Browse Source

Add update notification icon

Donald Carr 8 years ago
parent
commit
a330bae4c5

+ 8 - 3
qml/main.qml

@@ -112,7 +112,8 @@ Window {
         property bool unlicensed: false
         property bool fadeInImages: true
         property bool useGoldenRatio: false
-        property bool widgetTray: false
+        property bool infoTray: false
+        property bool rebootNecessary: true
 
         property real randomlyMirrorArtFreq: 0.5
         property real artOpacity: 1.0
@@ -144,8 +145,12 @@ Window {
                 Qt.createQmlObject(globalSettings.backdrop + ' { anchors.fill: parent }', root)
             }
 
-            if (globalSettings.widgetTray) {
-                Qt.createQmlObject('WidgetTray { z: 2; anchors { top: parent.top; right: parent.right } }', root)
+            if (globalSettings.rebootNecessary) {
+                Qt.createQmlObject('RebootReq { z: 2; anchors { top: parent.top; right: parent.right } }', root)
+            }
+
+            if (globalSettings.infoTray) {
+                Qt.createQmlObject('InfoTray { z: 2; anchors { bottom: parent.bottom; left: parent.left } }', root)
             }
 
             if (globalSettings.unlicensed) {

+ 1 - 1
qml/qml.pro

@@ -8,7 +8,7 @@ DISTFILES += \
         widgets/Clock.qml \
         widgets/ItemCount.qml \
         widgets/Resolution.qml \
-        widgets/WidgetTray.qml \
+        widgets/InfoTray.qml \
         common/VisualEffect.qml \
         common/ArtImage.qml \
         common/View.qml \

+ 2 - 1
qml/qmldir

@@ -10,7 +10,8 @@ FPS 1.0 widgets/FPS.qml
 Clock 1.0 widgets/Clock.qml
 Resolution 1.0 widgets/Resolution.qml
 ItemCount 1.0 widgets/ItemCount.qml
-WidgetTray 1.0 widgets/WidgetTray.qml
+InfoTray 1.0 widgets/InfoTray.qml
+RebootReq 1.0 widgets/RebootReq.qml
 Cells 1.0 3rdparty/backdrops/cells/cells.qml
 Swirls 1.0 3rdparty/backdrops/qml-presentation-visuals/BackgroundSwirls.qml
 Unlicensed 1.0 unlicensed/Unlicensed.qml

+ 0 - 0
qml/widgets/WidgetTray.qml → qml/widgets/InfoTray.qml


+ 6 - 0
qml/widgets/RebootReq.qml

@@ -0,0 +1,6 @@
+import QtQuick 2.5
+
+Image {
+  visible: nativeUtils.rebootRequired
+  source: "qrc:///buuf/Free Your Mind.png"
+}

+ 39 - 0
src/main.cpp

@@ -33,6 +33,41 @@
 #include <QScreen>
 #include <QDBusInterface>
 #include <QDBusConnection>
+#include <QFileSystemWatcher>
+
+class NativeUtil : public QObject {
+    Q_OBJECT
+    Q_PROPERTY(bool rebootRequired MEMBER rebootRequired NOTIFY rebootRequiredChanged)
+public:
+    NativeUtil();
+
+signals:
+    void rebootRequiredChanged();
+public slots:
+    void monitorRunPath(const QString &path);
+private:
+    QString watchFile;
+    QFileSystemWatcher runDirWatcher;
+    bool rebootRequired;
+};
+
+NativeUtil::NativeUtil()
+    : QObject(),
+      watchFile("/run/reboot-required"),
+      rebootRequired(false)
+{
+    runDirWatcher.addPath(QFileInfo(watchFile).absolutePath());
+    connect(&runDirWatcher, &QFileSystemWatcher::directoryChanged, this, &NativeUtil::monitorRunPath);
+    monitorRunPath("");
+}
+
+void NativeUtil::monitorRunPath(const QString &path)
+{
+    Q_UNUSED(path);
+
+    rebootRequired = QFileInfo::exists(watchFile);
+    emit rebootRequiredChanged();
+}
 
 int main(int argc, char *argv[])
 {
@@ -83,6 +118,7 @@ int main(int argc, char *argv[])
         });
     }
 
+    NativeUtil nativeUtils;
     QQmlApplicationEngine engine;
     qmlRegisterType<PictureModel>("PictureModel", 1, 0, "PictureModel");
 
@@ -94,8 +130,11 @@ int main(int argc, char *argv[])
     }
 
     engine.addImportPath(qmlPath);
+    engine.rootContext()->setContextProperty("nativeUtils", &nativeUtils);
     engine.rootContext()->setContextProperty("fileReader", new FileReader(&app));
     engine.load(QUrl(qmlPath + "/main.qml"));
 
     return app.exec();
 }
+
+#include "main.moc"

BIN
src/resources/buuf/Free Your Mind.png


+ 3 - 0
src/resources/buuf/origin

@@ -0,0 +1,3 @@
+http://mattahan.deviantart.com/art/Buuf-37966044
+license: Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
+url: https://creativecommons.org/licenses/by-nc-sa/2.5/

+ 1 - 0
src/resources/resources.qrc

@@ -1,5 +1,6 @@
 <RCC>
     <qresource prefix="/">
         <file>qt_logo_green_rgb.png</file>
+        <file>buuf/Free Your Mind.png</file>
     </qresource>
 </RCC>