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 <QMenu>
|
||||
#include <QTranslator>
|
||||
#include <QtPlugin>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Designer::Internal;
|
||||
using namespace Designer::Constants;
|
||||
|
||||
FormEditorPlugin::FormEditorPlugin()
|
||||
: m_actionSwitchSource(new QAction(tr("Switch Source/Form"), this))
|
||||
namespace Designer {
|
||||
namespace Internal {
|
||||
|
||||
class FormEditorPluginPrivate
|
||||
{
|
||||
}
|
||||
public:
|
||||
QAction actionSwitchSource{FormEditorPlugin::tr("Switch Source/Form"), nullptr};
|
||||
|
||||
FormEditorFactory formEditorFactory;
|
||||
SettingsPageProvider settingsPageProvider;
|
||||
QtDesignerFormClassCodeGenerator formClassCodeGenerator;
|
||||
};
|
||||
|
||||
FormEditorPlugin::~FormEditorPlugin()
|
||||
{
|
||||
FormEditorW::deleteInstance();
|
||||
delete d;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
// INHERITED FROM ExtensionSystem::Plugin
|
||||
//
|
||||
////////////////////////////////////////////////////
|
||||
bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
|
||||
d = new FormEditorPluginPrivate;
|
||||
|
||||
#ifdef CPP_ENABLED
|
||||
IWizardFactory::registerFactoryCreator(
|
||||
[]() -> QList<IWizardFactory *> {
|
||||
@@ -98,9 +102,7 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
#endif
|
||||
|
||||
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
|
||||
const QString locale = ICore::userInterfaceLanguage();
|
||||
if (!locale.isEmpty()) {
|
||||
@@ -125,9 +127,9 @@ void FormEditorPlugin::extensionsInitialized()
|
||||
mformtools->menu()->setTitle(tr("For&m Editor"));
|
||||
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);
|
||||
Command *cmd = ActionManager::registerAction(m_actionSwitchSource,
|
||||
Command *cmd = ActionManager::registerAction(&d->actionSwitchSource,
|
||||
"FormEditor.FormSwitchSource", context);
|
||||
cmd->setDefaultKeySequence(tr("Shift+F4"));
|
||||
mformtools->addAction(cmd, Core::Constants::G_DEFAULT_THREE);
|
||||
@@ -189,3 +191,6 @@ void FormEditorPlugin::switchSourceForm()
|
||||
if (!fileToOpen.isEmpty())
|
||||
EditorManager::openEditor(fileToOpen);
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // Designer
|
||||
|
@@ -27,10 +27,6 @@
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Designer {
|
||||
namespace Internal {
|
||||
|
||||
@@ -40,13 +36,9 @@ class FormEditorPlugin : public ExtensionSystem::IPlugin
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Designer.json")
|
||||
|
||||
public:
|
||||
FormEditorPlugin();
|
||||
FormEditorPlugin() = default;
|
||||
~FormEditorPlugin() override;
|
||||
|
||||
//Plugin
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage = nullptr) override;
|
||||
void extensionsInitialized() override;
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
private slots:
|
||||
void test_gotoslot();
|
||||
@@ -54,10 +46,13 @@ private slots:
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage = nullptr) override;
|
||||
void extensionsInitialized() override;
|
||||
|
||||
void switchSourceForm();
|
||||
void initializeTemplates();
|
||||
|
||||
QAction *m_actionSwitchSource = nullptr;
|
||||
class FormEditorPluginPrivate *d = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include <cpptools/abstracteditorsupport.h>
|
||||
#include <qtsupport/codegenerator.h>
|
||||
#include <qtsupport/codegensettings.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QTextStream>
|
||||
#include <QSettings>
|
||||
@@ -208,9 +209,14 @@ bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParamete
|
||||
return true;
|
||||
}
|
||||
|
||||
QtDesignerFormClassCodeGenerator::QtDesignerFormClassCodeGenerator(QObject *parent) :
|
||||
QObject(parent)
|
||||
QtDesignerFormClassCodeGenerator::QtDesignerFormClassCodeGenerator()
|
||||
{
|
||||
ExtensionSystem::PluginManager::addObject(this);
|
||||
}
|
||||
|
||||
QtDesignerFormClassCodeGenerator::~QtDesignerFormClassCodeGenerator()
|
||||
{
|
||||
ExtensionSystem::PluginManager::removeObject(this);
|
||||
}
|
||||
|
||||
QVariant QtDesignerFormClassCodeGenerator::generateFormClassCode(const FormClassWizardParameters ¶meters)
|
||||
|
@@ -29,10 +29,6 @@
|
||||
#include <QVariant>
|
||||
#include <QObject>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Designer {
|
||||
class FormClassWizardParameters;
|
||||
|
||||
@@ -42,7 +38,8 @@ class QtDesignerFormClassCodeGenerator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QtDesignerFormClassCodeGenerator(QObject *parent = nullptr);
|
||||
QtDesignerFormClassCodeGenerator();
|
||||
~QtDesignerFormClassCodeGenerator();
|
||||
|
||||
static bool generateCpp(const FormClassWizardParameters ¶meters,
|
||||
QString *header, QString *source, int indentation = 4);
|
||||
|
Reference in New Issue
Block a user