Move systray animation settings to notification settings page
authorromibi <romibi@bluewin.ch>
Mon, 5 Feb 2018 17:51:54 +0000 (18:51 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 14 Jun 2018 18:53:26 +0000 (20:53 +0200)
src/qtui/settingspages/appearancesettingspage.ui
src/qtui/systrayanimationnotificationbackend.cpp
src/qtui/systrayanimationnotificationbackend.h

index 5d8fa77..abf67d5 100644 (file)
        </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 2cb0550..65cc38b 100644 (file)
@@ -65,5 +65,55 @@ void SystrayAnimationNotificationBackend::animateChanged(const QVariant &v)
 
 SettingsPage *SystrayAnimationNotificationBackend::createConfigWidget() const
 {
-    return nullptr;
+    return new ConfigWidget();
+}
+
+
+/***************************************************************************/
+
+SystrayAnimationNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : SettingsPage("Internal", "SystrayNotification", parent)
+{
+    _animateBox = new QCheckBox(tr("Animate system tray icon"));
+    _animateBox->setIcon(QIcon::fromTheme("dialog-information"));
+    connect(_animateBox, SIGNAL(toggled(bool)), this, SLOT(widgetChanged()));
+    QHBoxLayout *layout = new QHBoxLayout(this);
+    layout->addWidget(_animateBox);
+}
+
+
+void SystrayAnimationNotificationBackend::ConfigWidget::widgetChanged()
+{
+    bool changed = (_animate != _animateBox->isChecked());
+    if (changed != hasChanged())
+        setChangedState(changed);
+}
+
+
+bool SystrayAnimationNotificationBackend::ConfigWidget::hasDefaults() const
+{
+    return true;
+}
+
+
+void SystrayAnimationNotificationBackend::ConfigWidget::defaults()
+{
+    _animateBox->setChecked(false);
+    widgetChanged();
+}
+
+
+void SystrayAnimationNotificationBackend::ConfigWidget::load()
+{
+    NotificationSettings s;
+    _animate = s.value("Systray/Animate", true).toBool();
+    _animateBox->setChecked(_animate);
+    setChangedState(false);
+}
+
+
+void SystrayAnimationNotificationBackend::ConfigWidget::save()
+{
+    NotificationSettings s;
+    s.setValue("Systray/Animate", _animateBox->isChecked());
+    load();
 }
\ No newline at end of file
index 6a72001..cbe934d 100644 (file)
@@ -41,5 +41,26 @@ private slots:
     void animateChanged(const QVariant &);
 
 private:
+    class ConfigWidget;
+    bool _animate;
+};
+
+
+class SystrayAnimationNotificationBackend::ConfigWidget : public SettingsPage
+{
+    Q_OBJECT
+
+public:
+    ConfigWidget(QWidget *parent = 0);
+    void save();
+    void load();
+    bool hasDefaults() const;
+    void defaults();
+
+private slots:
+    void widgetChanged();
+
+private:
+    QCheckBox *_animateBox;
     bool _animate;
 };
\ No newline at end of file