Fix highlight on Shortcut area 11/7711/1
authorTasuku Suzuki <tasuku.suzuki@qt.io>
Tue, 20 Dec 2016 11:17:10 +0000 (20:17 +0900)
committerTasuku Suzuki <tasuku.suzuki@qt.io>
Tue, 20 Dec 2016 11:17:10 +0000 (20:17 +0900)
Change-Id: I426bcc55842711c1cd00d11163c12899c00a9e42
Signed-off-by: Tasuku Suzuki <tasuku.suzuki@qt.io>
HomeScreen/qml/ShortcutArea.qml
HomeScreen/src2/applicationlauncher.cpp
HomeScreen/src2/applicationlauncher.h

index 9e71a94..1d7dd92 100644 (file)
@@ -28,7 +28,7 @@ Item {
         id: applicationModel
         ListElement {
             name: 'Home'
-            application: 'home@0.1'
+            application: ''
         }
         ListElement {
             name: 'Multimedia'
@@ -44,7 +44,6 @@ Item {
         }
     }
 
-    property int currentIndex: -1 // TODO: to be moved to whereever right
     property int pid: -1
 
     RowLayout {
@@ -56,13 +55,13 @@ Item {
                 Layout.fillWidth: true
                 Layout.fillHeight: true
                 name: model.name
-                active: model.index === root.currentIndex
+                active: model.application === launcher.current
                 onClicked: {
-                    root.currentIndex = active ? -1 : model.index
                     if (0 === model.index) {
                         appLauncherAreaLauncher.visible = true
                         applicationArea.visible = false
                         layoutHandler.hideAppLayer()
+                        launcher.current = ''
                     }
                     else {
                         pid = launcher.launch(model.application)
index 0ebc9b9..7011ebf 100644 (file)
@@ -43,5 +43,20 @@ int ApplicationLauncher::launch(const QString &application)
     result = mp_dBusAppFrameworkProxy->launchApp(application);
     qDebug() << "pid:" << result;
 
+    if (result > 1) {
+        setCurrent(application);
+    }
     return result;
 }
+
+QString ApplicationLauncher::current() const
+{
+    return m_current;
+}
+
+void ApplicationLauncher::setCurrent(const QString &current)
+{
+    if (m_current == current) return;
+    m_current = current;
+    emit currentChanged(current);
+}
index 14acae8..00fbbe8 100644 (file)
 class ApplicationLauncher : public QObject
 {
     Q_OBJECT
+    Q_PROPERTY(QString current READ current WRITE setCurrent NOTIFY currentChanged)
 public:
     explicit ApplicationLauncher(QObject *parent = NULL);
     ~ApplicationLauncher();
 
+    QString current() const;
+
 signals:
     void newAppRequestsToBeVisible(int pid);
+    void currentChanged(const QString &current);
 
 public slots:
     int launch(const QString &application);
+    void setCurrent(const QString &current);
 
 private:
     org::agl::appframework *mp_dBusAppFrameworkProxy;
+    QString m_current;
 };
 
 #endif // APPLICATIONLAUNCHER_H