forked from qt-creator/qt-creator
Implement Gui for Qml module deployment.
This commit is contained in:
@@ -87,6 +87,11 @@ QmlStandaloneAppWizardDialog::QmlStandaloneAppWizardDialog(QmlStandaloneAppWizar
|
||||
m_qmlOptionsPage = new QmlStandaloneAppWizardOptionsPage;
|
||||
const int qmlOptionsPagePageId = addPage(m_qmlOptionsPage);
|
||||
wizardProgress()->item(qmlOptionsPagePageId)->setTitle(tr("Qml App options"));
|
||||
if (m_type == QmlStandaloneAppWizard::NewQmlFile) {
|
||||
// In case of NewQmlFile, we show that page at the end. Is that useful? Or irritating?
|
||||
const int qmlSourcesPagePageId = addPage(m_qmlSourcesPage);
|
||||
wizardProgress()->item(qmlSourcesPagePageId)->setTitle(tr("Qml Sources"));
|
||||
}
|
||||
}
|
||||
|
||||
class QmlStandaloneAppWizardPrivate
|
||||
@@ -147,6 +152,8 @@ QWizard *QmlStandaloneAppWizard::createWizardDialog(QWidget *parent,
|
||||
m_d->wizardDialog->m_qmlOptionsPage->setNetworkEnabled(m_d->standaloneApp->networkEnabled());
|
||||
m_d->wizardDialog->m_qmlOptionsPage->setLoadDummyData(m_d->standaloneApp->loadDummyData());
|
||||
connect(m_d->wizardDialog, SIGNAL(introPageLeft(QString, QString)), SLOT(useProjectPath(QString, QString)));
|
||||
connect(m_d->wizardDialog->m_qmlSourcesPage,
|
||||
SIGNAL(externalModulesChanged(QStringList, QStringList)), SLOT(handleModulesChange(QStringList, QStringList)));
|
||||
|
||||
foreach (QWizardPage *p, extensionPages)
|
||||
BaseFileWizard::applyExtensionPageShortTitle(m_d->wizardDialog, m_d->wizardDialog->addPage(p));
|
||||
@@ -169,6 +176,8 @@ Core::GeneratedFiles QmlStandaloneAppWizard::generateFiles(const QWizard *w,
|
||||
m_d->standaloneApp->setNetworkEnabled(wizard->m_qmlOptionsPage->networkEnabled());
|
||||
if (m_d->type == QmlStandaloneAppWizard::ImportQmlFile)
|
||||
m_d->standaloneApp->setMainQmlFile(wizard->m_qmlSourcesPage->mainQmlFile());
|
||||
m_d->standaloneApp->setExternalModules(
|
||||
wizard->m_qmlSourcesPage->moduleUris(), wizard->m_qmlSourcesPage->moduleImportPaths());
|
||||
|
||||
return m_d->standaloneApp->generateFiles(errorMessage);
|
||||
}
|
||||
@@ -189,6 +198,13 @@ void QmlStandaloneAppWizard::useProjectPath(const QString &projectName, const QS
|
||||
m_d->wizardDialog->m_qmlOptionsPage->setSymbianUid(QmlStandaloneApp::symbianUidForPath(projectPath + projectName));
|
||||
}
|
||||
|
||||
void QmlStandaloneAppWizard::handleModulesChange(const QStringList &uris, const QStringList &paths)
|
||||
{
|
||||
QmlStandaloneApp testApp;
|
||||
testApp.setExternalModules(uris, paths);
|
||||
m_d->wizardDialog->m_qmlSourcesPage->setModulesError(testApp.error());
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
|
@@ -59,6 +59,7 @@ protected:
|
||||
|
||||
protected slots:
|
||||
void useProjectPath(const QString &projectName, const QString &projectPath);
|
||||
void handleModulesChange(const QStringList &uris, const QStringList &paths);
|
||||
|
||||
private:
|
||||
class QmlStandaloneAppWizardPrivate *m_d;
|
||||
|
@@ -30,9 +30,11 @@
|
||||
#include "qmlstandaloneappwizardpages.h"
|
||||
#include "ui_qmlstandaloneappwizardsourcespage.h"
|
||||
#include "ui_qmlstandaloneappwizardoptionspage.h"
|
||||
#include <coreplugin/coreconstants.h>
|
||||
|
||||
#include <QtGui/QDesktopServices>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtGui/QFileDialog>
|
||||
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
@@ -40,6 +42,7 @@ namespace Internal {
|
||||
class QmlStandaloneAppWizardSourcesPagePrivate
|
||||
{
|
||||
Ui::QmlStandaloneAppWizardSourcesPage ui;
|
||||
bool mainQmlFileChooserVisible;
|
||||
friend class QmlStandaloneAppWizardSourcesPage;
|
||||
};
|
||||
|
||||
@@ -51,8 +54,15 @@ QmlStandaloneAppWizardSourcesPage::QmlStandaloneAppWizardSourcesPage(QWidget *pa
|
||||
m_d->ui.mainQmlFileLineEdit->setExpectedKind(Utils::PathChooser::File);
|
||||
m_d->ui.mainQmlFileLineEdit->setPromptDialogFilter(QLatin1String("*.qml"));
|
||||
m_d->ui.mainQmlFileLineEdit->setPromptDialogTitle(tr("Select the main QML file of the application."));
|
||||
m_d->ui.qmlModulesGroupBox->setEnabled(false); // TODO: implement modules selection
|
||||
m_d->ui.addModuleUriButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_PLUS)));
|
||||
m_d->ui.removeModuleUriButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_MINUS)));
|
||||
m_d->ui.addImportPathButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_PLUS)));
|
||||
m_d->ui.removeImportPathButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_MINUS)));
|
||||
setMainQmlFileChooserVisible(true);
|
||||
setModulesError(QString());
|
||||
connect(m_d->ui.mainQmlFileLineEdit, SIGNAL(changed(QString)), SIGNAL(completeChanged()));
|
||||
connect(m_d->ui.urisListWidget, SIGNAL(itemChanged(QListWidgetItem*)), SLOT(handleModulesChanged()));
|
||||
connect(m_d->ui.importPathsListWidget, SIGNAL(itemChanged(QListWidgetItem*)), SLOT(handleModulesChanged()));
|
||||
}
|
||||
|
||||
QmlStandaloneAppWizardSourcesPage::~QmlStandaloneAppWizardSourcesPage()
|
||||
@@ -67,12 +77,84 @@ QString QmlStandaloneAppWizardSourcesPage::mainQmlFile() const
|
||||
|
||||
bool QmlStandaloneAppWizardSourcesPage::isComplete() const
|
||||
{
|
||||
return m_d->ui.mainQmlFileLineEdit->isValid();
|
||||
return (!m_d->mainQmlFileChooserVisible || m_d->ui.mainQmlFileLineEdit->isValid())
|
||||
&& m_d->ui.errorLabel->text().isEmpty();
|
||||
}
|
||||
|
||||
void QmlStandaloneAppWizardSourcesPage::setMainQmlFileChooserVisible(bool visible)
|
||||
{
|
||||
m_d->ui.mainQmlFileLineEdit->setVisible(visible);
|
||||
m_d->mainQmlFileChooserVisible = visible;
|
||||
m_d->ui.mainQmlFileGroupBox->setVisible(m_d->mainQmlFileChooserVisible);
|
||||
}
|
||||
|
||||
void QmlStandaloneAppWizardSourcesPage::setModulesError(const QString &error)
|
||||
{
|
||||
m_d->ui.errorLabel->setText(error);
|
||||
m_d->ui.errorLabel->setVisible(!error.isEmpty());
|
||||
}
|
||||
|
||||
void QmlStandaloneAppWizardSourcesPage::on_addModuleUriButton_clicked()
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem(m_d->ui.urisListWidget);
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
m_d->ui.urisListWidget->editItem(item);
|
||||
}
|
||||
|
||||
void QmlStandaloneAppWizardSourcesPage::on_removeModuleUriButton_clicked()
|
||||
{
|
||||
const int currentRow = m_d->ui.urisListWidget->currentRow();
|
||||
if (currentRow >= 0) {
|
||||
m_d->ui.urisListWidget->takeItem(currentRow);
|
||||
handleModulesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void QmlStandaloneAppWizardSourcesPage::on_addImportPathButton_clicked()
|
||||
{
|
||||
const QString path = QFileDialog::getExistingDirectory(this,
|
||||
tr("Select an import path for QML modules."), mainQmlFile());
|
||||
if (!path.isEmpty()) {
|
||||
QListWidgetItem *item = new QListWidgetItem(QDir::toNativeSeparators(path), m_d->ui.importPathsListWidget);
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
}
|
||||
}
|
||||
|
||||
void QmlStandaloneAppWizardSourcesPage::on_removeImportPathButton_clicked()
|
||||
{
|
||||
const int currentRow = m_d->ui.importPathsListWidget->currentRow();
|
||||
if (currentRow >= 0) {
|
||||
m_d->ui.importPathsListWidget->takeItem(currentRow);
|
||||
handleModulesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
static inline QStringList ertriesFromListWidget(const QListWidget &listWidget)
|
||||
{
|
||||
QStringList result;
|
||||
for (int i = 0; i < listWidget.count(); ++i) {
|
||||
const QString text = listWidget.item(i)->text().trimmed();
|
||||
if (!text.isEmpty())
|
||||
result.append(text);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void QmlStandaloneAppWizardSourcesPage::handleModulesChanged()
|
||||
{
|
||||
const QStringList uris = ertriesFromListWidget(*m_d->ui.urisListWidget);
|
||||
const QStringList paths = ertriesFromListWidget(*m_d->ui.importPathsListWidget);
|
||||
emit externalModulesChanged(uris, paths);
|
||||
emit completeChanged();
|
||||
}
|
||||
|
||||
QStringList QmlStandaloneAppWizardSourcesPage::moduleUris() const
|
||||
{
|
||||
return ertriesFromListWidget(*m_d->ui.urisListWidget);
|
||||
}
|
||||
|
||||
QStringList QmlStandaloneAppWizardSourcesPage::moduleImportPaths() const
|
||||
{
|
||||
return ertriesFromListWidget(*m_d->ui.importPathsListWidget);
|
||||
}
|
||||
|
||||
class QmlStandaloneAppWizardOptionsPagePrivate
|
||||
|
@@ -48,6 +48,19 @@ public:
|
||||
QString mainQmlFile() const;
|
||||
virtual bool isComplete() const;
|
||||
void setMainQmlFileChooserVisible(bool visible);
|
||||
void setModulesError(const QString &error);
|
||||
QStringList moduleUris() const;
|
||||
QStringList moduleImportPaths() const;
|
||||
|
||||
private slots:
|
||||
void on_addModuleUriButton_clicked();
|
||||
void on_removeModuleUriButton_clicked();
|
||||
void on_addImportPathButton_clicked();
|
||||
void on_removeImportPathButton_clicked();
|
||||
void handleModulesChanged();
|
||||
|
||||
signals:
|
||||
void externalModulesChanged(const QStringList &uris, const QStringList &importPaths) const;
|
||||
|
||||
private:
|
||||
class QmlStandaloneAppWizardSourcesPagePrivate *m_d;
|
||||
|
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>408</width>
|
||||
<height>340</height>
|
||||
<width>494</width>
|
||||
<height>346</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -31,9 +31,115 @@
|
||||
<property name="title">
|
||||
<string>Qml Modules</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="qmlModulesListWidget"/>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="childrenCollapsible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0" rowspan="3">
|
||||
<widget class="QListWidget" name="urisListWidget"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QToolButton" name="addModuleUriButton">
|
||||
<property name="text">
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QToolButton" name="removeModuleUriButton">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>URIs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0" rowspan="3">
|
||||
<widget class="QListWidget" name="importPathsListWidget"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QToolButton" name="addImportPathButton">
|
||||
<property name="text">
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QToolButton" name="removeImportPathButton">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Import Paths</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QLabel" name="errorLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Error</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -45,6 +151,11 @@
|
||||
<class>Utils::PathChooser</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header location="global">utils/pathchooser.h</header>
|
||||
<container>1</container>
|
||||
<slots>
|
||||
<signal>editingFinished()</signal>
|
||||
<signal>browsingFinished()</signal>
|
||||
</slots>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
|
Reference in New Issue
Block a user