Stylesheetify the marker line color
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 30 Jul 2009 08:39:50 +0000 (10:39 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 6 Aug 2009 18:25:58 +0000 (20:25 +0200)
This is now treated as a new palette role "marker-line" and can be set in
a Palette {} section as follows:

Palette { marker-line: #123456; }

src/qtui/chatline.cpp
src/uisupport/qssparser.cpp
src/uisupport/qssparser.h
src/uisupport/uistyle.cpp
src/uisupport/uistyle.h

index f6ea50f..3c68c4b 100644 (file)
@@ -186,9 +186,8 @@ void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
       BufferId bufferId = BufferId(chatScene()->idString().toInt());
       MsgId lastSeenMsgId = Client::networkModel()->lastSeenMarkerMsgId(bufferId);
       if(lastSeenMsgId < myMsgId && lastSeenMsgId >= prevMsgId) {
-        QtUiStyleSettings s("Colors");
         QLinearGradient gradient(0, 0, 0, contentsItem().fontMetrics()->lineSpacing());
-        gradient.setColorAt(0, s.value("newMsgMarkerFG", QColor(Qt::red)).value<QColor>());
+        gradient.setColorAt(0, QtUi::style()->markerLineBrush().color()); // FIXME: Use full (gradient?) brush instead of just the color
         gradient.setColorAt(0.1, Qt::transparent);
         painter->fillRect(boundingRect(), gradient);
       }
index b0e84b8..8234404 100644 (file)
@@ -302,6 +302,13 @@ void QssParser::parsePaletteData(const QString &decl, const QString &contents) {
     }
     QString rolestr = line.left(idx).trimmed();
     QString brushstr = line.mid(idx + 1).trimmed();
+
+    // We treat the marker line color as a palette role even though it isn't -> special casing
+    if(rolestr == "marker-line") {
+      _markerLineBrush = parseBrush(brushstr);
+      continue;
+    }
+
     if(!_paletteColorRoles.contains(rolestr)) {
       qWarning() << Q_FUNC_INFO << tr("Unknown palette role name: %1").arg(rolestr);
       continue;
index c92b406..e006955 100644 (file)
@@ -33,6 +33,7 @@ class QssParser {
 
     inline QPalette palette() const { return _palette; }
     inline const QHash<quint64, QTextCharFormat>& formats() const { return _formats; }
+    inline QBrush markerLineBrush() const { return _markerLineBrush; }
 
   protected:
     typedef QList<qreal> ColorTuple;
@@ -63,6 +64,7 @@ class QssParser {
   private:
     QPalette _palette;
     QHash<quint64, QTextCharFormat> _formats;
+    QBrush _markerLineBrush;
     int _maxSenderHash;
 };
 
index 1a478f2..3ab08f4 100644 (file)
@@ -81,6 +81,7 @@ void UiStyle::loadStyleSheet() {
     QssParser parser;
     parser.processStyleSheet(styleSheet);
     QApplication::setPalette(parser.palette());
+    _markerLineBrush = parser.markerLineBrush();
 
     QTextCharFormat baseFmt = parser.formats().value(Base);
     foreach(quint64 fmtType, parser.formats().keys()) {
index 843d2f2..3342aa4 100644 (file)
@@ -113,6 +113,7 @@ public:
   QFontMetricsF *fontMetrics(quint32 formatType, quint32 messageLabel = 0);
 
   inline QFont defaultFont() const { return _defaultFont; }
+  inline QBrush markerLineBrush() const { return _markerLineBrush; }
 
   QList<QTextLayout::FormatRange> toTextLayoutList(const FormatList &, int textLength, quint32 messageLabel = 0);
 
@@ -138,6 +139,7 @@ protected:
 
 private:
   QFont _defaultFont;
+  QBrush _markerLineBrush;
   QHash<quint64, QTextCharFormat> _formatCache;
   QHash<quint64, QFontMetricsF *> _metricsCache;
   static QHash<QString, FormatType> _formatCodes;