2 * Copyright (C) 2014-2016 Canonical Ltd.
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.
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.
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/>.
18import Lomiri.Components 1.3
22 spacing: overlayShown ? units.gu(2) : windowIsMaximized ? 0 : units.gu(1)
24 LomiriNumberAnimation {}
27 // to be set from outside
28 property bool active: false
29 property bool windowIsMaximized: false
30 property bool closeButtonShown: true
31 property bool maximizeButtonShown: true
32 property bool minimizeButtonVisible: true
33 property bool overlayShown
35 readonly property color color: theme.palette.normal.baseText
38 signal minimizeClicked()
39 signal maximizeClicked()
40 signal maximizeVerticallyClicked()
41 signal maximizeHorizontallyClicked()
45 objectName: "closeWindowButton"
49 onClicked: root.closeClicked()
50 visible: root.closeButtonShown
54 anchors.margins: windowIsMaximized ? units.dp(3) : 0
56 color: theme.palette.normal.negative
57 visible: parent.containsMouse && !overlayShown
61 anchors.margins: windowIsMaximized ? units.dp(6) : units.dp(3)
62 source: "graphics/window-close.svg"
63 color: root.active ? root.color : LomiriColors.jet
68 id: minimizeWindowButton
69 objectName: "minimizeWindowButton"
73 onClicked: root.minimizeClicked()
74 visible: root.minimizeButtonVisible
78 anchors.margins: windowIsMaximized ? units.dp(3) : 0
80 color: root.active ? LomiriColors.graphite : LomiriColors.ash
81 visible: parent.containsMouse && !overlayShown
85 anchors.margins: windowIsMaximized ? units.dp(6) : units.dp(3)
86 source: "graphics/window-minimize.svg"
87 color: root.active ? root.color : LomiriColors.slate
92 id: maximizeWindowButton
93 objectName: "maximizeWindowButton"
97 visible: root.maximizeButtonShown
98 acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
100 if (mouse.button == Qt.LeftButton) {
101 root.maximizeClicked();
102 } else if (mouse.button == Qt.RightButton) {
103 root.maximizeHorizontallyClicked();
104 } else if (mouse.button == Qt.MiddleButton) {
105 root.maximizeVerticallyClicked();
111 anchors.margins: windowIsMaximized ? units.dp(3) : 0
113 color: root.active ? LomiriColors.graphite : LomiriColors.ash
114 visible: parent.containsMouse && !overlayShown
118 anchors.margins: windowIsMaximized ? units.dp(6) : units.dp(3)
119 source: root.windowIsMaximized ? "graphics/window-window.svg" : "graphics/window-maximize.svg"
120 color: root.active ? root.color : LomiriColors.slate