forked from qt-creator/qt-creator
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:
@@ -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();
|
||||
|
@@ -65,7 +65,7 @@ private:
|
||||
QFuture<QString> m_optionsFuture;
|
||||
};
|
||||
|
||||
class AndroidSdkManagerWidget : public QWidget
|
||||
class AndroidSdkManagerWidget : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@@ -18,16 +18,16 @@
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="viewStack">
|
||||
@@ -297,6 +297,13 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
@@ -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<QScrollArea *>(parentWidget)) {
|
||||
scrollArea->ensureWidgetVisible(m_ui.sdkManagerGroupBox);
|
||||
break;
|
||||
}
|
||||
parentWidget = parentWidget->parent();
|
||||
};
|
||||
});
|
||||
|
||||
m_sdkManagerWidget = new AndroidSdkManagerWidget(m_androidConfig, &m_sdkManager, this);
|
||||
QMap<int, QString> 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)")
|
||||
|
@@ -158,6 +158,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QLabel" name="ndkComboBoxLabel">
|
||||
<property name="text">
|
||||
@@ -234,11 +241,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="sdkManagerGroupBox">
|
||||
<property name="title">
|
||||
<string>SDK Manager</string>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
Reference in New Issue
Block a user