r23877 by jghali - #%15972: Contents of colors, lines and fonts in combobox is not visible in dark mode

scribus-commit scribus-commit at lists.scribus.net
Thu Jun 4 15:44:11 UTC 2020


Author: jghali
Date: Thu Jun  4 15:44:11 2020
New Revision: 23877

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23877
Log:
#%15972: Contents of colors, lines and fonts in combobox is not visible in dark mode

Modified:
    trunk/Scribus/scribus/sclistboxpixmap.h
    trunk/Scribus/scribus/ui/fontcombo.cpp
    trunk/Scribus/scribus/ui/linecombo.cpp
    trunk/Scribus/scribus/ui/linecombo.h

Modified: trunk/Scribus/scribus/sclistboxpixmap.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23877&path=/trunk/Scribus/scribus/sclistboxpixmap.h
==============================================================================
--- trunk/Scribus/scribus/sclistboxpixmap.h	(original)
+++ trunk/Scribus/scribus/sclistboxpixmap.h	Thu Jun  4 15:44:11 2020
@@ -94,14 +94,13 @@
 		int yPos = (itemHeight - pmap->height()) / 2;
 		qpainter->drawPixmap(option.rect.x() + 3, option.rect.y() + yPos, *pmap);
 	}
+
 	if (option.state & QStyle::State_Selected)
-		qpainter->setBrush(option.palette.highlightedText());
+		qpainter->setPen(QPen(option.palette.highlightedText(), 0));
 	else
-		qpainter->setBrush(QBrush(Qt::black));
-	qpainter->setPen(Qt::black);
+		qpainter->setPen(QPen(option.palette.text(), 0));
 	
 	QString txt(index.data(Qt::DisplayRole).toString());
-
 	if (!txt.isEmpty())
 	{
 		QFontMetrics fm = qpainter->fontMetrics();

Modified: trunk/Scribus/scribus/ui/fontcombo.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23877&path=/trunk/Scribus/scribus/ui/fontcombo.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/fontcombo.cpp	(original)
+++ trunk/Scribus/scribus/ui/fontcombo.cpp	Thu Jun  4 15:44:11 2020
@@ -540,6 +540,8 @@
 	if (hasLatin)
 		font = font2;
 
+	pixPainter.setPen(QPen(option.palette.text(), 0));
+
 	invpixPainter.setBrush(option.palette.highlight());
 	invpixPainter.setPen(Qt::NoPen);
 	invpixPainter.drawRect(0, 0, option.rect.width(), option.rect.height());

Modified: trunk/Scribus/scribus/ui/linecombo.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23877&path=/trunk/Scribus/scribus/ui/linecombo.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/linecombo.cpp	(original)
+++ trunk/Scribus/scribus/ui/linecombo.cpp	Thu Jun  4 15:44:11 2020
@@ -21,6 +21,10 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <QEvent>
+#include <QPalette>
+#include <QSignalBlocker>
+
 #include "linecombo.h"
 #include "util.h"
 
@@ -40,12 +44,31 @@
 	updateList();
 }
 
+void LineCombo::changeEvent(QEvent *e)
+{
+	if (e->type() == QEvent::StyleChange)
+		styleChange();
+	else if (e->type() == QEvent::ThemeChange)
+		themeChange();
+	QComboBox::changeEvent(e);
+}
+
+void LineCombo::styleChange()
+{
+	QSignalBlocker sigBlocker(this);
+	for (int i = 0; i < 37; ++i)
+		setItemData(i, QIcon(createIcon(i)), Qt::DecorationRole);
+}
+
+void LineCombo::themeChange()
+{
+	styleChange();
+}
+
 void LineCombo::updateList()
 {
-	for (int a = 0; a < 37; a++)
-	{
-		addItem(QIcon(createIcon(a)), "");
-	}
+	for (int i = 0; i < 37; i++)
+		addItem(QIcon(createIcon(i)), QString());
 }
 
 QPixmap LineCombo::createIcon(int type)
@@ -63,7 +86,8 @@
 		getDashArray(type + 1, 1, m_array);
 		pen.setDashPattern(m_array);
 	}
-	pen.setColor(Qt::black);
+	const QPalette& pal = this->palette();
+	pen.setColor(pal.text().color());
 	pen.setWidth(3);
 	pen.setCapStyle(Qt::FlatCap);
 	p.setPen(pen);

Modified: trunk/Scribus/scribus/ui/linecombo.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23877&path=/trunk/Scribus/scribus/ui/linecombo.h
==============================================================================
--- trunk/Scribus/scribus/ui/linecombo.h	(original)
+++ trunk/Scribus/scribus/ui/linecombo.h	Thu Jun  4 15:44:11 2020
@@ -27,6 +27,8 @@
 #include <QComboBox>
 #include <QPixmap>
 
+class QEvent;
+
 #include "scribusapi.h"
 #include "sclistboxpixmap.h"
 
@@ -37,11 +39,19 @@
 class SCRIBUS_API LineCombo : public QComboBox
 {
 	Q_OBJECT
+
 public: 
 	LineCombo(QWidget* pa);
 	~LineCombo() {}
+
 	void updateList();
+
+protected:
 	QPixmap createIcon(int type);
+
+	void changeEvent(QEvent *e) override;
+	void styleChange();
+	void themeChange();
 };
 
 #endif




More information about the scribus-commit mailing list