diff --git a/src/plugins/android/androidsdkmanagerwidget.cpp b/src/plugins/android/androidsdkmanagerwidget.cpp index f4f00dd8404..08f05f0e9e7 100644 --- a/src/plugins/android/androidsdkmanagerwidget.cpp +++ b/src/plugins/android/androidsdkmanagerwidget.cpp @@ -15,6 +15,7 @@ #include #include +#include > #include #include #include @@ -65,9 +66,6 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config, auto updateInstalledButton = new QPushButton(Tr::tr("Update Installed")); - auto applySelectionButton = new QPushButton(Tr::tr("Apply")); - applySelectionButton->setEnabled(false); - auto channelCheckbox = new QComboBox; channelCheckbox->addItem(Tr::tr("Default")); channelCheckbox->addItem(Tr::tr("Stable")); @@ -90,8 +88,6 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config, auto expandCheck = new QCheckBox(Tr::tr("Expand All")); m_outputStack = new QWidget; - auto cancelButton = new QPushButton(Tr::tr("Cancel")); - m_operationProgress = new QProgressBar(m_outputStack); m_outputEdit = new QPlainTextEdit(m_outputStack); @@ -107,7 +103,8 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config, m_sdkLicenseButtonBox->hide(); m_buttonBox = new QDialogButtonBox(this); - m_buttonBox->setStandardButtons(QDialogButtonBox::Ok); + m_buttonBox->setStandardButtons(QDialogButtonBox::Apply | QDialogButtonBox::Cancel); + m_buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); m_viewStack = new QStackedWidget(this); m_viewStack->addWidget(m_packagesStack); @@ -131,7 +128,6 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config, Span(2, packagesView), Column { updateInstalledButton, - applySelectionButton, st, Group { title(Tr::tr("Show Packages")), @@ -152,7 +148,6 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config, m_outputEdit, Row { m_sdkLicenseLabel, m_sdkLicenseButtonBox }, m_operationProgress, - Row { st, cancelButton } }.attachTo(m_outputStack, WithoutMargins); Column { @@ -160,14 +155,15 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config, m_buttonBox }.attachTo(this); - connect(m_sdkModel, &AndroidSdkModel::dataChanged, this, [this, applySelectionButton] { + connect(m_sdkModel, &AndroidSdkModel::dataChanged, this, [this] { if (m_viewStack->currentWidget() == m_packagesStack) - applySelectionButton->setEnabled(!m_sdkModel->userSelection().isEmpty()); + m_buttonBox->button(QDialogButtonBox::Apply) + ->setEnabled(!m_sdkModel->userSelection().isEmpty()); }); connect(m_sdkModel, &AndroidSdkModel::modelAboutToBeReset, this, - [this, applySelectionButton, expandCheck] { - applySelectionButton->setEnabled(false); + [this, expandCheck] { + m_buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); expandCheck->setChecked(false); cancelPendingOperations(); switchView(PackageListing); @@ -209,10 +205,11 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config, expandCheck->setChecked(!text.isEmpty()); }); - connect(m_buttonBox, &QDialogButtonBox::accepted, this, &AndroidSdkManagerWidget::close); - connect(applySelectionButton, &QPushButton::clicked, this, [this] { onApplyButton(); }); - connect(cancelButton, &QPushButton::clicked, this, - &AndroidSdkManagerWidget::onCancel); + connect(m_buttonBox->button(QDialogButtonBox::Apply), &QAbstractButton::clicked, this, [this] { + onApplyButton(); + }); + connect(m_buttonBox, &QDialogButtonBox::rejected, this, &AndroidSdkManagerWidget::onCancel); + connect(optionsButton, &QPushButton::clicked, this, &AndroidSdkManagerWidget::onSdkManagerOptions); connect(m_sdkLicenseButtonBox, &QDialogButtonBox::accepted, this, [this] { @@ -369,6 +366,7 @@ void AndroidSdkManagerWidget::onUpdatePackages() void AndroidSdkManagerWidget::onCancel() { cancelPendingOperations(); + close(); } void AndroidSdkManagerWidget::onOperationResult(int index) @@ -542,10 +540,10 @@ void AndroidSdkManagerWidget::switchView(AndroidSdkManagerWidget::View view) 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_buttonBox->button(QDialogButtonBox::Ok)->setVisible(true); + m_buttonBox->button(QDialogButtonBox::Apply)->setVisible(true); emit updatingSdkFinished(); } else { - m_buttonBox->button(QDialogButtonBox::Ok)->setVisible(false); + m_buttonBox->button(QDialogButtonBox::Apply)->setVisible(false); emit updatingSdk(); }