2 * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "qlibwindowmanager.h"
21 int QLibWindowmanager::init(int port, const QString &token) {
22 std::string ctoken = token.toStdString();
23 return this->wm->init(port, ctoken.c_str());
26 int QLibWindowmanager::requestSurface(json_object *label) {
27 applabel = json_object_get_string(label);
29 json_object *obj = json_object_new_object();
30 json_object_object_add(obj, wm->kKeyDrawingName, label);
31 return this->wm->requestSurface(obj);
34 int QLibWindowmanager::activateSurface(json_object *label) {
35 qDebug() << "activateSurface applabel: " << applabel.c_str();
36 json_object *obj = json_object_new_object();
37 qDebug() << "DrawingName: " << wm->kKeyDrawingName;
38 json_object_object_add(obj, wm->kKeyDrawingName, label);
39 qDebug() << "DrawingArea: " << wm->kKeyDrawingArea;
40 json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string("normal.full"));
41 qDebug() << "obj pointer: " << obj;
42 qDebug() << "activateSurface end obj: " << json_object_get_string(obj);
44 return this->wm->activateSurface(obj);
47 int QLibWindowmanager::deactivateSurface(json_object *label) {
48 json_object *obj = json_object_new_object();
49 json_object_object_add(obj, wm->kKeyDrawingName, label);
50 return this->wm->deactivateSurface(obj);
53 int QLibWindowmanager::endDraw(json_object *label) {
54 json_object *obj = json_object_new_object();
55 qDebug() << "endDraw label: " << json_object_get_string(label);
56 json_object_object_add(obj, wm->kKeyDrawingName, label);
57 return this->wm->endDraw(obj);
60 void QLibWindowmanager::set_event_handler(enum QEventType et,
62 LibWindowmanager::EventType wet = (LibWindowmanager::EventType)et;
63 return this->wm->set_event_handler(wet, std::move(f));
66 void QLibWindowmanager::slotActivateSurface(){
68 qDebug("Let's show HVAC");
70 qDebug() << "slotActivateSurface applabel: " << applabel.c_str();
71 this->activateSurface(json_object_new_string(applabel.c_str()));
75 QLibWindowmanager::QLibWindowmanager(QObject *parent)
76 :QObject(parent), isActive(false)
78 wm = new LibWindowmanager();
81 QLibWindowmanager::~QLibWindowmanager() { }