summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2014-03-13 12:46:10 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-15 10:45:47 +0100
commit4d56c86f802a49e0fa5481e13ab1f000ff284637 (patch)
tree6f05b48b37524362b2596a3e6af344020a869340 /src/plugins/platforms/cocoa
parentf9e1e595a9a83a93dea98d7b34bf545d06d01387 (diff)
Cocoa: Disable the zoom button when appropriate
Disable the zoom (maximize) button for fixed-size windows and customized windows with the MaximizeButton flag not set. Task-number: QTBUG-37078 Change-Id: I6da88496474713de37b48aa65742203632ba99d6 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm16
2 files changed, 17 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 9128b05746..fe82edd618 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -190,6 +190,7 @@ public:
NSInteger windowLevel(Qt::WindowFlags flags);
NSUInteger windowStyleMask(Qt::WindowFlags flags);
void setWindowShadow(Qt::WindowFlags flags);
+ void setWindowZoomButton(Qt::WindowFlags flags);
void setCurrentContext(QCocoaGLContext *context);
QCocoaGLContext *currentContext() const;
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index c2a0c81b31..957428d043 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -805,6 +805,18 @@ void QCocoaWindow::setWindowShadow(Qt::WindowFlags flags)
[m_nsWindow setHasShadow:(keepShadow ? YES : NO)];
}
+void QCocoaWindow::setWindowZoomButton(Qt::WindowFlags flags)
+{
+ // Disable the zoom (maximize) button for fixed-sized windows and customized
+ // no-WindowMaximizeButtonHint windows. From a Qt perspective it migth be expected
+ // that the button would be removed in the latter case, but disabling it is more
+ // in line with the platform style guidelines.
+ bool fixedSizeNoZoom = (window()->minimumSize().isValid() && window()->maximumSize().isValid()
+ && window()->minimumSize() == window()->maximumSize());
+ bool customizeNoZoom = ((flags & Qt::CustomizeWindowHint) && !(flags & Qt::WindowMaximizeButtonHint));
+ [[m_nsWindow standardWindowButton:NSWindowZoomButton] setEnabled:!(fixedSizeNoZoom || customizeNoZoom)];
+}
+
void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
{
if (m_nsWindow && !m_isNSWindowChild) {
@@ -830,6 +842,7 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
}
}
#endif
+ setWindowZoomButton(flags);
}
m_windowFlags = flags;
@@ -993,6 +1006,9 @@ void QCocoaWindow::propagateSizeHints()
const QSize maximumSize = window()->maximumSize();
[m_nsWindow setContentMaxSize : NSMakeSize(maximumSize.width(), maximumSize.height())];
+ // The window may end up with a fixed size; in this case the zoom button should be disabled.
+ setWindowZoomButton(m_windowFlags);
+
// sizeIncrement is observed to take values of (-1, -1) and (0, 0) for windows that should be
// resizable and that have no specific size increment set. Cocoa expects (1.0, 1.0) in this case.
if (!window()->sizeIncrement().isEmpty())