forked from qt-creator/qt-creator
Designer: Partially pimpl and remove used of global object pool
Change-Id: I88f43678fb07d00501e7b5c04e992acee292d7fe Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -56,31 +56,35 @@
|
|||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QtPlugin>
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Designer::Internal;
|
|
||||||
using namespace Designer::Constants;
|
using namespace Designer::Constants;
|
||||||
|
|
||||||
FormEditorPlugin::FormEditorPlugin()
|
namespace Designer {
|
||||||
: m_actionSwitchSource(new QAction(tr("Switch Source/Form"), this))
|
namespace Internal {
|
||||||
|
|
||||||
|
class FormEditorPluginPrivate
|
||||||
{
|
{
|
||||||
}
|
public:
|
||||||
|
QAction actionSwitchSource{FormEditorPlugin::tr("Switch Source/Form"), nullptr};
|
||||||
|
|
||||||
|
FormEditorFactory formEditorFactory;
|
||||||
|
SettingsPageProvider settingsPageProvider;
|
||||||
|
QtDesignerFormClassCodeGenerator formClassCodeGenerator;
|
||||||
|
};
|
||||||
|
|
||||||
FormEditorPlugin::~FormEditorPlugin()
|
FormEditorPlugin::~FormEditorPlugin()
|
||||||
{
|
{
|
||||||
FormEditorW::deleteInstance();
|
FormEditorW::deleteInstance();
|
||||||
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// INHERITED FROM ExtensionSystem::Plugin
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////
|
|
||||||
bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
|
bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
|
||||||
{
|
{
|
||||||
Q_UNUSED(arguments)
|
Q_UNUSED(arguments)
|
||||||
|
|
||||||
|
d = new FormEditorPluginPrivate;
|
||||||
|
|
||||||
#ifdef CPP_ENABLED
|
#ifdef CPP_ENABLED
|
||||||
IWizardFactory::registerFactoryCreator(
|
IWizardFactory::registerFactoryCreator(
|
||||||
[]() -> QList<IWizardFactory *> {
|
[]() -> QList<IWizardFactory *> {
|
||||||
@@ -98,9 +102,7 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ProjectExplorer::JsonWizardFactory::registerPageFactory(new Internal::FormPageFactory);
|
ProjectExplorer::JsonWizardFactory::registerPageFactory(new Internal::FormPageFactory);
|
||||||
addAutoReleasedObject(new FormEditorFactory);
|
|
||||||
addAutoReleasedObject(new SettingsPageProvider);
|
|
||||||
addAutoReleasedObject(new QtDesignerFormClassCodeGenerator);
|
|
||||||
// Ensure that loading designer translations is done before FormEditorW is instantiated
|
// Ensure that loading designer translations is done before FormEditorW is instantiated
|
||||||
const QString locale = ICore::userInterfaceLanguage();
|
const QString locale = ICore::userInterfaceLanguage();
|
||||||
if (!locale.isEmpty()) {
|
if (!locale.isEmpty()) {
|
||||||
@@ -125,9 +127,9 @@ void FormEditorPlugin::extensionsInitialized()
|
|||||||
mformtools->menu()->setTitle(tr("For&m Editor"));
|
mformtools->menu()->setTitle(tr("For&m Editor"));
|
||||||
mtools->addMenu(mformtools);
|
mtools->addMenu(mformtools);
|
||||||
|
|
||||||
connect(m_actionSwitchSource, &QAction::triggered, this, &FormEditorPlugin::switchSourceForm);
|
connect(&d->actionSwitchSource, &QAction::triggered, this, &FormEditorPlugin::switchSourceForm);
|
||||||
Context context(C_FORMEDITOR, Core::Constants::C_EDITORMANAGER);
|
Context context(C_FORMEDITOR, Core::Constants::C_EDITORMANAGER);
|
||||||
Command *cmd = ActionManager::registerAction(m_actionSwitchSource,
|
Command *cmd = ActionManager::registerAction(&d->actionSwitchSource,
|
||||||
"FormEditor.FormSwitchSource", context);
|
"FormEditor.FormSwitchSource", context);
|
||||||
cmd->setDefaultKeySequence(tr("Shift+F4"));
|
cmd->setDefaultKeySequence(tr("Shift+F4"));
|
||||||
mformtools->addAction(cmd, Core::Constants::G_DEFAULT_THREE);
|
mformtools->addAction(cmd, Core::Constants::G_DEFAULT_THREE);
|
||||||
@@ -189,3 +191,6 @@ void FormEditorPlugin::switchSourceForm()
|
|||||||
if (!fileToOpen.isEmpty())
|
if (!fileToOpen.isEmpty())
|
||||||
EditorManager::openEditor(fileToOpen);
|
EditorManager::openEditor(fileToOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // Internal
|
||||||
|
} // Designer
|
||||||
|
@@ -27,10 +27,6 @@
|
|||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QAction;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Designer {
|
namespace Designer {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -40,13 +36,9 @@ class FormEditorPlugin : public ExtensionSystem::IPlugin
|
|||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Designer.json")
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Designer.json")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FormEditorPlugin();
|
FormEditorPlugin() = default;
|
||||||
~FormEditorPlugin() override;
|
~FormEditorPlugin() override;
|
||||||
|
|
||||||
//Plugin
|
|
||||||
bool initialize(const QStringList &arguments, QString *errorMessage = nullptr) override;
|
|
||||||
void extensionsInitialized() override;
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
private slots:
|
private slots:
|
||||||
void test_gotoslot();
|
void test_gotoslot();
|
||||||
@@ -54,10 +46,13 @@ private slots:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool initialize(const QStringList &arguments, QString *errorMessage = nullptr) override;
|
||||||
|
void extensionsInitialized() override;
|
||||||
|
|
||||||
void switchSourceForm();
|
void switchSourceForm();
|
||||||
void initializeTemplates();
|
void initializeTemplates();
|
||||||
|
|
||||||
QAction *m_actionSwitchSource = nullptr;
|
class FormEditorPluginPrivate *d = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include <cpptools/abstracteditorsupport.h>
|
#include <cpptools/abstracteditorsupport.h>
|
||||||
#include <qtsupport/codegenerator.h>
|
#include <qtsupport/codegenerator.h>
|
||||||
#include <qtsupport/codegensettings.h>
|
#include <qtsupport/codegensettings.h>
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
@@ -208,9 +209,14 @@ bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParamete
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QtDesignerFormClassCodeGenerator::QtDesignerFormClassCodeGenerator(QObject *parent) :
|
QtDesignerFormClassCodeGenerator::QtDesignerFormClassCodeGenerator()
|
||||||
QObject(parent)
|
|
||||||
{
|
{
|
||||||
|
ExtensionSystem::PluginManager::addObject(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
QtDesignerFormClassCodeGenerator::~QtDesignerFormClassCodeGenerator()
|
||||||
|
{
|
||||||
|
ExtensionSystem::PluginManager::removeObject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant QtDesignerFormClassCodeGenerator::generateFormClassCode(const FormClassWizardParameters ¶meters)
|
QVariant QtDesignerFormClassCodeGenerator::generateFormClassCode(const FormClassWizardParameters ¶meters)
|
||||||
|
@@ -29,10 +29,6 @@
|
|||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QSettings;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Designer {
|
namespace Designer {
|
||||||
class FormClassWizardParameters;
|
class FormClassWizardParameters;
|
||||||
|
|
||||||
@@ -42,7 +38,8 @@ class QtDesignerFormClassCodeGenerator : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit QtDesignerFormClassCodeGenerator(QObject *parent = nullptr);
|
QtDesignerFormClassCodeGenerator();
|
||||||
|
~QtDesignerFormClassCodeGenerator();
|
||||||
|
|
||||||
static bool generateCpp(const FormClassWizardParameters ¶meters,
|
static bool generateCpp(const FormClassWizardParameters ¶meters,
|
||||||
QString *header, QString *source, int indentation = 4);
|
QString *header, QString *source, int indentation = 4);
|
||||||
|
Reference in New Issue
Block a user