Update the window style when the modality changes on Cocoa
On Cocoa if the modality of a dialog changes then the style of the window needs to change to reflect this. So we add a variable to cache the windows modality when it is created to compare against when being made visible. Task-number: QTBUG-22316 Change-Id: I7bfd016321510a9ec70ccb90672f5203a0f3a468 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
This commit is contained in:
parent
1fb3d849e4
commit
595deca5c9
@ -157,6 +157,7 @@ public: // for QNSView
|
|||||||
NSWindow *m_nsWindow;
|
NSWindow *m_nsWindow;
|
||||||
Qt::WindowFlags m_windowFlags;
|
Qt::WindowFlags m_windowFlags;
|
||||||
Qt::WindowState m_synchedWindowState;
|
Qt::WindowState m_synchedWindowState;
|
||||||
|
Qt::WindowModality m_windowModality;
|
||||||
QPointer<QWindow> m_activePopupWindow;
|
QPointer<QWindow> m_activePopupWindow;
|
||||||
|
|
||||||
bool m_inConstructor;
|
bool m_inConstructor;
|
||||||
|
@ -187,6 +187,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
|
|||||||
: QPlatformWindow(tlw)
|
: QPlatformWindow(tlw)
|
||||||
, m_nsWindow(0)
|
, m_nsWindow(0)
|
||||||
, m_synchedWindowState(Qt::WindowActive)
|
, m_synchedWindowState(Qt::WindowActive)
|
||||||
|
, m_windowModality(Qt::NonModal)
|
||||||
, m_inConstructor(true)
|
, m_inConstructor(true)
|
||||||
, m_glContext(0)
|
, m_glContext(0)
|
||||||
, m_menubar(0)
|
, m_menubar(0)
|
||||||
@ -248,6 +249,9 @@ void QCocoaWindow::setVisible(bool visible)
|
|||||||
qDebug() << "QCocoaWindow::setVisible" << window() << visible;
|
qDebug() << "QCocoaWindow::setVisible" << window() << visible;
|
||||||
#endif
|
#endif
|
||||||
if (visible) {
|
if (visible) {
|
||||||
|
// We need to recreate if the modality has changed as the style mask will need updating
|
||||||
|
if (m_windowModality != window()->windowModality())
|
||||||
|
recreateWindow(parent());
|
||||||
QCocoaWindow *parentCocoaWindow = 0;
|
QCocoaWindow *parentCocoaWindow = 0;
|
||||||
if (window()->transientParent()) {
|
if (window()->transientParent()) {
|
||||||
parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle());
|
parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle());
|
||||||
@ -359,6 +363,8 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags)
|
|||||||
Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint;
|
Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint;
|
||||||
if (flags == Qt::Window) {
|
if (flags == Qt::Window) {
|
||||||
styleMask = (NSResizableWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSTitledWindowMask);
|
styleMask = (NSResizableWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSTitledWindowMask);
|
||||||
|
} else if ((flags & Qt::Dialog) && (window()->windowModality() != Qt::NonModal)) {
|
||||||
|
styleMask = NSTitledWindowMask;
|
||||||
} else if (!(flags & Qt::FramelessWindowHint)) {
|
} else if (!(flags & Qt::FramelessWindowHint)) {
|
||||||
if (flags & Qt::WindowMaximizeButtonHint)
|
if (flags & Qt::WindowMaximizeButtonHint)
|
||||||
styleMask |= NSResizableWindowMask;
|
styleMask |= NSResizableWindowMask;
|
||||||
@ -655,7 +661,7 @@ NSWindow * QCocoaWindow::createNSWindow()
|
|||||||
|
|
||||||
NSInteger level = windowLevel(flags);
|
NSInteger level = windowLevel(flags);
|
||||||
[createdWindow setLevel:level];
|
[createdWindow setLevel:level];
|
||||||
|
m_windowModality = window()->windowModality();
|
||||||
return createdWindow;
|
return createdWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user