forked from qt-creator/qt-creator
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:
@@ -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");
|
||||
|
||||
@@ -43,7 +43,7 @@ private:
|
||||
bool initialize(const QStringList &arguments, QString *errorString) final;
|
||||
void extensionsInitialized() final {}
|
||||
|
||||
class QmlProjectRunConfigurationFactory *m_rcFactory = nullptr;
|
||||
class QmlProjectPluginPrivate *d = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -459,8 +459,6 @@ QmlProjectRunConfigurationFactory::QmlProjectRunConfigurationFactory()
|
||||
registerRunConfiguration<QmlProjectRunConfiguration>
|
||||
("QmlProjectManager.QmlRunConfiguration.QmlScene");
|
||||
addSupportedProjectType(QmlProjectManager::Constants::QML_PROJECT_ID);
|
||||
|
||||
addRunWorkerFactory<SimpleTargetRunner>(ProjectExplorer::Constants::NORMAL_RUN_MODE);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmlprojectrunconfigurationfactory.h"
|
||||
#include "qmlprojectmanagerconstants.h"
|
||||
#include "qmlproject.h"
|
||||
#include "qmlprojectrunconfiguration.h"
|
||||
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
QmlProjectRunConfigurationFactory::QmlProjectRunConfigurationFactory() :
|
||||
ProjectExplorer::FixedRunConfigurationFactory(QmlProjectRunConfiguration::tr("QML Scene"), false)
|
||||
{
|
||||
registerRunConfiguration<QmlProjectRunConfiguration>(Constants::QML_SCENE_RC_ID);
|
||||
addSupportedProjectType(QmlProjectManager::Constants::QML_PROJECT_ID);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class QmlProjectRunConfigurationFactory : public ProjectExplorer::FixedRunConfigurationFactory
|
||||
{
|
||||
public:
|
||||
QmlProjectRunConfigurationFactory();
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
Reference in New Issue
Block a user