on xenial help sign in
implementation should be working now
5aa86faMichael Zanetti
plugins/Utils/CMakeLists.txt+1
@@ -10,6 +10,7 @@ include_directories(
10
10
11set(QMLPLUGIN_SRC
11set(QMLPLUGIN_SRC
12 activefocuslogger.cpp
12 activefocuslogger.cpp
13+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
13 applicationsfiltermodel.cpp
14 applicationsfiltermodel.cpp
14 constants.cpp
15 constants.cpp
15 HomeKeyWatcher.cpp
16 HomeKeyWatcher.cpp
plugins/Utils/applicationsfiltermodel.cpp+12−1
@@ -12,7 +12,6 @@ ApplicationsFilterModel::ApplicationsFilterModel(QObject *parent):
12 m_filterTouchApps(false),
12 m_filterTouchApps(false),
13 m_filterLegacyApps(false)
13 m_filterLegacyApps(false)
14{
14{
15−
16}
15}
17
16
18ApplicationManagerInterface *ApplicationsFilterModel::applicationsModel() const
17ApplicationManagerInterface *ApplicationsFilterModel::applicationsModel() const
@@ -22,9 +21,14 @@ ApplicationManagerInterface *ApplicationsFilterModel::applicationsModel() const
22
21
23void ApplicationsFilterModel::setApplicationsModel(ApplicationManagerInterface *applicationsModel)
22void ApplicationsFilterModel::setApplicationsModel(ApplicationManagerInterface *applicationsModel)
24{
23{
24+ if (m_appModel) {
25+ disconnect(m_appModel, &ApplicationManagerInterface::countChanged, this, &ApplicationsFilterModel::countChanged);
26+ }
25 if (m_appModel != applicationsModel) {
27 if (m_appModel != applicationsModel) {
26 m_appModel = applicationsModel;
28 m_appModel = applicationsModel;
29+ setSourceModel(m_appModel);
27 Q_EMIT applicationsModelChanged();
30 Q_EMIT applicationsModelChanged();
31+ connect(m_appModel, &ApplicationManagerInterface::countChanged, this, &ApplicationsFilterModel::countChanged);
28 }
32 }
29}
33}
30
34
@@ -40,6 +44,7 @@ void ApplicationsFilterModel::setFilterTouchApps(bool filterTouchApps)
40 Q_EMIT filterTouchAppsChanged();
44 Q_EMIT filterTouchAppsChanged();
41
45
42 invalidateFilter();
46 invalidateFilter();
47+ Q_EMIT countChanged();
43 }
48 }
44}
49}
45
50
@@ -55,6 +60,7 @@ void ApplicationsFilterModel::setFilterLegacyApps(bool filterLegacyApps)
55 Q_EMIT filterLegacyAppsChanged();
60 Q_EMIT filterLegacyAppsChanged();
56
61
57 invalidateFilter();
62 invalidateFilter();
63+ Q_EMIT countChanged();
58 }
64 }
59}
65}
60
66
@@ -72,3 +78,8 @@ bool ApplicationsFilterModel::filterAcceptsRow(int source_row, const QModelIndex
72 }
78 }
73 return true;
79 return true;
74}
80}
81+
82+ApplicationInfoInterface *ApplicationsFilterModel::get(int index) const
83+{
84+ return m_appModel->get(mapToSource(this->index(index, 0)).row());
85+}
plugins/Utils/applicationsfiltermodel.h+6−1
@@ -7,6 +7,7 @@ namespace unity {
7namespace shell {
7namespace shell {
8namespace application {
8namespace application {
9class ApplicationManagerInterface;
9class ApplicationManagerInterface;
10+class ApplicationInfoInterface;
10}
11}
11}
12}
12}
13}
@@ -16,10 +17,11 @@ class ApplicationsFilterModel: public QSortFilterProxyModel
16{
17{
17 Q_OBJECT
18 Q_OBJECT
18
19
19− Q_PROPERTY(ApplicationManagerInterface* applicationsModel READ applicationsModel WRITE setApplicationsModel NOTIFY applicationsModelChanged)
20+ Q_PROPERTY(unity::shell::application::ApplicationManagerInterface* applicationsModel READ applicationsModel WRITE setApplicationsModel NOTIFY applicationsModelChanged)
20 Q_PROPERTY(bool filterTouchApps READ filterTouchApps WRITE setFilterTouchApps NOTIFY filterTouchAppsChanged)
21 Q_PROPERTY(bool filterTouchApps READ filterTouchApps WRITE setFilterTouchApps NOTIFY filterTouchAppsChanged)
21 Q_PROPERTY(bool filterLegacyApps READ filterLegacyApps WRITE setFilterLegacyApps NOTIFY filterLegacyAppsChanged)
22 Q_PROPERTY(bool filterLegacyApps READ filterLegacyApps WRITE setFilterLegacyApps NOTIFY filterLegacyAppsChanged)
22
23
24+ Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
23public:
25public:
24 ApplicationsFilterModel(QObject *parent = 0);
26 ApplicationsFilterModel(QObject *parent = 0);
25
27
@@ -34,10 +36,13 @@ public:
34
36
35 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
37 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
36
38
39+ Q_INVOKABLE unity::shell::application::ApplicationInfoInterface* get(int index) const;
40+
37Q_SIGNALS:
41Q_SIGNALS:
38 void applicationsModelChanged();
42 void applicationsModelChanged();
39 void filterTouchAppsChanged();
43 void filterTouchAppsChanged();
40 void filterLegacyAppsChanged();
44 void filterLegacyAppsChanged();
45+ void countChanged();
41
46
42private:
47private:
43 ApplicationManagerInterface* m_appModel;
48 ApplicationManagerInterface* m_appModel;
qml/Components/ModeSwitchWarningDialog.qml+5
@@ -14,6 +14,7 @@ Dialog {
14 Label {
14 Label {
15 text: i18n.tr("Apps may have unsaved data:")
15 text: i18n.tr("Apps may have unsaved data:")
16 fontSize: "large"
16 fontSize: "large"
17+ color: "#5D5D5D"
17 }
18 }
18
19
19 Repeater {
20 Repeater {
@@ -30,6 +31,7 @@ Dialog {
30 Label {
31 Label {
31 Layout.fillWidth: true
32 Layout.fillWidth: true
32 text: model.name
33 text: model.name
34+ color: "#888888"
33 }
35 }
34 }
36 }
35 }
37 }
@@ -37,11 +39,13 @@ Dialog {
37 Label {
39 Label {
38 text: i18n.tr("Re-dock, save your work and close these apps to continue.")
40 text: i18n.tr("Re-dock, save your work and close these apps to continue.")
39 wrapMode: Text.WordWrap
41 wrapMode: Text.WordWrap
42+ color: "#888888"
40 }
43 }
41
44
42 Label {
45 Label {
43 text: i18n.tr("Or force close now (unsaved data will be lost).")
46 text: i18n.tr("Or force close now (unsaved data will be lost).")
44 wrapMode: Text.WordWrap
47 wrapMode: Text.WordWrap
48+ color: "#888888"
45 }
49 }
46
50
47 ThinDivider {}
51 ThinDivider {}
@@ -54,6 +58,7 @@ Dialog {
54 property string notClickedText: i18n.tr("OK, I will reconnect")
58 property string notClickedText: i18n.tr("OK, I will reconnect")
55 property string clickedText: i18n.tr("Reconnect now!")
59 property string clickedText: i18n.tr("Reconnect now!")
56 text: clicked ? clickedText : notClickedText
60 text: clicked ? clickedText : notClickedText
61+ color: "#333333"
57
62
58 MouseArea {
63 MouseArea {
59 anchors.fill: parent
64 anchors.fill: parent
qml/Shell.qml+20−7
@@ -42,7 +42,6 @@ import Unity.DashCommunicator 0.1
42import Unity.Indicators 0.1 as Indicators
42import Unity.Indicators 0.1 as Indicators
43import Cursor 1.0
43import Cursor 1.0
44
44
45−
46Item {
45Item {
47 id: shell
46 id: shell
48
47
@@ -95,6 +94,26 @@ Item {
95 }
94 }
96 }
95 }
97
96
97+ property var modeSwitchWarningPopup: null
98+ onUsageScenarioChanged: {
99+ if (usageScenario != "desktop" && legacyAppsModel.count > 0 && !modeSwitchWarningPopup) {
100+ var popup = PopupUtils.open(Qt.resolvedUrl("Components/ModeSwitchWarningDialog.qml"), shell, {model: legacyAppsModel})
101+ popup.forceClose.connect(function() {
102+ while (legacyAppsModel.count > 0) {
103+ ApplicationManager.stopApplication(legacyAppsModel.get(0).appId)
104+ }
105+ })
106+ } else if (usageScenario == "desktop" && modeSwitchWarningPopup) {
107+ PopupUtls.close(modeSwitchWarningPopup)
108+ }
109+ }
110+
111+ ApplicationsFilterModel {
112+ id: legacyAppsModel
113+ applicationsModel: ApplicationManager
114+ filterTouchApps: true
115+ }
116+
98 // For autopilot consumption
117 // For autopilot consumption
99 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
118 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
100
119
@@ -688,10 +707,4 @@ Item {
688 }
707 }
689 }
708 }
690 }
709 }
691−
692− ApplicationsFilterModel {
693− id: legacyAppsModel
694− applicationsModel: ApplicationManager
695− filterTouchApps: true
696− }
697}
710}
tests/mocks/Utils/CMakeLists.txt+2
@@ -18,6 +18,8 @@ set(QMLPLUGIN_SRC
18 ${CMAKE_SOURCE_DIR}/plugins/Utils/windowscreenshotprovider.cpp
18 ${CMAKE_SOURCE_DIR}/plugins/Utils/windowscreenshotprovider.cpp
19 ${CMAKE_SOURCE_DIR}/plugins/Utils/easingcurve.cpp
19 ${CMAKE_SOURCE_DIR}/plugins/Utils/easingcurve.cpp
20 ${CMAKE_SOURCE_DIR}/plugins/Utils/inputwatcher.cpp
20 ${CMAKE_SOURCE_DIR}/plugins/Utils/inputwatcher.cpp
21+ ${CMAKE_SOURCE_DIR}/plugins/Utils/applicationsfiltermodel.cpp
22+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
21 constants.cpp
23 constants.cpp
22 plugin.cpp
24 plugin.cpp
23 windowstatestorage.cpp
25 windowstatestorage.cpp
tests/mocks/Utils/plugin.cpp+2
@@ -35,6 +35,7 @@
35#include <windowkeysfilter.h>
35#include <windowkeysfilter.h>
36#include <windowscreenshotprovider.h>
36#include <windowscreenshotprovider.h>
37#include <easingcurve.h>
37#include <easingcurve.h>
38+#include <applicationsfiltermodel.h>
38
39
39static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine)
40static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine)
40{
41{
@@ -63,6 +64,7 @@ void FakeUtilsPlugin::registerTypes(const char *uri)
63 qmlRegisterType<InputWatcher>(uri, 0, 1, "InputWatcher");
64 qmlRegisterType<InputWatcher>(uri, 0, 1, "InputWatcher");
64 qmlRegisterSingletonType<Constants>(uri, 0, 1, "Constants", createConstants);
65 qmlRegisterSingletonType<Constants>(uri, 0, 1, "Constants", createConstants);
65 qmlRegisterType<ActiveFocusLogger>(uri, 0, 1, "ActiveFocusLogger");
66 qmlRegisterType<ActiveFocusLogger>(uri, 0, 1, "ActiveFocusLogger");
67+ qmlRegisterType<ApplicationsFilterModel>(uri, 0, 1, "ApplicationsFilterModel");
66}
68}
67
69
68void FakeUtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
70void FakeUtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)