on xenial help sign in
hide the maximize button when the max size is smaller than the desktop
45aa60fLukáš Tinkl
qml/Components/WindowControlButtons.qml+3
@@ -24,6 +24,7 @@ Row {
24 // to be set from outside
24 // to be set from outside
25 property bool active: false
25 property bool active: false
26 property bool closeButtonShown: true
26 property bool closeButtonShown: true
27+ property bool maximizeButtonShown: true
27
28
28 signal closeClicked()
29 signal closeClicked()
29 signal minimizeClicked()
30 signal minimizeClicked()
@@ -90,6 +91,8 @@ Row {
90 hoverEnabled: true
91 hoverEnabled: true
91 height: parent.height
92 height: parent.height
92 width: height
93 width: height
94+ visible: root.maximizeButtonShown
95+
93 acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
96 acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
94 onClicked: {
97 onClicked: {
95 if (mouse.button == Qt.LeftButton) {
98 if (mouse.button == Qt.LeftButton) {
qml/Stages/DecoratedWindow.qml+3−4
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014-2015 Canonical, Ltd.
2+ * Copyright (C) 2014-2016 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -12,8 +12,6 @@
12 *
12 *
13 * You should have received a copy of the GNU General Public License
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/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17 */
15 */
18
16
19import QtQuick 2.4
17import QtQuick 2.4
@@ -31,6 +29,7 @@ FocusScope {
31 property alias active: decoration.active
29 property alias active: decoration.active
32 readonly property alias title: applicationWindow.title
30 readonly property alias title: applicationWindow.title
33 property alias fullscreen: applicationWindow.fullscreen
31 property alias fullscreen: applicationWindow.fullscreen
32+ property alias maximizeButtonShown: decoration.maximizeButtonShown
34
33
35 readonly property bool decorationShown: !fullscreen
34 readonly property bool decorationShown: !fullscreen
36 property bool highlightShown: false
35 property bool highlightShown: false
@@ -42,7 +41,7 @@ FocusScope {
42 property alias minimumWidth: applicationWindow.minimumWidth
41 property alias minimumWidth: applicationWindow.minimumWidth
43 readonly property int minimumHeight: (root.decorationShown ? decoration.height : 0) + applicationWindow.minimumHeight
42 readonly property int minimumHeight: (root.decorationShown ? decoration.height : 0) + applicationWindow.minimumHeight
44 property alias maximumWidth: applicationWindow.maximumWidth
43 property alias maximumWidth: applicationWindow.maximumWidth
45− readonly property int maximumHeight: (root.decorationShown ? decoration.height : 0) + applicationWindow.maximumHeight
44+ readonly property int maximumHeight: (root.decorationShown && applicationWindow.maximumHeight > 0 ? decoration.height : 0) + applicationWindow.maximumHeight
46 property alias widthIncrement: applicationWindow.widthIncrement
45 property alias widthIncrement: applicationWindow.widthIncrement
47 property alias heightIncrement: applicationWindow.heightIncrement
46 property alias heightIncrement: applicationWindow.heightIncrement
48
47
qml/Stages/DesktopStage.qml+8
@@ -616,6 +616,8 @@ AbstractStage {
616 surface: model.surface
616 surface: model.surface
617 active: appDelegate.focus
617 active: appDelegate.focus
618 focus: true
618 focus: true
619+ maximizeButtonShown: (maximumWidth == 0 || maximumWidth >= appContainer.width) &&
620+ (maximumHeight == 0 || maximumHeight >= appContainer.height)
619
621
620 requestedWidth: appDelegate.requestedWidth
622 requestedWidth: appDelegate.requestedWidth
621 requestedHeight: appDelegate.requestedHeight
623 requestedHeight: appDelegate.requestedHeight
@@ -628,6 +630,12 @@ AbstractStage {
628 onMaximizeVerticallyClicked: appDelegate.maximizedVertically ? appDelegate.restoreFromMaximized() : appDelegate.maximizeVertically()
630 onMaximizeVerticallyClicked: appDelegate.maximizedVertically ? appDelegate.restoreFromMaximized() : appDelegate.maximizeVertically()
629 onMinimizeClicked: appDelegate.minimize()
631 onMinimizeClicked: appDelegate.minimize()
630 onDecorationPressed: { appDelegate.focus = true; }
632 onDecorationPressed: { appDelegate.focus = true; }
633+
634+ Component.onCompleted: {
635+ print("Window:", objectName);
636+ print("Width:", width, ", maximum width:", maximumWidth, ", desktop width:", appContainer.width);
637+ print("Height:", height, ", maximum height:", maximumHeight, ", desktop height:", appContainer.height);
638+ }
631 }
639 }
632
640
633 WindowedFullscreenPolicy {
641 WindowedFullscreenPolicy {
qml/Stages/WindowDecoration.qml+6−1
@@ -26,6 +26,7 @@ MouseArea {
26
26
27 property Item target
27 property Item target
28 property alias title: titleLabel.text
28 property alias title: titleLabel.text
29+ property alias maximizeButtonShown: buttons.maximizeButtonShown
29 property bool active: false
30 property bool active: false
30 hoverEnabled: true
31 hoverEnabled: true
31
32
@@ -35,7 +36,11 @@ MouseArea {
35 signal maximizeHorizontallyClicked()
36 signal maximizeHorizontallyClicked()
36 signal maximizeVerticallyClicked()
37 signal maximizeVerticallyClicked()
37
38
39+ onDoubleClicked: {
40+ if (maximizeButtonShown) {
38− onDoubleClicked: root.maximizeClicked()
41+ root.maximizeClicked();
42+ }
43+ }
39
44
40 QtObject {
45 QtObject {
41 id: priv
46 id: priv