on xenial help sign in
indicator title moved to root action state
09cdf79Nick Dedekind
Panel/Indicators/DefaultIndicatorWidget2.qml+6−6
@@ -86,8 +86,8 @@ Indicators.IndicatorWidget {
86 }
86 }
87 }
87 }
88
88
89− onActionStateChanged: {
89+ onRootActionStateChanged: {
90− if (actionState == undefined) {
90+ if (rootActionState == undefined) {
91 leftLabel = "";
91 leftLabel = "";
92 rightLabel = "";
92 rightLabel = "";
93 icons = undefined;
93 icons = undefined;
@@ -95,9 +95,9 @@ Indicators.IndicatorWidget {
95 return;
95 return;
96 }
96 }
97
97
98− leftLabel = actionState.leftLabel ? actionState.leftLabel : "";
98+ leftLabel = rootActionState.leftLabel ? rootActionState.leftLabel : "";
99− rightLabel = actionState.rightLabel ? actionState.rightLabel : "";
99+ rightLabel = rootActionState.rightLabel ? rootActionState.rightLabel : "";
100− icons = actionState.icons;
100+ icons = rootActionState.icons;
101− enabled = actionState.visible;
101+ enabled = rootActionState.visible;
102 }
102 }
103}
103}
Panel/MenuContent.qml+7−1
@@ -100,10 +100,10 @@ MainView {
100 Tab {
100 Tab {
101 id: tab
101 id: tab
102 objectName: model.identifier
102 objectName: model.identifier
103− title: model.title
104
103
105 page: Page {
104 page: Page {
106 Loader {
105 Loader {
106+ id: loader
107 clip: true
107 clip: true
108 anchors.fill: parent
108 anchors.fill: parent
109 source: pageSource
109 source: pageSource
@@ -136,6 +136,12 @@ MainView {
136 item.start()
136 item.start()
137 }
137 }
138 }
138 }
139+
140+ Binding {
141+ target: tab
142+ property: "title"
143+ value: loader.item && loader.item.hasOwnProperty("title") && loader.item.title !== "" ? loader.item.title : model.identifier
144+ }
139 }
145 }
140 }
146 }
141 }
147 }
plugins/Unity/Indicators/indicators.h−2
@@ -74,8 +74,6 @@ public:
74 enum Roles {
74 enum Roles {
75 Identifier = 0,
75 Identifier = 0,
76 Position,
76 Position,
77− Title,
78− Description,
79 WidgetSource,
77 WidgetSource,
80 PageSource,
78 PageSource,
81 IndicatorProperties,
79 IndicatorProperties,
plugins/Unity/Indicators/indicatorsmodel.cpp−8
@@ -201,8 +201,6 @@ QHash<int, QByteArray> IndicatorsModel::roleNames() const
201 {
201 {
202 roles[IndicatorsModelRole::Identifier] = "identifier";
202 roles[IndicatorsModelRole::Identifier] = "identifier";
203 roles[IndicatorsModelRole::Position] = "position";
203 roles[IndicatorsModelRole::Position] = "position";
204− roles[IndicatorsModelRole::Title] = "title";
205− roles[IndicatorsModelRole::Description] = "description";
206 roles[IndicatorsModelRole::WidgetSource] = "widgetSource";
204 roles[IndicatorsModelRole::WidgetSource] = "widgetSource";
207 roles[IndicatorsModelRole::PageSource] = "pageSource";
205 roles[IndicatorsModelRole::PageSource] = "pageSource";
208 roles[IndicatorsModelRole::IndicatorProperties] = "indicatorProperties";
206 roles[IndicatorsModelRole::IndicatorProperties] = "indicatorProperties";
@@ -223,10 +221,6 @@ QVariant IndicatorsModel::defaultData(Indicator::Ptr indicator, int role)
223 {
221 {
224 case IndicatorsModelRole::Position:
222 case IndicatorsModelRole::Position:
225 return 0;
223 return 0;
226− case IndicatorsModelRole::Title:
227− return indicator ? indicator->identifier() : "Unknown";
228− case IndicatorsModelRole::Description:
229− return "";
230 case IndicatorsModelRole::WidgetSource:
224 case IndicatorsModelRole::WidgetSource:
231 return shellAppDirectory()+"/Panel/Indicators/DefaultIndicatorWidget2.qml";
225 return shellAppDirectory()+"/Panel/Indicators/DefaultIndicatorWidget2.qml";
232 case IndicatorsModelRole::PageSource:
226 case IndicatorsModelRole::PageSource:
@@ -268,8 +262,6 @@ QVariant IndicatorsModel::data(const QModelIndex &index, int role) const
268 return QVariant(indicator->indicatorProperties());
262 return QVariant(indicator->indicatorProperties());
269 }
263 }
270 break;
264 break;
271− case IndicatorsModelRole::Title:
272− case IndicatorsModelRole::Description:
273 case IndicatorsModelRole::WidgetSource:
265 case IndicatorsModelRole::WidgetSource:
274 case IndicatorsModelRole::PageSource:
266 case IndicatorsModelRole::PageSource:
275 return indicatorData(indicator, role);
267 return indicatorData(indicator, role);
plugins/Unity/Indicators/qml/IndicatorBase.qml+5−1
@@ -27,7 +27,6 @@ Item {
27 enabled: menuObjectPaths.hasOwnProperty(device)
27 enabled: menuObjectPaths.hasOwnProperty(device)
28
28
29 //const
29 //const
30− property string title
31 property string busName
30 property string busName
32 property string actionsObjectPath
31 property string actionsObjectPath
33 property var menuObjectPaths: undefined
32 property var menuObjectPaths: undefined
@@ -45,4 +44,9 @@ Item {
45 actionsObjectPath: active ? indicatorItem.actionsObjectPath : ""
44 actionsObjectPath: active ? indicatorItem.actionsObjectPath : ""
46 menuObjectPath: active ? indicatorItem.deviceMenuObjectPath : ""
45 menuObjectPath: active ? indicatorItem.deviceMenuObjectPath : ""
47 }
46 }
47+
48+ property var rootActionState: Indicators.RootActionState {
49+ menu: menuModel
50+ onUpdated: indicatorItem.rootActionStateChanged()
51+ }
48}
52}
plugins/Unity/Indicators/qml/IndicatorPage.qml+1
@@ -26,6 +26,7 @@ IndicatorBase {
26 id: main
26 id: main
27
27
28 //const
28 //const
29+ property string title: rootActionState.title
29 property alias emptyText: emptyLabel.text
30 property alias emptyText: emptyLabel.text
30 property alias highlightFollowsCurrentItem : mainMenu.highlightFollowsCurrentItem
31 property alias highlightFollowsCurrentItem : mainMenu.highlightFollowsCurrentItem
31
32
plugins/Unity/Indicators/qml/IndicatorWidget.qml−5
@@ -26,9 +26,4 @@ IndicatorBase {
26 active: true
26 active: true
27 enabled: false
27 enabled: false
28 property int iconSize: height - units.gu(0.5)
28 property int iconSize: height - units.gu(0.5)
29−
30− property var actionState: Indicators.RootActionState {
31− menu: menuModel
32− onUpdated: indicatorWidget.actionStateChanged()
33− }
34}
29}
plugins/Unity/Indicators/rootactionstate.cpp+7−1
@@ -102,12 +102,18 @@ void RootActionState::updateActionState()
102 Q_EMIT updated();
102 Q_EMIT updated();
103}
103}
104
104
105−
106bool RootActionState::isValid() const
105bool RootActionState::isValid() const
107{
106{
108 return m_menu && m_menu->rowCount() > 0;
107 return m_menu && m_menu->rowCount() > 0;
109}
108}
110
109
110+QString RootActionState::title() const
111+{
112+ if (!isValid()) return QString();
113+
114+ return m_cachedState.value("title", QVariant::fromValue(QString())).toString();
115+}
116+
111QString RootActionState::leftLabel() const
117QString RootActionState::leftLabel() const
112{
118{
113 if (!isValid()) return QString();
119 if (!isValid()) return QString();
plugins/Unity/Indicators/rootactionstate.h+3
@@ -32,6 +32,7 @@ class UNITYINDICATORS_EXPORT RootActionState : public ActionStateParser
32 Q_PROPERTY(UnityMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged)
32 Q_PROPERTY(UnityMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged)
33
33
34 Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
34 Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
35+ Q_PROPERTY(QString title READ title NOTIFY titleChanged)
35 Q_PROPERTY(QString leftLabel READ leftLabel NOTIFY leftLabelChanged)
36 Q_PROPERTY(QString leftLabel READ leftLabel NOTIFY leftLabelChanged)
36 Q_PROPERTY(QString rightLabel READ rightLabel NOTIFY rightLabelChanged)
37 Q_PROPERTY(QString rightLabel READ rightLabel NOTIFY rightLabelChanged)
37 Q_PROPERTY(QStringList icons READ icons NOTIFY iconsChanged)
38 Q_PROPERTY(QStringList icons READ icons NOTIFY iconsChanged)
@@ -48,6 +49,7 @@ public:
48 void setIndex(int index);
49 void setIndex(int index);
49
50
50 bool isValid() const;
51 bool isValid() const;
52+ QString title() const;
51 QString leftLabel() const;
53 QString leftLabel() const;
52 QString rightLabel() const;
54 QString rightLabel() const;
53 QStringList icons() const;
55 QStringList icons() const;
@@ -64,6 +66,7 @@ Q_SIGNALS:
64 void indexChanged();
66 void indexChanged();
65
67
66 void validChanged();
68 void validChanged();
69+ void titleChanged();
67 void leftLabelChanged();
70 void leftLabelChanged();
68 void rightLabelChanged();
71 void rightLabelChanged();
69 void iconsChanged();
72 void iconsChanged();
plugins/Unity/Indicators/visibleindicatorsmodel.cpp−2
@@ -33,8 +33,6 @@ QHash<int, QByteArray> VisibleIndicatorsModel::roleNames() const
33 {
33 {
34 roles[IndicatorsModelRole::Identifier] = "identifier";
34 roles[IndicatorsModelRole::Identifier] = "identifier";
35 roles[IndicatorsModelRole::Position] = "position";
35 roles[IndicatorsModelRole::Position] = "position";
36− roles[IndicatorsModelRole::Title] = "title";
37− roles[IndicatorsModelRole::Description] = "description";
38 roles[IndicatorsModelRole::WidgetSource] = "widgetSource";
36 roles[IndicatorsModelRole::WidgetSource] = "widgetSource";
39 roles[IndicatorsModelRole::PageSource] = "pageSource";
37 roles[IndicatorsModelRole::PageSource] = "pageSource";
40 roles[IndicatorsModelRole::IndicatorProperties] = "indicatorProperties";
38 roles[IndicatorsModelRole::IndicatorProperties] = "indicatorProperties";
tests/mocks/Unity/Indicators/IndicatorsModel.qml+5−15
@@ -28,45 +28,35 @@ ListModel {
28 // which throws off the filter for non-visible indicators.
28 // which throws off the filter for non-visible indicators.
29 Component.onCompleted: {
29 Component.onCompleted: {
30 append({ "identifier": "indicator-fake1",
30 append({ "identifier": "indicator-fake1",
31− "priority": 0,
31+ "position": 0,
32− "title": "Menu1",
33− "description": "",
34 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget1.qml",
32 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget1.qml",
35 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page1.qml",
33 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page1.qml",
36 "indicatorProperties": ""
34 "indicatorProperties": ""
37 });
35 });
38
36
39 append({ "identifier": "indicator-fake2",
37 append({ "identifier": "indicator-fake2",
40− "priority": 1,
38+ "position": 1,
41− "title": "Menu2",
42− "description": "",
43 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget2.qml",
39 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget2.qml",
44 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page2.qml",
40 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page2.qml",
45 "indicatorProperties": ""
41 "indicatorProperties": ""
46 });
42 });
47
43
48 append({ "identifier": "indicator-fake3",
44 append({ "identifier": "indicator-fake3",
49− "priority": 2,
45+ "position": 2,
50− "title": "Menu3",
51− "description": "",
52 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget3.qml",
46 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget3.qml",
53 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page3.qml",
47 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page3.qml",
54 "indicatorProperties": ""
48 "indicatorProperties": ""
55 });
49 });
56
50
57 append({ "identifier": "indicator-fake4",
51 append({ "identifier": "indicator-fake4",
58− "priority": 3,
52+ "position": 3,
59− "title": "Menu4",
60− "description": "",
61 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget4.qml",
53 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget4.qml",
62 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page4.qml",
54 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page4.qml",
63 "indicatorProperties": ""
55 "indicatorProperties": ""
64 });
56 });
65
57
66 append({ "identifier": "indicator-fake5",
58 append({ "identifier": "indicator-fake5",
67− "priority": 4,
59+ "position": 4,
68− "title": "Menu5",
69− "description": "",
70 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget5.qml",
60 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget5.qml",
71 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page5.qml",
61 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page5.qml",
72 "indicatorProperties": ""
62 "indicatorProperties": ""
tests/plugins/Unity/Indicators/indicatorsmodeltest.cpp+7−9
@@ -66,14 +66,12 @@ private Q_SLOTS:
66 {
66 {
67 // Priority order. (2, 1, 4, 3)
67 // Priority order. (2, 1, 4, 3)
68 QVariantMap map;
68 QVariantMap map;
69− QVariantMap map1; map1["title"] = "fake1";
69+ QVariantMap map1; map1["widgetSource"] = "fake1.qml";
70− QVariantMap map2; map2["title"] = "fake2";
70+ QVariantMap map2; map2["widgetSource"] = "fake2.qml";
71− QVariantMap map3; map3["title"] = "fake3";
71+ QVariantMap map3; map3["widgetSource"] = "fake3.qml";
72− QVariantMap map4; map4["title"] = "fake4";
73 map["indicator-fake1"] = map1;
72 map["indicator-fake1"] = map1;
74 map["indicator-fake2"] = map2;
73 map["indicator-fake2"] = map2;
75 map["indicator-fake3"] = map3;
74 map["indicator-fake3"] = map3;
76− map["indicator-fake4"] = map4;
77
75
78 IndicatorsModel model;
76 IndicatorsModel model;
79 model.setIndicatorData(map);
77 model.setIndicatorData(map);
@@ -83,24 +81,24 @@ private Q_SLOTS:
83 // fake3, fake4, fake1, fake2
81 // fake3, fake4, fake1, fake2
84
82
85 QCOMPARE(model.data(0, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake3"));
83 QCOMPARE(model.data(0, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake3"));
86− QCOMPARE(model.data(0, IndicatorsModelRole::Title).toString(), QString("fake3"));
87 QCOMPARE(model.data(0, IndicatorsModelRole::Position).toInt(), 3);
84 QCOMPARE(model.data(0, IndicatorsModelRole::Position).toInt(), 3);
88 QCOMPARE(model.data(0, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake3"));
85 QCOMPARE(model.data(0, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake3"));
86+ QCOMPARE(model.data(0, IndicatorsModelRole::WidgetSource).toString(), QString("fake3.qml"));
89
87
90 QCOMPARE(model.data(1, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake4"));
88 QCOMPARE(model.data(1, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake4"));
91− QCOMPARE(model.data(1, IndicatorsModelRole::Title).toString(), QString("fake4"));
92 QCOMPARE(model.data(1, IndicatorsModelRole::Position).toInt(), 2);
89 QCOMPARE(model.data(1, IndicatorsModelRole::Position).toInt(), 2);
93 QCOMPARE(model.data(1, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake4"));
90 QCOMPARE(model.data(1, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake4"));
91+ QCOMPARE(model.data(1, IndicatorsModelRole::WidgetSource).toString(), shellAppDirectory()+"/Panel/Indicators/DefaultIndicatorWidget2.qml");
94
92
95 QCOMPARE(model.data(2, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake1"));
93 QCOMPARE(model.data(2, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake1"));
96− QCOMPARE(model.data(2, IndicatorsModelRole::Title).toString(), QString("fake1"));
97 QCOMPARE(model.data(2, IndicatorsModelRole::Position).toInt(), 1);
94 QCOMPARE(model.data(2, IndicatorsModelRole::Position).toInt(), 1);
98 QCOMPARE(model.data(2, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake1"));
95 QCOMPARE(model.data(2, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake1"));
96+ QCOMPARE(model.data(2, IndicatorsModelRole::WidgetSource).toString(), QString("fake1.qml"));
99
97
100 QCOMPARE(model.data(3, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake2"));
98 QCOMPARE(model.data(3, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake2"));
101− QCOMPARE(model.data(3, IndicatorsModelRole::Title).toString(), QString("fake2"));
102 QCOMPARE(model.data(3, IndicatorsModelRole::Position).toInt(), 0);
99 QCOMPARE(model.data(3, IndicatorsModelRole::Position).toInt(), 0);
103 QCOMPARE(model.data(3, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake2"));
100 QCOMPARE(model.data(3, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake2"));
101+ QCOMPARE(model.data(3, IndicatorsModelRole::WidgetSource).toString(), QString("fake2.qml"));
104 }
102 }
105};
103};
106
104
tests/qmltests/Panel/tst_IndicatorRow.qml+3−3
@@ -62,13 +62,13 @@ Item {
62 function test_set_current_item() {
62 function test_set_current_item() {
63 init_test();
63 init_test();
64 indicatorRow.setCurrentItem(0);
64 indicatorRow.setCurrentItem(0);
65− compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).title, "Menu1", "Incorrect item at position 0");
65+ compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake1", "Incorrect item at position 0");
66
66
67 indicatorRow.setCurrentItem(1);
67 indicatorRow.setCurrentItem(1);
68− compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).title, "Menu2", "Incorrect item at position 1");
68+ compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake2", "Incorrect item at position 1");
69
69
70 indicatorRow.setCurrentItem(2);
70 indicatorRow.setCurrentItem(2);
71− compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).title, "Menu3", "Incorrect item at position 2");
71+ compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake3", "Incorrect item at position 2");
72 }
72 }
73 }
73 }
74
74