ProjectExplorer: Let KitAspect pre-select a settings page item

... when the "Manage" button is clicked.
Make use of this in the device settings page.

Fixes: QTCREATORBUG-25077
Change-Id: I1173a72d4c538c839c3e8df278a698b74bd6fca2
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2024-01-19 10:49:08 +01:00
parent 3fc1b5f57b
commit f9f43f7492
4 changed files with 11 additions and 2 deletions

View File

@@ -190,7 +190,13 @@ DeviceSettingsWidget::DeviceSettingsWidget()
addButton->setEnabled(hasDeviceFactories);
int lastIndex = ICore::settings()->value(LastDeviceIndexKey, 0).toInt();
int lastIndex = -1;
if (const Id deviceToSelect = preselectedOptionsPageItem(Constants::DEVICE_SETTINGS_PAGE_ID);
deviceToSelect.isValid()) {
lastIndex = m_deviceManagerModel->indexForId(deviceToSelect);
}
if (lastIndex == -1)
lastIndex = ICore::settings()->value(LastDeviceIndexKey, 0).toInt();
if (lastIndex == -1)
lastIndex = 0;
if (lastIndex < m_configurationComboBox->count())

View File

@@ -897,6 +897,8 @@ private:
void makeReadOnly() override { m_comboBox->setEnabled(false); }
Id settingsPageItemToPreselect() const override { return DeviceKitAspect::deviceId(m_kit); }
void refresh() override
{
m_model->setTypeFilter(DeviceTypeKitAspect::deviceTypeId(m_kit));

View File

@@ -796,7 +796,7 @@ void KitAspect::addToLayout(Layouting::LayoutItem &parentItem)
if (m_managingPageId.isValid()) {
m_manageButton = createSubWidget<QPushButton>(msgManage());
connect(m_manageButton, &QPushButton::clicked, [this] {
Core::ICore::showOptionsDialog(m_managingPageId);
Core::ICore::showOptionsDialog(m_managingPageId, settingsPageItemToPreselect());
});
parentItem.addItem(m_manageButton);
}

View File

@@ -125,6 +125,7 @@ public:
protected:
virtual void makeReadOnly() {}
virtual void addToLayoutImpl(Layouting::LayoutItem &parentItem) = 0;
virtual Utils::Id settingsPageItemToPreselect() const { return {}; }
Kit *m_kit;
const KitAspectFactory *m_factory;