Просмотр исходного кода

Added option to start minimized

Malte Veerman 6 лет назад
Родитель
Сommit
1d6014169b

+ 1 - 1
fancontrol-gui/package/contents/ui/Application.qml

@@ -34,7 +34,6 @@ ApplicationWindow {
     width: 1024
     height: 768
     color: palette.window
-    visible: true
 
     onClosing: {
         windowConfig.save(window);
@@ -48,6 +47,7 @@ ApplicationWindow {
     Component.onCompleted: {
         Fancontrol.Base.load();
         windowConfig.restore(window);
+        window.visible = !Fancontrol.Base.startMinimized;
     }
 
     toolBar: ToolBar {

+ 25 - 0
fancontrol-gui/package/contents/ui/SettingsTab.qml

@@ -232,6 +232,31 @@ Item {
                 }
             }
         }
+        RowLayout {
+            width: column.width
+            enabled: Fancontrol.Base.showTray
+
+            Label {
+                Layout.preferredWidth: root.textWidth
+                clip: true
+                text: i18n("Start minimized:")
+                horizontalAlignment: Text.AlignRight
+                Component.onCompleted: root.textWidth = Math.max(root.textWidth, contentWidth)
+            }
+            CheckBox {
+                id: startMinimizedBox
+
+                Layout.minimumWidth: implicitWidth
+                Layout.fillWidth: true
+                checked: Fancontrol.Base.startMinimized
+                onCheckedChanged: Fancontrol.Base.startMinimized = checked
+
+                Connections {
+                    target: Fancontrol.Base
+                    onStartMinimizedChanged: if (Fancontrol.Base.startMinimized != startMinimizedBox.checked) startMinimizedBox.checked = Fancontrol.Base.startMinimized
+                }
+            }
+        }
 
         FileDialog {
             id: openFileDialog

+ 1 - 0
import/src/config.cpp

@@ -52,6 +52,7 @@ Config::Config(QObject *parent) : KCoreConfigSkeleton(KSharedConfig::openConfig(
     addItemStringList(QStringLiteral("ProfileNames"), m_profileNames, QStringList());
     addItemInt(QStringLiteral("CurrentProfile"), m_currentProfile, 0);
     addItemBool(QStringLiteral("ShowTray"), m_showTray, true);
+    addItemBool(QStringLiteral("StartMinimized"), m_startMinimized, false);
 
     load();
 }

+ 1 - 0
import/src/config.h

@@ -55,6 +55,7 @@ private:
     QStringList m_profileNames;
     int m_currentProfile;
     bool m_showTray;
+    bool m_startMinimized;
 };
 
 }

+ 19 - 0
import/src/guibase.cpp

@@ -125,6 +125,12 @@ bool GUIBase::showTray() const
     return m_config->findItem(QStringLiteral("ShowTray"))->property().toBool();
 }
 
+bool GUIBase::startMinimized() const
+{
+    m_config->setCurrentGroup(QStringLiteral("preferences"));
+    return m_config->findItem(QStringLiteral("StartMinimized"))->property().toBool();
+}
+
 void GUIBase::setMaxTemp(qreal temp)
 {
     if (temp != maxTemp())
@@ -199,6 +205,19 @@ void GUIBase::setShowTray(bool show)
     emit needsApplyChanged();
 }
 
+void GUIBase::setStartMinimized(bool sm)
+{
+    if (startMinimized() == sm)
+        return;
+
+    m_config->setCurrentGroup(QStringLiteral("preferences"));
+    m_config->findItem(QStringLiteral("StartMinimized"))->setProperty(sm);
+    emit startMinimizedChanged();
+
+    m_configChanged = true;
+    emit needsApplyChanged();
+}
+
 bool GUIBase::needsApply() const
 {
 #ifndef NO_SYSTEMD

+ 4 - 0
import/src/guibase.h

@@ -62,6 +62,7 @@ class GUIBase : public QObject
     Q_PROPERTY(QString error READ error NOTIFY errorChanged)
     Q_PROPERTY(bool needsApply READ needsApply NOTIFY needsApplyChanged)
     Q_PROPERTY(bool showTray READ showTray WRITE setShowTray NOTIFY showTrayChanged)
+    Q_PROPERTY(bool startMinimized READ startMinimized WRITE setStartMinimized NOTIFY startMinimizedChanged)
 
 public:
 
@@ -88,6 +89,8 @@ public:
     bool needsApply() const;
     bool showTray() const;
     void setShowTray(bool show);
+    bool startMinimized() const;
+    void setStartMinimized(bool sm);
     PwmFanModel *pwmFanModel() const { return m_pwmFanModel; }
     TempModel *tempModel() const { return m_tempModel; }
     QStringListModel *profileModel() const { return m_profileModel; }
@@ -118,6 +121,7 @@ signals:
     void criticalError();
     void needsApplyChanged();
     void showTrayChanged();
+    void startMinimizedChanged();
     void profileChanged(int profile);
 
 private: