qlibwindowmanager is now outside of the project 41/11941/4 4.99.3 eel/4.99.3 eel_4.99.3
authorRomain Forlot <romain.forlot@iot.bzh>
Mon, 13 Nov 2017 22:01:57 +0000 (23:01 +0100)
committerRomain Forlot <romain.forlot@iot.bzh>
Tue, 14 Nov 2017 13:38:02 +0000 (13:38 +0000)
Change-Id: Ifdabb7a3456ade9449e399a13ec43aac68ded108
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
app/app.pro
app/main.cpp
app/qlibwindowmanager.cpp [deleted file]
app/qlibwindowmanager.h [deleted file]

index 62d547e..00c9c55 100644 (file)
@@ -1,11 +1,10 @@
 TARGET = hvac
-QT = quickcontrols2
+QT = quickcontrols2 qml
 
-HEADERS = qlibwindowmanager.h
-SOURCES = main.cpp qlibwindowmanager.cpp
+SOURCES = main.cpp
 
 CONFIG += link_pkgconfig
-PKGCONFIG += libhomescreen libwindowmanager
+PKGCONFIG += libhomescreen libwindowmanager qlibwindowmanager
 
 RESOURCES += \
     hvac.qrc \
index 7722a0a..57c731e 100644 (file)
 #include <QtQuickControls2/QQuickStyle>
 #include <QQuickWindow>
 #include <libhomescreen.hpp>
-#include "qlibwindowmanager.h"
+#include <qlibwindowmanager.h>
 
 int main(int argc, char *argv[])
 {
-    std::string myname = std::string("HVAC");
+    QString myname = QString("HVAC");
 
     QGuiApplication app(argc, argv);
-    app.setApplicationName(myname.c_str());
     app.setApplicationVersion(QStringLiteral("0.1.0"));
     app.setOrganizationDomain(QStringLiteral("automotivelinux.org"));
     app.setOrganizationName(QStringLiteral("AutomotiveGradeLinux"));
@@ -69,29 +68,27 @@ int main(int argc, char *argv[])
             exit(EXIT_FAILURE);
         }
         // Request a surface as described in layers.json windowmanager’s file
-        if (qwm->requestSurface(json_object_new_string(myname.c_str())) != 0) {
+        if (qwm->requestSurface(myname) != 0) {
             exit(EXIT_FAILURE);
         }
-        // Create an event callback against an event type. Here a lambda is called when SyncDraw event occurs
+        // Create an event callbnewack against an event type. Here a lambda is called when SyncDraw event occurs
         qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [qwm, myname](json_object *object) {
             fprintf(stderr, "Surface got syncDraw!\n");
-            qwm->endDraw(json_object_new_string(myname.c_str()));
+            qwm->endDraw(myname);
         });
 
         // HomeScreen
         hs->init(port, token.c_str());
         // Set the event handler for Event_TapShortcut which will activate the surface for windowmanager
         hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [qwm, myname](json_object *object){
-            qDebug("object %s", json_object_to_json_string(object));
             json_object *appnameJ = nullptr;
             if(json_object_object_get_ex(object, "application_name", &appnameJ))
             {
                 const char *appname = json_object_get_string(appnameJ);
-                qDebug("appnameJ %s", json_object_to_json_string(appnameJ));
                 if(myname == appname)
                 {
                     qDebug("Surface %s got tapShortcut\n", appname);
-                    qwm->activateSurface(json_object_new_string(myname.c_str()));
+                    qwm->activateSurface(myname);
                 }
             }
         });
diff --git a/app/qlibwindowmanager.cpp b/app/qlibwindowmanager.cpp
deleted file mode 100644 (file)
index 7ad69f7..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "qlibwindowmanager.h"
-#include <QDebug>
-#include <unistd.h>
-
-int QLibWindowmanager::init(int port, const QString &token) {
-    std::string ctoken = token.toStdString();
-    return this->wm->init(port, ctoken.c_str());
-}
-
-int QLibWindowmanager::requestSurface(json_object *label) {
-    applabel = json_object_get_string(label);
-
-    json_object *obj = json_object_new_object();
-    json_object_object_add(obj, wm->kKeyDrawingName, label);
-    return this->wm->requestSurface(obj);
-}
-
-int QLibWindowmanager::activateSurface(json_object *label) {
-    json_object *obj = json_object_new_object();
-    json_object_object_add(obj, wm->kKeyDrawingName, label);
-    json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string("normal.full"));
-
-    return this->wm->activateSurface(obj);
-}
-
-int QLibWindowmanager::deactivateSurface(json_object *label) {
-    json_object *obj = json_object_new_object();
-    json_object_object_add(obj, wm->kKeyDrawingName, label);
-    return this->wm->deactivateSurface(obj);
-}
-
-int QLibWindowmanager::endDraw(json_object *label) {
-    json_object *obj = json_object_new_object();
-    json_object_object_add(obj, wm->kKeyDrawingName, label);
-    return this->wm->endDraw(obj);
-    }
-
-void QLibWindowmanager::set_event_handler(enum QEventType et,
- handler_fun f) {
-    LibWindowmanager::EventType wet = (LibWindowmanager::EventType)et;
-    return this->wm->set_event_handler(wet, std::move(f));
-}
-
-void QLibWindowmanager::slotActivateSurface(){
-    if(!isActive){
-        qDebug("Let's show HVAC");
-        isActive = true;
-        this->activateSurface(json_object_new_string(applabel.c_str()));
-    }
-}
-
-QLibWindowmanager::QLibWindowmanager(QObject *parent)
-    :QObject(parent), isActive(false)
-{
-    wm = new LibWindowmanager();
-}
-
-QLibWindowmanager::~QLibWindowmanager() { }
diff --git a/app/qlibwindowmanager.h b/app/qlibwindowmanager.h
deleted file mode 100644 (file)
index 07f8479..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef QLIBWINDOWMANAGER_H
-#define QLIBWINDOWMANAGER_H
-
-#include <libwindowmanager.h>
-#include <functional>
-#include <QObject>
-#include <QUrl>
-#include <QVariant>
-#include <string>
-#include <vector>
-
-class QLibWindowmanager : public QObject{
-Q_OBJECT
-public:
-    explicit QLibWindowmanager(QObject *parent = nullptr);
-    ~QLibWindowmanager();
-
-    QLibWindowmanager(const QLibWindowmanager &) = delete;
-    QLibWindowmanager &operator=(const QLibWindowmanager &) = delete;
-
-public:
-    using handler_fun = std::function<void(json_object *object)>;
-
-    enum QEventType {
-       Event_Active = 0,
-       Event_Inactive,
-
-       Event_Visible,
-       Event_Invisible,
-
-       Event_SyncDraw,
-       Event_FlushDraw,
-    };
-
-    static QLibWindowmanager &instance();
-
-    int init(int port, const QString &token);
-
-    // WM API
-    int requestSurface(json_object *label);
-    int activateSurface(json_object *label);
-    int deactivateSurface(json_object *label);
-    int endDraw(json_object *label);
-    void set_event_handler(enum QEventType et, handler_fun f);
-
-public slots:
-    void slotActivateSurface();
-
-private:
-    LibWindowmanager* wm;
-    std::string applabel;
-    std::vector<int> surfaceIDs;
-    bool isActive;
-
-};
-#endif // LIBWINDOWMANAGER_H