on xenial help sign in
merge lp:~mzanetti/unity8/surfacetitles-in-quicklist
commit11cc61efcb40c108cfc1e9d45296af15ca216ccf authorLukáš Tinkl <lukas.tinkl@canonical.com> dateTue 21 Mar 2017, 12:50 (10 years ago) parent593d500b079ca9
29 files changed+396−37
CMakeLists.txt+2−2 debian/control+3−3 plugins/Greeter/Unity/Launcher/quicklistmodel.cpp+2 plugins/Unity/Launcher/CMakeLists.txt+2 plugins/Unity/Launcher/launcheritem.cpp+30−6 plugins/Unity/Launcher/launcheritem.h+3−2 plugins/Unity/Launcher/launchermodel.cpp+47−14 plugins/Unity/Launcher/launchermodel.h+3−1 plugins/Unity/Launcher/quicklistentry.cpp+11 plugins/Unity/Launcher/quicklistentry.h+4 plugins/Unity/Launcher/quicklistmodel.cpp+9 plugins/Unity/Launcher/quicklistmodel.h+1 plugins/Utils/CMakeLists.txt+1 plugins/Utils/plugin.cpp+2 plugins/Utils/quicklistproxymodel.cpp+72 plugins/Utils/quicklistproxymodel.h+52 qml/Launcher/Launcher.qml+1 qml/Launcher/LauncherPanel.qml+8−1 qml/Shell.qml+1 tests/mocks/Unity/Application/MirSurface.cpp+4 tests/mocks/Unity/Application/MirSurface.h+1 tests/mocks/Unity/Launcher/MockLauncherModel.h+1−1 tests/mocks/Unity/Launcher/MockQuickListModel.cpp+3−1 tests/mocks/Unity/Launcher/MockQuickListModel.h+2 tests/mocks/Utils/CMakeLists.txt+2 tests/mocks/Utils/plugin.cpp+2 tests/plugins/Unity/Launcher/CMakeLists.txt+3 tests/plugins/Unity/Launcher/launchermodeltest.cpp+82−6 tests/qmltests/Launcher/tst_Launcher.qml+42
CMakeLists.txt+2−2
@@ -70,11 +70,11 @@ find_package(Qt5DBus 5.6 REQUIRED)
7070find_package(Qt5Concurrent 5.6 REQUIRED)
7171find_package(Qt5Sql 5.6 REQUIRED)
7272
73−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=26)
73+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=27)
7474pkg_check_modules(GEONAMES REQUIRED geonames>=0.2)
7575pkg_check_modules(GIO REQUIRED gio-2.0>=2.32)
7676pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
77−pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=11)
77+pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=12)
7878pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)
7979pkg_check_modules(GD3 REQUIRED gnome-desktop-3.0)
8080pkg_check_modules(UAL REQUIRED ubuntu-app-launch-3)
debian/control+3−3
@@ -38,7 +38,7 @@ Build-Depends: cmake,
3838 libubuntugestures5-private-dev (>= 1.3.2030),
3939 libudev-dev,
4040 libudm-common-dev,
41− libunity-api-dev (>= 8.2),
41+ libunity-api-dev (>= 8.6),
4242 libusermetricsoutput1-dev,
4343# Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop
4444 libx11-dev[!arm64 !armhf],
@@ -132,7 +132,7 @@ Depends: dmz-cursor-theme,
132132 qtdeclarative5-qtmir-plugin (>= 0.4.8),
133133 qtdeclarative5-ubuntu-telephony0.1,
134134 ubuntu-system-settings (>= 0.4),
135− unity-launcher-impl-10,
135+ unity-launcher-impl-12,
136136 unity8-common (= ${source:Version}),
137137 unity8-private (= ${binary:Version}),
138138 unity8-private | unity-launcher-impl,
@@ -235,7 +235,7 @@ Depends: accountsservice-ubuntu-schemas (>= 0.0.7),
235235 ${misc:Depends},
236236 ${shlibs:Depends},
237237Provides: unity-launcher-impl,
238− unity-launcher-impl-10,
238+ unity-launcher-impl-12,
239239Description: Unity 8 private libs
240240 The Unity 8 shell is the primary user interface for Ubuntu devices.
241241 .
plugins/Greeter/Unity/Launcher/quicklistmodel.cpp+2
@@ -65,6 +65,8 @@ QVariant QuickListModel::data(const QModelIndex &index, int role) const
6565 return m_list.at(index.row()).icon();
6666 case RoleClickable:
6767 return m_list.at(index.row()).clickable();
68+ case RoleIsPrivate:
69+ return false; // The greeter plugin would just not add any private entries
6870 }
6971 return QVariant();
7072}
plugins/Unity/Launcher/CMakeLists.txt+2
@@ -30,6 +30,8 @@ set(QMLLAUNCHERPLUGIN_SRC
3030 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
3131 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
3232 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h
33+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h
34+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
3335 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
3436 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
3537 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/QuickListModelInterface.h
plugins/Unity/Launcher/launcheritem.cpp+30−6
@@ -35,7 +35,6 @@ LauncherItem::LauncherItem(const QString &appId, const QString &name, const QStr
3535 m_countVisible(false),
3636 m_focused(false),
3737 m_alerting(false),
38− m_surfaceCount(0),
3938 m_quickList(new QuickListModel(this))
4039{
4140 Q_ASSERT(parent != nullptr);
@@ -48,11 +47,13 @@ LauncherItem::LauncherItem(const QString &appId, const QString &name, const QStr
4847 QuickListEntry pinningAction;
4948 pinningAction.setActionId(QStringLiteral("pin_item"));
5049 pinningAction.setText(gettext("Pin shortcut"));
50+ pinningAction.setIsPrivate(true);
5151 m_quickList->appendAction(pinningAction);
5252
5353 m_quitAction.setActionId(QStringLiteral("stop_item"));
5454 m_quitAction.setIcon(QStringLiteral("application-exit"));
5555 m_quitAction.setText(gettext("Quit"));
56+ m_quitAction.setIsPrivate(true);
5657}
5758
5859QString LauncherItem::appId() const
@@ -120,6 +121,7 @@ void LauncherItem::setPinned(bool pinned)
120121 QuickListEntry entry;
121122 entry.setActionId(QStringLiteral("pin_item"));
122123 entry.setText(pinned ? gettext("Unpin shortcut") : gettext("Pin shortcut"));
124+ entry.setIsPrivate(true);
123125 m_quickList->updateAction(entry);
124126}
125127
@@ -221,14 +223,36 @@ void LauncherItem::setAlerting(bool alerting)
221223
222224int LauncherItem::surfaceCount() const
223225{
224− return m_surfaceCount;
226+ return m_surfaces.count();
225227}
226228
227−void LauncherItem::setSurfaceCount(int surfaceCount)
229+void LauncherItem::setSurfaces(const QList<QPair<QString, QString> > &surfaces)
228230{
229− if (m_surfaceCount != surfaceCount) {
230− m_surfaceCount = surfaceCount;
231− Q_EMIT surfaceCountChanged(surfaceCount);
231+ if (m_surfaces != surfaces) {
232+ m_surfaces = surfaces;
233+
234+ QList<QuickListEntry> removedEntries;
235+ for (int i = 0; i < m_quickList->rowCount(); ++i) {
236+ QuickListEntry entry = m_quickList->get(i);
237+ if (entry.actionId().startsWith(QStringLiteral("surface_"))) {
238+ removedEntries.append(entry);
239+ }
240+ }
241+ Q_FOREACH (const QuickListEntry &entry, removedEntries) {
242+ m_quickList->removeAction(entry);
243+ }
244+ for (int i = 0; i < surfaces.count(); ++i) {
245+ QuickListEntry entry;
246+ entry.setActionId(QStringLiteral("surface_") + surfaces.at(i).first);
247+ entry.setText(surfaces.at(i).second);
248+ entry.setIsPrivate(true);
249+ if (i == surfaces.count() - 1) {
250+ entry.setHasSeparator(true);
251+ }
252+ m_quickList->insertAction(entry, i + 1);
253+ }
254+
255+ Q_EMIT surfaceCountChanged(m_surfaces.count());
232256 }
233257}
234258
plugins/Unity/Launcher/launcheritem.h+3−2
@@ -23,6 +23,7 @@
2323#include "quicklistmodel.h"
2424
2525#include <unity/shell/launcher/LauncherItemInterface.h>
26+#include <unity/shell/application/MirSurfaceInterface.h>
2627
2728class QuickListModel;
2829
@@ -62,7 +63,7 @@ private:
6263 void setCountVisible(bool countVisible);
6364 void setFocused(bool focused);
6465 void setAlerting(bool alerting);
65− void setSurfaceCount(int surfaceCount);
66+ void setSurfaces(const QList<QPair<QString, QString >> &surfaces);
6667
6768private:
6869 QString m_appId;
@@ -77,7 +78,7 @@ private:
7778 bool m_countVisible;
7879 bool m_focused;
7980 bool m_alerting;
80− int m_surfaceCount;
81+ QList<QPair<QString, QString> > m_surfaces;
8182 QuickListModel *m_quickList;
8283 QuickListEntry m_quitAction;
8384
plugins/Unity/Launcher/launchermodel.cpp+47−14
@@ -23,6 +23,7 @@
2323
2424#include <unity/shell/application/ApplicationInfoInterface.h>
2525#include <unity/shell/application/MirSurfaceListInterface.h>
26+#include <unity/shell/application/MirSurfaceInterface.h>
2627
2728#include <QDesktopServices>
2829#include <QDebug>
@@ -198,12 +199,25 @@ void LauncherModel::quickListActionInvoked(const QString &appId, int actionIndex
198199 } else {
199200 pin(appId);
200201 }
201− } else if (actionId == QLatin1String("launch_item")) {
202+ } else if (actionId == QStringLiteral("launch_item")) {
202203 QDesktopServices::openUrl(getUrlForAppId(appId));
203− } else if (actionId == QLatin1String("stop_item")) { // Quit
204+ } else if (actionId == QStringLiteral("stop_item")) { // Quit
204205 if (m_appManager) {
205206 m_appManager->stopApplication(appId);
206207 }
208+ } else if (actionId.startsWith(QStringLiteral("surface_"))){
209+ ApplicationInfoInterface *appInfo = m_appManager->findApplication(appId);
210+ if (!appInfo) {
211+ qWarning() << "App for" << appId << "not found in launcher. Cannot invoke quicklist action";
212+ }
213+ for (int i = 0; i < appInfo->surfaceList()->count(); ++i) {
214+ MirSurfaceInterface *iface = appInfo->surfaceList()->get(i);
215+ QString id = actionId;
216+ id.remove(QRegExp("^surface_"));
217+ if (id == iface->persistentId()) {
218+ iface->activate();
219+ }
220+ }
207221 // Nope, we don't know this action, let the backend forward it to the application
208222 } else {
209223 // TODO: forward quicklist action to app, possibly via m_dbusIface
@@ -517,40 +531,59 @@ void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
517531 item->setRecent(true);
518532 Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleRecent});
519533 }
520− if (item->surfaceCount() != app->surfaceCount()) {
521− item->setSurfaceCount(app->surfaceCount());
522− Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleSurfaceCount});
523− }
524−
525534 item->setRunning(true);
526535 } else {
527536 LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);
528537 item->setRecent(true);
529538 item->setRunning(true);
530539 item->setFocused(app->focused());
531− item->setSurfaceCount(app->surfaceCount());
532540 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
533541 m_list.append(item);
534542 endInsertRows();
535543 }
536− connect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::applicationSurfaceCountChanged);
544+ connect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::updateSurfaceList);
537545 m_asAdapter->syncItems(m_list);
538546 Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleRunning});
539547}
540548
541−void LauncherModel::applicationSurfaceCountChanged(int count)
549+void LauncherModel::updateSurfaceList()
542550{
543551 ApplicationInfoInterface *app = static_cast<ApplicationInfoInterface*>(sender());
552+ updateSurfaceListForApp(app);
553+}
554+
555+void LauncherModel::updateSurfaceListForSurface()
556+{
557+ MirSurfaceInterface *iface = static_cast<MirSurfaceInterface*>(sender());
558+ ApplicationInfoInterface* app = m_appManager->findApplication(iface->appId());
559+ if (!app) {
560+ return;
561+ }
562+ updateSurfaceListForApp(app);
563+}
564+
565+void LauncherModel::updateSurfaceListForApp(ApplicationInfoInterface* app)
566+{
544567 int idx = findApplication(app->appId());
545568 if (idx < 0) {
546569 qWarning() << "Received a surface count changed event from an app that's not in the Launcher model";
547570 return;
548571 }
549572 LauncherItem *item = m_list.at(idx);
550− if (item->surfaceCount() != count) {
551− item->setSurfaceCount(count);
552− Q_EMIT dataChanged(index(idx), index(idx), {RoleSurfaceCount});
573+ QList<QPair<QString, QString> > surfaces;
574+ for (int i = 0; i < app->surfaceList()->count(); ++i) {
575+ MirSurfaceInterface* iface = app->surfaceList()->get(i);
576+ // Avoid duplicate connections, so let's just disconnect first to be sure
577+ disconnect(iface, &MirSurfaceInterface::nameChanged, this, &LauncherModel::updateSurfaceListForSurface);
578+ connect(iface, &MirSurfaceInterface::nameChanged, this, &LauncherModel::updateSurfaceListForSurface);
579+ QString name = iface->name();
580+ if (name.isEmpty()) {
581+ name = app->name();
582+ }
583+ surfaces.append({iface->persistentId(), name});
553584 }
585+ item->setSurfaces(surfaces);
586+ Q_EMIT dataChanged(index(idx), index(idx), {RoleSurfaceCount});
554587}
555588
556589void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
@@ -571,7 +604,7 @@ void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
571604 return;
572605 }
573606
574− disconnect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::applicationSurfaceCountChanged);
607+ disconnect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::updateSurfaceList);
575608
576609 LauncherItem * item = m_list.at(appIndex);
577610
plugins/Unity/Launcher/launchermodel.h+3−1
@@ -75,7 +75,9 @@ private Q_SLOTS:
7575 void applicationAdded(const QModelIndex &parent, int row);
7676 void applicationRemoved(const QModelIndex &parent, int row);
7777 void focusedAppIdChanged();
78− void applicationSurfaceCountChanged(int);
78+ void updateSurfaceList();
79+ void updateSurfaceListForApp(ApplicationInfoInterface *app);
80+ void updateSurfaceListForSurface();
7981
8082private:
8183 QList<LauncherItem*> m_list;
plugins/Unity/Launcher/quicklistentry.cpp+11
@@ -20,6 +20,7 @@
2020
2121QuickListEntry::QuickListEntry()
2222 : m_hasSeparator(false)
23+ , m_isPrivate(false)
2324{
2425}
2526
@@ -72,3 +73,13 @@ bool QuickListEntry::operator==(const QuickListEntry &other)
7273{
7374 return !other.actionId().isEmpty() && other.actionId() == m_actionId;
7475}
76+
77+bool QuickListEntry::isPrivate() const
78+{
79+ return m_isPrivate;
80+}
81+
82+void QuickListEntry::setIsPrivate(bool isPrivate)
83+{
84+ m_isPrivate = isPrivate;
85+}
plugins/Unity/Launcher/quicklistentry.h+4
@@ -42,11 +42,15 @@ public:
4242
4343 bool operator==(const QuickListEntry & other);
4444
45+ bool isPrivate() const;
46+ void setIsPrivate(bool isPrivate);
47+
4548private:
4649 QString m_actionId;
4750 QString m_text;
4851 QString m_icon;
4952 bool m_hasSeparator;
53+ bool m_isPrivate;
5054};
5155
5256#endif // QUICKLISTENTRY
plugins/Unity/Launcher/quicklistmodel.cpp+9
@@ -37,6 +37,13 @@ void QuickListModel::appendAction(const QuickListEntry &entry)
3737 endInsertRows();
3838}
3939
40+void QuickListModel::insertAction(const QuickListEntry &entry, int index)
41+{
42+ beginInsertRows(QModelIndex(), index, index);
43+ m_list.insert(index, entry);
44+ endInsertRows();
45+}
46+
4047void QuickListModel::updateAction(const QuickListEntry &entry)
4148{
4249 for (int i = 0; i < m_list.count(); ++i) {
@@ -81,6 +88,8 @@ QVariant QuickListModel::data(const QModelIndex &index, int role) const
8188 return m_list.at(index.row()).clickable();
8289 case RoleHasSeparator:
8390 return m_list.at(index.row()).hasSeparator();
91+ case RoleIsPrivate:
92+ return m_list.at(index.row()).isPrivate();
8493 }
8594 return QVariant();
8695}
plugins/Unity/Launcher/quicklistmodel.h+1
@@ -36,6 +36,7 @@ public:
3636 ~QuickListModel();
3737
3838 void appendAction(const QuickListEntry &entry);
39+ void insertAction(const QuickListEntry &entry, int index);
3940
4041 /**
4142 * @brief Update an existing action
plugins/Utils/CMakeLists.txt+1
@@ -36,6 +36,7 @@ set(QMLPLUGIN_SRC
3636 URLDispatcher.cpp
3737 tabfocusfence.cpp
3838 expressionfiltermodel.cpp
39+ quicklistproxymodel.cpp
3940 plugin.cpp
4041 )
4142
plugins/Utils/plugin.cpp+2
@@ -42,6 +42,7 @@
4242#include "appdrawerproxymodel.h"
4343#include "tabfocusfence.h"
4444#include "expressionfiltermodel.h"
45+#include "quicklistproxymodel.h"
4546
4647static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine)
4748{
@@ -88,4 +89,5 @@ void UtilsPlugin::registerTypes(const char *uri)
8889 qmlRegisterType<AppDrawerProxyModel>(uri, 0, 1, "AppDrawerProxyModel");
8990 qmlRegisterType<TabFocusFenceItem>(uri, 0, 1, "TabFocusFence");
9091 qmlRegisterType<ExpressionFilterModel>(uri, 0, 1, "ExpressionFilterModel");
92+ qmlRegisterType<QuickListProxyModel>(uri, 0, 1, "QuickListProxyModel");
9193}
plugins/Utils/quicklistproxymodel.cppnew file+72
@@ -0,0 +1,72 @@
1+/*
2+ * Copyright (C) 2017 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "quicklistproxymodel.h"
18+
19+#include <QDebug>
20+
21+QuickListProxyModel::QuickListProxyModel(QObject *parent):
22+ QSortFilterProxyModel(parent)
23+{
24+ connect(this, &QAbstractListModel::rowsInserted, this, &QuickListProxyModel::countChanged);
25+ connect(this, &QAbstractListModel::rowsRemoved, this, &QuickListProxyModel::countChanged);
26+ connect(this, &QAbstractListModel::layoutChanged, this, &QuickListProxyModel::countChanged);
27+}
28+
29+QAbstractItemModel *QuickListProxyModel::source() const
30+{
31+ return m_source;
32+}
33+
34+bool QuickListProxyModel::privateMode() const
35+{
36+ return m_privateMode;
37+}
38+
39+void QuickListProxyModel::setPrivateMode(bool privateMode)
40+{
41+ if (m_privateMode != privateMode) {
42+ m_privateMode = privateMode;
43+ invalidateFilter();
44+ Q_EMIT privateModeChanged();
45+ }
46+}
47+
48+void QuickListProxyModel::setSource(QAbstractItemModel *source)
49+{
50+ if (m_source != source) {
51+ m_source = source;
52+ setSourceModel(m_source);
53+ connect(m_source, &QAbstractItemModel::rowsRemoved, this, &QuickListProxyModel::invalidate);
54+ connect(m_source, &QAbstractItemModel::rowsInserted, this, &QuickListProxyModel::invalidate);
55+ Q_EMIT sourceChanged();
56+ }
57+}
58+
59+int QuickListProxyModel::count() const
60+{
61+ return rowCount();
62+}
63+
64+bool QuickListProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
65+{
66+ Q_UNUSED(source_parent)
67+
68+ if (m_privateMode) {
69+ return !m_source->data(m_source->index(source_row, 0), QuickListModelInterface::RoleIsPrivate).toBool();
70+ }
71+ return true;
72+}
plugins/Utils/quicklistproxymodel.hnew file+52
@@ -0,0 +1,52 @@
1+/*
2+ * Copyright (C) 2017 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include <QSortFilterProxyModel>
18+
19+#include <unity/shell/launcher/QuickListModelInterface.h>
20+
21+using namespace unity::shell::launcher;
22+
23+class QuickListProxyModel: public QSortFilterProxyModel
24+{
25+ Q_OBJECT
26+ Q_PROPERTY(QAbstractItemModel* source READ source WRITE setSource NOTIFY sourceChanged)
27+ Q_PROPERTY(bool privateMode READ privateMode WRITE setPrivateMode NOTIFY privateModeChanged)
28+ Q_PROPERTY(int count READ count NOTIFY countChanged)
29+
30+public:
31+ QuickListProxyModel(QObject* parent = nullptr);
32+
33+ QAbstractItemModel* source() const;
34+ void setSource(QAbstractItemModel* source);
35+
36+ bool privateMode() const;
37+ void setPrivateMode(bool privateMode);
38+
39+ int count() const;
40+
41+protected:
42+ bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
43+
44+Q_SIGNALS:
45+ void sourceChanged();
46+ void privateModeChanged();
47+ void countChanged();
48+
49+private:
50+ QAbstractItemModel* m_source = nullptr;
51+ bool m_privateMode;
52+};
qml/Launcher/Launcher.qml+1
@@ -33,6 +33,7 @@ FocusScope {
3333 property Item blurSource: null
3434 property int topPanelHeight: 0
3535 property bool drawerEnabled: true
36+ property alias privateMode: panel.privateMode
3637
3738 property int panelWidth: units.gu(10)
3839 property int dragAreaWidth: units.gu(1)
qml/Launcher/LauncherPanel.qml+8−1
@@ -19,6 +19,7 @@ import QtQml.StateMachine 1.0 as DSM
1919import Ubuntu.Components 1.3
2020import Unity.Launcher 0.1
2121import Ubuntu.Components.Popups 1.3
22+import Utils 0.1
2223import "../Components"
2324
2425Rectangle {
@@ -29,6 +30,7 @@ Rectangle {
2930
3031 property var model
3132 property bool inverted: false
33+ property bool privateMode: false
3234 property bool dragging: false
3335 property bool moving: launcherListView.moving || launcherListView.flicking
3436 property bool preventHiding: moving || dndArea.draggedIndex >= 0 || quickList.state === "open" || dndArea.pressed
@@ -811,7 +813,11 @@ Rectangle {
811813
812814 Repeater {
813815 id: popoverRepeater
814− model: quickList.model
816+ objectName: "popoverRepeater"
817+ model: QuickListProxyModel {
818+ source: quickList.model
819+ privateMode: root.privateMode
820+ }
815821
816822 ListItem {
817823 objectName: "quickListEntry" + index
@@ -835,6 +841,7 @@ Rectangle {
835841 fontSize: index == 0 ? "medium" : "small"
836842 font.weight: index == 0 ? Font.Medium : Font.Light
837843 color: model.clickable ? theme.palette.normal.backgroundText : theme.palette.disabled.backgroundText
844+ elide: Text.ElideRight
838845 }
839846
840847 onClicked: {
qml/Shell.qml+1
@@ -559,6 +559,7 @@ StyledItem {
559559 blurSource: greeter.shown ? greeter : stages
560560 topPanelHeight: panel.panelHeight
561561 drawerEnabled: !greeter.active
562+ privateMode: greeter.active
562563
563564 onShowDashHome: showHome()
564565 onLauncherApplicationSelected: {
tests/mocks/Unity/Application/MirSurface.cpp+4
@@ -127,6 +127,10 @@ QString MirSurface::persistentId() const
127127 return m_name+"Id";
128128}
129129
130+QString MirSurface::appId() const
131+{
132+ return m_name+"appId";
133+}
130134Mir::Type MirSurface::type() const
131135{
132136 return m_type;
tests/mocks/Unity/Application/MirSurface.h+1
@@ -58,6 +58,7 @@ public:
5858 QString name() const override;
5959
6060 QString persistentId() const override;
61+ QString appId() const override;
6162
6263 QPoint position() const override { return m_position; }
6364
tests/mocks/Unity/Launcher/MockLauncherModel.h+1−1
@@ -28,7 +28,7 @@ using namespace unity::shell::launcher;
2828
2929class MockLauncherModel: public LauncherModelInterface
3030{
31− Q_OBJECT
31+ Q_OBJECT
3232
3333public:
3434 MockLauncherModel(QObject* parent = 0);
tests/mocks/Unity/Launcher/MockQuickListModel.cpp+3−1
@@ -39,6 +39,8 @@ QVariant MockQuickListModel::data(const QModelIndex &index, int role) const
3939 return index.row() == 1 ? false : true;
4040 case RoleHasSeparator:
4141 return index.row() <= 1 ? true : false;
42+ case RoleIsPrivate:
43+ return index.row() == 4 ? true : false;
4244 }
4345 return QVariant();
4446}
@@ -46,5 +48,5 @@ QVariant MockQuickListModel::data(const QModelIndex &index, int role) const
4648int MockQuickListModel::rowCount(const QModelIndex &parent) const
4749{
4850 Q_UNUSED(parent)
49− return 4;
51+ return 5;
5052}
tests/mocks/Unity/Launcher/MockQuickListModel.h+2
@@ -27,6 +27,8 @@ using namespace unity::shell::launcher;
2727class MockQuickListModel: public QuickListModelInterface
2828{
2929 Q_OBJECT
30+ Q_PROPERTY(int count READ rowCount)
31+
3032public:
3133 MockQuickListModel(QObject *parent = 0);
3234
tests/mocks/Utils/CMakeLists.txt+2
@@ -27,6 +27,7 @@ set(QMLPLUGIN_SRC
2727 ${CMAKE_SOURCE_DIR}/plugins/Utils/appdrawerproxymodel.cpp
2828 ${CMAKE_SOURCE_DIR}/plugins/Utils/tabfocusfence.cpp
2929 ${CMAKE_SOURCE_DIR}/plugins/Utils/expressionfiltermodel.cpp
30+ ${CMAKE_SOURCE_DIR}/plugins/Utils/quicklistproxymodel.cpp
3031 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
3132 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
3233 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h
@@ -35,6 +36,7 @@ set(QMLPLUGIN_SRC
3536 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/AppDrawerModelInterface.h
3637 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
3738 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherItemInterface.h
39+ ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/QuickListModelInterface.h
3840 constants.cpp
3941 plugin.cpp
4042 windowstatestorage.cpp
tests/mocks/Utils/plugin.cpp+2
@@ -43,6 +43,7 @@
4343#include <appdrawerproxymodel.h>
4444#include <tabfocusfence.h>
4545#include <expressionfiltermodel.h>
46+#include <quicklistproxymodel.h>
4647
4748static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine)
4849{
@@ -88,4 +89,5 @@ void FakeUtilsPlugin::registerTypes(const char *uri)
8889 qmlRegisterType<AppDrawerProxyModel>(uri, 0, 1, "AppDrawerProxyModel");
8990 qmlRegisterType<TabFocusFenceItem>(uri, 0, 1, "TabFocusFence");
9091 qmlRegisterType<ExpressionFilterModel>(uri, 0, 1, "ExpressionFilterModel");
92+ qmlRegisterType<QuickListProxyModel>(uri, 0, 1, "QuickListProxyModel");
9193}
tests/plugins/Unity/Launcher/CMakeLists.txt+3
@@ -34,6 +34,9 @@ add_executable(launchermodeltestExec
3434 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/LauncherModelInterface.h
3535 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/launcher/QuickListModelInterface.h
3636 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
37+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h
38+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h
39+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
3740 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
3841 )
3942target_link_libraries(launchermodeltestExec
tests/plugins/Unity/Launcher/launchermodeltest.cpp+82−6
@@ -17,6 +17,7 @@
1717// unity-api
1818#include <unity/shell/launcher/LauncherModelInterface.h>
1919#include <unity/shell/application/ApplicationInfoInterface.h>
20+#include <unity/shell/application/MirSurfaceListInterface.h>
2021
2122#include "launcheritem.h"
2223#include "launchermodel.h"
@@ -37,11 +38,74 @@
3738namespace unityapi = unity::shell::application;
3839
3940// This is a mock, specifically to test the LauncherModel
41+class MockSurface: public unity::shell::application::MirSurfaceInterface
42+{
43+ Q_OBJECT
44+public:
45+ MockSurface(const QString &id, const QString &appId, QObject* parent): unityapi::MirSurfaceInterface(parent), m_id(id), m_appId(appId) {}
46+ Mir::Type type() const override { return Mir::NormalType;}
47+ QString name() const override { return QStringLiteral("mock surface"); }
48+ QString persistentId() const override { return m_id; }
49+ QString appId() const override { return m_appId; }
50+ QPoint position() const override { return QPoint(); }
51+ QSize size() const override { return QSize(); }
52+ void resize(const QSize &size) override { Q_UNUSED(size) }
53+ void resize(int width, int height) override { Q_UNUSED(width); Q_UNUSED(height) }
54+ Mir::State state() const override { return Mir::RestoredState; }
55+ bool live() const override { return true; }
56+ bool visible() const override { return true; }
57+ Mir::OrientationAngle orientationAngle() const override { return Mir::Angle0; }
58+ void setOrientationAngle(Mir::OrientationAngle angle) override { Q_UNUSED(angle); }
59+ int minimumWidth() const override { return 0; }
60+ int minimumHeight() const override { return 0; }
61+ int maximumWidth() const override { return 0; }
62+ int maximumHeight() const override { return 0; }
63+ int widthIncrement() const override { return 0; }
64+ int heightIncrement() const override { return 0; }
65+ void setKeymap(const QString &) override {}
66+ Mir::ShellChrome shellChrome() const override { return Mir::NormalChrome; }
67+ QString keymap() const override { return QStringLiteral("de_DE"); }
68+ bool focused() const override { return true; }
69+ QRect inputBounds() const override { return QRect(); }
70+ bool confinesMousePointer() const override { return false; }
71+ QPoint requestedPosition() const override { return QPoint(); }
72+ void setRequestedPosition(const QPoint &) override {}
73+ MirSurfaceInterface* parentSurface() const override { return nullptr; }
74+ MirSurfaceListInterface* childSurfaceList() const override { return nullptr; }
75+ void close() override {}
76+ void activate() override {}
77+ void requestState(Mir::State) override {}
78+
79+private:
80+ QString m_id;
81+ QString m_appId;
82+};
83+
84+class MockSurfaceList: public unity::shell::application::MirSurfaceListInterface
85+{
86+ Q_OBJECT
87+public:
88+ MockSurfaceList(QObject *parent): unityapi::MirSurfaceListInterface(parent) {}
89+ int rowCount(const QModelIndex & = QModelIndex()) const override { return m_list.count(); }
90+ QVariant data(const QModelIndex &, int) const override { return QVariant(); }
91+ Q_INVOKABLE MirSurfaceInterface* get(int index) override { return m_list.at(index); }
92+ void append(MirSurfaceInterface* surface) {
93+ beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
94+ m_list.append(surface);
95+ endInsertRows();
96+ }
97+private:
98+ QList<MirSurfaceInterface*> m_list;
99+
100+};
101+
40102class MockApp: public unity::shell::application::ApplicationInfoInterface
41103{
42104 Q_OBJECT
43105public:
44− MockApp(const QString &appId, QObject *parent = 0): ApplicationInfoInterface(appId, parent), m_appId(appId), m_focused(false) { }
106+ MockApp(const QString &appId, QObject *parent = 0): ApplicationInfoInterface(appId, parent), m_appId(appId), m_focused(false) {
107+ m_surfaces = new MockSurfaceList(this);
108+ }
45109
46110 RequestedState requestedState() const override { return RequestedRunning; }
47111 void setRequestedState(RequestedState) override {}
@@ -64,10 +128,10 @@ public:
64128 void setExemptFromLifecycle(bool) override {}
65129 QSize initialSurfaceSize() const override { return QSize(); }
66130 void setInitialSurfaceSize(const QSize &) override {}
67− MirSurfaceListInterface* surfaceList() const override { return nullptr; }
131+ MirSurfaceListInterface* surfaceList() const override { return m_surfaces; }
68132 MirSurfaceListInterface* promptSurfaceList() const override { return nullptr; }
69− int surfaceCount() const override { return m_surfaceCount; }
70− void setSurfaceCount(int count) { m_surfaceCount = count; Q_EMIT surfaceCountChanged(count); }
133+ int surfaceCount() const override { return m_surfaces->count(); }
134+ void setSurfaces(MockSurfaceList* surfaces) { m_surfaces = surfaces; Q_EMIT surfaceCountChanged(m_surfaces->count()); }
71135 void close() override {}
72136
73137 // Methods used for mocking (not in the interface)
@@ -75,7 +139,7 @@ public:
75139private:
76140 QString m_appId;
77141 bool m_focused;
78− int m_surfaceCount = 0;
142+ MockSurfaceList *m_surfaces;
79143};
80144
81145// This is a mock, specifically to test the LauncherModel
@@ -748,8 +812,20 @@ private Q_SLOTS:
748812
749813 QCOMPARE(launcherModel->get(0)->surfaceCount(), 0);
750814 MockApp *app = qobject_cast<MockApp*>(appManager->findApplication(appId));
751− app->setSurfaceCount(1);
815+ MockSurfaceList* surfaces = new MockSurfaceList(appManager);
816+ surfaces->append(new MockSurface("foobar", "foobar", surfaces));
817+ app->setSurfaces(surfaces);
752818 QCOMPARE(launcherModel->get(0)->surfaceCount(), 1);
819+
820+ // Make sure the new surface appears in the quicklist
821+ QuickListModel *quickList = qobject_cast<QuickListModel*>(launcherModel->get(0)->quickList());
822+ bool found = false;
823+ for (int i = 0; i < quickList->rowCount(); ++i) {
824+ if (quickList->get(i).actionId() == "surface_foobar") {
825+ found = true;
826+ }
827+ }
828+ QCOMPARE(found, true);
753829 }
754830};
755831
tests/qmltests/Launcher/tst_Launcher.qml+42
@@ -95,6 +95,11 @@ Rectangle {
9595 property: "lockedVisible"
9696 value: lockedVisibleCheckBox.checked
9797 }
98+ Binding {
99+ target: launcherLoader.item
100+ property: "privateMode"
101+ value: privateModeCheckBox.checked
102+ }
98103 Binding {
99104 target: launcherLoader.item
100105 property: "panelWidth"
@@ -120,6 +125,20 @@ Rectangle {
120125 }
121126 }
122127
128+ RowLayout {
129+ CheckBox {
130+ id: privateModeCheckBox
131+ checked: false
132+ }
133+ Label {
134+ text: "Private mode (lockscreen locked)"
135+ AbstractButton {
136+ anchors.fill: parent
137+ onClicked: privateModeCheckBox.checked = !privateModeCheckBox.checked
138+ }
139+ }
140+ }
141+
123142 Slider {
124143 id: widthSlider
125144 Layout.fillWidth: true
@@ -1242,6 +1261,7 @@ Rectangle {
12421261 keyClick(Qt.Key_Down);
12431262 keyClick(Qt.Key_Down);
12441263 keyClick(Qt.Key_Down);
1264+ keyClick(Qt.Key_Down);
12451265 tryCompare(quickList, "selectedIndex", 0)
12461266
12471267 // Left gets us back to the launcher
@@ -1493,6 +1513,28 @@ Rectangle {
14931513 compare(launcher.state, "visibleTemporary");
14941514 }
14951515
1516+ function test_hideQuicklistItemsInPrivateModel_data() {
1517+ return [
1518+ { tag: "private mode", private: true },
1519+ { tag: "normal mode", private: false }
1520+ ];
1521+ }
1522+
1523+ function test_hideQuicklistItemsInPrivateModel(data) {
1524+ privateModeCheckBox.checked = data.private;
1525+
1526+ revealByEdgePush();
1527+
1528+ var item = findChild(launcher, "launcherDelegate4");
1529+ var quickListShape = findChild(launcher, "quickListShape")
1530+
1531+ mousePress(item)
1532+ tryCompare(quickListShape, "visible", true)
1533+
1534+ var repeater = findChild(launcher, "popoverRepeater");
1535+ tryCompare(repeater, "count", LauncherModel.get(4).quickList.count - (data.private ? 1 : 0))
1536+ }
1537+
14961538 function test_hintOnSizeChange() {
14971539 var oldSize = launcher.panelWidth;
14981540 launcher.maxPanelX = -launcher.panelWidth;