From ffc1afc30dc4343a3b1630c6b4ebd25570ac8d2d Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Mon, 7 Jun 2010 07:57:56 +0000 Subject: [PATCH] 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 | 216 +++++++++++++++--------- utils/themeeditor/skindocument.cpp | 12 +- utils/themeeditor/skindocument.h | 2 +- 5 files changed, 173 insertions(+), 87 deletions(-) diff --git a/utils/themeeditor/preferencesdialog.cpp b/utils/themeeditor/preferencesdialog.cpp index 4d3ad04495..79f781c1ca 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 a4adda47d1..7aadbade07 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 017e69dd01..5364fb4952 100644 --- a/utils/themeeditor/preferencesdialog.ui +++ b/utils/themeeditor/preferencesdialog.ui @@ -15,29 +15,56 @@ - + + + QTabWidget::West + 0 - - - - 0 - 0 - 352 - 288 - - - - Editor Colors + + + Editor - + - + + + + + Font + + + + + + + + + + + + + + Size + + + + + + + 12 + + + + + + + - Foreground + Foreground Color Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -47,10 +74,24 @@ + + + + false + + + Click To Change + + + + + + + - Background + Background Color Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -60,6 +101,27 @@ + + + + false + + + Click To Change + + + + + + + + + + Highlighting + + + + @@ -73,69 +135,6 @@ - - - - Escaped Character - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - escapedButton - - - - - - - Conditional - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - conditionalButton - - - - - - - Tag - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - tagButton - - - - - - - - - - - false - - - Click To Change - - - - - - - false - - - Click To Change - - - @@ -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 fbb33cc366..730d03a0a6 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 14a71e02a1..cf8f8a0313 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();