forked from github_mirror/framelesshelper
win: minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
ca8e9f555d
commit
e2f7c76c88
|
@ -132,20 +132,22 @@ if(FRAMELESSHELPER_BUILD_EXAMPLES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message("#######################################")
|
message("#######################################")
|
||||||
message("CMAKE_VERSION: ${CMAKE_VERSION}")
|
message("CMake version: ${CMAKE_VERSION}")
|
||||||
message("CMAKE_HOST_SYSTEM: ${CMAKE_HOST_SYSTEM}")
|
message("Host system: ${CMAKE_HOST_SYSTEM}")
|
||||||
message("CMAKE_HOST_SYSTEM_PROCESSOR: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
message("Host processor: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
||||||
#message("CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}") # Currently we are not using any C compilers.
|
#message("C compiler: ${CMAKE_C_COMPILER}") # Currently we are not using any C compilers.
|
||||||
message("CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
|
message("C++ compiler: ${CMAKE_CXX_COMPILER}")
|
||||||
message("CMAKE_LINKER: ${CMAKE_LINKER}")
|
message("Linker: ${CMAKE_LINKER}")
|
||||||
message("CMAKE_MAKE_PROGRAM: ${CMAKE_MAKE_PROGRAM}")
|
message("Make program: ${CMAKE_MAKE_PROGRAM}")
|
||||||
message("CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
|
message("Build type: ${CMAKE_BUILD_TYPE}")
|
||||||
message("#######################################")
|
message("#######################################")
|
||||||
|
set(__qt_inst_dir UNKNOWN)
|
||||||
if(DEFINED Qt6_DIR)
|
if(DEFINED Qt6_DIR)
|
||||||
message("Qt installation dir: ${Qt6_DIR}")
|
set(__qt_inst_dir "${Qt6_DIR}")
|
||||||
else()
|
else()
|
||||||
message("Qt installation dir: ${Qt5_DIR}")
|
set(__qt_inst_dir "${Qt5_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
message("Qt install dir: ${__qt_inst_dir}")
|
||||||
message("Qt version: ${QT_VERSION}")
|
message("Qt version: ${QT_VERSION}")
|
||||||
# TODO: output shared/static Qt.
|
# TODO: output shared/static Qt.
|
||||||
message("#######################################")
|
message("#######################################")
|
||||||
|
|
|
@ -301,6 +301,7 @@ enum class WindowsVersion
|
||||||
_2000 = 0,
|
_2000 = 0,
|
||||||
_XP = 1,
|
_XP = 1,
|
||||||
_XP_64 = 2,
|
_XP_64 = 2,
|
||||||
|
_WS_03 = _XP_64, // Windows Server 2003
|
||||||
_Vista = 3,
|
_Vista = 3,
|
||||||
_Vista_SP1 = 4,
|
_Vista_SP1 = 4,
|
||||||
_Vista_SP2 = 5,
|
_Vista_SP2 = 5,
|
||||||
|
@ -322,8 +323,10 @@ enum class WindowsVersion
|
||||||
_10_20H2 = 21,
|
_10_20H2 = 21,
|
||||||
_10_21H1 = 22,
|
_10_21H1 = 22,
|
||||||
_10_21H2 = 23,
|
_10_21H2 = 23,
|
||||||
|
_10 = _10_1507,
|
||||||
_11_21H2 = 24,
|
_11_21H2 = 24,
|
||||||
_11_22H2 = 25,
|
_11_22H2 = 25,
|
||||||
|
_11 = _11_21H2,
|
||||||
Latest = _11_22H2
|
Latest = _11_22H2
|
||||||
};
|
};
|
||||||
Q_ENUM_NS(WindowsVersion)
|
Q_ENUM_NS(WindowsVersion)
|
||||||
|
@ -407,6 +410,9 @@ struct VersionNumber
|
||||||
|
|
||||||
[[nodiscard]] friend constexpr bool operator>(const VersionNumber &lhs, const VersionNumber &rhs) noexcept
|
[[nodiscard]] friend constexpr bool operator>(const VersionNumber &lhs, const VersionNumber &rhs) noexcept
|
||||||
{
|
{
|
||||||
|
if (operator==(lhs, rhs)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (lhs.major > rhs.major) {
|
if (lhs.major > rhs.major) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -425,13 +431,7 @@ struct VersionNumber
|
||||||
if (lhs.patch < rhs.patch) {
|
if (lhs.patch < rhs.patch) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (lhs.tweak > rhs.tweak) {
|
return (lhs.tweak > rhs.tweak);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (lhs.tweak < rhs.tweak) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] friend constexpr bool operator<(const VersionNumber &lhs, const VersionNumber &rhs) noexcept
|
[[nodiscard]] friend constexpr bool operator<(const VersionNumber &lhs, const VersionNumber &rhs) noexcept
|
||||||
|
|
|
@ -31,34 +31,38 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
namespace WindowsVersionHelper
|
namespace WindowsVersionHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin2KOrGreater();
|
#define DECL(Name) [[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin##Name##OrGreater();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWinXPOrGreater();
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWinXP64OrGreater();
|
DECL(2K)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWinVistaOrGreater();
|
DECL(XP)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWinVistaSP1OrGreater();
|
DECL(XP64)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWinVistaSP2OrGreater();
|
DECL(Vista)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin7OrGreater();
|
DECL(VistaSP1)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin7SP1OrGreater();
|
DECL(VistaSP2)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin8OrGreater();
|
DECL(7)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin8Point1OrGreater();
|
DECL(7SP1)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin8Point1Update1OrGreater();
|
DECL(8)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin10OrGreater();
|
DECL(8Point1)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin10TH1OrGreater();
|
DECL(8Point1Update1)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin10TH2OrGreater();
|
DECL(10)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin10RS1OrGreater();
|
DECL(10TH1)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin10RS2OrGreater();
|
DECL(10TH2)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin10RS3OrGreater();
|
DECL(10RS1)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin10RS4OrGreater();
|
DECL(10RS2)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin10RS5OrGreater();
|
DECL(10RS3)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin1019H1OrGreater();
|
DECL(10RS4)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin1019H2OrGreater();
|
DECL(10RS5)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin1020H1OrGreater();
|
DECL(1019H1)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin1020H2OrGreater();
|
DECL(1019H2)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin21H1OrGreater();
|
DECL(1020H1)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin21H2OrGreater();
|
DECL(1020H2)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin11OrGreater();
|
DECL(1021H1)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin1121H2OrGreater();
|
DECL(1021H2)
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin1122H2OrGreater();
|
DECL(11)
|
||||||
|
DECL(1121H2)
|
||||||
|
DECL(1122H2)
|
||||||
|
|
||||||
|
#undef DECL
|
||||||
|
|
||||||
} // namespace WindowsVersionHelper
|
} // namespace WindowsVersionHelper
|
||||||
|
|
||||||
|
|
|
@ -29,175 +29,119 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
using namespace Global;
|
using namespace Global;
|
||||||
|
|
||||||
namespace WindowsVersionHelper
|
class WinVerHelper
|
||||||
{
|
{
|
||||||
|
Q_DISABLE_COPY_MOVE(WinVerHelper)
|
||||||
|
|
||||||
bool isWin2KOrGreater()
|
public:
|
||||||
|
explicit WinVerHelper();
|
||||||
|
~WinVerHelper();
|
||||||
|
|
||||||
|
[[nodiscard]] bool check(const WindowsVersion version) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initialize();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_flags[static_cast<int>(WindowsVersion::Latest) + 1] = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
WinVerHelper::WinVerHelper()
|
||||||
{
|
{
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_2000);
|
initialize();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isWinXPOrGreater()
|
WinVerHelper::~WinVerHelper() = default;
|
||||||
|
|
||||||
|
bool WinVerHelper::check(const WindowsVersion version) const
|
||||||
{
|
{
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_XP);
|
return m_flags[static_cast<int>(version)];
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isWinXP64OrGreater()
|
void WinVerHelper::initialize()
|
||||||
{
|
{
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_XP_64);
|
const auto fill = [this](const int no) -> void {
|
||||||
return result;
|
static const auto size = int(std::size(m_flags));
|
||||||
|
if ((no <= 0) || (no >= size)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i != size; ++i) {
|
||||||
|
m_flags[i] = (i <= no);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#define ELIF(Version) \
|
||||||
|
else if (Utils::isWindowsVersionOrGreater(WindowsVersion::_##Version)) { \
|
||||||
|
fill(static_cast<int>(WindowsVersion::_##Version)); \
|
||||||
|
}
|
||||||
|
if (false) { /* Dummy */ }
|
||||||
|
ELIF(11_22H2)
|
||||||
|
ELIF(11_21H2)
|
||||||
|
ELIF(10_21H2)
|
||||||
|
ELIF(10_21H1)
|
||||||
|
ELIF(10_20H2)
|
||||||
|
ELIF(10_2004)
|
||||||
|
ELIF(10_1909)
|
||||||
|
ELIF(10_1903)
|
||||||
|
ELIF(10_1809)
|
||||||
|
ELIF(10_1803)
|
||||||
|
ELIF(10_1709)
|
||||||
|
ELIF(10_1703)
|
||||||
|
ELIF(10_1607)
|
||||||
|
ELIF(10_1511)
|
||||||
|
ELIF(10_1507)
|
||||||
|
ELIF(8_1_Update1)
|
||||||
|
ELIF(8_1)
|
||||||
|
ELIF(8)
|
||||||
|
ELIF(7_SP1)
|
||||||
|
ELIF(7)
|
||||||
|
ELIF(Vista_SP2)
|
||||||
|
ELIF(Vista_SP1)
|
||||||
|
ELIF(Vista)
|
||||||
|
ELIF(XP_64)
|
||||||
|
ELIF(XP)
|
||||||
|
ELIF(2000)
|
||||||
|
else { /* Dummy */ }
|
||||||
|
#undef ELIF
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isWinVistaOrGreater()
|
Q_GLOBAL_STATIC(WinVerHelper, g_winVerHelper)
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_Vista);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWinVistaSP1OrGreater()
|
#define IMPL(Name, Version) \
|
||||||
{
|
bool WindowsVersionHelper::isWin##Name##OrGreater() \
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_Vista_SP1);
|
{ \
|
||||||
return result;
|
static const bool result = g_winVerHelper()->check(WindowsVersion::_##Version); \
|
||||||
}
|
return result; \
|
||||||
|
}
|
||||||
|
|
||||||
bool isWinVistaSP2OrGreater()
|
IMPL(2K, 2000)
|
||||||
{
|
IMPL(XP, XP)
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_Vista_SP2);
|
IMPL(XP64, XP_64)
|
||||||
return result;
|
IMPL(Vista, Vista)
|
||||||
}
|
IMPL(VistaSP1, Vista_SP1)
|
||||||
|
IMPL(VistaSP2, Vista_SP2)
|
||||||
|
IMPL(7, 7)
|
||||||
|
IMPL(7SP1, 7_SP1)
|
||||||
|
IMPL(8, 8)
|
||||||
|
IMPL(8Point1, 8_1)
|
||||||
|
IMPL(8Point1Update1, 8_1_Update1)
|
||||||
|
IMPL(10, 10)
|
||||||
|
IMPL(10TH1, 10_1507)
|
||||||
|
IMPL(10TH2, 10_1511)
|
||||||
|
IMPL(10RS1, 10_1607)
|
||||||
|
IMPL(10RS2, 10_1703)
|
||||||
|
IMPL(10RS3, 10_1709)
|
||||||
|
IMPL(10RS4, 10_1803)
|
||||||
|
IMPL(10RS5, 10_1809)
|
||||||
|
IMPL(1019H1, 10_1903)
|
||||||
|
IMPL(1019H2, 10_1909)
|
||||||
|
IMPL(1020H1, 10_2004)
|
||||||
|
IMPL(1020H2, 10_20H2)
|
||||||
|
IMPL(1021H1, 10_21H1)
|
||||||
|
IMPL(1021H2, 10_21H2)
|
||||||
|
IMPL(11, 11)
|
||||||
|
IMPL(1121H2, 11_21H2)
|
||||||
|
IMPL(1122H2, 11_22H2)
|
||||||
|
|
||||||
bool isWin7OrGreater()
|
#undef IMPL
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_7);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin7SP1OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_7_SP1);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin8OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_8);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin8Point1OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_8_1);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin8Point1Update1OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_8_1_Update1);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin10OrGreater()
|
|
||||||
{
|
|
||||||
return isWin10TH1OrGreater();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin10TH1OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1507);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin10TH2OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1511);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin10RS1OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1607);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin10RS2OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1703);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin10RS3OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1709);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin10RS4OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1803);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin10RS5OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1809);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin1019H1OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1903);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin1019H2OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1909);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin1020H1OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_2004);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin1020H2OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_20H2);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin21H1OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_21H1);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin21H2OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_21H2);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin11OrGreater()
|
|
||||||
{
|
|
||||||
return isWin1121H2OrGreater();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin1121H2OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_11_21H2);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWin1122H2OrGreater()
|
|
||||||
{
|
|
||||||
static const bool result = Utils::isWindowsVersionOrGreater(WindowsVersion::_11_22H2);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace WindowsVersionHelper
|
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
Loading…
Reference in New Issue