forked from qt-creator/qt-creator
Ios: Use setup functions for a few factories
Change-Id: Ide05c2ca859454c1745e5c243af6a3d05131194c Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <coreplugin/helpmanager.h>
|
||||
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <projectexplorer/devicesupport/idevicefactory.h>
|
||||
#include <projectexplorer/devicesupport/idevicewidget.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
|
||||
@@ -78,10 +79,24 @@ namespace Ios::Internal {
|
||||
|
||||
const char kHandler[] = "Handler";
|
||||
|
||||
class IosDeviceInfoWidget : public IDeviceWidget
|
||||
class IosDeviceInfoWidget final : public IDeviceWidget
|
||||
{
|
||||
public:
|
||||
IosDeviceInfoWidget(const ProjectExplorer::IDevice::Ptr &device);
|
||||
IosDeviceInfoWidget(const IDevice::Ptr &device)
|
||||
: IDeviceWidget(device)
|
||||
{
|
||||
const auto iosDevice = std::static_pointer_cast<IosDevice>(device);
|
||||
using namespace Layouting;
|
||||
// clang-format off
|
||||
Form {
|
||||
Tr::tr("Device name:"), iosDevice->deviceName(), br,
|
||||
Tr::tr("Identifier:"), iosDevice->uniqueInternalDeviceId(), br,
|
||||
Tr::tr("OS Version:"), iosDevice->osVersion(), br,
|
||||
Tr::tr("CPU Architecture:"), iosDevice->cpuArchitecture(),
|
||||
noMargin
|
||||
}.attachTo(this);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void updateDeviceFromUi() final {}
|
||||
};
|
||||
@@ -584,37 +599,30 @@ void IosDeviceManager::updateAvailableDevices(const QStringList &devices)
|
||||
|
||||
// Factory
|
||||
|
||||
IosDeviceFactory::IosDeviceFactory()
|
||||
: IDeviceFactory(Constants::IOS_DEVICE_TYPE)
|
||||
class IosDeviceFactory final : public IDeviceFactory
|
||||
{
|
||||
setDisplayName(IosDevice::name());
|
||||
setCombinedIcon(":/ios/images/iosdevicesmall.png",
|
||||
":/ios/images/iosdevice.png");
|
||||
setConstructionFunction([] { return IDevice::Ptr(new IosDevice); });
|
||||
}
|
||||
public:
|
||||
IosDeviceFactory()
|
||||
: IDeviceFactory(Constants::IOS_DEVICE_TYPE)
|
||||
{
|
||||
setDisplayName(IosDevice::name());
|
||||
setCombinedIcon(":/ios/images/iosdevicesmall.png",
|
||||
":/ios/images/iosdevice.png");
|
||||
setConstructionFunction([] { return IDevice::Ptr(new IosDevice); });
|
||||
}
|
||||
|
||||
bool IosDeviceFactory::canRestore(const Store &map) const
|
||||
{
|
||||
Store vMap = map.value(Constants::EXTRA_INFO_KEY).value<Store>();
|
||||
if (vMap.isEmpty() || vMap.value(kDeviceName).toString() == QLatin1String("*unknown*"))
|
||||
return false; // transient device (probably generated during an activation)
|
||||
return true;
|
||||
}
|
||||
bool canRestore(const Utils::Store &map) const override
|
||||
{
|
||||
Store vMap = map.value(Constants::EXTRA_INFO_KEY).value<Store>();
|
||||
if (vMap.isEmpty() || vMap.value(kDeviceName).toString() == QLatin1String("*unknown*"))
|
||||
return false; // transient device (probably generated during an activation)
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
IosDeviceInfoWidget::IosDeviceInfoWidget(const IDevice::Ptr &device)
|
||||
: IDeviceWidget(device)
|
||||
void setupIosDevice()
|
||||
{
|
||||
const auto iosDevice = std::static_pointer_cast<IosDevice>(device);
|
||||
using namespace Layouting;
|
||||
// clang-format off
|
||||
Form {
|
||||
Tr::tr("Device name:"), iosDevice->deviceName(), br,
|
||||
Tr::tr("Identifier:"), iosDevice->uniqueInternalDeviceId(), br,
|
||||
Tr::tr("OS Version:"), iosDevice->osVersion(), br,
|
||||
Tr::tr("CPU Architecture:"), iosDevice->cpuArchitecture(),
|
||||
noMargin
|
||||
}.attachTo(this);
|
||||
// clang-format on
|
||||
static IosDeviceFactory theIosDeviceFactory;
|
||||
}
|
||||
|
||||
} // Ios::Internal
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "iostoolhandler.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/devicesupport/idevicefactory.h>
|
||||
|
||||
#include <solutions/tasking/tasktree.h>
|
||||
|
||||
@@ -60,14 +59,6 @@ protected:
|
||||
mutable quint16 m_lastPort;
|
||||
};
|
||||
|
||||
class IosDeviceFactory final : public ProjectExplorer::IDeviceFactory
|
||||
{
|
||||
public:
|
||||
IosDeviceFactory();
|
||||
|
||||
bool canRestore(const Utils::Store &map) const override;
|
||||
};
|
||||
|
||||
class IosDeviceManager : public QObject
|
||||
{
|
||||
public:
|
||||
@@ -94,5 +85,7 @@ private:
|
||||
QStringList m_userModeDeviceIds;
|
||||
};
|
||||
|
||||
void setupIosDevice();
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Ios
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace QtSupport;
|
||||
|
||||
namespace Ios::Internal {
|
||||
|
||||
@@ -45,10 +44,6 @@ public:
|
||||
class IosPluginPrivate
|
||||
{
|
||||
public:
|
||||
IosRunConfigurationFactory runConfigurationFactory;
|
||||
IosSettingsPage settingsPage;
|
||||
IosQtVersionFactory qtVersionFactory;
|
||||
IosDeviceFactory deviceFactory;
|
||||
IosSimulatorFactory simulatorFactory;
|
||||
IosBuildStepFactory buildStepFactory;
|
||||
IosDeployStepFactory deployStepFactory;
|
||||
@@ -75,9 +70,14 @@ class IosPlugin final : public ExtensionSystem::IPlugin
|
||||
|
||||
setupIosToolchain();
|
||||
setupIosBuildConfiguration();
|
||||
setupIosQtVersion();
|
||||
setupIosDevice();
|
||||
|
||||
IosConfigurations::initialize();
|
||||
|
||||
setupIosRunConfiguration();
|
||||
setupIosSettingsPage();
|
||||
|
||||
d = new IosPluginPrivate;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtkitaspect.h>
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
#include <qtsupport/qtversionfactory.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
|
||||
#include <projectexplorer/kit.h>
|
||||
@@ -93,14 +94,23 @@ QSet<Utils::Id> IosQtVersion::targetDeviceTypes() const
|
||||
|
||||
// Factory
|
||||
|
||||
IosQtVersionFactory::IosQtVersionFactory()
|
||||
class IosQtVersionFactory final : public QtSupport::QtVersionFactory
|
||||
{
|
||||
setQtVersionCreator([] { return new IosQtVersion; });
|
||||
setSupportedType(Constants::IOSQT);
|
||||
setPriority(90);
|
||||
setRestrictionChecker([](const SetupData &setup) {
|
||||
return setup.platforms.contains("ios");
|
||||
});
|
||||
public:
|
||||
IosQtVersionFactory()
|
||||
{
|
||||
setQtVersionCreator([] { return new IosQtVersion; });
|
||||
setSupportedType(Constants::IOSQT);
|
||||
setPriority(90);
|
||||
setRestrictionChecker([](const SetupData &setup) {
|
||||
return setup.platforms.contains("ios");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
void setupIosQtVersion()
|
||||
{
|
||||
static IosQtVersionFactory theIosQtVersionFactory;
|
||||
}
|
||||
|
||||
} // Ios::Internal
|
||||
|
||||
@@ -3,14 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <qtsupport/qtversionfactory.h>
|
||||
|
||||
namespace Ios::Internal {
|
||||
|
||||
class IosQtVersionFactory : public QtSupport::QtVersionFactory
|
||||
{
|
||||
public:
|
||||
IosQtVersionFactory();
|
||||
};
|
||||
void setupIosQtVersion();
|
||||
|
||||
} // Ios::Internal
|
||||
|
||||
@@ -413,11 +413,20 @@ FilePath IosDeviceTypeAspect::localExecutable() const
|
||||
|
||||
// IosRunConfigurationFactory
|
||||
|
||||
IosRunConfigurationFactory::IosRunConfigurationFactory()
|
||||
class IosRunConfigurationFactory final : public RunConfigurationFactory
|
||||
{
|
||||
registerRunConfiguration<IosRunConfiguration>(Constants::IOS_RUNCONFIG_ID);
|
||||
addSupportedTargetDeviceType(Constants::IOS_DEVICE_TYPE);
|
||||
addSupportedTargetDeviceType(Constants::IOS_SIMULATOR_TYPE);
|
||||
public:
|
||||
IosRunConfigurationFactory()
|
||||
{
|
||||
registerRunConfiguration<IosRunConfiguration>(Constants::IOS_RUNCONFIG_ID);
|
||||
addSupportedTargetDeviceType(Constants::IOS_DEVICE_TYPE);
|
||||
addSupportedTargetDeviceType(Constants::IOS_SIMULATOR_TYPE);
|
||||
}
|
||||
};
|
||||
|
||||
void setupIosRunConfiguration()
|
||||
{
|
||||
static IosRunConfigurationFactory theIosRunConfigurationFactory;
|
||||
}
|
||||
|
||||
} // Ios::Internal
|
||||
|
||||
@@ -81,10 +81,6 @@ private:
|
||||
IosDeviceTypeAspect iosDeviceType;
|
||||
};
|
||||
|
||||
class IosRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory
|
||||
{
|
||||
public:
|
||||
IosRunConfigurationFactory();
|
||||
};
|
||||
void setupIosRunConfiguration();
|
||||
|
||||
} // Ios::Internal
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "simulatorinfomodel.h"
|
||||
#include "simulatoroperationdialog.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
@@ -396,12 +398,21 @@ void IosSettingsWidget::saveSettings()
|
||||
|
||||
// IosSettingsPage
|
||||
|
||||
IosSettingsPage::IosSettingsPage()
|
||||
class IosSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
setId(Constants::IOS_SETTINGS_ID);
|
||||
setDisplayName(Tr::tr("iOS"));
|
||||
setCategory(ProjectExplorer::Constants::DEVICE_SETTINGS_CATEGORY);
|
||||
setWidgetCreator([] { return new IosSettingsWidget; });
|
||||
public:
|
||||
IosSettingsPage()
|
||||
{
|
||||
setId(Constants::IOS_SETTINGS_ID);
|
||||
setDisplayName(Tr::tr("iOS"));
|
||||
setCategory(ProjectExplorer::Constants::DEVICE_SETTINGS_CATEGORY);
|
||||
setWidgetCreator([] { return new IosSettingsWidget; });
|
||||
}
|
||||
};
|
||||
|
||||
void setupIosSettingsPage()
|
||||
{
|
||||
static IosSettingsPage theIosSettingsPage;
|
||||
}
|
||||
|
||||
} // Ios::Internal
|
||||
|
||||
@@ -3,14 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
namespace Ios::Internal {
|
||||
|
||||
class IosSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
IosSettingsPage();
|
||||
};
|
||||
void setupIosSettingsPage();
|
||||
|
||||
} // Ios::Internal
|
||||
|
||||
Reference in New Issue
Block a user