on xenial help sign in
allow hiding "private" quicklist entries when the greeter is locked
1b401c3Michael Zanetti
plugins/Greeter/Unity/Launcher/quicklistmodel.cpp+2
@@ -65,6 +65,8 @@ QVariant QuickListModel::data(const QModelIndex &index, int role) const
65 return m_list.at(index.row()).icon();
65 return m_list.at(index.row()).icon();
66 case RoleClickable:
66 case RoleClickable:
67 return m_list.at(index.row()).clickable();
67 return m_list.at(index.row()).clickable();
68+ case RoleIsPrivate:
69+ return false; // The greeter plugin would just not add any private entries
68 }
70 }
69 return QVariant();
71 return QVariant();
70}
72}
plugins/Unity/Launcher/launcheritem.cpp+2
@@ -48,11 +48,13 @@ LauncherItem::LauncherItem(const QString &appId, const QString &name, const QStr
48 QuickListEntry pinningAction;
48 QuickListEntry pinningAction;
49 pinningAction.setActionId(QStringLiteral("pin_item"));
49 pinningAction.setActionId(QStringLiteral("pin_item"));
50 pinningAction.setText(gettext("Pin shortcut"));
50 pinningAction.setText(gettext("Pin shortcut"));
51+ pinningAction.setIsPrivate(true);
51 m_quickList->appendAction(pinningAction);
52 m_quickList->appendAction(pinningAction);
52
53
53 m_quitAction.setActionId(QStringLiteral("stop_item"));
54 m_quitAction.setActionId(QStringLiteral("stop_item"));
54 m_quitAction.setIcon(QStringLiteral("application-exit"));
55 m_quitAction.setIcon(QStringLiteral("application-exit"));
55 m_quitAction.setText(gettext("Quit"));
56 m_quitAction.setText(gettext("Quit"));
57+ m_quitAction.setIsPrivate(true);
56}
58}
57
59
58QString LauncherItem::appId() const
60QString LauncherItem::appId() const
plugins/Unity/Launcher/quicklistentry.cpp+11
@@ -20,6 +20,7 @@
20
20
21QuickListEntry::QuickListEntry()
21QuickListEntry::QuickListEntry()
22 : m_hasSeparator(false)
22 : m_hasSeparator(false)
23+ , m_isPrivate(false)
23{
24{
24}
25}
25
26
@@ -72,3 +73,13 @@ bool QuickListEntry::operator==(const QuickListEntry &other)
72{
73{
73 return !other.actionId().isEmpty() && other.actionId() == m_actionId;
74 return !other.actionId().isEmpty() && other.actionId() == m_actionId;
74}
75}
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:
42
42
43 bool operator==(const QuickListEntry & other);
43 bool operator==(const QuickListEntry & other);
44
44
45+ bool isPrivate() const;
46+ void setIsPrivate(bool isPrivate);
47+
45private:
48private:
46 QString m_actionId;
49 QString m_actionId;
47 QString m_text;
50 QString m_text;
48 QString m_icon;
51 QString m_icon;
49 bool m_hasSeparator;
52 bool m_hasSeparator;
53+ bool m_isPrivate;
50};
54};
51
55
52#endif // QUICKLISTENTRY
56#endif // QUICKLISTENTRY
plugins/Unity/Launcher/quicklistmodel.cpp+2
@@ -81,6 +81,8 @@ QVariant QuickListModel::data(const QModelIndex &index, int role) const
81 return m_list.at(index.row()).clickable();
81 return m_list.at(index.row()).clickable();
82 case RoleHasSeparator:
82 case RoleHasSeparator:
83 return m_list.at(index.row()).hasSeparator();
83 return m_list.at(index.row()).hasSeparator();
84+ case RoleIsPrivate:
85+ return m_list.at(index.row()).isPrivate();
84 }
86 }
85 return QVariant();
87 return QVariant();
86}
88}
qml/Launcher/Launcher.qml+1
@@ -33,6 +33,7 @@ FocusScope {
33 property Item blurSource: null
33 property Item blurSource: null
34 property int topPanelHeight: 0
34 property int topPanelHeight: 0
35 property bool drawerEnabled: true
35 property bool drawerEnabled: true
36+ property alias privateMode: panel.privateMode
36
37
37 property int panelWidth: units.gu(10)
38 property int panelWidth: units.gu(10)
38 property int dragAreaWidth: units.gu(1)
39 property int dragAreaWidth: units.gu(1)
qml/Launcher/LauncherPanel.qml+8−1
@@ -19,6 +19,7 @@ import QtQml.StateMachine 1.0 as DSM
19import Ubuntu.Components 1.3
19import Ubuntu.Components 1.3
20import Unity.Launcher 0.1
20import Unity.Launcher 0.1
21import Ubuntu.Components.Popups 1.3
21import Ubuntu.Components.Popups 1.3
22+import Utils 0.1
22import "../Components"
23import "../Components"
23
24
24Rectangle {
25Rectangle {
@@ -29,6 +30,7 @@ Rectangle {
29
30
30 property var model
31 property var model
31 property bool inverted: false
32 property bool inverted: false
33+ property bool privateMode: false
32 property bool dragging: false
34 property bool dragging: false
33 property bool moving: launcherListView.moving || launcherListView.flicking
35 property bool moving: launcherListView.moving || launcherListView.flicking
34 property bool preventHiding: moving || dndArea.draggedIndex >= 0 || quickList.state === "open" || dndArea.pressed
36 property bool preventHiding: moving || dndArea.draggedIndex >= 0 || quickList.state === "open" || dndArea.pressed
@@ -809,7 +811,12 @@ Rectangle {
809
811
810 Repeater {
812 Repeater {
811 id: popoverRepeater
813 id: popoverRepeater
814+ objectName: "popoverRepeater"
815+ model: UnitySortFilterProxyModel {
812− model: quickList.model
816+ model: quickList.model
817+ filterRole: QuickListModelInterface.RoleIsPrivate
818+ filterRegExp: root.privateMode ? RegExp(false) : RegExp()
819+ }
813
820
814 ListItem {
821 ListItem {
815 objectName: "quickListEntry" + index
822 objectName: "quickListEntry" + index
qml/Shell.qml+1
@@ -557,6 +557,7 @@ StyledItem {
557 blurSource: greeter.shown ? greeter : stages
557 blurSource: greeter.shown ? greeter : stages
558 topPanelHeight: panel.panelHeight
558 topPanelHeight: panel.panelHeight
559 drawerEnabled: !greeter.active
559 drawerEnabled: !greeter.active
560+ privateMode: greeter.active
560
561
561 onShowDashHome: showHome()
562 onShowDashHome: showHome()
562 onLauncherApplicationSelected: {
563 onLauncherApplicationSelected: {
tests/mocks/Unity/Launcher/MockLauncherModel.h+1−1
@@ -28,7 +28,7 @@ using namespace unity::shell::launcher;
28
28
29class MockLauncherModel: public LauncherModelInterface
29class MockLauncherModel: public LauncherModelInterface
30{
30{
31− Q_OBJECT
31+ Q_OBJECT
32
32
33public:
33public:
34 MockLauncherModel(QObject* parent = 0);
34 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
39 return index.row() == 1 ? false : true;
39 return index.row() == 1 ? false : true;
40 case RoleHasSeparator:
40 case RoleHasSeparator:
41 return index.row() <= 1 ? true : false;
41 return index.row() <= 1 ? true : false;
42+ case RoleIsPrivate:
43+ return index.row() == 4 ? true : false;
42 }
44 }
43 return QVariant();
45 return QVariant();
44}
46}
@@ -46,5 +48,5 @@ QVariant MockQuickListModel::data(const QModelIndex &index, int role) const
46int MockQuickListModel::rowCount(const QModelIndex &parent) const
48int MockQuickListModel::rowCount(const QModelIndex &parent) const
47{
49{
48 Q_UNUSED(parent)
50 Q_UNUSED(parent)
49− return 4;
51+ return 5;
50}
52}
tests/mocks/Unity/Launcher/MockQuickListModel.h+2
@@ -27,6 +27,8 @@ using namespace unity::shell::launcher;
27class MockQuickListModel: public QuickListModelInterface
27class MockQuickListModel: public QuickListModelInterface
28{
28{
29 Q_OBJECT
29 Q_OBJECT
30+ Q_PROPERTY(int count READ rowCount)
31+
30public:
32public:
31 MockQuickListModel(QObject *parent = 0);
33 MockQuickListModel(QObject *parent = 0);
32
34
tests/qmltests/Launcher/tst_Launcher.qml+42
@@ -95,6 +95,11 @@ Rectangle {
95 property: "lockedVisible"
95 property: "lockedVisible"
96 value: lockedVisibleCheckBox.checked
96 value: lockedVisibleCheckBox.checked
97 }
97 }
98+ Binding {
99+ target: launcherLoader.item
100+ property: "privateMode"
101+ value: privateModeCheckBox.checked
102+ }
98 Binding {
103 Binding {
99 target: launcherLoader.item
104 target: launcherLoader.item
100 property: "panelWidth"
105 property: "panelWidth"
@@ -120,6 +125,20 @@ Rectangle {
120 }
125 }
121 }
126 }
122
127
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+
123 Slider {
142 Slider {
124 id: widthSlider
143 id: widthSlider
125 Layout.fillWidth: true
144 Layout.fillWidth: true
@@ -1493,6 +1512,29 @@ Rectangle {
1493 compare(launcher.state, "visibleTemporary");
1512 compare(launcher.state, "visibleTemporary");
1494 }
1513 }
1495
1514
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+
1496 function test_hintOnSizeChange() {
1538 function test_hintOnSizeChange() {
1497 var oldSize = launcher.panelWidth;
1539 var oldSize = launcher.panelWidth;
1498 launcher.maxPanelX = -launcher.panelWidth;
1540 launcher.maxPanelX = -launcher.panelWidth;