@@ -16,19 +16,40 @@
1616
1717import QtQuick 2.4
1818import Ubuntu.Components 1.3
19+import Ubuntu.Layouts 1.0
1920import Unity.Application 0.1
21+import Unity.Indicators 0.1
22+import Utils 0.1
23+import Unity.ApplicationMenu 0.1
24+
25+import QtQuick.Window 2.2
26+// for indicator-keyboard
27+import AccountsService 0.1
28+import Unity.InputInfo 0.1
29+
30+import "../ApplicationMenus"
2031import "../Components"
2132import "../Components/PanelState"
2233import ".."
34+import "Indicators"
2335
2436Item {
2537 id: root
26− readonly property real panelHeight: indicatorArea.y + d.indicatorHeight
38+ readonly property real panelHeight: indicatorArea.y + minimizedPanelHeight
39+
40+ property real minimizedPanelHeight: units.gu(3)
41+ property real expandedPanelHeight: units.gu(7)
42+ property real indicatorMenuWidth: width
43+ property real applicationMenuWidth: width
44+
45+ property alias applicationMenus: fakeApplicationMenus
2746 property alias indicators: __indicators
28− property alias callHint: __callHint
2947 property bool fullscreenMode: false
3048 property real indicatorAreaShowProgress: 1.0
3149 property bool locked: false
50+ property bool greeterShown: false
51+
52+ property string mode: "staged"
3253
3354 MouseArea {
3455 anchors.fill: parent
@@ -42,7 +63,17 @@ Item {
4263 Binding {
4364 target: PanelState
4465 property: "panelHeight"
45− value: indicators.minimizedPanelHeight
66+ value: minimizedPanelHeight
67+ }
68+
69+ FakePanelMenu {
70+ id: fakeApplicationMenus
71+ model: registeredMenuModel.model
72+ }
73+
74+ RegisteredApplicationMenuModel {
75+ id: registeredMenuModel
76+ persistentSurfaceId: PanelState.focusedPersistentSurfaceId
4677 }
4778
4879 Item {
@@ -53,25 +84,24 @@ Item {
5384
5485 transform: Translate {
5586 y: indicators.state === "initial"
56− ? (1.0 - indicatorAreaShowProgress) * -d.indicatorHeight
87+ ? (1.0 - indicatorAreaShowProgress) * - minimizedPanelHeight
5788 : 0
5889 }
5990
6091 BorderImage {
6192 id: indicatorsDropShadow
6293 anchors {
63− fill: indicators
64− leftMargin: -units.gu(1)
65− bottomMargin: -units.gu(1)
94+ fill: __indicators
95+ margins: -units.gu(1)
6696 }
67− visible: !indicators.fullyClosed
97+ visible: !__indicators.fullyClosed
6898 source: "graphics/rectangular_dropshadow.sci"
6999 }
70100
71101 BorderImage {
72102 id: panelDropShadow
73103 anchors {
74− fill: indicatorAreaBackground
104+ fill: panelAreaBackground
75105 bottomMargin: -units.gu(1)
76106 }
77107 visible: PanelState.dropShadow && !callHint.visible
@@ -79,59 +109,289 @@ Item {
79109 }
80110
81111 Rectangle {
82− id: indicatorAreaBackground
83− color: callHint.visible ? theme.palette.normal.positive : theme.palette.normal.background
112+ id: panelAreaBackground
113+ color: theme.palette.normal.background
84114 anchors {
85115 top: parent.top
86116 left: parent.left
87117 right: parent.right
88118 }
89− height: indicators.minimizedPanelHeight
119+ height: minimizedPanelHeight
90120
91121 Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration } }
92122 }
93123
94− MouseArea {
95− objectName: "windowControlArea"
96− anchors {
97− top: parent.top
98− left: parent.left
99− right: indicators.left
100− }
101− height: indicators.minimizedPanelHeight
102− hoverEnabled: true
103− onClicked: if (callHint.visible) { callHint.showLiveCall(); }
124+ Loader {
125+ id: apppMenuLoader
126+ sourceComponent: mode == "staged" ? stagedLeftPanelComponent : windowedLeftPanelComponent
127+ width: parent.width
128+ height: minimizedPanelHeight
129+
130+ opacity: root.locked ? 0 : 1
131+ visible: opacity != 0
132+ Behavior on opacity { UbuntuNumberAnimation {} }
133+ }
134+
135+ Component {
136+ id: stagedLeftPanelComponent
137+
138+ MouseArea {
139+ id: decorationMouseArea
140+ objectName: "windowControlArea"
141+ anchors {
142+ left: parent.left
143+ right: parent.right
144+ }
145+ height: minimizedPanelHeight
146+ hoverEnabled: !__indicators.shown
147+ onClicked: {
148+ if (callHint.visible) {
149+ callHint.showLiveCall();
150+ }
151+ }
104152
105− onPressed: {
106− if (!callHint.visible) {
107− // let it fall through to the window decoration of the maximized window behind, if any
108− mouse.accepted = false;
153+ BorderImage {
154+ id: applicationMenusDropShadow
155+ anchors {
156+ fill: __applicationMenus
157+ margins: -units.gu(1)
158+ }
159+ visible: !__applicationMenus.fullyClosed
160+ source: "graphics/rectangular_dropshadow.sci"
161+ }
162+
163+ PanelMenu {
164+ id: __applicationMenus
165+
166+ hides: fakeApplicationMenus.hides
167+ model: fakeApplicationMenus.model
168+
169+ width: root.applicationMenuWidth
170+ minimizedPanelHeight: root.minimizedPanelHeight
171+ expandedPanelHeight: root.expandedPanelHeight
172+ openedHeight: root.height
173+ enableHint: !callHint.active && !fullscreenMode
174+ showOnClick: !callHint.visible
175+ panelColor: callHint.visible ? theme.palette.normal.positive : theme.palette.normal.background
176+ alignment: Qt.AlignLeft
177+
178+ showRowTitle: !expanded
179+ rowTitle: PanelState.title
180+ rowItemDelegate: ActionItem {
181+ id: actionItem
182+ property int ownIndex: index
183+
184+ width: _title.width + units.gu(2)
185+ height: parent.height
186+
187+ action: Action {
188+ text: model.label.replace("_", "&")
189+ }
190+
191+ Label {
192+ id: _title
193+ anchors.centerIn: parent
194+ text: actionItem.text
195+ horizontalAlignment: Text.AlignLeft
196+ color: enabled ? "white" : "#5d5d5d"
197+ }
198+ }
199+
200+ pageDelegate: IndicatorPage {
201+ id: page
202+ context: "application-menu"
203+ menuModel: __applicationMenus.model
204+ submenuIndex: modelIndex
205+ }
206+
207+ enabled: !root.locked && model
208+ opacity: !indicators.expanded ? 1 : 0
209+ visible: opacity != 0
210+ Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
211+
212+ Binding {
213+ target: fakeApplicationMenus
214+ property: "expanded"
215+ value: __applicationMenus.expanded
216+ }
217+
218+ Connections {
219+ target: fakeApplicationMenus
220+ onHide: __applicationMenus.hide();
221+ onShow: __applicationMenus.show();
222+ }
223+ }
224+
225+ ActiveCallHint {
226+ id: callHint
227+ x: __applicationMenus.x + __applicationMenus.barWidth
228+ height: parent.height
229+
230+ visible: active && (indicators.state == "initial" && __applicationMenus.state == "initial")
231+ greeterShown: root.greeterShown
232+ }
233+
234+ Binding {
235+ target: __indicators
236+ property: "overFlowWidth"
237+ value: {
238+ var width = root.width;
239+ if (callHint.visible) {
240+ width -= callHint.width;
241+ }
242+ if (__applicationMenus.visible) {
243+ width -= __applicationMenus.barWidth;
244+ }
245+ return Math.max(width, 0);
246+ }
247+ }
248+ Binding {
249+ target: panelAreaBackground
250+ property: "color"
251+ value: callHint.visible ? theme.palette.normal.positive : theme.palette.normal.background
252+ }
253+ Binding {
254+ target: __indicators
255+ property: "enableHint"
256+ value: !callHint.active && !__indicators.fullscreenMode
257+ }
258+ Binding {
259+ target: __indicators
260+ property: "showOnClick"
261+ value: !callHint.visible
262+ }
263+ Connections {
264+ target: __indicators
265+ onShowTapped: {
266+ if (callHint.active) {
267+ callHint.showLiveCall();
268+ }
269+ }
109270 }
110271 }
272+ }
111273
112− // WindowControlButtons inside the mouse area, otherwise QML doesn't grok nested hover events :/
113− // cf. https://bugreports.qt.io/browse/QTBUG-32909
114− WindowControlButtons {
115− id: windowControlButtons
116− objectName: "panelWindowControlButtons"
274+ Component {
275+ id: windowedLeftPanelComponent
276+
277+ MouseArea {
278+ id: decorationMouseArea
279+ objectName: "windowControlArea"
117280 anchors {
118281 left: parent.left
119− top: parent.top
120− }
121− height: indicators.minimizedPanelHeight
122−
123− visible: ((PanelState.buttonsVisible && parent.containsMouse) || PanelState.buttonsAlwaysVisible)
124− && !root.locked && !callHint.visible
125− active: PanelState.buttonsVisible || PanelState.buttonsAlwaysVisible
126− windowIsMaximized: true
127− onCloseClicked: PanelState.closeClicked()
128− onMinimizeClicked: PanelState.minimizeClicked()
129− onMaximizeClicked: PanelState.restoreClicked()
130− closeButtonShown: PanelState.closeButtonShown
282+ right: parent.right
283+ }
284+ height: minimizedPanelHeight
285+ hoverEnabled: !__indicators.shown
286+ onClicked: if (callHint.visible) { callHint.showLiveCall(); }
287+
288+ onPressed: {
289+ if (!callHint.visible) {
290+ // let it fall through to the window decoration of the maximized window behind, if any
291+ mouse.accepted = false;
292+ }
293+ }
294+
295+ property bool showWindowControls: (PanelState.decorationsVisible && (containsMouse || menuBarLoader.menusRequested)) || PanelState.decorationsAlwaysVisible
296+
297+ // WindowControlButtons inside the mouse area, otherwise QML doesn't grok nested hover events :/
298+ // cf. https://bugreports.qt.io/browse/QTBUG-32909
299+ WindowControlButtons {
300+ id: windowControlButtons
301+ objectName: "panelWindowControlButtons"
302+ anchors {
303+ left: parent.left
304+ top: parent.top
305+ }
306+ height: indicators.minimizedPanelHeight
307+ opacity: decorationMouseArea.showWindowControls ? 1 : 0
308+ visible: opacity != 0
309+ Behavior on opacity { UbuntuNumberAnimation {} }
310+
311+ active: PanelState.decorationsVisible || PanelState.decorationsAlwaysVisible
312+ windowIsMaximized: true
313+ onCloseClicked: PanelState.closeClicked()
314+ onMinimizeClicked: PanelState.minimizeClicked()
315+ onMaximizeClicked: PanelState.restoreClicked()
316+ closeButtonShown: PanelState.closeButtonShown
317+ }
318+
319+ Loader {
320+ id: menuBarLoader
321+ anchors {
322+ left: windowControlButtons.right
323+ leftMargin: units.gu(3)
324+ }
325+ height: parent.height
326+ opacity: windowControlButtons.opacity
327+ visible: opacity != 0
328+ active: fakeApplicationMenus.model
329+
330+ property bool menusRequested: menuBarLoader.item ? menuBarLoader.item.showRequested : false
331+
332+ sourceComponent: MenuBarLoader {
333+ height: menuBarLoader.height
334+ enableKeyFilter: valid && PanelState.decorationsVisible
335+ unityMenuModel: fakeApplicationMenus.model
336+ }
337+ }
338+
339+ Label {
340+ id: titleLabel
341+ objectName: "windowDecorationTitle"
342+ anchors {
343+ left: parent.left
344+ leftMargin: units.gu(1)
345+ verticalCenter: parent.verticalCenter
346+ }
347+ color: "white"
348+ opacity: !decorationMouseArea.showWindowControls ? 1 : 0
349+ visible: opacity != 0
350+ verticalAlignment: Text.AlignVCenter
351+ fontSize: "medium"
352+ font.weight: PanelState.decorationsVisible ? Font.Light : Font.Medium
353+ text: PanelState.title
354+ elide: Text.ElideRight
355+ maximumLineCount: 1
356+ Behavior on opacity { UbuntuNumberAnimation {} }
357+ }
358+
359+ ActiveCallHint {
360+ id: callHint
361+ anchors.centerIn: parent
362+ height: minimizedPanelHeight
363+
364+ visible: active && indicators.state == "initial"
365+ greeterShown: root.greeterShown
366+ }
367+
368+ Binding {
369+ target: panelAreaBackground
370+ property: "color"
371+ value: callHint.visible ? theme.palette.normal.positive : theme.palette.normal.background
372+ }
373+ Binding {
374+ target: __indicators
375+ property: "enableHint"
376+ value: !callHint.active && !__indicators.fullscreenMode
377+ }
378+ Binding {
379+ target: __indicators
380+ property: "showOnClick"
381+ value: !callHint.visible
382+ }
383+ Connections {
384+ target: __indicators
385+ onShowTapped: {
386+ if (callHint.active) {
387+ callHint.showLiveCall();
388+ }
389+ }
390+ }
131391 }
132392 }
133393
134− IndicatorsMenu {
394+ PanelMenu {
135395 id: __indicators
136396 objectName: "indicators"
137397
@@ -139,72 +399,77 @@ Item {
139399 top: parent.top
140400 right: parent.right
141401 }
142−
143− shown: false
144− width: root.width - (windowControlButtons.visible ? windowControlButtons.width + titleLabel.width : 0)
145− minimizedPanelHeight: units.gu(3)
146− expandedPanelHeight: units.gu(7)
402+ width: root.indicatorMenuWidth
403+ minimizedPanelHeight: root.minimizedPanelHeight
404+ expandedPanelHeight: root.expandedPanelHeight
147405 openedHeight: root.height
148406
149− overFlowWidth: {
150− if (callHint.visible) {
151− return Math.max(root.width - (callHint.width + units.gu(2)), 0)
152− }
153− return root.width
154− }
155− enableHint: !callHint.active && !fullscreenMode
156− showOnClick: !callHint.visible
157− panelColor: indicatorAreaBackground.color
407+ overFlowWidth: root.width
408+ enableHint: !fullscreenMode
409+ showOnClick: true
410+ panelColor: panelAreaBackground.color
158411
159− onShowTapped: {
160− if (callHint.active) {
161− callHint.showLiveCall();
162− }
412+ onShownChanged: {
413+ if (d.menuBar) d.menuBar.close();
163414 }
164− }
165415
166− Label {
167− id: titleLabel
168− objectName: "windowDecorationTitle"
169− anchors {
170− left: parent.left
171− right: __indicators.left
172− top: parent.top
173− leftMargin: units.gu(1)
174− rightMargin: units.gu(1)
175− topMargin: units.gu(0.5)
176− bottomMargin: units.gu(0.5)
416+ rowItemDelegate: IndicatorItem {
417+ id: indicatorItem
418+ objectName: identifier+"-panelItem"
419+
420+ property int ownIndex: index
421+ property bool overflow: parent.width - x > __indicators.overFlowWidth
422+ property bool hidden: !expanded && (overflow || !indicatorVisible || hideSessionIndicator || hideKeyboardIndicator)
423+ // HACK for indicator-session
424+ readonly property bool hideSessionIndicator: identifier == "indicator-session" && Math.min(Screen.width, Screen.height) <= units.gu(60)
425+ // HACK for indicator-keyboard
426+ readonly property bool hideKeyboardIndicator: identifier == "indicator-keyboard" && (AccountsService.keymaps.length < 2 || keyboardsModel.count == 0)
427+
428+ height: parent.height
429+ expanded: indicators.expanded
430+ selected: ListView.isCurrentItem
431+
432+ identifier: model.identifier
433+ busName: indicatorProperties.busName
434+ actionsObjectPath: indicatorProperties.actionsObjectPath
435+ menuObjectPath: indicatorProperties.menuObjectPath
436+
437+ opacity: hidden ? 0.0 : 1.0
438+ Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
439+
440+ width: ((expanded || indicatorVisible) && !hideSessionIndicator && !hideKeyboardIndicator) ? implicitWidth : 0
441+
442+ Behavior on width { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
177443 }
178− color: "white"
179− height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin
180− opacity: !windowControlButtons.visible && !root.locked && !callHint.visible ? 1 : 0
181− visible: opacity != 0
182− verticalAlignment: Text.AlignVCenter
183− fontSize: "medium"
184− font.weight: PanelState.buttonsVisible ? Font.Light : Font.Medium
185− text: PanelState.title
186− elide: Text.ElideRight
187− maximumLineCount: 1
188− Behavior on opacity { UbuntuNumberAnimation {} }
189− }
190444
191− // TODO here would the Locally integrated menus come
445+ pageDelegate: IndicatorPage {
446+ id: page
447+ objectName: context + "-page"
448+ context: modelData.identifier
449+ submenuIndex: 0
192450
193− ActiveCallHint {
194− id: __callHint
195− anchors {
196− top: parent.top
197− left: parent.left
451+ menuModel: delegate.menuModel
452+ IndicatorDelegate {
453+ id: delegate
454+ busName: modelData.indicatorProperties.busName
455+ actionsObjectPath: modelData.indicatorProperties.actionsObjectPath
456+ menuObjectPath: modelData.indicatorProperties.menuObjectPath
457+ }
198458 }
199− height: indicators.minimizedPanelHeight
200− visible: active && indicators.state == "initial"
459+
460+ enabled: !applicationMenus.expanded
461+ opacity: !applicationMenus.expanded ? 1 : 0
462+ Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
201463 }
202464 }
203465
204− QtObject {
205− id: d
206− objectName: "panelPriv"
207− readonly property real indicatorHeight: indicators.minimizedPanelHeight
466+ InputDeviceModel {
467+ id: keyboardsModel
468+ deviceFilter: InputInfo.Keyboard
469+ }
470+
471+ IndicatorsLight {
472+ id: indicatorLights
208473 }
209474
210475 states: [
@@ -222,7 +487,7 @@ Item {
222487 when: fullscreenMode
223488 PropertyChanges {
224489 target: indicatorArea;
225− anchors.topMargin: indicators.state === "initial" ? -d.indicatorHeight : 0
490+ anchors.topMargin: indicators.state === "initial" ? - minimizedPanelHeight : 0
226491 opacity: indicators.fullyClosed ? 0.0 : 1.0
227492 }
228493 PropertyChanges {