@@ -19,6 +19,7 @@
20import QtQuick 2.0
20import QtQuick 2.0
21import Ubuntu.Settings.Menus 0.1 as Menus
21import Ubuntu.Settings.Menus 0.1 as Menus
22+import Ubuntu.Settings.Components 0.1
22import QMenuModel 0.1
23import QMenuModel 0.1
23import Utils 0.1 as Utils
24import Utils 0.1 as Utils
24import Ubuntu.Components.ListItems 0.1 as ListItems
25import Ubuntu.Components.ListItems 0.1 as ListItems
@@ -84,6 +85,7 @@ Item {
84 id: sliderMenu;
85 id: sliderMenu;
86 Menus.SliderMenu {
87 Menus.SliderMenu {
87 objectName: "sliderMenu"
89 objectName: "sliderMenu"
88 property QtObject menuData: null
90 property QtObject menuData: null
89 property var menuModel: menuFactory.menuModel
91 property var menuModel: menuFactory.menuModel
@@ -113,14 +115,8 @@ Item {
113 onMenuIndexChanged: {
115 onMenuIndexChanged: {
114 loadAttributes();
116 loadAttributes();
116− onServerValueChanged: {
117− // value can be changed by slider, so a binding won't work.
118− if (serverValue !== undefined) {
119− value = serverValue;
122 onUpdated: {
118 onUpdated: {
123− menuModel.changeState(menuIndex, value);
119+ sliderMenuSync.activate()
126 function loadAttributes() {
122 function loadAttributes() {
@@ -130,6 +126,23 @@ Item {
130 'min-icon': 'icon',
126 'min-icon': 'icon',
131 'max-icon': 'icon'});
127 'max-icon': 'icon'});
130+ ServerActivationSync {
133+ syncTimeout: Utils.Constants.indicatorValueTimeout
134+ bufferedSyncTimeout: true
136+ userTarget: sliderItem
137+ userProperty: "value"
139+ serverTarget: sliderItem
140+ serverProperty: "serverValue"
143+ menuModel.changeState(menuIndex, value);
@@ -280,6 +293,7 @@ Item {
280 id: checkableMenu;
293 id: checkableMenu;
282 Menus.CheckableMenu {
295 Menus.CheckableMenu {
283 objectName: "checkableMenu"
297 objectName: "checkableMenu"
284 property QtObject menuData: null
298 property QtObject menuData: null
285 property int menuIndex: -1
299 property int menuIndex: -1
@@ -290,26 +304,23 @@ Item {
290 checked: serverChecked
304 checked: serverChecked
291 highlightWhenPressed: false
305 highlightWhenPressed: false
293− onServerCheckedChanged: updateFromServer()
294− onTriggered: {
307+ onTriggered: checkMenuSync.activate()
295− menuModel.activate(menuIndex);
296− resyncTimer.restart();
299− // value can be changed by menu, so a binding won't work.
309+ ServerActivationSync {
300− function updateFromServer() {
310+ id: checkMenuSync
301− resyncTimer.stop();
311+ objectName: "sync"
302− if (checked != serverChecked) {
312+
303− checked = serverChecked;
313+ syncTimeout: Utils.Constants.indicatorValueTimeout
307− // Server value is not guaranteed to change to what we expect from an activation.
315+ userTarget: checkItem
308− // In this case, we need to re-assert that we are presenting the UI with the set backend value.
316+ userProperty: "checked"
310− id: resyncTimer
318+ serverTarget: checkItem
311− interval: 1500
319+ serverProperty: "serverChecked"
312− onTriggered: updateFromServer()
320+
322+ menuModel.activate(checkItem.menuIndex);
@@ -318,9 +329,11 @@ Item {
318 id: switchMenu;
329 id: switchMenu;
320 Menus.SwitchMenu {
331 Menus.SwitchMenu {
321 objectName: "switchMenu"
333 objectName: "switchMenu"
322 property QtObject menuData: null
334 property QtObject menuData: null
323 property int menuIndex: -1
335 property int menuIndex: -1
324 property bool serverChecked: menuData && menuData.isToggled || false
337 property bool serverChecked: menuData && menuData.isToggled || false
326 text: menuData && menuData.label || ""
339 text: menuData && menuData.label || ""
@@ -329,26 +342,23 @@ Item {
329 checked: serverChecked
342 checked: serverChecked
330 highlightWhenPressed: false
343 highlightWhenPressed: false
332− onServerCheckedChanged: updateFromServer()
333− onTriggered: {
345+ onTriggered: switchMenuSync.activate()
334− menuModel.activate(menuIndex);
335− resyncTimer.restart();
338− // value can be changed by menu, so a binding won't work.
347+ ServerActivationSync {
339− function updateFromServer() {
348+ id: switchMenuSync
340− resyncTimer.stop();
349+ objectName: "sync"
341− if (checked != serverChecked) {
342− checked = serverChecked;
346− // Server value is not guaranteed to change to what we expect from an activation.
351+ syncTimeout: Utils.Constants.indicatorValueTimeout
347− // In this case, we need to re-assert that we are presenting the UI with the set backend value.
352+
348− Timer {
353+ userTarget: switchItem
349− id: resyncTimer
354+ userProperty: "checked"
351− onTriggered: updateFromServer()
356+ serverTarget: switchItem
357+ serverProperty: "serverChecked"
360+ menuModel.activate(switchItem.menuIndex);
@@ -464,6 +474,7 @@ Item {
464 id: accessPoint;
474 id: accessPoint;
466 Menus.AccessPointMenu {
476 Menus.AccessPointMenu {
467 objectName: "accessPoint"
478 objectName: "accessPoint"
468 property QtObject menuData: null
479 property QtObject menuData: null
469 property var menuModel: menuFactory.menuModel
480 property var menuModel: menuFactory.menuModel
@@ -485,10 +496,6 @@ Item {
485 signalStrength: strengthAction.valid ? strengthAction.state : 0
496 signalStrength: strengthAction.valid ? strengthAction.state : 0
486 highlightWhenPressed: false
497 highlightWhenPressed: false
488− onServerCheckedChanged: {
489− // value can be changed by menu, so a binding won't work.
490− active = serverChecked;
492 onMenuModelChanged: {
499 onMenuModelChanged: {
493 loadAttributes();
500 loadAttributes();
@@ -496,7 +503,7 @@ Item {
496 loadAttributes();
503 loadAttributes();
498 onTriggered: {
505 onTriggered: {
499− menuModel.activate(menuIndex);
506+ apMenuSync.activate();
502 function loadAttributes() {
509 function loadAttributes() {
@@ -505,6 +512,22 @@ Item {
505 'x-canonical-wifi-ap-is-secure': 'bool',
512 'x-canonical-wifi-ap-is-secure': 'bool',
506 'x-canonical-wifi-ap-strength-action': 'string'});
513 'x-canonical-wifi-ap-strength-action': 'string'});
516+ ServerActivationSync {
519+ syncTimeout: Utils.Constants.indicatorValueTimeout
522+ userProperty: "active"
524+ serverTarget: apItem
525+ serverProperty: "serverChecked"
528+ menuModel.activate(apItem.menuIndex);