forked from qt-creator/qt-creator
Android: Qt 5.2 deployment add a button to create a Android manifest
The AndroidManifest.xml is no longer needed in as many use cases as before. So the new deployment does not automatically create a android manifest. Offer a button on the deployment page to create a android manifest. This also edits the .pro file adding the ANDROID_PACKAGE_SOURCE_DIR. Change-Id: I2655dd6c96e2087732b4d7240b31fe9fcf168600 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
@@ -45,7 +45,8 @@ HEADERS += \
|
|||||||
androiddevicedialog.h \
|
androiddevicedialog.h \
|
||||||
androiddeployqtstep.h \
|
androiddeployqtstep.h \
|
||||||
certificatesmodel.h \
|
certificatesmodel.h \
|
||||||
androiddeployqtwidget.h
|
androiddeployqtwidget.h \
|
||||||
|
createandroidmanifestwizard.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
androidconfigurations.cpp \
|
androidconfigurations.cpp \
|
||||||
@@ -85,7 +86,8 @@ SOURCES += \
|
|||||||
androiddevicedialog.cpp \
|
androiddevicedialog.cpp \
|
||||||
androiddeployqtstep.cpp \
|
androiddeployqtstep.cpp \
|
||||||
certificatesmodel.cpp \
|
certificatesmodel.cpp \
|
||||||
androiddeployqtwidget.cpp
|
androiddeployqtwidget.cpp \
|
||||||
|
createandroidmanifestwizard.cpp
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
androidsettingswidget.ui \
|
androidsettingswidget.ui \
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "androidcreatekeystorecertificate.h"
|
#include "androidcreatekeystorecertificate.h"
|
||||||
#include "androiddeployqtstep.h"
|
#include "androiddeployqtstep.h"
|
||||||
#include "androidmanager.h"
|
#include "androidmanager.h"
|
||||||
|
#include "createandroidmanifestwizard.h"
|
||||||
|
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <qt4projectmanager/qt4buildconfiguration.h>
|
#include <qt4projectmanager/qt4buildconfiguration.h>
|
||||||
@@ -129,6 +130,9 @@ AndroidDeployQtWidget::AndroidDeployQtWidget(AndroidDeployQtStep *step)
|
|||||||
updateInputFileUi();
|
updateInputFileUi();
|
||||||
connect(m_step, SIGNAL(inputFileChanged()),
|
connect(m_step, SIGNAL(inputFileChanged()),
|
||||||
this, SLOT(updateInputFileUi()));
|
this, SLOT(updateInputFileUi()));
|
||||||
|
|
||||||
|
connect(m_ui->createAndroidManifestButton, SIGNAL(clicked()),
|
||||||
|
this, SLOT(createManifestButton()));
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidDeployQtWidget::~AndroidDeployQtWidget()
|
AndroidDeployQtWidget::~AndroidDeployQtWidget()
|
||||||
@@ -136,6 +140,12 @@ AndroidDeployQtWidget::~AndroidDeployQtWidget()
|
|||||||
delete m_ui;
|
delete m_ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AndroidDeployQtWidget::createManifestButton()
|
||||||
|
{
|
||||||
|
CreateAndroidManifestWizard wizard(m_step->target());
|
||||||
|
wizard.exec();
|
||||||
|
}
|
||||||
|
|
||||||
void AndroidDeployQtWidget::updateInputFileUi()
|
void AndroidDeployQtWidget::updateInputFileUi()
|
||||||
{
|
{
|
||||||
Qt4ProjectManager::Qt4Project *project
|
Qt4ProjectManager::Qt4Project *project
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ private slots:
|
|||||||
void signPackageCheckBoxToggled(bool checked);
|
void signPackageCheckBoxToggled(bool checked);
|
||||||
void updateInputFileUi();
|
void updateInputFileUi();
|
||||||
void inputFileComboBoxIndexChanged();
|
void inputFileComboBoxIndexChanged();
|
||||||
|
void createManifestButton();
|
||||||
private:
|
private:
|
||||||
virtual QString summaryText() const;
|
virtual QString summaryText() const;
|
||||||
virtual QString displayName() const;
|
virtual QString displayName() const;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>682</width>
|
<width>682</width>
|
||||||
<height>415</height>
|
<height>467</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -177,6 +177,19 @@ The APK will not be usable on any other device.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -186,21 +199,21 @@ The APK will not be usable on any other device.</string>
|
|||||||
<string>Advanced Actions</string>
|
<string>Advanced Actions</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QPushButton" name="cleanLibsPushButton">
|
<widget class="QPushButton" name="cleanLibsPushButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Clean Temporary Libraries Directory on Device</string>
|
<string>Clean Temporary Libraries Directory on Device</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QPushButton" name="installMinistroButton">
|
<widget class="QPushButton" name="installMinistroButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Install Ministro from APK</string>
|
<string>Install Ministro from APK</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QPushButton" name="resetDefaultDevices">
|
<widget class="QPushButton" name="resetDefaultDevices">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Reset Default Devices</string>
|
<string>Reset Default Devices</string>
|
||||||
@@ -221,6 +234,13 @@ The APK will not be usable on any other device.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QPushButton" name="createAndroidManifestButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Create AndroidManifest.xml</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
233
src/plugins/android/createandroidmanifestwizard.cpp
Normal file
233
src/plugins/android/createandroidmanifestwizard.cpp
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "createandroidmanifestwizard.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
|
#include <qt4projectmanager/qt4project.h>
|
||||||
|
#include <qt4projectmanager/qt4nodes.h>
|
||||||
|
#include <proparser/prowriter.h>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <qtsupport/qtkitinformation.h>
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
|
||||||
|
using namespace Android;
|
||||||
|
using namespace Android::Internal;
|
||||||
|
using Qt4ProjectManager::Qt4Project;
|
||||||
|
using Qt4ProjectManager::Qt4ProFileNode;
|
||||||
|
|
||||||
|
//
|
||||||
|
// NoApplicationProFilePage
|
||||||
|
//
|
||||||
|
NoApplicationProFilePage::NoApplicationProFilePage(CreateAndroidManifestWizard *wizard)
|
||||||
|
: m_wizard(wizard)
|
||||||
|
{
|
||||||
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
|
QLabel *label = new QLabel(this);
|
||||||
|
label->setWordWrap(true);
|
||||||
|
label->setText(tr("No application .pro file found in this project."));
|
||||||
|
layout->addWidget(label);
|
||||||
|
setTitle(tr("No Application .pro File"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// ChooseProFilePage
|
||||||
|
//
|
||||||
|
ChooseProFilePage::ChooseProFilePage(CreateAndroidManifestWizard *wizard, const QList<Qt4ProFileNode *> &nodes)
|
||||||
|
: m_wizard(wizard)
|
||||||
|
{
|
||||||
|
QFormLayout *fl = new QFormLayout(this);
|
||||||
|
QLabel *label = new QLabel(this);
|
||||||
|
label->setWordWrap(true);
|
||||||
|
label->setText(tr("Select the .pro file for which you want to create a AndroidManifest.xml file"));
|
||||||
|
fl->addRow(label);
|
||||||
|
|
||||||
|
m_comboBox = new QComboBox(this);
|
||||||
|
foreach (Qt4ProFileNode *node, nodes)
|
||||||
|
m_comboBox->addItem(node->displayName(), QVariant::fromValue(static_cast<void *>(node))); // TODO something more?
|
||||||
|
|
||||||
|
connect(m_comboBox, SIGNAL(currentIndexChanged(int)),
|
||||||
|
this, SLOT(nodeSelected(int)));
|
||||||
|
|
||||||
|
fl->addRow(tr(".pro file:"), m_comboBox);
|
||||||
|
setTitle(tr("Select a .pro File"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChooseProFilePage::nodeSelected(int index)
|
||||||
|
{
|
||||||
|
Q_UNUSED(index)
|
||||||
|
m_wizard->setNode(static_cast<Qt4ProFileNode *>(m_comboBox->currentData().value<void *>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// ChooseDirectoryPage
|
||||||
|
//
|
||||||
|
ChooseDirectoryPage::ChooseDirectoryPage(CreateAndroidManifestWizard *wizard)
|
||||||
|
: m_wizard(wizard), m_androidPackageSourceDir(0)
|
||||||
|
{
|
||||||
|
QString androidPackageDir = m_wizard->node()->singleVariableValue(Qt4ProjectManager::AndroidPackageSourceDir);
|
||||||
|
|
||||||
|
QFormLayout *fl = new QFormLayout(this);
|
||||||
|
QLabel *label = new QLabel(this);
|
||||||
|
label->setWordWrap(true);
|
||||||
|
fl->addRow(label);
|
||||||
|
|
||||||
|
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. "
|
||||||
|
"The files in the android package source directory are copied to the builddirectory's "
|
||||||
|
"android directory and overwrite the default files."));
|
||||||
|
|
||||||
|
m_androidPackageSourceDir->setPath(QFileInfo(m_wizard->node()->path()).absolutePath().append(QLatin1String("/android")));
|
||||||
|
} 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)));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// CreateAndroidManifestWizard
|
||||||
|
//
|
||||||
|
CreateAndroidManifestWizard::CreateAndroidManifestWizard(ProjectExplorer::Target *target)
|
||||||
|
: m_target(target), m_node(0)
|
||||||
|
{
|
||||||
|
setOption(QWizard::NoBackButtonOnStartPage);
|
||||||
|
setOption(QWizard::NoCancelButton, false);
|
||||||
|
setWindowTitle(tr("Create Android Manifest Wizard"));
|
||||||
|
|
||||||
|
Qt4Project *project = static_cast<Qt4Project *>(target->project());
|
||||||
|
QList<Qt4ProFileNode *> nodes = project->applicationProFiles();
|
||||||
|
if (nodes.isEmpty()) {
|
||||||
|
// oh uhm can't create anything
|
||||||
|
addPage(new NoApplicationProFilePage(this));
|
||||||
|
} else if (nodes.size() == 1) {
|
||||||
|
setNode(nodes.first());
|
||||||
|
addPage(new ChooseDirectoryPage(this));
|
||||||
|
} else {
|
||||||
|
addPage(new ChooseProFilePage(this, nodes));
|
||||||
|
addPage(new ChooseDirectoryPage(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt4ProjectManager::Qt4ProFileNode *CreateAndroidManifestWizard::node() const
|
||||||
|
{
|
||||||
|
return m_node;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateAndroidManifestWizard::setNode(Qt4ProjectManager::Qt4ProFileNode *node)
|
||||||
|
{
|
||||||
|
m_node = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateAndroidManifestWizard::setDirectory(const QString &directory)
|
||||||
|
{
|
||||||
|
m_directory = directory;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CreateAndroidManifestWizard::sourceFileName() const
|
||||||
|
{
|
||||||
|
QString result;
|
||||||
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(m_target->kit());
|
||||||
|
if (!version)
|
||||||
|
return result;
|
||||||
|
Utils::FileName srcPath
|
||||||
|
= Utils::FileName::fromString(version->qmakeProperty("QT_INSTALL_PREFIX"))
|
||||||
|
.appendPath(QLatin1String("src/android/java"));
|
||||||
|
srcPath.appendPath(QLatin1String("AndroidManifest.xml"));
|
||||||
|
return srcPath.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateAndroidManifestWizard::createAndroidManifestFile()
|
||||||
|
{
|
||||||
|
if (m_directory.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QDir dir;
|
||||||
|
if (!QFileInfo(m_directory).exists())
|
||||||
|
dir.mkpath(m_directory);
|
||||||
|
QString fileName = m_directory + QLatin1String("/AndroidManifest.xml");
|
||||||
|
if (QFileInfo(fileName).exists()) {
|
||||||
|
if (QMessageBox::question(this, tr("Overwrite AndroidManifest.xml"),
|
||||||
|
tr("Overwrite existing AndroidManifest.xml?"),
|
||||||
|
QMessageBox::Yes, QMessageBox::No)
|
||||||
|
== QMessageBox::Yes) {
|
||||||
|
if (!QFile(m_directory + QLatin1String("/AndroidManifest.xml")).remove()) {
|
||||||
|
QMessageBox::warning(this, tr("File Removal Error"),
|
||||||
|
tr("Could not remove file %1.").arg(fileName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!QFile::copy(sourceFileName(), fileName)) {
|
||||||
|
QMessageBox::warning(this, tr("File Creation Error"),
|
||||||
|
tr("Could not create file %1.").arg(fileName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_node->singleVariableValue(Qt4ProjectManager::AndroidPackageSourceDir).isEmpty()) {
|
||||||
|
// and now time for some magic
|
||||||
|
QString dir = QFileInfo(fileName).absolutePath();
|
||||||
|
QString value = QLatin1String("$$PWD/")
|
||||||
|
+ QDir(m_target->project()->projectDirectory()).relativeFilePath(dir);
|
||||||
|
bool result =
|
||||||
|
m_node->setProVariable(QLatin1String("ANDROID_PACKAGE_SOURCE_DIR"), value);
|
||||||
|
QStringList unChanged;
|
||||||
|
m_node->addFiles(QStringList(fileName), &unChanged);
|
||||||
|
|
||||||
|
if (result == false
|
||||||
|
|| !unChanged.isEmpty()) {
|
||||||
|
QMessageBox::warning(this, tr("Project File not Updated"),
|
||||||
|
tr("Could not update the .pro file %1.").arg(m_node->path()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Core::EditorManager::openEditor(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateAndroidManifestWizard::accept()
|
||||||
|
{
|
||||||
|
createAndroidManifestFile();
|
||||||
|
Utils::Wizard::accept();
|
||||||
|
}
|
||||||
102
src/plugins/android/createandroidmanifestwizard.h
Normal file
102
src/plugins/android/createandroidmanifestwizard.h
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef CREATEANDROIDMANIFESTWIZARD_H
|
||||||
|
#define CREATEANDROIDMANIFESTWIZARD_H
|
||||||
|
|
||||||
|
#include <utils/pathchooser.h>
|
||||||
|
#include <utils/wizard.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QComboBox;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace ProjectExplorer { class Target; }
|
||||||
|
namespace Qt4ProjectManager { class Qt4ProFileNode; }
|
||||||
|
|
||||||
|
namespace Android {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class CreateAndroidManifestWizard;
|
||||||
|
|
||||||
|
class NoApplicationProFilePage : public QWizardPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
NoApplicationProFilePage(CreateAndroidManifestWizard *wizard);
|
||||||
|
private:
|
||||||
|
CreateAndroidManifestWizard *m_wizard;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ChooseProFilePage : public QWizardPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ChooseProFilePage(CreateAndroidManifestWizard *wizard, const QList<Qt4ProjectManager::Qt4ProFileNode *> &nodes);
|
||||||
|
private slots:
|
||||||
|
void nodeSelected(int index);
|
||||||
|
private:
|
||||||
|
CreateAndroidManifestWizard *m_wizard;
|
||||||
|
QComboBox *m_comboBox;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ChooseDirectoryPage : public QWizardPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ChooseDirectoryPage(CreateAndroidManifestWizard *wizard);
|
||||||
|
private:
|
||||||
|
CreateAndroidManifestWizard *m_wizard;
|
||||||
|
Utils::PathChooser *m_androidPackageSourceDir;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CreateAndroidManifestWizard : public Utils::Wizard
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CreateAndroidManifestWizard(ProjectExplorer::Target *target);
|
||||||
|
|
||||||
|
Qt4ProjectManager::Qt4ProFileNode *node() const;
|
||||||
|
void setNode(Qt4ProjectManager::Qt4ProFileNode *node);
|
||||||
|
|
||||||
|
QString sourceFileName() const;
|
||||||
|
|
||||||
|
void accept();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setDirectory(const QString &directory);
|
||||||
|
private:
|
||||||
|
void createAndroidManifestFile();
|
||||||
|
ProjectExplorer::Target *m_target;
|
||||||
|
Qt4ProjectManager::Qt4ProFileNode *m_node;
|
||||||
|
QString m_directory;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CREATEANDROIDMANIFESTWIZARD_H
|
||||||
@@ -296,7 +296,7 @@ QStringList Qt4BuildConfiguration::configCommandLineArguments() const
|
|||||||
QStringList result;
|
QStringList result;
|
||||||
BaseQtVersion *version = QtKitInformation::qtVersion(target()->kit());
|
BaseQtVersion *version = QtKitInformation::qtVersion(target()->kit());
|
||||||
BaseQtVersion::QmakeBuildConfigs defaultBuildConfiguration =
|
BaseQtVersion::QmakeBuildConfigs defaultBuildConfiguration =
|
||||||
version ? version->defaultBuildConfig() : (BaseQtVersion::DebugBuild | BaseQtVersion::BuildAll);
|
version ? version->defaultBuildConfig() : BaseQtVersion::QmakeBuildConfigs(BaseQtVersion::DebugBuild | BaseQtVersion::BuildAll);
|
||||||
BaseQtVersion::QmakeBuildConfigs userBuildConfiguration = m_qmakeBuildConfiguration;
|
BaseQtVersion::QmakeBuildConfigs userBuildConfiguration = m_qmakeBuildConfiguration;
|
||||||
if ((defaultBuildConfiguration & BaseQtVersion::BuildAll) && !(userBuildConfiguration & BaseQtVersion::BuildAll))
|
if ((defaultBuildConfiguration & BaseQtVersion::BuildAll) && !(userBuildConfiguration & BaseQtVersion::BuildAll))
|
||||||
result << QLatin1String("CONFIG-=debug_and_release");
|
result << QLatin1String("CONFIG-=debug_and_release");
|
||||||
|
|||||||
@@ -1107,6 +1107,50 @@ QStringList Qt4PriFileNode::formResources(const QString &formFile) const
|
|||||||
return resourceFiles;
|
return resourceFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Qt4PriFileNode::ensureWriteableProFile(const QString &file)
|
||||||
|
{
|
||||||
|
// Ensure that the file is not read only
|
||||||
|
QFileInfo fi(file);
|
||||||
|
if (!fi.isWritable()) {
|
||||||
|
// Try via vcs manager
|
||||||
|
Core::IVersionControl *versionControl = Core::VcsManager::findVersionControlForDirectory(fi.absolutePath());
|
||||||
|
if (!versionControl || versionControl->vcsOpen(file)) {
|
||||||
|
bool makeWritable = QFile::setPermissions(file, fi.permissions() | QFile::WriteUser);
|
||||||
|
if (!makeWritable) {
|
||||||
|
QMessageBox::warning(Core::ICore::mainWindow(),
|
||||||
|
tr("Failed!"),
|
||||||
|
tr("Could not write project file %1.").arg(file));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair<ProFile *, QStringList> Qt4PriFileNode::readProFile(const QString &file)
|
||||||
|
{
|
||||||
|
QStringList lines;
|
||||||
|
ProFile *includeFile = 0;
|
||||||
|
{
|
||||||
|
QString contents;
|
||||||
|
{
|
||||||
|
Utils::FileReader reader;
|
||||||
|
if (!reader.fetch(file, QIODevice::Text)) {
|
||||||
|
Qt4Project::proFileParseError(reader.errorString());
|
||||||
|
return qMakePair(includeFile, lines);
|
||||||
|
}
|
||||||
|
contents = QString::fromLocal8Bit(reader.data());
|
||||||
|
lines = contents.split(QLatin1Char('\n'));
|
||||||
|
}
|
||||||
|
|
||||||
|
QMakeVfs vfs;
|
||||||
|
QtSupport::ProMessageHandler handler;
|
||||||
|
QMakeParser parser(0, &vfs, &handler);
|
||||||
|
includeFile = parser.parsedProBlock(contents, file, 1);
|
||||||
|
}
|
||||||
|
return qMakePair(includeFile, lines);
|
||||||
|
}
|
||||||
|
|
||||||
void Qt4PriFileNode::changeFiles(const QString &mimeType,
|
void Qt4PriFileNode::changeFiles(const QString &mimeType,
|
||||||
const QStringList &filePaths,
|
const QStringList &filePaths,
|
||||||
QStringList *notChanged,
|
QStringList *notChanged,
|
||||||
@@ -1121,41 +1165,14 @@ void Qt4PriFileNode::changeFiles(const QString &mimeType,
|
|||||||
if (!saveModifiedEditors())
|
if (!saveModifiedEditors())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Ensure that the file is not read only
|
if (!ensureWriteableProFile(m_projectFilePath))
|
||||||
QFileInfo fi(m_projectFilePath);
|
return;
|
||||||
if (!fi.isWritable()) {
|
QPair<ProFile *, QStringList> pair = readProFile(m_projectFilePath);
|
||||||
// Try via vcs manager
|
ProFile *includeFile = pair.first;
|
||||||
Core::IVersionControl *versionControl = Core::VcsManager::findVersionControlForDirectory(fi.absolutePath());
|
QStringList lines = pair.second;
|
||||||
if (!versionControl || versionControl->vcsOpen(m_projectFilePath)) {
|
|
||||||
bool makeWritable = QFile::setPermissions(m_projectFilePath, fi.permissions() | QFile::WriteUser);
|
|
||||||
if (!makeWritable) {
|
|
||||||
QMessageBox::warning(Core::ICore::mainWindow(),
|
|
||||||
tr("Failed!"),
|
|
||||||
tr("Could not write project file %1.").arg(m_projectFilePath));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList lines;
|
if (!includeFile)
|
||||||
ProFile *includeFile;
|
return;
|
||||||
{
|
|
||||||
QString contents;
|
|
||||||
{
|
|
||||||
Utils::FileReader reader;
|
|
||||||
if (!reader.fetch(m_projectFilePath, QIODevice::Text)) {
|
|
||||||
m_project->proFileParseError(reader.errorString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
contents = QString::fromLocal8Bit(reader.data());
|
|
||||||
lines = contents.split(QLatin1Char('\n'));
|
|
||||||
}
|
|
||||||
|
|
||||||
QMakeVfs vfs;
|
|
||||||
QtSupport::ProMessageHandler handler;
|
|
||||||
QMakeParser parser(0, &vfs, &handler);
|
|
||||||
includeFile = parser.parsedProBlock(contents, m_projectFilePath, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDir priFileDir = QDir(m_qt4ProFileNode->m_projectDir);
|
QDir priFileDir = QDir(m_qt4ProFileNode->m_projectDir);
|
||||||
|
|
||||||
@@ -1168,10 +1185,38 @@ void Qt4PriFileNode::changeFiles(const QString &mimeType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save file
|
// save file
|
||||||
Core::DocumentManager::expectFileChange(m_projectFilePath);
|
|
||||||
save(lines);
|
save(lines);
|
||||||
Core::DocumentManager::unexpectFileChange(m_projectFilePath);
|
includeFile->deref();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Qt4PriFileNode::setProVariable(const QString &var, const QString &value)
|
||||||
|
{
|
||||||
|
if (!ensureWriteableProFile(m_projectFilePath))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QPair<ProFile *, QStringList> pair = readProFile(m_projectFilePath);
|
||||||
|
ProFile *includeFile = pair.first;
|
||||||
|
QStringList lines = pair.second;
|
||||||
|
|
||||||
|
ProWriter::putVarValues(includeFile, &lines, QStringList(value), var,
|
||||||
|
ProWriter::ReplaceValues | ProWriter::OneLine | ProWriter::AssignOperator);
|
||||||
|
|
||||||
|
if (!includeFile)
|
||||||
|
return false;
|
||||||
|
save(lines);
|
||||||
|
includeFile->deref();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Qt4PriFileNode::save(const QStringList &lines)
|
||||||
|
{
|
||||||
|
Core::DocumentManager::expectFileChange(m_projectFilePath);
|
||||||
|
Utils::FileSaver saver(m_projectFilePath, QIODevice::Text);
|
||||||
|
saver.write(lines.join(QLatin1String("\n")).toLocal8Bit());
|
||||||
|
saver.finalize(Core::ICore::mainWindow());
|
||||||
|
|
||||||
|
m_project->qt4ProjectManager()->notifyChanged(m_projectFilePath);
|
||||||
|
Core::DocumentManager::unexpectFileChange(m_projectFilePath);
|
||||||
// This is a hack.
|
// This is a hack.
|
||||||
// We are saving twice in a very short timeframe, once the editor and once the ProFile.
|
// We are saving twice in a very short timeframe, once the editor and once the ProFile.
|
||||||
// So the modification time might not change between those two saves.
|
// So the modification time might not change between those two saves.
|
||||||
@@ -1187,17 +1232,6 @@ void Qt4PriFileNode::changeFiles(const QString &mimeType,
|
|||||||
if (!errorStrings.isEmpty())
|
if (!errorStrings.isEmpty())
|
||||||
QMessageBox::warning(Core::ICore::mainWindow(), tr("File Error"),
|
QMessageBox::warning(Core::ICore::mainWindow(), tr("File Error"),
|
||||||
errorStrings.join(QLatin1String("\n")));
|
errorStrings.join(QLatin1String("\n")));
|
||||||
|
|
||||||
includeFile->deref();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Qt4PriFileNode::save(const QStringList &lines)
|
|
||||||
{
|
|
||||||
Utils::FileSaver saver(m_projectFilePath, QIODevice::Text);
|
|
||||||
saver.write(lines.join(QLatin1String("\n")).toLocal8Bit());
|
|
||||||
saver.finalize(Core::ICore::mainWindow());
|
|
||||||
|
|
||||||
m_project->qt4ProjectManager()->notifyChanged(m_projectFilePath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Qt4PriFileNode::varNames(ProjectExplorer::FileType type)
|
QStringList Qt4PriFileNode::varNames(ProjectExplorer::FileType type)
|
||||||
@@ -1674,7 +1708,7 @@ void Qt4ProFileNode::applyEvaluate(EvalResult evalResult, bool async)
|
|||||||
setParseInProgressRecursive(false);
|
setParseInProgressRecursive(false);
|
||||||
|
|
||||||
if (evalResult == EvalFail) {
|
if (evalResult == EvalFail) {
|
||||||
m_project->proFileParseError(tr("Error while parsing file %1. Giving up.").arg(m_projectFilePath));
|
Qt4Project::proFileParseError(tr("Error while parsing file %1. Giving up.").arg(m_projectFilePath));
|
||||||
if (m_projectType == InvalidProject)
|
if (m_projectType == InvalidProject)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1964,6 +1998,7 @@ void Qt4ProFileNode::applyEvaluate(EvalResult evalResult, bool async)
|
|||||||
newVarValues[ShLibExtensionVar] = m_readerExact->values(QLatin1String("QMAKE_EXTENSION_SHLIB"));
|
newVarValues[ShLibExtensionVar] = m_readerExact->values(QLatin1String("QMAKE_EXTENSION_SHLIB"));
|
||||||
newVarValues[AndroidArchVar] = m_readerExact->values(QLatin1String("ANDROID_TARGET_ARCH"));
|
newVarValues[AndroidArchVar] = m_readerExact->values(QLatin1String("ANDROID_TARGET_ARCH"));
|
||||||
newVarValues[AndroidDeploySettingsFile] = m_readerExact->values(QLatin1String("ANDROID_DEPLOYMENT_SETTINGS_FILE"));
|
newVarValues[AndroidDeploySettingsFile] = m_readerExact->values(QLatin1String("ANDROID_DEPLOYMENT_SETTINGS_FILE"));
|
||||||
|
newVarValues[AndroidPackageSourceDir] = m_readerExact->values(QLatin1String("ANDROID_PACKAGE_SOURCE_DIR"));
|
||||||
|
|
||||||
m_isDeployable = false;
|
m_isDeployable = false;
|
||||||
if (m_projectType == ApplicationTemplate) {
|
if (m_projectType == ApplicationTemplate) {
|
||||||
@@ -2112,8 +2147,8 @@ QStringList Qt4ProFileNode::subDirsPaths(QtSupport::ProFileReader *reader, QStri
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!silent)
|
if (!silent)
|
||||||
m_project->proFileParseError(tr("Could not find .pro file for sub dir '%1' in '%2'")
|
Qt4Project::proFileParseError(tr("Could not find .pro file for sub dir '%1' in '%2'")
|
||||||
.arg(subDirVar).arg(realDir));
|
.arg(subDirVar).arg(realDir));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ enum Qt4Variable {
|
|||||||
StaticLibExtensionVar,
|
StaticLibExtensionVar,
|
||||||
ShLibExtensionVar,
|
ShLibExtensionVar,
|
||||||
AndroidArchVar,
|
AndroidArchVar,
|
||||||
AndroidDeploySettingsFile
|
AndroidDeploySettingsFile,
|
||||||
|
AndroidPackageSourceDir
|
||||||
};
|
};
|
||||||
|
|
||||||
// Import base classes into namespace
|
// Import base classes into namespace
|
||||||
@@ -159,6 +160,8 @@ public:
|
|||||||
bool deleteFiles(const QStringList &filePaths);
|
bool deleteFiles(const QStringList &filePaths);
|
||||||
bool renameFile(const QString &filePath, const QString &newFilePath);
|
bool renameFile(const QString &filePath, const QString &newFilePath);
|
||||||
|
|
||||||
|
bool setProVariable(const QString &var, const QString &value);
|
||||||
|
|
||||||
bool folderChanged(const QString &changedFolder, const QSet<Utils::FileName> &newFiles);
|
bool folderChanged(const QString &changedFolder, const QSet<Utils::FileName> &newFiles);
|
||||||
|
|
||||||
bool deploysFolder(const QString &folder) const;
|
bool deploysFolder(const QString &folder) const;
|
||||||
@@ -193,6 +196,8 @@ private slots:
|
|||||||
void scheduleUpdate();
|
void scheduleUpdate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static bool ensureWriteableProFile(const QString &file);
|
||||||
|
static QPair<ProFile *, QStringList> readProFile(const QString &file);
|
||||||
void save(const QStringList &lines);
|
void save(const QStringList &lines);
|
||||||
bool priFileWritable(const QString &path);
|
bool priFileWritable(const QString &path);
|
||||||
bool saveModifiedEditors();
|
bool saveModifiedEditors();
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ public:
|
|||||||
static QString buildNameFor(const ProjectExplorer::Kit *k);
|
static QString buildNameFor(const ProjectExplorer::Kit *k);
|
||||||
|
|
||||||
void emitBuildDirectoryInitialized();
|
void emitBuildDirectoryInitialized();
|
||||||
|
static void proFileParseError(const QString &errorMessage);
|
||||||
|
|
||||||
ProjectExplorer::ProjectImporter *createProjectImporter() const;
|
ProjectExplorer::ProjectImporter *createProjectImporter() const;
|
||||||
|
|
||||||
@@ -149,7 +150,6 @@ signals:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void scheduleAsyncUpdate();
|
void scheduleAsyncUpdate();
|
||||||
void proFileParseError(const QString &errorMessage);
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user