The style engine now reads the timestamp format string from the ChatView settings.
This means all that's missing now is a settingspage that offers an UI for changing
the string.
inline bool showWebPreview() { return localValue("ShowWebPreview", true).toBool(); }
inline void enableWebPreview(bool enabled) { setLocalValue("ShowWebPreview", enabled); }
+
+ inline QString timestampFormatString() { return localValue("TimestampFormat", "[hh:mm:ss]").toString(); }
+ inline void setTimestampFormatString(const QString &format) { setLocalValue("TimestampFormat", format); }
};
Q_DECLARE_METATYPE(ChatViewSettings::OperationMode);
#endif //CHATVIEWSETTINGS_H
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include "chatviewsettings.h"
#include "qtuistyle.h"
#include "qtuisettings.h"
QtUiStyle::QtUiStyle(QObject *parent) : UiStyle(parent) {
-
+ ChatViewSettings s;
+ s.notify("TimestampFormat", this, SLOT(updateTimestampFormatString()));
+ updateTimestampFormatString();
}
QtUiStyle::~QtUiStyle() {}
+
+void QtUiStyle::updateTimestampFormatString() {
+ ChatViewSettings s;
+ setTimestampFormatString(s.timestampFormatString());
+}
virtual inline qreal firstColumnSeparator() const { return 6; }
virtual inline qreal secondColumnSeparator() const { return 6; }
+private slots:
+ void updateTimestampFormatString();
+
};
#endif
#include "util.h"
QHash<QString, UiStyle::FormatType> UiStyle::_formatCodes;
+QString UiStyle::_timestampFormatString;
UiStyle::UiStyle(QObject *parent) : QObject(parent) {
// register FormatList if that hasn't happened yet
_formatCodes["%DM"] = ModeFlags;
_formatCodes["%DU"] = Url;
+ setTimestampFormatString("[hh:mm:ss]");
loadStyleSheet();
}
return ss;
}
+void UiStyle::setTimestampFormatString(const QString &format) {
+ if(_timestampFormatString != format) {
+ _timestampFormatString = format;
+ // FIXME reload
+ }
+}
+
/******** Caching *******/
QTextCharFormat UiStyle::cachedFormat(quint64 key) const {
}
QString UiStyle::StyledMessage::decoratedTimestamp() const {
- return QString("[%1]").arg(timestamp().toLocalTime().toString("hh:mm:ss"));
+ return timestamp().toLocalTime().toString(UiStyle::timestampFormatString());
}
QString UiStyle::StyledMessage::plainSender() const {
static FormatType formatType(Message::Type msgType);
static StyledString styleString(const QString &string, quint32 baseFormat = None);
static QString mircToInternal(const QString &);
+ static inline QString timestampFormatString() { return _timestampFormatString; }
QTextCharFormat format(quint32 formatType, quint32 messageLabel = 0);
QFontMetricsF *fontMetrics(quint32 formatType, quint32 messageLabel = 0);
static FormatType formatType(const QString &code);
static QString formatCode(FormatType);
+ static void setTimestampFormatString(const QString &format);
private:
QFont _defaultFont;
QHash<quint64, QTextCharFormat> _formatCache;
QHash<quint64, QFontMetricsF *> _metricsCache;
static QHash<QString, FormatType> _formatCodes;
+ static QString _timestampFormatString;
};
class UiStyle::StyledMessage : public Message {
quint8 senderHash() const;
protected:
- //! Styling is only needed for calls to plainContents() and contentsFormatList()
void style() const;
-
private:
mutable StyledString _contents;
mutable quint8 _senderHash;