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: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
Assam Boudjelthia
2022-03-06 03:06:59 +02:00
parent 20c0d93f7d
commit b6c83df7d9
5 changed files with 41 additions and 43 deletions

View File

@@ -68,7 +68,7 @@ private:
AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config, AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config,
AndroidSdkManager *sdkManager, QWidget *parent) : AndroidSdkManager *sdkManager, QWidget *parent) :
QWidget(parent), QDialog(parent),
m_androidConfig(config), m_androidConfig(config),
m_sdkManager(sdkManager), m_sdkManager(sdkManager),
m_sdkModel(new AndroidSdkModel(m_androidConfig, m_sdkManager, this)), m_sdkModel(new AndroidSdkModel(m_androidConfig, m_sdkManager, this)),
@@ -79,6 +79,7 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config,
m_ui->sdkLicensebuttonBox->hide(); m_ui->sdkLicensebuttonBox->hide();
m_ui->sdkLicenseLabel->hide(); m_ui->sdkLicenseLabel->hide();
m_ui->viewStack->setCurrentWidget(m_ui->packagesStack); m_ui->viewStack->setCurrentWidget(m_ui->packagesStack);
setModal(true);
m_formatter = new Utils::OutputFormatter; m_formatter = new Utils::OutputFormatter;
m_formatter->setPlainTextEdit(m_ui->outputEdit); m_formatter->setPlainTextEdit(m_ui->outputEdit);
@@ -136,6 +137,7 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config,
m_ui->expandCheck->setChecked(!text.isEmpty()); m_ui->expandCheck->setChecked(!text.isEmpty());
}); });
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &AndroidSdkManagerWidget::close);
connect(m_ui->applySelectionButton, &QPushButton::clicked, connect(m_ui->applySelectionButton, &QPushButton::clicked,
this, [this]() { onApplyButton(); }); this, [this]() { onApplyButton(); });
connect(m_ui->cancelButton, &QPushButton::clicked, this, connect(m_ui->cancelButton, &QPushButton::clicked, this,
@@ -268,6 +270,9 @@ void AndroidSdkManagerWidget::onApplyButton(const QString &extraMessage)
if (messageDlg.exec() == QMessageBox::Cancel) if (messageDlg.exec() == QMessageBox::Cancel)
return; return;
// Open the SDK Manager dialog after accepting to continue with the installation
show();
switchView(Operations); switchView(Operations);
m_pendingCommand = AndroidSdkManager::UpdatePackage; m_pendingCommand = AndroidSdkManager::UpdatePackage;
// User agreed with the selection. Check for licenses. // User agreed with the selection. Check for licenses.
@@ -401,6 +406,8 @@ void AndroidSdkManagerWidget::notifyOperationFinished()
QMessageBox::information(this, tr("Android SDK Changes"), QMessageBox::information(this, tr("Android SDK Changes"),
tr("Android SDK operations finished."), QMessageBox::Ok); tr("Android SDK operations finished."), QMessageBox::Ok);
m_ui->operationProgress->setValue(0); 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) if (m_currentView == PackageListing)
m_formatter->clear(); m_formatter->clear();
m_currentView = view; 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(); emit updatingSdkFinished();
else } else {
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setVisible(false);
emit updatingSdk(); emit updatingSdk();
}
if (m_currentView == LicenseWorkflow) if (m_currentView == LicenseWorkflow)
emit licenseWorkflowStarted(); emit licenseWorkflowStarted();

View File

@@ -65,7 +65,7 @@ private:
QFuture<QString> m_optionsFuture; QFuture<QString> m_optionsFuture;
}; };
class AndroidSdkManagerWidget : public QWidget class AndroidSdkManagerWidget : public QDialog
{ {
Q_OBJECT Q_OBJECT

View File

@@ -18,16 +18,16 @@
<number>-1</number> <number>-1</number>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>9</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>9</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>9</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>9</number>
</property> </property>
<item> <item>
<widget class="QStackedWidget" name="viewStack"> <widget class="QStackedWidget" name="viewStack">
@@ -297,6 +297,13 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>

View File

@@ -304,34 +304,7 @@ bool AndroidSettingsWidget::isDefaultNdkSelected() const
AndroidSettingsWidget::AndroidSettingsWidget() AndroidSettingsWidget::AndroidSettingsWidget()
{ {
m_ui.setupUi(this); m_ui.setupUi(this);
m_sdkManagerWidget = new AndroidSdkManagerWidget(m_androidConfig, &m_sdkManager, m_sdkManagerWidget = new AndroidSdkManagerWidget(m_androidConfig, &m_sdkManager, this);
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<QScrollArea *>(parentWidget)) {
scrollArea->ensureWidgetVisible(m_ui.sdkManagerGroupBox);
break;
}
parentWidget = parentWidget->parent();
};
});
QMap<int, QString> androidValidationPoints; QMap<int, QString> androidValidationPoints;
androidValidationPoints[SdkPathExistsAndWritableRow] = androidValidationPoints[SdkPathExistsAndWritableRow] =
tr("Android SDK path exists and is writable."); tr("Android SDK path exists and is writable.");
@@ -446,6 +419,8 @@ AndroidSettingsWidget::AndroidSettingsWidget()
m_androidSummary->setInProgressText("Retrieving packages information"); m_androidSummary->setInProgressText("Retrieving packages information");
m_androidProgress->show(); m_androidProgress->show();
}); });
connect(m_ui.sdkManagerToolButton, &QAbstractButton::clicked,
this, [this]() { m_sdkManagerWidget->exec(); });
connect(m_ui.sdkToolsAutoDownloadButton, &QAbstractButton::clicked, connect(m_ui.sdkToolsAutoDownloadButton, &QAbstractButton::clicked,
this, &AndroidSettingsWidget::downloadSdk); this, &AndroidSettingsWidget::downloadSdk);
connect(&m_sdkDownloader, &AndroidSdkDownloader::sdkDownloaderError, this, [this](const QString &error) { connect(&m_sdkDownloader, &AndroidSdkDownloader::sdkDownloaderError, this, [this](const QString &error) {
@@ -668,12 +643,9 @@ void AndroidSettingsWidget::createKitToggled()
void AndroidSettingsWidget::updateUI() void AndroidSettingsWidget::updateUI()
{ {
const bool sdkToolsOk = m_androidSummary->rowsOk({SdkPathExistsAndWritableRow, SdkToolsInstalledRow});
const bool androidSetupOk = m_androidSummary->allRowsOk(); const bool androidSetupOk = m_androidSummary->allRowsOk();
const bool openSslOk = m_openSslSummary->allRowsOk(); const bool openSslOk = m_openSslSummary->allRowsOk();
m_ui.sdkManagerGroupBox->setEnabled(sdkToolsOk);
const QListWidgetItem *currentItem = m_ui.ndkListWidget->currentItem(); const QListWidgetItem *currentItem = m_ui.ndkListWidget->currentItem();
const FilePath currentNdk = FilePath::fromString(currentItem ? currentItem->text() : ""); const FilePath currentNdk = FilePath::fromString(currentItem ? currentItem->text() : "");
const QString infoText = tr("(SDK Version: %1, NDK Version: %2)") const QString infoText = tr("(SDK Version: %1, NDK Version: %2)")

View File

@@ -158,6 +158,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2" colspan="4">
<widget class="QPushButton" name="sdkManagerToolButton">
<property name="text">
<string>SDK Manager</string>
</property>
</widget>
</item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="ndkComboBoxLabel"> <widget class="QLabel" name="ndkComboBoxLabel">
<property name="text"> <property name="text">
@@ -234,11 +241,11 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="sdkManagerGroupBox"> <spacer name="verticalSpacer">
<property name="title"> <property name="orientation">
<string>SDK Manager</string> <enum>Qt::Vertical</enum>
</property> </property>
</widget> </spacer>
</item> </item>
</layout> </layout>
</widget> </widget>