diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2024-05-03 16:57:24 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2024-05-05 19:58:29 +0000 |
commit | 679a51d12b657fdda0f27af905ace5f3718de5cb (patch) | |
tree | 027ee2c5ca2620671e5bf69de3e60b8e328dbe65 /src | |
parent | f62dea66f6f9bee1f60f6566f786d03868116a69 (diff) |
Android: Create and execute AndroidSdkManagerWidget on demand
There is no need to always instantiate it inside
AndroidSettingsWidget.
Force data refresh on model construction.
Change-Id: I1adcd933e8684df9819d3dbd9cef2d615cff84a8
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/android/androidsdkmodel.cpp | 3 | ||||
-rw-r--r-- | src/plugins/android/androidsettingswidget.cpp | 18 |
2 files changed, 7 insertions, 14 deletions
diff --git a/src/plugins/android/androidsdkmodel.cpp b/src/plugins/android/androidsdkmodel.cpp index 985e4a649a..c2b3ffdba3 100644 --- a/src/plugins/android/androidsdkmodel.cpp +++ b/src/plugins/android/androidsdkmodel.cpp @@ -30,6 +30,9 @@ AndroidSdkModel::AndroidSdkModel(AndroidSdkManager *sdkManager, QObject *parent) refreshData(); endResetModel(); }); + beginResetModel(); + refreshData(); + endResetModel(); } QVariant AndroidSdkModel::headerData(int section, Qt::Orientation orientation, int role) const diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp index b6a1df3a60..f9d382ba5e 100644 --- a/src/plugins/android/androidsettingswidget.cpp +++ b/src/plugins/android/androidsettingswidget.cpp @@ -162,7 +162,6 @@ class AndroidSettingsWidget final : public Core::IOptionsPageWidget public: // Todo: This would be so much simpler if it just used Utils::PathChooser!!! AndroidSettingsWidget(); - ~AndroidSettingsWidget() final; private: void showEvent(QShowEvent *event) override; @@ -184,8 +183,6 @@ private: bool isDefaultNdkSelected() const; void validateOpenSsl(); - AndroidSdkManagerWidget *m_sdkManagerWidget = nullptr; - AndroidSdkManager m_sdkManager; Tasking::TaskTreeRunner m_sdkDownloader; bool m_isInitialReloadDone = false; @@ -341,9 +338,6 @@ AndroidSettingsWidget::AndroidSettingsWidget() "If the automatic download fails, Qt Creator proposes to open the download URL\n" "in the system's browser for manual download.")); - - m_sdkManagerWidget = new AndroidSdkManagerWidget(&m_sdkManager, this); - const QMap<int, QString> androidValidationPoints = { { JavaPathExistsAndWritableRow, Tr::tr("JDK path exists and is writable.") }, { SdkPathExistsAndWritableRow, Tr::tr("Android SDK path exists and is writable.") }, @@ -500,8 +494,10 @@ AndroidSettingsWidget::AndroidSettingsWidget() m_androidSummary->setInProgressText("Retrieving packages information"); m_androidProgress->show(); }); - connect(sdkManagerToolButton, &QAbstractButton::clicked, - this, [this] { m_sdkManagerWidget->exec(); }); + connect(sdkManagerToolButton, &QAbstractButton::clicked, this, [this] { + AndroidSdkManagerWidget dialog(&m_sdkManager, this); + dialog.exec(); + }); connect(sdkToolsAutoDownloadButton, &QAbstractButton::clicked, this, &AndroidSettingsWidget::downloadSdk); connect(&m_sdkDownloader, &Tasking::TaskTreeRunner::done, this, [this](Tasking::DoneWith result) { @@ -526,12 +522,6 @@ AndroidSettingsWidget::AndroidSettingsWidget() setOnApply([] { AndroidConfigurations::setConfig(androidConfig()); }); } -AndroidSettingsWidget::~AndroidSettingsWidget() -{ - // Deleting m_sdkManagerWidget will cancel all ongoing and pending sdkmanager operations. - delete m_sdkManagerWidget; -} - void AndroidSettingsWidget::showEvent(QShowEvent *event) { Q_UNUSED(event) |