Browse Source

Move from QML Window class to c++

Donald Carr 7 years ago
parent
commit
fa6412e0a4
2 changed files with 8 additions and 37 deletions
  1. 1 31
      qml/main.qml
  2. 7 6
      src/main.cpp

+ 1 - 31
qml/main.qml

@@ -1,24 +1,14 @@
 import QtQuick 2.5
-import QtQuick.Window 2.2
 import Qt.labs.settings 1.0
 import PictureModel 1.0
 
-Window {
+Item {
     id: appWindow
 
-    color: "black"
-
-    width: 1280
-    height: 720
-
     onWidthChanged: {
         globalUtil.reset()
     }
 
-    function showAtCorrectSize() {
-        globalSettings.fullscreen ? showFullScreen() : show()
-    }
-
     PictureModel {
         id: imageModel
     }
@@ -106,7 +96,6 @@ Window {
 
         property bool smoothArt: false
         property bool randomlyMirrorArt: false
-        property bool fullscreen: true
         property bool commonFeed: true
         property bool commonFeedRoundRobin: true
         property bool unlicensed: false
@@ -120,7 +109,6 @@ Window {
         property real lessGoldenRatio: 4/3
 
         onColumnCountChanged: globalUtil.reset()
-        onFullscreenChanged: showAtCorrectSize()
 
         Component.onCompleted: {
             d.setView(view)
@@ -164,9 +152,6 @@ Window {
         focus: true
         Keys.onPressed: {
             switch(event.key) {
-            case Qt.Key_F:
-                globalSettings.fullscreen = !globalSettings.fullscreen
-                break;
             case Qt.Key_Left:
                 globalSettings.columnCount = Math.max(globalSettings.columnCount - 1, 1);
                 break;
@@ -184,19 +169,4 @@ Window {
             }
         }
     }
-
-    Component.onCompleted: {
-        showTimer.start()
-    }
-
-    Timer {
-        id: showTimer
-
-        running: false
-        repeat: false
-        interval: 1
-        onTriggered: {
-            showAtCorrectSize()
-        }
-    }
 }

+ 7 - 6
src/main.cpp

@@ -23,8 +23,9 @@
 #endif
 
 #include <QGuiApplication>
-#include <QQmlApplicationEngine>
+#include <QQuickView>
 #include <QQmlContext>
+#include <QQmlEngine>
 #include <QSettings>
 #include <QSurfaceFormat>
 #include <QTimer>
@@ -127,7 +128,7 @@ int main(int argc, char *argv[])
     }
 
     NativeUtil nativeUtils;
-    QQmlApplicationEngine engine;
+    QQuickView view;
     qmlRegisterType<PictureModel>("PictureModel", 1, 0, "PictureModel");
 
     QString qmlPath;
@@ -135,15 +136,15 @@ int main(int argc, char *argv[])
     qmlPath = "qrc:/qml";
 #else
     qmlPath = QCoreApplication::applicationDirPath() % "/qml";
-
     if (!QDir(qmlPath).exists()) {
         qmlPath = "/usr/share/" % app.applicationName() % "/qml";
     }
 #endif
 
-    engine.addImportPath(qmlPath);
-    engine.rootContext()->setContextProperty("nativeUtils", &nativeUtils);
-    engine.load(QUrl(qmlPath + "/main.qml"));
+    view.engine()->addImportPath(qmlPath);
+    view.rootContext()->setContextProperty("nativeUtils", &nativeUtils);
+    view.setSource(QUrl(qmlPath + "/main.qml"));
+    view.show();
 
     QGuiApplication::processEvents();
 #ifdef USING_SYSTEMD