on xenial help sign in
implementation should be working now
commit5aa86fa3d0d146a5181e01b8fcb088ab14660ffe authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 28 Oct 2015, 11:32 (11 years ago) parentffde63f
7 files changed+48−9
plugins/Utils/CMakeLists.txt+1 plugins/Utils/applicationsfiltermodel.cpp+12−1 plugins/Utils/applicationsfiltermodel.h+6−1 qml/Components/ModeSwitchWarningDialog.qml+5 qml/Shell.qml+20−7 tests/mocks/Utils/CMakeLists.txt+2 tests/mocks/Utils/plugin.cpp+2
plugins/Utils/CMakeLists.txt+1
@@ -10,6 +10,7 @@ include_directories(
1010
1111set(QMLPLUGIN_SRC
1212 activefocuslogger.cpp
13+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
1314 applicationsfiltermodel.cpp
1415 constants.cpp
1516 HomeKeyWatcher.cpp
plugins/Utils/applicationsfiltermodel.cpp+12−1
@@ -12,7 +12,6 @@ ApplicationsFilterModel::ApplicationsFilterModel(QObject *parent):
1212 m_filterTouchApps(false),
1313 m_filterLegacyApps(false)
1414{
15−
1615}
1716
1817ApplicationManagerInterface *ApplicationsFilterModel::applicationsModel() const
@@ -22,9 +21,14 @@ ApplicationManagerInterface *ApplicationsFilterModel::applicationsModel() const
2221
2322void ApplicationsFilterModel::setApplicationsModel(ApplicationManagerInterface *applicationsModel)
2423{
24+ if (m_appModel) {
25+ disconnect(m_appModel, &ApplicationManagerInterface::countChanged, this, &ApplicationsFilterModel::countChanged);
26+ }
2527 if (m_appModel != applicationsModel) {
2628 m_appModel = applicationsModel;
29+ setSourceModel(m_appModel);
2730 Q_EMIT applicationsModelChanged();
31+ connect(m_appModel, &ApplicationManagerInterface::countChanged, this, &ApplicationsFilterModel::countChanged);
2832 }
2933}
3034
@@ -40,6 +44,7 @@ void ApplicationsFilterModel::setFilterTouchApps(bool filterTouchApps)
4044 Q_EMIT filterTouchAppsChanged();
4145
4246 invalidateFilter();
47+ Q_EMIT countChanged();
4348 }
4449}
4550
@@ -55,6 +60,7 @@ void ApplicationsFilterModel::setFilterLegacyApps(bool filterLegacyApps)
5560 Q_EMIT filterLegacyAppsChanged();
5661
5762 invalidateFilter();
63+ Q_EMIT countChanged();
5864 }
5965}
6066
@@ -72,3 +78,8 @@ bool ApplicationsFilterModel::filterAcceptsRow(int source_row, const QModelIndex
7278 }
7379 return true;
7480}
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 {
77namespace shell {
88namespace application {
99class ApplicationManagerInterface;
10+class ApplicationInfoInterface;
1011}
1112}
1213}
@@ -16,10 +17,11 @@ class ApplicationsFilterModel: public QSortFilterProxyModel
1617{
1718 Q_OBJECT
1819
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)
2021 Q_PROPERTY(bool filterTouchApps READ filterTouchApps WRITE setFilterTouchApps NOTIFY filterTouchAppsChanged)
2122 Q_PROPERTY(bool filterLegacyApps READ filterLegacyApps WRITE setFilterLegacyApps NOTIFY filterLegacyAppsChanged)
2223
24+ Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
2325public:
2426 ApplicationsFilterModel(QObject *parent = 0);
2527
@@ -34,10 +36,13 @@ public:
3436
3537 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
3638
39+ Q_INVOKABLE unity::shell::application::ApplicationInfoInterface* get(int index) const;
40+
3741Q_SIGNALS:
3842 void applicationsModelChanged();
3943 void filterTouchAppsChanged();
4044 void filterLegacyAppsChanged();
45+ void countChanged();
4146
4247private:
4348 ApplicationManagerInterface* m_appModel;
qml/Components/ModeSwitchWarningDialog.qml+5
@@ -14,6 +14,7 @@ Dialog {
1414 Label {
1515 text: i18n.tr("Apps may have unsaved data:")
1616 fontSize: "large"
17+ color: "#5D5D5D"
1718 }
1819
1920 Repeater {
@@ -30,6 +31,7 @@ Dialog {
3031 Label {
3132 Layout.fillWidth: true
3233 text: model.name
34+ color: "#888888"
3335 }
3436 }
3537 }
@@ -37,11 +39,13 @@ Dialog {
3739 Label {
3840 text: i18n.tr("Re-dock, save your work and close these apps to continue.")
3941 wrapMode: Text.WordWrap
42+ color: "#888888"
4043 }
4144
4245 Label {
4346 text: i18n.tr("Or force close now (unsaved data will be lost).")
4447 wrapMode: Text.WordWrap
48+ color: "#888888"
4549 }
4650
4751 ThinDivider {}
@@ -54,6 +58,7 @@ Dialog {
5458 property string notClickedText: i18n.tr("OK, I will reconnect")
5559 property string clickedText: i18n.tr("Reconnect now!")
5660 text: clicked ? clickedText : notClickedText
61+ color: "#333333"
5762
5863 MouseArea {
5964 anchors.fill: parent
qml/Shell.qml+20−7
@@ -42,7 +42,6 @@ import Unity.DashCommunicator 0.1
4242import Unity.Indicators 0.1 as Indicators
4343import Cursor 1.0
4444
45−
4645Item {
4746 id: shell
4847
@@ -95,6 +94,26 @@ Item {
9594 }
9695 }
9796
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+
98117 // For autopilot consumption
99118 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
100119
@@ -688,10 +707,4 @@ Item {
688707 }
689708 }
690709 }
691−
692− ApplicationsFilterModel {
693− id: legacyAppsModel
694− applicationsModel: ApplicationManager
695− filterTouchApps: true
696− }
697710}
tests/mocks/Utils/CMakeLists.txt+2
@@ -18,6 +18,8 @@ set(QMLPLUGIN_SRC
1818 ${CMAKE_SOURCE_DIR}/plugins/Utils/windowscreenshotprovider.cpp
1919 ${CMAKE_SOURCE_DIR}/plugins/Utils/easingcurve.cpp
2020 ${CMAKE_SOURCE_DIR}/plugins/Utils/inputwatcher.cpp
21+ ${CMAKE_SOURCE_DIR}/plugins/Utils/applicationsfiltermodel.cpp
22+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
2123 constants.cpp
2224 plugin.cpp
2325 windowstatestorage.cpp
tests/mocks/Utils/plugin.cpp+2
@@ -35,6 +35,7 @@
3535#include <windowkeysfilter.h>
3636#include <windowscreenshotprovider.h>
3737#include <easingcurve.h>
38+#include <applicationsfiltermodel.h>
3839
3940static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine)
4041{
@@ -63,6 +64,7 @@ void FakeUtilsPlugin::registerTypes(const char *uri)
6364 qmlRegisterType<InputWatcher>(uri, 0, 1, "InputWatcher");
6465 qmlRegisterSingletonType<Constants>(uri, 0, 1, "Constants", createConstants);
6566 qmlRegisterType<ActiveFocusLogger>(uri, 0, 1, "ActiveFocusLogger");
67+ qmlRegisterType<ApplicationsFilterModel>(uri, 0, 1, "ApplicationsFilterModel");
6668}
6769
6870void FakeUtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)