Make disabling the tray icon animation work again
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 3 Mar 2010 00:37:48 +0000 (01:37 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 3 Mar 2010 01:36:37 +0000 (02:36 +0100)
The setting also moved to the Interface settings page.

src/qtui/legacysystemtray.cpp
src/qtui/mainwin.cpp
src/qtui/settingspages/appearancesettingspage.ui
src/qtui/statusnotifieritem.cpp
src/qtui/systemtray.cpp
src/qtui/systemtray.h
src/qtui/systraynotificationbackend.cpp

index 0c6a1e3..552324c 100644 (file)
@@ -106,7 +106,7 @@ void LegacySystemTray::setState(State state_) {
   State oldstate = state();
   SystemTray::setState(state_);
   if(oldstate != state()) {
-    if(state() == NeedsAttention && mode() == Legacy)
+    if(state() == NeedsAttention && mode() == Legacy && animationEnabled())
       _blinkTimer.start();
     else {
       _blinkTimer.stop();
index fe050fb..79f20aa 100644 (file)
@@ -189,13 +189,14 @@ void MainWin::init() {
   setupHotList();
 
 #ifndef HAVE_KDE
-  QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this));
-#  ifndef QT_NO_SYSTEMTRAYICON
-  QtUi::registerNotificationBackend(new SystrayNotificationBackend(this));
-#  endif
 #  ifdef HAVE_PHONON
   QtUi::registerNotificationBackend(new PhononNotificationBackend(this));
 #  endif
+#  ifndef QT_NO_SYSTEMTRAYICON
+  QtUi::registerNotificationBackend(new SystrayNotificationBackend(this));
+#  endif
+
+  QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this));
 
 #else /* HAVE_KDE */
   QtUi::registerNotificationBackend(new KNotificationBackend(this));
index 4b071ac..c2a643b 100644 (file)
     </widget>
    </item>
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
-     <item>
+    <layout class="QGridLayout" name="gridLayout_3">
+     <item row="0" column="0">
       <spacer name="horizontalSpacer_2">
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
       </spacer>
      </item>
-     <item>
+     <item row="0" column="1">
       <widget class="QCheckBox" name="minimizeOnClose">
        <property name="text">
         <string>Hide to tray on close button</string>
        </property>
       </widget>
      </item>
+     <item row="1" column="0">
+      <spacer name="horizontalSpacer_4">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeType">
+        <enum>QSizePolicy::Fixed</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>20</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item row="1" column="1">
+      <widget class="QCheckBox" name="animateSystrayIcon">
+       <property name="styleSheet">
+        <string notr="true"/>
+       </property>
+       <property name="text">
+        <string>Enable animations</string>
+       </property>
+       <property name="settingsKey" stdset="0">
+        <string notr="true">/Notification/Systray/Animate</string>
+       </property>
+       <property name="defaultValue" stdset="0">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
    <item>
index 9d61fa7..dc2e65c 100644 (file)
@@ -55,6 +55,7 @@ void StatusNotifierItem::init() {
 
   _statusNotifierItemDBus = new StatusNotifierItemDBus(this);
   connect(this, SIGNAL(toolTipChanged(QString,QString)), _statusNotifierItemDBus, SIGNAL(NewToolTip()));
+  connect(this, SIGNAL(animationEnabledChanged(bool)), _statusNotifierItemDBus, SIGNAL(NewAttentionIcon()));
 
   connect(QDBusConnection::sessionBus().interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
                                                      SLOT(serviceChange(QString,QString,QString)));
@@ -160,7 +161,10 @@ QString StatusNotifierItem::iconName() const {
 }
 
 QString StatusNotifierItem::attentionIconName() const {
-  return QString("quassel_message");
+  if(animationEnabled())
+    return QString("quassel_message");
+  else
+    return QString("quassel");
 }
 
 QString StatusNotifierItem::toolTipIconName() const {
index afa7964..7fb36ce 100644 (file)
@@ -81,6 +81,9 @@ void SystemTray::init() {
   _trayMenu->addAction(coll->action("Quit"));
 
   connect(_trayMenu, SIGNAL(aboutToShow()), SLOT(trayMenuAboutToShow()));
+
+  NotificationSettings notificationSettings;
+  notificationSettings.initAndNotify("Systray/Animate", this, SLOT(enableAnimationChanged(QVariant)), true);
 }
 
 void SystemTray::trayMenuAboutToShow() {
@@ -159,3 +162,8 @@ void SystemTray::activate(SystemTray::ActivationReason reason) {
 void SystemTray::minimizeRestore() {
   GraphicalUi::toggleMainWidget();
 }
+
+void SystemTray::enableAnimationChanged(const QVariant &v) {
+  _animationEnabled = v.toBool();
+  emit animationEnabledChanged(v.toBool());
+}
index 35a9c17..ad7a9ff 100644 (file)
@@ -83,6 +83,7 @@ public slots:
 signals:
   void activated(SystemTray::ActivationReason);
   void iconChanged(const Icon &);
+  void animationEnabledChanged(bool);
   void toolTipChanged(const QString &title, const QString &subtitle);
   void messageClicked(uint notificationId);
   void messageClosed(uint notificationId);
@@ -100,10 +101,12 @@ protected:
   inline QString toolTipSubTitle() const;
   inline QMenu *trayMenu() const;
 
+  inline bool animationEnabled() const;
 
 private slots:
   void minimizeRestore();
   void trayMenuAboutToShow();
+  void enableAnimationChanged(const QVariant &);
 
 private:
   Mode _mode;
@@ -111,6 +114,7 @@ private:
 
   QString _toolTipTitle, _toolTipSubTitle;
   Icon _passiveIcon, _activeIcon, _needsAttentionIcon;
+  bool _animationEnabled;
 
   QMenu *_trayMenu;
   QWidget *_associatedWidget;
@@ -126,6 +130,6 @@ SystemTray::State SystemTray::state() const { return _state; }
 QMenu *SystemTray::trayMenu() const { return _trayMenu; }
 QString SystemTray::toolTipTitle() const { return _toolTipTitle; }
 QString SystemTray::toolTipSubTitle() const { return _toolTipSubTitle; }
-
+bool SystemTray::animationEnabled() const { return _animationEnabled; }
 
 #endif
index f3bd5a0..82d9f96 100644 (file)
@@ -38,11 +38,8 @@ SystrayNotificationBackend::SystrayNotificationBackend(QObject *parent)
   _blockActivation(false)
 {
   NotificationSettings notificationSettings;
-  _showBubble = notificationSettings.value("Systray/ShowBubble", true).toBool();
-  _animate = notificationSettings.value("Systray/Animate", true).toBool();
-
-  notificationSettings.notify("Systray/ShowBubble", this, SLOT(showBubbleChanged(const QVariant &)));
-  notificationSettings.notify("Systray/Animate", this, SLOT(animateChanged(const QVariant &)));
+  notificationSettings.initAndNotify("Systray/ShowBubble", this, SLOT(showBubbleChanged(QVariant)), true);
+  notificationSettings.initAndNotify("Systray/Animate", this, SLOT(animateChanged(QVariant)), true);
 
   connect(QtUi::mainWindow()->systemTray(), SIGNAL(messageClicked(uint)), SLOT(notificationActivated(uint)));
   connect(QtUi::mainWindow()->systemTray(), SIGNAL(activated(SystemTray::ActivationReason)),