forked from qt-creator/qt-creator
AndroidRunConfigurations: Split up into general and qmake specific parts
The plan is to eventually move the qmake specific class into the qmake plugin. Change-Id: I5653c45ed88b1be296f4963ab4117bbfa791fb85 Reviewed-by: BogDan Vatra <bogdan@kde.org>
This commit is contained in:
@@ -53,7 +53,9 @@ HEADERS += \
|
||||
javafilewizard.h \
|
||||
avddialog.h \
|
||||
android_global.h \
|
||||
qmakeandroidsupport.h
|
||||
qmakeandroidsupport.h \
|
||||
qmakeandroidrunfactories.h \
|
||||
qmakeandroidrunconfiguration.h
|
||||
|
||||
SOURCES += \
|
||||
androidconfigurations.cpp \
|
||||
@@ -99,7 +101,9 @@ SOURCES += \
|
||||
javacompletionassistprovider.cpp \
|
||||
javafilewizard.cpp \
|
||||
avddialog.cpp \
|
||||
qmakeandroidsupport.cpp
|
||||
qmakeandroidsupport.cpp \
|
||||
qmakeandroidrunfactories.cpp \
|
||||
qmakeandroidrunconfiguration.cpp
|
||||
|
||||
FORMS += \
|
||||
androidsettingswidget.ui \
|
||||
|
||||
@@ -116,7 +116,12 @@ QtcPlugin {
|
||||
"javaindenter.h",
|
||||
"javaparser.cpp",
|
||||
"javaparser.h",
|
||||
"qmakeandroidrunconfiguration.cpp",
|
||||
"qmakeandroidrunconfiguration.h",
|
||||
"qmakeandroidrunfactories.cpp",
|
||||
"qmakeandroidrunfactories.h",
|
||||
"qmakeandroidsupport.cpp",
|
||||
"qmakeandroidsupport.h",
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
@@ -37,9 +37,10 @@ namespace Analyzer { class AnalyzerRunControl; }
|
||||
namespace ProjectExplorer { class RunControl; }
|
||||
|
||||
namespace Android {
|
||||
class AndroidRunConfiguration;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class AndroidRunConfiguration;
|
||||
class AndroidRunner;
|
||||
|
||||
class AndroidAnalyzeSupport : public AndroidRunSupport
|
||||
|
||||
@@ -39,9 +39,10 @@ class DebuggerRunControl;
|
||||
namespace ProjectExplorer { class RunControl; }
|
||||
|
||||
namespace Android {
|
||||
class AndroidRunConfiguration;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class AndroidRunConfiguration;
|
||||
class AndroidRunner;
|
||||
|
||||
class AndroidDebugSupport : public AndroidRunSupport
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "javacompletionassistprovider.h"
|
||||
#include "javafilewizard.h"
|
||||
#include "qmakeandroidsupport.h"
|
||||
#include "qmakeandroidrunfactories.h"
|
||||
#ifdef HAVE_QBS
|
||||
# include "androidqbspropertyprovider.h"
|
||||
#endif
|
||||
@@ -74,7 +75,7 @@ bool AndroidPlugin::initialize(const QStringList &arguments, QString *errorMessa
|
||||
new Internal::AndroidConfigurations(this);
|
||||
|
||||
addAutoReleasedObject(new Internal::AndroidRunControlFactory);
|
||||
addAutoReleasedObject(new Internal::AndroidRunConfigurationFactory);
|
||||
addAutoReleasedObject(new Internal::QmakeAndroidRunConfigurationFactory);
|
||||
addAutoReleasedObject(new Internal::AndroidPackageInstallationFactory);
|
||||
addAutoReleasedObject(new Internal::AndroidDeployQtStepFactory);
|
||||
addAutoReleasedObject(new Internal::AndroidSettingsPage);
|
||||
|
||||
@@ -36,36 +36,21 @@
|
||||
#include <projectexplorer/target.h>
|
||||
#include <qtsupport/qtoutputformatter.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qmakeprojectmanager/qmakeproject.h>
|
||||
#include <qmakeprojectmanager/qmakenodes.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
namespace {
|
||||
const char PRO_FILE_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.ProFile";
|
||||
}
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using QmakeProjectManager::QmakeProject;
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
AndroidRunConfiguration::AndroidRunConfiguration(Target *parent, Core::Id id, const QString &path)
|
||||
AndroidRunConfiguration::AndroidRunConfiguration(Target *parent, Core::Id id)
|
||||
: RunConfiguration(parent, id)
|
||||
, m_proFilePath(path)
|
||||
{
|
||||
QmakeProject *project = static_cast<QmakeProject *>(parent->project());
|
||||
m_parseSuccess = project->validParse(m_proFilePath);
|
||||
m_parseInProgress = project->parseInProgress(m_proFilePath);
|
||||
init();
|
||||
}
|
||||
|
||||
AndroidRunConfiguration::AndroidRunConfiguration(Target *parent, AndroidRunConfiguration *source)
|
||||
: RunConfiguration(parent, source)
|
||||
, m_proFilePath(source->m_proFilePath)
|
||||
, m_parseSuccess(source->m_parseSuccess)
|
||||
, m_parseInProgress(source->m_parseInProgress)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -73,55 +58,6 @@ AndroidRunConfiguration::AndroidRunConfiguration(Target *parent, AndroidRunConfi
|
||||
void AndroidRunConfiguration::init()
|
||||
{
|
||||
setDefaultDisplayName(defaultDisplayName());
|
||||
connect(target()->project(), SIGNAL(proFileUpdated(QmakeProjectManager::QmakeProFileNode*,bool,bool)),
|
||||
this, SLOT(proFileUpdated(QmakeProjectManager::QmakeProFileNode*,bool,bool)));
|
||||
}
|
||||
|
||||
bool AndroidRunConfiguration::fromMap(const QVariantMap &map)
|
||||
{
|
||||
const QDir projectDir = QDir(target()->project()->projectDirectory().toString());
|
||||
m_proFilePath = QDir::cleanPath(projectDir.filePath(map.value(QLatin1String(PRO_FILE_KEY)).toString()));
|
||||
m_parseSuccess = static_cast<QmakeProject *>(target()->project())->validParse(m_proFilePath);
|
||||
m_parseInProgress = static_cast<QmakeProject *>(target()->project())->parseInProgress(m_proFilePath);
|
||||
|
||||
return RunConfiguration::fromMap(map);
|
||||
}
|
||||
|
||||
QVariantMap AndroidRunConfiguration::toMap() const
|
||||
{
|
||||
const QDir projectDir = QDir(target()->project()->projectDirectory().toString());
|
||||
QVariantMap map(RunConfiguration::toMap());
|
||||
map.insert(QLatin1String(PRO_FILE_KEY), projectDir.relativeFilePath(m_proFilePath));
|
||||
return map;
|
||||
}
|
||||
|
||||
bool AndroidRunConfiguration::isEnabled() const
|
||||
{
|
||||
return m_parseSuccess && !m_parseInProgress;
|
||||
}
|
||||
|
||||
QString AndroidRunConfiguration::disabledReason() const
|
||||
{
|
||||
if (m_parseInProgress)
|
||||
return tr("The .pro file \"%1\" is currently being parsed.")
|
||||
.arg(QFileInfo(m_proFilePath).fileName());
|
||||
|
||||
if (!m_parseSuccess)
|
||||
return static_cast<QmakeProject *>(target()->project())->disabledReasonForRunConfiguration(m_proFilePath);
|
||||
return QString();
|
||||
}
|
||||
|
||||
void AndroidRunConfiguration::proFileUpdated(QmakeProjectManager::QmakeProFileNode *pro, bool success, bool parseInProgress)
|
||||
{
|
||||
if (m_proFilePath != pro->path())
|
||||
return;
|
||||
|
||||
bool enabled = isEnabled();
|
||||
QString reason = disabledReason();
|
||||
m_parseSuccess = success;
|
||||
m_parseInProgress = parseInProgress;
|
||||
if (enabled != isEnabled() || reason != disabledReason())
|
||||
emit enabledChanged();
|
||||
}
|
||||
|
||||
QWidget *AndroidRunConfiguration::createConfigurationWidget()
|
||||
@@ -144,10 +80,4 @@ const QString AndroidRunConfiguration::remoteChannel() const
|
||||
return QLatin1String(":5039");
|
||||
}
|
||||
|
||||
QString AndroidRunConfiguration::proFilePath() const
|
||||
{
|
||||
return m_proFilePath;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
||||
@@ -30,54 +30,32 @@
|
||||
#ifndef ANDROIDRUNCONFIGURATION_H
|
||||
#define ANDROIDRUNCONFIGURATION_H
|
||||
|
||||
#include "android_global.h"
|
||||
#include "androidconstants.h"
|
||||
#include "androidconfigurations.h"
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
namespace QmakeProjectManager { class QmakeProFileNode; }
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
class AndroidDeployStep;
|
||||
class AndroidRunConfigurationFactory;
|
||||
|
||||
class AndroidRunConfiguration : public ProjectExplorer::RunConfiguration
|
||||
class ANDROID_EXPORT AndroidRunConfiguration : public ProjectExplorer::RunConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class AndroidRunConfigurationFactory;
|
||||
|
||||
public:
|
||||
AndroidRunConfiguration(ProjectExplorer::Target *parent, Core::Id id, const QString &path);
|
||||
AndroidRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
|
||||
|
||||
QWidget *createConfigurationWidget();
|
||||
Utils::OutputFormatter *createOutputFormatter() const;
|
||||
|
||||
void setArguments(const QString &args);
|
||||
QString proFilePath() const;
|
||||
|
||||
const QString remoteChannel() const;
|
||||
|
||||
bool isEnabled() const;
|
||||
QString disabledReason() const;
|
||||
protected:
|
||||
AndroidRunConfiguration(ProjectExplorer::Target *parent, AndroidRunConfiguration *source);
|
||||
QString defaultDisplayName();
|
||||
|
||||
bool fromMap(const QVariantMap &map);
|
||||
QVariantMap toMap() const;
|
||||
private slots:
|
||||
void proFileUpdated(QmakeProjectManager::QmakeProFileNode *pro, bool success, bool parseInProgress);
|
||||
private:
|
||||
void init();
|
||||
|
||||
QString m_proFilePath;
|
||||
bool m_parseSuccess;
|
||||
bool m_parseInProgress;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
||||
#endif // ANDROIDRUNCONFIGURATION_H
|
||||
|
||||
@@ -33,9 +33,10 @@
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
namespace Android {
|
||||
class AndroidRunConfiguration;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class AndroidRunConfiguration;
|
||||
class AndroidRunner;
|
||||
|
||||
class AndroidRunControl : public ProjectExplorer::RunControl
|
||||
|
||||
@@ -40,114 +40,16 @@
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <debugger/debuggerconstants.h>
|
||||
#include <qmakeprojectmanager/qmakeproject.h>
|
||||
#include <qmakeprojectmanager/qmakenodes.h>
|
||||
#include <qtsupport/customexecutablerunconfiguration.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace QmakeProjectManager;
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
static const char ANDROID_RC_ID_PREFIX[] = "Qt4ProjectManager.AndroidRunConfiguration:";
|
||||
|
||||
static QString pathFromId(Core::Id id)
|
||||
{
|
||||
return id.suffixAfter(ANDROID_RC_ID_PREFIX);
|
||||
}
|
||||
|
||||
AndroidRunConfigurationFactory::AndroidRunConfigurationFactory(QObject *parent)
|
||||
: QmakeRunConfigurationFactory(parent)
|
||||
{
|
||||
setObjectName(QLatin1String("AndroidRunConfigurationFactory"));
|
||||
}
|
||||
|
||||
bool AndroidRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
return availableCreationIds(parent).contains(id);
|
||||
}
|
||||
|
||||
bool AndroidRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
return ProjectExplorer::idFromMap(map).name().startsWith(ANDROID_RC_ID_PREFIX);
|
||||
}
|
||||
|
||||
bool AndroidRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
||||
{
|
||||
return canCreate(parent, source->id());
|
||||
}
|
||||
|
||||
QList<Core::Id> AndroidRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
||||
{
|
||||
if (!AndroidManager::supportsAndroid(parent))
|
||||
return QList<Core::Id>();
|
||||
|
||||
QmakeProject *project = static_cast<QmakeProject *>(parent->project());
|
||||
|
||||
QList<QmakeProFileNode *> nodes = project->allProFiles(QList<QmakeProjectType>()
|
||||
<< ApplicationTemplate
|
||||
<< LibraryTemplate);
|
||||
|
||||
if (mode == AutoCreate)
|
||||
nodes = QmakeProject::nodesWithQtcRunnable(nodes);
|
||||
|
||||
const Core::Id base = Core::Id(ANDROID_RC_ID_PREFIX);
|
||||
return QmakeProject::idsForNodes(base, nodes);
|
||||
}
|
||||
|
||||
QString AndroidRunConfigurationFactory::displayNameForId(Core::Id id) const
|
||||
{
|
||||
return QFileInfo(pathFromId(id)).completeBaseName();
|
||||
}
|
||||
|
||||
RunConfiguration *AndroidRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
|
||||
{
|
||||
return new AndroidRunConfiguration(parent, id, pathFromId(id));
|
||||
}
|
||||
|
||||
RunConfiguration *AndroidRunConfigurationFactory::doRestore(Target *parent,
|
||||
const QVariantMap &map)
|
||||
{
|
||||
Core::Id id = ProjectExplorer::idFromMap(map);
|
||||
return new AndroidRunConfiguration(parent, id, pathFromId(id));
|
||||
}
|
||||
|
||||
RunConfiguration *AndroidRunConfigurationFactory::clone(Target *parent, RunConfiguration *source)
|
||||
{
|
||||
if (!canClone(parent, source))
|
||||
return 0;
|
||||
|
||||
AndroidRunConfiguration *old = static_cast<AndroidRunConfiguration *>(source);
|
||||
return new AndroidRunConfiguration(parent, old);
|
||||
}
|
||||
|
||||
bool AndroidRunConfigurationFactory::canHandle(Target *t) const
|
||||
{
|
||||
if (!t->project()->supportsKit(t->kit()))
|
||||
return false;
|
||||
return AndroidManager::supportsAndroid(t);
|
||||
}
|
||||
|
||||
QList<RunConfiguration *> AndroidRunConfigurationFactory::runConfigurationsForNode(Target *t, const Node *n)
|
||||
{
|
||||
QList<ProjectExplorer::RunConfiguration *> result;
|
||||
foreach (ProjectExplorer::RunConfiguration *rc, t->runConfigurations())
|
||||
if (AndroidRunConfiguration *qt4c = qobject_cast<AndroidRunConfiguration *>(rc))
|
||||
if (qt4c->proFilePath() == n->path())
|
||||
result << rc;
|
||||
return result;
|
||||
}
|
||||
|
||||
// #pragma mark -- AndroidRunControlFactory
|
||||
|
||||
AndroidRunControlFactory::AndroidRunControlFactory(QObject *parent)
|
||||
: IRunControlFactory(parent)
|
||||
{
|
||||
|
||||
@@ -30,8 +30,9 @@
|
||||
#ifndef ANDROIDRUNFACTORIES_H
|
||||
#define ANDROIDRUNFACTORIES_H
|
||||
|
||||
#include "android_global.h"
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <qmakeprojectmanager/qmakerunconfigurationfactory.h>
|
||||
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class RunControl;
|
||||
@@ -43,34 +44,6 @@ class Node;
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
class AndroidRunConfigurationFactory : public QmakeProjectManager::QmakeRunConfigurationFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AndroidRunConfigurationFactory(QObject *parent = 0);
|
||||
|
||||
QString displayNameForId(Core::Id id) const;
|
||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode = UserCreate) const;
|
||||
|
||||
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const;
|
||||
|
||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
||||
|
||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const;
|
||||
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source);
|
||||
|
||||
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
||||
const ProjectExplorer::Node *n);
|
||||
|
||||
private:
|
||||
bool canHandle(ProjectExplorer::Target *t) const;
|
||||
|
||||
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, Core::Id id);
|
||||
ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map);
|
||||
};
|
||||
|
||||
class AndroidRunControlFactory : public ProjectExplorer::IRunControlFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -41,9 +41,10 @@
|
||||
#include <QMutex>
|
||||
|
||||
namespace Android {
|
||||
class AndroidRunConfiguration;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class AndroidRunConfiguration;
|
||||
|
||||
class AndroidRunner : public QThread
|
||||
{
|
||||
|
||||
139
src/plugins/android/qmakeandroidrunconfiguration.cpp
Normal file
139
src/plugins/android/qmakeandroidrunconfiguration.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** Copyright (c) 2014 BogDan Vatra <bog_dan_ro@yahoo.com>
|
||||
** 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 "qmakeandroidrunconfiguration.h"
|
||||
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <qtsupport/qtoutputformatter.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qmakeprojectmanager/qmakeproject.h>
|
||||
#include <qmakeprojectmanager/qmakenodes.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
namespace {
|
||||
QLatin1String PRO_FILE_KEY("QMakeProjectManager.QmakeAndroidRunConfiguration.ProFile");
|
||||
}
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using QmakeProjectManager::QmakeProject;
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
QmakeAndroidRunConfiguration::QmakeAndroidRunConfiguration(Target *parent, Core::Id id, const QString &path)
|
||||
: AndroidRunConfiguration(parent, id)
|
||||
, m_proFilePath(path)
|
||||
{
|
||||
QmakeProject *project = static_cast<QmakeProject *>(parent->project());
|
||||
m_parseSuccess = project->validParse(m_proFilePath);
|
||||
m_parseInProgress = project->parseInProgress(m_proFilePath);
|
||||
init();
|
||||
}
|
||||
|
||||
QmakeAndroidRunConfiguration::QmakeAndroidRunConfiguration(Target *parent, QmakeAndroidRunConfiguration *source)
|
||||
: AndroidRunConfiguration(parent, source)
|
||||
, m_proFilePath(source->m_proFilePath)
|
||||
, m_parseSuccess(source->m_parseSuccess)
|
||||
, m_parseInProgress(source->m_parseInProgress)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void QmakeAndroidRunConfiguration::init()
|
||||
{
|
||||
connect(target()->project(), SIGNAL(proFileUpdated(QmakeProjectManager::QmakeProFileNode*,bool,bool)),
|
||||
this, SLOT(proFileUpdated(QmakeProjectManager::QmakeProFileNode*,bool,bool)));
|
||||
}
|
||||
|
||||
bool QmakeAndroidRunConfiguration::fromMap(const QVariantMap &map)
|
||||
{
|
||||
const QDir projectDir = QDir(target()->project()->projectDirectory().toString());
|
||||
m_proFilePath = QDir::cleanPath(projectDir.filePath(map.value(PRO_FILE_KEY).toString()));
|
||||
m_parseSuccess = static_cast<QmakeProject *>(target()->project())->validParse(m_proFilePath);
|
||||
m_parseInProgress = static_cast<QmakeProject *>(target()->project())->parseInProgress(m_proFilePath);
|
||||
|
||||
return RunConfiguration::fromMap(map);
|
||||
}
|
||||
|
||||
QVariantMap QmakeAndroidRunConfiguration::toMap() const
|
||||
{
|
||||
if (m_proFilePath.isEmpty()) {
|
||||
if (!target()->project()->rootProjectNode())
|
||||
return QVariantMap();
|
||||
m_proFilePath = target()->project()->rootProjectNode()->path();
|
||||
}
|
||||
|
||||
const QDir projectDir = QDir(target()->project()->projectDirectory().toString());
|
||||
QVariantMap map(RunConfiguration::toMap());
|
||||
map.insert(PRO_FILE_KEY, projectDir.relativeFilePath(m_proFilePath));
|
||||
return map;
|
||||
}
|
||||
|
||||
bool QmakeAndroidRunConfiguration::isEnabled() const
|
||||
{
|
||||
return m_parseSuccess && !m_parseInProgress;
|
||||
}
|
||||
|
||||
QString QmakeAndroidRunConfiguration::disabledReason() const
|
||||
{
|
||||
if (m_parseInProgress)
|
||||
return tr("The .pro file \"%1\" is currently being parsed.")
|
||||
.arg(QFileInfo(m_proFilePath).fileName());
|
||||
|
||||
if (!m_parseSuccess)
|
||||
return static_cast<QmakeProject *>(target()->project())->disabledReasonForRunConfiguration(m_proFilePath);
|
||||
return QString();
|
||||
}
|
||||
|
||||
void QmakeAndroidRunConfiguration::proFileUpdated(QmakeProjectManager::QmakeProFileNode *pro, bool success, bool parseInProgress)
|
||||
{
|
||||
if (m_proFilePath.isEmpty() && target()->project()->rootProjectNode()) {
|
||||
m_proFilePath = target()->project()->rootProjectNode()->path();
|
||||
}
|
||||
|
||||
if (m_proFilePath != pro->path())
|
||||
return;
|
||||
|
||||
bool enabled = isEnabled();
|
||||
QString reason = disabledReason();
|
||||
m_parseSuccess = success;
|
||||
m_parseInProgress = parseInProgress;
|
||||
if (enabled != isEnabled() || reason != disabledReason())
|
||||
emit enabledChanged();
|
||||
}
|
||||
|
||||
QString QmakeAndroidRunConfiguration::proFilePath() const
|
||||
{
|
||||
return m_proFilePath;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
73
src/plugins/android/qmakeandroidrunconfiguration.h
Normal file
73
src/plugins/android/qmakeandroidrunconfiguration.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** Copyright (c) 2014 BogDan Vatra <bog_dan_ro@yahoo.com>
|
||||
** 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 QMAKE_ANDROIDRUNCONFIGURATION_H
|
||||
#define QMAKE_ANDROIDRUNCONFIGURATION_H
|
||||
|
||||
#include "androidrunconfiguration.h"
|
||||
|
||||
namespace QmakeProjectManager { class QmakeProFileNode; }
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
class QmakeAndroidRunConfiguration : public Android::AndroidRunConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class QmakeAndroidRunConfigurationFactory;
|
||||
|
||||
public:
|
||||
QmakeAndroidRunConfiguration(ProjectExplorer::Target *parent, Core::Id id, const QString &path = QString());
|
||||
|
||||
QString proFilePath() const;
|
||||
|
||||
bool isEnabled() const;
|
||||
QString disabledReason() const;
|
||||
|
||||
protected:
|
||||
QmakeAndroidRunConfiguration(ProjectExplorer::Target *parent, QmakeAndroidRunConfiguration *source);
|
||||
|
||||
bool fromMap(const QVariantMap &map);
|
||||
QVariantMap toMap() const;
|
||||
|
||||
private slots:
|
||||
void proFileUpdated(QmakeProjectManager::QmakeProFileNode *pro, bool success, bool parseInProgress);
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
mutable QString m_proFilePath;
|
||||
bool m_parseSuccess;
|
||||
bool m_parseInProgress;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
||||
#endif // QMAKE_ANDROIDRUNCONFIGURATION_H
|
||||
148
src/plugins/android/qmakeandroidrunfactories.cpp
Normal file
148
src/plugins/android/qmakeandroidrunfactories.cpp
Normal file
@@ -0,0 +1,148 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** Copyright (c) 2014 BogDan Vatra <bog_dan_ro@yahoo.com>
|
||||
** 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 "qmakeandroidrunfactories.h"
|
||||
#include "qmakeandroidrunconfiguration.h"
|
||||
|
||||
#include <android/androidmanager.h>
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <debugger/debuggerconstants.h>
|
||||
#include <qmakeprojectmanager/qmakeproject.h>
|
||||
#include <qmakeprojectmanager/qmakenodes.h>
|
||||
#include <qtsupport/customexecutablerunconfiguration.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
|
||||
|
||||
using namespace Android;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace QmakeProjectManager;
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
static const char ANDROID_RC_ID_PREFIX[] = "Qt4ProjectManager.AndroidRunConfiguration:";
|
||||
|
||||
static QString pathFromId(const Core::Id id)
|
||||
{
|
||||
return id.suffixAfter(ANDROID_RC_ID_PREFIX);
|
||||
}
|
||||
|
||||
QmakeAndroidRunConfigurationFactory::QmakeAndroidRunConfigurationFactory(QObject *parent)
|
||||
: ProjectExplorer::IRunConfigurationFactory(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QString QmakeAndroidRunConfigurationFactory::displayNameForId(const Core::Id id) const
|
||||
{
|
||||
return QFileInfo(pathFromId(id)).completeBaseName();
|
||||
}
|
||||
|
||||
bool QmakeAndroidRunConfigurationFactory::canCreate(Target *parent, const Core::Id id) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
return availableCreationIds(parent).contains(id);
|
||||
}
|
||||
|
||||
bool QmakeAndroidRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
||||
{
|
||||
return canCreate(parent, ProjectExplorer::idFromMap(map));
|
||||
}
|
||||
|
||||
bool QmakeAndroidRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
||||
{
|
||||
return canCreate(parent, source->id());
|
||||
}
|
||||
|
||||
QList<Core::Id> QmakeAndroidRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return QList<Core::Id>();
|
||||
|
||||
QmakeProject *project = static_cast<QmakeProject *>(parent->project());
|
||||
QList<QmakeProFileNode *> nodes = project->allProFiles(QList<QmakeProjectType>()
|
||||
<< ApplicationTemplate
|
||||
<< LibraryTemplate);
|
||||
|
||||
if (mode == AutoCreate)
|
||||
nodes = QmakeProject::nodesWithQtcRunnable(nodes);
|
||||
|
||||
const Core::Id base = Core::Id(ANDROID_RC_ID_PREFIX);
|
||||
return QmakeProject::idsForNodes(base, nodes);
|
||||
}
|
||||
|
||||
RunConfiguration *QmakeAndroidRunConfigurationFactory::doCreate(Target *parent, const Core::Id id)
|
||||
{
|
||||
if (parent->project()->rootProjectNode())
|
||||
return new QmakeAndroidRunConfiguration(parent, id, parent->project()->rootProjectNode()->path());
|
||||
return new QmakeAndroidRunConfiguration(parent, id);
|
||||
}
|
||||
|
||||
RunConfiguration *QmakeAndroidRunConfigurationFactory::doRestore(Target *parent,
|
||||
const QVariantMap &map)
|
||||
{
|
||||
Core::Id id = ProjectExplorer::idFromMap(map);
|
||||
if (parent->project()->rootProjectNode())
|
||||
return new QmakeAndroidRunConfiguration(parent, id, parent->project()->rootProjectNode()->path());
|
||||
return new QmakeAndroidRunConfiguration(parent, id);
|
||||
}
|
||||
|
||||
RunConfiguration *QmakeAndroidRunConfigurationFactory::clone(Target *parent, RunConfiguration *source)
|
||||
{
|
||||
if (!canClone(parent, source))
|
||||
return 0;
|
||||
|
||||
QmakeAndroidRunConfiguration *old = static_cast<QmakeAndroidRunConfiguration *>(source);
|
||||
return new QmakeAndroidRunConfiguration(parent, old);
|
||||
}
|
||||
|
||||
bool QmakeAndroidRunConfigurationFactory::canHandle(Target *t) const
|
||||
{
|
||||
return t->project()->supportsKit(t->kit())
|
||||
&& AndroidManager::supportsAndroid(t)
|
||||
&& qobject_cast<QmakeProject *>(t->project());
|
||||
}
|
||||
|
||||
#warning FIX ME !!!
|
||||
QList<RunConfiguration *> QmakeAndroidRunConfigurationFactory::runConfigurationsForNode(Target *t, ProjectExplorer::Node *n)
|
||||
{
|
||||
QList<ProjectExplorer::RunConfiguration *> result;
|
||||
foreach (ProjectExplorer::RunConfiguration *rc, t->runConfigurations())
|
||||
if (QmakeAndroidRunConfiguration *qt4c = qobject_cast<QmakeAndroidRunConfiguration *>(rc))
|
||||
if (qt4c->proFilePath() == n->path())
|
||||
result << rc;
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
78
src/plugins/android/qmakeandroidrunfactories.h
Normal file
78
src/plugins/android/qmakeandroidrunfactories.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** Copyright (c) 2014 BogDan Vatra <bog_dan_ro@yahoo.com>
|
||||
** 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 QMAKE_ANDROIDRUNFACTORIES_H
|
||||
#define QMAKE_ANDROIDRUNFACTORIES_H
|
||||
|
||||
#include <android/androidrunfactories.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <qmakeprojectmanager/qmakerunconfigurationfactory.h>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class RunControl;
|
||||
class RunConfigWidget;
|
||||
class Target;
|
||||
class Node;
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
class QmakeAndroidRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QmakeAndroidRunConfigurationFactory(QObject *parent = 0);
|
||||
|
||||
QString displayNameForId(const Core::Id id) const;
|
||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode = UserCreate) const;
|
||||
|
||||
bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const;
|
||||
|
||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
|
||||
|
||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const;
|
||||
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source);
|
||||
|
||||
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
||||
ProjectExplorer::Node *n);
|
||||
|
||||
private:
|
||||
bool canHandle(ProjectExplorer::Target *t) const;
|
||||
|
||||
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id);
|
||||
ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
|
||||
const QVariantMap &map);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
||||
#endif // ANDROIDRUNFACTORIES_H
|
||||
Reference in New Issue
Block a user