From ffc1afc30dc4343a3b1630c6b4ebd25570ac8d2d Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Mon, 7 Jun 2010 07:57:56 +0000 Subject: Theme Editor: Added font selection git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26650 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/preferencesdialog.cpp | 28 +++++ utils/themeeditor/preferencesdialog.h | 2 + utils/themeeditor/preferencesdialog.ui | 184 ++++++++++++++++++++------------ utils/themeeditor/skindocument.cpp | 12 ++- utils/themeeditor/skindocument.h | 2 +- 5 files changed, 157 insertions(+), 71 deletions(-) diff --git a/utils/themeeditor/preferencesdialog.cpp b/utils/themeeditor/preferencesdialog.cpp index 4d3ad04..79f781c 100644 --- a/utils/themeeditor/preferencesdialog.cpp +++ b/utils/themeeditor/preferencesdialog.cpp @@ -42,6 +42,7 @@ PreferencesDialog::~PreferencesDialog() void PreferencesDialog::loadSettings() { loadColors(); + loadFont(); } void PreferencesDialog::loadColors() @@ -83,9 +84,25 @@ void PreferencesDialog::loadColors() settings.endGroup(); } +void PreferencesDialog::loadFont() +{ + QSettings settings; + settings.beginGroup("SkinDocument"); + + QVariant family = settings.value("fontFamily", QFont()); + int size = settings.value("fontSize", 12).toInt(); + + settings.endGroup(); + + ui->fontSelect->setCurrentFont(family.value()); + ui->fontSize->setValue(size); + +} + void PreferencesDialog::saveSettings() { saveColors(); + saveFont(); } void PreferencesDialog::saveColors() @@ -111,6 +128,17 @@ void PreferencesDialog::saveColors() settings.endGroup(); } +void PreferencesDialog::saveFont() +{ + QSettings settings; + settings.beginGroup("SkinDocument"); + + settings.setValue("fontFamily", ui->fontSelect->currentFont()); + settings.setValue("fontSize", ui->fontSize->value()); + + settings.endGroup(); +} + void PreferencesDialog::setupUI() { /* Connecting color buttons */ diff --git a/utils/themeeditor/preferencesdialog.h b/utils/themeeditor/preferencesdialog.h index a4adda4..7aadbad 100644 --- a/utils/themeeditor/preferencesdialog.h +++ b/utils/themeeditor/preferencesdialog.h @@ -53,8 +53,10 @@ private: void loadSettings(); void loadColors(); + void loadFont(); void saveSettings(); void saveColors(); + void saveFont(); void setupUI(); diff --git a/utils/themeeditor/preferencesdialog.ui b/utils/themeeditor/preferencesdialog.ui index 017e69d..5364fb4 100644 --- a/utils/themeeditor/preferencesdialog.ui +++ b/utils/themeeditor/preferencesdialog.ui @@ -15,109 +15,94 @@ - + + + QTabWidget::West + 0 - - - - 0 - 0 - 352 - 288 - - - - Editor Colors + + + Editor - + - + - + - Foreground - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - fgButton + Font - + + + + + + + + - Background - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - bgButton + Size - - - Comment - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - commentButton + + + 12 + + + + - + - Escaped Character + Foreground Color Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - escapedButton + fgButton - - - Conditional - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false - - conditionalButton + + Click To Change + + + + - + - Tag + Background Color Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - tagButton + bgButton - - - - - + false @@ -126,13 +111,27 @@ + + + + + + + Highlighting + + + + - - - false - + - Click To Change + Comment + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + commentButton @@ -149,6 +148,23 @@ + + + + + + + + Escaped Character + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + escapedButton + + + @@ -159,6 +175,23 @@ + + + + + + + + Conditional + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + conditionalButton + + + @@ -169,6 +202,23 @@ + + + + + + + + Tag + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + tagButton + + + @@ -206,8 +256,8 @@ accept() - 248 - 254 + 257 + 360 157 @@ -222,8 +272,8 @@ reject() - 316 - 260 + 325 + 360 286 diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp index fbb33cc..730d03a 100644 --- a/utils/themeeditor/skindocument.cpp +++ b/utils/themeeditor/skindocument.cpp @@ -65,7 +65,7 @@ SkinDocument::~SkinDocument() void SkinDocument::connectPrefs(PreferencesDialog* prefs) { QObject::connect(prefs, SIGNAL(accepted()), - this, SLOT(colorsChanged())); + this, SLOT(settingsChanged())); QObject::connect(prefs, SIGNAL(accepted()), highlighter, SLOT(loadSettings())); } @@ -124,10 +124,10 @@ void SkinDocument::setupUI() QObject::connect(editor, SIGNAL(textChanged()), this, SLOT(codeChanged())); - colorsChanged(); + settingsChanged(); } -void SkinDocument::colorsChanged() +void SkinDocument::settingsChanged() { /* Setting the editor colors */ QSettings settings; @@ -140,6 +140,12 @@ void SkinDocument::colorsChanged() palette.setColor(QPalette::All, QPalette::Text, fg); editor->setPalette(palette); + + /* Setting the font */ + QFont family = settings.value("fontFamily", QFont()).value(); + family.setPointSize(settings.value("fontSize", 12).toInt()); + editor->setFont(family); + editor->repaint(); settings.endGroup(); diff --git a/utils/themeeditor/skindocument.h b/utils/themeeditor/skindocument.h index 14a71e0..cf8f8a0 100644 --- a/utils/themeeditor/skindocument.h +++ b/utils/themeeditor/skindocument.h @@ -63,7 +63,7 @@ signals: void titleChanged(QString); public slots: - void colorsChanged(); + void settingsChanged(); private slots: void codeChanged(); -- cgit v1.1