Windows QPA: Clean up code checking for the OS version
Use QOperatingSystemVersion for comparisons and remove code for versions < Windows 7. Change-Id: I5a5e3d08a29accd42f170da3ee9c9021ca499f82 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This commit is contained in:
parent
cf7a97a658
commit
a75d42eebe
@ -40,6 +40,7 @@
|
|||||||
#include "qwin10helpers.h"
|
#include "qwin10helpers.h"
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
#include <QtCore/QOperatingSystemVersion>
|
||||||
#include <QtCore/private/qsystemlibrary_p.h>
|
#include <QtCore/private/qsystemlibrary_p.h>
|
||||||
|
|
||||||
#if defined(Q_CC_MINGW)
|
#if defined(Q_CC_MINGW)
|
||||||
@ -115,7 +116,7 @@ static QWindowsComBaseDLL baseComDll;
|
|||||||
|
|
||||||
bool QWindowsComBaseDLL::init()
|
bool QWindowsComBaseDLL::init()
|
||||||
{
|
{
|
||||||
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10 && !isValid()) {
|
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10 && !isValid()) {
|
||||||
QSystemLibrary library(QStringLiteral("combase"));
|
QSystemLibrary library(QStringLiteral("combase"));
|
||||||
roGetActivationFactory =
|
roGetActivationFactory =
|
||||||
reinterpret_cast<RoGetActivationFactory>(library.resolve("RoGetActivationFactory"));
|
reinterpret_cast<RoGetActivationFactory>(library.resolve("RoGetActivationFactory"));
|
||||||
|
@ -191,7 +191,8 @@ void QWindowsUser32DLL::init()
|
|||||||
getDisplayAutoRotationPreferences = (GetDisplayAutoRotationPreferences)library.resolve("GetDisplayAutoRotationPreferences");
|
getDisplayAutoRotationPreferences = (GetDisplayAutoRotationPreferences)library.resolve("GetDisplayAutoRotationPreferences");
|
||||||
setDisplayAutoRotationPreferences = (SetDisplayAutoRotationPreferences)library.resolve("SetDisplayAutoRotationPreferences");
|
setDisplayAutoRotationPreferences = (SetDisplayAutoRotationPreferences)library.resolve("SetDisplayAutoRotationPreferences");
|
||||||
|
|
||||||
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10) { // Appears in 10.0.14393, October 2016
|
if (QOperatingSystemVersion::current()
|
||||||
|
>= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 14393)) {
|
||||||
enableNonClientDpiScaling = (EnableNonClientDpiScaling)library.resolve("EnableNonClientDpiScaling");
|
enableNonClientDpiScaling = (EnableNonClientDpiScaling)library.resolve("EnableNonClientDpiScaling");
|
||||||
getWindowDpiAwarenessContext = (GetWindowDpiAwarenessContext)library.resolve("GetWindowDpiAwarenessContext");
|
getWindowDpiAwarenessContext = (GetWindowDpiAwarenessContext)library.resolve("GetWindowDpiAwarenessContext");
|
||||||
getAwarenessFromDpiAwarenessContext = (GetAwarenessFromDpiAwarenessContext)library.resolve("GetAwarenessFromDpiAwarenessContext");
|
getAwarenessFromDpiAwarenessContext = (GetAwarenessFromDpiAwarenessContext)library.resolve("GetAwarenessFromDpiAwarenessContext");
|
||||||
@ -434,7 +435,7 @@ QString QWindowsContext::registerWindowClass(const QWindow *w)
|
|||||||
// QOpenGLWidget or QQuickWidget later on. That cannot be detected at this stage.
|
// QOpenGLWidget or QQuickWidget later on. That cannot be detected at this stage.
|
||||||
if (w->surfaceType() == QSurface::OpenGLSurface || (flags & Qt::MSWindowsOwnDC))
|
if (w->surfaceType() == QSurface::OpenGLSurface || (flags & Qt::MSWindowsOwnDC))
|
||||||
style |= CS_OWNDC;
|
style |= CS_OWNDC;
|
||||||
if (!(flags & Qt::NoDropShadowWindowHint) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)
|
if (!(flags & Qt::NoDropShadowWindowHint)
|
||||||
&& (type == Qt::Popup || w->property("_q_windowsDropShadow").toBool())) {
|
&& (type == Qt::Popup || w->property("_q_windowsDropShadow").toBool())) {
|
||||||
style |= CS_DROPSHADOW;
|
style |= CS_DROPSHADOW;
|
||||||
}
|
}
|
||||||
@ -852,7 +853,7 @@ static inline bool resizeOnDpiChanged(const QWindow *w)
|
|||||||
|
|
||||||
static bool shouldHaveNonClientDpiScaling(const QWindow *window)
|
static bool shouldHaveNonClientDpiScaling(const QWindow *window)
|
||||||
{
|
{
|
||||||
return QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10
|
return QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10
|
||||||
&& window->isTopLevel()
|
&& window->isTopLevel()
|
||||||
&& !window->property(QWindowsWindow::embeddedNativeParentHandleProperty).isValid()
|
&& !window->property(QWindowsWindow::embeddedNativeParentHandleProperty).isValid()
|
||||||
#if QT_CONFIG(opengl) // /QTBUG-62901, EnableNonClientDpiScaling has problems with GL
|
#if QT_CONFIG(opengl) // /QTBUG-62901, EnableNonClientDpiScaling has problems with GL
|
||||||
|
@ -599,8 +599,8 @@ QString QWindowsShellItem::path() const
|
|||||||
{
|
{
|
||||||
if (isFileSystem())
|
if (isFileSystem())
|
||||||
return QDir::cleanPath(QWindowsShellItem::displayName(m_item, SIGDN_FILESYSPATH));
|
return QDir::cleanPath(QWindowsShellItem::displayName(m_item, SIGDN_FILESYSPATH));
|
||||||
// Check for a "Library" item (Windows 7)
|
// Check for a "Library" item
|
||||||
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7 && isDir())
|
if (isDir())
|
||||||
return QWindowsShellItem::libraryItemDefaultSaveFolder(m_item);
|
return QWindowsShellItem::libraryItemDefaultSaveFolder(m_item);
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
@ -2041,7 +2041,7 @@ bool useHelper(QPlatformTheme::DialogType type)
|
|||||||
return false;
|
return false;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QPlatformTheme::FileDialog:
|
case QPlatformTheme::FileDialog:
|
||||||
return QSysInfo::windowsVersion() >= QSysInfo::WV_XP;
|
return true;
|
||||||
case QPlatformTheme::ColorDialog:
|
case QPlatformTheme::ColorDialog:
|
||||||
#ifdef USE_NATIVE_COLOR_DIALOG
|
#ifdef USE_NATIVE_COLOR_DIALOG
|
||||||
return true;
|
return true;
|
||||||
@ -2062,13 +2062,10 @@ QPlatformDialogHelper *createHelper(QPlatformTheme::DialogType type)
|
|||||||
if (QWindowsIntegration::instance()->options() & QWindowsIntegration::NoNativeDialogs)
|
if (QWindowsIntegration::instance()->options() & QWindowsIntegration::NoNativeDialogs)
|
||||||
return 0;
|
return 0;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QPlatformTheme::FileDialog: // Note: "Windows XP Professional x64 Edition has version number WV_5_2 (WV_2003).
|
case QPlatformTheme::FileDialog:
|
||||||
if (QWindowsIntegration::instance()->options() & QWindowsIntegration::XpNativeDialogs
|
if (QWindowsIntegration::instance()->options() & QWindowsIntegration::XpNativeDialogs)
|
||||||
|| QSysInfo::windowsVersion() <= QSysInfo::WV_2003) {
|
|
||||||
return new QWindowsXpFileDialogHelper();
|
return new QWindowsXpFileDialogHelper();
|
||||||
}
|
return new QWindowsFileDialogHelper;
|
||||||
if (QSysInfo::windowsVersion() > QSysInfo::WV_2003)
|
|
||||||
return new QWindowsFileDialogHelper();
|
|
||||||
case QPlatformTheme::ColorDialog:
|
case QPlatformTheme::ColorDialog:
|
||||||
#ifdef USE_NATIVE_COLOR_DIALOG
|
#ifdef USE_NATIVE_COLOR_DIALOG
|
||||||
return new QWindowsColorDialogHelper();
|
return new QWindowsColorDialogHelper();
|
||||||
|
@ -379,9 +379,7 @@ static PIXELFORMATDESCRIPTOR
|
|||||||
initPixelFormatDescriptor(&pfd);
|
initPixelFormatDescriptor(&pfd);
|
||||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||||
pfd.iLayerType = PFD_MAIN_PLANE;
|
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||||
pfd.dwFlags = PFD_SUPPORT_OPENGL;
|
pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_SUPPORT_COMPOSITION;
|
||||||
if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
|
|
||||||
pfd.dwFlags = PFD_SUPPORT_COMPOSITION;
|
|
||||||
const bool isPixmap = (additional.formatFlags & QWindowsGLRenderToPixmap) != 0;
|
const bool isPixmap = (additional.formatFlags & QWindowsGLRenderToPixmap) != 0;
|
||||||
pfd.dwFlags |= isPixmap ? PFD_DRAW_TO_BITMAP : PFD_DRAW_TO_WINDOW;
|
pfd.dwFlags |= isPixmap ? PFD_DRAW_TO_BITMAP : PFD_DRAW_TO_WINDOW;
|
||||||
if (!(additional.formatFlags & QWindowsGLDirectRendering))
|
if (!(additional.formatFlags & QWindowsGLDirectRendering))
|
||||||
|
@ -130,8 +130,6 @@ static inline QTouchDevice *createTouchDevice()
|
|||||||
QT_NID_INTEGRATED_TOUCH = 0x1, QT_NID_EXTERNAL_TOUCH = 0x02,
|
QT_NID_INTEGRATED_TOUCH = 0x1, QT_NID_EXTERNAL_TOUCH = 0x02,
|
||||||
QT_NID_MULTI_INPUT = 0x40, QT_NID_READY = 0x80 };
|
QT_NID_MULTI_INPUT = 0x40, QT_NID_READY = 0x80 };
|
||||||
|
|
||||||
if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS7)
|
|
||||||
return 0;
|
|
||||||
const int digitizers = GetSystemMetrics(QT_SM_DIGITIZER);
|
const int digitizers = GetSystemMetrics(QT_SM_DIGITIZER);
|
||||||
if (!(digitizers & (QT_NID_INTEGRATED_TOUCH | QT_NID_EXTERNAL_TOUCH)))
|
if (!(digitizers & (QT_NID_INTEGRATED_TOUCH | QT_NID_EXTERNAL_TOUCH)))
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user