From 271d929ad6c380ffacba0fa2addcfd77045a2028 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 3 Jun 2019 13:48:36 +0300 Subject: [PATCH] Use VersionHelper API for Windows version. --- .../SourceFiles/platform/win/launcher_win.cpp | 24 ++++++++++++------- .../platform/win/main_window_win.cpp | 3 ++- .../SourceFiles/platform/win/windows_dlls.cpp | 6 ++--- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Telegram/SourceFiles/platform/win/launcher_win.cpp b/Telegram/SourceFiles/platform/win/launcher_win.cpp index dac5c205e..0c460a7d5 100644 --- a/Telegram/SourceFiles/platform/win/launcher_win.cpp +++ b/Telegram/SourceFiles/platform/win/launcher_win.cpp @@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/win/wrapper_windows_h.h" #include +#include namespace Platform { namespace { @@ -22,15 +23,20 @@ QString DeviceModel() { } QString SystemVersion() { - switch (QSysInfo::windowsVersion()) { - case QSysInfo::WV_XP: return "Windows XP"; - case QSysInfo::WV_2003: return "Windows 2003"; - case QSysInfo::WV_VISTA: return "Windows Vista"; - case QSysInfo::WV_WINDOWS7: return "Windows 7"; - case QSysInfo::WV_WINDOWS8: return "Windows 8"; - case QSysInfo::WV_WINDOWS8_1: return "Windows 8.1"; - case QSysInfo::WV_WINDOWS10: return "Windows 10"; - default: return "Windows"; + if (IsWindows10OrGreater()) { + return "Windows 10"; + } else if (IsWindows8Point1OrGreater()) { + return "Windows 8.1"; + } else if (IsWindows8OrGreater()) { + return "Windows 8"; + } else if (IsWindows7OrGreater()) { + return "Windows 7"; + } else if (IsWindowsVistaOrGreater()) { + return "Windows Vista"; + } else if (IsWindowsXPOrGreater()) { + return "Windows XP"; + } else { + return QSysInfo::prettyProductName(); } } diff --git a/Telegram/SourceFiles/platform/win/main_window_win.cpp b/Telegram/SourceFiles/platform/win/main_window_win.cpp index 3f1f6b372..737636de5 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.cpp +++ b/Telegram/SourceFiles/platform/win/main_window_win.cpp @@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include +#include #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) < (b) ? (b) : (a)) @@ -925,7 +926,7 @@ void MainWindow::psUpdateMargins() { } if (!_themeInited) { _themeInited = true; - if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8) { + if (!IsWindows8OrGreater()) { if (Dlls::SetWindowTheme != nullptr) { Dlls::SetWindowTheme(ps_hWnd, L" ", L" "); QApplication::setStyle(QStyleFactory::create(qsl("Windows"))); diff --git a/Telegram/SourceFiles/platform/win/windows_dlls.cpp b/Telegram/SourceFiles/platform/win/windows_dlls.cpp index bb3d66c9d..ec40c3f58 100644 --- a/Telegram/SourceFiles/platform/win/windows_dlls.cpp +++ b/Telegram/SourceFiles/platform/win/windows_dlls.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "platform/win/windows_dlls.h" +#include #include namespace Platform { @@ -76,8 +77,7 @@ void start() { LibUxTheme = LoadLibrary(L"UXTHEME.DLL"); load(LibUxTheme, "SetWindowTheme", SetWindowTheme); - auto version = QSysInfo::windowsVersion(); - if (version >= QSysInfo::WV_VISTA) { + if (IsWindowsVistaOrGreater()) { LibWtsApi32 = LoadLibrary(L"WTSAPI32.DLL"); load(LibWtsApi32, "WTSRegisterSessionNotification", WTSRegisterSessionNotification); load(LibWtsApi32, "WTSUnRegisterSessionNotification", WTSUnRegisterSessionNotification); @@ -86,7 +86,7 @@ void start() { load(LibPropSys, "PropVariantToString", PropVariantToString); load(LibPropSys, "PSStringFromPropertyKey", PSStringFromPropertyKey); - if (version >= QSysInfo::WV_WINDOWS8) { + if (IsWindows8OrGreater()) { LibComBase = LoadLibrary(L"COMBASE.DLL"); load(LibComBase, "RoGetActivationFactory", RoGetActivationFactory); load(LibComBase, "WindowsCreateStringReference", WindowsCreateStringReference);