r15464 by craig - Fix scripter plugin preferences for colour settings

scribus-commit scribus-commit at lists.scribus.net
Thu Sep 2 22:40:52 CEST 2010


Author: craig
Date: Thu Sep  2 20:40:52 2010
New Revision: 15464

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15464
Log:
Fix scripter plugin preferences for colour settings

Modified:
    trunk/Scribus/scribus/plugins/scriptplugin/pconsole.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/prefs_scripter.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/prefs_scripter.h

Modified: trunk/Scribus/scribus/plugins/scriptplugin/pconsole.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15464&path=/trunk/Scribus/scribus/plugins/scriptplugin/pconsole.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/pconsole.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/pconsole.cpp Thu Sep  2 20:40:52 2010
@@ -350,21 +350,20 @@
 		stringColor.setNamedColor(prefs->get("syntaxstring", "#005500"));
 		textColor.setNamedColor(prefs->get("syntaxtext", "#000000"));
 	}
+	else
+	{
+		errorColor.setNamedColor("#aa0000");
+		commentColor.setNamedColor("#A0A0A0");
+		keywordColor.setNamedColor("#00007f");
+		signColor.setNamedColor("#aa00ff");
+		numberColor.setNamedColor("#ffaa00");
+		stringColor.setNamedColor("#005500");
+		textColor.setNamedColor("#000000");
+	}
 }
 
 SyntaxColors::~SyntaxColors()
 {
-	PrefsContext* prefs = PrefsManager::instance()->prefsFile->getPluginContext("scriptplugin");
-	if (prefs)
-	{
-		prefs->set("syntaxerror", qcolor2named(errorColor));
-		prefs->set("syntaxcomment", qcolor2named(commentColor));
-		prefs->set("syntaxkeyword", qcolor2named(keywordColor));
-		prefs->set("syntaxsign", qcolor2named(signColor));
-		prefs->set("syntaxnumber", qcolor2named(numberColor));
-		prefs->set("syntaxstring", qcolor2named(stringColor));
-		prefs->set("syntaxtext", qcolor2named(textColor));
-	}
 }
 
 QString SyntaxColors::qcolor2named(QColor color)

Modified: trunk/Scribus/scribus/plugins/scriptplugin/prefs_scripter.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15464&path=/trunk/Scribus/scribus/plugins/scriptplugin/prefs_scripter.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/prefs_scripter.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/prefs_scripter.cpp Thu Sep  2 20:40:52 2010
@@ -14,7 +14,9 @@
 
 #include "prefs_scripter.h"
 #include "scriptercore.h"
-#include "pconsole.h"
+#include "prefsfile.h"
+#include "prefscontext.h"
+#include "prefsmanager.h"
 #include "prefsstructs.h"
 
 Prefs_Scripter::Prefs_Scripter(QWidget* parent)
@@ -66,47 +68,72 @@
 	scripterCore->setExtensionsEnabled(extensionScriptsChk->isChecked());
 	scripterCore->setStartupScript(startupScriptEdit->text());
 	// colors
-	SyntaxColors *syntax = new SyntaxColors();
-	syntax->textColor = textButton->palette().color(QPalette::Window);
-	syntax->commentColor = commentButton->palette().color(QPalette::Window);
-	syntax->keywordColor = keywordButton->palette().color(QPalette::Window);
-	syntax->errorColor = errorButton->palette().color(QPalette::Window);
-	syntax->signColor = signButton->palette().color(QPalette::Window);
-	syntax->stringColor = stringButton->palette().color(QPalette::Window);
-	syntax->numberColor = numberButton->palette().color(QPalette::Window);
-	delete(syntax);
+	PrefsContext* prefs = PrefsManager::instance()->prefsFile->getPluginContext("scriptplugin");
+	if (prefs)
+	{
+		prefs->set("syntaxerror", errorColor.name());
+		prefs->set("syntaxcomment", commentColor.name());
+		prefs->set("syntaxkeyword", keywordColor.name());
+		prefs->set("syntaxsign", signColor.name());
+		prefs->set("syntaxnumber", numberColor.name());
+		prefs->set("syntaxstring", stringColor.name());
+		prefs->set("syntaxtext", textColor.name());
+	}
 }
 
 void Prefs_Scripter::setColor()
 {
-	QPalette palette;
 	QPushButton* button = (QPushButton*)sender();
 	QColor color = QColorDialog::getColor(button->palette().color(QPalette::Window), this);
-	if (color.isValid())
+	if (color.isValid() && button)
 	{
-		palette.setColor(button->backgroundRole(), color);
- 		button->setPalette(palette);
+		QPixmap pm(54, 14);
+		pm.fill(color);
+		button->setIcon(pm);
+		if (button==textButton)
+			textColor=color;
+		if (button==commentButton)
+			commentColor=color;
+		if (button==keywordButton)
+			keywordColor=color;
+		if (button==errorButton)
+			errorColor=color;
+		if (button==signButton)
+			signColor=color;
+		if (button==stringButton)
+			stringColor=color;
+		if (button==numberButton)
+			numberColor=color;
 	}
 }
 
 void Prefs_Scripter::setupSyntaxColors()
 {
-	QPalette palette;
 	SyntaxColors *syntax = new SyntaxColors();
-	palette.setColor(textButton->backgroundRole(), syntax->textColor);
- 	textButton->setPalette(palette);
-	palette.setColor(commentButton->backgroundRole(), syntax->commentColor);
- 	commentButton->setPalette(palette);
-	palette.setColor(keywordButton->backgroundRole(), syntax->keywordColor);
- 	keywordButton->setPalette(palette);
-	palette.setColor(errorButton->backgroundRole(), syntax->errorColor);
- 	errorButton->setPalette(palette);
-	palette.setColor(signButton->backgroundRole(), syntax->signColor);
- 	signButton->setPalette(palette);
-	palette.setColor(stringButton->backgroundRole(), syntax->stringColor);
- 	stringButton->setPalette(palette);
-	palette.setColor(numberButton->backgroundRole(), syntax->numberColor);
- 	numberButton->setPalette(palette);
+	textColor=syntax->textColor;
+	commentColor=syntax->commentColor;
+	keywordColor=syntax->keywordColor;
+	errorColor=syntax->errorColor;
+	signColor=syntax->signColor;
+	stringColor=syntax->stringColor;
+	numberColor=syntax->numberColor;
+
+	QPixmap pm(54, 14);
+	pm.fill(textColor);
+	textButton->setIcon(pm);
+	pm.fill(commentColor);
+	commentButton->setIcon(pm);
+	pm.fill(keywordColor);
+	keywordButton->setIcon(pm);
+	pm.fill(errorColor);
+	errorButton->setIcon(pm);
+	pm.fill(signColor);
+	signButton->setIcon(pm);
+	pm.fill(stringColor);
+	stringButton->setIcon(pm);
+	pm.fill(numberColor);
+	numberButton->setIcon(pm);
+
 	delete(syntax);
 }
 

Modified: trunk/Scribus/scribus/plugins/scriptplugin/prefs_scripter.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15464&path=/trunk/Scribus/scribus/plugins/scriptplugin/prefs_scripter.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/prefs_scripter.h (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/prefs_scripter.h Thu Sep  2 20:40:52 2010
@@ -10,6 +10,7 @@
 
 #include "ui_prefs_scripterbase.h"
 #include "ui/prefs_pane.h"
+#include "pconsole.h"
 
 class Prefs_Scripter : public Prefs_Pane, Ui::Prefs_Scripter
 {
@@ -29,6 +30,13 @@
 
 	protected:
 		void setupSyntaxColors();
+		QColor textColor;
+		QColor commentColor;
+		QColor keywordColor;
+		QColor errorColor;
+		QColor signColor;
+		QColor stringColor;
+		QColor numberColor;
 
 	protected slots:
 		/*! \brief All requests for color change are handled here.




More information about the scribus-commit mailing list