r24511 by jghali - #16479: Story editor does not follow dark theme

scribus-commit scribus-commit at lists.scribus.net
Thu Feb 18 19:02:27 UTC 2021


Author: jghali
Date: Thu Feb 18 19:02:27 2021
New Revision: 24511

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24511
Log:
#16479: Story editor does not follow dark theme

Modified:
    trunk/Scribus/scribus/prefsmanager.cpp
    trunk/Scribus/scribus/ui/prefs_userinterface.cpp
    trunk/Scribus/scribus/ui/storyeditor.cpp

Modified: trunk/Scribus/scribus/prefsmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24511&path=/trunk/Scribus/scribus/prefsmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.cpp	(original)
+++ trunk/Scribus/scribus/prefsmanager.cpp	Thu Feb 18 19:02:27 2021
@@ -392,7 +392,9 @@
 	appPrefs.extToolPrefs.gs_exe = getGSDefaultExeName();
 	appPrefs.extToolPrefs.gs_Resolution = 72;
 
-	appPrefs.storyEditorPrefs.guiFontColorBackground = QColor(Qt::white);
+	// Do not override default text background color in story editor unless user has explicitly modified it.
+	// To do that, we initialize text background color to an invalid color and test its validity in the code. 
+	appPrefs.storyEditorPrefs.guiFontColorBackground = QColor() /*qApp->palette().color(QPalette::Active, QPalette::Base)*/;
 	appPrefs.storyEditorPrefs.smartTextSelection = false;
 
 	appPrefs.colorPrefs.DCMSset.DefaultMonitorProfile.clear();
@@ -1468,7 +1470,8 @@
 
 	QDomElement deSE = docu.createElement("StoryEditor");
 	deSE.setAttribute("Font", appPrefs.storyEditorPrefs.guiFont);
-	deSE.setAttribute("FontColorBackground", appPrefs.storyEditorPrefs.guiFontColorBackground.name());
+	if (appPrefs.storyEditorPrefs.guiFontColorBackground.isValid())
+		deSE.setAttribute("FontColorBackground", appPrefs.storyEditorPrefs.guiFontColorBackground.name());
 	deSE.setAttribute("SmartTextSelection", static_cast<int>(appPrefs.storyEditorPrefs.smartTextSelection));
 	elem.appendChild(deSE);
 
@@ -2157,7 +2160,12 @@
 		if (dc.tagName() == "StoryEditor")
 		{
 			appPrefs.storyEditorPrefs.guiFont  = dc.attribute("Font", "");
-			appPrefs.storyEditorPrefs.guiFontColorBackground  = QColor(dc.attribute("FontColorBackground", "#FFFFFF"));
+			if (dc.hasAttribute("FontColorBackground"))
+			{
+				QString colorName = dc.attribute("FontColorBackground");
+				if (QColor::isValidColor(colorName))
+					appPrefs.storyEditorPrefs.guiFontColorBackground  = QColor(colorName);
+			}
 			appPrefs.storyEditorPrefs.smartTextSelection = static_cast<bool>(dc.attribute("SmartTextSelection", "0").toInt());
 		}
 		if (dc.tagName() == "Typography")

Modified: trunk/Scribus/scribus/ui/prefs_userinterface.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24511&path=/trunk/Scribus/scribus/ui/prefs_userinterface.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_userinterface.cpp	(original)
+++ trunk/Scribus/scribus/ui/prefs_userinterface.cpp	Thu Feb 18 19:02:27 2021
@@ -109,7 +109,10 @@
 	seFont.fromString(prefsData->storyEditorPrefs.guiFont);
 	storyEditorFontPushButton->setText(seFont.family());
 	QPixmap pm(100, 30);
-	pm.fill(prefsData->storyEditorPrefs.guiFontColorBackground);
+	QColor backgroundColor = prefsData->storyEditorPrefs.guiFontColorBackground;
+	if (!backgroundColor.isValid())
+		backgroundColor = this->palette().color(QPalette::Active, QPalette::Base);
+	pm.fill(backgroundColor);
 	seFontColor = prefsData->storyEditorPrefs.guiFontColorBackground;
 	storyEditorFontColorPushButton->setIcon(pm);
 }
@@ -131,7 +134,8 @@
 	prefsData->uiPrefs.useSmallWidgets = useSmallWidgetsCheckBox->isChecked();
 
 	prefsData->storyEditorPrefs.guiFont = seFont.toString();
-	prefsData->storyEditorPrefs.guiFontColorBackground = seFontColor;
+	if (seFontColor.isValid())
+		prefsData->storyEditorPrefs.guiFontColorBackground = seFontColor;
 	prefsData->storyEditorPrefs.smartTextSelection = storyEditorUseSmartSelectionCheckBox->isChecked();
 }
 
@@ -144,9 +148,14 @@
 
 void Prefs_UserInterface::changeStoryEditorFontColor()
 {
-	QColor newColor(QColorDialog::getColor(seFontColor, this));
+	QColor fontBkgndColor = seFontColor;
+	if (!fontBkgndColor.isValid())
+		fontBkgndColor = this->palette().color(QPalette::Active, QPalette::Base);
+
+	QColor newColor(QColorDialog::getColor(fontBkgndColor, this));
 	if (!newColor.isValid())
 		return;
+
 	QPixmap pm(100, 30);
 	pm.fill(newColor);
 	seFontColor = newColor;

Modified: trunk/Scribus/scribus/ui/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24511&path=/trunk/Scribus/scribus/ui/storyeditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/storyeditor.cpp	(original)
+++ trunk/Scribus/scribus/ui/storyeditor.cpp	Thu Feb 18 19:02:27 2021
@@ -2000,12 +2000,15 @@
 	QFont fo;
 	fo.fromString(prefsManager.appPrefs.storyEditorPrefs.guiFont);
 	Editor->setFont(fo);
-	QPalette pal;
 	QColor newColor(prefsManager.appPrefs.storyEditorPrefs.guiFontColorBackground);
-	pal.setColor(QPalette::Active, QPalette::Base, newColor);
-	pal.setColor(QPalette::Inactive, QPalette::Base, newColor);
-	pal.setColor(QPalette::Disabled, QPalette::Base, newColor);
-	Editor->setPalette(pal);
+	if (newColor.isValid())
+	{
+		QPalette pal;
+		pal.setColor(QPalette::Active, QPalette::Base, newColor);
+		pal.setColor(QPalette::Inactive, QPalette::Base, newColor);
+		pal.setColor(QPalette::Disabled, QPalette::Base, newColor);
+		Editor->setPalette(pal);
+	}
 	EditorBar->setFrameStyle(Editor->frameStyle());
 	EditorBar->setLineWidth(Editor->lineWidth());
 }




More information about the scribus-commit mailing list