2
* This file is part of unity-2d
4
* Copyright 2012 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
import "../common/utils.js" as Utils
28
Accessible.name: "Hud"
30
LayoutMirroring.enabled: Utils.isRightToLeft()
31
LayoutMirroring.childrenInherit: true
33
property bool active: false
35
property int resultHeight: 42
37
property bool animating: heightAnimation.running
39
height: layout.childrenRect.height + layout.anchors.bottomMargin + 10
42
enabled: desktop.isCompositingManagerRunning
43
PropertyAnimation { id: heightAnimation; duration: 150; easing.type: Easing.InOutQuad }
48
contentXid: declarativeView.lastFocusedWindow
53
onShownChanged: active = false
58
declarativeView.forceActivateWindow()
59
resultList.focus = true
62
resultList.currentIndex = -1
67
target: declarativeView
69
onToggleHud: toggleHud()
73
if (event.key == Qt.Key_Escape) toggleHud()
76
function toggleHud() {
77
if (spread.shown) return
78
if (active) declarativeView.forceDeactivateWindow()
82
function executeResult(resultId) {
83
declarativeView.forceDeactivateWindow()
84
hudModel.executeResult(resultId)
88
property variant hudModel: Hud {}
103
/* Margins so content does not overlap with the background border */
104
anchors.bottomMargin: background.bottomBorderThickness
105
anchors.rightMargin: background.rightBorderThickness
113
anchors.top: parent.top
114
anchors.left: parent.left
115
anchors.leftMargin: tile.width
116
anchors.right: parent.right
117
source: "../common/artwork/panel_border.png"
118
fillMode: Image.Stretch
124
anchors.left: parent.left
125
anchors.top: parent.top
131
anchors.verticalCenter: iconTile.verticalCenter
132
anchors.horizontalCenterOffset: -1
133
anchors.left: parent.left
134
mirror: Utils.isRightToLeft()
136
source: "image://blended/%1color=%2alpha=%3"
137
.arg("launcher/artwork/launcher_arrow_ltr.png")
138
.arg("lightgrey").arg(1.0)
144
anchors.top: parent.top
146
anchors.left: parent.left
147
anchors.leftMargin: 5
151
source: (resultList.currentItem != null && resultList.count > 0)
152
? "image://icons/" + resultList.currentItem.icon
154
? "image://icons/" + activeWindow.icon
155
: "image://icons/unknown")
159
/* Unhandled keys will always be forwarded to the search bar. That way
160
the user can type and search from anywhere in the interface without
161
necessarily focusing the search bar first. */
162
Keys.forwardTo: [searchEntry]
167
anchors.top: parent.top
168
anchors.topMargin: 11
169
anchors.left: tile.right
170
anchors.leftMargin: 10
171
anchors.right: parent.right
172
anchors.rightMargin: 10
173
height: childrenRect.height
175
border.color: "#21ffffff" // 80% opaque
184
anchors.top: parent.top
185
anchors.left: parent.left
186
anchors.right: parent.right
192
placeHolderText: u2d.tr("Type your Command")
194
onSearchQueryChanged: {
195
hudModel.searchQuery = searchQuery
196
resultList.currentIndex = 0
198
onActivateFirstResult: executeResult(0)
206
Accessible.name: "result list"
210
anchors.top: searchEntry.bottom
211
anchors.left: parent.left
212
anchors.right: parent.right
213
height: count * resultHeight
215
boundsBehavior: ListView.StopAtBounds
217
delegate: ResultItem {
219
width: ListView.view.width
221
icon: iconName /* expose this property for tile */
223
onClicked: executeResult(resultId)