Commit e060086f authored by Daniel Teske's avatar Daniel Teske

Android: Don't let the user choose a stupid ANDROID_PACKAGE_SOURCE_DIR

On creating a AndroidManifest.xml we ask the user where to put the file,
which as a sideeffect also sets ANDROID_PACKAGE_DIR.

Since we copy everthing from ANDROID_PACKAGE_SOURCE_DIR into the build
directory, using the project's source directory is not desireable.

We now show a big error if the user tries that.

Task-number: QTCREATORBUG-11708
Change-Id: I7fade3efac0b7466cad8e83a92c2115d0a70c683
Reviewed-by: default avatarEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
parent 1f15995b
......@@ -95,7 +95,7 @@ void ChooseProFilePage::nodeSelected(int index)
// ChooseDirectoryPage
//
ChooseDirectoryPage::ChooseDirectoryPage(CreateAndroidManifestWizard *wizard)
: m_wizard(wizard), m_androidPackageSourceDir(0)
: m_wizard(wizard), m_androidPackageSourceDir(0), m_complete(true)
{
QString androidPackageDir = m_wizard->node()->singleVariableValue(QmakeProjectManager::AndroidPackageSourceDir);
......@@ -104,28 +104,68 @@ ChooseDirectoryPage::ChooseDirectoryPage(CreateAndroidManifestWizard *wizard)
label->setWordWrap(true);
fl->addRow(label);
m_sourceDirectoryWarning = new QLabel(this);
m_sourceDirectoryWarning->setVisible(false);
m_sourceDirectoryWarning->setText(tr("The Android package source directory can not be the same as the project directory."));
m_sourceDirectoryWarning->setWordWrap(true);
m_warningIcon = new QLabel(this);
m_warningIcon->setVisible(false);
m_warningIcon->setPixmap(QPixmap(QLatin1String(":/projectexplorer/images/compile_error.png")));
m_warningIcon->setWordWrap(true);
m_warningIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
QHBoxLayout *hbox = new QHBoxLayout;
hbox->addWidget(m_warningIcon);
hbox->addWidget(m_sourceDirectoryWarning);
hbox->setAlignment(m_warningIcon, Qt::AlignTop);
fl->addRow(hbox);
m_androidPackageSourceDir = new Utils::PathChooser(this);
m_androidPackageSourceDir->setExpectedKind(Utils::PathChooser::Directory);
fl->addRow(tr("Android package source directory:"), m_androidPackageSourceDir);
if (androidPackageDir.isEmpty()) {
label->setText(tr("Select the Android package source directory. "
label->setText(tr("Select the Android package source directory.\n\n"
"The files in the Android package source directory are copied to the build directory's "
"Android directory and the default files are overwritten."));
m_androidPackageSourceDir->setPath(QFileInfo(m_wizard->node()->path()).absolutePath().append(QLatin1String("/android")));
connect(m_androidPackageSourceDir, SIGNAL(changed(QString)),
this, SLOT(checkPackageSourceDir()));
} else {
label->setText(tr("The Android manifest file will be created in the ANDROID_PACKAGE_SOURCE_DIR set in the .pro file."));
m_androidPackageSourceDir->setPath(androidPackageDir);
m_androidPackageSourceDir->setReadOnly(true);
}
m_wizard->setDirectory(m_androidPackageSourceDir->path());
connect(m_androidPackageSourceDir, SIGNAL(pathChanged(QString)),
m_wizard, SLOT(setDirectory(QString)));
}
void ChooseDirectoryPage::checkPackageSourceDir()
{
QString projectDir = QFileInfo(m_wizard->node()->path()).absolutePath();
QString newDir = m_androidPackageSourceDir->path();
bool isComplete = QFileInfo(projectDir) != QFileInfo(newDir);
m_sourceDirectoryWarning->setVisible(!isComplete);
m_warningIcon->setVisible(!isComplete);
if (isComplete != m_complete) {
m_complete = isComplete;
emit completeChanged();
}
}
bool ChooseDirectoryPage::isComplete() const
{
return m_complete;
}
//
// CreateAndroidManifestWizard
//
......
......@@ -34,6 +34,7 @@
QT_BEGIN_NAMESPACE
class QComboBox;
class QLabel;
QT_END_NAMESPACE
namespace ProjectExplorer { class Target; }
......@@ -70,9 +71,16 @@ class ChooseDirectoryPage : public QWizardPage
Q_OBJECT
public:
ChooseDirectoryPage(CreateAndroidManifestWizard *wizard);
protected:
bool isComplete() const;
private slots:
void checkPackageSourceDir();
private:
CreateAndroidManifestWizard *m_wizard;
Utils::PathChooser *m_androidPackageSourceDir;
QLabel *m_sourceDirectoryWarning;
QLabel *m_warningIcon;
bool m_complete;
};
class CreateAndroidManifestWizard : public Utils::Wizard
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment