2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2014-03-24 16:31:28 +01: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/
|
2014-03-24 16:31:28 +01:00
|
|
|
**
|
|
|
|
|
** 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
|
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.
|
2014-03-24 16:31:28 +01: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.
|
2014-03-24 16:31:28 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "avddialog.h"
|
2022-07-21 18:54:08 +02:00
|
|
|
|
2020-01-08 14:55:16 +02:00
|
|
|
#include "androidavdmanager.h"
|
2021-09-26 16:57:59 +03:00
|
|
|
#include "androidconstants.h"
|
2022-07-21 18:54:08 +02:00
|
|
|
#include "androiddevice.h"
|
|
|
|
|
#include "androidsdkmanager.h"
|
2015-05-06 15:58:46 +02:00
|
|
|
|
2020-07-23 15:48:56 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2022-07-21 18:54:08 +02:00
|
|
|
|
2017-04-04 07:20:01 +02:00
|
|
|
#include <utils/algorithm.h>
|
2022-07-21 18:54:08 +02:00
|
|
|
#include <utils/infolabel.h>
|
|
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
2015-05-06 15:58:46 +02:00
|
|
|
#include <utils/tooltip/tooltip.h>
|
2016-08-03 17:55:54 +02:00
|
|
|
#include <utils/utilsicons.h>
|
2014-03-24 16:31:28 +01:00
|
|
|
|
2022-07-21 18:54:08 +02:00
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QDialogButtonBox>
|
2021-09-26 16:57:59 +03:00
|
|
|
#include <QFutureWatcher>
|
2015-05-06 15:58:46 +02:00
|
|
|
#include <QKeyEvent>
|
2022-07-21 18:54:08 +02:00
|
|
|
#include <QLineEdit>
|
2020-01-08 14:55:16 +02:00
|
|
|
#include <QLoggingCategory>
|
2022-07-21 18:54:08 +02:00
|
|
|
#include <QMessageBox>
|
2020-10-28 10:36:16 +02:00
|
|
|
#include <QPushButton>
|
2022-07-21 18:54:08 +02:00
|
|
|
#include <QSpinBox>
|
|
|
|
|
#include <QToolTip>
|
2014-03-24 16:31:28 +01:00
|
|
|
|
2022-07-21 18:54:08 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
namespace Android::Internal {
|
2014-03-24 16:31:28 +01:00
|
|
|
|
2020-01-15 14:39:23 +01:00
|
|
|
static Q_LOGGING_CATEGORY(avdDialogLog, "qtc.android.avdDialog", QtWarningMsg)
|
2022-07-21 18:54:08 +02:00
|
|
|
|
2020-01-08 14:55:16 +02:00
|
|
|
|
2021-09-26 16:57:59 +03:00
|
|
|
AvdDialog::AvdDialog(const AndroidConfig &config, QWidget *parent)
|
|
|
|
|
: QDialog(parent),
|
2021-11-22 12:28:41 +01:00
|
|
|
m_allowedNameChars(QLatin1String("[a-z|A-Z|0-9|._-]*")),
|
2021-10-25 15:58:02 +03:00
|
|
|
m_androidConfig(config),
|
2021-11-22 12:28:41 +01:00
|
|
|
m_sdkManager(m_androidConfig)
|
2014-03-24 16:31:28 +01:00
|
|
|
{
|
2022-07-21 18:54:08 +02:00
|
|
|
resize(800, 0);
|
|
|
|
|
setWindowTitle(tr("Create new AVD"));
|
|
|
|
|
|
|
|
|
|
m_abiComboBox = new QComboBox;
|
|
|
|
|
m_abiComboBox->addItems({
|
|
|
|
|
ProjectExplorer::Constants::ANDROID_ABI_X86,
|
|
|
|
|
ProjectExplorer::Constants::ANDROID_ABI_X86_64,
|
|
|
|
|
ProjectExplorer::Constants::ANDROID_ABI_ARMEABI_V7A,
|
|
|
|
|
ProjectExplorer::Constants::ANDROID_ABI_ARM64_V8A
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
m_sdcardSizeSpinBox = new QSpinBox;
|
|
|
|
|
m_sdcardSizeSpinBox->setSuffix(tr(" MiB"));
|
|
|
|
|
m_sdcardSizeSpinBox->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
|
|
|
|
|
m_sdcardSizeSpinBox->setRange(0, 1000000);
|
|
|
|
|
m_sdcardSizeSpinBox->setValue(512);
|
|
|
|
|
|
|
|
|
|
m_nameLineEdit = new QLineEdit;
|
|
|
|
|
m_nameLineEdit->setValidator(new QRegularExpressionValidator(m_allowedNameChars, this));
|
|
|
|
|
m_nameLineEdit->installEventFilter(this);
|
|
|
|
|
|
|
|
|
|
m_targetApiComboBox = new QComboBox;
|
|
|
|
|
|
|
|
|
|
m_deviceDefinitionComboBox = new QComboBox;
|
|
|
|
|
|
|
|
|
|
m_warningText = new InfoLabel;
|
|
|
|
|
m_warningText->setType(InfoLabel::Warning);
|
|
|
|
|
m_warningText->setElideMode(Qt::ElideNone);
|
|
|
|
|
|
|
|
|
|
m_deviceDefinitionTypeComboBox = new QComboBox;
|
|
|
|
|
|
|
|
|
|
m_overwriteCheckBox = new QCheckBox(tr("Overwrite existing AVD name"));
|
|
|
|
|
|
|
|
|
|
m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
|
|
|
|
|
2015-05-06 15:58:46 +02:00
|
|
|
m_hideTipTimer.setInterval(2000);
|
|
|
|
|
m_hideTipTimer.setSingleShot(true);
|
2014-03-24 16:31:28 +01:00
|
|
|
|
2022-07-21 18:54:08 +02:00
|
|
|
using namespace Layouting;
|
|
|
|
|
const Break nl;
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
Form {
|
|
|
|
|
tr("Name:"), m_nameLineEdit, nl,
|
|
|
|
|
tr("Device definition:"),
|
|
|
|
|
Row { m_deviceDefinitionTypeComboBox, m_deviceDefinitionComboBox }, nl,
|
|
|
|
|
tr("Architecture (ABI):"), m_abiComboBox, nl,
|
|
|
|
|
tr("Target API:"), m_targetApiComboBox, nl,
|
|
|
|
|
QString(), m_warningText, nl,
|
|
|
|
|
tr("SD card size:"), m_sdcardSizeSpinBox, nl,
|
|
|
|
|
QString(), m_overwriteCheckBox,
|
|
|
|
|
},
|
|
|
|
|
Stretch(),
|
|
|
|
|
m_buttonBox
|
|
|
|
|
}.attachTo(this);
|
|
|
|
|
|
2021-09-26 16:57:59 +03:00
|
|
|
connect(&m_hideTipTimer, &QTimer::timeout, this, &Utils::ToolTip::hide);
|
2022-07-21 18:54:08 +02:00
|
|
|
connect(m_deviceDefinitionTypeComboBox, &QComboBox::currentIndexChanged,
|
2021-09-26 16:57:59 +03:00
|
|
|
this, &AvdDialog::updateDeviceDefinitionComboBox);
|
2022-07-21 18:54:08 +02:00
|
|
|
connect(m_abiComboBox, &QComboBox::currentIndexChanged,
|
2021-09-26 16:57:59 +03:00
|
|
|
this, &AvdDialog::updateApiLevelComboBox);
|
2022-07-21 18:54:08 +02:00
|
|
|
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
|
|
|
|
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
2021-09-26 16:57:59 +03:00
|
|
|
|
2022-07-21 18:54:08 +02:00
|
|
|
m_deviceTypeToStringMap.insert(AvdDialog::Phone, "Phone");
|
|
|
|
|
m_deviceTypeToStringMap.insert(AvdDialog::Tablet, "Tablet");
|
|
|
|
|
m_deviceTypeToStringMap.insert(AvdDialog::Automotive, "Automotive");
|
|
|
|
|
m_deviceTypeToStringMap.insert(AvdDialog::TV, "TV");
|
|
|
|
|
m_deviceTypeToStringMap.insert(AvdDialog::Wear, "Wear");
|
2014-03-24 16:31:28 +01:00
|
|
|
|
2020-01-08 14:55:16 +02:00
|
|
|
parseDeviceDefinitionsList();
|
2022-07-21 18:54:08 +02:00
|
|
|
for (const QString &type : m_deviceTypeToStringMap)
|
|
|
|
|
m_deviceDefinitionTypeComboBox->addItem(type);
|
2014-03-24 16:31:28 +01:00
|
|
|
|
2020-01-08 14:55:16 +02:00
|
|
|
updateApiLevelComboBox();
|
2014-03-24 16:31:28 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-26 16:57:59 +03:00
|
|
|
int AvdDialog::exec()
|
|
|
|
|
{
|
|
|
|
|
const int execResult = QDialog::exec();
|
|
|
|
|
if (execResult == QDialog::Accepted) {
|
|
|
|
|
CreateAvdInfo result;
|
|
|
|
|
result.systemImage = systemImage();
|
|
|
|
|
result.name = name();
|
|
|
|
|
result.abi = abi();
|
|
|
|
|
result.deviceDefinition = deviceDefinition();
|
|
|
|
|
result.sdcardSize = sdcardSize();
|
2022-07-21 18:54:08 +02:00
|
|
|
result.overwrite = m_overwriteCheckBox->isChecked();
|
2021-09-26 16:57:59 +03:00
|
|
|
|
|
|
|
|
const AndroidAvdManager avdManager = AndroidAvdManager(m_androidConfig);
|
|
|
|
|
QFutureWatcher<CreateAvdInfo> createAvdFutureWatcher;
|
|
|
|
|
|
|
|
|
|
QEventLoop loop;
|
|
|
|
|
QObject::connect(&createAvdFutureWatcher, &QFutureWatcher<CreateAvdInfo>::finished,
|
|
|
|
|
&loop, &QEventLoop::quit);
|
|
|
|
|
QObject::connect(&createAvdFutureWatcher, &QFutureWatcher<CreateAvdInfo>::canceled,
|
|
|
|
|
&loop, &QEventLoop::quit);
|
2022-07-05 12:15:50 +02:00
|
|
|
createAvdFutureWatcher.setFuture(avdManager.createAvd(result));
|
2021-09-26 16:57:59 +03:00
|
|
|
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
|
|
|
|
|
|
|
|
|
const QFuture<CreateAvdInfo> future = createAvdFutureWatcher.future();
|
2022-07-06 18:49:15 +02:00
|
|
|
if (future.isResultReadyAt(0)) {
|
2021-09-26 16:57:59 +03:00
|
|
|
m_createdAvdInfo = future.result();
|
2022-07-06 18:49:15 +02:00
|
|
|
AndroidDeviceManager::instance()->updateAvdsList();
|
|
|
|
|
}
|
2021-09-26 16:57:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return execResult;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-24 16:31:28 +01:00
|
|
|
bool AvdDialog::isValid() const
|
|
|
|
|
{
|
2020-01-08 14:55:16 +02:00
|
|
|
return !name().isEmpty() && systemImage() && systemImage()->isValid() && !abi().isEmpty();
|
2014-03-24 16:31:28 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-26 16:57:59 +03:00
|
|
|
ProjectExplorer::IDevice::Ptr AvdDialog::device() const
|
2014-03-24 16:31:28 +01:00
|
|
|
{
|
2022-03-02 22:18:56 +02:00
|
|
|
if (!m_createdAvdInfo.systemImage) {
|
|
|
|
|
qCWarning(avdDialogLog) << "System image of the created AVD is nullptr";
|
|
|
|
|
return IDevice::Ptr();
|
|
|
|
|
}
|
2021-09-26 16:57:59 +03:00
|
|
|
AndroidDevice *dev = new AndroidDevice();
|
|
|
|
|
const Utils::Id deviceId = AndroidDevice::idFromAvdInfo(m_createdAvdInfo);
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
dev->setupId(IDevice::AutoDetected, deviceId);
|
|
|
|
|
dev->setMachineType(IDevice::Emulator);
|
|
|
|
|
dev->setDisplayName(m_createdAvdInfo.name);
|
|
|
|
|
dev->setDeviceState(IDevice::DeviceConnected);
|
|
|
|
|
dev->setExtraData(Constants::AndroidAvdName, m_createdAvdInfo.name);
|
|
|
|
|
dev->setExtraData(Constants::AndroidCpuAbi, {m_createdAvdInfo.abi});
|
|
|
|
|
dev->setExtraData(Constants::AndroidSdk, m_createdAvdInfo.systemImage->apiLevel());
|
|
|
|
|
return IDevice::Ptr(dev);
|
2017-08-18 08:22:34 +02:00
|
|
|
}
|
|
|
|
|
|
2020-01-08 14:55:16 +02:00
|
|
|
AvdDialog::DeviceType AvdDialog::tagToDeviceType(const QString &type_tag)
|
2017-08-18 08:22:34 +02:00
|
|
|
{
|
2020-01-08 14:55:16 +02:00
|
|
|
if (type_tag.contains("android-wear"))
|
|
|
|
|
return AvdDialog::Wear;
|
|
|
|
|
else if (type_tag.contains("android-tv"))
|
|
|
|
|
return AvdDialog::TV;
|
|
|
|
|
else if (type_tag.contains("android-automotive"))
|
|
|
|
|
return AvdDialog::Automotive;
|
|
|
|
|
else
|
|
|
|
|
return AvdDialog::PhoneOrTablet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AvdDialog::parseDeviceDefinitionsList()
|
|
|
|
|
{
|
|
|
|
|
QString output;
|
|
|
|
|
|
|
|
|
|
if (!AndroidAvdManager::avdManagerCommand(m_androidConfig, {"list", "device"}, &output)) {
|
|
|
|
|
qCDebug(avdDialogLog) << "Avd list command failed" << output
|
|
|
|
|
<< m_androidConfig.sdkToolsVersion();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList avdDeviceInfo;
|
|
|
|
|
|
2021-05-28 18:22:44 +03:00
|
|
|
const auto lines = output.split('\n');
|
|
|
|
|
for (const QString &line : lines) {
|
2020-01-08 14:55:16 +02:00
|
|
|
if (line.startsWith("---------") || line.isEmpty()) {
|
|
|
|
|
DeviceDefinitionStruct deviceDefinition;
|
|
|
|
|
for (const QString &line : avdDeviceInfo) {
|
|
|
|
|
if (line.contains("id:")) {
|
|
|
|
|
deviceDefinition.name_id = line.split("or").at(1);
|
|
|
|
|
deviceDefinition.name_id = deviceDefinition.name_id.remove(0, 1).remove('"');
|
|
|
|
|
} else if (line.contains("Tag :")) {
|
|
|
|
|
deviceDefinition.type_str = line.split(':').at(1);
|
|
|
|
|
deviceDefinition.type_str = deviceDefinition.type_str.remove(0, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeviceType deviceType = tagToDeviceType(deviceDefinition.type_str);
|
|
|
|
|
if (deviceType == PhoneOrTablet) {
|
|
|
|
|
if (deviceDefinition.name_id.contains("Tablet"))
|
|
|
|
|
deviceType = Tablet;
|
|
|
|
|
else
|
|
|
|
|
deviceType = Phone;
|
|
|
|
|
}
|
|
|
|
|
deviceDefinition.deviceType = deviceType;
|
|
|
|
|
m_deviceDefinitionsList.append(deviceDefinition);
|
|
|
|
|
avdDeviceInfo.clear();
|
|
|
|
|
} else {
|
|
|
|
|
avdDeviceInfo << line;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AvdDialog::updateDeviceDefinitionComboBox()
|
|
|
|
|
{
|
2022-07-21 18:54:08 +02:00
|
|
|
DeviceType curDeviceType = m_deviceTypeToStringMap.key(
|
|
|
|
|
m_deviceDefinitionTypeComboBox->currentText());
|
2020-01-08 14:55:16 +02:00
|
|
|
|
2022-07-21 18:54:08 +02:00
|
|
|
m_deviceDefinitionComboBox->clear();
|
2021-02-16 20:40:12 +01:00
|
|
|
for (const DeviceDefinitionStruct &item : qAsConst(m_deviceDefinitionsList)) {
|
2020-01-08 14:55:16 +02:00
|
|
|
if (item.deviceType == curDeviceType)
|
2022-07-21 18:54:08 +02:00
|
|
|
m_deviceDefinitionComboBox->addItem(item.name_id);
|
2020-01-08 14:55:16 +02:00
|
|
|
}
|
2022-07-21 18:54:08 +02:00
|
|
|
m_deviceDefinitionComboBox->addItem("Custom");
|
2020-01-08 14:55:16 +02:00
|
|
|
|
|
|
|
|
updateApiLevelComboBox();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const SystemImage* AvdDialog::systemImage() const
|
|
|
|
|
{
|
2022-07-21 18:54:08 +02:00
|
|
|
return m_targetApiComboBox->currentData().value<SystemImage*>();
|
2014-03-24 16:31:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AvdDialog::name() const
|
|
|
|
|
{
|
2022-07-21 18:54:08 +02:00
|
|
|
return m_nameLineEdit->text();
|
2014-03-24 16:31:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AvdDialog::abi() const
|
|
|
|
|
{
|
2022-07-21 18:54:08 +02:00
|
|
|
return m_abiComboBox->currentText();
|
2014-03-24 16:31:28 +01:00
|
|
|
}
|
|
|
|
|
|
2020-01-08 14:55:16 +02:00
|
|
|
QString AvdDialog::deviceDefinition() const
|
|
|
|
|
{
|
2022-07-21 18:54:08 +02:00
|
|
|
return m_deviceDefinitionComboBox->currentText();
|
2020-01-08 14:55:16 +02:00
|
|
|
}
|
|
|
|
|
|
2014-03-24 16:31:28 +01:00
|
|
|
int AvdDialog::sdcardSize() const
|
|
|
|
|
{
|
2022-07-21 18:54:08 +02:00
|
|
|
return m_sdcardSizeSpinBox->value();
|
2014-03-24 16:31:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AvdDialog::updateApiLevelComboBox()
|
|
|
|
|
{
|
2021-09-26 16:57:59 +03:00
|
|
|
SystemImageList installedSystemImages = m_sdkManager.installedSystemImages();
|
2022-07-21 18:54:08 +02:00
|
|
|
DeviceType curDeviceType = m_deviceTypeToStringMap.key(
|
|
|
|
|
m_deviceDefinitionTypeComboBox->currentText());
|
2017-04-04 07:20:01 +02:00
|
|
|
|
|
|
|
|
QString selectedAbi = abi();
|
2017-08-18 08:22:34 +02:00
|
|
|
auto hasAbi = [selectedAbi](const SystemImage *image) {
|
|
|
|
|
return image && image->isValid() && (image->abiName() == selectedAbi);
|
2017-04-04 07:20:01 +02:00
|
|
|
};
|
|
|
|
|
|
2020-01-08 14:55:16 +02:00
|
|
|
SystemImageList filteredList;
|
|
|
|
|
filteredList = Utils::filtered(installedSystemImages, [hasAbi, &curDeviceType](const SystemImage *image) {
|
|
|
|
|
DeviceType deviceType = tagToDeviceType(image->sdkStylePath().split(';').at(2));
|
|
|
|
|
if (deviceType == PhoneOrTablet && (curDeviceType == Phone || curDeviceType == Tablet))
|
|
|
|
|
curDeviceType = PhoneOrTablet;
|
|
|
|
|
return image && deviceType == curDeviceType && hasAbi(image);
|
2017-04-04 07:20:01 +02:00
|
|
|
});
|
2014-03-24 16:31:28 +01:00
|
|
|
|
2022-07-21 18:54:08 +02:00
|
|
|
m_targetApiComboBox->clear();
|
2021-02-16 20:40:12 +01:00
|
|
|
for (SystemImage *image : qAsConst(filteredList)) {
|
2020-01-08 14:55:16 +02:00
|
|
|
QString imageString = "android-" % QString::number(image->apiLevel());
|
2020-10-28 11:41:37 +02:00
|
|
|
const QStringList imageSplits = image->sdkStylePath().split(';');
|
|
|
|
|
if (imageSplits.size() == 4)
|
|
|
|
|
imageString += QStringLiteral(" (%1)").arg(imageSplits.at(2));
|
2022-07-21 18:54:08 +02:00
|
|
|
m_targetApiComboBox->addItem(imageString,
|
2020-01-08 14:55:16 +02:00
|
|
|
QVariant::fromValue<SystemImage *>(image));
|
2022-07-21 18:54:08 +02:00
|
|
|
m_targetApiComboBox->setItemData(m_targetApiComboBox->count() - 1,
|
2020-01-08 14:55:16 +02:00
|
|
|
image->descriptionText(),
|
|
|
|
|
Qt::ToolTipRole);
|
2017-04-03 11:11:17 +02:00
|
|
|
}
|
2014-03-24 16:31:28 +01:00
|
|
|
|
2020-01-08 14:55:16 +02:00
|
|
|
if (installedSystemImages.isEmpty()) {
|
2022-07-21 18:54:08 +02:00
|
|
|
m_targetApiComboBox->setEnabled(false);
|
|
|
|
|
m_warningText->setVisible(true);
|
|
|
|
|
m_warningText->setText(
|
2020-11-03 16:29:09 +02:00
|
|
|
tr("Cannot create a new AVD. No suitable Android system image is installed.<br/>"
|
2021-09-26 16:57:59 +03:00
|
|
|
"Install a system image for the intended Android version from the SDK Manager."));
|
2022-07-21 18:54:08 +02:00
|
|
|
m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
2014-03-24 16:31:28 +01:00
|
|
|
} else if (filteredList.isEmpty()) {
|
2022-07-21 18:54:08 +02:00
|
|
|
m_targetApiComboBox->setEnabled(false);
|
|
|
|
|
m_warningText->setVisible(true);
|
|
|
|
|
m_warningText->setText(tr("Cannot create an AVD for ABI %1.<br/>Install a system "
|
2020-10-08 14:27:49 +03:00
|
|
|
"image for it from the SDK Manager tab first.")
|
|
|
|
|
.arg(abi()));
|
2022-07-21 18:54:08 +02:00
|
|
|
m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
2014-03-24 16:31:28 +01:00
|
|
|
} else {
|
2022-07-21 18:54:08 +02:00
|
|
|
m_warningText->setVisible(false);
|
|
|
|
|
m_targetApiComboBox->setEnabled(true);
|
|
|
|
|
m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
2014-03-24 16:31:28 +01:00
|
|
|
}
|
|
|
|
|
}
|
2015-05-06 15:58:46 +02:00
|
|
|
|
|
|
|
|
bool AvdDialog::eventFilter(QObject *obj, QEvent *event)
|
|
|
|
|
{
|
2022-07-21 18:54:08 +02:00
|
|
|
if (obj == m_nameLineEdit && event->type() == QEvent::KeyPress) {
|
2018-07-25 12:19:15 +02:00
|
|
|
auto ke = static_cast<QKeyEvent *>(event);
|
2015-05-06 15:58:46 +02:00
|
|
|
const QString key = ke->text();
|
2020-03-18 13:32:28 +01:00
|
|
|
if (!key.isEmpty() && !m_allowedNameChars.match(key).hasMatch()) {
|
2022-07-21 18:54:08 +02:00
|
|
|
QPoint position = m_nameLineEdit->parentWidget()->mapToGlobal(m_nameLineEdit->geometry().bottomLeft());
|
2015-05-06 15:58:46 +02:00
|
|
|
position -= Utils::ToolTip::offsetFromPosition();
|
2022-07-21 18:54:08 +02:00
|
|
|
Utils::ToolTip::show(position, tr("Allowed characters are: a-z A-Z 0-9 and . _ -"), m_nameLineEdit);
|
2015-05-06 15:58:46 +02:00
|
|
|
m_hideTipTimer.start();
|
|
|
|
|
} else {
|
|
|
|
|
m_hideTipTimer.stop();
|
|
|
|
|
Utils::ToolTip::hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QDialog::eventFilter(obj, event);
|
|
|
|
|
}
|
2022-07-21 18:54:08 +02:00
|
|
|
|
|
|
|
|
} // Android::Internal
|