2
* This file is part of unity-2d
4
* Copyright 2011 Canonical Ltd.
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.
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.
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/>.
23
/* declare width & spacing of icons as required for layout calculations */
24
property int iconWidth: 32
25
property int iconSpacing: 28
27
property variant visibleLenses: SortFilterProxyModel {
29
dynamicSortFilter: true
31
filterRole: Lenses.RoleVisible
32
filterRegExp: RegExp("^true$")
43
/* LensBar contains a row of LensButtons */
47
anchors.horizontalCenter: background.horizontalCenter
48
anchors.top: background.top
49
anchors.bottom: background.bottom
52
Keys.onPressed: if (handleKeyPress(event.key)) event.accepted = true
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
58
function selectChild(index) {
59
var child = lensContainer.childFromIndex(index)
60
if (child != undefined) {
69
function handleKeyPress(key) {
72
return selectChild(currentIndex+1)
74
return selectChild(currentIndex-1)
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]
89
/* Need to manually include the Home lens */
94
icon: "artwork/home.png"
95
onClicked: dash.activateHome()
96
active: ( dashView.activeLens == "" )
98
anchors.top: parent.top
99
anchors.bottom: parent.bottom
102
/* Now fetch all other lenses and display */
107
delegate: LensButton {
110
onClicked: dash.activateLens(item.id)
112
anchors.top: parent != undefined ? parent.top : undefined
113
anchors.bottom: parent != undefined ? parent.bottom : undefined