+void UiStyle::updateSystemTimestampFormat()
+{
+ // Does the system locale use AM/PM designators? For example:
+ // AM/PM: h:mm AP
+ // AM/PM: hh:mm a
+ // 24-hour: h:mm
+ // 24-hour: hh:mm ADD things
+ // For timestamp format, see https://doc.qt.io/qt-5/qdatetime.html#toString
+ // This won't update if the system locale is changed while Quassel is running. If need be,
+ // Quassel could hook into notifications of changing system locale to update this.
+ //
+ // Match any AP or A designation if on a word boundary, including underscores.
+ // .*(\b|_)(A|AP)(\b|_).*
+ // .* Match any number of characters
+ // \b Match a word boundary, i.e. "AAA.BBB", "." is matched
+ // _ Match the literal character '_' (not considered a word boundary)
+ // (X|Y) Match either X or Y, exactly
+ //
+ // Note that '\' must be escaped as '\\'
+ // QRegExp does not support (?> ...), so it's replaced with standard matching, (...)
+ // Helpful interactive website for debugging and explaining: https://regex101.com/
+ const QRegExp regExpMatchAMPM(".*(\\b|_)(A|AP)(\\b|_).*", Qt::CaseInsensitive);
+
+ if (regExpMatchAMPM.exactMatch(QLocale::system().timeFormat(QLocale::ShortFormat))) {
+ // AM/PM style used
+ _systemTimestampFormatString = " h:mm:ss ap";
+ } else {
+ // 24-hour style used
+ _systemTimestampFormatString = " hh:mm:ss";
+ }
+ // Include a space to give the timestamp a small bit of padding between the border of the chat
+ // buffer window and the numbers. Helps with readability.
+ // If you change this to include brackets, e.g. "[hh:mm:ss]", also update
+ // ChatScene::updateTimestampHasBrackets() to true or false as needed!
+}
+
+
+// FIXME The following should trigger a reload/refresh of the chat view.
+void UiStyle::setUseCustomTimestampFormat(bool enabled)
+{
+ if (_useCustomTimestampFormat != enabled) {
+ _useCustomTimestampFormat = enabled;
+ }
+}
+