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>
This commit is contained in:
Jarek Kobus
2024-05-03 16:57:24 +02:00
parent f62dea66f6
commit 679a51d12b
2 changed files with 7 additions and 14 deletions

View File

@@ -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

View File

@@ -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)