on xenial help sign in
Use focusRequested signal from AppManager.
273c20fGerry Boland
Components/ApplicationManagerWrapper.qml+13−1
@@ -18,7 +18,7 @@ import QtQuick 2.0
18import Unity.Application 0.1
18import Unity.Application 0.1
19
19
20Item {
20Item {
21− id: applicationManager
21+ id: root
22
22
23 property alias mainStageApplications: mainStageModel
23 property alias mainStageApplications: mainStageModel
24 property alias sideStageApplications: sideStageModel
24 property alias sideStageApplications: sideStageModel
@@ -30,6 +30,8 @@ Item {
30
30
31 property bool fake: ApplicationManager.fake ? ApplicationManager.fake : false
31 property bool fake: ApplicationManager.fake ? ApplicationManager.fake : false
32
32
33+ signal focusRequested(string appId)
34+
33 ApplicationsModelStageFiltered {
35 ApplicationsModelStageFiltered {
34 id: mainStageModel
36 id: mainStageModel
35 stage: ApplicationInfo.MainStage
37 stage: ApplicationInfo.MainStage
@@ -61,6 +63,16 @@ Item {
61 }
63 }
62 }
64 }
63 }
65 }
66+
67+ onFocusRequested: {
68+ // if no side stage enabled, override application's stage parameter
69+ var app = ApplicationManager.findApplication(appId);
70+ if (app && app.stage === ApplicationInfo.SideStage && !sideStageEnabled) {
71+ app.stage = ApplicationInfo.MainStage;
72+ }
73+
74+ root.focusRequested(appId);
75+ }
64 }
76 }
65
77
66 function activateApplication(desktopFile, argument) {
78 function activateApplication(desktopFile, argument) {
Components/Stage.qml+5
@@ -84,6 +84,11 @@ Showable {
84 }
84 }
85 }
85 }
86
86
87+ Connections {
88+ target: applicationManager
89+ onFocusRequested: activateApplication(appId)
90+ }
91+
87 /* Keep a reference to the focused application so that we can safely
92 /* Keep a reference to the focused application so that we can safely
88 unfocus it when the stage is not fully shown and refocus it when the stage
93 unfocus it when the stage is not fully shown and refocus it when the stage
89 is fully shown again.
94 is fully shown again.
tests/mocks/Unity/Application/ApplicationInfo.h+1
@@ -35,6 +35,7 @@ class ApplicationInfo : public ApplicationInfoInterface {
35 Q_OBJECT
35 Q_OBJECT
36
36
37 Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)
37 Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)
38+ Q_PROPERTY(Stage stage READ stage WRITE setStage NOTIFY stageChanged)
38
39
39 // Only exists in this fake implementation
40 // Only exists in this fake implementation
40
41
tests/mocks/Unity/Application/ApplicationManager.h+1
@@ -99,6 +99,7 @@ class ApplicationManager : public ApplicationManagerInterface {
99 void keyboardHeightChanged();
99 void keyboardHeightChanged();
100 void keyboardVisibleChanged();
100 void keyboardVisibleChanged();
101 void focusRequested(FavoriteApplication favoriteApplication);
101 void focusRequested(FavoriteApplication favoriteApplication);
102+ void focusRequested(const QString &appId);
102
103
103 private:
104 private:
104 void add(ApplicationInfo *application);
105 void add(ApplicationInfo *application);