From 5c9b8946ce68065a81cbf5747d72c8079b2cc2ab Mon Sep 17 00:00:00 2001
From: Kai Koehne <kai.koehne@nokia.com>
Date: Fri, 24 Jun 2011 13:41:05 +0200
Subject: [PATCH] QtQuickApp wizard: Add Qt Components for Meego/Harmattan

Change-Id: I4809de36e4913037439ab9eb7c56021431cff365
Reviewed-on: http://codereview.qt.nokia.com/704
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Alessandro Portale <alessandro.portale@nokia.com>
---
 .../qtquickapp/qml/app/meego10/MainPage.qml   | 23 +++++++++++++
 .../qtquickapp/qml/app/meego10/main.qml       | 30 +++++++++++++++++
 .../qmlapplicationviewer.cpp                  |  2 +-
 .../qt-desktop/qt4desktoptargetfactory.cpp    |  1 +
 .../qt-desktop/qt4simulatortargetfactory.cpp  |  1 +
 .../qt4projectmanagerconstants.h              |  2 ++
 .../qt4projectmanager/wizards/qtquickapp.cpp  |  7 ++--
 .../qt4projectmanager/wizards/qtquickapp.h    |  3 +-
 .../wizards/qtquickappwizard.cpp              |  5 +++
 .../wizards/qtquickappwizardpages.cpp         |  3 ++
 .../wizards/qtquickcomponentsetoptionspage.ui | 33 +++++++++++++++++--
 .../remotelinux/qt4maemotargetfactory.cpp     |  3 +-
 12 files changed, 106 insertions(+), 7 deletions(-)
 create mode 100644 share/qtcreator/templates/qtquickapp/qml/app/meego10/MainPage.qml
 create mode 100644 share/qtcreator/templates/qtquickapp/qml/app/meego10/main.qml

diff --git a/share/qtcreator/templates/qtquickapp/qml/app/meego10/MainPage.qml b/share/qtcreator/templates/qtquickapp/qml/app/meego10/MainPage.qml
new file mode 100644
index 00000000000..b02ef34642a
--- /dev/null
+++ b/share/qtcreator/templates/qtquickapp/qml/app/meego10/MainPage.qml
@@ -0,0 +1,23 @@
+import QtQuick 1.1
+import com.meego 1.0
+
+Page {
+    tools: commonTools
+
+    Label {
+        id: label
+        anchors.centerIn: parent
+        text: qsTr("Hello world!")
+        visible: false
+    }
+
+    Button{
+        anchors {
+            horizontalCenter: parent.horizontalCenter
+            top: label.bottom
+            topMargin: 10
+        }
+        text: qsTr("Click here!")
+        onClicked: label.visible = true
+    }
+}
diff --git a/share/qtcreator/templates/qtquickapp/qml/app/meego10/main.qml b/share/qtcreator/templates/qtquickapp/qml/app/meego10/main.qml
new file mode 100644
index 00000000000..cb3a632b293
--- /dev/null
+++ b/share/qtcreator/templates/qtquickapp/qml/app/meego10/main.qml
@@ -0,0 +1,30 @@
+import QtQuick 1.1
+import com.meego 1.0
+
+PageStackWindow {
+    id: appWindow
+
+    initialPage: mainPage
+
+    MainPage {
+        id: mainPage
+    }
+
+    ToolBarLayout {
+        id: commonTools
+        visible: true
+        ToolIcon {
+            platformIconId: "toolbar-view-menu"
+            anchors.right: (parent === undefined) ? undefined : parent.right
+            onClicked: (myMenu.status == DialogStatus.Closed) ? myMenu.open() : myMenu.close()
+        }
+    }
+
+    Menu {
+        id: myMenu
+        visualParent: pageStack
+        MenuLayout {
+            MenuItem { text: qsTr("Sample menu item") }
+        }
+    }
+}
diff --git a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp
index be7ce4ec062..f1a6b80b2a8 100644
--- a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp
+++ b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp
@@ -146,7 +146,7 @@ void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
 
 void QmlApplicationViewer::showExpanded()
 {
-#ifdef Q_OS_SYMBIAN
+#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN)
     showFullScreen();
 #elif defined(Q_WS_MAEMO_5)
     showMaximized();
diff --git a/src/plugins/qt4projectmanager/qt-desktop/qt4desktoptargetfactory.cpp b/src/plugins/qt4projectmanager/qt-desktop/qt4desktoptargetfactory.cpp
index b27b1013939..194660850de 100644
--- a/src/plugins/qt4projectmanager/qt-desktop/qt4desktoptargetfactory.cpp
+++ b/src/plugins/qt4projectmanager/qt-desktop/qt4desktoptargetfactory.cpp
@@ -163,6 +163,7 @@ QSet<QString> Qt4DesktopTargetFactory::targetFeatures(const QString & /*id*/) co
     features << Constants::SHADOWBUILD_TARGETFEATURE_ID;
     // how to check check whether they component set is really installed?
     features << Constants::QTQUICKCOMPONENTS_SYMBIAN_TARGETFEATURE_ID;
+    features << Constants::QTQUICKCOMPONENTS_MEEGO_TARGETFEATURE_ID;
     return features;
 }
 
diff --git a/src/plugins/qt4projectmanager/qt-desktop/qt4simulatortargetfactory.cpp b/src/plugins/qt4projectmanager/qt-desktop/qt4simulatortargetfactory.cpp
index ae0ce9ccb98..6dadf5449ea 100644
--- a/src/plugins/qt4projectmanager/qt-desktop/qt4simulatortargetfactory.cpp
+++ b/src/plugins/qt4projectmanager/qt-desktop/qt4simulatortargetfactory.cpp
@@ -131,6 +131,7 @@ QSet<QString> Qt4SimulatorTargetFactory::targetFeatures(const QString & /*id*/)
     features << Constants::SHADOWBUILD_TARGETFEATURE_ID;
     // how to check check whether the component set is really installed?
     features << Constants::QTQUICKCOMPONENTS_SYMBIAN_TARGETFEATURE_ID;
+    features << Constants::QTQUICKCOMPONENTS_MEEGO_TARGETFEATURE_ID;
     return features;
 }
 
diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h b/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h
index 5562ebb0419..f3a21193b12 100644
--- a/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h
+++ b/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h
@@ -98,6 +98,8 @@ const char * const DESKTOP_TARGETFEATURE_ID = "Qt4ProjectManager.TargetFeature.D
 const char * const SHADOWBUILD_TARGETFEATURE_ID = "Qt4ProjectManager.TargetFeature.ShadowBuild";
 const char * const QTQUICKCOMPONENTS_SYMBIAN_TARGETFEATURE_ID
                                = "Qt4ProjectManager.TargetFeature.QtQuickComponentsSymbian";
+const char * const QTQUICKCOMPONENTS_MEEGO_TARGETFEATURE_ID
+                               = "Qt4ProjectManager.TargetFeature.QtQuickComponentsMeego";
 
 
 // Tool chains:
diff --git a/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp b/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp
index 548205fcd66..b6448213c4a 100644
--- a/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp
+++ b/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp
@@ -349,7 +349,8 @@ Core::GeneratedFiles QtQuickApp::generateFiles(QString *errorMessage) const
     Core::GeneratedFiles files = AbstractMobileApp::generateFiles(errorMessage);
     if (!useExistingMainQml()) {
         files.append(file(generateFile(QtQuickAppGeneratedFileInfo::MainQmlFile, errorMessage), path(MainQml)));
-        if (componentSet() == QtQuickApp::Symbian10Components)
+        if ((componentSet() == QtQuickApp::Symbian10Components)
+                || (componentSet() == QtQuickApp::Meego10Components))
             files.append(file(generateFile(QtQuickAppGeneratedFileInfo::MainPageQmlFile, errorMessage), path(MainPageQml)));
         files.last().setAttributes(Core::GeneratedFile::OpenEditorAttribute);
     }
@@ -451,13 +452,15 @@ QString QtQuickApp::componentSetDir(ComponentSet componentSet) const
     switch (componentSet) {
     case Symbian10Components:
         return QLatin1String("symbian10");
+    case Meego10Components:
+        return QLatin1String("meego10");
     case QtQuick10Components:
     default:
         return QLatin1String("qtquick10");
     }
 }
 
-const int QtQuickApp::StubVersion = 12;
+const int QtQuickApp::StubVersion = 13;
 
 } // namespace Internal
 } // namespace Qt4ProjectManager
diff --git a/src/plugins/qt4projectmanager/wizards/qtquickapp.h b/src/plugins/qt4projectmanager/wizards/qtquickapp.h
index 34b854272c1..0cc39aba52c 100644
--- a/src/plugins/qt4projectmanager/wizards/qtquickapp.h
+++ b/src/plugins/qt4projectmanager/wizards/qtquickapp.h
@@ -117,7 +117,8 @@ public:
 
     enum ComponentSet {
         QtQuick10Components,
-        Symbian10Components
+        Symbian10Components,
+        Meego10Components
     };
 
     QtQuickApp();
diff --git a/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp b/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp
index 380327cb467..0c2d8a3e72e 100644
--- a/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp
+++ b/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp
@@ -95,6 +95,11 @@ bool QtQuickAppWizardDialog::validateCurrentPage()
             QSet<QString> requiredFeatures;
             requiredFeatures << Constants::QTQUICKCOMPONENTS_SYMBIAN_TARGETFEATURE_ID;
             targetsPage()->setRequiredFeatures(requiredFeatures);
+        } else if (m_componentOptionsPage->componentSet() == QtQuickApp::Meego10Components) {
+            targetsPage()->setMinimumQtVersion(QtSupport::QtVersionNumber(4, 7, 4));
+            QSet<QString> requiredFeatures;
+            requiredFeatures << Constants::QTQUICKCOMPONENTS_MEEGO_TARGETFEATURE_ID;
+            targetsPage()->setRequiredFeatures(requiredFeatures);
         }
     }
     return AbstractMobileAppWizardDialog::validateCurrentPage();
diff --git a/src/plugins/qt4projectmanager/wizards/qtquickappwizardpages.cpp b/src/plugins/qt4projectmanager/wizards/qtquickappwizardpages.cpp
index 9a0884f94b2..ad5903e79d8 100644
--- a/src/plugins/qt4projectmanager/wizards/qtquickappwizardpages.cpp
+++ b/src/plugins/qt4projectmanager/wizards/qtquickappwizardpages.cpp
@@ -64,6 +64,7 @@ QtQuickComponentSetOptionsPage::QtQuickComponentSetOptionsPage(QWidget *parent)
     m_d->ui.setupUi(this);
     m_d->ui.buttonGroup->setId(m_d->ui.qtquick10RadioButton, 0);
     m_d->ui.buttonGroup->setId(m_d->ui.symbian10RadioButton, 1);
+    m_d->ui.buttonGroup->setId(m_d->ui.meego10RadioButton, 2);
     connect(m_d->ui.buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(radioButtonChecked(int)));
 }
 
@@ -75,6 +76,7 @@ QtQuickComponentSetOptionsPage::~QtQuickComponentSetOptionsPage()
 QtQuickApp::ComponentSet QtQuickComponentSetOptionsPage::componentSet() const
 {
     switch (m_d->ui.buttonGroup->checkedId()) {
+    case 2: return QtQuickApp::Meego10Components;
     case 1: return QtQuickApp::Symbian10Components;
     case 0:
     default: return QtQuickApp::QtQuick10Components;
@@ -84,6 +86,7 @@ QtQuickApp::ComponentSet QtQuickComponentSetOptionsPage::componentSet() const
 void QtQuickComponentSetOptionsPage::setComponentSet(QtQuickApp::ComponentSet componentSet)
 {
     switch (componentSet) {
+    case QtQuickApp::Meego10Components: m_d->ui.meego10RadioButton->click(); break;
     case QtQuickApp::Symbian10Components: m_d->ui.symbian10RadioButton->click(); break;
     case QtQuickApp::QtQuick10Components:
     default: m_d->ui.qtquick10RadioButton->click(); break;
diff --git a/src/plugins/qt4projectmanager/wizards/qtquickcomponentsetoptionspage.ui b/src/plugins/qt4projectmanager/wizards/qtquickcomponentsetoptionspage.ui
index 10b7944119f..cf514765ef3 100644
--- a/src/plugins/qt4projectmanager/wizards/qtquickcomponentsetoptionspage.ui
+++ b/src/plugins/qt4projectmanager/wizards/qtquickcomponentsetoptionspage.ui
@@ -52,6 +52,16 @@
         </attribute>
        </widget>
       </item>
+      <item>
+       <widget class="QRadioButton" name="meego10RadioButton">
+        <property name="text">
+         <string>Qt Quick Components for Meego/Harmattan</string>
+        </property>
+        <attribute name="buttonGroup">
+         <string>buttonGroup</string>
+        </attribute>
+       </widget>
+      </item>
       <item>
        <spacer name="verticalSpacer">
         <property name="orientation">
@@ -71,7 +81,7 @@
       <item>
        <widget class="QStackedWidget" name="descriptionStackedWidget">
         <property name="currentIndex">
-         <number>1</number>
+         <number>0</number>
         </property>
         <widget class="QWidget" name="qtquick10DescriptionWidget">
          <layout class="QGridLayout" name="gridLayout">
@@ -99,7 +109,26 @@ Requires Qt 4.7.1 or newer.</string>
             <property name="text">
              <string>The Qt Quick Components for Symbian are a set of ready-made components that are designed with specific native appearance for the Symbian platform.
 
-Requires Qt 4.7.3 or newer, and the component set installed for your Qt version / Symbian device.</string>
+Requires Qt 4.7.3 or newer, and the component set installed for your Qt version.</string>
+            </property>
+            <property name="alignment">
+             <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+            </property>
+            <property name="wordWrap">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+        <widget class="QWidget" name="meego10DescriptionWidget">
+         <layout class="QGridLayout" name="gridLayout_4">
+          <item row="0" column="0">
+           <widget class="QLabel" name="meego1DescriptionLabel">
+            <property name="text">
+             <string>The Qt Quick Components for Meego/Harmattan are a set of ready-made components that are designed with specific native appearance for the Meego/Harmattan platform.
+
+Requires Qt 4.7.4 or newer, and the component set installed for your Qt version.</string>
             </property>
             <property name="alignment">
              <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
diff --git a/src/plugins/remotelinux/qt4maemotargetfactory.cpp b/src/plugins/remotelinux/qt4maemotargetfactory.cpp
index b8661d1c992..0577ede5626 100644
--- a/src/plugins/remotelinux/qt4maemotargetfactory.cpp
+++ b/src/plugins/remotelinux/qt4maemotargetfactory.cpp
@@ -165,7 +165,8 @@ QSet<QString> Qt4MaemoTargetFactory::targetFeatures(const QString & /*id*/) cons
 #ifndef Q_OS_WIN
     features << Qt4ProjectManager::Constants::SHADOWBUILD_TARGETFEATURE_ID;
 #endif
-
+    // how to check check whether the component set is really installed?
+    features << Qt4ProjectManager::Constants::QTQUICKCOMPONENTS_MEEGO_TARGETFEATURE_ID;
     return features;
 }
 
-- 
GitLab