From b6c83df7d96982a18bb61ee9b333cd4122e17087 Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Sun, 6 Mar 2022 03:06:59 +0200 Subject: [PATCH] Android: move SDK Manager to separate dialog Hide the SDK Manager into own dialog which reduces the visible elements on the Android Settings page by default. The dialog will be brought up when installing essential packages for example. Also, the dialog can be opened manually via a new button, which makes it available on demand instead be there in the front all the time, because that SDK Manager UI is needed only when installing packages which doesn't happen often. Change-Id: I09b92ae7b10673ba520da9ffd98d8120e1aaf104 Reviewed-by: Reviewed-by: Alessandro Portale Reviewed-by: Leena Miettinen --- .../android/androidsdkmanagerwidget.cpp | 18 ++++++++-- src/plugins/android/androidsdkmanagerwidget.h | 2 +- .../android/androidsdkmanagerwidget.ui | 15 +++++--- src/plugins/android/androidsettingswidget.cpp | 34 ++----------------- src/plugins/android/androidsettingswidget.ui | 15 +++++--- 5 files changed, 41 insertions(+), 43 deletions(-) diff --git a/src/plugins/android/androidsdkmanagerwidget.cpp b/src/plugins/android/androidsdkmanagerwidget.cpp index be93c03f609..5539f36143b 100644 --- a/src/plugins/android/androidsdkmanagerwidget.cpp +++ b/src/plugins/android/androidsdkmanagerwidget.cpp @@ -68,7 +68,7 @@ private: AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config, AndroidSdkManager *sdkManager, QWidget *parent) : - QWidget(parent), + QDialog(parent), m_androidConfig(config), m_sdkManager(sdkManager), m_sdkModel(new AndroidSdkModel(m_androidConfig, m_sdkManager, this)), @@ -79,6 +79,7 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config, m_ui->sdkLicensebuttonBox->hide(); m_ui->sdkLicenseLabel->hide(); m_ui->viewStack->setCurrentWidget(m_ui->packagesStack); + setModal(true); m_formatter = new Utils::OutputFormatter; m_formatter->setPlainTextEdit(m_ui->outputEdit); @@ -136,6 +137,7 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config, m_ui->expandCheck->setChecked(!text.isEmpty()); }); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &AndroidSdkManagerWidget::close); connect(m_ui->applySelectionButton, &QPushButton::clicked, this, [this]() { onApplyButton(); }); connect(m_ui->cancelButton, &QPushButton::clicked, this, @@ -268,6 +270,9 @@ void AndroidSdkManagerWidget::onApplyButton(const QString &extraMessage) if (messageDlg.exec() == QMessageBox::Cancel) return; + // Open the SDK Manager dialog after accepting to continue with the installation + show(); + switchView(Operations); m_pendingCommand = AndroidSdkManager::UpdatePackage; // User agreed with the selection. Check for licenses. @@ -401,6 +406,8 @@ void AndroidSdkManagerWidget::notifyOperationFinished() QMessageBox::information(this, tr("Android SDK Changes"), tr("Android SDK operations finished."), QMessageBox::Ok); m_ui->operationProgress->setValue(0); + // Once the update/install is done, let's hide the dialog. + hide(); } } @@ -464,10 +471,15 @@ void AndroidSdkManagerWidget::switchView(AndroidSdkManagerWidget::View view) if (m_currentView == PackageListing) m_formatter->clear(); m_currentView = view; - if (m_currentView == PackageListing) + if (m_currentView == PackageListing) { + // We need the buttonBox only in the main listing view, as the license and update + // views already have a cancel button. + m_ui->buttonBox->button(QDialogButtonBox::Ok)->setVisible(true); emit updatingSdkFinished(); - else + } else { + m_ui->buttonBox->button(QDialogButtonBox::Ok)->setVisible(false); emit updatingSdk(); + } if (m_currentView == LicenseWorkflow) emit licenseWorkflowStarted(); diff --git a/src/plugins/android/androidsdkmanagerwidget.h b/src/plugins/android/androidsdkmanagerwidget.h index 5266290b109..f154d2a3a57 100644 --- a/src/plugins/android/androidsdkmanagerwidget.h +++ b/src/plugins/android/androidsdkmanagerwidget.h @@ -65,7 +65,7 @@ private: QFuture m_optionsFuture; }; -class AndroidSdkManagerWidget : public QWidget +class AndroidSdkManagerWidget : public QDialog { Q_OBJECT diff --git a/src/plugins/android/androidsdkmanagerwidget.ui b/src/plugins/android/androidsdkmanagerwidget.ui index ea35571896e..06203ce2a41 100644 --- a/src/plugins/android/androidsdkmanagerwidget.ui +++ b/src/plugins/android/androidsdkmanagerwidget.ui @@ -18,16 +18,16 @@ -1 - 0 + 9 - 0 + 9 - 0 + 9 - 0 + 9 @@ -297,6 +297,13 @@ + + + + QDialogButtonBox::Ok + + + diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp index 4f44cf820b7..58f03d6cb2e 100644 --- a/src/plugins/android/androidsettingswidget.cpp +++ b/src/plugins/android/androidsettingswidget.cpp @@ -304,34 +304,7 @@ bool AndroidSettingsWidget::isDefaultNdkSelected() const AndroidSettingsWidget::AndroidSettingsWidget() { m_ui.setupUi(this); - m_sdkManagerWidget = new AndroidSdkManagerWidget(m_androidConfig, &m_sdkManager, - m_ui.sdkManagerGroupBox); - auto sdkMangerLayout = new QVBoxLayout(m_ui.sdkManagerGroupBox); - sdkMangerLayout->addWidget(m_sdkManagerWidget); - connect(m_sdkManagerWidget, &AndroidSdkManagerWidget::updatingSdk, [this] { - // Disable the top level UI to keep the user from unintentionally interrupting operations - m_ui.androidSettingsGroupBox->setEnabled(false); - m_ui.androidOpenSSLSettingsGroupBox->setEnabled(false); - m_ui.CreateKitCheckBox->setEnabled(false); - m_androidSummary->setState(DetailsWidget::Collapsed); - m_androidProgress->hide(); - }); - connect(m_sdkManagerWidget, &AndroidSdkManagerWidget::updatingSdkFinished, [this] { - m_ui.androidSettingsGroupBox->setEnabled(true); - m_ui.androidOpenSSLSettingsGroupBox->setEnabled(true); - m_ui.CreateKitCheckBox->setEnabled(true); - }); - connect(m_sdkManagerWidget, &AndroidSdkManagerWidget::licenseWorkflowStarted, [this] { - QObject *parentWidget = parent(); - while (parentWidget) { - if (auto scrollArea = qobject_cast(parentWidget)) { - scrollArea->ensureWidgetVisible(m_ui.sdkManagerGroupBox); - break; - } - parentWidget = parentWidget->parent(); - }; - }); - + m_sdkManagerWidget = new AndroidSdkManagerWidget(m_androidConfig, &m_sdkManager, this); QMap androidValidationPoints; androidValidationPoints[SdkPathExistsAndWritableRow] = tr("Android SDK path exists and is writable."); @@ -446,6 +419,8 @@ AndroidSettingsWidget::AndroidSettingsWidget() m_androidSummary->setInProgressText("Retrieving packages information"); m_androidProgress->show(); }); + connect(m_ui.sdkManagerToolButton, &QAbstractButton::clicked, + this, [this]() { m_sdkManagerWidget->exec(); }); connect(m_ui.sdkToolsAutoDownloadButton, &QAbstractButton::clicked, this, &AndroidSettingsWidget::downloadSdk); connect(&m_sdkDownloader, &AndroidSdkDownloader::sdkDownloaderError, this, [this](const QString &error) { @@ -668,12 +643,9 @@ void AndroidSettingsWidget::createKitToggled() void AndroidSettingsWidget::updateUI() { - const bool sdkToolsOk = m_androidSummary->rowsOk({SdkPathExistsAndWritableRow, SdkToolsInstalledRow}); const bool androidSetupOk = m_androidSummary->allRowsOk(); const bool openSslOk = m_openSslSummary->allRowsOk(); - m_ui.sdkManagerGroupBox->setEnabled(sdkToolsOk); - const QListWidgetItem *currentItem = m_ui.ndkListWidget->currentItem(); const FilePath currentNdk = FilePath::fromString(currentItem ? currentItem->text() : ""); const QString infoText = tr("(SDK Version: %1, NDK Version: %2)") diff --git a/src/plugins/android/androidsettingswidget.ui b/src/plugins/android/androidsettingswidget.ui index fcfdc63a1d2..a4d3df36453 100644 --- a/src/plugins/android/androidsettingswidget.ui +++ b/src/plugins/android/androidsettingswidget.ui @@ -158,6 +158,13 @@ + + + + SDK Manager + + + @@ -234,11 +241,11 @@ - - - SDK Manager + + + Qt::Vertical - +