2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
#include "androidrunconfiguration.h"
|
2018-05-04 16:01:13 +02:00
|
|
|
|
|
|
|
|
#include "androidconstants.h"
|
2012-04-18 20:30:57 +03:00
|
|
|
#include "androidglobal.h"
|
|
|
|
|
#include "androidtoolchain.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "androidmanager.h"
|
2018-05-04 16:01:13 +02:00
|
|
|
#include "adbcommandswidget.h"
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2018-05-04 11:13:43 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2018-05-04 11:13:43 +02:00
|
|
|
|
2012-07-04 12:50:19 +02:00
|
|
|
#include <qtsupport/qtoutputformatter.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2018-05-04 16:01:13 +02:00
|
|
|
#include <utils/detailswidget.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
#include <utils/qtcassert.h>
|
2018-05-04 16:01:13 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
|
#include <utils/utilsicons.h>
|
|
|
|
|
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QSpacerItem>
|
|
|
|
|
#include <QWidget>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2018-05-04 16:01:13 +02:00
|
|
|
using namespace Android::Internal;
|
2012-07-25 17:41:01 +02:00
|
|
|
using namespace ProjectExplorer;
|
2018-05-04 16:01:13 +02:00
|
|
|
using namespace Utils;
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
namespace Android {
|
2017-06-08 14:57:09 +02:00
|
|
|
|
2018-05-04 16:01:13 +02:00
|
|
|
BaseStringListAspect::BaseStringListAspect(RunConfiguration *runConfig,
|
|
|
|
|
const QString &settingsKey,
|
|
|
|
|
Core::Id id)
|
|
|
|
|
: IRunConfigurationAspect(runConfig)
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2018-05-04 16:01:13 +02:00
|
|
|
setSettingsKey(settingsKey);
|
|
|
|
|
setId(id);
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2018-05-04 16:01:13 +02:00
|
|
|
BaseStringListAspect::~BaseStringListAspect() = default;
|
2017-06-08 14:57:09 +02:00
|
|
|
|
2018-05-04 16:01:13 +02:00
|
|
|
void BaseStringListAspect::addToConfigurationLayout(QFormLayout *layout)
|
2017-06-08 14:57:09 +02:00
|
|
|
{
|
2018-05-04 16:01:13 +02:00
|
|
|
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();
|
|
|
|
|
});
|
2017-06-08 14:57:09 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-04 16:01:13 +02:00
|
|
|
void BaseStringListAspect::fromMap(const QVariantMap &map)
|
2017-05-15 14:48:39 +02:00
|
|
|
{
|
2018-05-04 16:01:13 +02:00
|
|
|
m_value = map.value(settingsKey()).toStringList();
|
2017-05-15 14:48:39 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-04 16:01:13 +02:00
|
|
|
void BaseStringListAspect::toMap(QVariantMap &data) const
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2018-05-04 16:01:13 +02:00
|
|
|
data.insert(settingsKey(), m_value);
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2018-05-04 16:01:13 +02:00
|
|
|
QStringList BaseStringListAspect::value() const
|
2017-05-15 14:48:39 +02:00
|
|
|
{
|
2018-05-04 16:01:13 +02:00
|
|
|
return m_value;
|
2017-05-15 14:48:39 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-04 16:01:13 +02:00
|
|
|
void BaseStringListAspect::setValue(const QStringList &value)
|
2017-05-15 14:48:39 +02:00
|
|
|
{
|
2018-05-04 16:01:13 +02:00
|
|
|
m_value = value;
|
|
|
|
|
if (m_widget)
|
|
|
|
|
m_widget->setCommandList(m_value);
|
2017-05-15 14:48:39 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-04 16:01:13 +02:00
|
|
|
void BaseStringListAspect::setLabel(const QString &label)
|
2017-05-15 14:48:39 +02:00
|
|
|
{
|
2018-05-04 16:01:13 +02:00
|
|
|
m_label = label;
|
2017-05-15 14:48:39 +02:00
|
|
|
}
|
2017-06-08 14:57:09 +02:00
|
|
|
|
2018-05-04 16:01:13 +02:00
|
|
|
|
|
|
|
|
AndroidRunConfiguration::AndroidRunConfiguration(Target *target, Core::Id id)
|
|
|
|
|
: RunConfiguration(target, id)
|
2017-06-08 14:57:09 +02:00
|
|
|
{
|
2018-05-04 16:01:13 +02:00
|
|
|
auto amStartArgsAspect = new BaseStringAspect(this);
|
2018-05-15 12:11:54 +02:00
|
|
|
amStartArgsAspect->setId(Constants::ANDROID_AMSTARTARGS);
|
2018-05-04 16:01:13 +02:00
|
|
|
amStartArgsAspect->setSettingsKey("Android.AmStartArgsKey");
|
|
|
|
|
amStartArgsAspect->setLabelText(tr("Activity manager start options:"));
|
|
|
|
|
amStartArgsAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay);
|
2018-05-31 14:41:59 +02:00
|
|
|
amStartArgsAspect->setHistoryCompleter("Android.AmStartArgs.History");
|
2018-05-04 16:01:13 +02:00
|
|
|
addExtraAspect(amStartArgsAspect);
|
|
|
|
|
|
|
|
|
|
auto preStartShellCmdAspect = new BaseStringListAspect(this);
|
2018-05-15 12:11:54 +02:00
|
|
|
preStartShellCmdAspect->setId(Constants::ANDROID_PRESTARTSHELLCMDLIST);
|
2018-05-04 16:01:13 +02:00
|
|
|
preStartShellCmdAspect->setSettingsKey("Android.PreStartShellCmdListKey");
|
|
|
|
|
preStartShellCmdAspect->setLabel(tr("Shell commands to run on Android device before application launch."));
|
|
|
|
|
addExtraAspect(preStartShellCmdAspect);
|
|
|
|
|
|
|
|
|
|
auto postStartShellCmdAspect = new BaseStringListAspect(this);
|
2018-05-15 12:11:54 +02:00
|
|
|
postStartShellCmdAspect->setId(Constants::ANDROID_POSTFINISHSHELLCMDLIST);
|
2018-05-04 16:01:13 +02:00
|
|
|
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();
|
|
|
|
|
});
|
2017-06-08 14:57:09 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-04 16:01:13 +02:00
|
|
|
QWidget *AndroidRunConfiguration::createConfigurationWidget()
|
2017-06-08 14:57:09 +02:00
|
|
|
{
|
2018-05-04 16:01:13 +02:00
|
|
|
auto widget = new QWidget;
|
|
|
|
|
auto layout = new QFormLayout(widget);
|
|
|
|
|
|
2018-05-15 12:11:54 +02:00
|
|
|
extraAspect(Constants::ANDROID_AMSTARTARGS)->addToConfigurationLayout(layout);
|
2018-05-04 16:01:13 +02:00
|
|
|
|
|
|
|
|
auto warningIconLabel = new QLabel;
|
|
|
|
|
warningIconLabel->setPixmap(Utils::Icons::WARNING.pixmap());
|
|
|
|
|
|
|
|
|
|
auto warningLabel = new QLabel(tr("If the \"am start\" options conflict, the application might not start."));
|
|
|
|
|
layout->addRow(warningIconLabel, warningLabel);
|
|
|
|
|
|
2018-05-15 12:11:54 +02:00
|
|
|
extraAspect(Constants::ANDROID_PRESTARTSHELLCMDLIST)->addToConfigurationLayout(layout);
|
|
|
|
|
extraAspect(Constants::ANDROID_POSTFINISHSHELLCMDLIST)->addToConfigurationLayout(layout);
|
2018-05-04 16:01:13 +02:00
|
|
|
|
|
|
|
|
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;
|
2017-06-08 14:57:09 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-04 11:13:43 +02:00
|
|
|
void AndroidRunConfiguration::updateTargetInformation()
|
|
|
|
|
{
|
|
|
|
|
const BuildTargetInfo bti = buildTargetInfo();
|
|
|
|
|
setDisplayName(bti.displayName);
|
|
|
|
|
setDefaultDisplayName(bti.displayName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AndroidRunConfiguration::disabledReason() const
|
|
|
|
|
{
|
|
|
|
|
const BuildTargetInfo bti = buildTargetInfo();
|
|
|
|
|
const QString projectFileName = bti.projectFilePath.toString();
|
|
|
|
|
|
|
|
|
|
if (project()->isParsing())
|
|
|
|
|
return tr("The project file \"%1\" is currently being parsed.").arg(projectFileName);
|
|
|
|
|
|
|
|
|
|
if (!project()->hasParsingData()) {
|
|
|
|
|
if (!bti.projectFilePath.exists())
|
|
|
|
|
return tr("The project file \"%1\" does not exist.").arg(projectFileName);
|
|
|
|
|
|
|
|
|
|
return tr("The project file \"%1\" could not be parsed.").arg(projectFileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
} // namespace Android
|