2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
#include "androidconfigurations.h"
|
|
|
|
|
#include "androidconstants.h"
|
2019-12-23 16:13:23 +02:00
|
|
|
#include "androidsdkdownloader.h"
|
2020-05-20 12:51:21 +02:00
|
|
|
#include "androidsdkmanager.h"
|
2017-09-18 13:48:00 +02:00
|
|
|
#include "androidsdkmanagerwidget.h"
|
2022-10-06 17:53:35 +02:00
|
|
|
#include "androidsettingswidget.h"
|
|
|
|
|
#include "androidtr.h"
|
2020-05-20 12:51:21 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
#include <utils/detailswidget.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2019-12-12 23:15:48 +01:00
|
|
|
#include <utils/infolabel.h>
|
2022-07-22 10:04:02 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
2014-03-03 12:05:01 +01:00
|
|
|
#include <utils/pathchooser.h>
|
2021-05-30 14:27:02 +03:00
|
|
|
#include <utils/progressindicator.h>
|
2020-05-20 12:51:21 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2020-02-28 19:27:03 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2016-08-03 17:55:54 +02:00
|
|
|
#include <utils/utilsicons.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
#include <QCheckBox>
|
2014-02-18 20:20:32 +01:00
|
|
|
#include <QDesktopServices>
|
2019-12-23 16:13:23 +02:00
|
|
|
#include <QDir>
|
2020-03-11 18:49:02 +02:00
|
|
|
#include <QFileDialog>
|
2022-07-22 10:04:02 +02:00
|
|
|
#include <QGroupBox>
|
2020-01-10 12:53:28 +01:00
|
|
|
#include <QList>
|
2022-07-22 10:04:02 +02:00
|
|
|
#include <QListWidget>
|
2020-04-17 14:23:21 +03:00
|
|
|
#include <QLoggingCategory>
|
2012-04-18 20:30:57 +03:00
|
|
|
#include <QMessageBox>
|
2022-07-22 10:04:02 +02:00
|
|
|
#include <QPushButton>
|
2020-07-16 08:17:01 +02:00
|
|
|
#include <QStandardPaths>
|
2020-01-10 12:53:28 +01:00
|
|
|
#include <QTimer>
|
2022-07-22 10:04:02 +02:00
|
|
|
#include <QToolButton>
|
2020-01-10 12:53:28 +01:00
|
|
|
#include <QUrl>
|
2022-07-22 10:04:02 +02:00
|
|
|
#include <QVBoxLayout>
|
2020-01-10 12:53:28 +01:00
|
|
|
|
|
|
|
|
#include <memory>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2020-05-20 06:35:10 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
namespace Android::Internal {
|
2017-09-14 13:29:46 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
static Q_LOGGING_CATEGORY(androidsettingswidget, "qtc.android.androidsettingswidget", QtWarningMsg);
|
2020-02-28 19:27:03 +02:00
|
|
|
|
2017-09-14 13:29:46 +02:00
|
|
|
class SummaryWidget : public QWidget
|
|
|
|
|
{
|
|
|
|
|
class RowData {
|
|
|
|
|
public:
|
2020-05-20 09:54:50 +02:00
|
|
|
InfoLabel *m_infoLabel = nullptr;
|
2017-09-14 13:29:46 +02:00
|
|
|
bool m_valid = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
SummaryWidget(const QMap<int, QString> &validationPoints, const QString &validText,
|
2020-05-20 09:54:50 +02:00
|
|
|
const QString &invalidText, DetailsWidget *detailsWidget) :
|
2017-09-14 13:29:46 +02:00
|
|
|
QWidget(detailsWidget),
|
|
|
|
|
m_validText(validText),
|
|
|
|
|
m_invalidText(invalidText),
|
|
|
|
|
m_detailsWidget(detailsWidget)
|
|
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_detailsWidget);
|
2019-12-12 23:15:48 +01:00
|
|
|
auto layout = new QVBoxLayout(this);
|
2020-07-02 11:35:07 +02:00
|
|
|
layout->setContentsMargins(22, 0, 0, 12);
|
|
|
|
|
layout->setSpacing(4);
|
2017-09-14 13:29:46 +02:00
|
|
|
for (auto itr = validationPoints.cbegin(); itr != validationPoints.cend(); ++itr) {
|
|
|
|
|
RowData data;
|
2020-05-20 09:54:50 +02:00
|
|
|
data.m_infoLabel = new InfoLabel(itr.value());
|
2019-12-12 23:15:48 +01:00
|
|
|
layout->addWidget(data.m_infoLabel);
|
2017-09-14 13:29:46 +02:00
|
|
|
m_validationData[itr.key()] = data;
|
2020-07-02 14:01:47 +03:00
|
|
|
setPointValid(itr.key(), false);
|
2017-09-14 13:29:46 +02:00
|
|
|
}
|
2020-05-20 12:51:21 +02:00
|
|
|
m_detailsWidget->setWidget(this);
|
2020-07-02 11:35:07 +02:00
|
|
|
setContentsMargins(0, 0, 0, 0);
|
2017-09-14 13:29:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setPointValid(int key, bool valid)
|
|
|
|
|
{
|
|
|
|
|
if (!m_validationData.contains(key))
|
|
|
|
|
return;
|
2020-05-20 12:51:21 +02:00
|
|
|
RowData &data = m_validationData[key];
|
2017-09-14 13:29:46 +02:00
|
|
|
data.m_valid = valid;
|
2020-05-20 09:54:50 +02:00
|
|
|
data.m_infoLabel->setType(valid ? InfoLabel::Ok : InfoLabel::NotOk);
|
2017-09-18 13:48:00 +02:00
|
|
|
updateUi();
|
2017-09-14 13:29:46 +02:00
|
|
|
}
|
|
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
bool rowsOk(const QList<int> &keys) const
|
2017-09-14 13:29:46 +02:00
|
|
|
{
|
2017-09-18 13:48:00 +02:00
|
|
|
for (auto key : keys) {
|
|
|
|
|
if (!m_validationData[key].m_valid)
|
2017-09-14 13:29:46 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
bool allRowsOk() const
|
|
|
|
|
{
|
|
|
|
|
return rowsOk(m_validationData.keys());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setInfoText(const QString &text)
|
|
|
|
|
{
|
2017-09-18 13:48:00 +02:00
|
|
|
m_infoText = text;
|
|
|
|
|
updateUi();
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-30 14:27:02 +03:00
|
|
|
void setInProgressText(const QString &text)
|
|
|
|
|
{
|
|
|
|
|
m_detailsWidget->setIcon({});
|
|
|
|
|
m_detailsWidget->setSummaryText(QString("%1...").arg(text));
|
|
|
|
|
m_detailsWidget->setState(DetailsWidget::Collapsed);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
void setSetupOk(bool ok)
|
|
|
|
|
{
|
|
|
|
|
m_detailsWidget->setState(ok ? DetailsWidget::Collapsed : DetailsWidget::Expanded);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-30 14:27:02 +03:00
|
|
|
void setState(DetailsWidget::State state)
|
|
|
|
|
{
|
|
|
|
|
m_detailsWidget->setState(state);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 13:29:46 +02:00
|
|
|
private:
|
2017-09-18 13:48:00 +02:00
|
|
|
void updateUi() {
|
|
|
|
|
bool ok = allRowsOk();
|
2020-05-20 09:54:50 +02:00
|
|
|
m_detailsWidget->setIcon(ok ? Icons::OK.icon() : Icons::CRITICAL.icon());
|
2017-09-18 13:48:00 +02:00
|
|
|
m_detailsWidget->setSummaryText(ok ? QString("%1 %2").arg(m_validText).arg(m_infoText)
|
|
|
|
|
: m_invalidText);
|
|
|
|
|
}
|
2017-09-14 13:29:46 +02:00
|
|
|
QString m_validText;
|
|
|
|
|
QString m_invalidText;
|
2017-09-18 13:48:00 +02:00
|
|
|
QString m_infoText;
|
2020-05-20 09:54:50 +02:00
|
|
|
DetailsWidget *m_detailsWidget = nullptr;
|
2017-09-14 13:29:46 +02:00
|
|
|
QMap<int, RowData> m_validationData;
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
class AndroidSettingsWidget final : public Core::IOptionsPageWidget
|
2020-02-10 20:25:24 +02:00
|
|
|
{
|
2022-07-22 10:04:02 +02:00
|
|
|
public:
|
|
|
|
|
// Todo: This would be so much simpler if it just used Utils::PathChooser!!!
|
|
|
|
|
AndroidSettingsWidget();
|
|
|
|
|
~AndroidSettingsWidget() final;
|
2020-02-24 11:19:02 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
private:
|
|
|
|
|
void apply() final { AndroidConfigurations::setConfig(m_androidConfig); }
|
2020-03-11 18:49:02 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
void showEvent(QShowEvent *event) override;
|
2021-12-07 21:04:51 +01:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
void validateJdk();
|
|
|
|
|
void updateNdkList();
|
|
|
|
|
void onSdkPathChanged();
|
|
|
|
|
void validateSdk();
|
|
|
|
|
void openSDKDownloadUrl();
|
|
|
|
|
void openNDKDownloadUrl();
|
|
|
|
|
void openOpenJDKDownloadUrl();
|
|
|
|
|
void downloadOpenSslRepo(const bool silent = false);
|
|
|
|
|
void createKitToggled();
|
2020-02-24 11:19:02 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
void updateUI();
|
2020-03-11 18:49:02 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
void downloadSdk();
|
|
|
|
|
void addCustomNdkItem();
|
|
|
|
|
bool isDefaultNdkSelected() const;
|
|
|
|
|
void validateOpenSsl();
|
2019-12-23 16:13:23 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
AndroidSdkManagerWidget *m_sdkManagerWidget = nullptr;
|
|
|
|
|
AndroidConfig &m_androidConfig{AndroidConfigurations::currentConfig()};
|
2021-12-07 21:04:51 +01:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
AndroidSdkManager m_sdkManager{m_androidConfig};
|
|
|
|
|
AndroidSdkDownloader m_sdkDownloader;
|
|
|
|
|
bool m_isInitialReloadDone = false;
|
|
|
|
|
|
|
|
|
|
SummaryWidget *m_androidSummary = nullptr;
|
|
|
|
|
SummaryWidget *m_openSslSummary = nullptr;
|
|
|
|
|
|
|
|
|
|
ProgressIndicator *m_androidProgress = nullptr;
|
|
|
|
|
|
|
|
|
|
PathChooser *m_sdkLocationPathChooser;
|
|
|
|
|
QPushButton *m_makeDefaultNdkButton;
|
|
|
|
|
QListWidget *m_ndkListWidget;
|
|
|
|
|
PathChooser *m_openJdkLocationPathChooser;
|
|
|
|
|
QCheckBox *m_createKitCheckBox;
|
|
|
|
|
PathChooser *m_openSslPathChooser;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum AndroidValidation {
|
|
|
|
|
JavaPathExistsAndWritableRow,
|
|
|
|
|
SdkPathExistsAndWritableRow,
|
|
|
|
|
SdkToolsInstalledRow,
|
|
|
|
|
SdkManagerSuccessfulRow,
|
2022-11-10 15:58:03 +01:00
|
|
|
PlatformToolsInstalledRow,
|
2022-07-22 10:04:02 +02:00
|
|
|
PlatformSdkInstalledRow,
|
|
|
|
|
BuildToolsInstalledRow,
|
|
|
|
|
AllEssentialsInstalledRow,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum OpenSslValidation {
|
|
|
|
|
OpenSslPathExistsRow,
|
|
|
|
|
OpenSslPriPathExists,
|
|
|
|
|
OpenSslCmakeListsPathExists
|
|
|
|
|
};
|
2021-12-07 21:04:51 +01:00
|
|
|
|
2020-01-07 13:54:07 +01:00
|
|
|
AndroidSettingsWidget::AndroidSettingsWidget()
|
2020-05-20 09:54:50 +02:00
|
|
|
{
|
2022-10-06 17:53:35 +02:00
|
|
|
setWindowTitle(Tr::tr("Android Configuration"));
|
2017-09-14 13:29:46 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
const QIcon downloadIcon = Icons::ONLINE.icon();
|
2020-02-28 19:27:03 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
m_sdkLocationPathChooser = new PathChooser;
|
2019-12-23 16:13:23 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
auto downloadSdkToolButton = new QToolButton;
|
|
|
|
|
downloadSdkToolButton->setIcon(downloadIcon);
|
2022-10-06 17:53:35 +02:00
|
|
|
downloadSdkToolButton->setToolTip(Tr::tr("Open Android SDK download URL in the system's browser."));
|
2019-12-23 16:13:23 +02:00
|
|
|
|
2022-10-06 17:53:35 +02:00
|
|
|
auto addCustomNdkButton = new QPushButton(Tr::tr("Add..."));
|
|
|
|
|
addCustomNdkButton->setToolTip(Tr::tr("Add the selected custom NDK. The toolchains "
|
|
|
|
|
"and debuggers will be created automatically."));
|
2020-05-20 09:54:50 +02:00
|
|
|
|
2022-10-06 17:53:35 +02:00
|
|
|
auto removeCustomNdkButton = new QPushButton(Tr::tr("Remove"));
|
2022-07-22 10:04:02 +02:00
|
|
|
removeCustomNdkButton->setEnabled(false);
|
2022-10-06 17:53:35 +02:00
|
|
|
removeCustomNdkButton->setToolTip(Tr::tr("Remove the selected NDK if it has been added manually."));
|
2020-05-20 09:54:50 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
m_makeDefaultNdkButton = new QPushButton;
|
2022-10-06 17:53:35 +02:00
|
|
|
m_makeDefaultNdkButton->setToolTip(Tr::tr("Force a specific NDK installation to be used by all "
|
|
|
|
|
"Android kits.<br/>Note that the forced NDK might not "
|
|
|
|
|
"be compatible with all registered Qt versions."));
|
2022-07-22 10:04:02 +02:00
|
|
|
|
|
|
|
|
auto androidDetailsWidget = new DetailsWidget;
|
|
|
|
|
|
|
|
|
|
m_ndkListWidget = new QListWidget;
|
|
|
|
|
m_ndkListWidget->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
|
|
|
|
|
m_ndkListWidget->setIconSize(QSize(16, 16));
|
|
|
|
|
m_ndkListWidget->setResizeMode(QListView::Adjust);
|
|
|
|
|
m_ndkListWidget->setModelColumn(0);
|
|
|
|
|
m_ndkListWidget->setSortingEnabled(false);
|
|
|
|
|
|
|
|
|
|
m_openJdkLocationPathChooser = new PathChooser;
|
|
|
|
|
|
|
|
|
|
auto downloadOpenJdkToolButton = new QToolButton;
|
|
|
|
|
downloadOpenJdkToolButton->setIcon(downloadIcon);
|
2022-10-06 17:53:35 +02:00
|
|
|
downloadOpenJdkToolButton->setToolTip(Tr::tr("Open JDK download URL in the system's browser."));
|
2022-07-22 10:04:02 +02:00
|
|
|
|
2022-10-06 17:53:35 +02:00
|
|
|
auto sdkToolsAutoDownloadButton = new QPushButton(Tr::tr("Set Up SDK"));
|
2022-07-22 10:04:02 +02:00
|
|
|
sdkToolsAutoDownloadButton->setToolTip(
|
2022-10-06 17:53:35 +02:00
|
|
|
Tr::tr("Automatically download Android SDK Tools to selected location.\n\n"
|
|
|
|
|
"If the selected path contains no valid SDK Tools, the SDK Tools package is downloaded\n"
|
|
|
|
|
"from %1,\n"
|
|
|
|
|
"and extracted to the selected path.\n"
|
|
|
|
|
"After the SDK Tools are properly set up, you are prompted to install any essential\n"
|
|
|
|
|
"packages required for Qt to build for Android.")
|
|
|
|
|
.arg(m_androidConfig.sdkToolsUrl().toString()));
|
2020-07-22 13:14:55 +03:00
|
|
|
|
2022-10-06 17:53:35 +02:00
|
|
|
auto sdkManagerToolButton = new QPushButton(Tr::tr("SDK Manager"));
|
2022-07-22 10:04:02 +02:00
|
|
|
|
|
|
|
|
auto downloadNdkToolButton = new QToolButton;
|
2022-10-06 17:53:35 +02:00
|
|
|
downloadNdkToolButton->setToolTip(Tr::tr("Open Android NDK download URL in the system's browser."));
|
2022-07-22 10:04:02 +02:00
|
|
|
|
2022-10-06 17:53:35 +02:00
|
|
|
m_createKitCheckBox = new QCheckBox(Tr::tr("Automatically create kits for Android tool chains"));
|
2022-07-22 10:04:02 +02:00
|
|
|
m_createKitCheckBox->setChecked(true);
|
|
|
|
|
|
|
|
|
|
auto openSslDetailsWidget = new DetailsWidget;
|
|
|
|
|
|
|
|
|
|
m_openSslPathChooser = new PathChooser;
|
2022-10-06 17:53:35 +02:00
|
|
|
m_openSslPathChooser->setToolTip(Tr::tr("Select the path of the prebuilt OpenSSL binaries."));
|
2022-07-22 10:04:02 +02:00
|
|
|
|
2022-10-06 17:53:35 +02:00
|
|
|
auto downloadOpenSslPrebuiltLibs = new QPushButton(Tr::tr("Download OpenSSL"));
|
2022-07-22 10:04:02 +02:00
|
|
|
downloadOpenSslPrebuiltLibs->setToolTip(
|
2022-10-06 17:53:35 +02:00
|
|
|
Tr::tr("Automatically download OpenSSL prebuilt libraries.\n\n"
|
|
|
|
|
"These libraries can be shipped with your application if any SSL operations\n"
|
|
|
|
|
"are performed. Find the checkbox under \"Projects > Build > Build Steps >\n"
|
|
|
|
|
"Build Android APK > Additional Libraries\".\n"
|
|
|
|
|
"If the automatic download fails, Qt Creator proposes to open the download URL\n"
|
|
|
|
|
"in the system's browser for manual download."));
|
2019-08-23 19:13:51 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
|
|
|
|
|
m_sdkManagerWidget = new AndroidSdkManagerWidget(m_androidConfig, &m_sdkManager, this);
|
|
|
|
|
|
|
|
|
|
const QMap<int, QString> androidValidationPoints = {
|
2022-10-06 17:53:35 +02:00
|
|
|
{ JavaPathExistsAndWritableRow, Tr::tr("JDK path exists and is writable.") },
|
2022-11-10 15:58:03 +01:00
|
|
|
{ SdkPathExistsAndWritableRow, Tr::tr("Android SDK path exists and is writable.") },
|
|
|
|
|
{ SdkToolsInstalledRow, Tr::tr("Android SDK Command-line Tools installed.") },
|
|
|
|
|
{ SdkManagerSuccessfulRow, Tr::tr("Android SDK Command-line Tools run.") },
|
|
|
|
|
{ PlatformToolsInstalledRow, Tr::tr("Android SDK Platform-Tools installed.") },
|
2022-07-22 10:04:02 +02:00
|
|
|
{ AllEssentialsInstalledRow,
|
2022-10-06 17:53:35 +02:00
|
|
|
Tr::tr( "All essential packages installed for all installed Qt versions.") },
|
2022-11-10 15:58:03 +01:00
|
|
|
{ BuildToolsInstalledRow, Tr::tr("Android SDK Build-Tools installed.") },
|
|
|
|
|
{ PlatformSdkInstalledRow, Tr::tr("Android Platform SDK (version) installed.") }
|
2022-07-22 10:04:02 +02:00
|
|
|
};
|
|
|
|
|
|
2022-10-06 17:53:35 +02:00
|
|
|
m_androidSummary = new SummaryWidget(androidValidationPoints, Tr::tr("Android settings are OK."),
|
|
|
|
|
Tr::tr("Android settings have errors."),
|
2022-07-22 10:04:02 +02:00
|
|
|
androidDetailsWidget);
|
|
|
|
|
m_androidProgress = new ProgressIndicator(ProgressIndicatorSize::Medium, this);
|
|
|
|
|
m_androidProgress->attachToWidget(androidDetailsWidget);
|
|
|
|
|
m_androidProgress->hide();
|
|
|
|
|
|
|
|
|
|
const QMap<int, QString> openSslValidationPoints = {
|
2022-10-06 17:53:35 +02:00
|
|
|
{ OpenSslPathExistsRow, Tr::tr("OpenSSL path exists.") },
|
|
|
|
|
{ OpenSslPriPathExists, Tr::tr("QMake include project (openssl.pri) exists.") },
|
|
|
|
|
{ OpenSslCmakeListsPathExists, Tr::tr("CMake include project (CMakeLists.txt) exists.") }
|
2022-07-22 10:04:02 +02:00
|
|
|
};
|
|
|
|
|
m_openSslSummary = new SummaryWidget(openSslValidationPoints,
|
2022-10-06 17:53:35 +02:00
|
|
|
Tr::tr("OpenSSL Settings are OK."),
|
|
|
|
|
Tr::tr("OpenSSL settings have errors."),
|
2022-07-22 10:04:02 +02:00
|
|
|
openSslDetailsWidget);
|
|
|
|
|
|
|
|
|
|
connect(m_openJdkLocationPathChooser, &PathChooser::rawPathChanged,
|
|
|
|
|
this, &AndroidSettingsWidget::validateJdk);
|
|
|
|
|
if (m_androidConfig.openJDKLocation().isEmpty())
|
|
|
|
|
m_androidConfig.setOpenJDKLocation(AndroidConfig::getJdkPath());
|
|
|
|
|
m_openJdkLocationPathChooser->setFilePath(m_androidConfig.openJDKLocation());
|
2022-10-06 17:53:35 +02:00
|
|
|
m_openJdkLocationPathChooser->setPromptDialogTitle(Tr::tr("Select JDK Path"));
|
2022-07-22 10:04:02 +02:00
|
|
|
|
|
|
|
|
if (m_androidConfig.sdkLocation().isEmpty())
|
|
|
|
|
m_androidConfig.setSdkLocation(AndroidConfig::defaultSdkPath());
|
|
|
|
|
m_sdkLocationPathChooser->setFilePath(m_androidConfig.sdkLocation());
|
2022-10-06 17:53:35 +02:00
|
|
|
m_sdkLocationPathChooser->setPromptDialogTitle(Tr::tr("Select Android SDK Folder"));
|
2022-07-22 10:04:02 +02:00
|
|
|
|
2022-10-06 17:53:35 +02:00
|
|
|
m_openSslPathChooser->setPromptDialogTitle(Tr::tr("Select OpenSSL Include Project File"));
|
2022-07-22 10:04:02 +02:00
|
|
|
if (m_androidConfig.openSslLocation().isEmpty())
|
|
|
|
|
m_androidConfig.setOpenSslLocation(m_androidConfig.sdkLocation() / ("android_openssl"));
|
|
|
|
|
m_openSslPathChooser->setFilePath(m_androidConfig.openSslLocation());
|
|
|
|
|
|
|
|
|
|
m_createKitCheckBox->setChecked(m_androidConfig.automaticKitCreation());
|
|
|
|
|
|
|
|
|
|
downloadNdkToolButton->setIcon(downloadIcon);
|
|
|
|
|
|
|
|
|
|
using namespace Layouting;
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
Group {
|
2022-10-06 17:53:35 +02:00
|
|
|
title(Tr::tr("Android Settings")),
|
2022-07-22 10:04:02 +02:00
|
|
|
Grid {
|
2022-10-06 17:53:35 +02:00
|
|
|
Tr::tr("JDK location:"),
|
2022-07-22 10:04:02 +02:00
|
|
|
m_openJdkLocationPathChooser,
|
|
|
|
|
empty,
|
|
|
|
|
downloadOpenJdkToolButton,
|
|
|
|
|
br,
|
|
|
|
|
|
2022-10-06 17:53:35 +02:00
|
|
|
Tr::tr("Android SDK location:"),
|
2022-07-22 10:04:02 +02:00
|
|
|
m_sdkLocationPathChooser,
|
|
|
|
|
sdkToolsAutoDownloadButton,
|
|
|
|
|
downloadSdkToolButton,
|
|
|
|
|
br,
|
|
|
|
|
|
|
|
|
|
empty, empty, sdkManagerToolButton, br,
|
|
|
|
|
|
2022-10-06 17:53:35 +02:00
|
|
|
Column { Tr::tr("Android NDK list:"), st },
|
2022-07-22 10:04:02 +02:00
|
|
|
m_ndkListWidget,
|
|
|
|
|
Column {
|
|
|
|
|
addCustomNdkButton,
|
|
|
|
|
removeCustomNdkButton,
|
|
|
|
|
m_makeDefaultNdkButton,
|
|
|
|
|
},
|
|
|
|
|
downloadNdkToolButton,
|
|
|
|
|
br,
|
|
|
|
|
|
|
|
|
|
Span(4, androidDetailsWidget), br,
|
|
|
|
|
|
|
|
|
|
Span(4, m_createKitCheckBox)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Group {
|
2022-10-06 17:53:35 +02:00
|
|
|
title(Tr::tr("Android OpenSSL settings (Optional)")),
|
2022-07-22 10:04:02 +02:00
|
|
|
Grid {
|
2022-10-06 17:53:35 +02:00
|
|
|
Tr::tr("OpenSSL binaries location:"),
|
2022-07-22 10:04:02 +02:00
|
|
|
m_openSslPathChooser,
|
|
|
|
|
downloadOpenSslPrebuiltLibs,
|
|
|
|
|
br,
|
|
|
|
|
|
|
|
|
|
Span(4, openSslDetailsWidget)
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-07-22 18:54:04 +02:00
|
|
|
st
|
2022-07-22 10:04:02 +02:00
|
|
|
}.attachTo(this);
|
|
|
|
|
|
|
|
|
|
connect(m_sdkLocationPathChooser, &PathChooser::rawPathChanged,
|
2020-02-10 20:25:24 +02:00
|
|
|
this, &AndroidSettingsWidget::onSdkPathChanged);
|
2020-03-11 18:49:02 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
connect(m_ndkListWidget, &QListWidget::currentTextChanged,
|
|
|
|
|
[this, removeCustomNdkButton](const QString &ndk) {
|
2020-06-30 12:21:38 +03:00
|
|
|
updateUI();
|
2022-07-22 10:04:02 +02:00
|
|
|
removeCustomNdkButton->setEnabled(m_androidConfig.getCustomNdkList().contains(ndk));
|
2020-02-24 11:19:02 +02:00
|
|
|
});
|
2022-07-22 10:04:02 +02:00
|
|
|
connect(addCustomNdkButton, &QPushButton::clicked, this,
|
2020-02-24 11:19:02 +02:00
|
|
|
&AndroidSettingsWidget::addCustomNdkItem);
|
2022-07-22 10:04:02 +02:00
|
|
|
connect(removeCustomNdkButton, &QPushButton::clicked, this, [this] {
|
2021-12-07 21:04:51 +01:00
|
|
|
if (isDefaultNdkSelected())
|
|
|
|
|
m_androidConfig.setDefaultNdk({});
|
2022-07-22 10:04:02 +02:00
|
|
|
m_androidConfig.removeCustomNdk(m_ndkListWidget->currentItem()->text());
|
|
|
|
|
m_ndkListWidget->takeItem(m_ndkListWidget->currentRow());
|
2020-02-24 11:19:02 +02:00
|
|
|
});
|
2022-07-22 10:04:02 +02:00
|
|
|
connect(m_makeDefaultNdkButton, &QPushButton::clicked, this, [this] {
|
2021-12-07 21:04:51 +01:00
|
|
|
const FilePath defaultNdk = isDefaultNdkSelected()
|
|
|
|
|
? FilePath()
|
2022-07-22 10:04:02 +02:00
|
|
|
: FilePath::fromUserInput(m_ndkListWidget->currentItem()->text());
|
2021-12-07 21:04:51 +01:00
|
|
|
m_androidConfig.setDefaultNdk(defaultNdk);
|
|
|
|
|
updateUI();
|
|
|
|
|
});
|
2020-02-24 11:19:02 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
connect(m_openSslPathChooser, &PathChooser::rawPathChanged,
|
2020-05-20 09:54:50 +02:00
|
|
|
this, &AndroidSettingsWidget::validateOpenSsl);
|
2022-07-22 10:04:02 +02:00
|
|
|
connect(m_createKitCheckBox, &QAbstractButton::toggled,
|
2016-06-26 22:52:59 +03:00
|
|
|
this, &AndroidSettingsWidget::createKitToggled);
|
2022-07-22 10:04:02 +02:00
|
|
|
connect(downloadNdkToolButton, &QAbstractButton::clicked,
|
2016-06-26 22:52:59 +03:00
|
|
|
this, &AndroidSettingsWidget::openNDKDownloadUrl);
|
2022-07-22 10:04:02 +02:00
|
|
|
connect(downloadSdkToolButton, &QAbstractButton::clicked,
|
2019-12-23 16:13:23 +02:00
|
|
|
this, &AndroidSettingsWidget::openSDKDownloadUrl);
|
2022-07-22 10:04:02 +02:00
|
|
|
connect(downloadOpenSslPrebuiltLibs, &QAbstractButton::clicked,
|
2020-02-28 19:27:03 +02:00
|
|
|
this, &AndroidSettingsWidget::downloadOpenSslRepo);
|
2022-07-22 10:04:02 +02:00
|
|
|
connect(downloadOpenJdkToolButton, &QAbstractButton::clicked,
|
2016-06-26 22:52:59 +03:00
|
|
|
this, &AndroidSettingsWidget::openOpenJDKDownloadUrl);
|
2022-07-22 10:04:02 +02:00
|
|
|
|
2017-09-18 13:48:00 +02:00
|
|
|
// Validate SDK again after any change in SDK packages.
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(&m_sdkManager, &AndroidSdkManager::packageReloadFinished,
|
2020-03-16 20:14:56 +02:00
|
|
|
this, &AndroidSettingsWidget::validateSdk);
|
2021-05-30 14:27:02 +03:00
|
|
|
connect(&m_sdkManager, &AndroidSdkManager::packageReloadFinished,
|
|
|
|
|
m_androidProgress, &ProgressIndicator::hide);
|
2022-07-19 22:51:32 +02:00
|
|
|
connect(&m_sdkManager, &AndroidSdkManager::packageReloadBegin, this, [this] {
|
2021-05-30 14:27:02 +03:00
|
|
|
m_androidSummary->setInProgressText("Retrieving packages information");
|
|
|
|
|
m_androidProgress->show();
|
|
|
|
|
});
|
2022-07-22 10:04:02 +02:00
|
|
|
connect(sdkManagerToolButton, &QAbstractButton::clicked,
|
2022-07-19 22:51:32 +02:00
|
|
|
this, [this] { m_sdkManagerWidget->exec(); });
|
2022-07-22 10:04:02 +02:00
|
|
|
connect(sdkToolsAutoDownloadButton, &QAbstractButton::clicked,
|
2020-03-16 20:14:56 +02:00
|
|
|
this, &AndroidSettingsWidget::downloadSdk);
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(&m_sdkDownloader, &AndroidSdkDownloader::sdkDownloaderError, this, [this](const QString &error) {
|
2020-03-16 20:14:56 +02:00
|
|
|
QMessageBox::warning(this, AndroidSdkDownloader::dialogTitle(), error);
|
|
|
|
|
});
|
2020-05-20 09:54:50 +02:00
|
|
|
connect(&m_sdkDownloader, &AndroidSdkDownloader::sdkExtracted, this, [this] {
|
2020-11-28 15:44:37 +02:00
|
|
|
// Make sure the sdk path is created before installing packages
|
|
|
|
|
const FilePath sdkPath = m_androidConfig.sdkLocation();
|
|
|
|
|
if (!sdkPath.createDir()) {
|
|
|
|
|
QMessageBox::warning(this, AndroidSdkDownloader::dialogTitle(),
|
2022-10-06 17:53:35 +02:00
|
|
|
Tr::tr("Failed to create the SDK Tools path %1.")
|
2020-11-28 15:44:37 +02:00
|
|
|
.arg("\n\"" + sdkPath.toUserOutput() + "\""));
|
|
|
|
|
}
|
2020-05-20 09:54:50 +02:00
|
|
|
m_sdkManager.reloadPackages(true);
|
2020-03-16 20:14:56 +02:00
|
|
|
updateUI();
|
|
|
|
|
apply();
|
|
|
|
|
|
|
|
|
|
QMetaObject::Connection *const openSslOneShot = new QMetaObject::Connection;
|
2020-05-20 09:54:50 +02:00
|
|
|
*openSslOneShot = connect(&m_sdkManager, &AndroidSdkManager::packageReloadFinished,
|
|
|
|
|
this, [this, openSslOneShot] {
|
2020-03-16 20:14:56 +02:00
|
|
|
QObject::disconnect(*openSslOneShot);
|
|
|
|
|
downloadOpenSslRepo(true);
|
|
|
|
|
delete openSslOneShot;
|
|
|
|
|
});
|
2019-12-23 16:13:23 +02:00
|
|
|
});
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2013-12-16 20:19:07 +01:00
|
|
|
AndroidSettingsWidget::~AndroidSettingsWidget()
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2017-09-18 13:48:00 +02:00
|
|
|
// Deleting m_sdkManagerWidget will cancel all ongoing and pending sdkmanager operations.
|
|
|
|
|
delete m_sdkManagerWidget;
|
2015-01-08 17:05:09 +01:00
|
|
|
}
|
|
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
void AndroidSettingsWidget::showEvent(QShowEvent *event)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(event)
|
|
|
|
|
if (!m_isInitialReloadDone) {
|
|
|
|
|
validateJdk();
|
|
|
|
|
// Reloading SDK packages (force) is still synchronous. Use zero timer
|
|
|
|
|
// to let settings dialog open first.
|
|
|
|
|
QTimer::singleShot(0, &m_sdkManager, std::bind(&AndroidSdkManager::reloadPackages,
|
|
|
|
|
&m_sdkManager, false));
|
|
|
|
|
validateOpenSsl();
|
|
|
|
|
m_isInitialReloadDone = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::updateNdkList()
|
|
|
|
|
{
|
|
|
|
|
m_ndkListWidget->clear();
|
|
|
|
|
const auto installedPkgs = m_sdkManager.installedNdkPackages();
|
|
|
|
|
for (const Ndk *ndk : installedPkgs) {
|
|
|
|
|
m_ndkListWidget->addItem(new QListWidgetItem(Icons::LOCKED.icon(),
|
|
|
|
|
ndk->installedLocation().toUserOutput()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto customNdks = m_androidConfig.getCustomNdkList();
|
|
|
|
|
for (const QString &ndk : customNdks) {
|
|
|
|
|
if (m_androidConfig.isValidNdk(ndk)) {
|
|
|
|
|
m_ndkListWidget->addItem(new QListWidgetItem(Icons::UNLOCKED.icon(), ndk));
|
|
|
|
|
} else {
|
|
|
|
|
m_androidConfig.removeCustomNdk(ndk);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_ndkListWidget->setCurrentRow(0);
|
|
|
|
|
|
|
|
|
|
updateUI();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::addCustomNdkItem()
|
|
|
|
|
{
|
|
|
|
|
const QString homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation)
|
|
|
|
|
.constFirst();
|
2022-10-06 17:53:35 +02:00
|
|
|
const QString ndkPath = QFileDialog::getExistingDirectory(this, Tr::tr("Select an NDK"), homePath);
|
2022-07-22 10:04:02 +02:00
|
|
|
|
|
|
|
|
if (m_androidConfig.isValidNdk(ndkPath)) {
|
|
|
|
|
m_androidConfig.addCustomNdk(ndkPath);
|
|
|
|
|
if (m_ndkListWidget->findItems(ndkPath, Qt::MatchExactly).size() == 0) {
|
|
|
|
|
m_ndkListWidget->addItem(new QListWidgetItem(Icons::UNLOCKED.icon(), ndkPath));
|
|
|
|
|
}
|
|
|
|
|
} else if (!ndkPath.isEmpty()) {
|
|
|
|
|
QMessageBox::warning(
|
2022-10-06 17:53:35 +02:00
|
|
|
this,
|
|
|
|
|
Tr::tr("Add Custom NDK"),
|
|
|
|
|
Tr::tr("The selected path has an invalid NDK. This might mean that the path contains space "
|
|
|
|
|
"characters, or that it does not have a \"toolchains\" sub-directory, or that the "
|
|
|
|
|
"NDK version could not be retrieved because of a missing \"source.properties\" or "
|
|
|
|
|
"\"RELEASE.TXT\" file"));
|
2022-07-22 10:04:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool AndroidSettingsWidget::isDefaultNdkSelected() const
|
|
|
|
|
{
|
|
|
|
|
if (!m_androidConfig.defaultNdk().isEmpty()) {
|
|
|
|
|
if (const QListWidgetItem *item = m_ndkListWidget->currentItem()) {
|
|
|
|
|
return FilePath::fromUserInput(item->text()) == m_androidConfig.defaultNdk();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 13:29:46 +02:00
|
|
|
void AndroidSettingsWidget::validateJdk()
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2022-07-22 10:04:02 +02:00
|
|
|
m_androidConfig.setOpenJDKLocation(m_openJdkLocationPathChooser->filePath());
|
2017-09-14 13:29:46 +02:00
|
|
|
bool jdkPathExists = m_androidConfig.openJDKLocation().exists();
|
2021-09-14 17:33:44 +03:00
|
|
|
const FilePath bin = m_androidConfig.openJDKLocation()
|
|
|
|
|
.pathAppended("bin/javac" QTC_HOST_EXE_SUFFIX);
|
|
|
|
|
m_androidSummary->setPointValid(JavaPathExistsAndWritableRow, jdkPathExists && bin.exists());
|
2020-03-23 14:40:37 +01:00
|
|
|
|
2017-09-14 13:29:46 +02:00
|
|
|
updateUI();
|
2020-06-26 00:34:51 +03:00
|
|
|
|
|
|
|
|
if (m_isInitialReloadDone)
|
|
|
|
|
m_sdkManager.reloadPackages(true);
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2020-02-28 19:27:03 +02:00
|
|
|
void AndroidSettingsWidget::validateOpenSsl()
|
|
|
|
|
{
|
2022-07-22 10:04:02 +02:00
|
|
|
m_androidConfig.setOpenSslLocation(m_openSslPathChooser->filePath());
|
2020-02-28 19:27:03 +02:00
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
m_openSslSummary->setPointValid(OpenSslPathExistsRow, m_androidConfig.openSslLocation().exists());
|
2020-02-28 19:27:03 +02:00
|
|
|
|
|
|
|
|
const bool priFileExists = m_androidConfig.openSslLocation().pathAppended("openssl.pri").exists();
|
2020-05-20 12:51:21 +02:00
|
|
|
m_openSslSummary->setPointValid(OpenSslPriPathExists, priFileExists);
|
2020-02-28 19:27:03 +02:00
|
|
|
const bool cmakeListsExists
|
|
|
|
|
= m_androidConfig.openSslLocation().pathAppended("CMakeLists.txt").exists();
|
2020-05-20 12:51:21 +02:00
|
|
|
m_openSslSummary->setPointValid(OpenSslCmakeListsPathExists, cmakeListsExists);
|
|
|
|
|
|
2020-02-28 19:27:03 +02:00
|
|
|
updateUI();
|
2020-01-13 15:18:35 +02:00
|
|
|
}
|
|
|
|
|
|
2017-09-26 11:24:16 +02:00
|
|
|
void AndroidSettingsWidget::onSdkPathChanged()
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2022-07-22 10:04:02 +02:00
|
|
|
const FilePath sdkPath = m_sdkLocationPathChooser->filePath().cleanPath();
|
2017-09-14 13:29:46 +02:00
|
|
|
m_androidConfig.setSdkLocation(sdkPath);
|
2020-05-20 09:54:50 +02:00
|
|
|
FilePath currentOpenSslPath = m_androidConfig.openSslLocation();
|
2020-04-17 14:23:21 +03:00
|
|
|
if (currentOpenSslPath.isEmpty() || !currentOpenSslPath.exists())
|
|
|
|
|
currentOpenSslPath = sdkPath.pathAppended("android_openssl");
|
2022-07-22 10:04:02 +02:00
|
|
|
m_openSslPathChooser->setFilePath(currentOpenSslPath);
|
2017-09-26 11:24:16 +02:00
|
|
|
// Package reload will trigger validateSdk.
|
2020-05-20 09:54:50 +02:00
|
|
|
m_sdkManager.reloadPackages();
|
2017-09-26 11:24:16 +02:00
|
|
|
}
|
2017-09-14 13:29:46 +02:00
|
|
|
|
2017-09-26 11:24:16 +02:00
|
|
|
void AndroidSettingsWidget::validateSdk()
|
|
|
|
|
{
|
2022-07-22 10:04:02 +02:00
|
|
|
const FilePath sdkPath = m_sdkLocationPathChooser->filePath().cleanPath();
|
2019-12-23 16:13:23 +02:00
|
|
|
m_androidConfig.setSdkLocation(sdkPath);
|
|
|
|
|
|
2021-09-14 17:33:44 +03:00
|
|
|
const FilePath path = m_androidConfig.sdkLocation();
|
|
|
|
|
m_androidSummary->setPointValid(SdkPathExistsAndWritableRow,
|
|
|
|
|
path.exists() && path.isWritableDir());
|
2020-05-20 12:51:21 +02:00
|
|
|
m_androidSummary->setPointValid(SdkToolsInstalledRow,
|
|
|
|
|
!m_androidConfig.sdkToolsVersion().isNull());
|
|
|
|
|
m_androidSummary->setPointValid(PlatformToolsInstalledRow,
|
|
|
|
|
m_androidConfig.adbToolPath().exists());
|
|
|
|
|
m_androidSummary->setPointValid(BuildToolsInstalledRow,
|
|
|
|
|
!m_androidConfig.buildToolsVersion().isNull());
|
|
|
|
|
m_androidSummary->setPointValid(SdkManagerSuccessfulRow, m_sdkManager.packageListingSuccessful());
|
2017-09-26 11:24:16 +02:00
|
|
|
// installedSdkPlatforms should not trigger a package reload as validate SDK is only called
|
|
|
|
|
// after AndroidSdkManager::packageReloadFinished.
|
2020-05-20 12:51:21 +02:00
|
|
|
m_androidSummary->setPointValid(PlatformSdkInstalledRow,
|
|
|
|
|
!m_sdkManager.installedSdkPlatforms().isEmpty());
|
2020-07-01 23:42:34 +03:00
|
|
|
m_androidSummary->setPointValid(AllEssentialsInstalledRow,
|
|
|
|
|
m_androidConfig.allEssentialsInstalled(&m_sdkManager));
|
2020-05-20 12:51:21 +02:00
|
|
|
|
2021-09-14 17:33:44 +03:00
|
|
|
const bool sdkToolsOk = m_androidSummary->rowsOk({SdkPathExistsAndWritableRow,
|
2020-05-20 12:51:21 +02:00
|
|
|
SdkToolsInstalledRow,
|
|
|
|
|
SdkManagerSuccessfulRow});
|
|
|
|
|
const bool componentsOk = m_androidSummary->rowsOk({PlatformToolsInstalledRow,
|
|
|
|
|
BuildToolsInstalledRow,
|
|
|
|
|
PlatformSdkInstalledRow,
|
|
|
|
|
AllEssentialsInstalledRow});
|
2019-12-23 16:13:23 +02:00
|
|
|
m_androidConfig.setSdkFullyConfigured(sdkToolsOk && componentsOk);
|
2022-03-26 19:06:17 +02:00
|
|
|
if (sdkToolsOk && !componentsOk)
|
|
|
|
|
m_sdkManagerWidget->installEssentials();
|
2019-12-23 16:13:23 +02:00
|
|
|
|
|
|
|
|
updateNdkList();
|
2020-06-30 12:21:38 +03:00
|
|
|
updateUI();
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2014-02-18 20:20:32 +01:00
|
|
|
void AndroidSettingsWidget::openSDKDownloadUrl()
|
|
|
|
|
{
|
2022-11-24 13:40:33 +01:00
|
|
|
QDesktopServices::openUrl(QUrl::fromUserInput(
|
|
|
|
|
"https://developer.android.com/studio#command-line-tools-only"));
|
2014-02-18 20:20:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::openNDKDownloadUrl()
|
|
|
|
|
{
|
2016-09-22 20:45:00 +02:00
|
|
|
QDesktopServices::openUrl(QUrl::fromUserInput("https://developer.android.com/ndk/downloads/"));
|
2014-02-18 20:20:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidSettingsWidget::openOpenJDKDownloadUrl()
|
|
|
|
|
{
|
2020-06-26 14:37:48 +03:00
|
|
|
if (HostOsInfo::isLinuxHost())
|
|
|
|
|
QDesktopServices::openUrl(QUrl::fromUserInput("https://openjdk.java.net/install/"));
|
|
|
|
|
else
|
|
|
|
|
QDesktopServices::openUrl(QUrl::fromUserInput("https://adoptopenjdk.net/"));
|
2014-02-18 20:20:32 +01:00
|
|
|
}
|
|
|
|
|
|
2020-02-28 19:27:03 +02:00
|
|
|
void AndroidSettingsWidget::downloadOpenSslRepo(const bool silent)
|
|
|
|
|
{
|
2022-07-22 10:04:02 +02:00
|
|
|
const FilePath openSslPath = m_openSslPathChooser->filePath();
|
2022-10-06 17:53:35 +02:00
|
|
|
const QString openSslCloneTitle(Tr::tr("OpenSSL Cloning"));
|
2020-02-28 19:27:03 +02:00
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
if (m_openSslSummary->allRowsOk()) {
|
2020-03-15 01:49:59 +02:00
|
|
|
if (!silent) {
|
2020-02-28 19:27:03 +02:00
|
|
|
QMessageBox::information(this, openSslCloneTitle,
|
2022-10-06 17:53:35 +02:00
|
|
|
Tr::tr("OpenSSL prebuilt libraries repository is already configured."));
|
2020-02-28 19:27:03 +02:00
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDir openSslDir(openSslPath.toString());
|
2020-06-11 15:51:20 +03:00
|
|
|
const bool isEmptyDir = openSslDir.isEmpty(QDir::AllEntries | QDir::NoDotAndDotDot
|
|
|
|
|
| QDir::Hidden | QDir::System);
|
|
|
|
|
if (openSslDir.exists() && !isEmptyDir) {
|
|
|
|
|
QMessageBox::information(
|
|
|
|
|
this,
|
|
|
|
|
openSslCloneTitle,
|
2022-10-06 17:53:35 +02:00
|
|
|
Tr::tr("The selected download path (%1) for OpenSSL already exists and the directory is "
|
|
|
|
|
"not empty. Select a different path or make sure it is an empty directory.")
|
|
|
|
|
.arg(QDir::toNativeSeparators(openSslPath.toString())));
|
2020-06-11 15:51:20 +03:00
|
|
|
return;
|
2020-02-28 19:27:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QProgressDialog *openSslProgressDialog
|
2022-10-06 17:53:35 +02:00
|
|
|
= new QProgressDialog(Tr::tr("Cloning OpenSSL prebuilt libraries..."),
|
|
|
|
|
Tr::tr("Cancel"), 0, 0);
|
2020-06-25 12:11:45 +02:00
|
|
|
openSslProgressDialog->setWindowModality(Qt::ApplicationModal);
|
2020-02-28 19:27:03 +02:00
|
|
|
openSslProgressDialog->setWindowTitle(openSslCloneTitle);
|
|
|
|
|
openSslProgressDialog->setFixedSize(openSslProgressDialog->sizeHint());
|
|
|
|
|
|
2022-03-22 18:51:26 +01:00
|
|
|
const QString openSslRepo("https://github.com/KDAB/android_openssl.git");
|
|
|
|
|
QtcProcess *gitCloner = new QtcProcess(this);
|
|
|
|
|
CommandLine gitCloneCommand("git", {"clone", "--depth=1", openSslRepo, openSslPath.toString()});
|
|
|
|
|
gitCloner->setCommand(gitCloneCommand);
|
|
|
|
|
|
|
|
|
|
qCDebug(androidsettingswidget) << "Cloning OpenSSL repo: " << gitCloneCommand.toUserOutput();
|
|
|
|
|
|
|
|
|
|
connect(openSslProgressDialog, &QProgressDialog::canceled, gitCloner, &QObject::deleteLater);
|
2020-02-28 19:27:03 +02:00
|
|
|
|
2020-06-24 14:25:17 +03:00
|
|
|
auto failDialog = [=](const QString &msgSuffix = {}) {
|
2020-08-10 19:51:03 +02:00
|
|
|
QStringList sl;
|
2022-10-06 17:53:35 +02:00
|
|
|
sl << Tr::tr("OpenSSL prebuilt libraries cloning failed.");
|
2020-08-10 19:51:03 +02:00
|
|
|
if (!msgSuffix.isEmpty())
|
|
|
|
|
sl << msgSuffix;
|
2022-10-06 17:53:35 +02:00
|
|
|
sl << Tr::tr("Opening OpenSSL URL for manual download.");
|
2020-06-24 14:25:17 +03:00
|
|
|
QMessageBox msgBox;
|
2020-08-10 19:51:03 +02:00
|
|
|
msgBox.setText(sl.join(" "));
|
2022-10-06 17:53:35 +02:00
|
|
|
msgBox.addButton(Tr::tr("Cancel"), QMessageBox::RejectRole);
|
|
|
|
|
QAbstractButton *openButton = msgBox.addButton(Tr::tr("Open Download URL"), QMessageBox::ActionRole);
|
2020-06-24 14:25:17 +03:00
|
|
|
msgBox.exec();
|
|
|
|
|
|
|
|
|
|
if (msgBox.clickedButton() == openButton)
|
|
|
|
|
QDesktopServices::openUrl(QUrl::fromUserInput(openSslRepo));
|
|
|
|
|
openButton->deleteLater();
|
|
|
|
|
};
|
2020-02-28 19:27:03 +02:00
|
|
|
|
2022-04-05 17:22:46 +02:00
|
|
|
connect(gitCloner, &QtcProcess::done, this, [=] {
|
2020-06-24 14:25:17 +03:00
|
|
|
openSslProgressDialog->close();
|
2022-04-05 17:22:46 +02:00
|
|
|
if (gitCloner->error() != QProcess::UnknownError) {
|
|
|
|
|
if (gitCloner->error() == QProcess::FailedToStart) {
|
2022-10-06 17:53:35 +02:00
|
|
|
failDialog(Tr::tr("The Git tool might not be installed properly on your system."));
|
2022-04-05 17:22:46 +02:00
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
failDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
validateOpenSsl();
|
2022-07-22 10:04:02 +02:00
|
|
|
m_openSslPathChooser->triggerChanged(); // After cloning, the path exists
|
2022-04-05 17:22:46 +02:00
|
|
|
|
|
|
|
|
if (!openSslProgressDialog->wasCanceled()
|
|
|
|
|
|| gitCloner->result() == ProcessResult::FinishedWithError) {
|
2020-06-24 14:25:17 +03:00
|
|
|
failDialog();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
openSslProgressDialog->show();
|
|
|
|
|
gitCloner->start();
|
2020-02-28 19:27:03 +02:00
|
|
|
}
|
|
|
|
|
|
2013-02-14 15:51:59 +01:00
|
|
|
void AndroidSettingsWidget::createKitToggled()
|
|
|
|
|
{
|
2022-07-22 10:04:02 +02:00
|
|
|
m_androidConfig.setAutomaticKitCreation(m_createKitCheckBox->isChecked());
|
2013-02-14 15:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
2017-09-14 13:29:46 +02:00
|
|
|
void AndroidSettingsWidget::updateUI()
|
|
|
|
|
{
|
2020-05-20 12:51:21 +02:00
|
|
|
const bool androidSetupOk = m_androidSummary->allRowsOk();
|
|
|
|
|
const bool openSslOk = m_openSslSummary->allRowsOk();
|
2017-09-18 13:48:00 +02:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
const QListWidgetItem *currentItem = m_ndkListWidget->currentItem();
|
2020-05-20 12:51:21 +02:00
|
|
|
const FilePath currentNdk = FilePath::fromString(currentItem ? currentItem->text() : "");
|
2022-10-06 17:53:35 +02:00
|
|
|
const QString infoText = Tr::tr("(SDK Version: %1, NDK Version: %2)")
|
2020-05-20 12:51:21 +02:00
|
|
|
.arg(m_androidConfig.sdkToolsVersion().toString())
|
|
|
|
|
.arg(currentNdk.isEmpty() ? "" : m_androidConfig.ndkVersion(currentNdk).toString());
|
|
|
|
|
m_androidSummary->setInfoText(androidSetupOk ? infoText : "");
|
2017-09-18 13:48:00 +02:00
|
|
|
|
2020-05-20 12:51:21 +02:00
|
|
|
m_androidSummary->setSetupOk(androidSetupOk);
|
|
|
|
|
m_openSslSummary->setSetupOk(openSslOk);
|
2021-12-07 21:04:51 +01:00
|
|
|
|
|
|
|
|
// Mark default entry in NDK list widget
|
|
|
|
|
{
|
2022-07-22 10:04:02 +02:00
|
|
|
const QFont font = m_ndkListWidget->font();
|
2021-12-07 21:04:51 +01:00
|
|
|
QFont markedFont = font;
|
|
|
|
|
markedFont.setItalic(true);
|
2022-07-22 10:04:02 +02:00
|
|
|
for (int row = 0; row < m_ndkListWidget->count(); ++row) {
|
|
|
|
|
QListWidgetItem *item = m_ndkListWidget->item(row);
|
2021-12-07 21:04:51 +01:00
|
|
|
const bool isDefaultNdk =
|
|
|
|
|
FilePath::fromUserInput(item->text()) == m_androidConfig.defaultNdk();
|
|
|
|
|
item->setFont(isDefaultNdk ? markedFont : font);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-06 17:53:35 +02:00
|
|
|
m_makeDefaultNdkButton->setText(isDefaultNdkSelected() ? Tr::tr("Unset Default")
|
|
|
|
|
: Tr::tr("Make Default"));
|
2017-09-14 13:29:46 +02:00
|
|
|
}
|
|
|
|
|
|
2019-12-23 16:13:23 +02:00
|
|
|
void AndroidSettingsWidget::downloadSdk()
|
|
|
|
|
{
|
2020-05-18 18:58:32 +03:00
|
|
|
if (m_androidConfig.sdkToolsOk()) {
|
2020-03-16 20:14:56 +02:00
|
|
|
QMessageBox::warning(this, AndroidSdkDownloader::dialogTitle(),
|
2022-10-06 17:53:35 +02:00
|
|
|
Tr::tr("The selected path already has a valid SDK Tools package."));
|
2020-03-16 20:14:56 +02:00
|
|
|
validateSdk();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-06 17:53:35 +02:00
|
|
|
const QString message = Tr::tr("Download and install Android SDK Tools to %1?")
|
2022-07-22 10:04:02 +02:00
|
|
|
.arg("\n\"" + m_sdkLocationPathChooser->filePath().cleanPath().toUserOutput()
|
2022-03-06 16:39:27 +02:00
|
|
|
+ "\"");
|
2019-12-23 16:13:23 +02:00
|
|
|
auto userInput = QMessageBox::information(this, AndroidSdkDownloader::dialogTitle(),
|
|
|
|
|
message, QMessageBox::Yes | QMessageBox::No);
|
2021-12-20 00:09:00 +01:00
|
|
|
if (userInput == QMessageBox::Yes)
|
2020-11-28 15:44:37 +02:00
|
|
|
m_sdkDownloader.downloadAndExtractSdk();
|
2019-12-23 16:13:23 +02:00
|
|
|
}
|
|
|
|
|
|
2020-01-10 12:53:28 +01:00
|
|
|
// AndroidSettingsPage
|
|
|
|
|
|
|
|
|
|
AndroidSettingsPage::AndroidSettingsPage()
|
|
|
|
|
{
|
|
|
|
|
setId(Constants::ANDROID_SETTINGS_ID);
|
2022-10-06 17:53:35 +02:00
|
|
|
setDisplayName(Tr::tr("Android"));
|
2020-01-10 12:53:28 +01:00
|
|
|
setCategory(ProjectExplorer::Constants::DEVICE_SETTINGS_CATEGORY);
|
2020-07-22 13:03:21 +03:00
|
|
|
setWidgetCreator([] { return new AndroidSettingsWidget; });
|
2020-01-10 12:53:28 +01:00
|
|
|
}
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2022-07-22 10:04:02 +02:00
|
|
|
} // Android::Internal
|