diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp index a77727320b..682c9bab61 100644 --- a/src/corelib/global/qoperatingsystemversion.cpp +++ b/src/corelib/global/qoperatingsystemversion.cpp @@ -155,6 +155,8 @@ QT_BEGIN_NAMESPACE \fn QOperatingSystemVersion QOperatingSystemVersion::current() Returns a QOperatingSystemVersion indicating the current OS and its version number. + + \sa currentType() */ #if !defined(Q_OS_DARWIN) && !defined(Q_OS_WIN) QOperatingSystemVersion QOperatingSystemVersion::current() @@ -300,6 +302,14 @@ int QOperatingSystemVersion::compare(const QOperatingSystemVersion &v1, \sa name() */ +/*! + \fn QOperatingSystemVersion::OSType QOperatingSystemVersion::currentType() + + Returns the current OS type without constructing a QOperatingSystemVersion instance. + + \sa current() +*/ + /*! \fn QString QOperatingSystemVersion::name() const diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h index 55030c2200..5f27deab9e 100644 --- a/src/corelib/global/qoperatingsystemversion.h +++ b/src/corelib/global/qoperatingsystemversion.h @@ -92,6 +92,25 @@ public: static QOperatingSystemVersion current(); + static Q_DECL_CONSTEXPR OSType currentType() + { +#if defined(Q_OS_WIN) + return Windows; +#elif defined(Q_OS_MACOS) + return MacOS; +#elif defined(Q_OS_IOS) + return IOS; +#elif defined(Q_OS_TVOS) + return TvOS; +#elif defined(Q_OS_WATCHOS) + return WatchOS; +#elif defined(Q_OS_ANDROID) + return Android; +#else + return Unknown; +#endif + } + Q_DECL_CONSTEXPR int majorVersion() const { return m_major; } Q_DECL_CONSTEXPR int minorVersion() const { return m_minor; } Q_DECL_CONSTEXPR int microVersion() const { return m_micro; } diff --git a/src/corelib/global/qoperatingsystemversion_p.h b/src/corelib/global/qoperatingsystemversion_p.h index 78d0daf0c6..6922f4ad54 100644 --- a/src/corelib/global/qoperatingsystemversion_p.h +++ b/src/corelib/global/qoperatingsystemversion_p.h @@ -63,25 +63,6 @@ QT_BEGIN_NAMESPACE OSVERSIONINFOEX qWindowsVersionInfo(); #endif -static inline QOperatingSystemVersion::OSType currentType() -{ -#if defined(Q_OS_WIN) - return QOperatingSystemVersion::Windows; -#elif defined(Q_OS_MACOS) - return QOperatingSystemVersion::MacOS; -#elif defined(Q_OS_IOS) - return QOperatingSystemVersion::IOS; -#elif defined(Q_OS_TVOS) - return QOperatingSystemVersion::TvOS; -#elif defined(Q_OS_WATCHOS) - return QOperatingSystemVersion::WatchOS; -#elif defined(Q_OS_ANDROID) - return QOperatingSystemVersion::Android; -#else - return QOperatingSystemVersion::Unknown; -#endif -} - QT_END_NAMESPACE #endif // QOPERATINGSYSTEMVERSION_P_H