Squish: Use new setup pattern for SquishNavigationWidgetFactory

Change-Id: I44ac6a84f68b9b1fb22d9906921647e13d78de19
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2024-01-09 16:07:57 +01:00
parent 3f1a381c58
commit 910126867d
3 changed files with 28 additions and 31 deletions

View File

@@ -15,6 +15,7 @@
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/find/itemviewfind.h> #include <coreplugin/find/itemviewfind.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/inavigationwidgetfactory.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/checkablemessagebox.h> #include <utils/checkablemessagebox.h>
@@ -30,12 +31,12 @@ namespace Squish::Internal {
const int defaultSectionSize = 17; const int defaultSectionSize = 17;
class SquishNavigationWidget : public QWidget class SquishNavigationWidget final : public QWidget
{ {
public: public:
explicit SquishNavigationWidget(QWidget *parent = nullptr); SquishNavigationWidget();
~SquishNavigationWidget() override;
void contextMenuEvent(QContextMenuEvent *event) override; void contextMenuEvent(QContextMenuEvent *event) final;
static QList<QToolButton *> createToolButtons(); static QList<QToolButton *> createToolButtons();
private: private:
@@ -54,9 +55,7 @@ private:
SquishTestTreeSortModel *m_sortModel; SquishTestTreeSortModel *m_sortModel;
}; };
SquishNavigationWidget::SquishNavigationWidget()
SquishNavigationWidget::SquishNavigationWidget(QWidget *parent)
: QWidget(parent)
{ {
setWindowTitle(Tr::tr("Squish")); setWindowTitle(Tr::tr("Squish"));
m_view = new SquishTestTreeView(this); m_view = new SquishTestTreeView(this);
@@ -105,8 +104,6 @@ SquishNavigationWidget::SquishNavigationWidget(QWidget *parent)
}); });
} }
SquishNavigationWidget::~SquishNavigationWidget() {}
void SquishNavigationWidget::contextMenuEvent(QContextMenuEvent *event) void SquishNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
{ {
QMenu menu; QMenu menu;
@@ -356,20 +353,29 @@ void SquishNavigationWidget::onNewTestCaseTriggered(const QModelIndex &index)
m_view->edit(m_sortModel->mapFromSource(added)); m_view->edit(m_sortModel->mapFromSource(added));
} }
SquishNavigationWidgetFactory::SquishNavigationWidgetFactory() class SquishNavigationWidgetFactory final : public Core::INavigationWidgetFactory
{ {
setDisplayName(Tr::tr("Squish")); public:
setId(Squish::Constants::SQUISH_ID); SquishNavigationWidgetFactory()
setPriority(777); {
} setDisplayName(Tr::tr("Squish"));
setId(Squish::Constants::SQUISH_ID);
setPriority(777);
}
Core::NavigationView SquishNavigationWidgetFactory::createWidget() Core::NavigationView createWidget() final
{
SquishNavigationWidget *squishNavigationWidget = new SquishNavigationWidget;
Core::NavigationView view;
view.widget = squishNavigationWidget;
view.dockToolBarWidgets = squishNavigationWidget->createToolButtons();
return view;
}
};
void setupSquishNavigationWidgetFactory()
{ {
SquishNavigationWidget *squishNavigationWidget = new SquishNavigationWidget; static SquishNavigationWidgetFactory squishNavigationWidgetFactory;
Core::NavigationView view;
view.widget = squishNavigationWidget;
view.dockToolBarWidgets = squishNavigationWidget->createToolButtons();
return view;
} }
} // Squish::Internal } // Squish::Internal

View File

@@ -3,17 +3,8 @@
#pragma once #pragma once
#include <coreplugin/inavigationwidgetfactory.h>
namespace Squish::Internal { namespace Squish::Internal {
class SquishNavigationWidgetFactory : public Core::INavigationWidgetFactory void setupSquishNavigationWidgetFactory();
{
public:
SquishNavigationWidgetFactory();
private:
Core::NavigationView createWidget() override;
};
} // Squish::Internal } // Squish::Internal

View File

@@ -39,7 +39,6 @@ public:
bool initializeGlobalScripts(); bool initializeGlobalScripts();
SquishNavigationWidgetFactory m_navigationWidgetFactory;
ObjectsMapEditorFactory m_objectsMapEditorFactory; ObjectsMapEditorFactory m_objectsMapEditorFactory;
SquishOutputPane m_outputPane; SquishOutputPane m_outputPane;
SquishTools m_squishTools; SquishTools m_squishTools;
@@ -109,6 +108,7 @@ private:
d.reset(new SquishPluginPrivate); d.reset(new SquishPluginPrivate);
setupSquishWizardPages(); setupSquishWizardPages();
setupSquishNavigationWidgetFactory();
ProjectExplorer::JsonWizardFactory::addWizardPath(":/squish/wizard/"); ProjectExplorer::JsonWizardFactory::addWizardPath(":/squish/wizard/");
} }