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 {
|
namespace QtSupport::Internal {
|
||||||
|
|
||||||
class QtSupportPluginPrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TranslationWizardPageFactory translationWizardPageFactory;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void processRunnerCallback(ProcessData *data)
|
static void processRunnerCallback(ProcessData *data)
|
||||||
{
|
{
|
||||||
FilePath rootPath = FilePath::fromString(data->deviceRoot);
|
FilePath rootPath = FilePath::fromString(data->deviceRoot);
|
||||||
@@ -74,18 +68,9 @@ class QtSupportPlugin final : public ExtensionSystem::IPlugin
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QtSupport.json")
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QtSupport.json")
|
||||||
|
|
||||||
public:
|
|
||||||
~QtSupportPlugin() final
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initialize() final;
|
void initialize() final;
|
||||||
void extensionsInitialized() final;
|
void extensionsInitialized() final;
|
||||||
ShutdownFlag aboutToShutdown() final;
|
ShutdownFlag aboutToShutdown() final;
|
||||||
|
|
||||||
QtSupportPluginPrivate *d = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void QtSupportPlugin::initialize()
|
void QtSupportPlugin::initialize()
|
||||||
@@ -109,6 +94,8 @@ void QtSupportPlugin::initialize()
|
|||||||
setupExternalDesigner(this);
|
setupExternalDesigner(this);
|
||||||
setupExternalLinguist();
|
setupExternalLinguist();
|
||||||
|
|
||||||
|
setupTranslationWizardPage();
|
||||||
|
|
||||||
theProcessRunner() = processRunnerCallback;
|
theProcessRunner() = processRunnerCallback;
|
||||||
|
|
||||||
thePrompter() = [this](const QString &msg, const QStringList &context) -> std::optional<QString> {
|
thePrompter() = [this](const QString &msg, const QStringList &context) -> std::optional<QString> {
|
||||||
@@ -149,8 +136,6 @@ void QtSupportPlugin::initialize()
|
|||||||
|
|
||||||
BuildPropertiesSettings::showQtSettings();
|
BuildPropertiesSettings::showQtSettings();
|
||||||
|
|
||||||
d = new QtSupportPluginPrivate;
|
|
||||||
|
|
||||||
QtVersionManager::initialized();
|
QtVersionManager::initialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
#include "qtsupporttr.h"
|
#include "qtsupporttr.h"
|
||||||
|
|
||||||
#include <projectexplorer/jsonwizard/jsonwizard.h>
|
#include <projectexplorer/jsonwizard/jsonwizard.h>
|
||||||
|
#include <projectexplorer/jsonwizard/jsonwizardpagefactory.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectmanager.h>
|
#include <projectexplorer/projectmanager.h>
|
||||||
|
|
||||||
@@ -30,8 +31,7 @@ using namespace Core;
|
|||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace QtSupport {
|
namespace QtSupport::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class TranslationWizardPage : public WizardPage
|
class TranslationWizardPage : public WizardPage
|
||||||
{
|
{
|
||||||
@@ -54,20 +54,6 @@ private:
|
|||||||
const bool m_isProjectWizard;
|
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)
|
TranslationWizardPage::TranslationWizardPage(const QString &enabledExpr, bool singleFile)
|
||||||
: m_enabledExpr(enabledExpr)
|
: m_enabledExpr(enabledExpr)
|
||||||
, m_isProjectWizard(!singleFile)
|
, m_isProjectWizard(!singleFile)
|
||||||
@@ -144,7 +130,7 @@ void TranslationWizardPage::updateLineEdit()
|
|||||||
auto jsonWizard = static_cast<JsonWizard *>(wizard());
|
auto jsonWizard = static_cast<JsonWizard *>(wizard());
|
||||||
QString projectName = jsonWizard->stringValue("ProjectName");
|
QString projectName = jsonWizard->stringValue("ProjectName");
|
||||||
if (!m_isProjectWizard && projectName.isEmpty()) {
|
if (!m_isProjectWizard && projectName.isEmpty()) {
|
||||||
if (auto project = ProjectExplorer::ProjectManager::startupProject())
|
if (auto project = ProjectManager::startupProject())
|
||||||
projectName = FileUtils::fileSystemFriendlyName(project->displayName());
|
projectName = FileUtils::fileSystemFriendlyName(project->displayName());
|
||||||
else
|
else
|
||||||
projectName = FilePath::fromUserInput(jsonWizard->stringValue("InitialPath")).baseName();
|
projectName = FilePath::fromUserInput(jsonWizard->stringValue("InitialPath")).baseName();
|
||||||
@@ -157,7 +143,31 @@ void TranslationWizardPage::updateLineEdit()
|
|||||||
emit completeChanged();
|
emit completeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
class TranslationWizardPageFactory final : public JsonWizardPageFactory
|
||||||
} // namespace QtSupport
|
{
|
||||||
|
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>
|
#include <translationwizardpage.moc>
|
||||||
|
@@ -3,21 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <projectexplorer/jsonwizard/jsonwizardpagefactory.h>
|
namespace QtSupport::Internal {
|
||||||
|
|
||||||
namespace QtSupport {
|
void setupTranslationWizardPage();
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class TranslationWizardPageFactory : public ProjectExplorer::JsonWizardPageFactory
|
} // QtSupport::Internal
|
||||||
{
|
|
||||||
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
|
|
||||||
|
Reference in New Issue
Block a user