diff --git a/utils/themeeditor/graphics/rbfont.cpp b/utils/themeeditor/graphics/rbfont.cpp index e59c79a970..1c2739d118 100644 --- a/utils/themeeditor/graphics/rbfont.cpp +++ b/utils/themeeditor/graphics/rbfont.cpp @@ -27,6 +27,7 @@ #include #include #include +#include quint16 RBFont::maxFontSizeFor16BitOffsets = 0xFFDB; @@ -36,7 +37,19 @@ RBFont::RBFont(QString file) /* Attempting to locate the correct file name */ if(!QFile::exists(file)) - file = ":/fonts/08-Schumacher-Clean.fnt"; + { + /* Checking in the fonts repository */ + QSettings settings; + settings.beginGroup("RBFont"); + + file = file.split("/").last(); + file = settings.value("fontDir", "").toString() + "/" + file; + + settings.endGroup(); + + if(!QFile::exists(file)) + file = ":/fonts/08-Schumacher-Clean.fnt"; + } header.insert("filename", file); /* Opening the file */ diff --git a/utils/themeeditor/gui/preferencesdialog.cpp b/utils/themeeditor/gui/preferencesdialog.cpp index 8cd9665779..f8c71f4450 100644 --- a/utils/themeeditor/gui/preferencesdialog.cpp +++ b/utils/themeeditor/gui/preferencesdialog.cpp @@ -24,6 +24,7 @@ #include #include +#include PreferencesDialog::PreferencesDialog(QWidget *parent) : QDialog(parent), @@ -43,6 +44,7 @@ void PreferencesDialog::loadSettings() { loadColors(); loadFont(); + loadFontDir(); } void PreferencesDialog::loadColors() @@ -105,10 +107,21 @@ void PreferencesDialog::loadFont() } +void PreferencesDialog::loadFontDir() +{ + QSettings settings; + settings.beginGroup("RBFont"); + + ui->fontBox->setText(settings.value("fontDir", "/").toString()); + + settings.endGroup(); +} + void PreferencesDialog::saveSettings() { saveColors(); saveFont(); + saveFontDir(); } void PreferencesDialog::saveColors() @@ -146,6 +159,16 @@ void PreferencesDialog::saveFont() settings.endGroup(); } +void PreferencesDialog::saveFontDir() +{ + QSettings settings; + settings.beginGroup("RBFont"); + + settings.setValue("fontDir", ui->fontBox->text()); + + settings.endGroup(); +} + void PreferencesDialog::setupUI() { /* Connecting color buttons */ @@ -161,6 +184,9 @@ void PreferencesDialog::setupUI() for(int i = 0; i < buttons.count(); i++) QObject::connect(buttons[i], SIGNAL(pressed()), this, SLOT(colorClicked())); + + QObject::connect(ui->fontBrowseButton, SIGNAL(clicked()), + this, SLOT(browseFont())); } void PreferencesDialog::colorClicked() @@ -193,6 +219,14 @@ void PreferencesDialog::colorClicked() } } +void PreferencesDialog::browseFont() +{ + QString path = QFileDialog:: + getExistingDirectory(this, "Font Directory", + ui->fontBox->text()); + ui->fontBox->setText(path); +} + void PreferencesDialog::accept() { saveSettings(); diff --git a/utils/themeeditor/gui/preferencesdialog.h b/utils/themeeditor/gui/preferencesdialog.h index d717d04ab8..3df2409fd9 100644 --- a/utils/themeeditor/gui/preferencesdialog.h +++ b/utils/themeeditor/gui/preferencesdialog.h @@ -47,6 +47,7 @@ public slots: private slots: void colorClicked(); + void browseFont(); private: Ui::PreferencesDialog *ui; @@ -54,9 +55,11 @@ private: void loadSettings(); void loadColors(); void loadFont(); + void loadFontDir(); void saveSettings(); void saveColors(); void saveFont(); + void saveFontDir(); void setupUI(); diff --git a/utils/themeeditor/gui/preferencesdialog.ui b/utils/themeeditor/gui/preferencesdialog.ui index 7dddcf9057..15e1743138 100644 --- a/utils/themeeditor/gui/preferencesdialog.ui +++ b/utils/themeeditor/gui/preferencesdialog.ui @@ -23,9 +23,6 @@ QTabWidget::North - - 0 - Editor @@ -258,6 +255,37 @@ + + + Fonts + + + + + + + + Font Path + + + fontBox + + + + + + + + + + Browse... + + + + + + +