added general settings page
authorAlexander von Renteln <phon@quassel-irc.org>
Fri, 8 Feb 2008 15:17:48 +0000 (15:17 +0000)
committerAlexander von Renteln <phon@quassel-irc.org>
Fri, 8 Feb 2008 15:17:48 +0000 (15:17 +0000)
minimize and close buttons can now be configured to minimize quasselclient to the system tray

src/qtui/mainwin.cpp
src/qtui/mainwin.h
src/qtui/qtui.pri
src/qtui/qtuisettings.cpp [new file with mode: 0644]
src/qtui/qtuisettings.h [new file with mode: 0644]
src/qtui/settingspages/generalsettingspage.cpp [new file with mode: 0644]
src/qtui/settingspages/generalsettingspage.h [new file with mode: 0644]
src/qtui/settingspages/generalsettingspage.ui [new file with mode: 0644]
src/qtui/settingspages/settingspages.pri
version.inc

index bd99269..fb0ebdb 100644 (file)
@@ -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();
   }
 }
 
index 12c639f..a78832d 100644 (file)
@@ -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);
index 29c0e02..d7f0f83 100644 (file)
@@ -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 (file)
index 0000000..2a79bc7
--- /dev/null
@@ -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 (file)
index 0000000..fa3c792
--- /dev/null
@@ -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 (file)
index 0000000..5341511
--- /dev/null
@@ -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 (file)
index 0000000..42216d8
--- /dev/null
@@ -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 <QHash>
+
+#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<QString, QVariant> settings;
+
+    bool testHasChanged();
+};
+
+#endif
diff --git a/src/qtui/settingspages/generalsettingspage.ui b/src/qtui/settingspages/generalsettingspage.ui
new file mode 100644 (file)
index 0000000..340faaf
--- /dev/null
@@ -0,0 +1,92 @@
+<ui version="4.0" >
+ <class>GeneralSettingsPage</class>
+ <widget class="QWidget" name="GeneralSettingsPage" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>475</width>
+    <height>366</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" >
+   <item>
+    <widget class="QGroupBox" name="useSystemTrayIcon" >
+     <property name="title" >
+      <string>Use system tray icon:</string>
+     </property>
+     <property name="checkable" >
+      <bool>true</bool>
+     </property>
+     <layout class="QVBoxLayout" >
+      <item>
+       <widget class="QCheckBox" name="minimizeOnMinimize" >
+        <property name="text" >
+         <string>Minimize to tray on minimize button</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="minimizeOnClose" >
+        <property name="text" >
+         <string>Minimize to tray on close button</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox" >
+     <property name="title" >
+      <string>Display user related messages:</string>
+     </property>
+     <layout class="QVBoxLayout" >
+      <item>
+       <widget class="QCheckBox" name="userMessagesInStatusBuffer" >
+        <property name="text" >
+         <string>in status buffer</string>
+        </property>
+        <property name="checked" >
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="userMessagesInQueryBuffer" >
+        <property name="text" >
+         <string> in query buffer (if exists)</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="userMessagesInCurrentBuffer" >
+        <property name="text" >
+         <string>in current buffer</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index 09483da..84cec57 100644 (file)
@@ -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 =
index 741f6a5..0aa8dbe 100644 (file)
@@ -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;