on xenial help sign in
allow hiding "private" quicklist entries when the greeter is locked
commit1b401c376e9beb65d2c7ba1c789a05f751d24504 authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 24 Feb 2017, 13:52 (10 years ago) parent6f314ea
12 files changed+79−3
plugins/Greeter/Unity/Launcher/quicklistmodel.cpp+2 plugins/Unity/Launcher/launcheritem.cpp+2 plugins/Unity/Launcher/quicklistentry.cpp+11 plugins/Unity/Launcher/quicklistentry.h+4 plugins/Unity/Launcher/quicklistmodel.cpp+2 qml/Launcher/Launcher.qml+1 qml/Launcher/LauncherPanel.qml+8−1 qml/Shell.qml+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/qmltests/Launcher/tst_Launcher.qml+42
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/launcheritem.cpp+2
@@ -48,11 +48,13 @@ LauncherItem::LauncherItem(const QString &appId, const QString &name, const QStr
4848 QuickListEntry pinningAction;
4949 pinningAction.setActionId(QStringLiteral("pin_item"));
5050 pinningAction.setText(gettext("Pin shortcut"));
51+ pinningAction.setIsPrivate(true);
5152 m_quickList->appendAction(pinningAction);
5253
5354 m_quitAction.setActionId(QStringLiteral("stop_item"));
5455 m_quitAction.setIcon(QStringLiteral("application-exit"));
5556 m_quitAction.setText(gettext("Quit"));
57+ m_quitAction.setIsPrivate(true);
5658}
5759
5860QString LauncherItem::appId() const
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+2
@@ -81,6 +81,8 @@ QVariant QuickListModel::data(const QModelIndex &index, int role) const
8181 return m_list.at(index.row()).clickable();
8282 case RoleHasSeparator:
8383 return m_list.at(index.row()).hasSeparator();
84+ case RoleIsPrivate:
85+ return m_list.at(index.row()).isPrivate();
8486 }
8587 return QVariant();
8688}
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
@@ -809,7 +811,12 @@ Rectangle {
809811
810812 Repeater {
811813 id: popoverRepeater
812− model: quickList.model
814+ objectName: "popoverRepeater"
815+ model: UnitySortFilterProxyModel {
816+ model: quickList.model
817+ filterRole: QuickListModelInterface.RoleIsPrivate
818+ filterRegExp: root.privateMode ? RegExp(false) : RegExp()
819+ }
813820
814821 ListItem {
815822 objectName: "quickListEntry" + index
qml/Shell.qml+1
@@ -557,6 +557,7 @@ StyledItem {
557557 blurSource: greeter.shown ? greeter : stages
558558 topPanelHeight: panel.panelHeight
559559 drawerEnabled: !greeter.active
560+ privateMode: greeter.active
560561
561562 onShowDashHome: showHome()
562563 onLauncherApplicationSelected: {
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/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: lockedVisibleCheckBox.checked = !lockedVisibleCheckBox.checked
138+ }
139+ }
140+ }
141+
123142 Slider {
124143 id: widthSlider
125144 Layout.fillWidth: true
@@ -1493,6 +1512,29 @@ Rectangle {
14931512 compare(launcher.state, "visibleTemporary");
14941513 }
14951514
1515+ function test_hideQuicklistItemsInPrivateModel_data() {
1516+ return [
1517+ { tag: "private mode", private: true },
1518+ { tag: "normal mode", private: false }
1519+ ];
1520+ }
1521+
1522+ function test_hideQuicklistItemsInPrivateModel(data) {
1523+ privateModeCheckBox.checked = data.private;
1524+
1525+ revealByEdgePush();
1526+
1527+ var item = findChild(launcher, "launcherDelegate4");
1528+ var quickListShape = findChild(launcher, "quickListShape")
1529+
1530+ mousePress(item)
1531+ tryCompare(quickListShape, "visible", true)
1532+
1533+ var repeater = findChild(launcher, "popoverRepeater");
1534+ print("model is", LauncherModel)
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;