diff options
Diffstat (limited to 'homescreen/src')
-rw-r--r-- | homescreen/src/homescreenhandler.cpp | 30 | ||||
-rw-r--r-- | homescreen/src/homescreenhandler.h | 10 | ||||
-rw-r--r-- | homescreen/src/main.cpp | 32 | ||||
-rw-r--r-- | homescreen/src/mastervolume.cpp | 2 | ||||
-rw-r--r-- | homescreen/src/mastervolume.h | 4 | ||||
-rw-r--r-- | homescreen/src/statusbarmodel.cpp | 11 | ||||
-rw-r--r-- | homescreen/src/toucharea.cpp | 36 | ||||
-rw-r--r-- | homescreen/src/toucharea.h | 30 |
8 files changed, 134 insertions, 21 deletions
diff --git a/homescreen/src/homescreenhandler.cpp b/homescreen/src/homescreenhandler.cpp index 5da8b9e..ac50451 100644 --- a/homescreen/src/homescreenhandler.cpp +++ b/homescreen/src/homescreenhandler.cpp @@ -22,7 +22,8 @@ void* HomescreenHandler::myThis = 0; HomescreenHandler::HomescreenHandler(QObject *parent) : QObject(parent), - mp_hs(NULL) + mp_hs(NULL), + current_applciation("launcher") { } @@ -48,13 +49,34 @@ void HomescreenHandler::init(int port, const char *token) json_object_object_get(object, "display_message")); HMI_DEBUG("HomeScreen","set_event_handler Event_OnScreenMessage display_message = %s", display_message); }); +} +void HomescreenHandler::tapShortcut(QString application_name, bool is_full) +{ + HMI_DEBUG("HomeScreen","tapShortcut %s", application_name.toStdString().c_str()); + struct json_object* j_json = json_object_new_object(); + struct json_object* value; + if(is_full) { + value = json_object_new_string("fullscreen"); + HMI_DEBUG("HomeScreen","tapShortcut fullscreen"); + } else { + value = json_object_new_string("normal"); + HMI_DEBUG("HomeScreen","tapShortcut normal"); + } + json_object_object_add(j_json, "area", value); + mp_hs->showWindow(application_name.toStdString().c_str(), j_json); } -void HomescreenHandler::tapShortcut(QString application_name) +void HomescreenHandler::setCurrentApplication(QString application_name) { - HMI_DEBUG("HomeScreen","tapShortcut %s", application_name.toStdString().c_str()); - mp_hs->tapShortcut(application_name.toStdString().c_str()); + HMI_DEBUG("HomeScreen","setCurrentApplication %s", application_name.toStdString().c_str()); + current_applciation = application_name; +} + +QString HomescreenHandler::getCurrentApplication() +{ + HMI_DEBUG("HomeScreen","getCurrentApplication %s", current_applciation.toStdString().c_str()); + return current_applciation; } void HomescreenHandler::onRep_static(struct json_object* reply_contents) diff --git a/homescreen/src/homescreenhandler.h b/homescreen/src/homescreenhandler.h index c18d7a0..539d380 100644 --- a/homescreen/src/homescreenhandler.h +++ b/homescreen/src/homescreenhandler.h @@ -32,7 +32,9 @@ public: void init(int port, const char* token); - Q_INVOKABLE void tapShortcut(QString application_name); + Q_INVOKABLE void tapShortcut(QString application_name, bool is_full); + Q_INVOKABLE QString getCurrentApplication(); + void setCurrentApplication(QString application_name); void onRep(struct json_object* reply_contents); void onEv(const string& event, struct json_object* event_contents); @@ -40,8 +42,14 @@ public: static void* myThis; static void onRep_static(struct json_object* reply_contents); static void onEv_static(const string& event, struct json_object* event_contents); + +signals: + void notification(QString id, QString icon, QString text); + void information(QString text); + private: LibHomeScreen *mp_hs; + QString current_applciation; }; #endif // HOMESCREENHANDLER_H diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp index 620c869..ff30e15 100644 --- a/homescreen/src/main.cpp +++ b/homescreen/src/main.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH - * Copyright (c) 2017, 2018 TOYOTA MOTOR CORPORATION + * 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. @@ -22,6 +22,7 @@ #include <QtQml/QQmlContext> #include <QtQml/qqml.h> #include <QQuickWindow> +#include <QThread> #include <qlibwindowmanager.h> #include <weather.h> @@ -32,6 +33,7 @@ #include "mastervolume.h" #include "homescreenhandler.h" #include "hmi-debug.h" +#include "toucharea.h" // XXX: We want this DBus connection to be shared across the different // QML objects, is there another way to do this, a nice way, perhaps? @@ -75,7 +77,7 @@ int main(int argc, char *argv[]) parser.addVersionOption(); parser.process(a); QStringList positionalArguments = parser.positionalArguments(); - + int port = 1700; QString token = "wm"; @@ -93,12 +95,11 @@ int main(int argc, char *argv[]) ApplicationLauncher *launcher = new ApplicationLauncher(); QLibWindowmanager* layoutHandler = new QLibWindowmanager(); + HomescreenHandler* homescreenHandler = new HomescreenHandler(); if(layoutHandler->init(port,token) != 0){ exit(EXIT_FAILURE); } - AGLScreenInfo screenInfo(layoutHandler->get_scale_factor()); - if (layoutHandler->requestSurface(QString("HomeScreen")) != 0) { exit(EXIT_FAILURE); } @@ -107,19 +108,18 @@ int main(int argc, char *argv[]) layoutHandler->endDraw(QString("HomeScreen")); }); - layoutHandler->set_event_handler(QLibWindowmanager::Event_ScreenUpdated, [layoutHandler, launcher](json_object *object) { + layoutHandler->set_event_handler(QLibWindowmanager::Event_ScreenUpdated, [layoutHandler, launcher, homescreenHandler](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()); + HMI_DEBUG("HomeScreen","Event_ScreenUpdated application11: %s.", label.toStdString().c_str()); + homescreenHandler->setCurrentApplication(label); 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")); @@ -131,23 +131,35 @@ int main(int argc, char *argv[]) query.addQueryItem(QStringLiteral("token"), token); bindingAddress.setQuery(query); + TouchArea* touchArea = new TouchArea(); + // mail.qml loading QQmlApplicationEngine engine; engine.rootContext()->setContextProperty("layoutHandler", layoutHandler); engine.rootContext()->setContextProperty("homescreenHandler", homescreenHandler); + engine.rootContext()->setContextProperty("touchArea", touchArea); engine.rootContext()->setContextProperty("launcher", launcher); engine.rootContext()->setContextProperty("weather", new Weather(bindingAddress)); engine.rootContext()->setContextProperty("bluetooth", new Bluetooth(bindingAddress)); - engine.rootContext()->setContextProperty("screenInfo", &screenInfo); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); QObject *root = engine.rootObjects().first(); QQuickWindow *window = qobject_cast<QQuickWindow *>(root); - QObject::connect(window, SIGNAL(frameSwapped()), layoutHandler, SLOT(slotActivateSurface())); + + touchArea->setWindow(window); + QThread* thread = new QThread; + touchArea->moveToThread(thread); + QObject::connect(thread, &QThread::started, touchArea, &TouchArea::init); + + thread->start(); QList<QObject *> sobjs = engine.rootObjects(); StatusBarModel *statusBar = sobjs.first()->findChild<StatusBarModel *>("statusBar"); statusBar->init(bindingAddress, engine.rootContext()); + QObject::connect(window, SIGNAL(frameSwapped()), layoutHandler, SLOT(slotActivateSurface())); + + homescreenHandler->init(port, token.toStdString().c_str()); + return a.exec(); } diff --git a/homescreen/src/mastervolume.cpp b/homescreen/src/mastervolume.cpp index 9fb92a9..5e1e450 100644 --- a/homescreen/src/mastervolume.cpp +++ b/homescreen/src/mastervolume.cpp @@ -16,7 +16,7 @@ #include "mastervolume.h" -void MasterVolume::setVolume(int volume) +void MasterVolume::setVolume(pa_volume_t volume) { int volume_delta = volume - m_volume; m_volume = volume; diff --git a/homescreen/src/mastervolume.h b/homescreen/src/mastervolume.h index bca6356..645968a 100644 --- a/homescreen/src/mastervolume.h +++ b/homescreen/src/mastervolume.h @@ -17,6 +17,8 @@ #include <QtCore/QObject> #include <QQmlEngine> +#include <pulse/pulseaudio.h> + class MasterVolume : public QObject { Q_OBJECT @@ -31,7 +33,7 @@ class MasterVolume : public QObject ~MasterVolume() {} uint32_t getVolume() const { return m_volume; } - void setVolume(int volume); + void setVolume(pa_volume_t volume); public slots: void changeExternalVolume(int volume); diff --git a/homescreen/src/statusbarmodel.cpp b/homescreen/src/statusbarmodel.cpp index 5e63b7d..c093ceb 100644 --- a/homescreen/src/statusbarmodel.cpp +++ b/homescreen/src/statusbarmodel.cpp @@ -1,6 +1,5 @@ /* * Copyright (C) 2016 The Qt Company Ltd. - * Copyright (C) 2017, 2018 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. @@ -17,11 +16,14 @@ #include "statusbarmodel.h" #include "statusbarserver.h" +#include <QDebug> +#include "hmi-debug.h" #include <QtDBus/QDBusConnection> #include "network.h" + class StatusBarModel::Private { public: @@ -65,6 +67,7 @@ StatusBarModel::~StatusBarModel() void StatusBarModel::init(QUrl &url, QQmlContext *context) { + HMI_DEBUG("HomeScreen", "StatusBarModel::init"); d->network = new Network(url, context); context->setContextProperty("network", d->network); @@ -77,6 +80,7 @@ void StatusBarModel::init(QUrl &url, QQmlContext *context) void StatusBarModel::setWifiStatus(bool connected, bool enabled, int strength) { + HMI_DEBUG("HomeScreen", "StatusBarModel::setWifiStatus"); if (enabled && connected) if (strength < 30) d->server.setStatusIcon(0, QStringLiteral("qrc:/images/Status/HMI_Status_Wifi_1Bar-01.png")); @@ -111,7 +115,6 @@ int StatusBarModel::rowCount(const QModelIndex &parent) const if (parent.isValid()) return 0; - // Delete bluetooth because use agl-service-bluetooth. return StatusBarServer::SupportedCount - 1; } @@ -123,9 +126,9 @@ QVariant StatusBarModel::data(const QModelIndex &index, int role) const switch (role) { case Qt::DisplayRole: - if (index.row() == 0){ + if (index.row() == 0) { ret = d->iconList[StatusBarServer::StatusWifi]; - }else if (index.row() == 1){ + } else if (index.row() == 1) { ret = d->iconList[StatusBarServer::StatusCellular]; } break; diff --git a/homescreen/src/toucharea.cpp b/homescreen/src/toucharea.cpp new file mode 100644 index 0000000..1cf4384 --- /dev/null +++ b/homescreen/src/toucharea.cpp @@ -0,0 +1,36 @@ +#include "toucharea.h" +#include "hmi-debug.h" + +TouchArea::TouchArea() +{ +} + +TouchArea::~TouchArea() +{ + +} + +void TouchArea::setWindow(QQuickWindow *window) +{ + myWindow = window; +} + +void TouchArea::init() +{ + bitmapNormal = QPixmap(":/images/AGL_HMI_Normal_Background.png").createHeuristicMask(); + bitmapFullscreen = QPixmap(":/images/AGL_HMI_Full_Background.png").createHeuristicMask(); + myWindow->setMask(QRegion(bitmapNormal)); +} + +void TouchArea::switchArea(int areaType) +{ + if(areaType == NORMAL) { + myWindow->setMask(QRegion(bitmapNormal)); + HMI_DEBUG("HomeScreen","TouchArea switchArea: %d.", areaType); + } else if (areaType == FULLSCREEN) { + HMI_DEBUG("HomeScreen","TouchArea switchArea: %d.", areaType); + myWindow->setMask(QRegion(bitmapFullscreen)); + } +} + + diff --git a/homescreen/src/toucharea.h b/homescreen/src/toucharea.h new file mode 100644 index 0000000..69c6872 --- /dev/null +++ b/homescreen/src/toucharea.h @@ -0,0 +1,30 @@ +#ifndef TOUCHAREA_H +#define TOUCHAREA_H + +#include <QBitmap> +#include <QQuickWindow> + +enum { + NORMAL=0, + FULLSCREEN +}; + +class TouchArea : public QObject +{ + Q_OBJECT +public: + explicit TouchArea(); + ~TouchArea(); + + Q_INVOKABLE void switchArea(int areaType); + void setWindow(QQuickWindow* window); + +public slots: + void init(); + +private: + QBitmap bitmapNormal, bitmapFullscreen; + QQuickWindow* myWindow; +}; + +#endif // TOUCHAREA_H |