diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2012-03-29 12:55:12 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-13 08:33:43 +0200 |
commit | fe0f72fa1a01c41c020afcb95acd503a8dca3a8a (patch) | |
tree | dd1e00a3b94ac42a4de2e7212ac197949a353541 /src/plugins/platforms/windows/qwindowswindow.cpp | |
parent | 58ac4658c17ae120856235bd23727564cd4f67e2 (diff) |
Implement modality in the Windows plugin.
Disable blocked windows and flash the active window if
a blocked one is activated (as in Qt 4).
Change-Id: I6b6d230f94a271ce2aa649e3f4e13ebd63e93da4
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowswindow.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 2b86d069ab..453838ac07 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1194,6 +1194,22 @@ void QWindowsWindow::lower() SetWindowPos(m_data.hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); } +void QWindowsWindow::windowEvent(QEvent *event) +{ + switch (event->type()) { + case QEvent::WindowBlocked: // Blocked by another modal window. + setEnabled(false); + setFlag(BlockedByModal); + break; + case QEvent::WindowUnblocked: + setEnabled(true); + clearFlag(BlockedByModal); + break; + default: + break; + } +} + void QWindowsWindow::propagateSizeHints() { if (QWindowsContext::verboseWindows) @@ -1354,6 +1370,50 @@ QWindowsWindow *QWindowsWindow::childAt(const QPoint &clientPoint, unsigned cwex return 0; } +void QWindowsWindow::alertWindow(int durationMs) +{ + DWORD timeOutMs = GetCaretBlinkTime(); + if (!timeOutMs || timeOutMs == INFINITE) + timeOutMs = 250; + + FLASHWINFO info; + info.cbSize = sizeof(info); + info.hwnd = m_data.hwnd; + info.dwFlags = FLASHW_TRAY; + info.dwTimeout = timeOutMs; + info.uCount = durationMs == 0 ? 10 : durationMs / timeOutMs; + FlashWindowEx(&info); +} + +void QWindowsWindow::stopAlertWindow() +{ + FLASHWINFO info; + info.cbSize = sizeof(info); + info.hwnd = m_data.hwnd; + info.dwFlags = FLASHW_STOP; + info.dwTimeout = 0; + info.uCount = 0; + FlashWindowEx(&info); +} + +bool QWindowsWindow::isEnabled() const +{ + return (style() & WS_DISABLED) == 0; +} + +void QWindowsWindow::setEnabled(bool enabled) +{ + const unsigned oldStyle = style(); + unsigned newStyle = oldStyle; + if (enabled) { + newStyle &= ~WS_DISABLED; + } else { + newStyle |= WS_DISABLED; + } + if (newStyle != oldStyle) + setStyle(newStyle); +} + QByteArray QWindowsWindow::debugWindowFlags(Qt::WindowFlags wf) { const int iwf = int(wf); |