1
0
Fork 0
forked from len0rd/rockbox

Theme Editor: Added font selection

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26650 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-07 07:57:56 +00:00
parent 4a9398e3fc
commit ffc1afc30d
5 changed files with 173 additions and 87 deletions

View file

@ -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<QFont>());
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 */

View file

@ -53,8 +53,10 @@ private:
void loadSettings();
void loadColors();
void loadFont();
void saveSettings();
void saveColors();
void saveFont();
void setupUI();

View file

@ -15,29 +15,56 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolBox" name="prefsGroups">
<widget class="QTabWidget" name="prefsGroups">
<property name="tabPosition">
<enum>QTabWidget::West</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="highlighting">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>352</width>
<height>288</height>
</rect>
</property>
<attribute name="label">
<string>Editor Colors</string>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Editor</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="fontSelect"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Size</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="fontSize">
<property name="value">
<number>12</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Foreground</string>
<string>Foreground Color</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
@ -47,10 +74,24 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="fgButton">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>Click To Change</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Background</string>
<string>Background Color</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
@ -60,6 +101,27 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bgButton">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>Click To Change</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="prefsGroupsPage1" native="true">
<attribute name="title">
<string>Highlighting</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
@ -73,69 +135,6 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Escaped Character</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>escapedButton</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Conditional</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>conditionalButton</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Tag</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>tagButton</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="fgButton">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>Click To Change</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bgButton">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>Click To Change</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="commentButton">
<property name="autoFillBackground">
@ -149,6 +148,23 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Escaped Character</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>escapedButton</cstring>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="escapedButton">
<property name="autoFillBackground">
@ -159,6 +175,23 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Conditional</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>conditionalButton</cstring>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="conditionalButton">
<property name="autoFillBackground">
@ -169,6 +202,23 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Tag</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>tagButton</cstring>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="tagButton">
<property name="autoFillBackground">
@ -206,8 +256,8 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
<x>257</x>
<y>360</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
@ -222,8 +272,8 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
<x>325</x>
<y>360</y>
</hint>
<hint type="destinationlabel">
<x>286</x>

View file

@ -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<QFont>();
family.setPointSize(settings.value("fontSize", 12).toInt());
editor->setFont(family);
editor->repaint();
settings.endGroup();

View file

@ -63,7 +63,7 @@ signals:
void titleChanged(QString);
public slots:
void colorsChanged();
void settingsChanged();
private slots:
void codeChanged();