X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatscene.cpp;fp=src%2Fqtui%2Fchatscene.cpp;h=dbe4220e4d7c2bb54388d32e222cb99f90518e4e;hp=188eba6c0b6baad84c100878355870a325c79563;hb=27fe4e6f46547c45d19fa39c175fa2104a5feb28;hpb=fdd99d12760219b082d3d68af2c8bb2f1863745f diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 188eba6c..dbe4220e 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -134,6 +134,9 @@ ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, qreal w _showSenderBrackets = defaultSettings.showSenderBrackets(); defaultSettings.notify("ShowSenderBrackets", this, SLOT(showSenderBracketsChanged())); + _useCustomTimestampFormat = defaultSettings.useCustomTimestampFormat(); + defaultSettings.notify("UseCustomTimestampFormat", this, SLOT(useCustomTimestampFormatChanged())); + _timestampFormatString = defaultSettings.timestampFormatString(); defaultSettings.notify("TimestampFormat", this, SLOT(timestampFormatStringChanged())); updateTimestampHasBrackets(); @@ -1346,6 +1349,13 @@ void ChatScene::showSenderBracketsChanged() _showSenderBrackets = settings.showSenderBrackets(); } +void ChatScene::useCustomTimestampFormatChanged() +{ + ChatViewSettings settings; + _useCustomTimestampFormat = settings.useCustomTimestampFormat(); + updateTimestampHasBrackets(); +} + void ChatScene::timestampFormatStringChanged() { ChatViewSettings settings; @@ -1357,23 +1367,29 @@ void ChatScene::updateTimestampHasBrackets() { // Calculate these parameters only as needed, rather than on-demand - // Does the timestamp format contain brackets? For example: - // Classic: "[hh:mm:ss]" - // Modern: " hh:mm:ss" - // - // Match groups of any opening or closing brackets - (), {}, [], <>, (>, {], etc: - // ^\s*[({[<].+[)}\]>]\s*$ - // [...] is a character group containing ... - // ^ matches start of string - // \s* matches any amount of whitespace - // [({[<] matches (, {, [, or < - // .+ matches one or more characters - // [)}\]>] matches ), }, ], or >, escaping the ] - // $ matches end of string - // Alternatively, if opening and closing brackets must be in pairs, use this: - // (^\s*\(.+\)\s*$)|(^\s*\{.+\}\s*$)|(^\s*\[.+\]\s*$)|(^\s*<.+>\s*$) - // Note that '\' must be escaped as '\\' - // Helpful interactive website for debugging and explaining: https://regex101.com/ - const QRegExp regExpMatchBrackets("^\\s*[({[<].+[)}\\]>]\\s*$"); - _timestampHasBrackets = regExpMatchBrackets.exactMatch(_timestampFormatString); + if (!_useCustomTimestampFormat) { + // The default timestamp format string does not have brackets, no need to check. + // If UiStyle::updateSystemTimestampFormat() has brackets added, change this, too. + _timestampHasBrackets = false; + } else { + // Does the timestamp format contain brackets? For example: + // Classic: "[hh:mm:ss]" + // Modern: " hh:mm:ss" + // + // Match groups of any opening or closing brackets - (), {}, [], <>, (>, {], etc: + // ^\s*[({[<].+[)}\]>]\s*$ + // [...] is a character group containing ... + // ^ matches start of string + // \s* matches any amount of whitespace + // [({[<] matches (, {, [, or < + // .+ matches one or more characters + // [)}\]>] matches ), }, ], or >, escaping the ] + // $ matches end of string + // Alternatively, if opening and closing brackets must be in pairs, use this: + // (^\s*\(.+\)\s*$)|(^\s*\{.+\}\s*$)|(^\s*\[.+\]\s*$)|(^\s*<.+>\s*$) + // Note that '\' must be escaped as '\\' + // Helpful interactive website for debugging and explaining: https://regex101.com/ + const QRegExp regExpMatchBrackets("^\\s*[({[<].+[)}\\]>]\\s*$"); + _timestampHasBrackets = regExpMatchBrackets.exactMatch(_timestampFormatString); + } }