Commit 82f8cb70 authored by hjk's avatar hjk

WinRT: Dissolve RunControlFactory

Less code, and it's what most other targets do nowadays.

Change-Id: I2cf55d1a32ad10427ce2508536d03bca8921b451
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
parent 20b6ccd2
......@@ -24,21 +24,28 @@
****************************************************************************/
#include "winrtplugin.h"
#include "winrtconstants.h"
#include "winrtrunfactories.h"
#include "winrtdevice.h"
#include "winrtdevicefactory.h"
#include "winrtdeployconfiguration.h"
#include "winrtqtversionfactory.h"
#include "winrtrunconfiguration.h"
#include "winrtruncontrol.h"
#include "winrtdebugsupport.h"
#include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h>
#include <QtPlugin>
#include <QSysInfo>
using ExtensionSystem::PluginManager;
using ProjectExplorer::DeviceManager;
using namespace ProjectExplorer;
namespace WinRt {
namespace Internal {
......@@ -54,10 +61,33 @@ bool WinRtPlugin::initialize(const QStringList &arguments, QString *errorMessage
Q_UNUSED(errorMessage)
addAutoReleasedObject(new Internal::WinRtRunConfigurationFactory);
addAutoReleasedObject(new Internal::WinRtRunControlFactory);
addAutoReleasedObject(new Internal::WinRtQtVersionFactory);
addAutoReleasedObject(new Internal::WinRtDeployConfigurationFactory);
addAutoReleasedObject(new Internal::WinRtDeployStepFactory);
auto runConstraint = [](RunConfiguration *runConfig) {
IDevice::ConstPtr device = DeviceKitInformation::device(runConfig->target()->kit());
if (!device)
return false;
return qobject_cast<WinRtRunConfiguration *>(runConfig) != nullptr;
};
auto debugConstraint = [](RunConfiguration *runConfig) {
IDevice::ConstPtr device = DeviceKitInformation::device(runConfig->target()->kit());
if (!device)
return false;
if (device->type() != Internal::Constants::WINRT_DEVICE_TYPE_LOCAL)
return false;
return qobject_cast<WinRtRunConfiguration *>(runConfig) != nullptr;
};
RunControl::registerWorker<WinRtRunner>
(ProjectExplorer::Constants::NORMAL_RUN_MODE, runConstraint);
RunControl::registerWorker<WinRtDebugSupport>
(ProjectExplorer::Constants::DEBUG_RUN_MODE, debugConstraint);
RunControl::registerWorker<WinRtDebugSupport>
(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN, debugConstraint);
return true;
}
......
......@@ -27,14 +27,12 @@
#include "winrtrunconfiguration.h"
#include "winrtruncontrol.h"
#include "winrtconstants.h"
#include "winrtdebugsupport.h"
#include <projectexplorer/kit.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <qmakeprojectmanager/qmakeproject.h>
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
using QmakeProjectManager::QmakeProject;
......@@ -124,54 +122,5 @@ bool WinRtRunConfigurationFactory::canHandle(Target *parent) const
return true;
}
WinRtRunControlFactory::WinRtRunControlFactory()
{
}
bool WinRtRunControlFactory::canRun(RunConfiguration *runConfiguration,
Core::Id mode) const
{
if (!runConfiguration)
return false;
IDevice::ConstPtr device = DeviceKitInformation::device(runConfiguration->target()->kit());
if (!device)
return false;
if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE
|| mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN) {
if (device->type() != Constants::WINRT_DEVICE_TYPE_LOCAL)
return false;
return qobject_cast<WinRtRunConfiguration *>(runConfiguration);
}
if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE)
return qobject_cast<WinRtRunConfiguration *>(runConfiguration);
return false;
}
RunControl *WinRtRunControlFactory::create(
RunConfiguration *runConfiguration, Core::Id mode, QString *)
{
RunControl *runControl = nullptr;
if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE) {
runControl = new RunControl(runConfiguration, mode);
(void) new WinRtRunner(runControl);
return runControl;
} else if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE
|| mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN) {
runControl = new RunControl(runConfiguration, mode);
(void) new WinRtDebugSupport(runControl);
return runControl;
}
return nullptr;
}
QString WinRtRunControlFactory::displayName() const
{
return tr("WinRT Run Control Factory");
}
} // namespace Internal
} // namespace WinRt
......@@ -52,17 +52,5 @@ private:
virtual ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent, const QVariantMap &map) override;
};
class WinRtRunControlFactory : public ProjectExplorer::IRunControlFactory
{
Q_OBJECT
public:
WinRtRunControlFactory();
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
Core::Id mode) const override;
ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
Core::Id mode, QString *errorMessage) override;
QString displayName() const;
};
} // namespace Internal
} // namespace WinRt
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