on 2989086 help sign in
unity8/qml/Components/WindowControlButtons.qml
119 lines 3.4 kB history raw
1/*
2 * Copyright (C) 2014-2015 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 */
17import QtQuick 2.4
18import Ubuntu.Components 1.3
20Row {
21 id: root
22 spacing: units.gu(1)
24 // to be set from outside
25 property bool active: false
27 signal close()
28 signal minimize()
29 signal maximize()
30 signal maximizeVertically()
31 signal maximizeHorizontally()
33 MouseArea {
34 id: closeWindowButton
35 objectName: "closeWindowButton"
36 hoverEnabled: true
37 height: parent.height
38 width: height
39 onClicked: root.close()
41 Rectangle {
42 anchors.centerIn: parent
43 width: units.gu(2)
44 height: units.gu(2)
45 radius: height / 2
46 color: "#ed3146"
47 visible: parent.containsMouse
48 }
49 Icon {
50 width: height
51 height: parent.height *.5
52 anchors.centerIn: parent
53 source: "graphics/window-close.svg"
54 color: root.active ? "white" : "#5d5d5d"
55 keyColor: "black"
56 }
57 }
59 MouseArea {
60 id: minimizeWindowButton
61 objectName: "minimizeWindowButton"
62 hoverEnabled: true
63 height: parent.height
64 width: height
65 onClicked: root.minimize()
67 Rectangle {
68 anchors.centerIn: parent
69 width: units.gu(2)
70 height: units.gu(2)
71 radius: height / 2
72 color: "#888888"
73 visible: parent.containsMouse
74 }
75 Icon {
76 width: height
77 height: parent.height *.5
78 anchors.centerIn: parent
79 source: "graphics/window-minimize.svg"
80 color: root.active ? "white" : "#5d5d5d"
81 keyColor: "black"
82 }
83 }
85 MouseArea {
86 id: maximizeWindowButton
87 objectName: "maximizeWindowButton"
88 hoverEnabled: true
89 height: parent.height
90 width: height
91 acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
92 onClicked: {
93 if (mouse.button == Qt.LeftButton) {
94 root.maximize();
95 } else if (mouse.button == Qt.RightButton) {
96 root.maximizeHorizontally();
97 } else if (mouse.button == Qt.MiddleButton) {
98 root.maximizeVertically();
99 }
100 }
102 Rectangle {
103 anchors.centerIn: parent
104 width: units.gu(2)
105 height: units.gu(2)
106 radius: height / 2
107 color: "#888888"
108 visible: parent.containsMouse
109 }
110 Icon {
111 width: height
112 height: parent.height *.5
113 anchors.centerIn: parent
114 source: "graphics/window-maximize.svg"
115 color: root.active ? "white" : "#5d5d5d"
116 keyColor: "black"
117 }
118 }