on xenial help sign in
add window control buttons to panel
3d80664Michael 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+14
@@ -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 {
@@ -148,6 +149,19 @@ Item {
148 }
149 }
149 }
150 }
150
151
152+ WindowControlButtons {
153+ anchors {
154+ left: parent.left
155+ top: parent.top
156+ margins: units.gu(0.7)
157+ }
158+ height: indicators.minimizedPanelHeight - anchors.margins * 2
159+ visible: PanelState.buttonsVisible
160+ onClose: PanelState.close()
161+ onMinimize: PanelState.minimize()
162+ onMaximize: PanelState.maximize()
163+ }
164+
151 PanelSeparatorLine {
165 PanelSeparatorLine {
152 id: indicatorOrangeLine
166 id: indicatorOrangeLine
153 anchors {
167 anchors {
qml/Shell.qml+1−1
@@ -45,7 +45,7 @@ Item {
45 id: shell
45 id: shell
46
46
47 // this is only here to select the width / height of the window if not running fullscreen
47 // this is only here to select the width / height of the window if not running fullscreen
48− property bool tablet: false
48+ property bool tablet: true
49 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
49 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
50 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
50 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
51
51
qml/Stages/DesktopStage.qml+22
@@ -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,12 @@ Item {
54
55
55 QtObject {
56 QtObject {
56 id: priv
57 id: priv
58+
59+ readonly property string focusedAppId: ApplicationManager.focusedApplicationId
60+ onFocusedAppIdChanged: print("focused app id changed", focusedAppId)
61+ readonly property var focusedAppDelegate: focusedAppId ? appRepeater.itemAt(indexOf(focusedAppId)) : null
62+ onFocusedAppDelegateChanged: print("focused app delegate changed", focusedAppDelegate)
63+
57 function indexOf(appId) {
64 function indexOf(appId) {
58 for (var i = 0; i < ApplicationManager.count; i++) {
65 for (var i = 0; i < ApplicationManager.count; i++) {
59 if (ApplicationManager.get(i).appId == appId) {
66 if (ApplicationManager.get(i).appId == appId) {
@@ -64,6 +71,21 @@ Item {
64 }
71 }
65 }
72 }
66
73
74+ Connections {
75+ target: PanelState
76+ onClose: {
77+ ApplicationManager.stopApplication(ApplicationManager.focusedApplicationId)
78+ }
79+ onMinimize: appRepeater.itemAt(0).state = "minimized"
80+ onMaximize: appRepeater.itemAt(0).state = "normal"
81+ }
82+
83+ Binding {
84+ target: PanelState
85+ property: "buttonsVisible"
86+ value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.state === "maximized"
87+ }
88+
67 Repeater {
89 Repeater {
68 id: appRepeater
90 id: appRepeater
69 model: ApplicationManager
91 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 {