X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fuistyle.h;h=899ab9a71ad34b370eb457ae7a98ecebcde0478a;hp=7d1a8bcd285414d4b2565e12b431f943aa233749;hb=68878dc8366f2f4a0afe132847aad9a51a80cdbf;hpb=ac7a58dd970833da2336f6ce035ec55515bac0f1 diff --git a/src/uisupport/uistyle.h b/src/uisupport/uistyle.h index 7d1a8bcd..899ab9a7 100644 --- a/src/uisupport/uistyle.h +++ b/src/uisupport/uistyle.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -80,7 +81,7 @@ public: Bold = 0x00000100, Italic = 0x00000200, Underline = 0x00000400, - Reverse = 0x00000800, + Strikethrough = 0x00000800, // Individual parts of a message Timestamp = 0x00001000, @@ -127,6 +128,11 @@ public: Invalid = 0xffffffff }; + enum class FormatProperty { + AllowForegroundOverride = QTextFormat::UserProperty, + AllowBackgroundOverride + }; + enum class ColorRole { MarkerLine, // Sender colors (16 + self) @@ -158,6 +164,8 @@ public: struct Format { FormatType type; + QColor foreground; + QColor background; }; using FormatList = std::vector>; @@ -242,7 +250,7 @@ public: */ static QString timestampFormatString(); - QTextCharFormat format(FormatType formatType, MessageLabel messageLabel) const; + QTextCharFormat format(const Format &format, MessageLabel messageLabel) const; QFontMetricsF *fontMetrics(FormatType formatType, MessageLabel messageLabel) const; QList toTextLayoutList(const FormatList &, int textLength, MessageLabel messageLabel) const; @@ -263,11 +271,12 @@ protected: void loadStyleSheet(); QString loadStyleSheet(const QString &name, bool shouldExist = false); - QTextCharFormat format(quint64 key) const; - QTextCharFormat cachedFormat(FormatType formatType, MessageLabel messageLabel) const; - void setCachedFormat(const QTextCharFormat &format, FormatType formatType, MessageLabel messageLabel) const; - void mergeFormat(QTextCharFormat &format, FormatType formatType, MessageLabel messageLabel) const; - void mergeSubElementFormat(QTextCharFormat &format, FormatType formatType, MessageLabel messageLabel) const; + QTextCharFormat parsedFormat(quint64 key) const; + QTextCharFormat cachedFormat(const Format &format, MessageLabel messageLabel) const; + void setCachedFormat(const QTextCharFormat &charFormat, const Format &format, MessageLabel messageLabel) const; + void mergeFormat(QTextCharFormat &charFormat, const Format &format, MessageLabel messageLabel) const; + void mergeSubElementFormat(QTextCharFormat &charFormat, FormatType formatType, MessageLabel messageLabel) const; + void mergeColors(QTextCharFormat &charFormat, const Format &format, MessageLabel messageLabel) const; static FormatType formatType(const QString &code); static QString formatCode(FormatType); @@ -319,7 +328,7 @@ private: QVector _uiStylePalette; QBrush _markerLineBrush; QHash _formats; - mutable QHash _formatCache; + mutable QHash _formatCache; mutable QHash _metricsCache; QHash _listItemFormats; static QHash _formatCodes;