diff --git a/src/plugins/qmlprofiler/qmlprofiler.pro b/src/plugins/qmlprofiler/qmlprofiler.pro index 0995840d2bc..a1edff0e2c2 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.pro +++ b/src/plugins/qmlprofiler/qmlprofiler.pro @@ -28,7 +28,6 @@ SOURCES += \ qmlprofilerrangemodel.cpp \ qmlprofilerrunconfigurationaspect.cpp \ qmlprofilerruncontrol.cpp \ - qmlprofilerruncontrolfactory.cpp \ qmlprofilersettings.cpp \ qmlprofilerstatemanager.cpp \ qmlprofilerstatewidget.cpp \ @@ -72,7 +71,6 @@ HEADERS += \ qmlprofilerrangemodel.h \ qmlprofilerrunconfigurationaspect.h \ qmlprofilerruncontrol.h \ - qmlprofilerruncontrolfactory.h \ qmlprofilersettings.h \ qmlprofilerstatemanager.h \ qmlprofilerstatewidget.h \ diff --git a/src/plugins/qmlprofiler/qmlprofiler.qbs b/src/plugins/qmlprofiler/qmlprofiler.qbs index b509ac07a36..8bf7b5147b2 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.qbs +++ b/src/plugins/qmlprofiler/qmlprofiler.qbs @@ -45,7 +45,6 @@ QtcPlugin { "qmlprofileroptionspage.cpp", "qmlprofileroptionspage.h", "qmlprofilerplugin.cpp", "qmlprofilerplugin.h", "qmlprofilerrunconfigurationaspect.cpp", "qmlprofilerrunconfigurationaspect.h", - "qmlprofilerruncontrolfactory.cpp", "qmlprofilerruncontrolfactory.h", "qmlprofilerrangemodel.cpp", "qmlprofilerrangemodel.h", "qmlprofilerruncontrol.cpp", "qmlprofilerruncontrol.h", "qmlprofilersettings.cpp", "qmlprofilersettings.h", diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp index 123a84bd17f..3b2585b5e7e 100644 --- a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp @@ -24,7 +24,7 @@ ****************************************************************************/ #include "qmlprofilerplugin.h" -#include "qmlprofilerruncontrolfactory.h" +#include "qmlprofilerrunconfigurationaspect.h" #include "qmlprofileroptionspage.h" #include "qmlprofilertool.h" #include "qmlprofilertimelinemodel.h" @@ -57,15 +57,34 @@ #endif // WITH_TESTS #include + +#include +#include +#include +#include + #include +#include #include +using namespace ProjectExplorer; + namespace QmlProfiler { namespace Internal { 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) { Q_UNUSED(arguments) @@ -80,8 +99,21 @@ void QmlProfilerPlugin::extensionsInitialized() { (void) new QmlProfilerTool(this); - addAutoReleasedObject(new QmlProfilerRunControlFactory()); - addAutoReleasedObject(new Internal::QmlProfilerOptionsPage()); + addAutoReleasedObject(new 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 + (ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, constraint); } ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown() diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp deleted file mode 100644 index 31c1198f679..00000000000 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include - -#include - -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 diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h deleted file mode 100644 index 5df39366737..00000000000 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** 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 - -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