From 22fea756df3d68f8bc433d2540ac6e7400853d7b Mon Sep 17 00:00:00 2001 From: Alexander von Renteln Date: Mon, 31 Mar 2008 18:22:59 +0000 Subject: [PATCH] -moved the style option to general->appearance -added template settingspage in dev-notes --- dev-notes/blanksettingspage.cpp | 74 +++++++++++++++ dev-notes/blanksettingspage.h | 52 ++++++++++ src/qtui/mainwin.cpp | 4 +- .../settingspages/appearancesettingspage.cpp | 94 +++++++++++++++++++ .../settingspages/appearancesettingspage.h | 53 +++++++++++ .../settingspages/appearancesettingspage.ui | 45 +++++++++ .../settingspages/generalsettingspage.cpp | 31 ------ src/qtui/settingspages/generalsettingspage.h | 1 - src/qtui/settingspages/generalsettingspage.ui | 12 --- src/qtui/settingspages/settingspages.pri | 2 +- version.inc | 2 +- 11 files changed, 323 insertions(+), 47 deletions(-) create mode 100644 dev-notes/blanksettingspage.cpp create mode 100644 dev-notes/blanksettingspage.h create mode 100644 src/qtui/settingspages/appearancesettingspage.cpp create mode 100644 src/qtui/settingspages/appearancesettingspage.h create mode 100644 src/qtui/settingspages/appearancesettingspage.ui diff --git a/dev-notes/blanksettingspage.cpp b/dev-notes/blanksettingspage.cpp new file mode 100644 index 00000000..55a6333a --- /dev/null +++ b/dev-notes/blanksettingspage.cpp @@ -0,0 +1,74 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel IRC Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Blank Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Blank Public License for more details. * + * * + * You should have received a copy of the GNU Blank Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "blanksettingspage.h" + +#include "qtui.h" +#include "uisettings.h" + + +BlankSettingsPage::BlankSettingsPage(QWidget *parent) + : SettingsPage(tr("Behaviour"), tr("Blank"), parent) { + ui.setupUi(this); + + connect(ui.exampleCheckbox, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); +} + +bool BlankSettingsPage::hasDefaults() const { + return true; +} + +void BlankSettingsPage::defaults() { + ui.exampleCheckbox->setChecked(true); + + widgetHasChanged(); +} + +void BlankSettingsPage::load() { + UiSettings uiSettings; + + settings["exampleCheckbox"] = uiSettings.value("exampleCheckbox", QVariant(false)); + ui.exampleCheckbox->setChecked(settings["exampleCheckbox"].toBool()); + + setChangedState(false); +} + +void BlankSettingsPage::save() { + UiSettings uiSettings; + uiSettings.setValue("exampleCheckbox", ui.exampleCheckbox->isChecked()); + + load(); + setChangedState(false); +} + +void BlankSettingsPage::widgetHasChanged() { + bool changed = testHasChanged(); + if(changed != hasChanged()) setChangedState(changed); +} + +bool BlankSettingsPage::testHasChanged() { + if(settings["exampleCheckbox"].toBool() != ui.exampleCheckbox->isChecked()) return true; + + return false; +} + + + + diff --git a/dev-notes/blanksettingspage.h b/dev-notes/blanksettingspage.h new file mode 100644 index 00000000..8cc0a765 --- /dev/null +++ b/dev-notes/blanksettingspage.h @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel IRC Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Blank Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Blank Public License for more details. * + * * + * You should have received a copy of the GNU Blank Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _BLANKSETTINGSPAGE_H_ +#define _BLANKSETTINGSPAGE_H_ + +#include + +#include "settingspage.h" +#include "ui_blanksettingspage.h" + +class BlankSettingsPage : public SettingsPage { + Q_OBJECT + + public: + BlankSettingsPage(QWidget *parent = 0); + + bool hasDefaults() const; + + public slots: + void save(); + void load(); + void defaults(); + + private slots: + void widgetHasChanged(); + + private: + Ui::BlankSettingsPage ui; + QHash settings; + + bool testHasChanged(); +}; + +#endif diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index fcbd228e..4f308a1d 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -45,6 +45,7 @@ #include "selectionmodelsynchronizer.h" #include "mappedselectionmodel.h" +#include "settingspages/appearancesettingspage.h" #include "settingspages/bufferviewsettingspage.h" #include "settingspages/colorsettingspage.h" #include "settingspages/fontssettingspage.h" @@ -75,7 +76,7 @@ MainWin::MainWin(QtUi *_gui, QWidget *parent) statusBar()->showMessage(tr("Waiting for core...")); installEventFilter(new JumpKeyHandler(this)); - + UiSettings uiSettings; QString style = uiSettings.value("Style", QString("")).toString(); if(style != "") { @@ -200,6 +201,7 @@ void MainWin::setupSettingsDlg() { //Category: Behaviour settingsDlg->registerSettingsPage(new GeneralSettingsPage(settingsDlg)); //Category: General + settingsDlg->registerSettingsPage(new AppearanceSettingsPage(settingsDlg)); settingsDlg->registerSettingsPage(new IdentitiesSettingsPage(settingsDlg)); settingsDlg->registerSettingsPage(new NetworksSettingsPage(settingsDlg)); // settingsDlg->registerSettingsPage(new BufferViewSettingsPage(settingsDlg)); diff --git a/src/qtui/settingspages/appearancesettingspage.cpp b/src/qtui/settingspages/appearancesettingspage.cpp new file mode 100644 index 00000000..a6745f61 --- /dev/null +++ b/src/qtui/settingspages/appearancesettingspage.cpp @@ -0,0 +1,94 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel IRC Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Appearance Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Appearance Public License for more details. * + * * + * You should have received a copy of the GNU Appearance Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "appearancesettingspage.h" + +#include "qtui.h" +#include "uisettings.h" + +#include + +AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent) + : SettingsPage(tr("General"), tr("Appearance"), parent) { + ui.setupUi(this); + initStyleComboBox(); + + connect(ui.styleComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged())); +} + +void AppearanceSettingsPage::initStyleComboBox() { + QStringList styleList = QStyleFactory::keys(); + ui.styleComboBox->addItem(""); + foreach(QString style, styleList) { + ui.styleComboBox->addItem(style); + } +} + +bool AppearanceSettingsPage::hasDefaults() const { + return true; +} + +void AppearanceSettingsPage::defaults() { + ui.styleComboBox->setCurrentIndex(0); + + widgetHasChanged(); +} + +void AppearanceSettingsPage::load() { + UiSettings uiSettings; + + settings["Style"] = uiSettings.value("Style", QString("")); + if(settings["Style"].toString() == "") { + ui.styleComboBox->setCurrentIndex(0); + } else { + ui.styleComboBox->setCurrentIndex(ui.styleComboBox->findText(settings["Style"].toString(), Qt::MatchExactly)); + QApplication::setStyle(settings["Style"].toString()); + } + + setChangedState(false); +} + +void AppearanceSettingsPage::save() { + UiSettings uiSettings; + + if(ui.styleComboBox->currentIndex() < 1) { + uiSettings.setValue("Style", QString("")); + } else { + uiSettings.setValue("Style", ui.styleComboBox->currentText()); + } + + load(); + setChangedState(false); +} + +void AppearanceSettingsPage::widgetHasChanged() { + bool changed = testHasChanged(); + if(changed != hasChanged()) setChangedState(changed); +} + +bool AppearanceSettingsPage::testHasChanged() { + if(settings["Style"].toString() != ui.styleComboBox->currentText()) return true; + + return false; +} + + + + diff --git a/src/qtui/settingspages/appearancesettingspage.h b/src/qtui/settingspages/appearancesettingspage.h new file mode 100644 index 00000000..6a4071f3 --- /dev/null +++ b/src/qtui/settingspages/appearancesettingspage.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel IRC Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Appearance Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Appearance Public License for more details. * + * * + * You should have received a copy of the GNU Appearance Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _APPEARANCESETTINGSPAGE_H_ +#define _APPEARANCESETTINGSPAGE_H_ + +#include + +#include "settingspage.h" +#include "ui_appearancesettingspage.h" + +class AppearanceSettingsPage : public SettingsPage { + Q_OBJECT + + public: + AppearanceSettingsPage(QWidget *parent = 0); + + bool hasDefaults() const; + + public slots: + void save(); + void load(); + void defaults(); + + private slots: + void widgetHasChanged(); + + private: + Ui::AppearanceSettingsPage ui; + QHash settings; + + bool testHasChanged(); + void initStyleComboBox(); +}; + +#endif diff --git a/src/qtui/settingspages/appearancesettingspage.ui b/src/qtui/settingspages/appearancesettingspage.ui new file mode 100644 index 00000000..3a9478f1 --- /dev/null +++ b/src/qtui/settingspages/appearancesettingspage.ui @@ -0,0 +1,45 @@ + + AppearanceSettingsPage + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Client style: + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/src/qtui/settingspages/generalsettingspage.cpp b/src/qtui/settingspages/generalsettingspage.cpp index a0c0228a..5111b4ec 100644 --- a/src/qtui/settingspages/generalsettingspage.cpp +++ b/src/qtui/settingspages/generalsettingspage.cpp @@ -24,12 +24,9 @@ #include "uisettings.h" #include "buffersettings.h" -#include - GeneralSettingsPage::GeneralSettingsPage(QWidget *parent) : SettingsPage(tr("Behaviour"), tr("General"), parent) { ui.setupUi(this); - initStyleComboBox(); #ifdef Q_WS_MAC ui.useSystemTrayIcon->hide(); @@ -55,16 +52,6 @@ GeneralSettingsPage::GeneralSettingsPage(QWidget *parent) connect(ui.displayTopicInTooltip, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); connect(ui.mouseWheelChangesBuffers, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); - - connect(ui.styleComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged())); -} - -void GeneralSettingsPage::initStyleComboBox() { - QStringList styleList = QStyleFactory::keys(); - ui.styleComboBox->addItem(""); - foreach(QString style, styleList) { - ui.styleComboBox->addItem(style); - } } bool GeneralSettingsPage::hasDefaults() const { @@ -87,8 +74,6 @@ void GeneralSettingsPage::defaults() { ui.displayTopicInTooltip->setChecked(false); ui.mouseWheelChangesBuffers->setChecked(true); - ui.styleComboBox->setCurrentIndex(0); - widgetHasChanged(); } @@ -114,14 +99,6 @@ void GeneralSettingsPage::load() { settings["DisplayPopupMessages"] = uiSettings.value("DisplayPopupMessages", QVariant(true)); ui.displayPopupMessages->setChecked(settings["DisplayPopupMessages"].toBool()); - settings["Style"] = uiSettings.value("Style", QString("")); - if(settings["Style"].toString() == "") { - ui.styleComboBox->setCurrentIndex(0); - } else { - ui.styleComboBox->setCurrentIndex(ui.styleComboBox->findText(settings["Style"].toString(), Qt::MatchExactly)); - QApplication::setStyle(settings["Style"].toString()); - } - // bufferSettings: BufferSettings bufferSettings; settings["UserMessagesInStatusBuffer"] = bufferSettings.value("UserMessagesInStatusBuffer", QVariant(true)); @@ -149,12 +126,6 @@ void GeneralSettingsPage::save() { uiSettings.setValue("AnimateTrayIcon", ui.animateTrayIcon->isChecked()); uiSettings.setValue("DisplayPopupMessages", ui.displayPopupMessages->isChecked()); - if(ui.styleComboBox->currentIndex() < 1) { - uiSettings.setValue("Style", QString("")); - } else { - uiSettings.setValue("Style", ui.styleComboBox->currentText()); - } - BufferSettings bufferSettings; bufferSettings.setValue("UserMessagesInStatusBuffer", ui.userMessagesInStatusBuffer->isChecked()); bufferSettings.setValue("UserMessagesInQueryBuffer", ui.userMessagesInQueryBuffer->isChecked()); @@ -186,8 +157,6 @@ bool GeneralSettingsPage::testHasChanged() { if(settings["DisplayTopicInTooltip"].toBool() != ui.displayTopicInTooltip->isChecked()) return true; if(settings["MouseWheelChangesBuffers"].toBool() != ui.mouseWheelChangesBuffers->isChecked()) return true; - if(settings["Style"].toString() != ui.styleComboBox->currentText()) return true; - return false; } diff --git a/src/qtui/settingspages/generalsettingspage.h b/src/qtui/settingspages/generalsettingspage.h index f7fc9e48..42216d82 100644 --- a/src/qtui/settingspages/generalsettingspage.h +++ b/src/qtui/settingspages/generalsettingspage.h @@ -47,7 +47,6 @@ class GeneralSettingsPage : public SettingsPage { QHash settings; bool testHasChanged(); - void initStyleComboBox(); }; #endif diff --git a/src/qtui/settingspages/generalsettingspage.ui b/src/qtui/settingspages/generalsettingspage.ui index e8574408..4fce47f5 100644 --- a/src/qtui/settingspages/generalsettingspage.ui +++ b/src/qtui/settingspages/generalsettingspage.ui @@ -155,18 +155,6 @@ - - - - Client style: - - - - - - - - diff --git a/src/qtui/settingspages/settingspages.pri b/src/qtui/settingspages/settingspages.pri index 6d7d510f..40139052 100644 --- a/src/qtui/settingspages/settingspages.pri +++ b/src/qtui/settingspages/settingspages.pri @@ -1,6 +1,6 @@ # Putting $FOO in SETTINGSPAGES automatically includes # $FOOsettingspage.cpp, $FOOsettingspage.h and $FOOsettingspage.ui -SETTINGSPAGES = color fonts general identities networks bufferview +SETTINGSPAGES = appearance bufferview color fonts general identities networks # Specify additional files (e.g. for subdialogs) here! SP_SRCS = diff --git a/version.inc b/version.inc index b1798eef..38887a29 100644 --- a/version.inc +++ b/version.inc @@ -5,7 +5,7 @@ quasselVersion = "0.2.0-alpha5-pre"; quasselDate = "2008-03-31"; - quasselBuild = 676; + quasselBuild = 677; //! Minimum client build number the core needs clientBuildNeeded = 642; -- 2.20.1