Android: Replace setting for input .json file and use active rc instead

That's a more natural approach to select the application .pro file

Task-number: QTCREATORBUG-13732
Change-Id: I8c6745bea4b408e1d4f7ed2cd4e1d50798c60881
Reviewed-by: BogDan Vatra <bogdan@kde.org>
This commit is contained in:
Daniel Teske
2015-01-16 11:28:44 +01:00
parent 2477df97fe
commit e57ed31c33
6 changed files with 10 additions and 96 deletions

View File

@@ -31,6 +31,7 @@
#include "qmakeandroidbuildapkstep.h" #include "qmakeandroidbuildapkstep.h"
#include "qmakeandroidbuildapkwidget.h" #include "qmakeandroidbuildapkwidget.h"
#include "qmakeandroidrunconfiguration.h"
#include <android/androidconfigurations.h> #include <android/androidconfigurations.h>
#include <android/androidconstants.h> #include <android/androidconstants.h>
@@ -143,17 +144,14 @@ QmakeAndroidBuildApkStep::QmakeAndroidBuildApkStep(ProjectExplorer::BuildStepLis
QString QmakeAndroidBuildApkStep::proFilePathForInputFile() const QString QmakeAndroidBuildApkStep::proFilePathForInputFile() const
{ {
return m_proFilePathForInputFile; ProjectExplorer::RunConfiguration *rc = target()->activeRunConfiguration();
} if (auto *arc = qobject_cast<QmakeAndroidRunConfiguration *>(rc))
return arc->proFilePath();
void QmakeAndroidBuildApkStep::setProFilePathForInputFile(const QString &path) return QString();
{
m_proFilePathForInputFile = path;
} }
QmakeAndroidBuildApkStep::QmakeAndroidBuildApkStep(ProjectExplorer::BuildStepList *bc, QmakeAndroidBuildApkStep *other) QmakeAndroidBuildApkStep::QmakeAndroidBuildApkStep(ProjectExplorer::BuildStepList *bc, QmakeAndroidBuildApkStep *other)
: Android::AndroidBuildApkStep(bc, other), : Android::AndroidBuildApkStep(bc, other)
m_proFilePathForInputFile(other->m_proFilePathForInputFile)
{ {
ctor(); ctor();
} }
@@ -162,7 +160,7 @@ Utils::FileName QmakeAndroidBuildApkStep::androidPackageSourceDir() const
{ {
QmakeProjectManager::QmakeProject *pro = static_cast<QmakeProjectManager::QmakeProject *>(project()); QmakeProjectManager::QmakeProject *pro = static_cast<QmakeProjectManager::QmakeProject *>(project());
const QmakeProjectManager::QmakeProFileNode *node const QmakeProjectManager::QmakeProFileNode *node
= pro->rootQmakeProjectNode()->findProFileFor(m_proFilePathForInputFile); = pro->rootQmakeProjectNode()->findProFileFor(proFilePathForInputFile());
if (!node) if (!node)
return Utils::FileName(); return Utils::FileName();
return Utils::FileName::fromString(node->singleVariableValue(QmakeProjectManager::AndroidPackageSourceDir)); return Utils::FileName::fromString(node->singleVariableValue(QmakeProjectManager::AndroidPackageSourceDir));
@@ -170,8 +168,6 @@ Utils::FileName QmakeAndroidBuildApkStep::androidPackageSourceDir() const
void QmakeAndroidBuildApkStep::ctor() void QmakeAndroidBuildApkStep::ctor()
{ {
connect(project(), SIGNAL(proFilesEvaluated()),
this, SLOT(updateInputFile()));
} }
bool QmakeAndroidBuildApkStep::init() bool QmakeAndroidBuildApkStep::init()
@@ -309,32 +305,14 @@ ProjectExplorer::BuildStepConfigWidget *QmakeAndroidBuildApkStep::createConfigWi
bool QmakeAndroidBuildApkStep::fromMap(const QVariantMap &map) bool QmakeAndroidBuildApkStep::fromMap(const QVariantMap &map)
{ {
m_proFilePathForInputFile = map.value(ProFilePathForInputFile).toString();
return Android::AndroidBuildApkStep::fromMap(map); return Android::AndroidBuildApkStep::fromMap(map);
} }
QVariantMap QmakeAndroidBuildApkStep::toMap() const QVariantMap QmakeAndroidBuildApkStep::toMap() const
{ {
QVariantMap map = Android::AndroidBuildApkStep::toMap(); QVariantMap map = Android::AndroidBuildApkStep::toMap();
map.insert(ProFilePathForInputFile, m_proFilePathForInputFile);
return map; return map;
} }
void QmakeAndroidBuildApkStep::updateInputFile()
{
QmakeProject *pro = static_cast<QmakeProject *>(project());
QList<QmakeProFileNode *> nodes = pro->applicationProFiles();
const QmakeProFileNode *node = pro->rootQmakeProjectNode()->findProFileFor(m_proFilePathForInputFile);
if (!nodes.contains(const_cast<QmakeProFileNode *>(node))) {
if (!nodes.isEmpty())
m_proFilePathForInputFile = nodes.first()->path();
else
m_proFilePathForInputFile.clear();
}
emit inputFileChanged();
}
} // namespace Internal } // namespace Internal
} // namespace QmakeProjectManager } // namespace QmakeProjectManager

View File

@@ -86,18 +86,10 @@ protected:
bool fromMap(const QVariantMap &map); bool fromMap(const QVariantMap &map);
QVariantMap toMap() const; QVariantMap toMap() const;
signals:
// also on purpose emitted if the possible values of this changed
void inputFileChanged();
private slots:
void updateInputFile();
private: private:
void setupProcessParameters(ProjectExplorer::ProcessParameters *pp, void setupProcessParameters(ProjectExplorer::ProcessParameters *pp,
ProjectExplorer::BuildConfiguration *bc, ProjectExplorer::BuildConfiguration *bc,
const QStringList &arguments, const QString &command); const QStringList &arguments, const QString &command);
QString m_proFilePathForInputFile;
QString m_command; QString m_command;
QString m_argumentsPasswordConcealed; QString m_argumentsPasswordConcealed;
bool m_skipBuilding; bool m_skipBuilding;

View File

@@ -39,6 +39,7 @@
#include <qmakeprojectmanager/qmakeproject.h> #include <qmakeprojectmanager/qmakeproject.h>
#include <QFileDialog> #include <QFileDialog>
#include <QLabel>
using QmakeProjectManager::QmakeProject; using QmakeProjectManager::QmakeProject;
using QmakeProjectManager::QmakeProFileNode; using QmakeProjectManager::QmakeProFileNode;
@@ -86,13 +87,6 @@ QmakeAndroidBuildApkWidget::QmakeAndroidBuildApkWidget(QmakeAndroidBuildApkStep
m_extraLibraryListModel = new AndroidExtraLibraryListModel(static_cast<QmakeProject *>(m_step->project()), this); m_extraLibraryListModel = new AndroidExtraLibraryListModel(static_cast<QmakeProject *>(m_step->project()), this);
m_ui->androidExtraLibsListView->setModel(m_extraLibraryListModel); m_ui->androidExtraLibsListView->setModel(m_extraLibraryListModel);
updateInputFileUi();
connect(m_step, SIGNAL(inputFileChanged()),
SLOT(updateInputFileUi()));
connect(m_ui->inputFileComboBox, SIGNAL(currentIndexChanged(int)),
SLOT(inputFileComboBoxIndexChanged()));
connect(m_ui->createAndroidTemplatesButton, SIGNAL(clicked()), connect(m_ui->createAndroidTemplatesButton, SIGNAL(clicked()),
SLOT(createAndroidTemplatesButton())); SLOT(createAndroidTemplatesButton()));
@@ -116,40 +110,6 @@ QmakeAndroidBuildApkWidget::~QmakeAndroidBuildApkWidget()
delete m_ui; delete m_ui;
} }
void QmakeAndroidBuildApkWidget::updateInputFileUi()
{
QmakeProject *project
= static_cast<QmakeProject *>(m_step->project());
QList<QmakeProFileNode *> nodes = project->applicationProFiles();
int size = nodes.size();
if (size == 0 || size == 1) {
// there's nothing to select, e.g. before parsing
m_ui->inputFileLabel->setVisible(false);
m_ui->inputFileComboBox->setVisible(false);
} else {
m_ignoreChange = true;
m_ui->inputFileLabel->setVisible(true);
m_ui->inputFileComboBox->setVisible(true);
m_ui->inputFileComboBox->clear();
foreach (QmakeProFileNode *node, nodes)
m_ui->inputFileComboBox->addItem(node->displayName(), node->path());
int index = m_ui->inputFileComboBox->findData(m_step->proFilePathForInputFile());
m_ui->inputFileComboBox->setCurrentIndex(index);
m_ignoreChange = false;
}
}
void QmakeAndroidBuildApkWidget::inputFileComboBoxIndexChanged()
{
if (m_ignoreChange)
return;
QString proFilePath = m_ui->inputFileComboBox->itemData(m_ui->inputFileComboBox->currentIndex()).toString();
m_step->setProFilePathForInputFile(proFilePath);
}
void QmakeAndroidBuildApkWidget::createAndroidTemplatesButton() void QmakeAndroidBuildApkWidget::createAndroidTemplatesButton()
{ {
CreateAndroidManifestWizard wizard(m_step->target()); CreateAndroidManifestWizard wizard(m_step->target());

View File

@@ -61,8 +61,6 @@ public:
~QmakeAndroidBuildApkWidget(); ~QmakeAndroidBuildApkWidget();
private slots: private slots:
void updateInputFileUi();
void inputFileComboBoxIndexChanged();
void createAndroidTemplatesButton(); void createAndroidTemplatesButton();
void addAndroidExtraLib(); void addAndroidExtraLib();
void removeAndroidExtraLib(); void removeAndroidExtraLib();

View File

@@ -50,20 +50,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="inputFileLabel">
<property name="text">
<string>Input file for androiddeployqt:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="inputFileComboBox"/>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@@ -104,7 +104,7 @@ QList<Core::Id> QmakeAndroidRunConfigurationFactory::availableCreationIds(Target
RunConfiguration *QmakeAndroidRunConfigurationFactory::doCreate(Target *parent, Core::Id id) RunConfiguration *QmakeAndroidRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
{ {
if (parent->project()->rootProjectNode()) if (parent->project()->rootProjectNode())
return new QmakeAndroidRunConfiguration(parent, id, parent->project()->rootProjectNode()->path()); return new QmakeAndroidRunConfiguration(parent, id, pathFromId(id));
return new QmakeAndroidRunConfiguration(parent, id); return new QmakeAndroidRunConfiguration(parent, id);
} }
@@ -113,7 +113,7 @@ RunConfiguration *QmakeAndroidRunConfigurationFactory::doRestore(Target *parent,
{ {
Core::Id id = ProjectExplorer::idFromMap(map); Core::Id id = ProjectExplorer::idFromMap(map);
if (parent->project()->rootProjectNode()) if (parent->project()->rootProjectNode())
return new QmakeAndroidRunConfiguration(parent, id, parent->project()->rootProjectNode()->path()); return new QmakeAndroidRunConfiguration(parent, id);
return new QmakeAndroidRunConfiguration(parent, id); return new QmakeAndroidRunConfiguration(parent, id);
} }