More work on ThemeFactory, fixed highlighting of icon theme on Linux.

This commit is contained in:
Martin Rotter 2013-06-15 19:48:56 +02:00
parent bb420269fe
commit 9257df1935
7 changed files with 78 additions and 7 deletions

View File

@ -248,7 +248,6 @@ endif(Qt5LinguistTools_FOUND)
# Include additional directory paths.
include_directories (
${CMAKE_CURRENT_SOURCE_DIR}/src
# ${CMAKE_CURRENT_SOURCE_DIR}/src/muparserx
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/src
${Qt5Xml_INCLUDE_DIRS}

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -25,12 +25,12 @@ class Settings : public QSettings {
const QString &key,
const QVariant &value);
// Synchronises settings.
QSettings::Status checkSettings();
protected:
// Creates settings file in correct location.
static QSettings::Status setupSettings();
// Synchronises settings.
QSettings::Status checkSettings();
};
#endif // SETTINGS_H

View File

@ -81,8 +81,8 @@
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
@ -213,7 +213,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
<height>19</height>
</rect>
</property>
<widget class="QMenu" name="m_menuFile">

View File

@ -1,10 +1,69 @@
#include "gui/formsettings.h"
#include "gui/themefactory.h"
#include "core/settings.h"
FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormSettings) {
m_ui->setupUi(this);
// Set flags.
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog);
// Establish needed connections.
connect(this, &FormSettings::accepted, this, &FormSettings::saveSettings);
// Load all settings.
loadInterface();
}
FormSettings::~FormSettings() {
delete m_ui;
}
void FormSettings::saveSettings() {
// Save all categories.
//saveGeneral();
saveInterface();
//saveLanguages();
// Make sure that settings is synced.
Settings::getInstance().checkSettings();
}
void FormSettings::loadInterface() {
QString current_theme = ThemeFactory::getCurrentIconTheme();
#if defined(Q_OS_LINUX)
QString system_theme = ThemeFactory::getSystemIconTheme();
#endif
foreach (QString icon_theme_name, ThemeFactory::getInstalledIconThemes()) {
#if defined(Q_OS_LINUX)
if (icon_theme_name == system_theme) {
m_ui->m_cmbIconTheme->addItem(tr("system icon theme (default)"),
icon_theme_name);
}
else {
#endif
m_ui->m_cmbIconTheme->addItem(icon_theme_name,
icon_theme_name);
#if defined(Q_OS_LINUX)
}
if (current_theme == system_theme) {
// Because system icon theme lies at the index 0.
// See ThemeFactory::getInstalledIconThemes() for more info.
m_ui->m_cmbIconTheme->setCurrentIndex(0);
}
else {
#endif
// TODO: Display correct theme on linux.
m_ui->m_cmbIconTheme->setCurrentText(current_theme);
#if defined(Q_OS_LINUX)
}
#endif
}
}
void FormSettings::saveInterface() {
// Save selected icon theme.
ThemeFactory::setCurrentIconTheme(m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString());
}

View File

@ -16,6 +16,14 @@ class FormSettings : public QDialog {
public:
explicit FormSettings(QWidget *parent = 0);
~FormSettings();
protected slots:
// Saves settings into global configuration.
void saveSettings();
// Load/save GUI settings.
void loadInterface();
void saveInterface();
private:
Ui::FormSettings *m_ui;

View File

@ -9,6 +9,11 @@ class ThemeFactory {
ThemeFactory();
public:
enum Type {
SYSTEM,
USER
};
// Adds custom application path to be search for icons.
static void setupSearchPaths();