_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();
if (webPreview.previewItem && webPreview.previewItem->scene())
removeItem(webPreview.previewItem);
// Fall through to deletion!
+ [[fallthrough]];
case WebPreview::HidePreview:
if (webPreview.previewItem) {
delete webPreview.previewItem;
removeItem(webPreview.previewItem);
}
// fall through into to set hidden state
+ [[fallthrough]];
case WebPreview::DelayPreview:
// we're just loading, so haven't shown the preview yet.
webPreview.previewState = WebPreview::HidePreview;
_showSenderBrackets = settings.showSenderBrackets();
}
+void ChatScene::useCustomTimestampFormatChanged()
+{
+ ChatViewSettings settings;
+ _useCustomTimestampFormat = settings.useCustomTimestampFormat();
+ updateTimestampHasBrackets();
+}
+
void ChatScene::timestampFormatStringChanged()
{
ChatViewSettings settings;
{
// 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);
+ }
}