Fix issue #1237: White text on almost-white background
authorMichael Schuster <michael@schuster.ms>
Mon, 23 Dec 2019 13:29:34 +0000 (14:29 +0100)
committerMichael Schuster <48932272+misch7@users.noreply.github.com>
Tue, 24 Dec 2019 06:44:18 +0000 (07:44 +0100)
Signed-off-by: Michael Schuster <michael@schuster.ms>
src/gui/folderstatusdelegate.cpp

index 5cd2ed11870cb8e802b5568c2a06486d46a7ebfc..4b8899a05803e6a01d23a8a4c53ecd71bbe76449 100644 (file)
@@ -273,6 +273,11 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
         rect.setHeight(texts.count() * subFm.height() + 2 * margin);
         rect.setRight(option.rect.right() - margin);
 
+        // save previous state to not mess up colours with the background (fixes issue: https://github.com/nextcloud/desktop/issues/1237)
+        auto oldBrush = painter->brush();
+        auto oldPen = painter->pen();
+        auto oldFont = painter->font();
+
         painter->setBrush(color);
         painter->setPen(QColor(0xaa, 0xaa, 0xaa));
         painter->drawRoundedRect(QStyle::visualRect(option.direction, option.rect, rect),
@@ -290,6 +295,11 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
             textRect.translate(0, textRect.height());
         }
 
+        // restore previous state
+        painter->setBrush(oldBrush);
+        painter->setPen(oldPen);
+        painter->setFont(oldFont);
+
         h = rect.bottom() + margin;
     };