on xenial help sign in
Fixed currentIndex indicator removal causing misalignment
ea717a0Nick Dedekind
qml/Panel/IndicatorRow.qml+51−29
@@ -26,7 +26,7 @@ Item {
26 readonly property int currentItemIndex: currentItem ? currentItem.ownIndex : -1
26 readonly property int currentItemIndex: currentItem ? currentItem.ownIndex : -1
27 property alias row: row
27 property alias row: row
28 property QtObject indicatorsModel: null
28 property QtObject indicatorsModel: null
29− property var visibleIndicators: defined
29+ property var visibleIndicators: undefined
30 property int overFlowWidth: width
30 property int overFlowWidth: width
31 property bool showAll: false
31 property bool showAll: false
32 property real currentItemOffset: 0.0
32 property real currentItemOffset: 0.0
@@ -94,34 +94,56 @@ Item {
94 property real opacityMultiplier: highlighted ? 1 : (1 - indicatorRow.unitProgress)
94 property real opacityMultiplier: highlighted ? 1 : (1 - indicatorRow.unitProgress)
95
95
96 IndicatorItem {
96 IndicatorItem {
97− id: indicatorItem
97+ id: indicatorItem
98− identifier: model.identifier
98+ identifier: model.identifier
99− height: parent.height
99+ height: parent.height
100−
100+
101− dimmed: itemWrapper.dimmed
101+ dimmed: itemWrapper.dimmed
102−
102+
103− widgetSource: model.widgetSource
103+ widgetSource: model.widgetSource
104− indicatorProperties : model.indicatorProperties
104+ indicatorProperties : model.indicatorProperties
105−
105+
106− Component.onCompleted: {
106+ Component.onCompleted: {
107− if (visibleIndicators == undefined) {
107+ updateVisiblility();
108− visibleIndicators = {}
109− }
110− indicatorRow.visibleIndicators[model.identifier] = indicatorVisible;
111− indicatorRow.visibleIndicatorsChanged();
112− }
108+ }
113− onIndicatorVisibleChanged: {
109+ onIndicatorVisibleChanged: {
114− if (visibleIndicators == undefined) {
110+ updateVisiblility();
115− visibleIndicators = {}
111+
116− }
117− indicatorRow.visibleIndicators[model.identifier] = indicatorVisible;
118− indicatorRow.visibleIndicatorsChanged();
119−
120− if (indicatorVisible) {
112+ if (indicatorVisible) {
121− showAll = true;
113+ showAll = true;
122− allVisible.start();
114+ allVisible.start();
115+ }
116+ }
117+
118+ function updateVisiblility() {
119+ if (visibleIndicators == undefined) {
120+ visibleIndicators = {}
121+ }
122+ indicatorRow.visibleIndicators[model.identifier] = indicatorVisible;
123+
124+ // removed current index?
125+ if (indicatorRow.currentItemIndex === index && !indicatorVisible) {
126+ // find the next closest visible indicator (after current, else before)
127+ var newIndex = -1;
128+ for (var i = index+1; i < rowRepeater.count; i++) {
129+ if (indicatorRow.visibleIndicators[i] === undefined || indicatorRow.visibleIndicators[model.identifier]) {
130+ newIndex = i;
131+ break;
123− }
132+ }
133+ }
134+ if (newIndex === -1) {
135+ for (i = index - 1; i >= 0; i--) {
136+ if (indicatorRow.visibleIndicators[i] === undefined || indicatorRow.visibleIndicators[model.identifier]) {
137+ newIndex = i;
138+ break;
139+ }
140+ }
141+ }
142+ indicatorRow.setCurrentItem(newIndex);
143+ }
144+
145+ indicatorRow.visibleIndicatorsChanged();
124− }
146+ }
125 }
147 }
126
148
127 states: [
149 states: [
qml/Panel/Indicators.qml+13−3
@@ -193,7 +193,6 @@ Showable {
193 clip: !indicators.fullyOpened
193 clip: !indicators.fullyOpened
194 activeHeader: indicators.state == "hint" || indicators.state == "reveal"
194 activeHeader: indicators.state == "hint" || indicators.state == "reveal"
195 enabled: contentEnabled
195 enabled: contentEnabled
196− visibleIndicators: indicatorRow.visibleIndicators
197
196
198 //small shadow gradient at bottom of menu
197 //small shadow gradient at bottom of menu
199 Rectangle {
198 Rectangle {
@@ -249,8 +248,6 @@ Showable {
249
248
250 Indicators.IndicatorsModel {
249 Indicators.IndicatorsModel {
251 id: indicatorsModel
250 id: indicatorsModel
252−
253− Component.onCompleted: load()
254 }
251 }
255
252
256 IndicatorRow {
253 IndicatorRow {
@@ -265,6 +262,14 @@ Showable {
265 state: indicators.state
262 state: indicators.state
266 unitProgress: indicators.unitProgress
263 unitProgress: indicators.unitProgress
267
264
265+ onVisibleIndicatorsChanged: {
266+ // need to do it here so we can control sequence
267+ if (visibleIndicators !== undefined) {
268+ menuContent.visibleIndicators = visibleIndicators;
269+ menuContent.setCurrentMenuIndex(currentItemIndex);
270+ }
271+ }
272+
268 EdgeDragArea {
273 EdgeDragArea {
269 id: rowDragArea
274 id: rowDragArea
270 anchors.fill: indicatorRow
275 anchors.fill: indicatorRow
@@ -431,4 +436,9 @@ Showable {
431 NumberAnimation {targets: [indicatorRow, menuContent]; property: "y"; duration: 300; easing.type: Easing.OutCubic}
436 NumberAnimation {targets: [indicatorRow, menuContent]; property: "y"; duration: 300; easing.type: Easing.OutCubic}
432 }
437 }
433 ]
438 ]
439+
440+ Component.onCompleted: initialise();
441+ function initialise() {
442+ indicatorsModel.load();
443+ }
434}
444}
qml/Panel/MenuContent.qml+2−6
@@ -39,10 +39,10 @@ MainView {
39 height: units.gu(42)
39 height: units.gu(42)
40
40
41 function setCurrentMenuIndex(index) {
41 function setCurrentMenuIndex(index) {
42− var filteredIndex = filteredIndicators.mapFromSource(index)
42+ var filteredIndex = filteredIndicators.mapFromSource(index);
43
43
44 if (tabs.selectedTabIndex !== filteredIndex) {
44 if (tabs.selectedTabIndex !== filteredIndex) {
45− if (tabs.selectedTabIndex == -1 || !animateNextMenuChange) {
45+ if (tabs.selectedTabIndex === -1 || !animateNextMenuChange) {
46 tabs.tabBar.animate = false;
46 tabs.tabBar.animate = false;
47 }
47 }
48 tabs.selectedTabIndex = filteredIndex;
48 tabs.selectedTabIndex = filteredIndex;
@@ -74,10 +74,6 @@ MainView {
74
74
75 filterRole: Indicators.IndicatorsModelRole.IsVisible
75 filterRole: Indicators.IndicatorsModelRole.IsVisible
76 filterRegExp: RegExp("^true$")
76 filterRegExp: RegExp("^true$")
77−
78− onDataChanged: tabs.selectedTabIndexChanged();
79− onRowsInserted: tabs.selectedTabIndexChanged();
80− onRowsRemoved: tabs.selectedTabIndexChanged();
81 }
77 }
82
78
83 Indicators.VisibleIndicatorsModel {
79 Indicators.VisibleIndicatorsModel {