change fullscreen button size.
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>
Thu, 22 Nov 2018 05:16:08 +0000 (14:16 +0900)
committerzheng_wenlong <wenlong_zheng@nexty-ele.com>
Thu, 22 Nov 2018 05:16:08 +0000 (14:16 +0900)
homescreen/qml/images/menubar_full_background.png
homescreen/qml/images/menubar_normal_background.png
homescreen/qml/main.qml
homescreen/src/main.cpp

index 39e12b9..16a7e77 100644 (file)
Binary files a/homescreen/qml/images/menubar_full_background.png and b/homescreen/qml/images/menubar_full_background.png differ
index ceb3684..bfffc55 100644 (file)
Binary files a/homescreen/qml/images/menubar_normal_background.png and b/homescreen/qml/images/menubar_normal_background.png differ
index 13500bd..10509fd 100644 (file)
@@ -134,38 +134,44 @@ Window {
 
     Item {
         id: switchBtn
+        width: 110
+        height: 110
         anchors.right: parent.right
-        anchors.rightMargin: 20
         anchors.top: parent.top
-        anchors.topMargin: 5
-        width: 55
-        height: 55
         z: 1
+        Image {
+            id: image
+            width: 55
+            height: 55
+            anchors.right: parent.right
+            anchors.rightMargin: 20
+            anchors.top: parent.top
+            anchors.topMargin: 5
+            source: './images/normal.png'
+        }
 
         MouseArea {
             anchors.fill: parent
             property string btnState: 'normal'
-            Image {
-                id: image
-                anchors.fill: parent
-                source: './images/normal.png'
-            }
             onClicked: {
-                if (btnState === 'normal') {
-                    image.source = './images/fullscreen.png'
-                    btnState = 'fullscreen'
-                    container.state = 'fullscreen'
-                    container.opacity = 0.0
-                    touchArea.switchArea(1)
-
+                if (container.state === 'normal') {
+                    turnToFullscreen()
                 } else {
-                    image.source = './images/normal.png'
-                    btnState = 'normal'
-                    container.state = 'normal'
-                    container.opacity = 1.0
-                    touchArea.switchArea(0)
+                    turnToNormal()
                 }
             }
         }
     }
+    function turnToFullscreen() {
+        image.source = './images/fullscreen.png'
+        container.state = 'fullscreen'
+        container.opacity = 0.0
+        touchArea.switchArea(1)
+    }
+    function turnToNormal() {
+        image.source = './images/normal.png'
+        container.state = 'normal'
+        container.opacity = 1.0
+        touchArea.switchArea(0)
+    }
 }
index a80dd04..08f83a8 100644 (file)
@@ -93,6 +93,9 @@ int main(int argc, char *argv[])
     qmlRegisterType<StatusBarModel>("HomeScreen", 1, 0, "StatusBarModel");
 
     ApplicationLauncher *launcher = new ApplicationLauncher();
+    HomescreenHandler* homescreenHandler = new HomescreenHandler();
+    homescreenHandler->init(port, token.toStdString().c_str());
+
     QLibWindowmanager* layoutHandler = new QLibWindowmanager();
     if(layoutHandler->init(port,token) != 0){
         exit(EXIT_FAILURE);
@@ -102,24 +105,6 @@ int main(int argc, char *argv[])
         exit(EXIT_FAILURE);
     }
 
-    layoutHandler->set_event_handler(QLibWindowmanager::Event_SyncDraw, [layoutHandler](json_object *object) {
-        layoutHandler->endDraw(QString("homescreen"));
-    });
-
-    layoutHandler->set_event_handler(QLibWindowmanager::Event_ScreenUpdated, [layoutHandler, launcher](json_object *object) {
-        json_object *jarray = json_object_object_get(object, "ids");
-        int arrLen = json_object_array_length(jarray);
-        for( int idx = 0; idx < arrLen; idx++)
-        {
-            QString label = QString(json_object_get_string(    json_object_array_get_idx(jarray, idx) ));
-            HMI_DEBUG("HomeScreen","Event_ScreenUpdated application: %s.", label.toStdString().c_str());
-            QMetaObject::invokeMethod(launcher, "setCurrent", Qt::QueuedConnection, Q_ARG(QString, label));
-        }
-    });
-
-    HomescreenHandler* homescreenHandler = new HomescreenHandler();
-    homescreenHandler->init(port, token.toStdString().c_str());
-
     QUrl bindingAddress;
     bindingAddress.setScheme(QStringLiteral("ws"));
     bindingAddress.setHost(QStringLiteral("localhost"));
@@ -134,7 +119,7 @@ int main(int argc, char *argv[])
 
     // mail.qml loading
     QQmlApplicationEngine engine;
-    engine.rootContext()->setContextProperty("layoutHandler", layoutHandler);
+//    engine.rootContext()->setContextProperty("layoutHandler", layoutHandler);
     engine.rootContext()->setContextProperty("homescreenHandler", homescreenHandler);
     engine.rootContext()->setContextProperty("touchArea", touchArea);
     engine.rootContext()->setContextProperty("launcher", launcher);
@@ -143,6 +128,29 @@ int main(int argc, char *argv[])
     engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
 
     QObject *root = engine.rootObjects().first();
+
+    layoutHandler->set_event_handler(QLibWindowmanager::Event_SyncDraw, [layoutHandler](json_object *object) {
+        layoutHandler->endDraw(QString("homescreen"));
+    });
+
+    layoutHandler->set_event_handler(QLibWindowmanager::Event_ScreenUpdated, [layoutHandler, launcher, root](json_object *object) {
+        json_object *jarray = json_object_object_get(object, "ids");
+        int arrLen = json_object_array_length(jarray);
+        for( int idx = 0; idx < arrLen; idx++)
+        {
+            QString label = QString(json_object_get_string(    json_object_array_get_idx(jarray, idx) ));
+            HMI_DEBUG("HomeScreen","Event_ScreenUpdated application: %s.", label.toStdString().c_str());
+            QMetaObject::invokeMethod(launcher, "setCurrent", Qt::QueuedConnection, Q_ARG(QString, label));
+            if(label == "launcher") {
+                QMetaObject::invokeMethod(root, "turnToNormal");
+//                homescreenHandler->emitTurnToFullscreen(false);
+            } else {
+                QMetaObject::invokeMethod(root, "turnToFullscreen");
+//                homescreenHandler->emitTurnToFullscreen(true);
+            }
+        }
+    });
+
     QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
 
     touchArea->setWindow(window);