~aacid/unity8/dash_overview

« back to all changes in this revision

Viewing changes to qml/Dash/Dash.qml

  • Committer: Albert Astals
  • Date: 2014-08-07 15:27:32 UTC
  • mfrom: (1155.1.29 do_merged)
  • Revision ID: albert.astals@canonical.com-20140807152732-0zf22298f1lsxrz8
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
15
 */
16
16
 
17
 
import QtQuick 2.0
 
17
import QtQuick 2.2
18
18
import Ubuntu.Components 0.1
19
19
import Ubuntu.Gestures 0.1
20
20
import Unity 0.2
39
39
    }
40
40
 
41
41
    function setCurrentScope(scopeId, animate, reset) {
42
 
        var scopeIndex = filteredScopes.findFirst(Scopes.RoleId, scopeId)
 
42
        var scopeIndex = -1;
 
43
        for (var i = 0; i < scopes.count; ++i) {
 
44
            if (scopes.getScope(i).id == scopeId) {
 
45
                scopeIndex = i;
 
46
                break;
 
47
            }
 
48
        }
43
49
 
44
50
        if (scopeIndex == -1) {
45
51
            console.warn("No match for scope with id: %1".arg(scopeId))
64
70
        }
65
71
    }
66
72
 
67
 
    SortFilterProxyModel {
68
 
        id: filteredScopes
69
 
        model: Scopes {
70
 
            id: scopes
71
 
        }
72
 
        dynamicSortFilter: true
73
 
 
74
 
        filterRole: Scopes.RoleVisible
75
 
        filterRegExp: RegExp("^true$")
 
73
    Scopes {
 
74
        id: scopes
76
75
    }
77
76
 
78
77
    QtObject {
114
113
            hide();
115
114
        }
116
115
        onSearchSelected: {
117
 
            var scopeIndex = filteredScopes.findFirst(Scopes.RoleId, scopeId);
 
116
            var scopeIndex = -1;
 
117
            for (var i = 0; i < scopes.count; ++i) {
 
118
                if (scopes.getScope(i).id == scopeId) {
 
119
                    scopeIndex = i;
 
120
                    break;
 
121
                }
 
122
            }
118
123
            if (scopeIndex >= 0) {
119
124
                // Is a favorite one
120
125
                setCurrentScope(scopeId, false, false);
157
162
        objectName: "dashContent"
158
163
        width: dash.width
159
164
        height: dash.height
160
 
        model: filteredScopes
161
165
        scopes: scopes
162
166
        visible: !scopesOverview.showingNonFavoriteScope && x != -width
163
167
        onGotoScope: {
254
258
        }
255
259
    }
256
260
 
 
261
    Rectangle {
 
262
        id: indicator
 
263
        objectName: "processingIndicator"
 
264
        anchors {
 
265
            left: parent.left
 
266
            right: parent.right
 
267
            bottom: parent.bottom
 
268
        }
 
269
        height: units.dp(3)
 
270
        color: scopeStyle.backgroundLuminance > 0.7 ? "#50000000" : "#50ffffff"
 
271
        opacity: 0
 
272
        visible: opacity > 0
 
273
 
 
274
        readonly property bool processing: dashContent.processing || scopeItem.processing
 
275
 
 
276
        Behavior on opacity {
 
277
            UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
 
278
        }
 
279
 
 
280
        onProcessingChanged: {
 
281
            if (processing) delay.start();
 
282
            else if (!persist.running) indicator.opacity = 0;
 
283
        }
 
284
 
 
285
        Timer {
 
286
            id: delay
 
287
            interval: 200
 
288
            onTriggered: if (indicator.processing) {
 
289
                persist.restart();
 
290
                indicator.opacity = 1;
 
291
            }
 
292
        }
 
293
 
 
294
        Timer {
 
295
            id: persist
 
296
            interval: 2 * UbuntuAnimation.SleepyDuration - UbuntuAnimation.FastDuration
 
297
            onTriggered: if (!indicator.processing) indicator.opacity = 0
 
298
        }
 
299
 
 
300
        Rectangle {
 
301
            id: orange
 
302
            anchors { top: parent.top;  bottom: parent.bottom }
 
303
            width: parent.width / 4
 
304
            color: Theme.palette.selected.foreground
 
305
 
 
306
            SequentialAnimation {
 
307
                running: indicator.visible
 
308
                loops: Animation.Infinite
 
309
                XAnimator {
 
310
                    from: -orange.width / 2
 
311
                    to: indicator.width - orange.width / 2
 
312
                    duration: UbuntuAnimation.SleepyDuration
 
313
                    easing.type: Easing.InOutSine
 
314
                    target: orange
 
315
                }
 
316
                XAnimator {
 
317
                    from: indicator.width - orange.width / 2
 
318
                    to: -orange.width / 2
 
319
                    duration: UbuntuAnimation.SleepyDuration
 
320
                    easing.type: Easing.InOutSine
 
321
                    target: orange
 
322
                }
 
323
            }
 
324
        }
 
325
    }
 
326
 
257
327
    EdgeDragArea {
258
328
        id: overviewDragHandle
259
329
        objectName: "overviewDragHandle"