aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>2018-11-30 19:20:22 +0900
committerzheng_wenlong <wenlong_zheng@nexty-ele.com>2018-11-30 19:20:22 +0900
commit9e12877a80b90a1921a8e8714c0c5464779a6ba6 (patch)
tree7704ded0a8b755bbb619f2ad4f990720ea5afb82
parentfabcb8148b8032f4f8d04523e2f24cf8debe477f (diff)
Add feature : changeAreaSize
-rw-r--r--homescreen/homescreen.pro4
-rw-r--r--homescreen/qml/images/images.qrc2
-rw-r--r--homescreen/qml/images/menubar_full_background.pngbin6608 -> 5705 bytes
-rw-r--r--homescreen/qml/images/menubar_normal_background.pngbin68858 -> 71216 bytes
-rw-r--r--homescreen/qml/images/split_switch.pngbin0 -> 1156 bytes
-rw-r--r--homescreen/qml/images/split_switch_disable.pngbin0 -> 1296 bytes
-rw-r--r--homescreen/qml/main.qml67
-rw-r--r--homescreen/src/homescreenhandler.cpp71
-rw-r--r--homescreen/src/homescreenhandler.h19
-rw-r--r--homescreen/src/main.cpp43
10 files changed, 166 insertions, 40 deletions
diff --git a/homescreen/homescreen.pro b/homescreen/homescreen.pro
index e0a038e..e3f1e27 100644
--- a/homescreen/homescreen.pro
+++ b/homescreen/homescreen.pro
@@ -18,9 +18,9 @@ TARGET = HomeScreen
QT = qml quick dbus websockets
CONFIG += c++11 link_pkgconfig
DESTDIR = $${OUT_PWD}/../package/root/bin
-PKGCONFIG += qlibwindowmanager qtappfw
+PKGCONFIG += libwindowmanager qtappfw
-LIBS += -lhomescreen
+LIBS += -lhomescreen -lwindowmanager
include(../interfaces/interfaces.pri)
diff --git a/homescreen/qml/images/images.qrc b/homescreen/qml/images/images.qrc
index e72f697..0715215 100644
--- a/homescreen/qml/images/images.qrc
+++ b/homescreen/qml/images/images.qrc
@@ -5,5 +5,7 @@
<file>menubar_full_background.png</file>
<file>fullscreen.png</file>
<file>normal.png</file>
+ <file>split_switch.png</file>
+ <file>split_switch_disable.png</file>
</qresource>
</RCC>
diff --git a/homescreen/qml/images/menubar_full_background.png b/homescreen/qml/images/menubar_full_background.png
index 16a7e77..6db3a9e 100644
--- a/homescreen/qml/images/menubar_full_background.png
+++ b/homescreen/qml/images/menubar_full_background.png
Binary files differ
diff --git a/homescreen/qml/images/menubar_normal_background.png b/homescreen/qml/images/menubar_normal_background.png
index bfffc55..dadafcf 100644
--- a/homescreen/qml/images/menubar_normal_background.png
+++ b/homescreen/qml/images/menubar_normal_background.png
Binary files differ
diff --git a/homescreen/qml/images/split_switch.png b/homescreen/qml/images/split_switch.png
new file mode 100644
index 0000000..751b2fa
--- /dev/null
+++ b/homescreen/qml/images/split_switch.png
Binary files differ
diff --git a/homescreen/qml/images/split_switch_disable.png b/homescreen/qml/images/split_switch_disable.png
new file mode 100644
index 0000000..c4bfa67
--- /dev/null
+++ b/homescreen/qml/images/split_switch_disable.png
Binary files differ
diff --git a/homescreen/qml/main.qml b/homescreen/qml/main.qml
index 10509fd..f523339 100644
--- a/homescreen/qml/main.qml
+++ b/homescreen/qml/main.qml
@@ -128,25 +128,20 @@ Window {
}
}
-
-
-
-
Item {
id: switchBtn
- width: 110
- height: 110
+ width: 61
+ height: 61
anchors.right: parent.right
+ anchors.rightMargin: 17
anchors.top: parent.top
+ anchors.topMargin: 2
z: 1
Image {
id: image
width: 55
height: 55
- anchors.right: parent.right
- anchors.rightMargin: 20
- anchors.top: parent.top
- anchors.topMargin: 5
+ anchors.centerIn: parent
source: './images/normal.png'
}
@@ -162,16 +157,68 @@ Window {
}
}
}
+
+ Item {
+ id: splitSwitchBtn
+ width: 61
+ height: 61
+ anchors.right: switchBtn.left
+ anchors.top: parent.top
+ anchors.topMargin: 2
+ z: 1
+ property bool enableSplitSwitchBtn: false
+ Image {
+ id: splitSwitchImage
+ width: 55
+ height: 55
+ anchors.centerIn: parent
+ source: './images/split_switch_disable.png'
+ }
+
+ MouseArea {
+ property bool changed : false
+ anchors.fill: parent
+ onClicked: {
+ if (splitSwitchBtn.enableSplitSwitchBtn) {
+ if(changed) {
+ switchSplitArea(0)
+ changed = false
+ }
+ else {
+ switchSplitArea(1)
+ changed = true
+ }
+ }
+ }
+ }
+ }
+
+
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)
}
+
+ function enableSplitSwitchBtn() {
+ splitSwitchImage.source = './images/split_switch.png'
+ splitSwitchBtn.enableSplitSwitchBtn = true
+ }
+
+ function disableSplitSwitchBtn() {
+ splitSwitchImage.source = './images/split_switch_disable.png'
+ splitSwitchBtn.enableSplitSwitchBtn = false;
+ }
+
+ function switchSplitArea(val) {
+ homescreenHandler.changeLayout(val);
+ }
}
diff --git a/homescreen/src/homescreenhandler.cpp b/homescreen/src/homescreenhandler.cpp
index a655a5e..9125ecf 100644
--- a/homescreen/src/homescreenhandler.cpp
+++ b/homescreen/src/homescreenhandler.cpp
@@ -16,13 +16,15 @@
#include "homescreenhandler.h"
#include <functional>
+#include <QQmlApplicationEngine>
+#include <QtQuick/QQuickWindow>
#include "hmi-debug.h"
void* HomescreenHandler::myThis = 0;
HomescreenHandler::HomescreenHandler(QObject *parent) :
QObject(parent),
- mp_hs(NULL)
+ mp_hs(NULL), mp_wm(NULL), m_role()
{
}
@@ -32,10 +34,29 @@ HomescreenHandler::~HomescreenHandler()
if (mp_hs != NULL) {
delete mp_hs;
}
+ if (mp_wm != NULL) {
+ delete mp_wm;
+ }
}
-void HomescreenHandler::init(int port, const char *token)
+void HomescreenHandler::init(const char* role, int port, const char *token)
{
+ this->m_role = role;
+
+ // LibWindowManager initialize
+ mp_wm = new LibWindowmanager();
+ if(mp_wm->init(port,token) != 0){
+ exit(EXIT_FAILURE);
+ }
+
+ int surface = mp_wm->requestSurface(m_role.c_str());
+ if (surface < 0) {
+ exit(EXIT_FAILURE);
+ }
+ std::string ivi_id = std::to_string(surface);
+ setenv("QT_IVI_SURFACE_ID", ivi_id.c_str(), true);
+
+ // LibHomeScreen initialize
mp_hs = new LibHomeScreen();
mp_hs->init(port, token);
@@ -50,6 +71,52 @@ void HomescreenHandler::init(int port, const char *token)
});
}
+void HomescreenHandler::setWMHandler(WMHandler& h) {
+ h.on_sync_draw = [&](const char* role, const char* area, Rect r) {
+ this->mp_wm->endDraw(this->m_role.c_str());
+ };
+ mp_wm->setEventHandler(h);
+}
+
+void HomescreenHandler::disconnect_frame_swapped(void)
+{
+ qDebug("Let's start homescreen");
+ QObject::disconnect(this->loading);
+ mp_wm->activateWindow(m_role.c_str(), "fullscreen");
+}
+
+void HomescreenHandler::attach(QQmlApplicationEngine* engine)
+{
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(engine->rootObjects().first());
+ this->loading = QObject::connect(window, SIGNAL(frameSwapped()), this, SLOT(disconnect_frame_swapped()));
+}
+
+void HomescreenHandler::changeLayout(int pattern)
+{
+ HMI_NOTICE("HomeScreen", "Pressed %d, %s", pattern,
+ (pattern == P_LEFT_METER_RIGHT_MAP) ? "left:meter, right:map": "left:map, right:meter");
+ ChangeAreaReq req;
+ std::unordered_map<std::string, Rect> map_list;
+ switch(pattern) {
+ case P_LEFT_METER_RIGHT_MAP:
+ map_list["split.main"] = Rect(0, 0, 1280, 720);
+ map_list["split.sub"] = Rect(1280, 0, 640, 720);
+ break;
+ case P_LEFT_MAP_RIGHT_METER:
+ map_list["split.main"] = Rect(640, 0, 1280, 720);
+ map_list["split.sub"] = Rect(0, 0, 640, 720);
+ break;
+ default:
+ break;
+ }
+ if(map_list.size() != 0)
+ {
+ req.setAreaReq(map_list);
+ HMI_NOTICE("Homescreen", "Change layout");
+ mp_wm->changeAreaSize(req);
+ }
+}
+
void HomescreenHandler::tapShortcut(QString application_name)
{
HMI_DEBUG("HomeScreen","tapShortcut %s", application_name.toStdString().c_str());
diff --git a/homescreen/src/homescreenhandler.h b/homescreen/src/homescreenhandler.h
index 99367d5..c32e6cc 100644
--- a/homescreen/src/homescreenhandler.h
+++ b/homescreen/src/homescreenhandler.h
@@ -19,20 +19,31 @@
#include <QObject>
#include <libhomescreen.hpp>
+#include <libwindowmanager.h>
#include <string>
using namespace std;
+class QQmlApplicationEngine;
+
class HomescreenHandler : public QObject
{
Q_OBJECT
public:
+ enum CHANGE_LAYOUT_PATTERN {
+ P_LEFT_METER_RIGHT_MAP = 0,
+ P_LEFT_MAP_RIGHT_METER
+ };
+ Q_ENUMS(CHANGE_LAYOUT_PATTERN)
explicit HomescreenHandler(QObject *parent = 0);
~HomescreenHandler();
- void init(int port, const char* token);
+ void init(const char* role, int port, const char* token);
+ void attach(QQmlApplicationEngine* engine);
+ void setWMHandler(WMHandler &handler);
Q_INVOKABLE void tapShortcut(QString application_name);
+ Q_INVOKABLE void changeLayout(int pattern);
void onRep(struct json_object* reply_contents);
void onEv(const string& event, struct json_object* event_contents);
@@ -45,8 +56,14 @@ signals:
void notification(QString id, QString icon, QString text);
void information(QString text);
+private Q_SLOTS:
+ void disconnect_frame_swapped(void);
+
private:
LibHomeScreen *mp_hs;
+ LibWindowmanager *mp_wm;
+ std::string m_role;
+ QMetaObject::Connection loading;
};
#endif // HOMESCREENHANDLER_H
diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp
index 08f83a8..6479cd9 100644
--- a/homescreen/src/main.cpp
+++ b/homescreen/src/main.cpp
@@ -24,7 +24,6 @@
#include <QQuickWindow>
#include <QThread>
-#include <qlibwindowmanager.h>
#include <weather.h>
#include <bluetooth.h>
#include "applicationlauncher.h"
@@ -57,6 +56,7 @@ void noOutput(QtMsgType, const QMessageLogContext &, const QString &)
int main(int argc, char *argv[])
{
QGuiApplication a(argc, argv);
+ const char* graphic_role = "homescreen";
// use launch process
QScopedPointer<org::AGL::afm::user, Cleanup> afm_user_daemon_proxy(new org::AGL::afm::user("org.AGL.afm.user",
@@ -94,16 +94,7 @@ int main(int argc, char *argv[])
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);
- }
-
- if (layoutHandler->requestSurface(QString("homescreen")) != 0) {
- exit(EXIT_FAILURE);
- }
+ homescreenHandler->init(graphic_role, port, token.toStdString().c_str());
QUrl bindingAddress;
bindingAddress.setScheme(QStringLiteral("ws"));
@@ -119,7 +110,6 @@ int main(int argc, char *argv[])
// 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);
@@ -129,27 +119,32 @@ int main(int argc, char *argv[])
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);
+ WMHandler wmh;
+ wmh.on_screen_updated = [launcher, root](std::vector<std::string> list) {
+ for(const auto& i : list) {
+ HMI_DEBUG("HomeScreen", "ids=%s", i.c_str());
+ }
+ int arrLen = list.size();
+ QString label = QString("");
for( int idx = 0; idx < arrLen; idx++)
{
- QString label = QString(json_object_get_string( json_object_array_get_idx(jarray, idx) ));
+ label = list[idx].c_str();
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);
+ }
+ if((arrLen == 1) && (QString("restriction") != label)) {
+ QMetaObject::invokeMethod(root, "disableSplitSwitchBtn");
+ } else {
+ QMetaObject::invokeMethod(root, "enableSplitSwitchBtn");
}
}
- });
+ };
+ homescreenHandler->setWMHandler(wmh);
+ homescreenHandler->attach(&engine);
QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
@@ -164,7 +159,5 @@ int main(int argc, char *argv[])
StatusBarModel *statusBar = sobjs.first()->findChild<StatusBarModel *>("statusBar");
statusBar->init(bindingAddress, engine.rootContext());
- QObject::connect(window, SIGNAL(frameSwapped()), layoutHandler, SLOT(slotActivateSurface()));
-
return a.exec();
}