diff options
author | hjk <hjk121@nokiamail.com> | 2014-11-06 11:41:54 +0100 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2014-11-19 11:05:29 +0100 |
commit | 72155f4eb4a4c14464c44d8e848b912eeae8580a (patch) | |
tree | 47a233041374da0e2bbe1d606f4716af12880e60 /src/corelib/global/qsysinfo.h | |
parent | f5f8a8c346b7566b544d500254c6f9f4eb109c79 (diff) |
Make QSysInfo enum types available cross-platform
This makes the WinVersion and MacVersion enums accessible in platform
indepedent code to avoid the need to use #ifdef Q_OS_* chains in
user code, leading to fewer platform-dependent code paths and better
maintainability.
To indicate "this is not a Windows based OS" a enum value
QSysInfo::WV_None (with value 0x0000) in QSysInfo::WinVersion
is introduced. This keeps the WV_*_based masks usable.
To indicate "this is not a Darwin based OS" a enum values
QSysInfo::MV_None (with value 0xffff) in QSysInfo::MacVersion
is introduced. 0x0000 might have been preferable for (not so
important "consitency" with QSysInfo::WV_None), but is already
taken by QSysInfo::MV_Unknown with a different meaning.
Change-Id: Ib395e0efba58558f31f4e0806f7333165aa90aa5
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qsysinfo.h')
-rw-r--r-- | src/corelib/global/qsysinfo.h | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h index 2ac18f2ed8..35672479e0 100644 --- a/src/corelib/global/qsysinfo.h +++ b/src/corelib/global/qsysinfo.h @@ -72,8 +72,9 @@ public: # endif }; #endif -#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) enum WinVersion { + WV_None = 0x0000, + WV_32s = 0x0001, WV_95 = 0x0002, WV_98 = 0x0003, @@ -107,14 +108,18 @@ public: WV_CE_6 = 0x0400, WV_CE_based = 0x0f00 }; +#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) static const WinVersion WindowsVersion; static WinVersion windowsVersion(); - +#else + static const WinVersion WindowsVersion = WV_None; + static WinVersion windowsVersion() { return WV_None; } #endif -#ifdef Q_OS_MAC -# define Q_MV_OSX(major, minor) (major == 10 ? minor + 2 : (major == 9 ? 1 : 0)) -# define Q_MV_IOS(major, minor) (QSysInfo::MV_IOS | major << 4 | minor) + +#define Q_MV_OSX(major, minor) (major == 10 ? minor + 2 : (major == 9 ? 1 : 0)) +#define Q_MV_IOS(major, minor) (QSysInfo::MV_IOS | major << 4 | minor) enum MacVersion { + MV_None = 0xffff, MV_Unknown = 0x0000, /* version */ @@ -155,8 +160,12 @@ public: MV_IOS_7_1 = Q_MV_IOS(7, 1), MV_IOS_8_0 = Q_MV_IOS(8, 0) }; +#if defined(Q_OS_MAC) static const MacVersion MacintoshVersion; static MacVersion macVersion(); +#else + static const MacVersion MacintoshVersion = MV_None; + static MacVersion macVersion() { return MV_None; } #endif static QString buildCpuArchitecture(); |