forked from qt-creator/qt-creator
QtSupport: Use setup function for TranslationWizardPageFactory
And remove the plugin pimpl which is not needed anymore. Change-Id: Ib23405b09a389d1b1c99548969fe542461139c36 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -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<QString> {
|
||||
@@ -149,8 +136,6 @@ void QtSupportPlugin::initialize()
|
||||
|
||||
BuildPropertiesSettings::showQtSettings();
|
||||
|
||||
d = new QtSupportPluginPrivate;
|
||||
|
||||
QtVersionManager::initialized();
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include "qtsupporttr.h"
|
||||
|
||||
#include <projectexplorer/jsonwizard/jsonwizard.h>
|
||||
#include <projectexplorer/jsonwizard/jsonwizardpagefactory.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
|
||||
@@ -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<JsonWizard *>(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 <translationwizardpage.moc>
|
||||
|
@@ -3,21 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/jsonwizard/jsonwizardpagefactory.h>
|
||||
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
|
||||
|
Reference in New Issue
Block a user