Support other platform names on configure.exe
authorRafael Roquetto <rafael.roquetto.qnx@kdab.com>
Fri, 8 Jun 2012 13:20:35 +0000 (15:20 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 12 Jun 2012 02:30:00 +0000 (04:30 +0200)
Added three new methods, which are meant to be used internally to
configureapp.cpp:
    - int platform(): returns an integer representing a platform
    - QString platformName(): returns the platform name string to be used when
      displaying the license agreement.
    - QString qpaPlatformName(): returns the value to be defined as
      QT_QPA_DEFAULT_PLATFORM_NAME.

Currently supported names are Windows, Windows CE, QNX and Blackberry. Default
is "Windows".

Change-Id: Ifa4d1b9c02cda956be9becdf8db195d3d494f1d5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
tools/configure/configureapp.cpp
tools/configure/configureapp.h

index 8c06a15..5a24e9b 100644 (file)
 
 QT_BEGIN_NAMESPACE
 
+enum Platforms {
+    WINDOWS,
+    WINDOWS_CE,
+    QNX,
+    BLACKBERRY
+};
+
 std::ostream &operator<<(std::ostream &s, const QString &val) {
     s << val.toLocal8Bit().data();
     return s;
@@ -2961,7 +2968,7 @@ void Configure::generateConfigfiles()
         if (dictionary[ "QT_SXE" ] == "no")
           tmpStream<<"#define QT_NO_SXE"<<endl;
 
-        tmpStream<<"#define QT_QPA_DEFAULT_PLATFORM_NAME \"windows\""<<endl;
+        tmpStream<<"#define QT_QPA_DEFAULT_PLATFORM_NAME \"" << qpaPlatformName() << "\""<<endl;
 
         tmpStream.flush();
         tmpFile.flush();
@@ -3699,11 +3706,7 @@ bool Configure::showLicense(QString orgLicenseFile)
 
 void Configure::readLicense()
 {
-   if (QFile::exists(dictionary["QT_SOURCE_TREE"] + "/src/corelib/kernel/qfunctions_wince.h") &&
-       (dictionary.value("QMAKESPEC").startsWith("wince") || dictionary.value("XQMAKESPEC").startsWith("wince")))
-        dictionary["PLATFORM NAME"] = "Qt for Windows CE";
-    else
-        dictionary["PLATFORM NAME"] = "Qt for Windows";
+    dictionary["PLATFORM NAME"] = platformName();
     dictionary["LICENSE FILE"] = sourcePath;
 
     bool openSource = false;
@@ -3809,6 +3812,52 @@ bool Configure::isOk()
     return (dictionary[ "DONE" ] != "error");
 }
 
+QString Configure::platformName() const
+{
+    switch (platform()) {
+    default:
+    case WINDOWS:
+        return QStringLiteral("Qt for Windows");
+    case WINDOWS_CE:
+        return QStringLiteral("Qt for Windows CE");
+    case QNX:
+        return QStringLiteral("Qt for QNX");
+    case BLACKBERRY:
+        return QStringLiteral("Qt for Blackberry");
+    }
+}
+
+QString Configure::qpaPlatformName() const
+{
+    switch (platform()) {
+    default:
+    case WINDOWS:
+    case WINDOWS_CE:
+        return QStringLiteral("windows");
+    case QNX:
+        return QStringLiteral("qnx");
+    case BLACKBERRY:
+        return QStringLiteral("blackberry");
+    }
+}
+
+int Configure::platform() const
+{
+    const QString qMakeSpec = dictionary.value("QMAKESPEC");
+    const QString xQMakeSpec = dictionary.value("XQMAKESPEC");
+
+    if ((qMakeSpec.startsWith("wince") || xQMakeSpec.startsWith("wince")))
+        return WINDOWS_CE;
+
+    if (xQMakeSpec.contains("qnx"))
+        return QNX;
+
+    if (xQMakeSpec.contains("blackberry"))
+        return BLACKBERRY;
+
+    return WINDOWS;
+}
+
 bool
 Configure::filesDiffer(const QString &fn1, const QString &fn2)
 {
index 42068e7..4ac0736 100644 (file)
@@ -104,6 +104,11 @@ public:
     ProjectType projectType( const QString& proFileName );
     bool isDone();
     bool isOk();
+
+    int platform() const;
+    QString platformName() const;
+    QString qpaPlatformName() const;
+
 private:
     // Our variable dictionaries
     QMap<QString,QString> dictionary;