Work on skins. First implementation ready.
This commit is contained in:
parent
d995782668
commit
6ef18d1477
6 changed files with 181 additions and 71 deletions
|
@ -78,6 +78,8 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form
|
||||||
this, SLOT(displayProxyPassword(int)));
|
this, SLOT(displayProxyPassword(int)));
|
||||||
connect(m_ui->m_btnBrowserProgressColor, SIGNAL(clicked()),
|
connect(m_ui->m_btnBrowserProgressColor, SIGNAL(clicked()),
|
||||||
this, SLOT(changeBrowserProgressColor()));
|
this, SLOT(changeBrowserProgressColor()));
|
||||||
|
connect(m_ui->m_treeSkins, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
|
||||||
|
this, SLOT(onSkinSelected(QTreeWidgetItem*,QTreeWidgetItem*)));
|
||||||
|
|
||||||
// Load all settings.
|
// Load all settings.
|
||||||
loadGeneral();
|
loadGeneral();
|
||||||
|
@ -92,6 +94,16 @@ FormSettings::~FormSettings() {
|
||||||
delete m_ui;
|
delete m_ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormSettings::onSkinSelected(QTreeWidgetItem *current,
|
||||||
|
QTreeWidgetItem *previous) {
|
||||||
|
Q_UNUSED(previous);
|
||||||
|
|
||||||
|
if (current != NULL) {
|
||||||
|
Skin skin = current->data(0, Qt::UserRole).value<Skin>();
|
||||||
|
m_ui->m_lblSelectedContents->setText(skin.m_visibleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FormSettings::changeBrowserProgressColor() {
|
void FormSettings::changeBrowserProgressColor() {
|
||||||
QColorDialog color_dialog(m_initialSettings.m_webBrowserProgress, this);
|
QColorDialog color_dialog(m_initialSettings.m_webBrowserProgress, this);
|
||||||
color_dialog.setWindowTitle(tr("Select color for web browser progress bar"));
|
color_dialog.setWindowTitle(tr("Select color for web browser progress bar"));
|
||||||
|
@ -397,28 +409,36 @@ void FormSettings::loadInterface() {
|
||||||
m_ui->m_cmbIconTheme->setCurrentIndex(theme_index);
|
m_ui->m_cmbIconTheme->setCurrentIndex(theme_index);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Load skin.
|
// Load skin.
|
||||||
QList<Skin> installed_skins = SkinFactory::getInstance()->getInstalledSkins();
|
QList<Skin> installed_skins = SkinFactory::getInstance()->getInstalledSkins();
|
||||||
QString active_skin = SkinFactory::getInstance()->getCurrentSkinName();
|
QString selected_skin = SkinFactory::getInstance()->getSelectedSkinName();
|
||||||
|
QString active_skin = SkinFactory::getInstance()->getCurrentSkinName();
|
||||||
|
|
||||||
foreach (Skin skin, installed_skins) {
|
foreach (Skin skin, installed_skins) {
|
||||||
QTreeWidgetItem *new_item = new QTreeWidgetItem(QStringList() <<
|
QTreeWidgetItem *new_item = new QTreeWidgetItem(QStringList() <<
|
||||||
skin.m_visibleName <<
|
skin.m_visibleName <<
|
||||||
skin.m_version <<
|
skin.m_version <<
|
||||||
skin.m_author <<
|
skin.m_author <<
|
||||||
skin.m_email);
|
skin.m_email);
|
||||||
new_item->setData(0, Qt::UserRole, QVariant::fromValue(skin));
|
new_item->setData(0, Qt::UserRole, QVariant::fromValue(skin));
|
||||||
|
|
||||||
// Add this skin and mark it as active if its active now.
|
// Add this skin and mark it as active if its active now.
|
||||||
m_ui->m_treeSkins->addTopLevelItem(new_item);
|
m_ui->m_treeSkins->addTopLevelItem(new_item);
|
||||||
|
|
||||||
if (skin.m_baseName == active_skin) {
|
if (skin.m_baseName == selected_skin) {
|
||||||
m_ui->m_treeSkins->setCurrentItem(new_item);
|
m_ui->m_treeSkins->setCurrentItem(new_item);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_ui->m_treeSkins->currentItem() == NULL) {
|
||||||
|
// No skin is selected or currently selected skin is unavailable.
|
||||||
|
m_ui->m_treeSkins->setCurrentItem(m_ui->m_treeSkins->topLevelItem(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ui->m_lblActiveContents->setText(SkinFactory::getInstance()->getSkinInfo(active_skin).m_visibleName);
|
||||||
|
|
||||||
// Load tab settings.
|
// Load tab settings.
|
||||||
m_ui->m_checkCloseTabsMiddleClick->setChecked(settings->value(APP_CFG_GUI,
|
m_ui->m_checkCloseTabsMiddleClick->setChecked(settings->value(APP_CFG_GUI,
|
||||||
"tab_close_mid_button",
|
"tab_close_mid_button",
|
||||||
|
|
|
@ -32,6 +32,7 @@ class FormSettings : public QDialog {
|
||||||
void loadInterface();
|
void loadInterface();
|
||||||
void saveInterface();
|
void saveInterface();
|
||||||
void changeBrowserProgressColor();
|
void changeBrowserProgressColor();
|
||||||
|
void onSkinSelected(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||||
|
|
||||||
void loadGeneral();
|
void loadGeneral();
|
||||||
void saveGeneral();
|
void saveGeneral();
|
||||||
|
|
|
@ -121,49 +121,121 @@
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Icons && skins</string>
|
<string>Icons && skins</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
<item row="0" column="0">
|
<property name="leftMargin">
|
||||||
<widget class="QLabel" name="m_lblIconTheme">
|
<number>0</number>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Icon theme</string>
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QScrollArea" name="m_scrollIconSkins">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
<property name="widgetResizable">
|
||||||
<cstring>m_cmbIconTheme</cstring>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<widget class="QWidget" name="scrollAreaWidgetContents_2">
|
||||||
</item>
|
<property name="geometry">
|
||||||
<item row="0" column="1">
|
<rect>
|
||||||
<widget class="QComboBox" name="m_cmbIconTheme"/>
|
<x>0</x>
|
||||||
</item>
|
<y>0</y>
|
||||||
<item row="1" column="0">
|
<width>581</width>
|
||||||
<widget class="QLabel" name="m_lblSkin">
|
<height>340</height>
|
||||||
<property name="text">
|
</rect>
|
||||||
<string>Skin</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" colspan="2">
|
|
||||||
<widget class="QTreeWidget" name="m_treeSkins">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="indentation">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="itemsExpandable">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="expandsOnDoubleClick">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">1</string>
|
|
||||||
</property>
|
</property>
|
||||||
</column>
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="m_lblIconTheme">
|
||||||
|
<property name="text">
|
||||||
|
<string>Icon theme</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>m_cmbIconTheme</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="m_cmbIconTheme"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="m_lblSkin">
|
||||||
|
<property name="text">
|
||||||
|
<string>Skin</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QTreeWidget" name="m_treeSkins">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="indentation">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="itemsExpandable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="expandsOnDoubleClick">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">1</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="m_lblActiveCaption">
|
||||||
|
<property name="text">
|
||||||
|
<string>Active skin</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLabel" name="m_lblActiveContents">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="m_lblSelectedCaption">
|
||||||
|
<property name="text">
|
||||||
|
<string>Selected skin</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QLabel" name="m_lblSelectedContents">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Newly selected skin is activated after the applicaton gets restarted!!!</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -28,16 +28,13 @@ SkinFactory *SkinFactory::getInstance() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkinFactory::loadCurrentSkin() {
|
void SkinFactory::loadCurrentSkin() {
|
||||||
QString skin_name_from_settings = Settings::getInstance()->value(APP_CFG_GUI,
|
QString skin_name_from_settings = getSelectedSkinName();
|
||||||
"skin",
|
|
||||||
"base/plain.xml").toString();
|
|
||||||
bool loaded = false;
|
bool loaded = false;
|
||||||
Skin skin_data = getSkinInfo(skin_name_from_settings, &loaded);
|
Skin skin_data = getSkinInfo(skin_name_from_settings, &loaded);
|
||||||
|
|
||||||
if (skin_name_from_settings == APP_THEME_SYSTEM) {
|
if (skin_name_from_settings == APP_THEME_SYSTEM) {
|
||||||
qApp->setStyleSheet(QString());
|
// NOTE: No need to call qApp->setStylesheet(QString()) here.
|
||||||
qApp->setStyle(NULL);
|
qDebug("'Default system skin' loaded.");
|
||||||
qDebug("System default skin loaded.");
|
|
||||||
}
|
}
|
||||||
else if (loaded) {
|
else if (loaded) {
|
||||||
loadSkinFromData(skin_data.m_rawData, skin_name_from_settings);
|
loadSkinFromData(skin_data.m_rawData, skin_name_from_settings);
|
||||||
|
@ -54,7 +51,7 @@ void SkinFactory::loadCurrentSkin() {
|
||||||
qDebug("Skin '%s' loaded.", qPrintable(skin_name_from_settings));
|
qDebug("Skin '%s' loaded.", qPrintable(skin_name_from_settings));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebug("Skin '%s' not loaded because style name is not specified or skin raw data is missing.",
|
qDebug("Skin '%s' not loaded because style name is not specified or skin raw data is missing. Default skin loaded.",
|
||||||
qPrintable(skin_name_from_settings));
|
qPrintable(skin_name_from_settings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +86,12 @@ bool SkinFactory::loadSkinFromData(QString skin_data, const QString &skin_path)
|
||||||
|
|
||||||
void SkinFactory::setCurrentSkinName(const QString &skin_name) {
|
void SkinFactory::setCurrentSkinName(const QString &skin_name) {
|
||||||
Settings::getInstance()->setValue(APP_CFG_GUI, "skin", skin_name);
|
Settings::getInstance()->setValue(APP_CFG_GUI, "skin", skin_name);
|
||||||
loadCurrentSkin();
|
}
|
||||||
|
|
||||||
|
QString SkinFactory::getSelectedSkinName() {
|
||||||
|
return Settings::getInstance()->value(APP_CFG_GUI,
|
||||||
|
"skin",
|
||||||
|
APP_THEME_SYSTEM).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SkinFactory::getCurrentSkinName() {
|
QString SkinFactory::getCurrentSkinName() {
|
||||||
|
@ -98,6 +100,21 @@ QString SkinFactory::getCurrentSkinName() {
|
||||||
|
|
||||||
Skin SkinFactory::getSkinInfo(const QString &skin_name, bool *ok) {
|
Skin SkinFactory::getSkinInfo(const QString &skin_name, bool *ok) {
|
||||||
Skin skin;
|
Skin skin;
|
||||||
|
|
||||||
|
if (skin_name == APP_THEME_SYSTEM) {
|
||||||
|
skin.m_author = "-";
|
||||||
|
skin.m_baseName = APP_THEME_SYSTEM;
|
||||||
|
skin.m_email = "-";
|
||||||
|
skin.m_version = "-";
|
||||||
|
skin.m_visibleName = tr("default system skin");
|
||||||
|
|
||||||
|
if (ok != NULL) {
|
||||||
|
*ok = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return skin;
|
||||||
|
}
|
||||||
|
|
||||||
QXmlQuery query;
|
QXmlQuery query;
|
||||||
QFile skin_file(APP_SKIN_PATH + QDir::separator() + skin_name);
|
QFile skin_file(APP_SKIN_PATH + QDir::separator() + skin_name);
|
||||||
|
|
||||||
|
@ -157,13 +174,7 @@ Skin SkinFactory::getSkinInfo(const QString &skin_name, bool *ok) {
|
||||||
QList<Skin> SkinFactory::getInstalledSkins() {
|
QList<Skin> SkinFactory::getInstalledSkins() {
|
||||||
QList<Skin> skins;
|
QList<Skin> skins;
|
||||||
|
|
||||||
Skin default_skin;
|
skins.append(getSkinInfo(APP_THEME_SYSTEM));
|
||||||
default_skin.m_author = "-";
|
|
||||||
default_skin.m_baseName = APP_THEME_SYSTEM;
|
|
||||||
default_skin.m_email = "-";
|
|
||||||
default_skin.m_version = "-";
|
|
||||||
default_skin.m_visibleName = tr("default system skin");
|
|
||||||
skins.append(default_skin);
|
|
||||||
|
|
||||||
bool skin_load_ok;
|
bool skin_load_ok;
|
||||||
QStringList skin_directories = QDir(APP_SKIN_PATH).entryList(QDir::Dirs |
|
QStringList skin_directories = QDir(APP_SKIN_PATH).entryList(QDir::Dirs |
|
||||||
|
|
|
@ -44,8 +44,15 @@ class SkinFactory : public QObject {
|
||||||
// NOTE: Skin name is formatted as "<folder>/<skin>.xml".
|
// NOTE: Skin name is formatted as "<folder>/<skin>.xml".
|
||||||
QString getCurrentSkinName();
|
QString getCurrentSkinName();
|
||||||
|
|
||||||
|
// Returns the name of the skin, that should be activated
|
||||||
|
// after application restart.
|
||||||
|
QString getSelectedSkinName();
|
||||||
|
|
||||||
|
// Gets skin about a particular skin.
|
||||||
Skin getSkinInfo(const QString &skin_name, bool *ok = NULL);
|
Skin getSkinInfo(const QString &skin_name, bool *ok = NULL);
|
||||||
|
|
||||||
|
// Returns list of installed skins, including "default system skin".
|
||||||
|
// NOTE: Default skin always lies at position 0.
|
||||||
QList<Skin> getInstalledSkins();
|
QList<Skin> getInstalledSkins();
|
||||||
|
|
||||||
// Sets the desired skin as the active one if it exists.
|
// Sets the desired skin as the active one if it exists.
|
||||||
|
|
|
@ -72,7 +72,6 @@ int main(int argc, char *argv[]) {
|
||||||
IconThemeFactory::getInstance()->setupSearchPaths();
|
IconThemeFactory::getInstance()->setupSearchPaths();
|
||||||
IconThemeFactory::getInstance()->loadCurrentIconTheme(false);
|
IconThemeFactory::getInstance()->loadCurrentIconTheme(false);
|
||||||
SkinFactory::getInstance()->loadCurrentSkin();
|
SkinFactory::getInstance()->loadCurrentSkin();
|
||||||
SkinFactory::getInstance()->getInstalledSkins();
|
|
||||||
|
|
||||||
// Load localization and setup locale before any widget is constructed.
|
// Load localization and setup locale before any widget is constructed.
|
||||||
LoadLocalization();
|
LoadLocalization();
|
||||||
|
|
Loading…
Add table
Reference in a new issue