forked from qt-creator/qt-creator
Android: Make runconfiguration use aspects
Change-Id: I6d89de901e64b2f29d62073e458eb6cd86c44acd Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
This commit is contained in:
@@ -54,7 +54,7 @@ static void swapData(QStringListModel *model, const QModelIndex &srcIndex,
|
||||
class AdbCommandsWidgetPrivate
|
||||
{
|
||||
public:
|
||||
AdbCommandsWidgetPrivate(const AdbCommandsWidget &parent, QWidget *parentWidget);
|
||||
AdbCommandsWidgetPrivate(AdbCommandsWidget *parent);
|
||||
~AdbCommandsWidgetPrivate();
|
||||
|
||||
private:
|
||||
@@ -65,16 +65,15 @@ private:
|
||||
void onRemove();
|
||||
void onCurrentIndexChanged(const QModelIndex &newIndex, const QModelIndex &prevIndex);
|
||||
|
||||
const AdbCommandsWidget &m_parent;
|
||||
QGroupBox *m_rootWidget = nullptr;
|
||||
AdbCommandsWidget *q;
|
||||
Ui::AdbCommandsWidget *m_ui = nullptr;
|
||||
QStringListModel *m_stringModel = nullptr;
|
||||
friend class AdbCommandsWidget;
|
||||
};
|
||||
|
||||
AdbCommandsWidget::AdbCommandsWidget(QWidget *parent) :
|
||||
QObject(parent),
|
||||
d(new AdbCommandsWidgetPrivate(*this, parent))
|
||||
QGroupBox(parent),
|
||||
d(new AdbCommandsWidgetPrivate(this))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -87,14 +86,9 @@ QStringList AdbCommandsWidget::commandsList() const
|
||||
return d->m_stringModel->stringList();
|
||||
}
|
||||
|
||||
QWidget *AdbCommandsWidget::widget() const
|
||||
{
|
||||
return d->m_rootWidget;
|
||||
}
|
||||
|
||||
void AdbCommandsWidget::setTitleText(const QString &title)
|
||||
{
|
||||
d->m_rootWidget->setTitle(title);
|
||||
setTitle(title);
|
||||
}
|
||||
|
||||
void AdbCommandsWidget::setCommandList(const QStringList &commands)
|
||||
@@ -102,14 +96,12 @@ void AdbCommandsWidget::setCommandList(const QStringList &commands)
|
||||
d->m_stringModel->setStringList(commands);
|
||||
}
|
||||
|
||||
AdbCommandsWidgetPrivate::AdbCommandsWidgetPrivate(const AdbCommandsWidget &parent,
|
||||
QWidget *parentWidget):
|
||||
m_parent(parent),
|
||||
m_rootWidget(new QGroupBox(parentWidget)),
|
||||
AdbCommandsWidgetPrivate::AdbCommandsWidgetPrivate(AdbCommandsWidget *q):
|
||||
q(q),
|
||||
m_ui(new Ui::AdbCommandsWidget),
|
||||
m_stringModel(new QStringListModel)
|
||||
{
|
||||
m_ui->setupUi(m_rootWidget);
|
||||
m_ui->setupUi(q);
|
||||
m_ui->addButton->setIcon(Utils::Icons::PLUS.icon());
|
||||
m_ui->removeButton->setIcon(Utils::Icons::MINUS.icon());
|
||||
m_ui->moveUpButton->setIcon(Utils::Icons::ARROW_UP.icon());
|
||||
@@ -131,9 +123,9 @@ AdbCommandsWidgetPrivate::AdbCommandsWidgetPrivate(const AdbCommandsWidget &pare
|
||||
|
||||
m_ui->commandsView->setModel(m_stringModel);
|
||||
QObject::connect(m_stringModel, &QStringListModel::dataChanged,
|
||||
&m_parent, &AdbCommandsWidget::commandsChanged);
|
||||
q, &AdbCommandsWidget::commandsChanged);
|
||||
QObject::connect(m_stringModel, &QStringListModel::rowsRemoved,
|
||||
&m_parent, &AdbCommandsWidget::commandsChanged);
|
||||
q, &AdbCommandsWidget::commandsChanged);
|
||||
QObject::connect(m_ui->commandsView->selectionModel(), &QItemSelectionModel::currentChanged,
|
||||
std::bind(&AdbCommandsWidgetPrivate::onCurrentIndexChanged, this, _1, _2));
|
||||
}
|
||||
|
||||
@@ -25,21 +25,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QGroupBox>
|
||||
#include <QStringList>
|
||||
|
||||
#include <memory>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
class AdbCommandsWidgetPrivate;
|
||||
|
||||
class AdbCommandsWidget : public QObject
|
||||
class AdbCommandsWidget : public QGroupBox
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -49,8 +45,6 @@ public:
|
||||
QStringList commandsList() const;
|
||||
void setCommandList(const QStringList &commands);
|
||||
|
||||
QWidget *widget() const;
|
||||
|
||||
void setTitleText(const QString &title);
|
||||
|
||||
signals:
|
||||
|
||||
@@ -50,7 +50,6 @@ HEADERS += \
|
||||
androidtoolmanager.h \
|
||||
androidsdkmanager.h \
|
||||
androidavdmanager.h \
|
||||
androidrunconfigurationwidget.h \
|
||||
adbcommandswidget.h \
|
||||
androidsdkpackage.h \
|
||||
androidsdkmodel.h \
|
||||
@@ -99,7 +98,6 @@ SOURCES += \
|
||||
androidtoolmanager.cpp \
|
||||
androidsdkmanager.cpp \
|
||||
androidavdmanager.cpp \
|
||||
androidrunconfigurationwidget.cpp \
|
||||
adbcommandswidget.cpp \
|
||||
androidsdkpackage.cpp \
|
||||
androidsdkmodel.cpp \
|
||||
@@ -113,7 +111,6 @@ FORMS += \
|
||||
androiddevicedialog.ui \
|
||||
androiddeployqtwidget.ui \
|
||||
androidbuildapkwidget.ui \
|
||||
androidrunconfigurationwidget.ui \
|
||||
adbcommandswidget.ui \
|
||||
androidsdkmanagerwidget.ui
|
||||
|
||||
|
||||
@@ -84,9 +84,6 @@ Project {
|
||||
"androidqtversionfactory.h",
|
||||
"androidrunconfiguration.cpp",
|
||||
"androidrunconfiguration.h",
|
||||
"androidrunconfigurationwidget.cpp",
|
||||
"androidrunconfigurationwidget.h",
|
||||
"androidrunconfigurationwidget.ui",
|
||||
"androidruncontrol.cpp",
|
||||
"androidruncontrol.h",
|
||||
"androidrunnable.cpp",
|
||||
|
||||
@@ -51,6 +51,10 @@ const char ANDROID_SETTINGS_ID[] = "BB.Android Configurations";
|
||||
const char ANDROID_TOOLCHAIN_ID[] = "Qt4ProjectManager.ToolChain.Android";
|
||||
const char ANDROIDQT[] = "Qt4ProjectManager.QtVersion.Android";
|
||||
|
||||
const char ANDROID_AMSTARTARGS_ASPECT[] = "Android.AmStartArgs";
|
||||
const char ANDROID_PRESTARTSHELLCMDLIST_ASPECT[] = "Android.PreStartShellCmdList";
|
||||
const char ANDROID_POSTSTARTSHELLCMDLIST_ASPECT[] = "Android.PostStartShellCmdList";
|
||||
|
||||
const char ANDROID_DEVICE_TYPE[] = "Android.Device.Type";
|
||||
const char ANDROID_DEVICE_ID[] = "Android Device";
|
||||
const char ANDROID_MANIFEST_MIME_TYPE[] = "application/vnd.google.android.android_manifest";
|
||||
|
||||
@@ -24,10 +24,12 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "androidrunconfiguration.h"
|
||||
|
||||
#include "androidconstants.h"
|
||||
#include "androidglobal.h"
|
||||
#include "androidtoolchain.h"
|
||||
#include "androidmanager.h"
|
||||
#include "androidrunconfigurationwidget.h"
|
||||
#include "adbcommandswidget.h"
|
||||
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/project.h>
|
||||
@@ -36,88 +38,125 @@
|
||||
#include <qtsupport/qtoutputformatter.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
#include <utils/detailswidget.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QSpacerItem>
|
||||
#include <QWidget>
|
||||
|
||||
using namespace Android::Internal;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Android {
|
||||
using namespace Internal;
|
||||
|
||||
const char amStartArgsKey[] = "Android.AmStartArgsKey";
|
||||
const char preStartShellCmdsKey[] = "Android.PreStartShellCmdListKey";
|
||||
const char postFinishShellCmdsKey[] = "Android.PostFinishShellCmdListKey";
|
||||
BaseStringListAspect::BaseStringListAspect(RunConfiguration *runConfig,
|
||||
const QString &settingsKey,
|
||||
Core::Id id)
|
||||
: IRunConfigurationAspect(runConfig)
|
||||
{
|
||||
setSettingsKey(settingsKey);
|
||||
setId(id);
|
||||
}
|
||||
|
||||
BaseStringListAspect::~BaseStringListAspect() = default;
|
||||
|
||||
void BaseStringListAspect::addToConfigurationLayout(QFormLayout *layout)
|
||||
{
|
||||
QTC_CHECK(!m_widget);
|
||||
m_widget = new AdbCommandsWidget(layout->parentWidget());
|
||||
m_widget->setCommandList(m_value);
|
||||
m_widget->setTitleText(m_label);
|
||||
layout->addRow(m_widget);
|
||||
connect(m_widget.data(), &AdbCommandsWidget::commandsChanged, this, [this] {
|
||||
m_value = m_widget->commandsList();
|
||||
emit changed();
|
||||
});
|
||||
}
|
||||
|
||||
void BaseStringListAspect::fromMap(const QVariantMap &map)
|
||||
{
|
||||
m_value = map.value(settingsKey()).toStringList();
|
||||
}
|
||||
|
||||
void BaseStringListAspect::toMap(QVariantMap &data) const
|
||||
{
|
||||
data.insert(settingsKey(), m_value);
|
||||
}
|
||||
|
||||
QStringList BaseStringListAspect::value() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void BaseStringListAspect::setValue(const QStringList &value)
|
||||
{
|
||||
m_value = value;
|
||||
if (m_widget)
|
||||
m_widget->setCommandList(m_value);
|
||||
}
|
||||
|
||||
void BaseStringListAspect::setLabel(const QString &label)
|
||||
{
|
||||
m_label = label;
|
||||
}
|
||||
|
||||
|
||||
AndroidRunConfiguration::AndroidRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
auto amStartArgsAspect = new BaseStringAspect(this);
|
||||
amStartArgsAspect->setId(Constants::ANDROID_AMSTARTARGS_ASPECT);
|
||||
amStartArgsAspect->setSettingsKey("Android.AmStartArgsKey");
|
||||
amStartArgsAspect->setLabelText(tr("Activity manager start options:"));
|
||||
amStartArgsAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay);
|
||||
addExtraAspect(amStartArgsAspect);
|
||||
|
||||
auto preStartShellCmdAspect = new BaseStringListAspect(this);
|
||||
preStartShellCmdAspect->setId(Constants::ANDROID_PRESTARTSHELLCMDLIST_ASPECT);
|
||||
preStartShellCmdAspect->setSettingsKey("Android.PreStartShellCmdListKey");
|
||||
preStartShellCmdAspect->setLabel(tr("Shell commands to run on Android device before application launch."));
|
||||
addExtraAspect(preStartShellCmdAspect);
|
||||
|
||||
auto postStartShellCmdAspect = new BaseStringListAspect(this);
|
||||
postStartShellCmdAspect->setId(Constants::ANDROID_POSTSTARTSHELLCMDLIST_ASPECT);
|
||||
postStartShellCmdAspect->setSettingsKey("Android.PostStartShellCmdListKey");
|
||||
postStartShellCmdAspect->setLabel(tr("Shell commands to run on Android device after application quits."));
|
||||
addExtraAspect(postStartShellCmdAspect);
|
||||
|
||||
setOutputFormatter<QtSupport::QtOutputFormatter>();
|
||||
connect(target->project(), &Project::parsingFinished, this, [this] {
|
||||
updateTargetInformation();
|
||||
});
|
||||
}
|
||||
|
||||
void AndroidRunConfiguration::setPreStartShellCommands(const QStringList &cmdList)
|
||||
{
|
||||
m_preStartShellCommands = cmdList;
|
||||
}
|
||||
|
||||
void AndroidRunConfiguration::setPostFinishShellCommands(const QStringList &cmdList)
|
||||
{
|
||||
m_postFinishShellCommands = cmdList;
|
||||
}
|
||||
|
||||
void AndroidRunConfiguration::setAmStartExtraArgs(const QStringList &args)
|
||||
{
|
||||
m_amStartExtraArgs = args;
|
||||
}
|
||||
|
||||
QWidget *AndroidRunConfiguration::createConfigurationWidget()
|
||||
{
|
||||
auto configWidget = new AndroidRunConfigurationWidget();
|
||||
configWidget->setAmStartArgs(m_amStartExtraArgs);
|
||||
configWidget->setPreStartShellCommands(m_preStartShellCommands);
|
||||
configWidget->setPostFinishShellCommands(m_postFinishShellCommands);
|
||||
connect(configWidget, &AndroidRunConfigurationWidget::amStartArgsChanged,
|
||||
this, &AndroidRunConfiguration::setAmStartExtraArgs);
|
||||
connect(configWidget, &AndroidRunConfigurationWidget::preStartCmdsChanged,
|
||||
this, &AndroidRunConfiguration::setPreStartShellCommands);
|
||||
connect(configWidget, &AndroidRunConfigurationWidget::postFinishCmdsChanged,
|
||||
this, &AndroidRunConfiguration::setPostFinishShellCommands);
|
||||
return configWidget;
|
||||
}
|
||||
auto widget = new QWidget;
|
||||
auto layout = new QFormLayout(widget);
|
||||
|
||||
bool AndroidRunConfiguration::fromMap(const QVariantMap &map)
|
||||
{
|
||||
if (!RunConfiguration::fromMap(map))
|
||||
return false;
|
||||
m_preStartShellCommands = map.value(preStartShellCmdsKey).toStringList();
|
||||
m_postFinishShellCommands = map.value(postFinishShellCmdsKey).toStringList();
|
||||
m_amStartExtraArgs = map.value(amStartArgsKey).toStringList();
|
||||
return true;
|
||||
}
|
||||
extraAspect(Constants::ANDROID_AMSTARTARGS_ASPECT)->addToConfigurationLayout(layout);
|
||||
|
||||
QVariantMap AndroidRunConfiguration::toMap() const
|
||||
{
|
||||
QVariantMap res = RunConfiguration::toMap();
|
||||
res[preStartShellCmdsKey] = m_preStartShellCommands;
|
||||
res[postFinishShellCmdsKey] = m_postFinishShellCommands;
|
||||
res[amStartArgsKey] = m_amStartExtraArgs;
|
||||
return res;
|
||||
}
|
||||
auto warningIconLabel = new QLabel;
|
||||
warningIconLabel->setPixmap(Utils::Icons::WARNING.pixmap());
|
||||
|
||||
const QStringList &AndroidRunConfiguration::amStartExtraArgs() const
|
||||
{
|
||||
return m_amStartExtraArgs;
|
||||
}
|
||||
auto warningLabel = new QLabel(tr("If the \"am start\" options conflict, the application might not start."));
|
||||
layout->addRow(warningIconLabel, warningLabel);
|
||||
|
||||
const QStringList &AndroidRunConfiguration::preStartShellCommands() const
|
||||
{
|
||||
return m_preStartShellCommands;
|
||||
}
|
||||
extraAspect(Constants::ANDROID_PRESTARTSHELLCMDLIST_ASPECT)->addToConfigurationLayout(layout);
|
||||
extraAspect(Constants::ANDROID_POSTSTARTSHELLCMDLIST_ASPECT)->addToConfigurationLayout(layout);
|
||||
|
||||
const QStringList &AndroidRunConfiguration::postFinishShellCommands() const
|
||||
{
|
||||
return m_postFinishShellCommands;
|
||||
auto wrapped = wrapWidget(widget);
|
||||
auto detailsWidget = qobject_cast<DetailsWidget *>(wrapped);
|
||||
QTC_ASSERT(detailsWidget, return wrapped);
|
||||
detailsWidget->setState(DetailsWidget::Expanded);
|
||||
detailsWidget->setSummaryText(tr("Android run settings"));
|
||||
return detailsWidget;
|
||||
}
|
||||
|
||||
void AndroidRunConfiguration::updateTargetInformation()
|
||||
|
||||
@@ -27,36 +27,53 @@
|
||||
|
||||
#include "android_global.h"
|
||||
|
||||
#include "adbcommandswidget.h"
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
|
||||
namespace Android {
|
||||
|
||||
class BaseStringListAspect : public ProjectExplorer::IRunConfigurationAspect
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BaseStringListAspect(ProjectExplorer::RunConfiguration *rc,
|
||||
const QString &settingsKey = QString(),
|
||||
Core::Id id = Core::Id());
|
||||
~BaseStringListAspect() override;
|
||||
|
||||
void addToConfigurationLayout(QFormLayout *layout) override;
|
||||
|
||||
QStringList value() const;
|
||||
void setValue(const QStringList &val);
|
||||
|
||||
void setLabel(const QString &label);
|
||||
|
||||
void fromMap(const QVariantMap &map) override;
|
||||
void toMap(QVariantMap &map) const override;
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
private:
|
||||
QStringList m_value;
|
||||
QString m_label;
|
||||
QPointer<Android::Internal::AdbCommandsWidget> m_widget; // Owned by RunConfigWidget
|
||||
};
|
||||
|
||||
class ANDROID_EXPORT AndroidRunConfiguration : public ProjectExplorer::RunConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AndroidRunConfiguration(ProjectExplorer::Target *target, Core::Id id);
|
||||
|
||||
QString disabledReason() const override;
|
||||
QWidget *createConfigurationWidget() override;
|
||||
|
||||
bool fromMap(const QVariantMap &map) override;
|
||||
QVariantMap toMap() const override;
|
||||
QString disabledReason() const override;
|
||||
|
||||
const QStringList &amStartExtraArgs() const;
|
||||
const QStringList &preStartShellCommands() const;
|
||||
const QStringList &postFinishShellCommands() const;
|
||||
|
||||
private:
|
||||
// FIXME: This appears to miss a copyFrom() implementation.
|
||||
void setPreStartShellCommands(const QStringList &cmdList);
|
||||
void setPostFinishShellCommands(const QStringList &cmdList);
|
||||
void setAmStartExtraArgs(const QStringList &args);
|
||||
void updateTargetInformation();
|
||||
|
||||
QStringList m_amStartExtraArgs;
|
||||
QStringList m_preStartShellCommands;
|
||||
QStringList m_postFinishShellCommands;
|
||||
};
|
||||
|
||||
} // namespace Android
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "androidrunconfigurationwidget.h"
|
||||
#include "adbcommandswidget.h"
|
||||
#include "ui_androidrunconfigurationwidget.h"
|
||||
|
||||
#include "utils/utilsicons.h"
|
||||
#include "utils/qtcprocess.h"
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
AndroidRunConfigurationWidget::AndroidRunConfigurationWidget(QWidget *parent):
|
||||
Utils::DetailsWidget(parent),
|
||||
m_ui(new Ui::AndroidRunConfigurationWidget)
|
||||
{
|
||||
auto detailsWidget = new QWidget(this);
|
||||
m_ui->setupUi(detailsWidget);
|
||||
m_ui->m_warningIconLabel->setPixmap(Utils::Icons::WARNING.pixmap());
|
||||
|
||||
m_preStartCmdsWidget = new AdbCommandsWidget(detailsWidget);
|
||||
connect(m_preStartCmdsWidget, &AdbCommandsWidget::commandsChanged, [this]() {
|
||||
emit preStartCmdsChanged(m_preStartCmdsWidget->commandsList());
|
||||
});
|
||||
m_preStartCmdsWidget->setTitleText(tr("Shell commands to run on Android device before"
|
||||
" application launch."));
|
||||
|
||||
m_postEndCmdsWidget = new AdbCommandsWidget(detailsWidget);
|
||||
connect(m_postEndCmdsWidget, &AdbCommandsWidget::commandsChanged, [this]() {
|
||||
emit postFinishCmdsChanged(m_postEndCmdsWidget->commandsList());
|
||||
});
|
||||
m_postEndCmdsWidget->setTitleText(tr("Shell commands to run on Android device after application"
|
||||
" quits."));
|
||||
|
||||
auto mainLayout = static_cast<QGridLayout*>(detailsWidget->layout());
|
||||
mainLayout->addWidget(m_preStartCmdsWidget->widget(), mainLayout->rowCount(),
|
||||
0, mainLayout->columnCount() - 1, 0);
|
||||
mainLayout->addWidget(m_postEndCmdsWidget->widget(), mainLayout->rowCount(),
|
||||
0, mainLayout->columnCount() - 1, 0);
|
||||
|
||||
setWidget(detailsWidget);
|
||||
setSummaryText(tr("Android run settings"));
|
||||
|
||||
connect(m_ui->m_amStartArgsEdit, &QLineEdit::editingFinished, [this]() {
|
||||
QString optionText = m_ui->m_amStartArgsEdit->text().simplified();
|
||||
emit amStartArgsChanged(optionText.split(' '));
|
||||
});
|
||||
}
|
||||
|
||||
AndroidRunConfigurationWidget::~AndroidRunConfigurationWidget() = default;
|
||||
|
||||
void AndroidRunConfigurationWidget::setAmStartArgs(const QStringList &args)
|
||||
{
|
||||
m_ui->m_amStartArgsEdit->setText(Utils::QtcProcess::joinArgs(args, Utils::OsTypeLinux));
|
||||
}
|
||||
|
||||
void AndroidRunConfigurationWidget::setPreStartShellCommands(const QStringList &cmdList)
|
||||
{
|
||||
m_preStartCmdsWidget->setCommandList(cmdList);
|
||||
}
|
||||
|
||||
void AndroidRunConfigurationWidget::setPostFinishShellCommands(const QStringList &cmdList)
|
||||
{
|
||||
m_postEndCmdsWidget->setCommandList(cmdList);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "androidrunconfiguration.h"
|
||||
|
||||
#include "projectexplorer/runconfiguration.h"
|
||||
#include "utils/detailswidget.h"
|
||||
|
||||
#include <QStringListModel>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
class AdbCommandsWidget;
|
||||
namespace Ui {
|
||||
class AndroidRunConfigurationWidget;
|
||||
}
|
||||
|
||||
class AndroidRunConfigurationWidget : public Utils::DetailsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AndroidRunConfigurationWidget(QWidget *parent = nullptr);
|
||||
~AndroidRunConfigurationWidget();
|
||||
|
||||
void setAmStartArgs(const QStringList &args);
|
||||
void setPreStartShellCommands(const QStringList &cmdList);
|
||||
void setPostFinishShellCommands(const QStringList &cmdList);
|
||||
|
||||
signals:
|
||||
void amStartArgsChanged(QStringList args);
|
||||
void preStartCmdsChanged(const QStringList &cmdList);
|
||||
void postFinishCmdsChanged(const QStringList &cmdList);
|
||||
|
||||
private:
|
||||
void addPreStartCommand(const QString &command);
|
||||
void addPostFinishCommand(const QString &command);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::AndroidRunConfigurationWidget> m_ui;
|
||||
AdbCommandsWidget *m_preStartCmdsWidget = nullptr;
|
||||
AdbCommandsWidget *m_postEndCmdsWidget = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Android::Internal::AndroidRunConfigurationWidget</class>
|
||||
<widget class="QWidget" name="Android::Internal::AndroidRunConfigurationWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>731</width>
|
||||
<height>119</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="spacing">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Activity manager start options:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="m_warningIconLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>12</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>If the "am start" options conflict, the application might not start.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="m_amStartArgsEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "androidrunner.h"
|
||||
|
||||
#include "androidconstants.h"
|
||||
#include "androiddeployqtstep.h"
|
||||
#include "androidconfigurations.h"
|
||||
#include "androidrunconfiguration.h"
|
||||
@@ -36,6 +37,7 @@
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorersettings.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <utils/url.h>
|
||||
|
||||
@@ -135,13 +137,17 @@ AndroidRunner::AndroidRunner(RunControl *runControl,
|
||||
m_androidRunnable.deviceSerialNumber = AndroidManager::deviceSerialNumber(m_target);
|
||||
m_androidRunnable.apiLevel = AndroidManager::deviceApiLevel(m_target);
|
||||
|
||||
if (auto androidRunConfig = qobject_cast<AndroidRunConfiguration *>(
|
||||
runControl->runConfiguration())) {
|
||||
m_androidRunnable.amStartExtraArgs = androidRunConfig->amStartExtraArgs();
|
||||
for (QString shellCmd: androidRunConfig->preStartShellCommands())
|
||||
m_androidRunnable.beforeStartAdbCommands.append(QString("shell %1").arg(shellCmd));
|
||||
RunConfiguration *rc = runControl->runConfiguration();
|
||||
if (auto aspect = rc->extraAspect(Constants::ANDROID_AMSTARTARGS_ASPECT))
|
||||
m_androidRunnable.amStartExtraArgs = static_cast<BaseStringAspect *>(aspect)->value().split(' ');
|
||||
|
||||
for (QString shellCmd: androidRunConfig->postFinishShellCommands())
|
||||
if (auto aspect = rc->extraAspect(Constants::ANDROID_PRESTARTSHELLCMDLIST_ASPECT)) {
|
||||
for (QString shellCmd : static_cast<BaseStringListAspect *>(aspect)->value())
|
||||
m_androidRunnable.beforeStartAdbCommands.append(QString("shell %1").arg(shellCmd));
|
||||
}
|
||||
|
||||
if (auto aspect = rc->extraAspect(Constants::ANDROID_POSTSTARTSHELLCMDLIST_ASPECT)) {
|
||||
for (QString shellCmd : static_cast<BaseStringListAspect *>(aspect)->value())
|
||||
m_androidRunnable.afterFinishAdbCommands.append(QString("shell %1").arg(shellCmd));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user