QMessageBox: Clean up some Q_WS_WIN code.
Enable 'Close' of system menu according to whether escape button is present. Change-Id: I305e4732f781dbe2d81c2503ee278ec33579acdb Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
This commit is contained in:
parent
37a7b035f8
commit
b0a0403daf
@ -65,20 +65,27 @@
|
|||||||
#include <QtGui/qfontmetrics.h>
|
#include <QtGui/qfontmetrics.h>
|
||||||
#include <QtGui/qclipboard.h>
|
#include <QtGui/qclipboard.h>
|
||||||
|
|
||||||
#ifndef QT_NO_STYLE_S60
|
#ifdef Q_OS_WIN
|
||||||
#include <qs60style.h>
|
# include <QtCore/qt_windows.h>
|
||||||
#endif
|
# include <QtGui/QPlatformNativeInterface>
|
||||||
|
|
||||||
#ifdef Q_WS_WINCE
|
|
||||||
extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp
|
|
||||||
extern bool qt_wince_is_smartphone();//defined in qguifunctions_wince.cpp
|
|
||||||
extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wince.cpp
|
|
||||||
|
|
||||||
#include "qguifunctions_wince.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
static inline HMENU qt_getWindowsSystemMenu(const QWidget *w)
|
||||||
|
{
|
||||||
|
QWindow *window = w->windowHandle();
|
||||||
|
if (!window)
|
||||||
|
if (const QWidget *nativeParent = w->nativeParentWidget())
|
||||||
|
window = nativeParent->windowHandle();
|
||||||
|
if (window)
|
||||||
|
if (void *handle = QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", window))
|
||||||
|
return GetSystemMenu(reinterpret_cast<HWND>(handle), FALSE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6,
|
enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6,
|
||||||
Old_Ignore = 7, Old_YesAll = 8, Old_NoAll = 9, Old_ButtonMask = 0xFF,
|
Old_Ignore = 7, Old_YesAll = 8, Old_NoAll = 9, Old_ButtonMask = 0xFF,
|
||||||
NewButtonMask = 0xFFFFFC00 };
|
NewButtonMask = 0xFFFFFC00 };
|
||||||
@ -1480,13 +1487,10 @@ void QMessageBox::showEvent(QShowEvent *e)
|
|||||||
#ifndef QT_NO_ACCESSIBILITY
|
#ifndef QT_NO_ACCESSIBILITY
|
||||||
QAccessible::updateAccessibility(this, 0, QAccessible::Alert);
|
QAccessible::updateAccessibility(this, 0, QAccessible::Alert);
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
HMENU systemMenu = GetSystemMenu((HWND)winId(), FALSE);
|
if (const HMENU systemMenu = qt_getWindowsSystemMenu(this)) {
|
||||||
if (!d->detectedEscapeButton) {
|
EnableMenuItem(systemMenu, SC_CLOSE, d->detectedEscapeButton ?
|
||||||
EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED);
|
MF_BYCOMMAND|MF_ENABLED : MF_BYCOMMAND|MF_GRAYED);
|
||||||
}
|
|
||||||
else {
|
|
||||||
EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_ENABLED);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
QDialog::showEvent(e);
|
QDialog::showEvent(e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user