ProjectExplorer: Introduce a SimpleRunWorkerFactory template

... and use in as replacement for RunConfiguration::addRunWorkerFactory.

It is still convenient to have a simple way to set up run worker
factories for the typical "just run for this configuration" case,
but it's even better if it follows the nowadays predominant pattern
of keeping factories in the plugin's pimpl.

Also, it turned out there were two copies of
QmlProjectRunconfigurationFactory code, one is enough.

Change-Id: I0b28c4ea18d0f52165a49f6133dc8687a3b9c7cf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-03-13 12:22:44 +01:00
parent 404b284e8f
commit 1bc10248c0
20 changed files with 50 additions and 128 deletions

View File

@@ -25,12 +25,13 @@
#include "qmlprojectplugin.h"
#include "qmlproject.h"
#include "qmlprojectrunconfigurationfactory.h"
#include "qmlprojectrunconfiguration.h"
#include <coreplugin/fileiconprovider.h>
#include <coreplugin/icore.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/runcontrol.h>
#include <qmljstools/qmljstoolsconstants.h>
@@ -39,16 +40,24 @@ using namespace ProjectExplorer;
namespace QmlProjectManager {
namespace Internal {
class QmlProjectPluginPrivate
{
public:
QmlProjectRunConfigurationFactory runConfigFactory;
SimpleRunWorkerFactory<QmlProjectRunConfiguration, SimpleTargetRunner>
runWorkerFactory{ProjectExplorer::Constants::NORMAL_RUN_MODE};
};
QmlProjectPlugin::~QmlProjectPlugin()
{
delete m_rcFactory;
delete d;
}
bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage)
{
Q_UNUSED(errorMessage)
m_rcFactory = new QmlProjectRunConfigurationFactory;
d = new QmlProjectPluginPrivate;
ProjectManager::registerProjectType<QmlProject>(QmlJSTools::Constants::QMLPROJECT_MIMETYPE);
Core::FileIconProvider::registerIconOverlayForSuffix(":/qmlproject/images/qmlproject.png", "qmlproject");