diff options
author | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2017-11-09 19:32:10 +0900 |
---|---|---|
committer | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2017-11-09 19:32:10 +0900 |
commit | eb92236c8e83f09f68e8ddb484697070dc040874 (patch) | |
tree | b7d9b0c0cdddc6f4d7388ddda3f9db880313932b | |
parent | 7e295b2829ae96c9a3d17af6433896db4f98bc37 (diff) |
Link qlibwindowmanager package
* Remove qlibwindowmanager.[h|cpp] source code
* Modified main.cpp
Change-Id: Iaf80bf69c95c565943f40429ee280fb8df9b8bca
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r-- | app/app.pro | 6 | ||||
-rw-r--r-- | app/main.cpp | 10 | ||||
-rw-r--r-- | app/qlibwindowmanager.cpp | 71 | ||||
-rw-r--r-- | app/qlibwindowmanager.h | 71 |
4 files changed, 8 insertions, 150 deletions
diff --git a/app/app.pro b/app/app.pro index 51d370e..367fc78 100644 --- a/app/app.pro +++ b/app/app.pro @@ -1,11 +1,11 @@ TARGET = radio QT = quickcontrols2 qml -HEADERS = PresetDataObject.h qlibwindowmanager.h qlibsoundmanager.h -SOURCES = main.cpp PresetDataObject.cpp qlibwindowmanager.cpp qlibsoundmanager.cpp +HEADERS = PresetDataObject.h qlibsoundmanager.h +SOURCES = main.cpp PresetDataObject.cpp qlibsoundmanager.cpp CONFIG += link_pkgconfig -PKGCONFIG += libsoundmanager libwindowmanager libhomescreen +PKGCONFIG += libsoundmanager qlibwindowmanager libhomescreen RESOURCES += \ radio.qrc \ diff --git a/app/main.cpp b/app/main.cpp index ef0204a..e7e4ab0 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -27,13 +27,13 @@ #include <QQuickWindow> #include "PresetDataObject.h" #include <libhomescreen.hpp> -#include "qlibwindowmanager.h" +#include <qlibwindowmanager.h> #include "qlibsoundmanager.h" static LibHomeScreen* hs; static QLibWindowmanager* qwm; static QLibSoundmanager* smw; -static std::string myname = std::string("Radio"); +static QString myname = QString("Radio"); int main(int argc, char *argv[]) { @@ -104,12 +104,12 @@ int main(int argc, char *argv[]) if(qwm->init(port,secret) != 0){ exit(EXIT_FAILURE); } - if (qwm->requestSurface(myname.c_str()) != 0) { + if (qwm->requestSurface(myname) != 0) { exit(EXIT_FAILURE); } qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [qwm](json_object *object) { fprintf(stderr, "Surface got syncDraw!\n"); - qwm->endDraw(myname.c_str()); + qwm->endDraw(myname); }); qwm->set_event_handler(QLibWindowmanager::Event_FlushDraw, [&engine, smw](json_object *object) { fprintf(stderr, "Surface got flushDraw!\n"); @@ -126,7 +126,7 @@ int main(int argc, char *argv[]) if(myname == appname) { qDebug("Surface %s got tapShortcut\n", appname); - qwm->activateSurface(myname.c_str()); + qwm->activateSurface(myname); } }); diff --git a/app/qlibwindowmanager.cpp b/app/qlibwindowmanager.cpp deleted file mode 100644 index 7380bc8..0000000 --- a/app/qlibwindowmanager.cpp +++ /dev/null @@ -1,71 +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 <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(const char *label) { - applabel = label; - json_object *obj = json_object_new_object(); - json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(label)); - return this->wm->requestSurface(obj); -} - -int QLibWindowmanager::activateSurface(const char *label) { - json_object *obj = json_object_new_object(); - json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(label)); - json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string("normal.full")); - return this->wm->activateSurface(obj); -} - -int QLibWindowmanager::deactivateSurface(const char *label) { - json_object *obj = json_object_new_object(); - json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(label)); - return this->wm->deactivateSurface(obj); -} - -int QLibWindowmanager::endDraw(const char *label) { - json_object *obj = json_object_new_object(); - json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(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 radio"); - isActive = true; - this->activateSurface(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 index dd0694e..0000000 --- a/app/qlibwindowmanager.h +++ /dev/null @@ -1,71 +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(const char *label); - int activateSurface(const char *label); - int deactivateSurface(const char *label); - int endDraw(const char *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 |