From 53b619c6e80c9efc6993c23ff7b1035e8e101834 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Mon, 7 Jun 2010 03:25:40 +0000 Subject: Theme Editor: Added a preferences dialog and allowed modification of the syntax highlighting and editor colors git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26640 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/skindocument.cpp | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'utils/themeeditor/skindocument.cpp') diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp index efb16eeae1..fbb33cc366 100644 --- a/utils/themeeditor/skindocument.cpp +++ b/utils/themeeditor/skindocument.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -61,6 +62,14 @@ SkinDocument::~SkinDocument() delete model; } +void SkinDocument::connectPrefs(PreferencesDialog* prefs) +{ + QObject::connect(prefs, SIGNAL(accepted()), + this, SLOT(colorsChanged())); + QObject::connect(prefs, SIGNAL(accepted()), + highlighter, SLOT(loadSettings())); +} + bool SkinDocument::requestClose() { if(editor->document()->toPlainText() != saved) @@ -106,9 +115,7 @@ void SkinDocument::setupUI() setLayout(layout); /* Attaching the syntax highlighter */ - highlighter = new SkinHighlighter(QColor(0,180,0), QColor(255,0,0), - QColor(0,0,255), QColor(120,120,120), - editor->document()); + highlighter = new SkinHighlighter(editor->document()); /* Setting up the model */ model = new ParseTreeModel(""); @@ -116,6 +123,27 @@ void SkinDocument::setupUI() /* Connecting the editor's signal */ QObject::connect(editor, SIGNAL(textChanged()), this, SLOT(codeChanged())); + + colorsChanged(); +} + +void SkinDocument::colorsChanged() +{ + /* Setting the editor colors */ + QSettings settings; + settings.beginGroup("SkinDocument"); + + QColor fg = settings.value("fgColor", Qt::black).value(); + QColor bg = settings.value("bgColor", Qt::white).value(); + QPalette palette; + palette.setColor(QPalette::All, QPalette::Base, bg); + palette.setColor(QPalette::All, QPalette::Text, fg); + + editor->setPalette(palette); + editor->repaint(); + + settings.endGroup(); + } void SkinDocument::codeChanged() -- cgit v1.2.3