From b6745556187013f9ddb84abd26498c77a7db5999 Mon Sep 17 00:00:00 2001 From: Alexander von Renteln Date: Fri, 8 Feb 2008 15:17:48 +0000 Subject: [PATCH] added general settings page minimize and close buttons can now be configured to minimize quasselclient to the system tray --- src/qtui/mainwin.cpp | 69 +++++++---- src/qtui/mainwin.h | 4 +- src/qtui/qtui.pri | 4 +- src/qtui/qtuisettings.cpp | 25 ++++ src/qtui/qtuisettings.h | 34 ++++++ .../settingspages/generalsettingspage.cpp | 110 ++++++++++++++++++ src/qtui/settingspages/generalsettingspage.h | 52 +++++++++ src/qtui/settingspages/generalsettingspage.ui | 92 +++++++++++++++ src/qtui/settingspages/settingspages.pri | 2 +- version.inc | 2 +- 10 files changed, 369 insertions(+), 25 deletions(-) create mode 100644 src/qtui/qtuisettings.cpp create mode 100644 src/qtui/qtuisettings.h create mode 100644 src/qtui/settingspages/generalsettingspage.cpp create mode 100644 src/qtui/settingspages/generalsettingspage.h create mode 100644 src/qtui/settingspages/generalsettingspage.ui diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index bd992691..fb0ebdb9 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -36,6 +36,7 @@ #include "inputwidget.h" #include "verticaldock.h" #include "uisettings.h" +#include "qtuisettings.h" #include "selectionmodelsynchronizer.h" #include "mappedselectionmodel.h" @@ -43,6 +44,7 @@ #include "settingspages/fontssettingspage.h" #include "settingspages/identitiessettingspage.h" #include "settingspages/networkssettingspage.h" +#include "settingspages/generalsettingspage.h" #include "debugconsole.h" @@ -88,6 +90,7 @@ void MainWin::init() { setupTopicWidget(); setupSystray(); + setupSettingsDlg(); // restore mainwin state @@ -161,7 +164,8 @@ void MainWin::setupSettingsDlg() { settingsDlg->registerSettingsPage(new FontsSettingsPage(settingsDlg)); settingsDlg->registerSettingsPage(new IdentitiesSettingsPage(settingsDlg)); settingsDlg->registerSettingsPage(new NetworksSettingsPage(settingsDlg)); - + settingsDlg->registerSettingsPage(new GeneralSettingsPage(settingsDlg)); + #ifdef SPUTDEV connect(settingsDlg, SIGNAL(finished(int)), QApplication::instance(), SLOT(quit())); // FIXME #endif @@ -256,11 +260,27 @@ void MainWin::setupSystray() { systray->setContextMenu(systrayMenu); - systray->show(); + QtUiSettings s; + if(s.value("UseSystemTrayIcon").toBool()) { + systray->show(); + } + #ifndef Q_WS_MAC connect(systray, SIGNAL(activated( QSystemTrayIcon::ActivationReason )), this, SLOT(systrayActivated( QSystemTrayIcon::ActivationReason ))); #endif + +} + +void MainWin::changeEvent(QEvent *event) { + if(event->type() == QEvent::WindowStateChange) { + if(windowState() & Qt::WindowMinimized) { + QtUiSettings s; + if(s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnMinimize").toBool()) { + toggleVisibility(); + } + } + } } void MainWin::connectedToCore() { @@ -314,33 +334,42 @@ void MainWin::showDebugConsole() { void MainWin::closeEvent(QCloseEvent *event) { - //if (userReallyWantsToQuit()) { - UiSettings s; - s.setValue("MainWinSize", size()); - s.setValue("MainWinPos", pos()); - s.setValue("MainWinState", saveState()); + QtUiSettings s; + if(s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnClose").toBool()) { + toggleVisibility(); + event->ignore(); + } else { event->accept(); + } + //if (userReallyWantsToQuit()) { + s.setValue("MainWinSize", size()); + s.setValue("MainWinPos", pos()); + s.setValue("MainWinState", saveState()); //} else { - //event->ignore(); + // event->ignore(); //} } void MainWin::systrayActivated( QSystemTrayIcon::ActivationReason activationReason) { if (activationReason == QSystemTrayIcon::Trigger) { - if(isHidden()) { - show(); - if(isMinimized()) { - if(isMaximized()) { - showMaximized(); - } else { - showNormal(); - } + toggleVisibility(); + } +} + +void MainWin::toggleVisibility() { + if(isHidden()) { + show(); + if(isMinimized()) { + if(isMaximized()) { + showMaximized(); + } else { + showNormal(); } - raise(); - activateWindow(); - } else { - hide(); } + raise(); + activateWindow(); + } else { + hide(); } } diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 12c639fc..a78832d8 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -52,6 +52,7 @@ class MainWin : public QMainWindow { protected: void closeEvent(QCloseEvent *event); + virtual void changeEvent(QEvent *event); virtual void keyPressEvent(QKeyEvent *event); protected slots: @@ -60,7 +61,6 @@ class MainWin : public QMainWindow { void systrayActivated( QSystemTrayIcon::ActivationReason ); private slots: - void showSettingsDlg(); void showNetworkDlg(); void showDebugConsole(); @@ -94,6 +94,8 @@ class MainWin : public QMainWindow { void setupSettingsDlg(); + void toggleVisibility(); + void enableMenus(); void bindKey(int key); diff --git a/src/qtui/qtui.pri b/src/qtui/qtui.pri index 29c0e021..d7f0f834 100644 --- a/src/qtui/qtui.pri +++ b/src/qtui/qtui.pri @@ -2,11 +2,11 @@ DEPMOD = uisupport common client QT_MOD = core gui network SRCS += bufferwidget.cpp chatline-old.cpp chatwidget.cpp coreconfigwizard.cpp coreconnectdlg.cpp configwizard.cpp debugconsole.cpp inputwidget.cpp \ - mainwin.cpp nicklistwidget.cpp qtui.cpp qtuistyle.cpp settingsdlg.cpp settingspagedlg.cpp \ + mainwin.cpp nicklistwidget.cpp qtui.cpp qtuisettings.cpp qtuistyle.cpp settingsdlg.cpp settingspagedlg.cpp \ topicwidget.cpp verticaldock.cpp HDRS += bufferwidget.h chatline-old.h chatwidget.h coreconfigwizard.h configwizard.h debugconsole.h inputwidget.h \ - coreconnectdlg.h mainwin.h nicklistwidget.h qtui.h qtuistyle.h settingsdlg.h settingspagedlg.h \ + coreconnectdlg.h mainwin.h nicklistwidget.h qtui.h qtuisettings.h qtuistyle.h settingsdlg.h settingspagedlg.h \ topicwidget.h verticaldock.h FORMNAMES = mainwin.ui coreaccounteditdlg.ui coreconnectdlg.ui bufferviewwidget.ui bufferwidget.ui nicklistwidget.ui settingsdlg.ui \ diff --git a/src/qtui/qtuisettings.cpp b/src/qtui/qtuisettings.cpp new file mode 100644 index 00000000..2a79bc79 --- /dev/null +++ b/src/qtui/qtuisettings.cpp @@ -0,0 +1,25 @@ +/*************************************************************************** + * 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 General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) version 3. * + * * + * 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General 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 "qtuisettings.h" + +QtUiSettings::QtUiSettings(const QString &group) : UiSettings(group) { + +} diff --git a/src/qtui/qtuisettings.h b/src/qtui/qtuisettings.h new file mode 100644 index 00000000..fa3c7928 --- /dev/null +++ b/src/qtui/qtuisettings.h @@ -0,0 +1,34 @@ +/*************************************************************************** + * 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 General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) version 3. * + * * + * 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General 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 _QTUISETTINGS_H_ +#define _QTUISETTINGS_H_ + +#include "uisettings.h" + +class QtUiSettings : public UiSettings { + + public: + QtUiSettings(const QString &group = "QtUi"); + +}; + + +#endif diff --git a/src/qtui/settingspages/generalsettingspage.cpp b/src/qtui/settingspages/generalsettingspage.cpp new file mode 100644 index 00000000..5341511b --- /dev/null +++ b/src/qtui/settingspages/generalsettingspage.cpp @@ -0,0 +1,110 @@ +/*************************************************************************** + * 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 General 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General 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 "generalsettingspage.h" + +#include "qtui.h" +#include "qtuisettings.h" + +GeneralSettingsPage::GeneralSettingsPage(QWidget *parent) + : SettingsPage(tr("Behaviour"), tr("General"), parent) { + ui.setupUi(this); + + connect(ui.useSystemTrayIcon, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); + connect(ui.minimizeOnMinimize, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); + connect(ui.minimizeOnClose, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); + + connect(ui.userMessagesInStatusBuffer, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); + connect(ui.userMessagesInQueryBuffer, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); + connect(ui.userMessagesInCurrentBuffer, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); +} + +bool GeneralSettingsPage::hasDefaults() const { + return true; +} + +void GeneralSettingsPage::defaults() { + qDebug() << "defaults in generalsettingspage"; + ui.useSystemTrayIcon->setChecked(true); + ui.minimizeOnMinimize->setChecked(false); + ui.minimizeOnClose->setChecked(false); + + ui.userMessagesInStatusBuffer->setChecked(true); + ui.userMessagesInQueryBuffer->setChecked(false); + ui.userMessagesInCurrentBuffer->setChecked(false); + + widgetHasChanged(); +} + +void GeneralSettingsPage::load() { + QtUiSettings s; + settings["UseSystemTrayIcon"] = s.value("UseSystemTrayIcon"); + ui.useSystemTrayIcon->setChecked(settings["UseSystemTrayIcon"].toBool()); + + settings["MinimizeOnMinimize"] = s.value("MinimizeOnMinimize"); + ui.minimizeOnMinimize->setChecked(settings["MinimizeOnMinimize"].toBool()); + + settings["MinimizeOnClose"] = s.value("MinimizeOnClose"); + ui.minimizeOnClose->setChecked(settings["MinimizeOnClose"].toBool()); + + settings["UserMessagesInStatusBuffer"] = s.value("UserMessagesInStatusBuffer"); + ui.userMessagesInStatusBuffer->setChecked(settings["UserMessagesInStatusBuffer"].toBool()); + + settings["UserMessagesInQueryBuffer"] = s.value("UserMessagesInQueryBuffer"); + ui.userMessagesInQueryBuffer->setChecked(settings["UserMessagesInQueryBuffer"].toBool()); + + settings["UserMessagesInCurrentBuffer"] = s.value("UserMessagesInCurrentBuffer"); + ui.userMessagesInCurrentBuffer->setChecked(settings["UserMessagesInCurrentBuffer"].toBool()); + + setChangedState(false); +} + +void GeneralSettingsPage::save() { + QtUiSettings s; + s.setValue("UseSystemTrayIcon", ui.useSystemTrayIcon->isChecked()); + s.setValue("MinimizeOnMinimize", ui.minimizeOnMinimize->isChecked()); + s.setValue("MinimizeOnClose", ui.minimizeOnClose->isChecked()); + + s.setValue("UserMessagesInStatusBuffer", ui.userMessagesInStatusBuffer->isChecked()); + s.setValue("UserMessagesInQueryBuffer", ui.userMessagesInQueryBuffer->isChecked()); + s.setValue("UserMessagesInCurrentBuffer", ui.userMessagesInCurrentBuffer->isChecked()); + + setChangedState(false); +} + +void GeneralSettingsPage::widgetHasChanged() { + bool changed = testHasChanged(); + if(changed != hasChanged()) setChangedState(changed); +} + +bool GeneralSettingsPage::testHasChanged() { + if(settings["UseSystemTrayIcon"] != ui.useSystemTrayIcon->isChecked()) return true; + if(settings["MinimizeOnMinimize"] != ui.minimizeOnMinimize->isChecked()) return true; + if(settings["MinimizeOnClose"] != ui.minimizeOnClose->isChecked()) return true; + if(settings["UserMessagesInStatusBuffer"] != ui.userMessagesInStatusBuffer->isChecked()) return true; + if(settings["UserMessagesInQueryBuffer"] != ui.userMessagesInQueryBuffer->isChecked()) return true; + if(settings["UserMessagesInCurrentBuffer"] != ui.userMessagesInCurrentBuffer->isChecked()) return true; + + return false; +} + + + + diff --git a/src/qtui/settingspages/generalsettingspage.h b/src/qtui/settingspages/generalsettingspage.h new file mode 100644 index 00000000..42216d82 --- /dev/null +++ b/src/qtui/settingspages/generalsettingspage.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 General 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General 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 _GENERALSETTINGSPAGE_H_ +#define _GENERALSETTINGSPAGE_H_ + +#include + +#include "settingspage.h" +#include "ui_generalsettingspage.h" + +class GeneralSettingsPage : public SettingsPage { + Q_OBJECT + + public: + GeneralSettingsPage(QWidget *parent = 0); + + bool hasDefaults() const; + + public slots: + void save(); + void load(); + void defaults(); + + private slots: + void widgetHasChanged(); + + private: + Ui::GeneralSettingsPage ui; + QHash settings; + + bool testHasChanged(); +}; + +#endif diff --git a/src/qtui/settingspages/generalsettingspage.ui b/src/qtui/settingspages/generalsettingspage.ui new file mode 100644 index 00000000..340faafa --- /dev/null +++ b/src/qtui/settingspages/generalsettingspage.ui @@ -0,0 +1,92 @@ + + GeneralSettingsPage + + + + 0 + 0 + 475 + 366 + + + + Form + + + + + + Use system tray icon: + + + true + + + + + + Minimize to tray on minimize button + + + + + + + Minimize to tray on close button + + + + + + + + + + Display user related messages: + + + + + + in status buffer + + + true + + + + + + + in query buffer (if exists) + + + + + + + in current buffer + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/src/qtui/settingspages/settingspages.pri b/src/qtui/settingspages/settingspages.pri index 09483dac..84cec579 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 = fonts identities networks +SETTINGSPAGES = fonts identities networks general # Specify additional files (e.g. for subdialogs) here! SP_SRCS = diff --git a/version.inc b/version.inc index 741f6a58..0aa8dbea 100644 --- a/version.inc +++ b/version.inc @@ -5,7 +5,7 @@ quasselVersion = "0.2.0-pre"; quasselDate = "2008-02-08"; - quasselBuild = 480; + quasselBuild = 483; //! Minimum client build number the core needs clientBuildNeeded = 480; -- 2.20.1