Skip to content

Commit

Permalink
Merge PR #3827: Add setting to toggle 24-hour time format for the chat
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebeatrici authored Oct 11, 2019
2 parents 909896d + cf99882 commit cf81dee
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/mumble/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ void LogConfig::load(const Settings &r) {
}

qsbMaxBlocks->setValue(r.iMaxLogBlocks);
qcb24HourClock->setChecked(r.bLog24HourClock);

#ifdef USE_NO_TTS
qtwMessages->hideColumn(ColTTS);
Expand Down Expand Up @@ -140,6 +141,7 @@ void LogConfig::save() const {
s.qmMessageSounds[mt] = i->text(ColStaticSoundPath);
}
s.iMaxLogBlocks = qsbMaxBlocks->value();
s.bLog24HourClock = qcb24HourClock->isChecked();

#ifndef USE_NO_TTS
s.iTTSVolume=qsVolume->value();
Expand Down Expand Up @@ -493,7 +495,10 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
} else if (! g.mw->qteLog->document()->isEmpty()) {
tc.insertBlock();
}
tc.insertHtml(Log::msgColor(QString::fromLatin1("[%1] ").arg(dt.time().toString().toHtmlEscaped()), Log::Time));

const QString timeString = dt.time().toString(QLatin1String(g.s.bLog24HourClock ? "HH:mm:ss" : "hh:mm:ss AP"));
tc.insertHtml(Log::msgColor(QString::fromLatin1("[%1] ").arg(timeString.toHtmlEscaped()), Log::Time));

validHtml(console, &tc);
tc.movePosition(QTextCursor::End);
g.mw->qteLog->setTextCursor(tc);
Expand Down
16 changes: 14 additions & 2 deletions src/mumble/Log.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>446</width>
<height>334</height>
<width>554</width>
<height>405</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -241,6 +241,18 @@
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="qcb24HourClock">
<property name="toolTip">
<string>If checked the time at the beginning of a message will be displayed in the 24-hour format.

The setting only applies for new messages, the already shown ones will retain the previous time format.</string>
</property>
<property name="text">
<string>Use 24-hour clock</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
3 changes: 3 additions & 0 deletions src/mumble/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ Settings::Settings() {
requireRestartToApply = false;

iMaxLogBlocks = 0;
bLog24HourClock = true;

bShortcutEnable = true;
bSuppressMacEventTapWarning = false;
Expand Down Expand Up @@ -753,6 +754,7 @@ void Settings::load(QSettings* settings_ptr) {
SAVELOAD(bShowTransmitModeComboBox, "ui/transmitmodecombobox");
SAVELOAD(bHighContrast, "ui/HighContrast");
SAVELOAD(iMaxLogBlocks, "ui/MaxLogBlocks");
SAVELOAD(bLog24HourClock, "ui/24HourClock");

// PTT Button window
SAVELOAD(bShowPTTButtonWindow, "ui/showpttbuttonwindow");
Expand Down Expand Up @@ -1089,6 +1091,7 @@ void Settings::save() {
SAVELOAD(bShowTransmitModeComboBox, "ui/transmitmodecombobox");
SAVELOAD(bHighContrast, "ui/HighContrast");
SAVELOAD(iMaxLogBlocks, "ui/MaxLogBlocks");
SAVELOAD(bLog24HourClock, "ui/24HourClock");

// PTT Button window
SAVELOAD(bShowPTTButtonWindow, "ui/showpttbuttonwindow");
Expand Down
1 change: 1 addition & 0 deletions src/mumble/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ struct Settings {

enum MessageLog { LogNone = 0x00, LogConsole = 0x01, LogTTS = 0x02, LogBalloon = 0x04, LogSoundfile = 0x08, LogHighlight = 0x10 };
int iMaxLogBlocks;
bool bLog24HourClock;
QMap<int, QString> qmMessageSounds;
QMap<int, quint32> qmMessages;

Expand Down

0 comments on commit cf81dee

Please sign in to comment.