on xenial help sign in
hide the maximize button when the max size is smaller than the desktop
commit45aa60f2371bc9233a75b1f5158c4b3572eb9333 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateFri 27 May 2016, 16:05 (10 years ago) parent5443fdb
4 files changed+20−5
qml/Components/WindowControlButtons.qml+3 qml/Stages/DecoratedWindow.qml+3−4 qml/Stages/DesktopStage.qml+8 qml/Stages/WindowDecoration.qml+6−1
qml/Components/WindowControlButtons.qml+3
@@ -24,6 +24,7 @@ Row {
2424 // to be set from outside
2525 property bool active: false
2626 property bool closeButtonShown: true
27+ property bool maximizeButtonShown: true
2728
2829 signal closeClicked()
2930 signal minimizeClicked()
@@ -90,6 +91,8 @@ Row {
9091 hoverEnabled: true
9192 height: parent.height
9293 width: height
94+ visible: root.maximizeButtonShown
95+
9396 acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
9497 onClicked: {
9598 if (mouse.button == Qt.LeftButton) {
qml/Stages/DecoratedWindow.qml+3−4
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014-2015 Canonical, Ltd.
2+ * Copyright (C) 2014-2016 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -12,8 +12,6 @@
1212 *
1313 * You should have received a copy of the GNU General Public License
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Authors: Michael Zanetti <michael.zanetti@canonical.com>
1715 */
1816
1917import QtQuick 2.4
@@ -31,6 +29,7 @@ FocusScope {
3129 property alias active: decoration.active
3230 readonly property alias title: applicationWindow.title
3331 property alias fullscreen: applicationWindow.fullscreen
32+ property alias maximizeButtonShown: decoration.maximizeButtonShown
3433
3534 readonly property bool decorationShown: !fullscreen
3635 property bool highlightShown: false
@@ -42,7 +41,7 @@ FocusScope {
4241 property alias minimumWidth: applicationWindow.minimumWidth
4342 readonly property int minimumHeight: (root.decorationShown ? decoration.height : 0) + applicationWindow.minimumHeight
4443 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
4645 property alias widthIncrement: applicationWindow.widthIncrement
4746 property alias heightIncrement: applicationWindow.heightIncrement
4847
qml/Stages/DesktopStage.qml+8
@@ -616,6 +616,8 @@ AbstractStage {
616616 surface: model.surface
617617 active: appDelegate.focus
618618 focus: true
619+ maximizeButtonShown: (maximumWidth == 0 || maximumWidth >= appContainer.width) &&
620+ (maximumHeight == 0 || maximumHeight >= appContainer.height)
619621
620622 requestedWidth: appDelegate.requestedWidth
621623 requestedHeight: appDelegate.requestedHeight
@@ -628,6 +630,12 @@ AbstractStage {
628630 onMaximizeVerticallyClicked: appDelegate.maximizedVertically ? appDelegate.restoreFromMaximized() : appDelegate.maximizeVertically()
629631 onMinimizeClicked: appDelegate.minimize()
630632 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+ }
631639 }
632640
633641 WindowedFullscreenPolicy {
qml/Stages/WindowDecoration.qml+6−1
@@ -26,6 +26,7 @@ MouseArea {
2626
2727 property Item target
2828 property alias title: titleLabel.text
29+ property alias maximizeButtonShown: buttons.maximizeButtonShown
2930 property bool active: false
3031 hoverEnabled: true
3132
@@ -35,7 +36,11 @@ MouseArea {
3536 signal maximizeHorizontallyClicked()
3637 signal maximizeVerticallyClicked()
3738
38− onDoubleClicked: root.maximizeClicked()
39+ onDoubleClicked: {
40+ if (maximizeButtonShown) {
41+ root.maximizeClicked();
42+ }
43+ }
3944
4045 QtObject {
4146 id: priv