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-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-09-12 10:43:10 +02:00
|
|
|
BaseStringListAspect::BaseStringListAspect(const QString &settingsKey, Core::Id id)
|
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
|
|
|
|
2019-10-15 17:20:51 +02:00
|
|
|
void BaseStringListAspect::addToLayout(LayoutBuilder &builder)
|
2017-06-08 14:57:09 +02:00
|
|
|
{
|
2018-05-04 16:01:13 +02:00
|
|
|
QTC_CHECK(!m_widget);
|
2019-10-15 17:20:51 +02:00
|
|
|
m_widget = new AdbCommandsWidget;
|
2018-05-04 16:01:13 +02:00
|
|
|
m_widget->setCommandList(m_value);
|
|
|
|
|
m_widget->setTitleText(m_label);
|
2019-10-15 17:20:51 +02:00
|
|
|
builder.addItem(m_widget.data());
|
2018-05-04 16:01:13 +02:00
|
|
|
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
|
|
|
{
|
2019-03-07 09:08:40 +01:00
|
|
|
auto envAspect = addAspect<EnvironmentAspect>();
|
2019-03-07 10:10:22 +01:00
|
|
|
envAspect->addSupportedBaseEnvironment(tr("Clean Environment"), {});
|
2019-03-07 09:08:40 +01:00
|
|
|
|
2018-09-04 10:36:44 +02:00
|
|
|
addAspect<ArgumentsAspect>();
|
2018-07-31 12:21:47 +02:00
|
|
|
|
2018-09-04 10:36:44 +02:00
|
|
|
auto amStartArgsAspect = addAspect<BaseStringAspect>();
|
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
|
|
|
|
2018-09-06 17:14:49 +02:00
|
|
|
auto warning = addAspect<BaseStringAspect>();
|
|
|
|
|
warning->setLabelPixmap(Icons::WARNING.pixmap());
|
|
|
|
|
warning->setValue(tr("If the \"am start\" options conflict, the application might not start."));
|
|
|
|
|
|
2018-09-04 10:36:44 +02:00
|
|
|
auto preStartShellCmdAspect = addAspect<BaseStringListAspect>();
|
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."));
|
|
|
|
|
|
2018-09-04 10:36:44 +02:00
|
|
|
auto postStartShellCmdAspect = addAspect<BaseStringListAspect>();
|
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."));
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
connect(target, &Target::parsingFinished, this, [this] {
|
2018-05-04 16:01:13 +02:00
|
|
|
updateTargetInformation();
|
2019-08-01 10:12:34 +02:00
|
|
|
AndroidManager::updateGradleProperties(this->target(), buildKey());
|
2018-05-04 16:01:13 +02:00
|
|
|
});
|
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-09-06 17:14:49 +02:00
|
|
|
auto wrapped = RunConfiguration::createConfigurationWidget();
|
2018-05-04 16:01:13 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
} // namespace Android
|