From 45f80a52c2d01ba14f550e48e32d95748a3ff444 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 18 Jan 2017 09:32:12 +0100 Subject: Windows platform headers: Add isTabletMode() Add a bool function querying Windows 10 tablet mode. Task-number: QTBUG-56831 Change-Id: Ief728a7d80a11ba79f7859033ff4be6ef79bbd4e Reviewed-by: Leena Miettinen Reviewed-by: Joerg Bornemann --- .../windowsfunctions/qwindowswindowfunctions.h | 9 ++++++ .../windowsfunctions/qwindowswindowfunctions.qdoc | 32 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) (limited to 'src/platformheaders/windowsfunctions') diff --git a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h index d0826bdb50..e51c2fde67 100644 --- a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h +++ b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h @@ -90,6 +90,15 @@ public: if (func) func(behavior); } + + typedef bool (*IsTabletModeType)(); + static const QByteArray isTabletModeIdentifier() { return QByteArrayLiteral("WindowsIsTabletMode"); } + + static bool isTabletMode() + { + IsTabletModeType func = reinterpret_cast(QGuiApplication::platformFunction(isTabletModeIdentifier())); + return func && func(); + } }; Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowsWindowFunctions::TouchWindowTouchTypes) diff --git a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc index 24e4847042..898b1bbb29 100644 --- a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc +++ b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc @@ -144,3 +144,35 @@ \sa QWidget::activateWindow(), QWindow::requestActivate() \since 5.7 */ + +/*! + \typedef QWindowsWindowFunctions::IsTabletModeType + + This is the typedef for the function returned by QGuiApplication::platformFunction() + when passed isTabletModeIdentifier(). + + \since 5.9 +*/ + +/*! + \fn QByteArray QWindowsWindowFunctions::isTabletModeIdentifier() + + Returns a bytearray that can be used to query + QGuiApplication::platformFunction() to retrieve the IsTabletModeType + function. + + \since 5.9 +*/ + +/*! + \fn bool QWindowsWindowFunctions::isTabletMode() + + This is a convenience function that can be used directly instead of resolving + the function pointer. The function can be used to query whether Windows 10 + operates in \e{Tablet Mode}. In this mode, Windows forces all application + main windows to open in maximized state. Applications should then avoid + resizing windows or restoring geometries to non-maximized states. + + \sa QWidget::showMaximized(), QWidget::saveGeometry(), QWidget::restoreGeometry() + \since 5.9 +*/ -- cgit v1.2.3