ProjectExplorer: Make "Manage..." kits button work again

When configuring a newly opened or created project you are
able to press a 'Manage...' button that brings up the
options page of the kits. Was broken with the rework done
on the global object pool.

Change-Id: I87d91351c5769655c1192431a53784de1bca77aa
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2018-04-24 15:07:02 +02:00
parent ef9c5e47bb
commit f8937daf71
4 changed files with 16 additions and 9 deletions

View File

@@ -235,8 +235,11 @@ QModelIndex KitOptionsPageWidget::currentIndex() const
// KitOptionsPage: // KitOptionsPage:
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
static KitOptionsPage *theKitOptionsPage = nullptr;
KitOptionsPage::KitOptionsPage() KitOptionsPage::KitOptionsPage()
{ {
theKitOptionsPage = this;
static const Utils::Icon categoryIcon({{":/projectexplorer/images/mode_project_mask.png", static const Utils::Icon categoryIcon({{":/projectexplorer/images/mode_project_mask.png",
Utils::Theme::PanelTextColorDark}}, Utils::Theme::PanelTextColorDark}},
Utils::Icon::Tint); Utils::Icon::Tint);
@@ -283,4 +286,9 @@ void KitOptionsPage::showKit(Kit *k)
m_widget->m_kitsView->scrollTo(index); m_widget->m_kitsView->scrollTo(index);
} }
KitOptionsPage *KitOptionsPage::instance()
{
return theKitOptionsPage;
}
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -53,6 +53,7 @@ public:
void finish() override; void finish() override;
void showKit(Kit *k); void showKit(Kit *k);
static KitOptionsPage *instance();
private: private:
QPointer<Internal::KitOptionsPageWidget> m_widget; QPointer<Internal::KitOptionsPageWidget> m_widget;

View File

@@ -42,8 +42,6 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/idocument.h> #include <coreplugin/idocument.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/basetreeview.h> #include <utils/basetreeview.h>
#include <utils/navigationtreeview.h> #include <utils/navigationtreeview.h>
@@ -531,8 +529,8 @@ public:
void handleManageKits() void handleManageKits()
{ {
if (ProjectItem *projectItem = m_projectsModel.rootItem()->childAt(0)) { if (ProjectItem *projectItem = m_projectsModel.rootItem()->childAt(0)) {
if (KitOptionsPage *page = ExtensionSystem::PluginManager::getObject<KitOptionsPage>()) if (auto kitPage = KitOptionsPage::instance())
page->showKit(KitManager::kit(Id::fromSetting(projectItem->data(0, KitIdRole)))); kitPage->showKit(KitManager::kit(Id::fromSetting(projectItem->data(0, KitIdRole))));
} }
ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, ICore::mainWindow()); ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, ICore::mainWindow());
} }

View File

@@ -34,7 +34,6 @@
#include "kitoptionspage.h" #include "kitoptionspage.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/detailsbutton.h> #include <utils/detailsbutton.h>
@@ -201,12 +200,13 @@ void TargetSetupWidget::targetCheckBoxToggled(bool b)
void TargetSetupWidget::manageKit() void TargetSetupWidget::manageKit()
{ {
KitOptionsPage *page = ExtensionSystem::PluginManager::getObject<KitOptionsPage>(); if (!m_kit)
if (!page || !m_kit)
return; return;
page->showKit(m_kit); if (auto kitPage = KitOptionsPage::instance()) {
Core::ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, parentWidget()); kitPage->showKit(m_kit);
Core::ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, parentWidget());
}
} }
void TargetSetupWidget::setProjectPath(const QString &projectPath) void TargetSetupWidget::setProjectPath(const QString &projectPath)