diff --git a/src/plugins/qtsupport/qtsupportplugin.cpp b/src/plugins/qtsupport/qtsupportplugin.cpp index 80e36f7f8ad..da8aee2d3ab 100644 --- a/src/plugins/qtsupport/qtsupportplugin.cpp +++ b/src/plugins/qtsupport/qtsupportplugin.cpp @@ -45,12 +45,6 @@ using namespace ProjectExplorer; namespace QtSupport::Internal { -class QtSupportPluginPrivate -{ -public: - TranslationWizardPageFactory translationWizardPageFactory; -}; - static void processRunnerCallback(ProcessData *data) { FilePath rootPath = FilePath::fromString(data->deviceRoot); @@ -74,18 +68,9 @@ class QtSupportPlugin final : public ExtensionSystem::IPlugin Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QtSupport.json") -public: - ~QtSupportPlugin() final - { - delete d; - } - -private: void initialize() final; void extensionsInitialized() final; ShutdownFlag aboutToShutdown() final; - - QtSupportPluginPrivate *d = nullptr; }; void QtSupportPlugin::initialize() @@ -109,6 +94,8 @@ void QtSupportPlugin::initialize() setupExternalDesigner(this); setupExternalLinguist(); + setupTranslationWizardPage(); + theProcessRunner() = processRunnerCallback; thePrompter() = [this](const QString &msg, const QStringList &context) -> std::optional { @@ -149,8 +136,6 @@ void QtSupportPlugin::initialize() BuildPropertiesSettings::showQtSettings(); - d = new QtSupportPluginPrivate; - QtVersionManager::initialized(); } diff --git a/src/plugins/qtsupport/translationwizardpage.cpp b/src/plugins/qtsupport/translationwizardpage.cpp index 79dde408d0a..70ba4869279 100644 --- a/src/plugins/qtsupport/translationwizardpage.cpp +++ b/src/plugins/qtsupport/translationwizardpage.cpp @@ -6,6 +6,7 @@ #include "qtsupporttr.h" #include +#include #include #include @@ -30,8 +31,7 @@ using namespace Core; using namespace ProjectExplorer; using namespace Utils; -namespace QtSupport { -namespace Internal { +namespace QtSupport::Internal { class TranslationWizardPage : public WizardPage { @@ -54,20 +54,6 @@ private: const bool m_isProjectWizard; }; -TranslationWizardPageFactory::TranslationWizardPageFactory() -{ - setTypeIdsSuffix("QtTranslation"); -} - -WizardPage *TranslationWizardPageFactory::create(JsonWizard *wizard, Id typeId, - const QVariant &data) -{ - Q_UNUSED(wizard) - Q_UNUSED(typeId) - return new TranslationWizardPage(data.toMap().value("enabled").toString(), - data.toMap().value("singleFile").toBool()); -} - TranslationWizardPage::TranslationWizardPage(const QString &enabledExpr, bool singleFile) : m_enabledExpr(enabledExpr) , m_isProjectWizard(!singleFile) @@ -144,7 +130,7 @@ void TranslationWizardPage::updateLineEdit() auto jsonWizard = static_cast(wizard()); QString projectName = jsonWizard->stringValue("ProjectName"); if (!m_isProjectWizard && projectName.isEmpty()) { - if (auto project = ProjectExplorer::ProjectManager::startupProject()) + if (auto project = ProjectManager::startupProject()) projectName = FileUtils::fileSystemFriendlyName(project->displayName()); else projectName = FilePath::fromUserInput(jsonWizard->stringValue("InitialPath")).baseName(); @@ -157,7 +143,31 @@ void TranslationWizardPage::updateLineEdit() emit completeChanged(); } -} // namespace Internal -} // namespace QtSupport +class TranslationWizardPageFactory final : public JsonWizardPageFactory +{ +public: + TranslationWizardPageFactory() + { + setTypeIdsSuffix("QtTranslation"); + } + +private: + WizardPage *create(JsonWizard *wizard, Id typeId, const QVariant &data) final + { + Q_UNUSED(wizard) + Q_UNUSED(typeId) + return new TranslationWizardPage(data.toMap().value("enabled").toString(), + data.toMap().value("singleFile").toBool()); + } + + bool validateData(Id, const QVariant &, QString *) final { return true; } +}; + +void setupTranslationWizardPage() +{ + static TranslationWizardPageFactory theTranslationWizardPageFactory; +} + +} // QtSupport::Internal #include diff --git a/src/plugins/qtsupport/translationwizardpage.h b/src/plugins/qtsupport/translationwizardpage.h index 4aec110ee63..84da56338dd 100644 --- a/src/plugins/qtsupport/translationwizardpage.h +++ b/src/plugins/qtsupport/translationwizardpage.h @@ -3,21 +3,8 @@ #pragma once -#include +namespace QtSupport::Internal { -namespace QtSupport { -namespace Internal { +void setupTranslationWizardPage(); -class TranslationWizardPageFactory : public ProjectExplorer::JsonWizardPageFactory -{ -public: - TranslationWizardPageFactory(); - -private: - Utils::WizardPage *create(ProjectExplorer::JsonWizard *wizard, Utils::Id typeId, - const QVariant &data) override; - bool validateData(Utils::Id, const QVariant &, QString *) override { return true; } -}; - -} // namespace Internal -} // namespace QtSupport +} // QtSupport::Internal