summaryrefslogtreecommitdiffstats
path: root/homescreen
diff options
context:
space:
mode:
Diffstat (limited to 'homescreen')
-rw-r--r--homescreen/qml/Home.qml3
-rw-r--r--homescreen/qml/ShortcutArea.qml7
-rw-r--r--homescreen/qml/ShortcutIcon.qml49
-rw-r--r--homescreen/qml/TopArea.qml16
-rw-r--r--homescreen/qml/main.qml4
-rw-r--r--homescreen/src/applicationlauncher.cpp30
-rw-r--r--homescreen/src/applicationlauncher.h10
-rw-r--r--homescreen/src/main.cpp15
8 files changed, 112 insertions, 22 deletions
diff --git a/homescreen/qml/Home.qml b/homescreen/qml/Home.qml
index 287b250..5d54093 100644
--- a/homescreen/qml/Home.qml
+++ b/homescreen/qml/Home.qml
@@ -72,11 +72,8 @@ Item {
if (currentId === '') {
pid = launcher.launch(applicationModel.id(loc.index))
if (1 < pid) {
-// layoutHandler.makeMeVisible(pid)
-
applicationArea.visible = true
appLauncherAreaLauncher.visible = false
- // layoutHandler.showAppLayer(applicationModel.id(loc.index), pid)
}
else {
console.warn("app cannot be launched!")
diff --git a/homescreen/qml/ShortcutArea.qml b/homescreen/qml/ShortcutArea.qml
index 63f8e7b..1698a88 100644
--- a/homescreen/qml/ShortcutArea.qml
+++ b/homescreen/qml/ShortcutArea.qml
@@ -56,21 +56,18 @@ Item {
Layout.fillWidth: true
Layout.fillHeight: true
name: model.name
- active: model.application === launcher.current
+ active: model.name === launcher.current
onClicked: {
if (0 === model.index) {
appLauncherAreaLauncher.visible = true
applicationArea.visible = false
-// layoutHandler.hideAppLayer()
- launcher.current = ''
+ launcher.current = 'Home'
}
else {
pid = launcher.launch(model.application)
if (1 < pid) {
applicationArea.visible = true
appLauncherAreaLauncher.visible = false
-// layoutHandler.makeMeVisible(pid)
-// layoutHandler.showAppLayer(model.application, pid)
}
else {
console.warn(model.application)
diff --git a/homescreen/qml/ShortcutIcon.qml b/homescreen/qml/ShortcutIcon.qml
index 2fb653f..1100a7c 100644
--- a/homescreen/qml/ShortcutIcon.qml
+++ b/homescreen/qml/ShortcutIcon.qml
@@ -17,6 +17,7 @@
import QtQuick 2.2
import QtQuick.Controls 2.0
+import QtGraphicalEffects 1.0
MouseArea {
id: root
@@ -24,15 +25,27 @@ MouseArea {
height: 216.8
property string name: 'Home'
property bool active: false
- Image {
+ Item {
id: icon
+ property real desaturation: 0
anchors.fill: parent
- source: './images/Shortcut/%1.svg'.arg(root.name.toLowerCase())
- }
- Image {
- anchors.fill: parent
- source: './images/Shortcut/%1_active.svg'.arg(root.name.toLowerCase())
- opacity: 1.0 - icon.opacity
+ Image {
+ id: inactiveIcon
+ anchors.fill: parent
+ source: './images/Shortcut/%1.svg'.arg(root.name.toLowerCase())
+ }
+ Image {
+ id: activeIcon
+ anchors.fill: parent
+ source: './images/Shortcut/%1_active.svg'.arg(root.name.toLowerCase())
+ opacity: 0.0
+ }
+ layer.enabled: true
+ layer.effect: Desaturate {
+ id: desaturate
+ desaturation: icon.desaturation
+ cached: true
+ }
}
Label {
id: name
@@ -48,11 +61,26 @@ MouseArea {
}
states: [
State {
- when: root.active
+ when: launcher.launching
+ PropertyChanges {
+ target: root
+ enabled: false
+ }
PropertyChanges {
target: icon
+ desaturation: 1.0
+ }
+ },
+ State {
+ when: root.active
+ PropertyChanges {
+ target: inactiveIcon
opacity: 0.0
}
+ PropertyChanges {
+ target: activeIcon
+ opacity: 1.0
+ }
}
]
@@ -60,8 +88,13 @@ MouseArea {
Transition {
NumberAnimation {
properties: 'opacity'
+ duration: 500
easing.type: Easing.OutExpo
}
+ NumberAnimation {
+ properties: 'desaturation'
+ duration: 250
+ }
}
]
}
diff --git a/homescreen/qml/TopArea.qml b/homescreen/qml/TopArea.qml
index 922742d..9cff3ed 100644
--- a/homescreen/qml/TopArea.qml
+++ b/homescreen/qml/TopArea.qml
@@ -17,6 +17,7 @@
import QtQuick 2.2
import QtQuick.Layouts 1.1
+import QtQuick.Controls 2.0
Image {
width: 1920
@@ -40,4 +41,19 @@ Image {
Layout.preferredWidth: 295
}
}
+
+ Timer {
+ id: launching
+ interval: 500
+ running: launcher.launching
+ }
+
+ ProgressBar {
+ id: progressBar
+ anchors.verticalCenter: parent.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ indeterminate: visible
+ visible: launcher.launching && !launching.running
+ }
}
diff --git a/homescreen/qml/main.qml b/homescreen/qml/main.qml
index 899cb6d..8417de0 100644
--- a/homescreen/qml/main.qml
+++ b/homescreen/qml/main.qml
@@ -27,10 +27,6 @@ Window {
height: container.height * container.scale
title: 'HomeScreen'
- ApplicationLauncher {
- id: launcher
- }
-
Image {
id: container
anchors.centerIn: parent
diff --git a/homescreen/src/applicationlauncher.cpp b/homescreen/src/applicationlauncher.cpp
index 7e1cda1..5a1e2d6 100644
--- a/homescreen/src/applicationlauncher.cpp
+++ b/homescreen/src/applicationlauncher.cpp
@@ -26,7 +26,23 @@ extern org::AGL::afm::user *afm_user_daemon_proxy;
ApplicationLauncher::ApplicationLauncher(QObject *parent)
: QObject(parent)
+ , m_launching(false)
+ , m_timeout(new QTimer(this))
{
+ m_timeout->setInterval(3000);
+ m_timeout->setSingleShot(true);
+ connect(m_timeout, &QTimer::timeout, [&]() {
+ setLaunching(false);
+ });
+ connect(this, &ApplicationLauncher::launchingChanged, [&](bool launching) {
+ if (launching)
+ m_timeout->start();
+ else
+ m_timeout->stop();
+ });
+ connect(this, &ApplicationLauncher::currentChanged, [&]() {
+ setLaunching(false);
+ });
}
int ApplicationLauncher::launch(const QString &application)
@@ -38,12 +54,24 @@ int ApplicationLauncher::launch(const QString &application)
HMI_DEBUG("HomeScreen","ApplicationLauncher pid: %d.", result);
if (result > 1) {
- setCurrent(application);
+ setLaunching(true);
}
return result;
}
+bool ApplicationLauncher::isLaunching() const
+{
+ return m_launching;
+}
+
+void ApplicationLauncher::setLaunching(bool launching)
+{
+ if (m_launching == launching) return;
+ m_launching = launching;
+ launchingChanged(launching);
+}
+
QString ApplicationLauncher::current() const
{
return m_current;
diff --git a/homescreen/src/applicationlauncher.h b/homescreen/src/applicationlauncher.h
index 697dad0..dfa5846 100644
--- a/homescreen/src/applicationlauncher.h
+++ b/homescreen/src/applicationlauncher.h
@@ -21,17 +21,22 @@
#include <QtCore/QObject>
+class QTimer;
+
class ApplicationLauncher : public QObject
{
Q_OBJECT
+ Q_PROPERTY(bool launching READ isLaunching NOTIFY launchingChanged)
Q_PROPERTY(QString current READ current WRITE setCurrent NOTIFY currentChanged)
public:
explicit ApplicationLauncher(QObject *parent = NULL);
+ bool isLaunching() const;
QString current() const;
signals:
void newAppRequestsToBeVisible(int pid);
+ void launchingChanged(bool launching);
void currentChanged(const QString &current);
public slots:
@@ -39,7 +44,12 @@ public slots:
void setCurrent(const QString &current);
private:
+ void setLaunching(bool launching);
+
+private:
+ bool m_launching;
QString m_current;
+ QTimer *m_timeout;
};
#endif // APPLICATIONLAUNCHER_H
diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp
index e0850d6..522f957 100644
--- a/homescreen/src/main.cpp
+++ b/homescreen/src/main.cpp
@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
HMI_DEBUG("HomeScreen","port = %d, token = %s", port, token.toStdString().c_str());
// import C++ class to QML
- qmlRegisterType<ApplicationLauncher>("HomeScreen", 1, 0, "ApplicationLauncher");
+ // qmlRegisterType<ApplicationLauncher>("HomeScreen", 1, 0, "ApplicationLauncher");
qmlRegisterType<ApplicationModel>("Home", 1, 0, "ApplicationModel");
qmlRegisterType<StatusBarModel>("HomeScreen", 1, 0, "StatusBarModel");
qmlRegisterType<MasterVolume>("MasterVolume", 1, 0, "MasterVolume");
@@ -96,6 +96,7 @@ int main(int argc, char *argv[])
qDBusRegisterMetaType<AppInfo>();
qDBusRegisterMetaType<QList<AppInfo> >();
+ ApplicationLauncher *launcher = new ApplicationLauncher();
QLibWindowmanager* layoutHandler = new QLibWindowmanager();
if(layoutHandler->init(port,token) != 0){
exit(EXIT_FAILURE);
@@ -109,6 +110,17 @@ int main(int argc, char *argv[])
layoutHandler->endDraw(QString("HomeScreen"));
});
+ layoutHandler->set_event_handler(QLibWindowmanager::Event_Visible, [layoutHandler, launcher](json_object *object) {
+ QString label = QString(json_object_get_string( json_object_object_get(object, "drawing_name") ));
+ qDebug() << label;
+ QMetaObject::invokeMethod(launcher, "setCurrent", Qt::QueuedConnection, Q_ARG(QString, label == "HomeScreen" ? "Home" : label));
+ });
+
+ layoutHandler->set_event_handler(QLibWindowmanager::Event_Invisible, [layoutHandler, launcher](json_object *object) {
+ const char* label = json_object_get_string( json_object_object_get(object, "drawing_name") );
+ HMI_DEBUG("HomeScreen", "surface %s Event_Invisible", label);
+ });
+
HomescreenHandler* homescreenHandler = new HomescreenHandler();
homescreenHandler->init(port, token.toStdString().c_str());
@@ -116,6 +128,7 @@ int main(int argc, char *argv[])
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("layoutHandler", layoutHandler);
engine.rootContext()->setContextProperty("homescreenHandler", homescreenHandler);
+ engine.rootContext()->setContextProperty("launcher", launcher);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QObject *root = engine.rootObjects().first();