Add QSysInfo::MacVersion enum values and parsing for iOS
Change-Id: I82e425e3cd06e0f515aa6edfb25ef9895956a5c6 Reviewed-by: Jake Petroules <jake.petroules@petroules.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
This commit is contained in:
parent
6ad97bfa73
commit
e6d13c7f00
@ -985,8 +985,7 @@ bool qSharedBuild() Q_DECL_NOTHROW
|
||||
/*!
|
||||
\fn QSysInfo::MacVersion QSysInfo::macVersion()
|
||||
|
||||
Returns the version of Mac OS X on which the application is run (Mac OS X
|
||||
Only).
|
||||
Returns the version of Darwin (OS X or iOS) on which the application is run.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -1056,7 +1055,7 @@ bool qSharedBuild() Q_DECL_NOTHROW
|
||||
\enum QSysInfo::MacVersion
|
||||
|
||||
This enum provides symbolic names for the various versions of the
|
||||
OS X operating system. On OS X, the
|
||||
Darwin operating system, covering both OS X and iOS. The
|
||||
QSysInfo::MacintoshVersion variable gives the version of the
|
||||
system on which the application is run.
|
||||
|
||||
@ -1084,6 +1083,15 @@ bool qSharedBuild() Q_DECL_NOTHROW
|
||||
\value MV_MOUNTAINLION Apple codename for MV_10_8
|
||||
\value MV_MAVERICKS Apple codename for MV_10_9
|
||||
|
||||
\value MV_IOS iOS (any)
|
||||
\value MV_IOS_4_3 iOS 4.3
|
||||
\value MV_IOS_5_0 iOS 5.0
|
||||
\value MV_IOS_5_1 iOS 5.1
|
||||
\value MV_IOS_6_0 iOS 6.0
|
||||
\value MV_IOS_6_1 iOS 6.1
|
||||
\value MV_IOS_7_0 iOS 7.0
|
||||
\value MV_IOS_7_1 iOS 7.1
|
||||
|
||||
\sa WinVersion
|
||||
*/
|
||||
|
||||
@ -1706,13 +1714,15 @@ static const unsigned int qt_one = 1;
|
||||
const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian);
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_MACX)
|
||||
#if defined(Q_OS_MAC)
|
||||
|
||||
QT_BEGIN_INCLUDE_NAMESPACE
|
||||
#include "private/qcore_mac_p.h"
|
||||
#include "qnamespace.h"
|
||||
QT_END_INCLUDE_NAMESPACE
|
||||
|
||||
#if defined(Q_OS_OSX)
|
||||
|
||||
Q_CORE_EXPORT OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref)
|
||||
{
|
||||
return FSPathMakeRef(reinterpret_cast<const UInt8 *>(file.toUtf8().constData()), fsref, 0);
|
||||
@ -1728,17 +1738,17 @@ Q_CORE_EXPORT void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding e
|
||||
Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr) {
|
||||
return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding()));
|
||||
}
|
||||
#endif // defined(Q_OS_MACX)
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
#endif // defined(Q_OS_OSX)
|
||||
|
||||
QSysInfo::MacVersion QSysInfo::macVersion()
|
||||
{
|
||||
#ifdef Q_OS_MACX
|
||||
#if defined(Q_OS_OSX)
|
||||
SInt32 gestalt_version;
|
||||
if (Gestalt(gestaltSystemVersion, &gestalt_version) == noErr) {
|
||||
return QSysInfo::MacVersion(((gestalt_version & 0x00F0) >> 4) + 2);
|
||||
}
|
||||
#elif defined(Q_OS_IOS)
|
||||
return qt_ios_version(); // qtcore_mac_objc.mm
|
||||
#endif
|
||||
return QSysInfo::MV_Unknown;
|
||||
}
|
||||
|
@ -120,6 +120,7 @@ public:
|
||||
|
||||
#endif
|
||||
#ifdef Q_OS_MAC
|
||||
# define Q_MV_IOS(major, minor) (QSysInfo::MV_IOS | major << 4 | minor)
|
||||
enum MacVersion {
|
||||
MV_Unknown = 0x0000,
|
||||
|
||||
@ -146,7 +147,17 @@ public:
|
||||
MV_SNOWLEOPARD = MV_10_6,
|
||||
MV_LION = MV_10_7,
|
||||
MV_MOUNTAINLION = MV_10_8,
|
||||
MV_MAVERICKS = MV_10_9
|
||||
MV_MAVERICKS = MV_10_9,
|
||||
|
||||
/* iOS */
|
||||
MV_IOS = 1 << 8,
|
||||
MV_IOS_4_3 = Q_MV_IOS(4, 3),
|
||||
MV_IOS_5_0 = Q_MV_IOS(5, 0),
|
||||
MV_IOS_5_1 = Q_MV_IOS(5, 1),
|
||||
MV_IOS_6_0 = Q_MV_IOS(6, 0),
|
||||
MV_IOS_6_1 = Q_MV_IOS(6, 1),
|
||||
MV_IOS_7_0 = Q_MV_IOS(7, 0),
|
||||
MV_IOS_7_1 = Q_MV_IOS(7, 1)
|
||||
};
|
||||
static const MacVersion MacintoshVersion;
|
||||
static MacVersion macVersion();
|
||||
|
@ -41,6 +41,10 @@
|
||||
|
||||
#include <private/qcore_mac_p.h>
|
||||
|
||||
#ifdef Q_OS_IOS
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
NSString *QCFString::toNSString(const QString &string)
|
||||
@ -54,5 +58,26 @@ QString QCFString::toQString(const NSString *nsstr)
|
||||
return toQString(reinterpret_cast<CFStringRef>(nsstr));
|
||||
}
|
||||
|
||||
#ifdef Q_OS_IOS
|
||||
QSysInfo::MacVersion qt_ios_version()
|
||||
{
|
||||
int major = 0, minor = 0;
|
||||
NSArray *components = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
|
||||
switch ([components count]) {
|
||||
case 3:
|
||||
// We don't care about the patch version
|
||||
case 2:
|
||||
minor = [[components objectAtIndex:1] intValue];
|
||||
// fall through
|
||||
case 1:
|
||||
major = [[components objectAtIndex:0] intValue];
|
||||
break;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
return QSysInfo::MacVersion(Q_MV_IOS(major, minor));
|
||||
}
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -143,6 +143,10 @@ private:
|
||||
QString string;
|
||||
};
|
||||
|
||||
#ifdef Q_OS_IOS
|
||||
QSysInfo::MacVersion qt_ios_version();
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QCORE_MAC_P_H
|
||||
|
Loading…
Reference in New Issue
Block a user