forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.12'
Change-Id: I3e7049da2c3da6f784e3cb3407c22ada556e5d24
This commit is contained in:
@@ -472,8 +472,6 @@ AndroidDeviceDialog::AndroidDeviceDialog(int apiLevel, const QStringList &abis,
|
||||
|
||||
connect(m_ui->lookingForDeviceCancel, &QPushButton::clicked,
|
||||
this, &AndroidDeviceDialog::defaultDeviceClear);
|
||||
|
||||
m_connectedDevices = AndroidConfig::connectedDevices(AndroidConfigurations::currentConfig().adbToolPath());
|
||||
}
|
||||
|
||||
AndroidDeviceDialog::~AndroidDeviceDialog()
|
||||
|
||||
@@ -539,6 +539,8 @@ QString AndroidManager::androidNameForApiLevel(int x)
|
||||
return QLatin1String("Android 9");
|
||||
case 29:
|
||||
return QLatin1String("Android 10");
|
||||
case 30:
|
||||
return QLatin1String("Android 11");
|
||||
default:
|
||||
return tr("Unknown Android version. API Level: %1").arg(QString::number(x));
|
||||
}
|
||||
|
||||
@@ -49,32 +49,39 @@
|
||||
#include <texteditor/texteditor.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QFileInfo>
|
||||
#include <QDomDocument>
|
||||
#include <QDir>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QFormLayout>
|
||||
#include <QComboBox>
|
||||
#include <QSpinBox>
|
||||
#include <QDebug>
|
||||
#include <QToolButton>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/stylehelper.h>
|
||||
#include <QListView>
|
||||
#include <QPushButton>
|
||||
#include <QFileDialog>
|
||||
#include <QTimer>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QDomDocument>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QImage>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QListView>
|
||||
#include <QLoggingCategory>
|
||||
#include <QPushButton>
|
||||
#include <QScrollArea>
|
||||
#include <QSpinBox>
|
||||
#include <QTimer>
|
||||
#include <QToolButton>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
|
||||
namespace {
|
||||
static Q_LOGGING_CATEGORY(androidManifestEditorLog, "qtc.android.manifestEditor", QtWarningMsg)
|
||||
}
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Android;
|
||||
using namespace Android::Internal;
|
||||
@@ -237,22 +244,44 @@ void AndroidManifestEditorWidget::initializePage()
|
||||
|
||||
createDPIButton(iconLayout,
|
||||
applicationGroupBox,
|
||||
m_lIconButton, m_lIconClearButton,
|
||||
tr("Low DPI icon"), tr("Select low DPI icon."));
|
||||
m_masterIconButton, iconSize(LowDPI),
|
||||
tr("Master icon"), tr("Select master icon."));
|
||||
|
||||
m_masterIconButton->setIcon(QIcon::fromTheme(QLatin1String("document-open"), Utils::Icons::OPENFILE.icon()));
|
||||
|
||||
iconLayout->addStretch(1);
|
||||
|
||||
QFrame* line = new QFrame();
|
||||
line->setFrameShape(QFrame::VLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
iconLayout->addWidget(line);
|
||||
|
||||
iconLayout->addStretch(1);
|
||||
|
||||
createDPIButton(iconLayout,
|
||||
applicationGroupBox,
|
||||
m_mIconButton, m_mIconClearButton,
|
||||
tr("Medium DPI icon"), tr("Select medium DPI icon."));
|
||||
m_lIconButton, iconSize(LowDPI),
|
||||
tr("Low DPI icon"), tr("Select low DPI icon."),
|
||||
&m_lIconClearButton,
|
||||
&m_lIconScaleWarningLabel);
|
||||
|
||||
iconLayout->addStretch(1);
|
||||
|
||||
createDPIButton(iconLayout,
|
||||
applicationGroupBox,
|
||||
m_hIconButton, m_hIconClearButton,
|
||||
tr("High DPI icon"), tr("Select high DPI icon."));
|
||||
m_mIconButton, iconSize(MediumDPI),
|
||||
tr("Medium DPI icon"), tr("Select medium DPI icon."),
|
||||
&m_mIconClearButton,
|
||||
&m_mIconScaleWarningLabel);
|
||||
|
||||
iconLayout->addStretch(1);
|
||||
|
||||
createDPIButton(iconLayout,
|
||||
applicationGroupBox,
|
||||
m_hIconButton, iconSize(HighDPI),
|
||||
tr("High DPI icon"), tr("Select high DPI icon."),
|
||||
&m_hIconClearButton,
|
||||
&m_hIconScaleWarningLabel);
|
||||
|
||||
iconLayout->addStretch(6);
|
||||
|
||||
@@ -269,6 +298,8 @@ void AndroidManifestEditorWidget::initializePage()
|
||||
connect(m_targetLineEdit, &QComboBox::currentTextChanged,
|
||||
this, setDirtyFunc);
|
||||
|
||||
connect(m_masterIconButton, &QAbstractButton::clicked,
|
||||
this, &AndroidManifestEditorWidget::setMasterIcon);
|
||||
connect(m_lIconButton, &QAbstractButton::clicked,
|
||||
this, &AndroidManifestEditorWidget::setLDPIIcon);
|
||||
connect(m_mIconButton, &QAbstractButton::clicked,
|
||||
@@ -549,10 +580,7 @@ void AndroidManifestEditorWidget::setDirty(bool dirty)
|
||||
|
||||
bool AndroidManifestEditorWidget::isModified() const
|
||||
{
|
||||
return m_dirty
|
||||
|| !m_hIconPath.isEmpty()
|
||||
|| !m_mIconPath.isEmpty()
|
||||
|| !m_lIconPath.isEmpty();
|
||||
return m_dirty;
|
||||
}
|
||||
|
||||
AndroidManifestEditorWidget::EditorPage AndroidManifestEditorWidget::activePage() const
|
||||
@@ -592,18 +620,10 @@ void AndroidManifestEditorWidget::preSave()
|
||||
syncToEditor();
|
||||
|
||||
QString baseDir = m_textEditorWidget->textDocument()->filePath().toFileInfo().absolutePath();
|
||||
if (!m_lIconPath.isEmpty()) {
|
||||
copyIcon(LowDPI, baseDir, m_lIconPath);
|
||||
m_lIconPath.clear();
|
||||
}
|
||||
if (!m_mIconPath.isEmpty()) {
|
||||
copyIcon(MediumDPI, baseDir, m_mIconPath);
|
||||
m_mIconPath.clear();
|
||||
}
|
||||
if (!m_hIconPath.isEmpty()) {
|
||||
copyIcon(HighDPI, baseDir, m_hIconPath);
|
||||
m_hIconPath.clear();
|
||||
}
|
||||
copyIcon(LowDPI, baseDir, m_lIconPath);
|
||||
copyIcon(MediumDPI, baseDir, m_mIconPath);
|
||||
copyIcon(HighDPI, baseDir, m_hIconPath);
|
||||
|
||||
// no need to emit changed() since this is called as part of saving
|
||||
|
||||
updateInfoBar();
|
||||
@@ -795,9 +815,9 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
|
||||
m_lIconButton->setIcon(icon(baseDir, LowDPI));
|
||||
m_mIconButton->setIcon(icon(baseDir, MediumDPI));
|
||||
m_hIconButton->setIcon(icon(baseDir, HighDPI));
|
||||
m_lIconPath.clear();
|
||||
m_mIconPath.clear();
|
||||
m_hIconPath.clear();
|
||||
m_lIconPath = baseDir + iconPath(LowDPI);
|
||||
m_mIconPath = baseDir + iconPath(MediumDPI);
|
||||
m_hIconPath = baseDir + iconPath(HighDPI);
|
||||
|
||||
disconnect(m_defaultPermissonsCheckBox, &QCheckBox::stateChanged,
|
||||
this, &AndroidManifestEditorWidget::defaultPermissionOrFeatureCheckBoxClicked);
|
||||
@@ -999,15 +1019,17 @@ void AndroidManifestEditorWidget::parseApplication(QXmlStreamReader &reader, QXm
|
||||
QXmlStreamAttributes attributes = reader.attributes();
|
||||
QStringList keys = {QLatin1String("android:label")};
|
||||
QStringList values = {m_appNameLineEdit->text()};
|
||||
QStringList remove;
|
||||
bool ensureIconAttribute = !m_lIconPath.isEmpty()
|
||||
|| !m_mIconPath.isEmpty()
|
||||
|| !m_hIconPath.isEmpty();
|
||||
if (ensureIconAttribute) {
|
||||
keys << QLatin1String("android:icon");
|
||||
values << QLatin1String("@drawable/icon");
|
||||
}
|
||||
} else
|
||||
remove << QLatin1String("android:icon");
|
||||
|
||||
QXmlStreamAttributes result = modifyXmlStreamAttributes(attributes, keys, values);
|
||||
QXmlStreamAttributes result = modifyXmlStreamAttributes(attributes, keys, values, remove);
|
||||
writer.writeAttributes(result);
|
||||
|
||||
reader.readNext();
|
||||
@@ -1230,6 +1252,34 @@ QString AndroidManifestEditorWidget::iconPath(IconDPI dpi)
|
||||
return {};
|
||||
}
|
||||
|
||||
QSize AndroidManifestEditorWidget::iconSize(IconDPI dpi)
|
||||
{
|
||||
switch (dpi) {
|
||||
case HighDPI:
|
||||
return QSize(72, 72);
|
||||
case MediumDPI:
|
||||
return QSize(48, 48);
|
||||
case LowDPI:
|
||||
return QSize(32, 32);
|
||||
}
|
||||
return QSize(72, 72);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::updateIconPath(const QString &newPath, IconDPI dpi)
|
||||
{
|
||||
switch (dpi) {
|
||||
case HighDPI:
|
||||
m_hIconPath = newPath;
|
||||
break;
|
||||
case MediumDPI:
|
||||
m_mIconPath = newPath;
|
||||
break;
|
||||
case LowDPI:
|
||||
m_lIconPath = newPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QIcon AndroidManifestEditorWidget::icon(const QString &baseDir, IconDPI dpi)
|
||||
{
|
||||
|
||||
@@ -1250,90 +1300,177 @@ QIcon AndroidManifestEditorWidget::icon(const QString &baseDir, IconDPI dpi)
|
||||
|
||||
void AndroidManifestEditorWidget::copyIcon(IconDPI dpi, const QString &baseDir, const QString &filePath)
|
||||
{
|
||||
if (!QFileInfo::exists(filePath))
|
||||
return;
|
||||
|
||||
const QString targetPath = baseDir + iconPath(dpi);
|
||||
QFile::remove(targetPath);
|
||||
QDir dir;
|
||||
dir.mkpath(QFileInfo(targetPath).absolutePath());
|
||||
QFile::copy(filePath, targetPath);
|
||||
if (targetPath.isEmpty()) {
|
||||
qCDebug(androidManifestEditorLog) << "Icon target path empty, cannot copy icon.";
|
||||
return;
|
||||
}
|
||||
QFileInfo targetFile(targetPath);
|
||||
if (filePath == targetPath)
|
||||
return;
|
||||
removeIcon(dpi, baseDir);
|
||||
QImage original(filePath);
|
||||
if (!targetPath.isEmpty() && !original.isNull()) {
|
||||
QDir dir;
|
||||
dir.mkpath(QFileInfo(targetPath).absolutePath());
|
||||
QSize targetSize = iconSize(dpi);
|
||||
QImage scaled = original.scaled(targetSize.width(), targetSize.height(),
|
||||
Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
toggleIconScaleWarning(dpi, scaled.width() > original.width() || scaled.height() > original.height());
|
||||
scaled.save(targetPath);
|
||||
updateIconPath(targetPath, dpi);
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::removeIcon(IconDPI dpi, const QString &baseDir)
|
||||
{
|
||||
const QString targetPath = baseDir + iconPath(dpi);
|
||||
if (targetPath.isEmpty()) {
|
||||
qCDebug(androidManifestEditorLog) << "Icon target path empty, cannot remove icon.";
|
||||
return;
|
||||
}
|
||||
QFileInfo targetFile(targetPath);
|
||||
if (targetFile.exists()) {
|
||||
QDir rmRf(targetFile.absoluteDir());
|
||||
rmRf.removeRecursively();
|
||||
}
|
||||
toggleIconScaleWarning(dpi, false);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::toggleIconScaleWarning(IconDPI dpi, bool visible)
|
||||
{
|
||||
switch (dpi) {
|
||||
case HighDPI:
|
||||
m_hIconScaleWarningLabel->setVisible(visible);
|
||||
break;
|
||||
case MediumDPI:
|
||||
m_mIconScaleWarningLabel->setVisible(visible);
|
||||
break;
|
||||
case LowDPI:
|
||||
m_lIconScaleWarningLabel->setVisible(visible);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const auto fileDialogIconFiles = QWidget::tr("Images (*.png *.jpg *.webp *.svg)");
|
||||
|
||||
void AndroidManifestEditorWidget::setMasterIcon()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Choose Master Icon"), QDir::homePath(), fileDialogIconFiles);
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
QString baseDir = m_textEditorWidget->textDocument()->filePath().toFileInfo().absolutePath();
|
||||
copyIcon(LowDPI, baseDir, file);
|
||||
copyIcon(MediumDPI, baseDir, file);
|
||||
copyIcon(HighDPI, baseDir, file);
|
||||
m_lIconButton->setIcon(icon(baseDir, LowDPI));
|
||||
m_mIconButton->setIcon(icon(baseDir, MediumDPI));
|
||||
m_hIconButton->setIcon(icon(baseDir, HighDPI));
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::setLDPIIcon()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Choose Low DPI Icon"), QDir::homePath(), tr("PNG images (*.png)"));
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Choose Low DPI Icon"), QDir::homePath(), fileDialogIconFiles);
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
m_lIconPath = file;
|
||||
m_lIconButton->setIcon(QIcon(file));
|
||||
setDirty(true);
|
||||
QString baseDir = m_textEditorWidget->textDocument()->filePath().toFileInfo().absolutePath();
|
||||
copyIcon(LowDPI, baseDir, m_lIconPath);
|
||||
m_lIconButton->setIcon(icon(baseDir, LowDPI));
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::setMDPIIcon()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Choose Medium DPI Icon"), QDir::homePath(), tr("PNG images (*.png)"));
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Choose Medium DPI Icon"), QDir::homePath(), fileDialogIconFiles);
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
m_mIconPath = file;
|
||||
m_mIconButton->setIcon(QIcon(file));
|
||||
setDirty(true);
|
||||
QString baseDir = m_textEditorWidget->textDocument()->filePath().toFileInfo().absolutePath();
|
||||
copyIcon(MediumDPI, baseDir, m_mIconPath);
|
||||
m_mIconButton->setIcon(icon(baseDir, MediumDPI));
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::setHDPIIcon()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Choose High DPI Icon"), QDir::homePath(), tr("PNG images (*.png)"));
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Choose High DPI Icon"), QDir::homePath(), fileDialogIconFiles);
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
m_hIconPath = file;
|
||||
m_hIconButton->setIcon(QIcon(file));
|
||||
setDirty(true);
|
||||
QString baseDir = m_textEditorWidget->textDocument()->filePath().toFileInfo().absolutePath();
|
||||
copyIcon(HighDPI, baseDir, m_hIconPath);
|
||||
m_hIconButton->setIcon(icon(baseDir, HighDPI));
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::clearLDPIIcon()
|
||||
{
|
||||
m_lIconPath.clear();
|
||||
m_lIconButton->setIcon(QIcon());
|
||||
QString baseDir = m_textEditorWidget->textDocument()->filePath().toFileInfo().absolutePath();
|
||||
removeIcon(LowDPI, baseDir);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::clearMDPIIcon()
|
||||
{
|
||||
m_mIconPath.clear();
|
||||
m_mIconButton->setIcon(QIcon());
|
||||
QString baseDir = m_textEditorWidget->textDocument()->filePath().toFileInfo().absolutePath();
|
||||
removeIcon(MediumDPI, baseDir);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::clearHDPIIcon()
|
||||
{
|
||||
m_hIconPath.clear();
|
||||
m_hIconButton->setIcon(QIcon());
|
||||
QString baseDir = m_textEditorWidget->textDocument()->filePath().toFileInfo().absolutePath();
|
||||
removeIcon(HighDPI, baseDir);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::createDPIButton(QHBoxLayout *layout,
|
||||
QWidget *parent,
|
||||
QToolButton *&button,
|
||||
QToolButton *&clearButton,
|
||||
const QSize &buttonSize,
|
||||
const QString &title,
|
||||
const QString &tooltip)
|
||||
const QString &tooltip,
|
||||
QToolButton **clearButton,
|
||||
QLabel **scaleWarningLabel)
|
||||
{
|
||||
auto iconLayout = new QVBoxLayout();
|
||||
auto iconTitle = new QLabel(title, parent);
|
||||
auto iconButtonLayout = new QGridLayout();
|
||||
button = new QToolButton(parent);
|
||||
button->setMinimumSize(QSize(48, 48));
|
||||
button->setMaximumSize(QSize(48, 48));
|
||||
button->setMinimumSize(buttonSize);
|
||||
button->setMaximumSize(buttonSize);
|
||||
button->setToolTip(tooltip);
|
||||
clearButton = new QToolButton(parent);
|
||||
clearButton->setMinimumSize(QSize(16, 16));
|
||||
clearButton->setMaximumSize(QSize(16, 16));
|
||||
clearButton->setIcon(Utils::Icons::CLOSE_FOREGROUND.icon());
|
||||
button->setIconSize(buttonSize);
|
||||
QSize clearAndWarningSize(16, 16);
|
||||
if (clearButton) {
|
||||
*clearButton = new QToolButton(parent);
|
||||
(*clearButton)->setMinimumSize(clearAndWarningSize);
|
||||
(*clearButton)->setMaximumSize(clearAndWarningSize);
|
||||
(*clearButton)->setIcon(Utils::Icons::CLOSE_FOREGROUND.icon());
|
||||
}
|
||||
if (scaleWarningLabel) {
|
||||
*scaleWarningLabel = new QLabel(parent);
|
||||
(*scaleWarningLabel)->setMinimumSize(clearAndWarningSize);
|
||||
(*scaleWarningLabel)->setMaximumSize(clearAndWarningSize);
|
||||
(*scaleWarningLabel)->setPixmap(Utils::Icons::WARNING.icon().pixmap(clearAndWarningSize));
|
||||
(*scaleWarningLabel)->setToolTip(tr("Icon scaled up"));
|
||||
(*scaleWarningLabel)->setVisible(false);
|
||||
}
|
||||
auto label = new QLabel(tr("Click to select"), parent);
|
||||
iconLayout->addWidget(iconTitle);
|
||||
iconLayout->setAlignment(iconTitle, Qt::AlignHCenter);
|
||||
iconButtonLayout->setColumnMinimumWidth(0, 16);
|
||||
iconButtonLayout->addWidget(button, 0, 1, 1, 3);
|
||||
iconButtonLayout->setAlignment(button, Qt::AlignVCenter);
|
||||
iconButtonLayout->addWidget(clearButton, 0, 4, 1, 1);
|
||||
iconButtonLayout->setAlignment(clearButton, Qt::AlignTop);
|
||||
if (clearButton) {
|
||||
iconButtonLayout->addWidget(*clearButton, 0, 4, 1, 1);
|
||||
iconButtonLayout->setAlignment(*clearButton, Qt::AlignTop);
|
||||
}
|
||||
if (scaleWarningLabel) {
|
||||
iconButtonLayout->addWidget(*scaleWarningLabel, 0, 0, 1, 1);
|
||||
iconButtonLayout->setAlignment(*scaleWarningLabel, Qt::AlignTop);
|
||||
}
|
||||
iconLayout->addLayout(iconButtonLayout);
|
||||
iconLayout->setAlignment(iconButtonLayout, Qt::AlignHCenter);
|
||||
iconLayout->addWidget(label);
|
||||
|
||||
@@ -116,6 +116,8 @@ protected:
|
||||
void focusInEvent(QFocusEvent *event) override;
|
||||
|
||||
private:
|
||||
void setMasterIcon();
|
||||
void clearMasterIcon();
|
||||
void setLDPIIcon();
|
||||
void setMDPIIcon();
|
||||
void setHDPIIcon();
|
||||
@@ -124,8 +126,11 @@ private:
|
||||
void clearHDPIIcon();
|
||||
void createDPIButton(QHBoxLayout *layout,
|
||||
QWidget *parent,
|
||||
QToolButton *&button, QToolButton *&clearButton,
|
||||
const QString &title, const QString &tooltip);
|
||||
QToolButton *&button, const QSize &buttonSize,
|
||||
const QString &title, const QString &tooltip,
|
||||
QToolButton **clearButton = nullptr,
|
||||
QLabel **scaleWarningLabel = nullptr
|
||||
);
|
||||
void defaultPermissionOrFeatureCheckBoxClicked();
|
||||
void addPermission();
|
||||
void removePermission();
|
||||
@@ -146,7 +151,11 @@ private:
|
||||
enum IconDPI { LowDPI, MediumDPI, HighDPI };
|
||||
QIcon icon(const QString &baseDir, IconDPI dpi);
|
||||
QString iconPath(IconDPI dpi);
|
||||
QSize iconSize(IconDPI dpi);
|
||||
void updateIconPath(const QString &newPath, IconDPI dpi);
|
||||
void copyIcon(IconDPI dpi, const QString &baseDir, const QString &filePath);
|
||||
void removeIcon(IconDPI dpi, const QString &baseDir);
|
||||
void toggleIconScaleWarning(IconDPI dpi, bool visible);
|
||||
|
||||
void updateInfoBar(const QString &errorMessage, int line, int column);
|
||||
void hideInfoBar();
|
||||
@@ -180,13 +189,17 @@ private:
|
||||
QLineEdit *m_appNameLineEdit;
|
||||
QLineEdit *m_activityNameLineEdit;
|
||||
QComboBox *m_targetLineEdit;
|
||||
QToolButton *m_masterIconButton;
|
||||
QToolButton *m_lIconButton;
|
||||
QToolButton *m_lIconClearButton;
|
||||
QLabel *m_lIconScaleWarningLabel;
|
||||
QToolButton *m_mIconButton;
|
||||
QToolButton *m_mIconClearButton;
|
||||
QLabel *m_mIconScaleWarningLabel;
|
||||
QToolButton *m_hIconButton;
|
||||
QToolButton *m_hIconClearButton;
|
||||
QString m_lIconPath; // only set if the user changed the icon
|
||||
QLabel *m_hIconScaleWarningLabel;
|
||||
QString m_lIconPath;
|
||||
QString m_mIconPath;
|
||||
QString m_hIconPath;
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ void AndroidSdkDownloader::cancel()
|
||||
m_reply->deleteLater();
|
||||
}
|
||||
if (m_progressDialog)
|
||||
m_progressDialog->hide();
|
||||
m_progressDialog->cancel();
|
||||
}
|
||||
|
||||
void AndroidSdkDownloader::cancelWithError(const QString &error)
|
||||
|
||||
@@ -69,15 +69,19 @@ using SdkCmdFutureInterface = QFutureInterface<AndroidSdkManager::OperationOutpu
|
||||
int platformNameToApiLevel(const QString &platformName)
|
||||
{
|
||||
int apiLevel = -1;
|
||||
QRegularExpression re("(android-)(?<apiLevel>[0-9Q]{1,})",
|
||||
QRegularExpression re("(android-)(?<apiLevel>[0-9A-Z]{1,})",
|
||||
QRegularExpression::CaseInsensitiveOption);
|
||||
QRegularExpressionMatch match = re.match(platformName);
|
||||
if (match.hasMatch()) {
|
||||
QString apiLevelStr = match.captured("apiLevel");
|
||||
if (apiLevelStr == 'Q')
|
||||
apiLevel = 29;
|
||||
else
|
||||
apiLevel = apiLevelStr.toInt();
|
||||
bool isUInt;
|
||||
apiLevel = apiLevelStr.toUInt(&isUInt);
|
||||
if (!isUInt) {
|
||||
if (apiLevelStr == 'Q')
|
||||
apiLevel = 29;
|
||||
else if (apiLevelStr == 'R')
|
||||
apiLevel = 30;
|
||||
}
|
||||
}
|
||||
return apiLevel;
|
||||
}
|
||||
|
||||
@@ -132,6 +132,7 @@ private:
|
||||
bool allEssentialsInstalled();
|
||||
bool sdkToolsOk() const;
|
||||
Utils::FilePath getDefaultSdkPath();
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
||||
Ui_AndroidSettingsWidget *m_ui;
|
||||
AndroidSdkManagerWidget *m_sdkManagerWidget = nullptr;
|
||||
@@ -143,6 +144,7 @@ private:
|
||||
QString m_lastAddedAvd;
|
||||
std::unique_ptr<AndroidAvdManager> m_avdManager;
|
||||
std::unique_ptr<AndroidSdkManager> m_sdkManager;
|
||||
bool m_isInitialReloadDone = false;
|
||||
};
|
||||
|
||||
enum JavaValidation {
|
||||
@@ -330,7 +332,19 @@ Utils::FilePath AndroidSettingsWidget::getDefaultSdkPath()
|
||||
}
|
||||
|
||||
return Utils::FilePath::fromString(
|
||||
QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/Android/Sdk");
|
||||
QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/Android/Sdk");
|
||||
}
|
||||
|
||||
void AndroidSettingsWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
if (!m_isInitialReloadDone) {
|
||||
// Reloading SDK packages (force) is still synchronous. Use zero timer
|
||||
// to let settings dialog open first.
|
||||
QTimer::singleShot(0, std::bind(&AndroidSdkManager::reloadPackages,
|
||||
m_sdkManager.get(), true));
|
||||
m_isInitialReloadDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidSettingsWidget::updateNdkList()
|
||||
@@ -398,8 +412,6 @@ AndroidSettingsWidget::AndroidSettingsWidget()
|
||||
m_ui->OpenJDKLocationPathChooser->setFileName(currentJdkPath);
|
||||
m_ui->OpenJDKLocationPathChooser->setPromptDialogTitle(tr("Select JDK Path"));
|
||||
|
||||
connect(m_ui->SDKLocationPathChooser, &Utils::PathChooser::rawPathChanged,
|
||||
this, &AndroidSettingsWidget::onSdkPathChanged);
|
||||
Utils::FilePath currentSDKPath = m_androidConfig.sdkLocation();
|
||||
if (currentSDKPath.isEmpty())
|
||||
currentSDKPath = getDefaultSdkPath();
|
||||
@@ -421,6 +433,8 @@ AndroidSettingsWidget::AndroidSettingsWidget()
|
||||
m_ui->downloadOpenJDKToolButton->setIcon(downloadIcon);
|
||||
m_ui->sdkToolsAutoDownloadButton->setIcon(Utils::Icons::RELOAD.icon());
|
||||
|
||||
connect(m_ui->SDKLocationPathChooser, &Utils::PathChooser::rawPathChanged,
|
||||
this, &AndroidSettingsWidget::onSdkPathChanged);
|
||||
connect(m_ui->ndkListComboBox, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||
[this](const QString) { validateNdk(); });
|
||||
connect(&m_virtualDevicesWatcher, &QFutureWatcherBase::finished,
|
||||
@@ -464,20 +478,6 @@ AndroidSettingsWidget::AndroidSettingsWidget()
|
||||
}
|
||||
downloadSdk();
|
||||
});
|
||||
|
||||
auto startOneShot = QSharedPointer<QMetaObject::Connection>::create();
|
||||
*startOneShot = connect(m_sdkManager.get(),
|
||||
&AndroidSdkManager::packageReloadFinished, [this, startOneShot] {
|
||||
QObject::disconnect(*startOneShot);
|
||||
if (!sdkToolsOk())
|
||||
downloadSdk();
|
||||
});
|
||||
|
||||
// Reloading SDK packages (force) is still synchronous. Use zero timer to let settings dialog open
|
||||
// first.
|
||||
QTimer::singleShot(0, std::bind(&AndroidSdkManager::reloadPackages, m_sdkManager.get(), true));
|
||||
|
||||
startUpdateAvd();
|
||||
}
|
||||
|
||||
AndroidSettingsWidget::~AndroidSettingsWidget()
|
||||
@@ -648,6 +648,7 @@ void AndroidSettingsWidget::validateSdk()
|
||||
}
|
||||
}
|
||||
|
||||
startUpdateAvd();
|
||||
updateNdkList();
|
||||
validateNdk();
|
||||
}
|
||||
@@ -769,9 +770,8 @@ void AndroidSettingsWidget::manageAVD()
|
||||
|
||||
void AndroidSettingsWidget::downloadSdk()
|
||||
{
|
||||
QString message(tr("Android SDK Tools package is not installed. Do you want to download it?\n"
|
||||
"The final location: ")
|
||||
+ QDir::toNativeSeparators(m_ui->SDKLocationPathChooser->rawPath()));
|
||||
QString message(tr("Do you want to download and install Android SDK Tools to: %1?")
|
||||
.arg(QDir::toNativeSeparators(m_ui->SDKLocationPathChooser->rawPath())));
|
||||
auto userInput = QMessageBox::information(this, AndroidSdkDownloader::dialogTitle(),
|
||||
message, QMessageBox::Yes | QMessageBox::No);
|
||||
if (userInput == QMessageBox::Yes) {
|
||||
@@ -786,6 +786,7 @@ void AndroidSettingsWidget::downloadSdk()
|
||||
|
||||
connect(sdkDownloader, &AndroidSdkDownloader::sdkExtracted, this, [this]() {
|
||||
m_sdkManager->reloadPackages(true);
|
||||
updateUI();
|
||||
apply();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user