forked from len0rd/rockbox
Theme Editor: Added font directory option in preferences dialog, renderer will now search that directory for fonts if they're not found in the project directory
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27322 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
120f3e1c10
commit
eccc2bd009
4 changed files with 82 additions and 4 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
quint16 RBFont::maxFontSizeFor16BitOffsets = 0xFFDB;
|
quint16 RBFont::maxFontSizeFor16BitOffsets = 0xFFDB;
|
||||||
|
|
||||||
|
@ -35,8 +36,20 @@ RBFont::RBFont(QString file)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Attempting to locate the correct file name */
|
/* Attempting to locate the correct file name */
|
||||||
|
if(!QFile::exists(file))
|
||||||
|
{
|
||||||
|
/* 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))
|
if(!QFile::exists(file))
|
||||||
file = ":/fonts/08-Schumacher-Clean.fnt";
|
file = ":/fonts/08-Schumacher-Clean.fnt";
|
||||||
|
}
|
||||||
header.insert("filename", file);
|
header.insert("filename", file);
|
||||||
|
|
||||||
/* Opening the file */
|
/* Opening the file */
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
PreferencesDialog::PreferencesDialog(QWidget *parent) :
|
PreferencesDialog::PreferencesDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
@ -43,6 +44,7 @@ void PreferencesDialog::loadSettings()
|
||||||
{
|
{
|
||||||
loadColors();
|
loadColors();
|
||||||
loadFont();
|
loadFont();
|
||||||
|
loadFontDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::loadColors()
|
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()
|
void PreferencesDialog::saveSettings()
|
||||||
{
|
{
|
||||||
saveColors();
|
saveColors();
|
||||||
saveFont();
|
saveFont();
|
||||||
|
saveFontDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::saveColors()
|
void PreferencesDialog::saveColors()
|
||||||
|
@ -146,6 +159,16 @@ void PreferencesDialog::saveFont()
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::saveFontDir()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
settings.beginGroup("RBFont");
|
||||||
|
|
||||||
|
settings.setValue("fontDir", ui->fontBox->text());
|
||||||
|
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
void PreferencesDialog::setupUI()
|
void PreferencesDialog::setupUI()
|
||||||
{
|
{
|
||||||
/* Connecting color buttons */
|
/* Connecting color buttons */
|
||||||
|
@ -161,6 +184,9 @@ void PreferencesDialog::setupUI()
|
||||||
for(int i = 0; i < buttons.count(); i++)
|
for(int i = 0; i < buttons.count(); i++)
|
||||||
QObject::connect(buttons[i], SIGNAL(pressed()),
|
QObject::connect(buttons[i], SIGNAL(pressed()),
|
||||||
this, SLOT(colorClicked()));
|
this, SLOT(colorClicked()));
|
||||||
|
|
||||||
|
QObject::connect(ui->fontBrowseButton, SIGNAL(clicked()),
|
||||||
|
this, SLOT(browseFont()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::colorClicked()
|
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()
|
void PreferencesDialog::accept()
|
||||||
{
|
{
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
|
|
@ -47,6 +47,7 @@ public slots:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void colorClicked();
|
void colorClicked();
|
||||||
|
void browseFont();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::PreferencesDialog *ui;
|
Ui::PreferencesDialog *ui;
|
||||||
|
@ -54,9 +55,11 @@ private:
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
void loadColors();
|
void loadColors();
|
||||||
void loadFont();
|
void loadFont();
|
||||||
|
void loadFontDir();
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
void saveColors();
|
void saveColors();
|
||||||
void saveFont();
|
void saveFont();
|
||||||
|
void saveFontDir();
|
||||||
|
|
||||||
void setupUI();
|
void setupUI();
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,6 @@
|
||||||
<property name="tabPosition">
|
<property name="tabPosition">
|
||||||
<enum>QTabWidget::North</enum>
|
<enum>QTabWidget::North</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="tab_2">
|
<widget class="QWidget" name="tab_2">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Editor</string>
|
<string>Editor</string>
|
||||||
|
@ -258,6 +255,37 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Fonts</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_10">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font Path</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>fontBox</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="fontBox"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="fontBrowseButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Browse...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue