Commit 611f373d authored by hjk's avatar hjk

QmlProfiler: Partially dissolve QmlProfilerRunControlFactory

Change-Id: Id902cfa6387bcb6ad96da0cd36f3114f795afd99
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent c8affd6e
...@@ -28,7 +28,6 @@ SOURCES += \ ...@@ -28,7 +28,6 @@ SOURCES += \
qmlprofilerrangemodel.cpp \ qmlprofilerrangemodel.cpp \
qmlprofilerrunconfigurationaspect.cpp \ qmlprofilerrunconfigurationaspect.cpp \
qmlprofilerruncontrol.cpp \ qmlprofilerruncontrol.cpp \
qmlprofilerruncontrolfactory.cpp \
qmlprofilersettings.cpp \ qmlprofilersettings.cpp \
qmlprofilerstatemanager.cpp \ qmlprofilerstatemanager.cpp \
qmlprofilerstatewidget.cpp \ qmlprofilerstatewidget.cpp \
...@@ -72,7 +71,6 @@ HEADERS += \ ...@@ -72,7 +71,6 @@ HEADERS += \
qmlprofilerrangemodel.h \ qmlprofilerrangemodel.h \
qmlprofilerrunconfigurationaspect.h \ qmlprofilerrunconfigurationaspect.h \
qmlprofilerruncontrol.h \ qmlprofilerruncontrol.h \
qmlprofilerruncontrolfactory.h \
qmlprofilersettings.h \ qmlprofilersettings.h \
qmlprofilerstatemanager.h \ qmlprofilerstatemanager.h \
qmlprofilerstatewidget.h \ qmlprofilerstatewidget.h \
......
...@@ -45,7 +45,6 @@ QtcPlugin { ...@@ -45,7 +45,6 @@ QtcPlugin {
"qmlprofileroptionspage.cpp", "qmlprofileroptionspage.h", "qmlprofileroptionspage.cpp", "qmlprofileroptionspage.h",
"qmlprofilerplugin.cpp", "qmlprofilerplugin.h", "qmlprofilerplugin.cpp", "qmlprofilerplugin.h",
"qmlprofilerrunconfigurationaspect.cpp", "qmlprofilerrunconfigurationaspect.h", "qmlprofilerrunconfigurationaspect.cpp", "qmlprofilerrunconfigurationaspect.h",
"qmlprofilerruncontrolfactory.cpp", "qmlprofilerruncontrolfactory.h",
"qmlprofilerrangemodel.cpp", "qmlprofilerrangemodel.h", "qmlprofilerrangemodel.cpp", "qmlprofilerrangemodel.h",
"qmlprofilerruncontrol.cpp", "qmlprofilerruncontrol.h", "qmlprofilerruncontrol.cpp", "qmlprofilerruncontrol.h",
"qmlprofilersettings.cpp", "qmlprofilersettings.h", "qmlprofilersettings.cpp", "qmlprofilersettings.h",
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
****************************************************************************/ ****************************************************************************/
#include "qmlprofilerplugin.h" #include "qmlprofilerplugin.h"
#include "qmlprofilerruncontrolfactory.h" #include "qmlprofilerrunconfigurationaspect.h"
#include "qmlprofileroptionspage.h" #include "qmlprofileroptionspage.h"
#include "qmlprofilertool.h" #include "qmlprofilertool.h"
#include "qmlprofilertimelinemodel.h" #include "qmlprofilertimelinemodel.h"
...@@ -57,15 +57,34 @@ ...@@ -57,15 +57,34 @@
#endif // WITH_TESTS #endif // WITH_TESTS
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <projectexplorer/environmentaspect.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/target.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QtPlugin> #include <QtPlugin>
using namespace ProjectExplorer;
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
Q_GLOBAL_STATIC(QmlProfilerSettings, qmlProfilerGlobalSettings) Q_GLOBAL_STATIC(QmlProfilerSettings, qmlProfilerGlobalSettings)
class QmlProfilerRunControlFactory : public IRunControlFactory
{
public:
IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc) override
{
return new QmlProfilerRunConfigurationAspect(rc);
}
};
bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString) bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString)
{ {
Q_UNUSED(arguments) Q_UNUSED(arguments)
...@@ -80,8 +99,21 @@ void QmlProfilerPlugin::extensionsInitialized() ...@@ -80,8 +99,21 @@ void QmlProfilerPlugin::extensionsInitialized()
{ {
(void) new QmlProfilerTool(this); (void) new QmlProfilerTool(this);
addAutoReleasedObject(new QmlProfilerRunControlFactory()); addAutoReleasedObject(new QmlProfilerOptionsPage);
addAutoReleasedObject(new Internal::QmlProfilerOptionsPage()); addAutoReleasedObject(new QmlProfilerRunControlFactory);
auto constraint = [](RunConfiguration *runConfiguration) {
Target *target = runConfiguration ? runConfiguration->target() : nullptr;
Kit *kit = target ? target->kit() : nullptr;
return DeviceTypeKitInformation::deviceTypeId(kit)
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
};
RunControl::registerWorkerCreator(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE,
[this](RunControl *runControl) { return new QmlProfilerRunner(runControl); });
RunControl::registerWorker<LocalQmlProfilerSupport>
(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, constraint);
} }
ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown() ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown()
......
/****************************************************************************
**
** Copyright (C) 2016 Kläralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
** 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 "qmlprofilerruncontrolfactory.h"
#include "qmlprofilerruncontrol.h"
#include "qmlprofilerrunconfigurationaspect.h"
#include <projectexplorer/environmentaspect.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h>
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
namespace QmlProfiler {
namespace Internal {
static bool isLocal(RunConfiguration *runConfiguration)
{
Target *target = runConfiguration ? runConfiguration->target() : 0;
Kit *kit = target ? target->kit() : 0;
return DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
}
QmlProfilerRunControlFactory::QmlProfilerRunControlFactory(QObject *parent) :
IRunControlFactory(parent)
{
RunControl::registerWorkerCreator(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE,
[this](RunControl *runControl) { return new QmlProfilerRunner(runControl); });
}
bool QmlProfilerRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const
{
return mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE && isLocal(runConfiguration);
}
RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *)
{
auto runControl = new RunControl(runConfiguration, mode);
(void) new LocalQmlProfilerSupport(runControl);
return runControl;
}
ProjectExplorer::IRunConfigurationAspect *
QmlProfilerRunControlFactory::createRunConfigurationAspect(ProjectExplorer::RunConfiguration *rc)
{
return new QmlProfilerRunConfigurationAspect(rc);
}
} // namespace Internal
} // namespace QmlProfiler
/****************************************************************************
**
** Copyright (C) 2016 Kläralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
** 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 QmlProfiler {
namespace Internal {
class QmlProfilerRunControlFactory : public ProjectExplorer::IRunControlFactory
{
Q_OBJECT
public:
typedef ProjectExplorer::RunConfiguration RunConfiguration;
explicit QmlProfilerRunControlFactory(QObject *parent = 0);
// IRunControlFactory implementation
bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const override;
ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration, Core::Id mode,
QString *errorMessage) override;
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect(
ProjectExplorer::RunConfiguration *rc) override;
};
} // namespace Internal
} // namespace QmlProfiler
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment