forked from qt-creator/qt-creator
Android: move non UI functions from settingsWidget class
Change-Id: I2d6c6806fc8b219b65d241a0243ee1edab5125a1 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -73,6 +73,7 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QStandardPaths>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
@@ -964,6 +965,27 @@ QStringList AndroidConfig::allEssentials() const
|
|||||||
return allPackages;
|
return allPackages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AndroidConfig::allEssentialsInstalled()
|
||||||
|
{
|
||||||
|
QStringList essentialPkgs(allEssentials());
|
||||||
|
for (const AndroidSdkPackage *pkg :
|
||||||
|
AndroidConfigurations::sdkManager()->installedSdkPackages()) {
|
||||||
|
if (essentialPkgs.contains(pkg->sdkStylePath()))
|
||||||
|
essentialPkgs.removeOne(pkg->sdkStylePath());
|
||||||
|
if (essentialPkgs.isEmpty())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return essentialPkgs.isEmpty() ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AndroidConfig::sdkToolsOk() const
|
||||||
|
{
|
||||||
|
bool exists = sdkLocation().exists();
|
||||||
|
bool writable = sdkLocation().isWritablePath();
|
||||||
|
bool sdkToolsExist = !sdkToolsVersion().isNull();
|
||||||
|
return exists && writable && sdkToolsExist;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList AndroidConfig::essentialsFromQtVersion(const BaseQtVersion &version) const
|
QStringList AndroidConfig::essentialsFromQtVersion(const BaseQtVersion &version) const
|
||||||
{
|
{
|
||||||
QtVersionNumber qtVersion = version.qtVersion();
|
QtVersionNumber qtVersion = version.qtVersion();
|
||||||
@@ -1070,6 +1092,28 @@ void AndroidConfig::setAutomaticKitCreation(bool b)
|
|||||||
m_automaticKitCreation = b;
|
m_automaticKitCreation = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FilePath AndroidConfig::defaultSdkPath()
|
||||||
|
{
|
||||||
|
QString sdkFromEnvVar = QString::fromLocal8Bit(getenv("ANDROID_SDK_ROOT"));
|
||||||
|
if (!sdkFromEnvVar.isEmpty())
|
||||||
|
return Utils::FilePath::fromString(sdkFromEnvVar);
|
||||||
|
|
||||||
|
// Set default path of SDK as used by Android Studio
|
||||||
|
if (Utils::HostOsInfo::isMacHost()) {
|
||||||
|
return Utils::FilePath::fromString(
|
||||||
|
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
|
||||||
|
+ "/../Android/sdk");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Utils::HostOsInfo::isWindowsHost()) {
|
||||||
|
return Utils::FilePath::fromString(
|
||||||
|
QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/Android/sdk");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Utils::FilePath::fromString(
|
||||||
|
QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/Android/Sdk");
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
// AndroidConfigurations
|
// AndroidConfigurations
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
@@ -134,6 +134,8 @@ public:
|
|||||||
QStringList defaultEssentials() const;
|
QStringList defaultEssentials() const;
|
||||||
QStringList essentialsFromQtVersion(const QtSupport::BaseQtVersion &version) const;
|
QStringList essentialsFromQtVersion(const QtSupport::BaseQtVersion &version) const;
|
||||||
QStringList allEssentials() const;
|
QStringList allEssentials() const;
|
||||||
|
bool allEssentialsInstalled();
|
||||||
|
bool sdkToolsOk() const;
|
||||||
|
|
||||||
Utils::FilePath openJDKLocation() const;
|
Utils::FilePath openJDKLocation() const;
|
||||||
void setOpenJDKLocation(const Utils::FilePath &openJDKLocation);
|
void setOpenJDKLocation(const Utils::FilePath &openJDKLocation);
|
||||||
@@ -150,6 +152,7 @@ public:
|
|||||||
bool automaticKitCreation() const;
|
bool automaticKitCreation() const;
|
||||||
void setAutomaticKitCreation(bool b);
|
void setAutomaticKitCreation(bool b);
|
||||||
|
|
||||||
|
static Utils::FilePath defaultSdkPath();
|
||||||
Utils::FilePath adbToolPath() const;
|
Utils::FilePath adbToolPath() const;
|
||||||
Utils::FilePath androidToolPath() const;
|
Utils::FilePath androidToolPath() const;
|
||||||
Utils::FilePath emulatorToolPath() const;
|
Utils::FilePath emulatorToolPath() const;
|
||||||
|
@@ -102,6 +102,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
void apply() final { AndroidConfigurations::setConfig(m_androidConfig); }
|
void apply() final { AndroidConfigurations::setConfig(m_androidConfig); }
|
||||||
|
|
||||||
|
void showEvent(QShowEvent *event) override;
|
||||||
|
|
||||||
void validateJdk();
|
void validateJdk();
|
||||||
void validateNdk();
|
void validateNdk();
|
||||||
void updateNdkList();
|
void updateNdkList();
|
||||||
@@ -127,10 +129,6 @@ private:
|
|||||||
void disableAvdControls();
|
void disableAvdControls();
|
||||||
|
|
||||||
void downloadSdk();
|
void downloadSdk();
|
||||||
bool allEssentialsInstalled();
|
|
||||||
bool sdkToolsOk() const;
|
|
||||||
FilePath getDefaultSdkPath() const;
|
|
||||||
void showEvent(QShowEvent *event) final;
|
|
||||||
void addCustomNdkItem();
|
void addCustomNdkItem();
|
||||||
void validateOpenSsl();
|
void validateOpenSsl();
|
||||||
|
|
||||||
@@ -293,28 +291,6 @@ AvdModel::AvdModel()
|
|||||||
setHeader({tr("AVD Name"), tr("API"), tr("CPU/ABI"), tr("Device type"), tr("Target"), tr("SD-card size")});
|
setHeader({tr("AVD Name"), tr("API"), tr("CPU/ABI"), tr("Device type"), tr("Target"), tr("SD-card size")});
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath AndroidSettingsWidget::getDefaultSdkPath() const
|
|
||||||
{
|
|
||||||
QString sdkFromEnvVar = QString::fromLocal8Bit(getenv("ANDROID_SDK_ROOT"));
|
|
||||||
if (!sdkFromEnvVar.isEmpty())
|
|
||||||
return FilePath::fromString(sdkFromEnvVar);
|
|
||||||
|
|
||||||
// Set default path of SDK as used by Android Studio
|
|
||||||
if (HostOsInfo::isMacHost()) {
|
|
||||||
return FilePath::fromString(
|
|
||||||
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
|
|
||||||
+ "/../Android/sdk");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HostOsInfo::isWindowsHost()) {
|
|
||||||
return FilePath::fromString(
|
|
||||||
QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/Android/sdk");
|
|
||||||
}
|
|
||||||
|
|
||||||
return FilePath::fromString(
|
|
||||||
QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/Android/Sdk");
|
|
||||||
}
|
|
||||||
|
|
||||||
void AndroidSettingsWidget::showEvent(QShowEvent *event)
|
void AndroidSettingsWidget::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
@@ -437,7 +413,7 @@ AndroidSettingsWidget::AndroidSettingsWidget()
|
|||||||
|
|
||||||
FilePath currentSDKPath = m_androidConfig.sdkLocation();
|
FilePath currentSDKPath = m_androidConfig.sdkLocation();
|
||||||
if (currentSDKPath.isEmpty())
|
if (currentSDKPath.isEmpty())
|
||||||
currentSDKPath = getDefaultSdkPath();
|
currentSDKPath = AndroidConfig::defaultSdkPath();
|
||||||
|
|
||||||
m_ui.SDKLocationPathChooser->setFilePath(currentSDKPath);
|
m_ui.SDKLocationPathChooser->setFilePath(currentSDKPath);
|
||||||
m_ui.SDKLocationPathChooser->setPromptDialogTitle(tr("Select Android SDK folder"));
|
m_ui.SDKLocationPathChooser->setPromptDialogTitle(tr("Select Android SDK folder"));
|
||||||
@@ -651,9 +627,7 @@ void AndroidSettingsWidget::validateSdk()
|
|||||||
// after AndroidSdkManager::packageReloadFinished.
|
// after AndroidSdkManager::packageReloadFinished.
|
||||||
m_androidSummary->setPointValid(PlatformSdkInstalledRow,
|
m_androidSummary->setPointValid(PlatformSdkInstalledRow,
|
||||||
!m_sdkManager.installedSdkPlatforms().isEmpty());
|
!m_sdkManager.installedSdkPlatforms().isEmpty());
|
||||||
|
m_androidSummary->setPointValid(AllEssentialsInstalledRow, m_androidConfig.allEssentialsInstalled());
|
||||||
m_androidSummary->setPointValid(AllEssentialsInstalledRow, allEssentialsInstalled());
|
|
||||||
|
|
||||||
updateUI();
|
updateUI();
|
||||||
|
|
||||||
const bool sdkToolsOk = m_androidSummary->rowsOk({SdkPathExistsRow,
|
const bool sdkToolsOk = m_androidSummary->rowsOk({SdkPathExistsRow,
|
||||||
@@ -868,7 +842,7 @@ void AndroidSettingsWidget::updateUI()
|
|||||||
|
|
||||||
void AndroidSettingsWidget::downloadSdk()
|
void AndroidSettingsWidget::downloadSdk()
|
||||||
{
|
{
|
||||||
if (sdkToolsOk()) {
|
if (m_androidConfig.sdkToolsOk()) {
|
||||||
QMessageBox::warning(this, AndroidSdkDownloader::dialogTitle(),
|
QMessageBox::warning(this, AndroidSdkDownloader::dialogTitle(),
|
||||||
tr("The selected path already has a valid SDK Tools package."));
|
tr("The selected path already has a valid SDK Tools package."));
|
||||||
validateSdk();
|
validateSdk();
|
||||||
@@ -888,25 +862,6 @@ void AndroidSettingsWidget::downloadSdk()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidSettingsWidget::allEssentialsInstalled()
|
|
||||||
{
|
|
||||||
QStringList essentialPkgs = m_androidConfig.allEssentials();
|
|
||||||
for (const AndroidSdkPackage *pkg : m_sdkManager.installedSdkPackages()) {
|
|
||||||
essentialPkgs.removeOne(pkg->sdkStylePath());
|
|
||||||
if (essentialPkgs.isEmpty())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return essentialPkgs.isEmpty() ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AndroidSettingsWidget::sdkToolsOk() const
|
|
||||||
{
|
|
||||||
bool exists = m_androidConfig.sdkLocation().exists();
|
|
||||||
bool writable = m_androidConfig.sdkLocation().isWritablePath();
|
|
||||||
bool sdkToolsExist = !m_androidConfig.sdkToolsVersion().isNull();
|
|
||||||
return exists && writable && sdkToolsExist;
|
|
||||||
}
|
|
||||||
|
|
||||||
// AndroidSettingsPage
|
// AndroidSettingsPage
|
||||||
|
|
||||||
AndroidSettingsPage::AndroidSettingsPage()
|
AndroidSettingsPage::AndroidSettingsPage()
|
||||||
|
Reference in New Issue
Block a user