2 * Copyright (C) 2013-2017 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18import Ubuntu.Components 1.3
19import Ubuntu.Layouts 1.0
20import Unity.Application 0.1
21import Unity.Indicators 0.1
23import Unity.ApplicationMenu 0.1
25import QtQuick.Window 2.2
27import "../ApplicationMenus"
29import "../Components/PanelState"
35 readonly property real panelHeight: panelArea.y + minimizedPanelHeight
37 property real minimizedPanelHeight: units.gu(3)
38 property real expandedPanelHeight: units.gu(7)
39 property real indicatorMenuWidth: width
40 property real applicationMenuWidth: width
42 property alias applicationMenus: __applicationMenus
43 property alias indicators: __indicators
44 property bool fullscreenMode: false
45 property real panelAreaShowProgress: 1.0
46 property bool greeterShown: false
47 property bool hasKeyboard: false
49 property string mode: "staged"
54 anchors.topMargin: panelHeight
55 visible: !indicators.fullyClosed || !applicationMenus.fullyClosed
57 hoverEnabled: true // should also eat hover events, otherwise they will pass through
60 __applicationMenus.hide();
67 property: "panelHeight"
68 value: minimizedPanelHeight
71 RegisteredApplicationMenuModel {
72 id: registeredMenuModel
73 persistentSurfaceId: PanelState.focusedPersistentSurfaceId
79 property bool revealControls: !greeterShown &&
80 !applicationMenus.shown &&
82 (decorationMouseArea.containsMouse || menuBarLoader.menusRequested)
84 property bool showWindowDecorationControls: (revealControls && PanelState.decorationsVisible) ||
85 PanelState.decorationsAlwaysVisible
87 property bool showPointerMenu: revealControls && enablePointerMenu &&
88 (PanelState.decorationsVisible || mode == "staged")
90 property bool enablePointerMenu: applicationMenus.available &&
91 applicationMenus.model
93 property bool showTouchMenu: !greeterShown &&
95 !showWindowDecorationControls
97 property bool enableTouchMenus: showTouchMenu &&
98 applicationMenus.available &&
99 applicationMenus.model
104 objectName: "panelArea"
108 transform: Translate {
109 y: indicators.state === "initial"
110 ? (1.0 - panelAreaShowProgress) * - minimizedPanelHeight
115 id: indicatorsDropShadow
118 margins: -units.gu(1)
120 visible: !__indicators.fullyClosed
121 source: "graphics/rectangular_dropshadow.sci"
125 id: appmenuDropShadow
127 fill: __applicationMenus
128 margins: -units.gu(1)
130 visible: !__applicationMenus.fullyClosed
131 source: "graphics/rectangular_dropshadow.sci"
137 fill: panelAreaBackground
138 bottomMargin: -units.gu(1)
140 visible: PanelState.dropShadow
141 source: "graphics/rectangular_dropshadow.sci"
145 id: panelAreaBackground
146 color: callHint.visible ? theme.palette.normal.positive : theme.palette.normal.background
152 height: minimizedPanelHeight
154 Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration } }
158 id: decorationMouseArea
159 objectName: "windowControlArea"
164 height: minimizedPanelHeight
165 hoverEnabled: !__indicators.shown
167 if (callHint.visible) {
168 callHint.showLiveCall();
173 if (!callHint.visible) {
174 // let it fall through to the window decoration of the maximized window behind, if any
175 mouse.accepted = false;
177 var menubar = menuBarLoader.item;
179 menubar.invokeMenu(mouse);
187 // WindowControlButtons inside the mouse area, otherwise QML doesn't grok nested hover events :/
188 // cf. https://bugreports.qt.io/browse/QTBUG-32909
189 WindowControlButtons {
190 id: windowControlButtons
191 objectName: "panelWindowControlButtons"
192 height: indicators.minimizedPanelHeight
193 opacity: d.showWindowDecorationControls ? 1 : 0
194 visible: opacity != 0
195 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
197 active: PanelState.decorationsVisible || PanelState.decorationsAlwaysVisible
198 windowIsMaximized: true
199 onCloseClicked: PanelState.closeClicked()
200 onMinimizeClicked: PanelState.minimizeClicked()
201 onMaximizeClicked: PanelState.restoreClicked()
202 closeButtonShown: PanelState.closeButtonShown
207 objectName: "menuBarLoader"
208 height: parent.height
209 enabled: d.enablePointerMenu
210 opacity: d.showPointerMenu ? 1 : 0
211 visible: opacity != 0
212 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
213 active: d.showPointerMenu && !callHint.visible
215 width: parent.width - windowControlButtons.width - units.gu(2) - __indicators.barWidth
217 readonly property bool menusRequested: menuBarLoader.item ? menuBarLoader.item.showRequested : false
219 sourceComponent: MenuBar {
221 objectName: "menuBar"
222 anchors.left: parent.left
223 anchors.margins: units.gu(1)
224 height: menuBarLoader.height
225 enableKeyFilter: valid && PanelState.decorationsVisible
226 unityMenuModel: __applicationMenus.model
229 target: __applicationMenus
230 onShownChanged: bar.dismiss();
235 onShownChanged: bar.dismiss();
238 onDoubleClicked: PanelState.restoreClicked()
239 onPressed: mouse.accepted = false // let the parent mouse area handle this, so it can both unsnap window and show menu
246 objectName: "callHint"
248 anchors.centerIn: parent
249 height: minimizedPanelHeight
251 visible: active && indicators.state == "initial" && __applicationMenus.state == "initial"
252 greeterShown: root.greeterShown
257 id: __applicationMenus
259 model: registeredMenuModel.model
260 width: root.applicationMenuWidth
261 minimizedPanelHeight: root.minimizedPanelHeight
262 expandedPanelHeight: root.expandedPanelHeight
263 openedHeight: root.height
264 alignment: Qt.AlignLeft
265 enableHint: !callHint.active && !fullscreenMode
267 panelColor: panelAreaBackground.color
270 if (callHint.active) {
271 callHint.showLiveCall();
275 showRowTitle: !expanded
276 rowTitle: PanelState.title
277 rowItemDelegate: ActionItem {
279 property int ownIndex: index
280 objectName: "appMenuItem"+index
282 width: _title.width + units.gu(2)
283 height: parent.height
286 text: model.label.replace("_", "&")
291 anchors.centerIn: parent
292 text: actionItem.text
293 horizontalAlignment: Text.AlignLeft
294 color: enabled ? theme.palette.normal.backgroundText : theme.palette.disabled.backgroundText
298 pageDelegate: PanelMenuPage {
299 menuModel: __applicationMenus.model
300 submenuIndex: modelIndex
302 factory: ApplicationMenuItemFactory {
303 rootModel: __applicationMenus.model
307 enabled: d.enableTouchMenus
308 opacity: d.showTouchMenu ? 1 : 0
309 visible: opacity != 0
310 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
313 if (!enabled) hide();
319 objectName: "indicators"
325 width: root.indicatorMenuWidth
326 minimizedPanelHeight: root.minimizedPanelHeight
327 expandedPanelHeight: root.expandedPanelHeight
328 openedHeight: root.height
330 overFlowWidth: root.width
331 enableHint: !callHint.active && !fullscreenMode
332 showOnClick: !callHint.visible
333 panelColor: panelAreaBackground.color
336 if (callHint.active) {
337 callHint.showLiveCall();
341 rowItemDelegate: IndicatorItem {
343 objectName: identifier+"-panelItem"
345 property int ownIndex: index
346 readonly property bool overflow: parent.width - x > __indicators.overFlowWidth
347 readonly property bool hidden: !expanded && (overflow || !indicatorVisible || hideSessionIndicator || hideKeyboardIndicator)
348 // HACK for indicator-session
349 readonly property bool hideSessionIndicator: identifier == "indicator-session" && Math.min(Screen.width, Screen.height) <= units.gu(60)
350 // HACK for indicator-keyboard
351 readonly property bool hideKeyboardIndicator: identifier == "indicator-keyboard" && !hasKeyboard
353 height: parent.height
354 expanded: indicators.expanded
355 selected: ListView.isCurrentItem
357 identifier: model.identifier
358 busName: indicatorProperties.busName
359 actionsObjectPath: indicatorProperties.actionsObjectPath
360 menuObjectPath: indicatorProperties.menuObjectPath
362 opacity: hidden ? 0.0 : 1.0
363 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
365 width: ((expanded || indicatorVisible) && !hideSessionIndicator && !hideKeyboardIndicator) ? implicitWidth : 0
367 Behavior on width { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
370 pageDelegate: PanelMenuPage {
371 objectName: modelData.identifier + "-page"
374 menuModel: delegate.menuModel
376 factory: IndicatorMenuItemFactory {
378 var context = modelData.identifier;
379 if (context && context.indexOf("fake-") === 0) {
380 context = context.substring("fake-".length)
384 rootModel: delegate.menuModel
389 busName: modelData.indicatorProperties.busName
390 actionsObjectPath: modelData.indicatorProperties.actionsObjectPath
391 menuObjectPath: modelData.indicatorProperties.menuObjectPath
395 enabled: !applicationMenus.expanded
396 opacity: !callHint.visible && !applicationMenus.expanded ? 1 : 0
397 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
400 if (!enabled) hide();
411 name: "onscreen" //fully opaque and visible at top edge of screen
412 when: !fullscreenMode
420 name: "offscreen" //pushed off screen
425 if (indicators.state !== "initial") return 0;
426 if (applicationMenus.state !== "initial") return 0;
427 return -minimizedPanelHeight;
429 opacity: indicators.fullyClosed && applicationMenus.fullyClosed ? 0.0 : 1.0
432 target: indicators.showDragHandle;
433 anchors.bottomMargin: -units.gu(1)
436 target: applicationMenus.showDragHandle;
437 anchors.bottomMargin: -units.gu(1)
445 UbuntuNumberAnimation { target: panelArea; properties: "anchors.topMargin,opacity" }
449 UbuntuNumberAnimation { target: panelArea; properties: "anchors.topMargin,opacity" }
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list