on 6bb8a90 help sign in
unity8/qml/Components/WindowControlButtons.qml
97 lines 2.8 kB history raw
1/*
2 * Copyright (C) 2014-2016 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
26 property bool windowIsMaximized: false
28 signal close()
29 signal minimize()
30 signal maximize()
32 MouseArea {
33 id: closeWindowButton
34 objectName: "closeWindowButton"
35 hoverEnabled: true
36 height: parent.height
37 width: height
38 onClicked: root.close()
40 Rectangle {
41 anchors.fill: parent
42 radius: height / 2
43 color: UbuntuColors.red
44 visible: parent.containsMouse
45 }
46 Icon {
47 anchors.fill: parent
48 anchors.margins: units.dp(3)
49 source: "graphics/window-close.svg"
50 color: root.active ? "white" : UbuntuColors.slate
51 }
52 }
54 MouseArea {
55 id: minimizeWindowButton
56 objectName: "minimizeWindowButton"
57 hoverEnabled: true
58 height: parent.height
59 width: height
60 onClicked: root.minimize()
62 Rectangle {
63 anchors.fill: parent
64 radius: height / 2
65 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
66 visible: parent.containsMouse
67 }
68 Icon {
69 anchors.fill: parent
70 anchors.margins: units.dp(3)
71 source: "graphics/window-minimize.svg"
72 color: root.active ? "white" : UbuntuColors.slate
73 }
74 }
76 MouseArea {
77 id: maximizeWindowButton
78 objectName: "maximizeWindowButton"
79 hoverEnabled: true
80 height: parent.height
81 width: height
82 onClicked: root.maximize()
84 Rectangle {
85 anchors.fill: parent
86 radius: height / 2
87 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
88 visible: parent.containsMouse
89 }
90 Icon {
91 anchors.fill: parent
92 anchors.margins: units.dp(3)
93 source: root.windowIsMaximized ? "graphics/window-window.svg" : "graphics/window-maximize.svg"
94 color: root.active ? "white" : UbuntuColors.slate
95 }
96 }