on xenial help sign in
Changes according to review
3e4697fAndrea Cimitan
qml/Dash/GenericScopeView.qml+14−13
@@ -439,7 +439,6 @@ FocusScope {
439 }
439 }
440
440
441 onBackClicked: scopeView.backClicked()
441 onBackClicked: scopeView.backClicked()
442−
443 onSettingsClicked: subPageLoader.openSubPage("settings")
442 onSettingsClicked: subPageLoader.openSubPage("settings")
444 }
443 }
445 }
444 }
@@ -480,24 +479,26 @@ FocusScope {
480 open = false;
479 open = false;
481 }
480 }
482
481
482+ source: switch(subPage) {
483− source: subPage && (subPage == "preview" ? "PreviewListView.qml" : "ScopeSettingsPage.qml") || ""
483+ case "preview": return "PreviewListView.qml";
484+ case "settings": return "ScopeSettingsPage.qml";
485+ default: return "";
486+ }
484
487
485 onLoaded: {
488 onLoaded: {
486− if (status === Loader.Ready) {
487− item.scope = Qt.binding(function() { return subPageLoader.scope } )
489+ item.scope = Qt.binding(function() { return subPageLoader.scope; } )
488− item.scopeStyle = Qt.binding(function() { return subPageLoader.scopeStyle } )
490+ item.scopeStyle = Qt.binding(function() { return subPageLoader.scopeStyle; } )
489− if (subPage == "preview") {
491+ if (subPage == "preview") {
490− item.open = Qt.binding(function() { return subPageLoader.open } )
492+ item.open = Qt.binding(function() { return subPageLoader.open; } )
491− item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex } )
493+ item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
492− item.model = Qt.binding(function() { return subPageLoader.model } )
494+ item.model = Qt.binding(function() { return subPageLoader.model; } )
493− }
494− open = true;
495 }
495 }
496+ open = true;
496 }
497 }
497
498
498− onOpenChanged: pageHeaderLoader.item.unfocus();
499+ onOpenChanged: pageHeaderLoader.item.unfocus()
499
500
500− onVisibleChanged: if (!visible) subPage = "";
501+ onVisibleChanged: if (!visible) subPage = ""
501
502
502 Connections {
503 Connections {
503 target: subPageLoader.item
504 target: subPageLoader.item
qml/Dash/PageHeader.qml+2−6
@@ -249,9 +249,7 @@ Item {
249 backAction: Action {
249 backAction: Action {
250 iconName: "back"
250 iconName: "back"
251 visible: root.showBackButton
251 visible: root.showBackButton
252− onTriggered: {
253− root.backClicked();
252+ onTriggered: root.backClicked()
254− }
255 }
253 }
256
254
257 actions: [
255 actions: [
@@ -268,9 +266,7 @@ Item {
268 objectName: "settings"
266 objectName: "settings"
269 iconName: "settings"
267 iconName: "settings"
270 visible: root.settingsEnabled
268 visible: root.settingsEnabled
271− onTriggered: {
272− root.settingsClicked()
269+ onTriggered: root.settingsClicked()
273− }
274 }
270 }
275 ]
271 ]
276 }
272 }
qml/Dash/ScopeSettings/ScopeSetting.qml+3−2
@@ -26,11 +26,12 @@ Item {
26 //! Variable used to contain widget's data
26 //! Variable used to contain widget's data
27 property var widgetData: null
27 property var widgetData: null
28
28
29− readonly property real __margins: units.gu(2)
30−
31 /*! \brief This signal should be emitted when a setting action was updated.
29 /*! \brief This signal should be emitted when a setting action was updated.
32 *
30 *
33 * \param value the new setting value.
31 * \param value the new setting value.
34 */
32 */
35 signal updated(var value)
33 signal updated(var value)
34+
35+ //! \internal
36+ readonly property real settingMargins: units.gu(2)
36}
37}
qml/Dash/ScopeSettings/ScopeSettingBoolean.qml+6−5
@@ -26,21 +26,22 @@ ScopeSetting {
26 id: listItem
26 id: listItem
27
27
28 onClicked: {
28 onClicked: {
29− control.checked = !control.checked
29+ control.checked = !control.checked;
30− updated(control.checked)
30+ updated(control.checked);
31 }
31 }
32
32
33 Label {
33 Label {
34 anchors {
34 anchors {
35 left: parent.left
35 left: parent.left
36− leftMargin: __margins
36+ leftMargin: settingMargins
37 right: control.left
37 right: control.left
38 rightMargin: units.gu(1)
38 rightMargin: units.gu(1)
39 verticalCenter: parent.verticalCenter
39 verticalCenter: parent.verticalCenter
40 }
40 }
41 text: widgetData.displayName
41 text: widgetData.displayName
42 elide: Text.ElideMiddle
42 elide: Text.ElideMiddle
43− maximumLineCount: 1
43+ maximumLineCount: 2
44+ wrapMode: Text.Wrap
44 color: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.baseText
45 color: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.baseText
45 }
46 }
46
47
@@ -49,7 +50,7 @@ ScopeSetting {
49 objectName: "control"
50 objectName: "control"
50 anchors {
51 anchors {
51 right: parent.right
52 right: parent.right
52− rightMargin: __margins
53+ rightMargin: settingMargins
53 verticalCenter: parent.verticalCenter
54 verticalCenter: parent.verticalCenter
54 }
55 }
55 checked: widgetData.value
56 checked: widgetData.value
qml/Dash/ScopeSettings/ScopeSettingList.qml+12−1
@@ -24,6 +24,8 @@ ScopeSetting {
24 // FIXME workaround for: https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1355830
24 // FIXME workaround for: https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1355830
25 height: listItem.currentlyExpanded ? listItem.itemHeight * widgetData.properties["values"].length + units.gu(6) : listItem.height
25 height: listItem.currentlyExpanded ? listItem.itemHeight * widgetData.properties["values"].length + units.gu(6) : listItem.height
26
26
27+ property int initialValue: -1
28+
27 ListItem.ItemSelector {
29 ListItem.ItemSelector {
28 id: listItem
30 id: listItem
29 objectName: "control"
31 objectName: "control"
@@ -34,6 +36,15 @@ ScopeSetting {
34 text: widgetData.displayName
36 text: widgetData.displayName
35 model: widgetData.properties["values"]
37 model: widgetData.properties["values"]
36
38
39+ onSelectedIndexChanged: {
40+ if (root.initialValue >= 0) {
41+ var tmpValue = root.initialValue;
42+ root.initialValue = -1;
43+ selectedIndex = tmpValue;
44+ return;
45+ }
46+
37− onSelectedIndexChanged: root.updated(selectedIndex)
47+ root.updated(selectedIndex)
48+ }
38 }
49 }
39}
50}
qml/Dash/ScopeSettings/ScopeSettingString.qml+4−3
@@ -35,14 +35,15 @@ ScopeSetting {
35 id: label
35 id: label
36 anchors {
36 anchors {
37 left: parent.left
37 left: parent.left
38− leftMargin: __margins
38+ leftMargin: settingMargins
39 right: control.left
39 right: control.left
40 rightMargin: units.gu(1)
40 rightMargin: units.gu(1)
41 verticalCenter: parent.verticalCenter
41 verticalCenter: parent.verticalCenter
42 }
42 }
43 text: widgetData.displayName
43 text: widgetData.displayName
44 elide: Text.ElideMiddle
44 elide: Text.ElideMiddle
45− maximumLineCount: 1
45+ maximumLineCount: 2
46+ wrapMode: Text.Wrap
46 color: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.baseText
47 color: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.baseText
47 }
48 }
48
49
@@ -51,7 +52,7 @@ ScopeSetting {
51 objectName: "control"
52 objectName: "control"
52 anchors {
53 anchors {
53 right: parent.right
54 right: parent.right
54− rightMargin: __margins
55+ rightMargin: settingMargins
55 verticalCenter: parent.verticalCenter
56 verticalCenter: parent.verticalCenter
56 }
57 }
57 width: root.mode == "number" ? units.gu(8) : units.gu(12)
58 width: root.mode == "number" ? units.gu(8) : units.gu(12)
qml/Dash/ScopeSettings/ScopeSettingsWidgetFactory.qml+3−2
@@ -45,8 +45,9 @@ Loader {
45 //! \endcond
45 //! \endcond
46
46
47 onLoaded: {
47 onLoaded: {
48+ if (item.hasOwnProperty("initialValue")) item.initialValue = root.widgetData.value;
48− item.widgetData = Qt.binding(function() { return root.widgetData } )
49+ item.widgetData = Qt.binding(function() { return root.widgetData; } )
49− item.scopeStyle = Qt.binding(function() { return root.scopeStyle } )
50+ item.scopeStyle = Qt.binding(function() { return root.scopeStyle; } )
50 }
51 }
51
52
52 Connections {
53 Connections {
qml/Dash/ScopeSettingsPage.qml+1−1
@@ -34,7 +34,7 @@ Item {
34 width: parent.width
34 width: parent.width
35 title: scope ? scope.name : ""
35 title: scope ? scope.name : ""
36 showBackButton: true
36 showBackButton: true
37− scopeStyle: root.scopeStyle || undefined
37+ scopeStyle: root.scopeStyle
38
38
39 onBackClicked: root.backClicked()
39 onBackClicked: root.backClicked()
40 }
40 }
tests/mocks/Unity/fake_settingsmodel.cpp+1−2
@@ -69,8 +69,7 @@ QVariant SettingsModel::data(const QModelIndex& index, int role) const {
69 return result;
69 return result;
70}
70}
71
71
72−bool SettingsModel::setData(const QModelIndex &index, const QVariant &value,
72+bool SettingsModel::setData(const QModelIndex &index, const QVariant &value, int role) {
73− int role) {
74 int row = index.row();
73 int row = index.row();
75 if (row < m_data.size()) {
74 if (row < m_data.size()) {
76 switch (role) {
75 switch (role) {
tests/mocks/Unity/fake_unity_plugin.cpp+1−1
@@ -44,7 +44,7 @@ void FakeUnityPlugin::registerTypes(const char *uri)
44 qmlRegisterType<Scopes>(uri, 0, 2, "Scopes");
44 qmlRegisterType<Scopes>(uri, 0, 2, "Scopes");
45 qmlRegisterType<Scope>(uri, 0, 2, "MockScope");
45 qmlRegisterType<Scope>(uri, 0, 2, "MockScope");
46 qmlRegisterUncreatableType<unity::shell::scopes::ScopeInterface>(uri, 0, 2, "Scope", "Can't create Scope object in QML.");
46 qmlRegisterUncreatableType<unity::shell::scopes::ScopeInterface>(uri, 0, 2, "Scope", "Can't create Scope object in QML.");
47− qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "Scope", "Can't create SettingsModel object in QML.");
47+ qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "SettingsModel", "Can't create SettingsModel object in QML.");
48 qmlRegisterUncreatableType<unity::shell::scopes::NavigationInterface>(uri, 0, 2, "Navigation", "Can't create Navigation object in QML.");
48 qmlRegisterUncreatableType<unity::shell::scopes::NavigationInterface>(uri, 0, 2, "Navigation", "Can't create Navigation object in QML.");
49 qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
49 qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
50 qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from PreviewStack instance.");
50 qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from PreviewStack instance.");
tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml+1−1
@@ -93,7 +93,7 @@ Rectangle {
93 factory.widgetData = { type: data.type };
93 factory.widgetData = { type: data.type };
94 factory.widgetType = data.type;
94 factory.widgetType = data.type;
95
95
96− verify(("" + factory.source).indexOf(data.source) != -1);
96+ verify((String() + factory.source).indexOf(data.source) != -1);
97 }
97 }
98 }
98 }
99}
99}
tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingBoolean.qml+1−1
@@ -44,7 +44,7 @@ Rectangle {
44
44
45 UT.UnityTestCase {
45 UT.UnityTestCase {
46 id: testCase
46 id: testCase
47− name: "ScopeSettingBooleanTest"
47+ name: "ScopeSettingBoolean"
48 when: windowShown
48 when: windowShown
49
49
50 function test_updated() {
50 function test_updated() {
tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingList.qml+2−2
@@ -44,12 +44,12 @@ Rectangle {
44
44
45 UT.UnityTestCase {
45 UT.UnityTestCase {
46 id: testCase
46 id: testCase
47− name: "ScopeSettingListTest"
47+ name: "ScopeSettingList"
48 when: windowShown
48 when: windowShown
49
49
50 property var control: findChild(scopeSetting, "control")
50 property var control: findChild(scopeSetting, "control")
51
51
52− function init() {
52+ function cleanup() {
53 control.selectedIndex = 0;
53 control.selectedIndex = 0;
54 spy.clear();
54 spy.clear();
55 }
55 }
tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingNumber.qml+3−3
@@ -44,13 +44,13 @@ Rectangle {
44
44
45 UT.UnityTestCase {
45 UT.UnityTestCase {
46 id: testCase
46 id: testCase
47− name: "ScopeSettingNumberTest"
47+ name: "ScopeSettingNumber"
48 when: windowShown
48 when: windowShown
49
49
50 property var control: findChild(scopeSetting, "control")
50 property var control: findChild(scopeSetting, "control")
51 property real newNumber: 11.7
51 property real newNumber: 11.7
52
52
53− function init() {
53+ function cleanup() {
54 control.focus = false;
54 control.focus = false;
55 control.text = settingData.value;
55 control.text = settingData.value;
56 spy.clear();
56 spy.clear();
@@ -85,7 +85,7 @@ Rectangle {
85 verify(control.displayText == newNumber);
85 verify(control.displayText == newNumber);
86 }
86 }
87
87
88− function test_unacceptableInput() {
88+ function test_unacceptable_input() {
89 mouseClick(control, control.width / 2, control.height / 2);
89 mouseClick(control, control.width / 2, control.height / 2);
90 control.selectAll();
90 control.selectAll();
91 control.cut();
91 control.cut();
tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingString.qml+2−2
@@ -44,13 +44,13 @@ Rectangle {
44
44
45 UT.UnityTestCase {
45 UT.UnityTestCase {
46 id: testCase
46 id: testCase
47− name: "ScopeSettingStringTest"
47+ name: "ScopeSettingString"
48 when: windowShown
48 when: windowShown
49
49
50 property var control: findChild(scopeSetting, "control")
50 property var control: findChild(scopeSetting, "control")
51 property string newText: "new text to compare"
51 property string newText: "new text to compare"
52
52
53− function init() {
53+ function cleanup() {
54 control.focus = false;
54 control.focus = false;
55 control.text = settingData.value;
55 control.text = settingData.value;
56 spy.clear();
56 spy.clear();
tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingsWidgetFactory.qml+2−2
@@ -42,7 +42,7 @@ Rectangle {
42
42
43 UT.UnityTestCase {
43 UT.UnityTestCase {
44 id: testCase
44 id: testCase
45− name: "ScopeSettingWidgetFactoryTest"
45+ name: "ScopeSettingWidgetFactory"
46 when: windowShown
46 when: windowShown
47
47
48 function test_mapping_data() {
48 function test_mapping_data() {
@@ -59,7 +59,7 @@ Rectangle {
59 newSettingData.type = data.type;
59 newSettingData.type = data.type;
60 scopeSettingsWidgetFactory.widgetData = newSettingData;
60 scopeSettingsWidgetFactory.widgetData = newSettingData;
61
61
62− verify(("" + scopeSettingsWidgetFactory.source).indexOf(data.source) != -1);
62+ verify((String() + scopeSettingsWidgetFactory.source).indexOf(data.source) != -1);
63 }
63 }
64 }
64 }
65}
65}
tests/qmltests/Dash/tst_GenericScopeView.qml+2−1
@@ -377,7 +377,7 @@ Item {
377 var settings = findChild(innerHeader, "settings_header_button");
377 var settings = findChild(innerHeader, "settings_header_button");
378 mouseClick(settings, settings.width / 2, settings.height / 2);
378 mouseClick(settings, settings.width / 2, settings.height / 2);
379 tryCompare(testCase.subPageLoader, "open", true);
379 tryCompare(testCase.subPageLoader, "open", true);
380− tryCompareFunction(function() { return ("" + subPageLoader.source).indexOf("ScopeSettingsPage.qml") != -1; }, true);
380+ tryCompareFunction(function() { return (String() + subPageLoader.source).indexOf("ScopeSettingsPage.qml") != -1; }, true);
381 tryCompare(genericScopeView, "subPageShown", true);
381 tryCompare(genericScopeView, "subPageShown", true);
382 compare(testCase.subPageLoader.subPage, "settings");
382 compare(testCase.subPageLoader.subPage, "settings");
383 tryCompare(testCase.subPageLoader, "x", 0);
383 tryCompare(testCase.subPageLoader, "x", 0);
@@ -390,6 +390,7 @@ Item {
390 var categoryListView = findChild(genericScopeView, "categoryListView");
390 var categoryListView = findChild(genericScopeView, "categoryListView");
391 tryCompare(categoryListView, "x", 0);
391 tryCompare(categoryListView, "x", 0);
392 tryCompare(testCase.subPageLoader, "visible", false);
392 tryCompare(testCase.subPageLoader, "visible", false);
393+ tryCompare(testCase.subPageLoader, "source", "");
393 }
394 }
394
395
395 function test_header_style_data() {
396 function test_header_style_data() {