~ubuntu-branches/ubuntu/trusty/unity8/trusty-proposed

« back to all changes in this revision

Viewing changes to qml/Panel/Indicators.qml

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Nick Dedekind, Albert Astals, Mirco Müller, Andrea Cimitan, CI bot, Michał Karnicki
  • Date: 2014-01-29 16:11:20 UTC
  • mfrom: (1.1.62)
  • Revision ID: package-import@ubuntu.com-20140129161120-12chvzss1dghhsg5
Tags: 7.84+14.04.20140129-0ubuntu1
[ Nick Dedekind ]
* Added Panel/VisibleIndicatorsModel for use with both indicator row &
  menuContent. This removes the need to hide indicators in the row and
  map inicator indexes between row & content. Fixes the indicator
  highlight line offset not bound by listView position.
* Ported indicators to using ubuntu-settings-components

[ Albert Astals ]
* Prepend /sbin/ to initctl calls My phablet user does not have /sbin/
  in path and thus this calls fail
* Call updateDelegateCreationRange when it's needed It depends on
  other variables than the ones we were using to call it, so need to
  call it if these change too Device manual test, go to apps scope,
  scroll down so that only part of the installed apps collapsed
  category is shown, expand it, see how previously some icons were not
  painted and now they are

[ Mirco Müller ]
* Fixed the failure of notification autopilot-test
  test_sd_incoming_call.

[ Andrea Cimitan ]
* Add AP test for policykit/network manager, which was causing issues
  with nested mir

[ CI bot ]
* Resync trunk

[ Michał Karnicki ]
* Don't display artShape when artImage source not set.
* Fix FilterGrid rendering issues.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
import "../Components"
23
23
import "../Components/ListItems"
 
24
import "Indicators"
24
25
 
25
26
Showable {
26
27
    id: indicators
31
32
    property alias overFlowWidth: indicatorRow.overFlowWidth
32
33
    property alias showAll: indicatorRow.showAll
33
34
 
34
 
    property int hintValue
 
35
    readonly property real hintValue: panelHeight + menuContent.headerHeight
35
36
    readonly property int lockThreshold: openedHeight / 2
36
37
    property bool fullyOpened: height == openedHeight
37
38
    property bool partiallyOpened: height > panelHeight && !fullyOpened
39
40
    property bool contentEnabled: true
40
41
    property bool initalizeItem: true
41
42
    readonly property alias content: menuContent
42
 
    property real unitProgress: 0.0
 
43
    property real unitProgress: (height - panelHeight) / (openedHeight - panelHeight)
43
44
 
44
45
    // TODO: Perhaps we need a animation standard for showing/hiding? Each showable seems to
45
46
    // use its own values. Need to ask design about this.
128
129
 
129
130
        rowCoordinates = indicatorRow.mapToItem(indicatorRow.row, xValue, 0);
130
131
        // get the current delegate
131
 
        currentItem = indicatorRow.row.childAt(rowCoordinates.x, 0);
 
132
        currentItem = indicatorRow.row.itemAt(rowCoordinates.x, 0);
132
133
        if (currentItem) {
133
134
            itemCoordinates = indicatorRow.row.mapToItem(currentItem, rowCoordinates.x, 0);
134
135
            distanceFromRightEdge = (currentItem.width - itemCoordinates.x) / (currentItem.width);
143
144
                    }
144
145
                }
145
146
                if ((!useBuffer || (useBuffer && bufferExceeded)) || indicatorRow.currentItemIndex < 0 || indicatorRow.currentItem == null)  {
146
 
                    indicatorRow.currentItem = currentItem;
 
147
                    indicatorRow.setCurrentItem(currentItem);
147
148
                }
148
149
 
149
150
                // need to re-init the distanceFromRightEdge for offset calculation
151
152
                distanceFromRightEdge = (indicatorRow.currentItem.width - itemCoordinates.x) / (indicatorRow.currentItem.width);
152
153
            }
153
154
            indicatorRow.currentItemOffset = 1 - (distanceFromRightEdge * 2);
154
 
        } else {
 
155
        } else if (initalizeItem) {
155
156
            indicatorRow.setDefaultItem();
156
157
            indicatorRow.currentItemOffset = 0;
157
158
        }
179
180
        source: "graphics/VerticalDivider.png"
180
181
    }
181
182
 
 
183
    VisibleIndicators {
 
184
        id: visibleIndicators
 
185
    }
 
186
 
182
187
    MenuContent {
183
188
        id: menuContent
184
189
        objectName: "menuContent"
189
194
            top: indicatorRow.bottom
190
195
            bottom: handle.top
191
196
        }
192
 
        indicatorsModel: indicatorsModel
 
197
        indicatorsModel: visibleIndicators.model
193
198
        clip: !indicators.fullyOpened
194
199
        activeHeader: indicators.state == "hint" || indicators.state == "reveal"
195
200
        enabled: contentEnabled
220
225
            right: parent.right
221
226
            bottom: parent.bottom
222
227
        }
223
 
        height: get_height()
 
228
        height: Math.max(Math.min(handleImage.height, indicators.height - handleImage.height), 0)
224
229
        clip: height < handleImage.height
225
230
 
226
 
        function get_height() {
227
 
            return Math.max(Math.min(handleImage.height, indicators.height - handleImage.height), 0);
228
 
        }
229
 
 
230
231
        BorderImage {
231
232
            id: handleImage
232
233
            source: "graphics/handle.sci"
246
247
        anchors.fill: indicatorRow
247
248
    }
248
249
 
249
 
    Indicators.IndicatorsModel {
250
 
        id: indicatorsModel
251
 
    }
252
 
 
253
250
    IndicatorRow {
254
251
        id: indicatorRow
255
252
        objectName: "indicatorRow"
258
255
            right: parent.right
259
256
        }
260
257
        height: indicators.panelHeight
261
 
        indicatorsModel: indicatorsModel
 
258
        indicatorsModel: visibleIndicators.model
262
259
        state: indicators.state
263
260
        unitProgress: indicators.unitProgress
264
261
 
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
 
 
273
262
        EdgeDragArea {
274
263
            id: rowDragArea
275
264
            anchors.fill: indicatorRow
303
292
        onRunningChanged: {
304
293
            if (showAnimation.running) {
305
294
                indicators.state = "commit";
 
295
                indicatorRow.currentItemOffset = 0;
306
296
            }
307
297
        }
308
298
    }
313
303
            if (hideAnimation.running) {
314
304
                indicators.state = "initial";
315
305
                initalizeItem = true;
316
 
                menuContent.animateNextMenuChange = false;
 
306
                indicatorRow.currentItemOffset = 0;
317
307
            }
318
308
        }
319
309
    }
331
321
            if (!oldActive) return;
332
322
            d.enableIndexChangeSignal = false;
333
323
 
334
 
            indicatorRow.setCurrentItem(menuContent.currentMenuIndex);
 
324
            indicatorRow.setCurrentItemIndex(menuContent.currentMenuIndex);
335
325
 
336
326
            d.enableIndexChangeSignal = oldActive;
337
327
        }
344
334
            if (!oldActive) return;
345
335
            d.enableIndexChangeSignal = false;
346
336
 
347
 
            menuContent.setCurrentMenuIndex(indicatorRow.currentItemIndex);
 
337
            menuContent.setCurrentMenuIndex(indicatorRow.currentItemIndex, fullyOpened || partiallyOpened);
348
338
 
349
339
            d.enableIndexChangeSignal = oldActive;
350
340
        }
439
429
 
440
430
    Component.onCompleted: initialise();
441
431
    function initialise() {
442
 
        indicatorsModel.load();
 
432
        visibleIndicators.load();
443
433
    }
444
434
}