created buffersettings to access options concerning buffers
authorAlexander von Renteln <phon@quassel-irc.org>
Mon, 25 Feb 2008 15:19:22 +0000 (15:19 +0000)
committerAlexander von Renteln <phon@quassel-irc.org>
Mon, 25 Feb 2008 15:19:22 +0000 (15:19 +0000)
buffer tooltip can now be configured (with or without topic)
change buffers with mouse scrolling is now optional (default enabled)

12 files changed:
src/client/buffersettings.cpp [new file with mode: 0644]
src/client/buffersettings.h [new file with mode: 0644]
src/client/client.pri
src/client/clientsettings.cpp
src/client/clientsettings.h
src/client/networkmodel.cpp
src/qtui/mainwin.cpp
src/qtui/settingspages/colorsettingspage.ui
src/qtui/settingspages/generalsettingspage.cpp
src/qtui/settingspages/generalsettingspage.ui
src/uisupport/bufferview.cpp
version.inc

diff --git a/src/client/buffersettings.cpp b/src/client/buffersettings.cpp
new file mode 100644 (file)
index 0000000..c586471
--- /dev/null
@@ -0,0 +1,33 @@
+/***************************************************************************
+ *   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 "buffersettings.h"
+
+BufferSettings::BufferSettings(const QString &group) : ClientSettings(group) {
+
+}
+
+void BufferSettings::setValue(const QString &key, const QVariant &data) {
+  setLocalValue(key, data);
+}
+
+QVariant BufferSettings::value(const QString &key, const QVariant &def) {
+  return localValue(key, def);
+}
\ No newline at end of file
diff --git a/src/client/buffersettings.h b/src/client/buffersettings.h
new file mode 100644 (file)
index 0000000..f4266a5
--- /dev/null
@@ -0,0 +1,38 @@
+/***************************************************************************
+ *   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 _BUFFERSETTINGS_H_
+#define _BUFFERSETTINGS_H_
+
+#include "clientsettings.h"
+
+class BufferSettings : public ClientSettings {
+
+  public:
+    BufferSettings(const QString &group = "Buffer");
+
+    void setValue(const QString &key, const QVariant &data);
+    QVariant value(const QString &key, const QVariant &def = QVariant());
+
+
+};
+
+
+#endif
index a6b81f4..cf6586c 100644 (file)
@@ -1,6 +1,6 @@
 DEPMOD = common
 QT_MOD = core network gui
-SRCS += buffer.cpp treemodel.cpp networkmodel.cpp buffermodel.cpp client.cpp clientsettings.cpp clientsyncer.cpp \
+SRCS += buffer.cpp buffersettings.cpp treemodel.cpp networkmodel.cpp buffermodel.cpp client.cpp clientsettings.cpp clientsyncer.cpp \
         mappedselectionmodel.cpp modelpropertymapper.cpp selectionmodelsynchronizer.cpp
-HDRS += buffer.h treemodel.h networkmodel.h buffermodel.h client.h clientsettings.h clientsyncer.h quasselui.h \
+HDRS += buffer.h buffersettings.h treemodel.h networkmodel.h buffermodel.h client.h clientsettings.h clientsyncer.h quasselui.h \
         mappedselectionmodel.h modelpropertymapper.h selectionmodelsynchronizer.h
index 7cccac6..f35420d 100644 (file)
@@ -104,20 +104,4 @@ void CoreAccountSettings::removeAccount(AccountId id) {
   removeLocalKey(QString("%1").arg(id.toInt()));
 }
 
-/***********************************************************************************************/
-
-BufferSettings::BufferSettings(BufferId bufferId)
-  : CoreAccountSettings(QString("Buffers/%1").arg(bufferId.toInt()))
-{
-}
-
-void BufferSettings::setLastSeen(QDateTime seenDate) {
-  setAccountValue("LastSeen", seenDate);
-}
-
-QDateTime BufferSettings::lastSeen() {
-  return accountValue("LastSeen", QDateTime()).value<QDateTime>();
-}
-
-/***********************************************************************************************/
 
index 20dc918..919084e 100644 (file)
@@ -68,12 +68,4 @@ class CoreAccountSettings : public ClientSettings {
     QString _subgroup;
 };
 
-class BufferSettings : public CoreAccountSettings {
-public:
-  BufferSettings(BufferId bufferId);
-
-  void setLastSeen(QDateTime);
-  QDateTime lastSeen();
-};
-
 #endif
index a72b71e..94d90b8 100644 (file)
 #include "ircchannel.h"
 #include "ircuser.h"
 
+#include "buffersettings.h"
+
 #include "util.h" // get rid of this (needed for isChannelName)
 
+// #define PHONDEV
+
 /*****************************************
 *  Fancy Buffer Items
 *****************************************/
@@ -293,10 +297,22 @@ QString BufferItem::toolTip(int column) const {
       break;
     }
     case BufferInfo::ChannelBuffer:
-      toolTip.append(QString("<b>Channel %1</b>").arg(bufferName()));
+      toolTip.append(QString("<h4>Channel %1</h4>").arg(bufferName()));
       if(isActive()) {
-        toolTip.append(QString("Topic: %1").arg(topic()));
-        toolTip.append(QString("Users: %1").arg(nickCount()));
+        //TODO: add channel modes 
+        toolTip.append(QString("<b>Users:</b> %1").arg(nickCount()));
+
+        BufferSettings s;
+        bool showTopic = s.value("DisplayTopicInTooltip", QVariant(false)).toBool();
+        if(showTopic) {
+          QString _topic = topic();
+          if(_topic != "") {
+            _topic.replace(QString("<"), QString("&lt;"));
+            _topic.replace(QString(">"), QString("&gt;"));
+            toolTip.append(QString("<font size='-2'>&nbsp;</font>"));
+            toolTip.append(QString("<b>Topic:</b> %1").arg(_topic));
+          }
+        }
       } else {
         toolTip.append(QString("Not active <br /> Double-click to join"));
       }
index 7ccd533..32a59df 100644 (file)
@@ -281,7 +281,7 @@ void MainWin::setupSystray() {
 
   systray->setContextMenu(systrayMenu);
 
-  QtUiSettings s;
+  UiSettings s;
   if(s.value("UseSystemTrayIcon", QVariant(true)).toBool()) {
     systray->show();
   }
@@ -296,7 +296,7 @@ void MainWin::setupSystray() {
 void MainWin::changeEvent(QEvent *event) {
   if(event->type() == QEvent::WindowStateChange) {
     if(windowState() & Qt::WindowMinimized) {
-      QtUiSettings s;
+      UiSettings s;
       if(s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnMinimize").toBool()) {
         toggleVisibility();
         event->ignore();
@@ -368,7 +368,7 @@ void MainWin::showAboutDlg() {
 }
 
 void MainWin::closeEvent(QCloseEvent *event) {
-  QtUiSettings s;
+  UiSettings s;
   if(s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnClose").toBool()) {
     toggleVisibility();
     event->ignore();
index 112fe37..8fbc33d 100644 (file)
           </item>
           <item row="1" column="1" >
            <widget class="ColorButton" name="noActivityFG" >
+            <property name="sizePolicy" >
+             <sizepolicy vsizetype="Maximum" hsizetype="Maximum" >
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
             <property name="text" >
              <string/>
             </property>
             <property name="enabled" >
              <bool>false</bool>
             </property>
+            <property name="sizePolicy" >
+             <sizepolicy vsizetype="Maximum" hsizetype="Maximum" >
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
             <property name="text" >
              <string/>
             </property>
index e18e436..e8e6bfb 100644 (file)
@@ -21,7 +21,8 @@
 #include "generalsettingspage.h"
 
 #include "qtui.h"
-#include "qtuisettings.h"
+#include "uisettings.h"
+#include "buffersettings.h"
 
 GeneralSettingsPage::GeneralSettingsPage(QWidget *parent)
   : SettingsPage(tr("Behaviour"), tr("General"), parent) {
@@ -45,6 +46,13 @@ GeneralSettingsPage::GeneralSettingsPage(QWidget *parent)
   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()));
+
+  connect(ui.displayTopicInTooltip, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged()));
+  connect(ui.mouseWheelChangesBuffers, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged()));
+
+  ui.userMessagesInStatusBuffer->setEnabled(false);
+  ui.userMessagesInQueryBuffer->setEnabled(false);
+  ui.userMessagesInCurrentBuffer->setEnabled(false);
 }
 
 bool GeneralSettingsPage::hasDefaults() const {
@@ -62,42 +70,58 @@ void GeneralSettingsPage::defaults() {
   ui.userMessagesInQueryBuffer->setChecked(false);
   ui.userMessagesInCurrentBuffer->setChecked(false);
 
+  ui.displayTopicInTooltip->setChecked(false);
+  ui.mouseWheelChangesBuffers->setChecked(true);
+
   widgetHasChanged();
 }
 
 void GeneralSettingsPage::load() {
-  QtUiSettings s;
-  settings["UseSystemTrayIcon"] = s.value("UseSystemTrayIcon", QVariant(true));
+  // uiSettings:
+  UiSettings uiSettings("Ui");
+  settings["UseSystemTrayIcon"] = uiSettings.value("UseSystemTrayIcon", QVariant(true));
   ui.useSystemTrayIcon->setChecked(settings["UseSystemTrayIcon"].toBool());
   ui.showSystemTrayIcon->setChecked(settings["UseSystemTrayIcon"].toBool());
 
-  settings["MinimizeOnMinimize"] = s.value("MinimizeOnMinimize", QVariant(false));
+  settings["MinimizeOnMinimize"] = uiSettings.value("MinimizeOnMinimize", QVariant(false));
   ui.minimizeOnMinimize->setChecked(settings["MinimizeOnMinimize"].toBool());
 
-  settings["MinimizeOnClose"] = s.value("MinimizeOnClose", QVariant(false));
+  settings["MinimizeOnClose"] = uiSettings.value("MinimizeOnClose", QVariant(false));
   ui.minimizeOnClose->setChecked(settings["MinimizeOnClose"].toBool());
 
-  settings["UserMessagesInStatusBuffer"] = s.value("UserMessagesInStatusBuffer", QVariant(true));
+  settings["MouseWheelChangesBuffers"] = uiSettings.value("mouseWheelChangesBuffers", QVariant(true));
+  ui.mouseWheelChangesBuffers->setChecked(settings["MouseWheelChangesBuffers"].toBool());
+
+  // bufferSettings:
+  BufferSettings bufferSettings;
+  settings["UserMessagesInStatusBuffer"] = bufferSettings.value("UserMessagesInStatusBuffer", QVariant(true));
   ui.userMessagesInStatusBuffer->setChecked(settings["UserMessagesInStatusBuffer"].toBool());
 
-  settings["UserMessagesInQueryBuffer"] = s.value("UserMessagesInQueryBuffer", QVariant(false));
+  settings["UserMessagesInQueryBuffer"] = bufferSettings.value("UserMessagesInQueryBuffer", QVariant(false));
   ui.userMessagesInQueryBuffer->setChecked(settings["UserMessagesInQueryBuffer"].toBool());
 
-  settings["UserMessagesInCurrentBuffer"] = s.value("UserMessagesInCurrentBuffer", QVariant(false));
+  settings["UserMessagesInCurrentBuffer"] = bufferSettings.value("UserMessagesInCurrentBuffer", QVariant(false));
   ui.userMessagesInCurrentBuffer->setChecked(settings["UserMessagesInCurrentBuffer"].toBool());
 
+  settings["DisplayTopicInTooltip"] = bufferSettings.value("DisplayTopicInTooltip", QVariant(false));
+  ui.displayTopicInTooltip->setChecked(settings["DisplayTopicInTooltip"].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());
+  UiSettings uiSettings("Ui");
+  uiSettings.setValue("UseSystemTrayIcon", ui.useSystemTrayIcon->isChecked());
+  uiSettings.setValue("MinimizeOnMinimize",  ui.minimizeOnMinimize->isChecked());
+  uiSettings.setValue("MinimizeOnClose", ui.minimizeOnClose->isChecked());
+  uiSettings.setValue("MouseWheelChangesBuffers", ui.mouseWheelChangesBuffers->isChecked());
+
+  BufferSettings bufferSettings;
+  bufferSettings.setValue("UserMessagesInStatusBuffer", ui.userMessagesInStatusBuffer->isChecked());
+  bufferSettings.setValue("UserMessagesInQueryBuffer", ui.userMessagesInQueryBuffer->isChecked());
+  bufferSettings.setValue("UserMessagesInCurrentBuffer", ui.userMessagesInCurrentBuffer->isChecked());
 
-  s.setValue("UserMessagesInStatusBuffer", ui.userMessagesInStatusBuffer->isChecked());
-  s.setValue("UserMessagesInQueryBuffer", ui.userMessagesInQueryBuffer->isChecked());
-  s.setValue("UserMessagesInCurrentBuffer", ui.userMessagesInCurrentBuffer->isChecked());
+  bufferSettings.setValue("DisplayTopicInTooltip", ui.displayTopicInTooltip->isChecked());
 
   load();
   setChangedState(false);
@@ -112,10 +136,14 @@ bool GeneralSettingsPage::testHasChanged() {
   if(settings["UseSystemTrayIcon"].toBool() != ui.useSystemTrayIcon->isChecked()) return true;
   if(settings["MinimizeOnMinimize"].toBool() != ui.minimizeOnMinimize->isChecked()) return true;
   if(settings["MinimizeOnClose"].toBool() != ui.minimizeOnClose->isChecked()) return true;
+
   if(settings["UserMessagesInStatusBuffer"].toBool() != ui.userMessagesInStatusBuffer->isChecked()) return true;
   if(settings["UserMessagesInQueryBuffer"].toBool() != ui.userMessagesInQueryBuffer->isChecked()) return true;
   if(settings["UserMessagesInCurrentBuffer"].toBool() != ui.userMessagesInCurrentBuffer->isChecked()) return true;
 
+  if(settings["DisplayTopicInTooltip"].toBool() != ui.displayTopicInTooltip->isChecked()) return true;
+  if(settings["MouseWheelChangesBuffers"].toBool() != ui.mouseWheelChangesBuffers->isChecked()) return true;
+
   return false;
 }
 
index 51cece6..4a4784e 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>475</width>
-    <height>366</height>
+    <width>448</width>
+    <height>480</height>
    </rect>
   </property>
   <property name="windowTitle" >
@@ -67,7 +67,7 @@
       <item>
        <widget class="QCheckBox" name="userMessagesInStatusBuffer" >
         <property name="enabled" >
-         <bool>false</bool>
+         <bool>true</bool>
         </property>
         <property name="text" >
          <string>in status buffer</string>
@@ -80,7 +80,7 @@
       <item>
        <widget class="QCheckBox" name="userMessagesInQueryBuffer" >
         <property name="enabled" >
-         <bool>false</bool>
+         <bool>true</bool>
         </property>
         <property name="text" >
          <string>in query buffer (if exists)</string>
@@ -90,7 +90,7 @@
       <item>
        <widget class="QCheckBox" name="userMessagesInCurrentBuffer" >
         <property name="enabled" >
-         <bool>false</bool>
+         <bool>true</bool>
         </property>
         <property name="text" >
          <string>in current buffer</string>
      </layout>
     </widget>
    </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox_2" >
+     <property name="title" >
+      <string>Buffer view:</string>
+     </property>
+     <layout class="QVBoxLayout" >
+      <item>
+       <widget class="QCheckBox" name="displayTopicInTooltip" >
+        <property name="text" >
+         <string>Display topic in tooltip</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="mouseWheelChangesBuffers" >
+        <property name="text" >
+         <string>Mouse wheel changes displayed buffers</string>
+        </property>
+        <property name="checked" >
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
    <item>
     <spacer>
      <property name="orientation" >
       <enum>Qt::Vertical</enum>
      </property>
-     <property name="sizeHint" stdset="0" >
+     <property name="sizeHint" >
       <size>
-       <width>457</width>
-       <height>51</height>
+       <width>20</width>
+       <height>40</height>
       </size>
      </property>
     </spacer>
   </layout>
  </widget>
  <resources/>
- <connections>
-  <connection>
-   <sender>showSystemTrayIcon</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>useSystemTrayIcon</receiver>
-   <slot>setChecked(bool)</slot>
-   <hints>
-    <hint type="sourcelabel" >
-     <x>237</x>
-     <y>139</y>
-    </hint>
-    <hint type="destinationlabel" >
-     <x>237</x>
-     <y>49</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>useSystemTrayIcon</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>showSystemTrayIcon</receiver>
-   <slot>setChecked(bool)</slot>
-   <hints>
-    <hint type="sourcelabel" >
-     <x>237</x>
-     <y>49</y>
-    </hint>
-    <hint type="destinationlabel" >
-     <x>237</x>
-     <y>139</y>
-    </hint>
-   </hints>
-  </connection>
- </connections>
+ <connections/>
 </ui>
index 380828d..0ebfdea 100644 (file)
@@ -24,6 +24,8 @@
 #include "networkmodel.h"
 #include "network.h"
 
+#include "uisettings.h"
+
 /*****************************************
 * The TreeView showing the Buffers
 *****************************************/
@@ -222,6 +224,8 @@ void BufferView::showContextMenu(const QPoint &pos) {
 
 void BufferView::wheelEvent(QWheelEvent* event)
 {
+  UiSettings s;
+  if(s.value("MouseWheelChangesBuffers",QVariant(true)).toBool()) {
     int rowDelta = ( event->delta() > 0 ) ? -1 : 1;
     QModelIndex currentIndex = selectionModel()->currentIndex();
     QModelIndex resultingIndex;
@@ -242,5 +246,8 @@ void BufferView::wheelEvent(QWheelEvent* event)
     }
     selectionModel()->setCurrentIndex( resultingIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
     selectionModel()->select( resultingIndex, QItemSelectionModel::ClearAndSelect );
+  } else {
+    QAbstractScrollArea::wheelEvent(event);
+  }
 }
 
index a682746..96e2b8a 100644 (file)
@@ -5,7 +5,7 @@
 
   quasselVersion = "0.2.0-alpha1";
   quasselDate = "2008-02-24";
-  quasselBuild = 584;
+  quasselBuild = 585;
 
   //! Minimum client build number the core needs
   clientBuildNeeded = 563;