forked from qt-creator/qt-creator
Make IDeviceFactory use data members
... for display name, icon, and "can create". Also add a convenience function for the special icon setup that's used in all re-implementations. Change-Id: I8332adb38fb4a77b6992007ffe62f861339ba188 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -28,10 +28,6 @@
|
||||
|
||||
#include "androidconstants.h"
|
||||
|
||||
#include <utils/icon.h>
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
@@ -39,32 +35,9 @@ AndroidDeviceFactory::AndroidDeviceFactory()
|
||||
: ProjectExplorer::IDeviceFactory(Constants::ANDROID_DEVICE_TYPE)
|
||||
{
|
||||
setObjectName(QLatin1String("AndroidDeviceFactory"));
|
||||
}
|
||||
|
||||
QString AndroidDeviceFactory::displayName() const
|
||||
{
|
||||
return tr("Android Device");
|
||||
}
|
||||
|
||||
QIcon AndroidDeviceFactory::icon() const
|
||||
{
|
||||
using namespace Utils;
|
||||
static const QIcon icon =
|
||||
Icon::combinedIcon({Icon({{":/android/images/androiddevicesmall.png",
|
||||
Theme::PanelTextColorDark}}, Icon::Tint),
|
||||
Icon({{":/android/images/androiddevice.png",
|
||||
Theme::IconsBaseColor}})});
|
||||
return icon;
|
||||
}
|
||||
|
||||
bool AndroidDeviceFactory::canCreate() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ProjectExplorer::IDevice::Ptr AndroidDeviceFactory::create() const
|
||||
{
|
||||
return ProjectExplorer::IDevice::Ptr();
|
||||
setDisplayName(tr("Android Device"));
|
||||
setCombinedIcon(":/android/images/androiddevicesmall.png",
|
||||
":/android/images/androiddevice.png");
|
||||
}
|
||||
|
||||
ProjectExplorer::IDevice::Ptr AndroidDeviceFactory::restore(const QVariantMap &map) const
|
||||
|
@@ -36,11 +36,6 @@ class AndroidDeviceFactory : public ProjectExplorer::IDeviceFactory
|
||||
public:
|
||||
AndroidDeviceFactory();
|
||||
|
||||
QString displayName() const override;
|
||||
QIcon icon() const override;
|
||||
|
||||
bool canCreate() const override;
|
||||
ProjectExplorer::IDevice::Ptr create() const override;
|
||||
ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const override;
|
||||
};
|
||||
|
||||
|
@@ -29,11 +29,8 @@
|
||||
#include "baremetalconstants.h"
|
||||
#include "baremetaldevice.h"
|
||||
|
||||
#include <utils/icon.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace BareMetal {
|
||||
@@ -42,22 +39,10 @@ namespace Internal {
|
||||
BareMetalDeviceConfigurationFactory::BareMetalDeviceConfigurationFactory()
|
||||
: IDeviceFactory(Constants::BareMetalOsType)
|
||||
{
|
||||
}
|
||||
|
||||
QString BareMetalDeviceConfigurationFactory::displayName() const
|
||||
{
|
||||
return tr("Bare Metal Device");
|
||||
}
|
||||
|
||||
QIcon BareMetalDeviceConfigurationFactory::icon() const
|
||||
{
|
||||
using namespace Utils;
|
||||
static const QIcon icon =
|
||||
Icon::combinedIcon({Icon({{":/baremetal/images/baremetaldevicesmall.png",
|
||||
Theme::PanelTextColorDark}}, Icon::Tint),
|
||||
Icon({{":/baremetal/images/baremetaldevice.png",
|
||||
Theme::IconsBaseColor}})});
|
||||
return icon;
|
||||
setDisplayName(tr("Bare Metal Device"));
|
||||
setCombinedIcon(":/baremetal/images/baremetaldevicesmall.png",
|
||||
":/baremetal/images/baremetaldevice.png");
|
||||
setCanCreate(true);
|
||||
}
|
||||
|
||||
IDevice::Ptr BareMetalDeviceConfigurationFactory::create() const
|
||||
|
@@ -38,9 +38,6 @@ class BareMetalDeviceConfigurationFactory
|
||||
public:
|
||||
BareMetalDeviceConfigurationFactory();
|
||||
|
||||
QString displayName() const override;
|
||||
QIcon icon() const override;
|
||||
|
||||
ProjectExplorer::IDevice::Ptr create() const override;
|
||||
ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const override;
|
||||
};
|
||||
|
@@ -28,10 +28,6 @@
|
||||
|
||||
#include "iosconstants.h"
|
||||
|
||||
#include <utils/icon.h>
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
|
||||
@@ -39,32 +35,9 @@ IosDeviceFactory::IosDeviceFactory()
|
||||
: ProjectExplorer::IDeviceFactory(Constants::IOS_DEVICE_ID)
|
||||
{
|
||||
setObjectName(QLatin1String("IosDeviceFactory"));
|
||||
}
|
||||
|
||||
QString IosDeviceFactory::displayName() const
|
||||
{
|
||||
return IosDevice::name();
|
||||
}
|
||||
|
||||
QIcon IosDeviceFactory::icon() const
|
||||
{
|
||||
using namespace Utils;
|
||||
static const QIcon icon =
|
||||
Icon::combinedIcon({Icon({{":/ios/images/iosdevicesmall.png",
|
||||
Theme::PanelTextColorDark}}, Icon::Tint),
|
||||
Icon({{":/ios/images/iosdevice.png",
|
||||
Theme::IconsBaseColor}})});
|
||||
return icon;
|
||||
}
|
||||
|
||||
bool IosDeviceFactory::canCreate() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ProjectExplorer::IDevice::Ptr IosDeviceFactory::create() const
|
||||
{
|
||||
return ProjectExplorer::IDevice::Ptr();
|
||||
setDisplayName(IosDevice::name());
|
||||
setCombinedIcon(":/ios/images/iosdevicesmall.png",
|
||||
":/ios/images/iosdevice.png");
|
||||
}
|
||||
|
||||
bool IosDeviceFactory::canRestore(const QVariantMap &map) const
|
||||
|
@@ -27,10 +27,6 @@
|
||||
|
||||
#include <projectexplorer/devicesupport/idevicefactory.h>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
|
||||
@@ -40,11 +36,6 @@ class IosDeviceFactory : public ProjectExplorer::IDeviceFactory
|
||||
public:
|
||||
IosDeviceFactory();
|
||||
|
||||
QString displayName() const override;
|
||||
QIcon icon() const override;
|
||||
|
||||
bool canCreate() const override;
|
||||
ProjectExplorer::IDevice::Ptr create() const override;
|
||||
bool canRestore(const QVariantMap &map) const override;
|
||||
ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const override;
|
||||
};
|
||||
|
@@ -24,13 +24,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "iossimulatorfactory.h"
|
||||
#include <QLatin1String>
|
||||
|
||||
#include "iosconstants.h"
|
||||
#include "iossimulator.h"
|
||||
#include "utils/icon.h"
|
||||
#include "utils/qtcassert.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include "utils/qtcassert.h"
|
||||
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
@@ -39,32 +37,9 @@ IosSimulatorFactory::IosSimulatorFactory()
|
||||
: ProjectExplorer::IDeviceFactory(Constants::IOS_SIMULATOR_TYPE)
|
||||
{
|
||||
setObjectName(QLatin1String("IosSimulatorFactory"));
|
||||
}
|
||||
|
||||
QString IosSimulatorFactory::displayName() const
|
||||
{
|
||||
return tr("iOS Simulator");
|
||||
}
|
||||
|
||||
QIcon IosSimulatorFactory::icon() const
|
||||
{
|
||||
using namespace Utils;
|
||||
static const QIcon icon =
|
||||
Icon::combinedIcon({Icon({{":/ios/images/iosdevicesmall.png",
|
||||
Theme::PanelTextColorDark}}, Icon::Tint),
|
||||
Icon({{":/ios/images/iosdevice.png",
|
||||
Theme::IconsBaseColor}})});
|
||||
return icon;
|
||||
}
|
||||
|
||||
bool IosSimulatorFactory::canCreate() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ProjectExplorer::IDevice::Ptr IosSimulatorFactory::create() const
|
||||
{
|
||||
return ProjectExplorer::IDevice::Ptr();
|
||||
setDisplayName(tr("iOS Simulator"));
|
||||
setCombinedIcon(":/ios/images/iosdevicesmall.png",
|
||||
":/ios/images/iosdevice.png");
|
||||
}
|
||||
|
||||
ProjectExplorer::IDevice::Ptr IosSimulatorFactory::restore(const QVariantMap &map) const
|
||||
|
@@ -36,11 +36,6 @@ class IosSimulatorFactory : public ProjectExplorer::IDeviceFactory
|
||||
public:
|
||||
IosSimulatorFactory();
|
||||
|
||||
QString displayName() const override;
|
||||
QIcon icon() const override;
|
||||
|
||||
bool canCreate() const override;
|
||||
ProjectExplorer::IDevice::Ptr create() const override;
|
||||
ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const override;
|
||||
};
|
||||
|
||||
|
@@ -32,7 +32,6 @@
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QIcon>
|
||||
#include <QStyle>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -40,31 +39,12 @@ namespace Internal {
|
||||
|
||||
DesktopDeviceFactory::DesktopDeviceFactory()
|
||||
: IDeviceFactory(Constants::DESKTOP_DEVICE_TYPE)
|
||||
{ }
|
||||
|
||||
QString DesktopDeviceFactory::displayName() const
|
||||
{
|
||||
return tr("Desktop");
|
||||
}
|
||||
|
||||
QIcon DesktopDeviceFactory::icon() const
|
||||
{
|
||||
static const QIcon icon =
|
||||
Utils::creatorTheme()->flag(Utils::Theme::FlatSideBarIcons)
|
||||
setDisplayName(tr("Desktop"));
|
||||
setIcon(Utils::creatorTheme()->flag(Utils::Theme::FlatSideBarIcons)
|
||||
? Utils::Icon::combinedIcon({Icons::DESKTOP_DEVICE.icon(),
|
||||
Icons::DESKTOP_DEVICE_SMALL.icon()})
|
||||
: QApplication::style()->standardIcon(QStyle::SP_ComputerIcon);
|
||||
return icon;
|
||||
}
|
||||
|
||||
bool DesktopDeviceFactory::canCreate() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IDevice::Ptr DesktopDeviceFactory::create() const
|
||||
{
|
||||
return IDevice::Ptr();
|
||||
: QApplication::style()->standardIcon(QStyle::SP_ComputerIcon));
|
||||
}
|
||||
|
||||
IDevice::Ptr DesktopDeviceFactory::restore(const QVariantMap &map) const
|
||||
|
@@ -32,16 +32,9 @@ namespace Internal {
|
||||
|
||||
class DesktopDeviceFactory : public IDeviceFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DesktopDeviceFactory();
|
||||
|
||||
QString displayName() const override;
|
||||
QIcon icon() const override;
|
||||
|
||||
bool canCreate() const override;
|
||||
IDevice::Ptr create() const override;
|
||||
IDevice::Ptr restore(const QVariantMap &map) const override;
|
||||
};
|
||||
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "idevicefactory.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/icon.h>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
@@ -42,20 +43,15 @@ namespace ProjectExplorer {
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QString displayNameForId(Core::Id type) const = 0
|
||||
\fn virtual QString displayName() const = 0
|
||||
|
||||
Returns a short, one-line description of the device type.
|
||||
Returns a short, one-line description of the device type this factory
|
||||
can create.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QList<Core::Id> availableCreationIds() const = 0
|
||||
|
||||
Lists the device types this factory can create.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual IDevice::Ptr create(Core::Id id) const = 0
|
||||
Creates a new device with the id \a id. This may or may not open a wizard.
|
||||
\fn virtual IDevice::Ptr create() const
|
||||
Creates a new device. This may or may not open a wizard.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@@ -80,7 +76,7 @@ namespace ProjectExplorer {
|
||||
|
||||
bool IDeviceFactory::canCreate() const
|
||||
{
|
||||
return true;
|
||||
return m_canCreate;
|
||||
}
|
||||
|
||||
static QList<IDeviceFactory *> g_deviceFactories;
|
||||
@@ -99,6 +95,28 @@ IDeviceFactory::IDeviceFactory(Core::Id deviceType)
|
||||
g_deviceFactories.append(this);
|
||||
}
|
||||
|
||||
void IDeviceFactory::setIcon(const QIcon &icon)
|
||||
{
|
||||
m_icon = icon;
|
||||
}
|
||||
|
||||
void IDeviceFactory::setCombinedIcon(const QString &small, const QString &large)
|
||||
{
|
||||
using namespace Utils;
|
||||
m_icon = Icon::combinedIcon({Icon({{small, Theme::PanelTextColorDark}}, Icon::Tint),
|
||||
Icon({{large, Theme::IconsBaseColor}})});
|
||||
}
|
||||
|
||||
void IDeviceFactory::setCanCreate(bool canCreate)
|
||||
{
|
||||
m_canCreate = canCreate;
|
||||
}
|
||||
|
||||
void IDeviceFactory::setDisplayName(const QString &displayName)
|
||||
{
|
||||
m_displayName = displayName;
|
||||
}
|
||||
|
||||
IDeviceFactory::~IDeviceFactory()
|
||||
{
|
||||
g_deviceFactories.removeOne(this);
|
||||
|
@@ -28,16 +28,10 @@
|
||||
#include "idevice.h"
|
||||
#include <projectexplorer/projectexplorer_export.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QIcon>
|
||||
#include <QVariantMap>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class IDeviceWidget;
|
||||
|
||||
|
||||
class PROJECTEXPLORER_EXPORT IDeviceFactory : public QObject
|
||||
{
|
||||
@@ -47,23 +41,31 @@ public:
|
||||
~IDeviceFactory() override;
|
||||
static const QList<IDeviceFactory *> allDeviceFactories();
|
||||
|
||||
virtual QString displayName() const = 0;
|
||||
virtual QIcon icon() const = 0;
|
||||
Core::Id deviceType() const { return m_deviceType; }
|
||||
QString displayName() const { return m_displayName; }
|
||||
QIcon icon() const { return m_icon; }
|
||||
bool canCreate() const;
|
||||
|
||||
virtual bool canCreate() const;
|
||||
virtual IDevice::Ptr create() const = 0;
|
||||
virtual IDevice::Ptr create() const { return IDevice::Ptr(); }
|
||||
|
||||
virtual bool canRestore(const QVariantMap &) const { return true; }
|
||||
virtual IDevice::Ptr restore(const QVariantMap &map) const = 0;
|
||||
|
||||
static IDeviceFactory *find(Core::Id type);
|
||||
Core::Id deviceType() const { return m_deviceType; }
|
||||
|
||||
protected:
|
||||
explicit IDeviceFactory(Core::Id deviceType);
|
||||
|
||||
void setDisplayName(const QString &displayName);
|
||||
void setIcon(const QIcon &icon);
|
||||
void setCombinedIcon(const QString &small, const QString &large);
|
||||
void setCanCreate(bool canCreate);
|
||||
|
||||
private:
|
||||
const Core::Id m_deviceType;
|
||||
QString m_displayName;
|
||||
QIcon m_icon;
|
||||
bool m_canCreate = false;
|
||||
};
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
@@ -30,9 +30,6 @@
|
||||
#include "qnxdevice.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/icon.h>
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
@@ -40,27 +37,10 @@ namespace Internal {
|
||||
QnxDeviceFactory::QnxDeviceFactory()
|
||||
: ProjectExplorer::IDeviceFactory(Constants::QNX_QNX_OS_TYPE)
|
||||
{
|
||||
}
|
||||
|
||||
QString QnxDeviceFactory::displayName() const
|
||||
{
|
||||
return tr("QNX Device");
|
||||
}
|
||||
|
||||
QIcon QnxDeviceFactory::icon() const
|
||||
{
|
||||
using namespace Utils;
|
||||
static const QIcon icon =
|
||||
Icon::combinedIcon({Icon({{":/qnx/images/qnxdevicesmall.png",
|
||||
Theme::PanelTextColorDark}}, Icon::Tint),
|
||||
Icon({{":/qnx/images/qnxdevice.png",
|
||||
Theme::IconsBaseColor}})});
|
||||
return icon;
|
||||
}
|
||||
|
||||
bool QnxDeviceFactory::canCreate() const
|
||||
{
|
||||
return true;
|
||||
setDisplayName(tr("QNX Device"));
|
||||
setCombinedIcon(":/qnx/images/qnxdevicesmall.png",
|
||||
":/qnx/images/qnxdevice.png");
|
||||
setCanCreate(true);
|
||||
}
|
||||
|
||||
ProjectExplorer::IDevice::Ptr QnxDeviceFactory::create() const
|
||||
|
@@ -37,10 +37,6 @@ class QnxDeviceFactory : public ProjectExplorer::IDeviceFactory
|
||||
public:
|
||||
QnxDeviceFactory();
|
||||
|
||||
QString displayName() const override;
|
||||
QIcon icon() const override;
|
||||
|
||||
bool canCreate() const override;
|
||||
ProjectExplorer::IDevice::Ptr create() const override;
|
||||
ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const override;
|
||||
|
||||
|
@@ -33,8 +33,6 @@
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace RemoteLinux {
|
||||
@@ -42,16 +40,9 @@ namespace RemoteLinux {
|
||||
GenericLinuxDeviceConfigurationFactory::GenericLinuxDeviceConfigurationFactory()
|
||||
: IDeviceFactory(Constants::GenericLinuxOsType)
|
||||
{
|
||||
}
|
||||
|
||||
QString GenericLinuxDeviceConfigurationFactory::displayName() const
|
||||
{
|
||||
return tr("Generic Linux Device");
|
||||
}
|
||||
|
||||
QIcon GenericLinuxDeviceConfigurationFactory::icon() const
|
||||
{
|
||||
return QIcon();
|
||||
setDisplayName(tr("Generic Linux Device"));
|
||||
setIcon(QIcon());
|
||||
setCanCreate(true);
|
||||
}
|
||||
|
||||
IDevice::Ptr GenericLinuxDeviceConfigurationFactory::create() const
|
||||
|
@@ -39,9 +39,6 @@ class REMOTELINUX_EXPORT GenericLinuxDeviceConfigurationFactory
|
||||
public:
|
||||
GenericLinuxDeviceConfigurationFactory();
|
||||
|
||||
QString displayName() const override;
|
||||
QIcon icon() const override;
|
||||
|
||||
ProjectExplorer::IDevice::Ptr create() const override;
|
||||
ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const override;
|
||||
};
|
||||
|
@@ -32,10 +32,9 @@
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
#include <utils/icon.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QIcon>
|
||||
#include <QFileInfo>
|
||||
|
||||
using Core::MessageManager;
|
||||
@@ -59,26 +58,9 @@ WinRtDeviceFactory::WinRtDeviceFactory(Core::Id deviceType)
|
||||
&QtVersionManager::qtVersionsLoaded,
|
||||
this, &WinRtDeviceFactory::onPrerequisitesLoaded, Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
QString WinRtDeviceFactory::displayName() const
|
||||
{
|
||||
return WinRtDevice::displayNameForType(deviceType());
|
||||
}
|
||||
|
||||
QIcon WinRtDeviceFactory::icon() const
|
||||
{
|
||||
using namespace Utils;
|
||||
return Icon::combinedIcon({Icon({{":/winrt/images/winrtdevicesmall.png",
|
||||
Theme::PanelTextColorDark}}, Icon::Tint),
|
||||
Icon({{":/winrt/images/winrtdevice.png",
|
||||
Theme::IconsBaseColor}})});
|
||||
}
|
||||
|
||||
IDevice::Ptr WinRtDeviceFactory::create() const
|
||||
{
|
||||
QTC_CHECK(false);
|
||||
return IDevice::Ptr();
|
||||
setDisplayName(WinRtDevice::displayNameForType(deviceType));
|
||||
setCombinedIcon(":/winrt/images/winrtdevicesmall.png",
|
||||
":/winrt/images/winrtdevice.png");
|
||||
}
|
||||
|
||||
IDevice::Ptr WinRtDeviceFactory::restore(const QVariantMap &map) const
|
||||
|
@@ -36,10 +36,7 @@ class WinRtDeviceFactory : public ProjectExplorer::IDeviceFactory
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WinRtDeviceFactory(Core::Id deviceType);
|
||||
QString displayName() const override;
|
||||
QIcon icon() const override;
|
||||
bool canCreate() const override { return false; }
|
||||
ProjectExplorer::IDevice::Ptr create() const override;
|
||||
|
||||
ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const override;
|
||||
|
||||
void autoDetect();
|
||||
|
Reference in New Issue
Block a user