GenericProject: Use new setup pattern for ProjectFilesFactory

Change-Id: If5d64a8d6b09fbd3ceaea1736ce74ba2c837a456
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-11-20 15:18:28 +01:00
parent 181b362fcf
commit 96dcd41d41
3 changed files with 28 additions and 33 deletions

View File

@@ -6,33 +6,36 @@
#include <coreplugin/coreplugintr.h> #include <coreplugin/coreplugintr.h>
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <texteditor/textdocument.h>
#include <texteditor/texteditoractionhandler.h>
#include <QCoreApplication> #include <texteditor/textdocument.h>
#include <texteditor/texteditor.h>
#include <texteditor/texteditoractionhandler.h>
using namespace TextEditor; using namespace TextEditor;
namespace GenericProjectManager { namespace GenericProjectManager::Internal {
namespace Internal {
// class ProjectFilesFactory : public TextEditorFactory
// ProjectFilesFactory
//
ProjectFilesFactory::ProjectFilesFactory()
{ {
setId(Constants::FILES_EDITOR_ID); public:
setDisplayName(::Core::Tr::tr(".files Editor")); ProjectFilesFactory()
addMimeType("application/vnd.qtcreator.generic.files"); {
addMimeType("application/vnd.qtcreator.generic.includes"); setId(Constants::FILES_EDITOR_ID);
addMimeType("application/vnd.qtcreator.generic.config"); setDisplayName(::Core::Tr::tr(".files Editor"));
addMimeType("application/vnd.qtcreator.generic.cxxflags"); addMimeType("application/vnd.qtcreator.generic.files");
addMimeType("application/vnd.qtcreator.generic.cflags"); addMimeType("application/vnd.qtcreator.generic.includes");
addMimeType("application/vnd.qtcreator.generic.config");
addMimeType("application/vnd.qtcreator.generic.cxxflags");
addMimeType("application/vnd.qtcreator.generic.cflags");
setDocumentCreator([]() { return new TextDocument(Constants::FILES_EDITOR_ID); }); setDocumentCreator([]() { return new TextDocument(Constants::FILES_EDITOR_ID); });
setEditorActionHandlers(TextEditorActionHandler::None); setEditorActionHandlers(TextEditorActionHandler::None);
}
};
void setupGenericProjectFiles()
{
static ProjectFilesFactory theProjectFilesFactory;
} }
} // namespace Internal } // GenericProjectManager::Internal
} // namespace GenericProjectManager

View File

@@ -3,16 +3,8 @@
#pragma once #pragma once
#include <texteditor/texteditor.h> namespace GenericProjectManager::Internal {
namespace GenericProjectManager { void setupGenericProjectFiles();
namespace Internal {
class ProjectFilesFactory : public TextEditor::TextEditorFactory } // GenericProjectManager::Internal
{
public:
ProjectFilesFactory();
};
} // namespace Internal
} // namespace GenericProjectManager

View File

@@ -35,7 +35,6 @@ class GenericProjectPluginPrivate : public QObject
public: public:
GenericProjectPluginPrivate(); GenericProjectPluginPrivate();
ProjectFilesFactory projectFilesFactory;
GenericMakeStepFactory makeStepFactory; GenericMakeStepFactory makeStepFactory;
GenericBuildConfigurationFactory buildConfigFactory; GenericBuildConfigurationFactory buildConfigFactory;
}; };
@@ -45,6 +44,7 @@ GenericProjectPluginPrivate::GenericProjectPluginPrivate()
ProjectManager::registerProjectType<GenericProject>(Constants::GENERICMIMETYPE); ProjectManager::registerProjectType<GenericProject>(Constants::GENERICMIMETYPE);
setupGenericProjectWizard(); setupGenericProjectWizard();
setupGenericProjectFiles();
ActionBuilder editAction(this, "GenericProjectManager.EditFiles"); ActionBuilder editAction(this, "GenericProjectManager.EditFiles");
editAction.setContext(Constants::GENERICPROJECT_ID); editAction.setContext(Constants::GENERICPROJECT_ID);