on xenial help sign in
Add window control buttons to panel for fullscreen applications
e245638Michael Zanetti
qml/Components/PanelState/PanelState.qmlnew file+29
@@ -0,0 +1,29 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+pragma Singleton
18+import QtQuick 2.0
19+
20+QtObject {
21+ id: root
22+
23+ property string title: ""
24+ property bool buttonsVisible: false
25+
26+ signal close()
27+ signal minimize()
28+ signal maximize()
29+}
qml/Components/PanelState/qmldirnew file+1
@@ -0,0 +1 @@
1+singleton PanelState 1.0 PanelState.qml
qml/Components/WindowControlButtons.qmlnew file+60
@@ -0,0 +1,60 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ *
16+ * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17+ */
18+
19+import QtQuick 2.3
20+import Ubuntu.Components 1.1
21+
22+Row {
23+ id: root
24+ spacing: units.gu(0.5)
25+
26+ signal close()
27+ signal minimize()
28+ signal maximize()
29+
30+ Rectangle {
31+ height: parent.height; width: height; radius: height / 2
32+ gradient: Gradient {
33+ GradientStop { color: "#F49073"; position: 0 }
34+ GradientStop { color: "#DF4F1C"; position: 1 }
35+ }
36+ border.width: units.dp(.5)
37+ border.color: "black"
38+ MouseArea { anchors.fill: parent; onClicked: root.close() }
39+ }
40+ Rectangle {
41+ height: parent.height; width: height; radius: height / 2
42+ gradient: Gradient {
43+ GradientStop { color: "#92918C"; position: 0 }
44+ GradientStop { color: "#5E5D58"; position: 1 }
45+ }
46+ border.width: units.dp(.5)
47+ border.color: "black"
48+ MouseArea { anchors.fill: parent; onClicked: root.minimize() }
49+ }
50+ Rectangle {
51+ height: parent.height; width: height; radius: height / 2
52+ gradient: Gradient {
53+ GradientStop { color: "#92918C"; position: 0 }
54+ GradientStop { color: "#5E5D58"; position: 1 }
55+ }
56+ border.width: units.dp(.5)
57+ border.color: "black"
58+ MouseArea { anchors.fill: parent; onClicked: root.maximize() }
59+ }
60+}
qml/Panel/Panel.qml+17−2
@@ -18,6 +18,7 @@ import QtQuick 2.2
18import Ubuntu.Components 1.1
18import Ubuntu.Components 1.1
19import Unity.Application 0.1
19import Unity.Application 0.1
20import "../Components"
20import "../Components"
21+import "../Components/PanelState"
21import ".."
22import ".."
22
23
23Item {
24Item {
@@ -123,7 +124,7 @@ Item {
123 }
124 }
124
125
125 shown: false
126 shown: false
126− width: root.width
127+ width: root.width - (PanelState.buttonsVisible ? windowControlButtons.width : 0)
127 minimizedPanelHeight: units.gu(3)
128 minimizedPanelHeight: units.gu(3)
128 expandedPanelHeight: units.gu(7)
129 expandedPanelHeight: units.gu(7)
129 openedHeight: root.height - indicatorOrangeLine.height
130 openedHeight: root.height - indicatorOrangeLine.height
@@ -148,6 +149,20 @@ Item {
148 }
149 }
149 }
150 }
150
151
152+ WindowControlButtons {
153+ id: windowControlButtons
154+ anchors {
155+ left: parent.left
156+ top: parent.top
157+ margins: units.gu(0.7)
158+ }
159+ height: indicators.minimizedPanelHeight - anchors.margins * 2
160+ visible: PanelState.buttonsVisible
161+ onClose: PanelState.close()
162+ onMinimize: PanelState.minimize()
163+ onMaximize: PanelState.maximize()
164+ }
165+
151 PanelSeparatorLine {
166 PanelSeparatorLine {
152 id: indicatorOrangeLine
167 id: indicatorOrangeLine
153 anchors {
168 anchors {
@@ -161,7 +176,7 @@ Item {
161 id: __callHint
176 id: __callHint
162 anchors {
177 anchors {
163 top: parent.top
178 top: parent.top
164− left: parent.left
179+ left: PanelState.buttonsVisible ? windowControlButtons.right : parent.left
165 }
180 }
166 height: indicators.minimizedPanelHeight
181 height: indicators.minimizedPanelHeight
167 visible: active && indicators.state == "initial"
182 visible: active && indicators.state == "initial"
qml/Stages/DesktopStage.qml+20
@@ -19,6 +19,7 @@
19import QtQuick 2.3
19import QtQuick 2.3
20import Ubuntu.Components 1.1
20import Ubuntu.Components 1.1
21import Unity.Application 0.1
21import Unity.Application 0.1
22+import "../Components/PanelState"
22
23
23Item {
24Item {
24 id: root
25 id: root
@@ -54,6 +55,10 @@ Item {
54
55
55 QtObject {
56 QtObject {
56 id: priv
57 id: priv
58+
59+ readonly property string focusedAppId: ApplicationManager.focusedApplicationId
60+ readonly property var focusedAppDelegate: focusedAppId ? appRepeater.itemAt(indexOf(focusedAppId)) : null
61+
57 function indexOf(appId) {
62 function indexOf(appId) {
58 for (var i = 0; i < ApplicationManager.count; i++) {
63 for (var i = 0; i < ApplicationManager.count; i++) {
59 if (ApplicationManager.get(i).appId == appId) {
64 if (ApplicationManager.get(i).appId == appId) {
@@ -64,6 +69,21 @@ Item {
64 }
69 }
65 }
70 }
66
71
72+ Connections {
73+ target: PanelState
74+ onClose: {
75+ ApplicationManager.stopApplication(ApplicationManager.focusedApplicationId)
76+ }
77+ onMinimize: appRepeater.itemAt(0).state = "minimized"
78+ onMaximize: appRepeater.itemAt(0).state = "normal"
79+ }
80+
81+ Binding {
82+ target: PanelState
83+ property: "buttonsVisible"
84+ value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.state === "maximized"
85+ }
86+
67 Repeater {
87 Repeater {
68 id: appRepeater
88 id: appRepeater
69 model: ApplicationManager
89 model: ApplicationManager
qml/Stages/WindowDecoration.qml+8−30
@@ -18,6 +18,7 @@
18
18
19import QtQuick 2.3
19import QtQuick 2.3
20import Ubuntu.Components 1.1
20import Ubuntu.Components 1.1
21+import "../Components"
21
22
22Item {
23Item {
23 id: root
24 id: root
@@ -42,37 +43,14 @@ Item {
42
43
43 Row {
44 Row {
44 anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: units.gu(0.7) }
45 anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: units.gu(0.7) }
45− spacing: units.gu(0.5)
46+ spacing: units.gu(1)
46 opacity: root.active ? 1 : 0.5
47 opacity: root.active ? 1 : 0.5
47− Rectangle {
48+
49+ WindowControlButtons {
48− height: parent.height; width: height; radius: height / 2
50+ height: parent.height
49− gradient: Gradient {
51+ onClose: root.close();
50− GradientStop { color: "#F49073"; position: 0 }
52+ onMinimize: root.minimize();
51− GradientStop { color: "#DF4F1C"; position: 1 }
53+ onMaximize: root.maximize();
52− }
53− border.width: units.dp(.5)
54− border.color: "black"
55− MouseArea { anchors.fill: parent; onClicked: root.close() }
56− }
57− Rectangle {
58− height: parent.height; width: height; radius: height / 2
59− gradient: Gradient {
60− GradientStop { color: "#92918C"; position: 0 }
61− GradientStop { color: "#5E5D58"; position: 1 }
62− }
63− border.width: units.dp(.5)
64− border.color: "black"
65− MouseArea { anchors.fill: parent; onClicked: root.minimize() }
66− }
67− Rectangle {
68− height: parent.height; width: height; radius: height / 2
69− gradient: Gradient {
70− GradientStop { color: "#92918C"; position: 0 }
71− GradientStop { color: "#5E5D58"; position: 1 }
72− }
73− border.width: units.dp(.5)
74− border.color: "black"
75− MouseArea { anchors.fill: parent; onClicked: root.maximize() }
76 }
54 }
77
55
78 Label {
56 Label {