~ubuntu-branches/ubuntu/precise/unity-2d/precise-updates

« back to all changes in this revision

Viewing changes to places/LensBar.qml

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-08-11 21:22:18 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: james.westby@ubuntu.com-20110811212218-vjwi8txoyl6g7upb
Tags: 4.0.0-0ubuntu1
* New upstream release:
  - [launcher] Impossible to keep KDE Apps in Launcher (LP: #741129)
  - [dash] Background should be blurred (LP: #823326)
  - No 'safely remove' option is present in the unity menu when a usb disk
    is inserted (LP: #660010)
  - Quicklist item "Keep In Launcher" should be "Keep in launcher" as design
    (LP: #795422)
  - [launcher] ESC doesn't dismiss launcher when activated with Alt+F1
    (LP: #812792)
  - [dash] Background wallpaper shifted when using a non compositing window
    manager (LP: #823295)
  - [launcher] Bottom gradient appears too early (LP: #823877)
  - mute/unmute sound when user clicks on sound applet using scroll button
    or middle mouse button (LP: #609860)
  - Secondary activate (i.e. middle click) support for indicators advanced
    usage (LP: #812933)
  - Unused GConfItemQmlWrapper dep found (LP: #821880)
* debian/control:
  - bump libunity-core-4.0-dev, libnux-1.0-dev
  - recommends lenses and not places anymore. Adding music lens

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of unity-2d
 
3
 *
 
4
 * Copyright 2011 Canonical Ltd.
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; version 3.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
import QtQuick 1.0
 
20
import Unity2d 1.0
 
21
 
 
22
FocusScope {
 
23
    /* declare width & spacing of icons as required for layout calculations */
 
24
    property int iconWidth: 32
 
25
    property int iconSpacing: 28
 
26
 
 
27
    property variant visibleLenses: SortFilterProxyModel {
 
28
        model: dash.lenses
 
29
        dynamicSortFilter: true
 
30
 
 
31
        filterRole: Lenses.RoleVisible
 
32
        filterRegExp: RegExp("^true$")
 
33
    }
 
34
 
 
35
    Rectangle {
 
36
        id: background
 
37
 
 
38
        anchors.fill: parent
 
39
        color: "black"
 
40
        opacity: 0.22
 
41
    }
 
42
 
 
43
    /* LensBar contains a row of LensButtons */
 
44
    Row {
 
45
        id: lensContainer
 
46
 
 
47
        anchors.horizontalCenter: background.horizontalCenter
 
48
        anchors.top: background.top
 
49
        anchors.bottom: background.bottom
 
50
        spacing: iconSpacing
 
51
 
 
52
        Keys.onPressed: if (handleKeyPress(event.key)) event.accepted = true
 
53
 
 
54
        /* The Home lens is unfortunately not supplied by the "lenses" list
 
55
           This causes the keyboard navigation logic to be messy */
 
56
        property int currentIndex: 0
 
57
 
 
58
        function selectChild(index) {
 
59
            var child = lensContainer.childFromIndex(index)
 
60
            if (child != undefined) {
 
61
                child.focus = true
 
62
                currentIndex = index
 
63
                return true
 
64
            } else {
 
65
                return false
 
66
            }
 
67
        }
 
68
 
 
69
        function handleKeyPress(key) {
 
70
            switch (key) {
 
71
            case Qt.Key_Right:
 
72
                return selectChild(currentIndex+1)
 
73
            case Qt.Key_Left:
 
74
                return selectChild(currentIndex-1)
 
75
            }
 
76
        }
 
77
 
 
78
        function childFromIndex(index) {
 
79
            var indexInChildren = 0
 
80
            for(var i=0; i<children.length; i++) {
 
81
                if (children[i] != repeater) {
 
82
                    if (indexInChildren == index) return children[i]
 
83
                    indexInChildren++
 
84
                }
 
85
            }
 
86
            return undefined
 
87
        }
 
88
 
 
89
        /* Need to manually include the Home lens */
 
90
        LensButton {
 
91
            id: homeLens
 
92
 
 
93
            focus: true
 
94
            icon: "artwork/home.png"
 
95
            onClicked: dash.activateHome()
 
96
            active: ( dashView.activeLens == "" )
 
97
            width: iconWidth
 
98
            anchors.top: parent.top
 
99
            anchors.bottom: parent.bottom
 
100
        }
 
101
 
 
102
        /* Now fetch all other lenses and display */
 
103
        Repeater{
 
104
            id: repeater
 
105
 
 
106
            model: visibleLenses
 
107
            delegate: LensButton {
 
108
                icon: item.iconHint
 
109
                active: item.active
 
110
                onClicked: dash.activateLens(item.id)
 
111
                width: iconWidth
 
112
                anchors.top: parent != undefined ? parent.top : undefined
 
113
                anchors.bottom: parent != undefined ? parent.bottom : undefined
 
114
            }
 
115
        }
 
116
    }
 
117
}