forked from qt-creator/qt-creator
check if Android sdk folder is writable
Fixes: QTCREATORBUG-21943 Change-Id: Ic20ed4c24c567b0b08269b7ad07014eb4248b214 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -768,6 +768,13 @@ bool FilePath::exists() const
|
|||||||
return !isEmpty() && QFileInfo::exists(m_data);
|
return !isEmpty() && QFileInfo::exists(m_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \returns a bool indicating whether a path is writable.
|
||||||
|
bool FilePath::isWritablePath() const
|
||||||
|
{
|
||||||
|
const QFileInfo fi{m_data};
|
||||||
|
return exists() && fi.isDir() && fi.isWritable();
|
||||||
|
}
|
||||||
|
|
||||||
/// Find the parent directory of a given directory.
|
/// Find the parent directory of a given directory.
|
||||||
|
|
||||||
/// Returns an empty FilePath if the current directory is already
|
/// Returns an empty FilePath if the current directory is already
|
||||||
|
@@ -82,6 +82,7 @@ public:
|
|||||||
|
|
||||||
QString fileName(int pathComponents = 0) const;
|
QString fileName(int pathComponents = 0) const;
|
||||||
bool exists() const;
|
bool exists() const;
|
||||||
|
bool isWritablePath() const;
|
||||||
|
|
||||||
FilePath parentDir() const;
|
FilePath parentDir() const;
|
||||||
|
|
||||||
|
@@ -72,6 +72,7 @@ enum JavaValidation {
|
|||||||
|
|
||||||
enum AndroidValidation {
|
enum AndroidValidation {
|
||||||
SdkPathExistsRow,
|
SdkPathExistsRow,
|
||||||
|
SdkPathWritableRow,
|
||||||
SdkToolsInstalledRow,
|
SdkToolsInstalledRow,
|
||||||
PlatformToolsInstalledRow,
|
PlatformToolsInstalledRow,
|
||||||
BuildToolsInstalledRow,
|
BuildToolsInstalledRow,
|
||||||
@@ -255,6 +256,7 @@ AndroidSettingsWidget::AndroidSettingsWidget(QWidget *parent)
|
|||||||
|
|
||||||
QMap<int, QString> androidValidationPoints;
|
QMap<int, QString> androidValidationPoints;
|
||||||
androidValidationPoints[SdkPathExistsRow] = tr("Android SDK path exists.");
|
androidValidationPoints[SdkPathExistsRow] = tr("Android SDK path exists.");
|
||||||
|
androidValidationPoints[SdkPathWritableRow] = tr("Android SDK path writable.");
|
||||||
androidValidationPoints[SdkToolsInstalledRow] = tr("SDK tools installed.");
|
androidValidationPoints[SdkToolsInstalledRow] = tr("SDK tools installed.");
|
||||||
androidValidationPoints[PlatformToolsInstalledRow] = tr("Platform tools installed.");
|
androidValidationPoints[PlatformToolsInstalledRow] = tr("Platform tools installed.");
|
||||||
androidValidationPoints[BuildToolsInstalledRow] = tr("Build tools installed.");
|
androidValidationPoints[BuildToolsInstalledRow] = tr("Build tools installed.");
|
||||||
@@ -415,6 +417,7 @@ void AndroidSettingsWidget::validateSdk()
|
|||||||
{
|
{
|
||||||
auto summaryWidget = static_cast<SummaryWidget *>(m_ui->androidDetailsWidget->widget());
|
auto summaryWidget = static_cast<SummaryWidget *>(m_ui->androidDetailsWidget->widget());
|
||||||
summaryWidget->setPointValid(SdkPathExistsRow, m_androidConfig.sdkLocation().exists());
|
summaryWidget->setPointValid(SdkPathExistsRow, m_androidConfig.sdkLocation().exists());
|
||||||
|
summaryWidget->setPointValid(SdkPathWritableRow, m_androidConfig.sdkLocation().isWritablePath());
|
||||||
summaryWidget->setPointValid(SdkToolsInstalledRow,
|
summaryWidget->setPointValid(SdkToolsInstalledRow,
|
||||||
!m_androidConfig.sdkToolsVersion().isNull());
|
!m_androidConfig.sdkToolsVersion().isNull());
|
||||||
summaryWidget->setPointValid(PlatformToolsInstalledRow,
|
summaryWidget->setPointValid(PlatformToolsInstalledRow,
|
||||||
@@ -427,7 +430,7 @@ void AndroidSettingsWidget::validateSdk()
|
|||||||
summaryWidget->setPointValid(PlatformSdkInstalledRow,
|
summaryWidget->setPointValid(PlatformSdkInstalledRow,
|
||||||
!m_sdkManager->installedSdkPlatforms().isEmpty());
|
!m_sdkManager->installedSdkPlatforms().isEmpty());
|
||||||
updateUI();
|
updateUI();
|
||||||
bool sdkToolsOk = summaryWidget->rowsOk({SdkPathExistsRow, SdkToolsInstalledRow});
|
bool sdkToolsOk = summaryWidget->rowsOk({SdkPathExistsRow, SdkPathWritableRow, SdkToolsInstalledRow});
|
||||||
bool componentsOk = summaryWidget->rowsOk({PlatformToolsInstalledRow,
|
bool componentsOk = summaryWidget->rowsOk({PlatformToolsInstalledRow,
|
||||||
BuildToolsInstalledRow,
|
BuildToolsInstalledRow,
|
||||||
PlatformSdkInstalledRow});
|
PlatformSdkInstalledRow});
|
||||||
@@ -528,7 +531,7 @@ void AndroidSettingsWidget::updateUI()
|
|||||||
auto javaSummaryWidget = static_cast<SummaryWidget *>(m_ui->javaDetailsWidget->widget());
|
auto javaSummaryWidget = static_cast<SummaryWidget *>(m_ui->javaDetailsWidget->widget());
|
||||||
auto androidSummaryWidget = static_cast<SummaryWidget *>(m_ui->androidDetailsWidget->widget());
|
auto androidSummaryWidget = static_cast<SummaryWidget *>(m_ui->androidDetailsWidget->widget());
|
||||||
bool javaSetupOk = javaSummaryWidget->allRowsOk();
|
bool javaSetupOk = javaSummaryWidget->allRowsOk();
|
||||||
bool sdkToolsOk = androidSummaryWidget->rowsOk({SdkPathExistsRow, SdkToolsInstalledRow});
|
bool sdkToolsOk = androidSummaryWidget->rowsOk({SdkPathExistsRow, SdkPathWritableRow, SdkToolsInstalledRow});
|
||||||
bool androidSetupOk = androidSummaryWidget->allRowsOk();
|
bool androidSetupOk = androidSummaryWidget->allRowsOk();
|
||||||
|
|
||||||
m_ui->avdManagerTab->setEnabled(javaSetupOk && androidSetupOk);
|
m_ui->avdManagerTab->setEnabled(javaSetupOk && androidSetupOk);
|
||||||
|
Reference in New Issue
Block a user