1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel IRC Team *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU Appearance Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU Appearance Public License for more details. *
15 * You should have received a copy of the GNU Appearance Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "appearancesettingspage.h"
24 #include "uisettings.h"
26 #include <QStyleFactory>
28 AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent)
29 : SettingsPage(tr("Appearance"), tr("General"), parent) {
33 connect(ui.styleComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged()));
36 void AppearanceSettingsPage::initStyleComboBox() {
37 QStringList styleList = QStyleFactory::keys();
38 ui.styleComboBox->addItem("<default>");
39 foreach(QString style, styleList) {
40 ui.styleComboBox->addItem(style);
44 bool AppearanceSettingsPage::hasDefaults() const {
48 void AppearanceSettingsPage::defaults() {
49 ui.styleComboBox->setCurrentIndex(0);
54 void AppearanceSettingsPage::load() {
55 UiSettings uiSettings;
57 settings["Style"] = uiSettings.value("Style", QString(""));
58 if(settings["Style"].toString() == "") {
59 ui.styleComboBox->setCurrentIndex(0);
61 ui.styleComboBox->setCurrentIndex(ui.styleComboBox->findText(settings["Style"].toString(), Qt::MatchExactly));
62 QApplication::setStyle(settings["Style"].toString());
65 setChangedState(false);
68 void AppearanceSettingsPage::save() {
69 UiSettings uiSettings;
71 if(ui.styleComboBox->currentIndex() < 1) {
72 uiSettings.setValue("Style", QString(""));
74 uiSettings.setValue("Style", ui.styleComboBox->currentText());
78 setChangedState(false);
81 void AppearanceSettingsPage::widgetHasChanged() {
82 bool changed = testHasChanged();
83 if(changed != hasChanged()) setChangedState(changed);
86 bool AppearanceSettingsPage::testHasChanged() {
87 if(settings["Style"].toString() != ui.styleComboBox->currentText()) return true;