Commit 845480d4 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Mobile wizards: Make options pages target-specific.

Task-number: QTCREATORBUG-2511
Reviewed-by: Alessandro Portale
parent 7a5c0047
......@@ -139,8 +139,10 @@ FORMS += makestep.ui \
wizards/testwizardpage.ui \
wizards/targetsetuppage.ui \
wizards/qmlstandaloneappwizardsourcespage.ui \
wizards/mobileappwizardoptionspage.ui \
wizards/mobilelibrarywizardoptionpage.ui \
wizards/mobileappwizardgenericoptionspage.ui \
wizards/mobileappwizardsymbianoptionspage.ui \
wizards/mobileappwizardmaemooptionspage.ui \
librarydetailswidget.ui
RESOURCES += qt4projectmanager.qrc \
wizards/wizards.qrc
......
......@@ -36,6 +36,7 @@
#include <extensionsystem/pluginmanager.h>
#include <qt4projectmanager/qt4project.h>
#include <qt4projectmanager/qt4projectmanager.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <QtGui/QIcon>
......@@ -48,13 +49,57 @@ AbstractMobileAppWizardDialog::AbstractMobileAppWizardDialog(QWidget *parent)
m_targetsPage = new TargetSetupPage;
resize(900, 450);
m_targetsPage->setImportDirectoryBrowsingEnabled(false);
int pageId = addPage(m_targetsPage);
wizardProgress()->item(pageId)->setTitle(tr("Qt Versions"));
m_optionsPage = new MobileAppWizardOptionsPage;
pageId = addPage(m_optionsPage);
wizardProgress()->item(pageId)->setTitle(tr("Application Options"));
addPageWithTitle(m_targetsPage, tr("Qt Versions"));
m_genericOptionsPage = new MobileAppWizardGenericOptionsPage;
m_genericOptionsPageId = addPageWithTitle(m_genericOptionsPage,
tr("Generic Mobile Application Options"));
m_symbianOptionsPage = new MobileAppWizardSymbianOptionsPage;
m_symbianOptionsPageId = addPageWithTitle(m_symbianOptionsPage,
tr("Symbian-specific Options"));
m_maemoOptionsPage = new MobileAppWizardMaemoOptionsPage;
m_maemoOptionsPageId = addPageWithTitle(m_maemoOptionsPage,
tr("Maemo-specific Options"));
}
int AbstractMobileAppWizardDialog::addPageWithTitle(QWizardPage *page, const QString &title)
{
const int pageId = addPage(page);
wizardProgress()->item(pageId)->setTitle(title);
return pageId;
}
int AbstractMobileAppWizardDialog::nextId() const
{
const bool symbianTargetSelected =
m_targetsPage->isTargetSelected(QLatin1String(Constants::S60_EMULATOR_TARGET_ID))
|| m_targetsPage->isTargetSelected(QLatin1String(Constants::S60_DEVICE_TARGET_ID));
const bool maemoTargetSelected =
m_targetsPage->isTargetSelected(QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID));
if (currentPage() == m_targetsPage) {
if (symbianTargetSelected || maemoTargetSelected)
return m_genericOptionsPageId;
else
return idOfNextGenericPage();
} else if (currentPage() == m_genericOptionsPage) {
if (symbianTargetSelected)
return m_symbianOptionsPageId;
else
return m_maemoOptionsPageId;
} else if (currentPage() == m_symbianOptionsPage) {
if (maemoTargetSelected)
return m_maemoOptionsPageId;
else
return idOfNextGenericPage();
} else {
return BaseProjectWizardDialog::nextId();
}
}
int AbstractMobileAppWizardDialog::idOfNextGenericPage() const
{
return pageIds().at(pageIds().indexOf(m_maemoOptionsPageId) + 1);
}
AbstractMobileAppWizard::AbstractMobileAppWizard(const Core::BaseFileWizardParameters &params,
QObject *parent) : Core::BaseFileWizard(params, parent)
......@@ -68,10 +113,10 @@ QWizard *AbstractMobileAppWizard::createWizardDialog(QWidget *parent,
= createWizardDialogInternal(parent);
wdlg->setPath(defaultPath);
wdlg->setProjectName(ProjectExplorer::BaseProjectWizardDialog::uniqueProjectName(defaultPath));
wdlg->m_optionsPage->setSymbianSvgIcon(app()->symbianSvgIcon());
wdlg->m_optionsPage->setMaemoPngIcon(app()->maemoPngIcon());
wdlg->m_optionsPage->setOrientation(app()->orientation());
wdlg->m_optionsPage->setNetworkEnabled(app()->networkEnabled());
wdlg->m_genericOptionsPage->setOrientation(app()->orientation());
wdlg->m_symbianOptionsPage->setSvgIcon(app()->symbianSvgIcon());
wdlg->m_symbianOptionsPage->setNetworkEnabled(app()->networkEnabled());
wdlg->m_maemoOptionsPage->setPngIcon(app()->maemoPngIcon());
connect(wdlg, SIGNAL(projectParametersChanged(QString, QString)),
SLOT(useProjectPath(QString, QString)));
foreach (QWizardPage *p, extensionPages)
......@@ -85,11 +130,11 @@ Core::GeneratedFiles AbstractMobileAppWizard::generateFiles(const QWizard *wizar
prepareGenerateFiles(wizard, errorMessage);
const AbstractMobileAppWizardDialog *wdlg
= qobject_cast<const AbstractMobileAppWizardDialog*>(wizard);
app()->setSymbianTargetUid(wdlg->m_optionsPage->symbianUid());
app()->setSymbianSvgIcon(wdlg->m_optionsPage->symbianSvgIcon());
app()->setMaemoPngIcon(wdlg->m_optionsPage->maemoPngIcon());
app()->setOrientation(wdlg->m_optionsPage->orientation());
app()->setNetworkEnabled(wdlg->m_optionsPage->networkEnabled());
app()->setOrientation(wdlg->m_genericOptionsPage->orientation());
app()->setSymbianTargetUid(wdlg->m_symbianOptionsPage->symbianUid());
app()->setSymbianSvgIcon(wdlg->m_symbianOptionsPage->svgIcon());
app()->setNetworkEnabled(wdlg->m_symbianOptionsPage->networkEnabled());
app()->setMaemoPngIcon(wdlg->m_maemoOptionsPage->pngIcon());
return app()->generateFiles(errorMessage);
}
......@@ -112,7 +157,7 @@ bool AbstractMobileAppWizard::postGenerateFiles(const QWizard *w,
void AbstractMobileAppWizard::useProjectPath(const QString &projectName,
const QString &projectPath)
{
wizardDialog()->m_optionsPage->setSymbianUid(app()->symbianUidForPath(projectPath + projectName));
wizardDialog()->m_symbianOptionsPage->setSymbianUid(app()->symbianUidForPath(projectPath + projectName));
app()->setProjectName(projectName);
app()->setProjectPath(projectPath);
wizardDialog()->m_targetsPage->setProFilePath(app()->path(AbstractMobileApp::AppPro));
......
......@@ -37,16 +37,33 @@ namespace Qt4ProjectManager {
namespace Internal {
class AbstractMobileApp;
class MobileAppWizardGenericOptionsPage;
class MobileAppWizardSymbianOptionsPage;
class MobileAppWizardMaemoOptionsPage;
class AbstractMobileAppWizardDialog : public ProjectExplorer::BaseProjectWizardDialog
class AbstractMobileAppWizardDialog : public ProjectExplorer::BaseProjectWizardDialog
{
Q_OBJECT
protected:
explicit AbstractMobileAppWizardDialog(QWidget *parent = 0);
public:
class MobileAppWizardOptionsPage *m_optionsPage;
MobileAppWizardGenericOptionsPage *m_genericOptionsPage;
MobileAppWizardSymbianOptionsPage *m_symbianOptionsPage;
MobileAppWizardMaemoOptionsPage *m_maemoOptionsPage;
class TargetSetupPage *m_targetsPage;
protected:
int addPageWithTitle(QWizardPage *page, const QString &title);
private:
virtual int nextId() const;
int idOfNextGenericPage() const;
int m_genericOptionsPageId;
int m_symbianOptionsPageId;
int m_maemoOptionsPageId;
};
class AbstractMobileAppWizard : public Core::BaseFileWizard
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MobileAppWizardGenericOptionsPage</class>
<widget class="QWizardPage" name="MobileAppWizardGenericOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>396</width>
<height>115</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="orientationBehaviorLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Orientation behavior:</string>
</property>
<property name="buddy">
<cstring>orientationBehaviorComboBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="orientationBehaviorComboBox"/>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>66</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MobileAppWizardMaemoOptionsPage</class>
<widget class="QWizardPage" name="MobileAppWizardMaemoOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="appIconLabel">
<property name="text">
<string>Application icon (64x64):</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="pngIconButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MobileAppWizardOptionPage</class>
<widget class="QWizardPage" name="MobileAppWizardOptionPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>404</width>
<height>548</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>General</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="verticalSpacing">
<number>12</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="orientationBehaviorLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Orientation behavior:</string>
</property>
<property name="buddy">
<cstring>orientationBehaviorComboBox</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="orientationBehaviorComboBox"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTabWidget" name="platformsTabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Symbian Specific</string>
</attribute>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="symbianAppIconLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Application icon (.svg):</string>
</property>
<property name="buddy">
<cstring>symbianAppIconLoadToolButton</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="symbianAppIconPreview">
<property name="minimumSize">
<size>
<width>45</width>
<height>45</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>45</width>
<height>45</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="symbianAppIconLoadToolButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="symbianTargetUid3Label">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Target UID3:</string>
</property>
<property name="buddy">
<cstring>symbianTargetUid3LineEdit</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="symbianTargetUid3LineEdit"/>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="symbianEnableNetworkChackBox">
<property name="text">
<string>Enable network access</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Maemo Specific</string>
</attribute>
<widget class="QLabel" name="maemoAppIconLabel">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>155</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Application icon (64x64):</string>
</property>
</widget>
<widget class="QToolButton" name="maemoPngIconButton">
<property name="geometry">
<rect>
<x>171</x>
<y>10</y>
<width>71</width>
<height>70</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
</widget>
</widget>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -28,7 +28,9 @@
**************************************************************************/
#include "mobileappwizardpages.h"
#include "ui_mobileappwizardoptionspage.h"
#include "ui_mobileappwizardgenericoptionspage.h"
#include "ui_mobileappwizardmaemooptionspage.h"
#include "ui_mobileappwizardsymbianoptionspage.h"
#include <coreplugin/coreconstants.h>
#include <QtGui/QDesktopServices>
......@@ -39,26 +41,32 @@
namespace Qt4ProjectManager {
namespace Internal {
class MobileAppWizardOptionsPagePrivate
class MobileAppWizardGenericOptionsPagePrivate
{
Ui::MobileAppWizardOptionPage ui;
QString symbianSvgIcon;
QString maemoPngIcon;
friend class MobileAppWizardOptionsPage;
Ui::MobileAppWizardGenericOptionsPage ui;
friend class MobileAppWizardGenericOptionsPage;
};
MobileAppWizardOptionsPage::MobileAppWizardOptionsPage(QWidget *parent)
: QWizardPage(parent)
, m_d(new MobileAppWizardOptionsPagePrivate)
class MobileAppWizardSymbianOptionsPagePrivate
{
m_d->ui.setupUi(this);
Ui::MobileAppWizardSymbianOptionsPage ui;
QString svgIcon;
friend class MobileAppWizardSymbianOptionsPage;
};
const QIcon open = QApplication::style()->standardIcon(QStyle::SP_DirOpenIcon);
m_d->ui.symbianAppIconLoadToolButton->setIcon(open);
connect(m_d->ui.symbianAppIconLoadToolButton, SIGNAL(clicked()), SLOT(openSymbianSvgIcon()));
connect(m_d->ui.maemoPngIconButton, SIGNAL(clicked()), this,
SLOT(openMaemoPngIcon()));
class MobileAppWizardMaemoOptionsPagePrivate
{
Ui::MobileAppWizardMaemoOptionsPage ui;
QString pngIcon;
friend class MobileAppWizardMaemoOptionsPage;
};
MobileAppWizardGenericOptionsPage::MobileAppWizardGenericOptionsPage(QWidget *parent)
: QWizardPage(parent)
, m_d(new MobileAppWizardGenericOptionsPagePrivate)
{
m_d->ui.setupUi(this);
m_d->ui.orientationBehaviorComboBox->addItem(tr("Automatically Rotate Orientation"),
AbstractMobileApp::ScreenOrientationAuto);
m_d->ui.orientationBehaviorComboBox->addItem(tr("Lock to Landscape Orientation"),
......@@ -67,12 +75,12 @@ MobileAppWizardOptionsPage::MobileAppWizardOptionsPage(QWidget *parent)
AbstractMobileApp::ScreenOrientationLockPortrait);
}
MobileAppWizardOptionsPage::~MobileAppWizardOptionsPage()
MobileAppWizardGenericOptionsPage::~MobileAppWizardGenericOptionsPage()
{
delete m_d;
}
void MobileAppWizardOptionsPage::setOrientation(AbstractMobileApp::ScreenOrientation orientation)
void MobileAppWizardGenericOptionsPage::setOrientation(AbstractMobileApp::ScreenOrientation orientation)
{
QComboBox *const comboBox = m_d->ui.orientationBehaviorComboBox;
for (int i = 0; i < comboBox->count(); ++i)
......@@ -82,88 +90,118 @@ void MobileAppWizardOptionsPage::setOrientation(AbstractMobileApp::ScreenOrienta
}
}
AbstractMobileApp::ScreenOrientation MobileAppWizardOptionsPage::orientation() const
AbstractMobileApp::ScreenOrientation MobileAppWizardGenericOptionsPage::orientation() const
{
const int index = m_d->ui.orientationBehaviorComboBox->currentIndex();
return static_cast<