Expose the icon name from the device instance
This commit is contained in:
parent
61fcf3f4ba
commit
b7420146eb
4 changed files with 25 additions and 2 deletions
|
@ -484,3 +484,20 @@ QString Device::type2str(Device::DeviceType deviceType) {
|
|||
if (deviceType == Tablet) return "tablet";
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
QString Device::iconName() const
|
||||
{
|
||||
switch(m_deviceType) {
|
||||
case Device::Desktop:
|
||||
return "computer";
|
||||
case Device::Laptop:
|
||||
return "computer-laptop";
|
||||
case Device::Phone:
|
||||
return "smartphone";
|
||||
case Device::Tablet:
|
||||
return "tablet";
|
||||
case Device::Unknown:
|
||||
return "unknown";
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@ class KDECONNECTCORE_EXPORT Device
|
|||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device")
|
||||
Q_PROPERTY(QString id READ id)
|
||||
Q_PROPERTY(QString id READ id CONSTANT)
|
||||
Q_PROPERTY(QString iconName READ iconName CONSTANT)
|
||||
Q_PROPERTY(QString name READ name)
|
||||
|
||||
enum PairStatus {
|
||||
|
@ -78,6 +79,7 @@ public:
|
|||
QString id() const { return m_deviceId; }
|
||||
QString name() const { return m_deviceName; }
|
||||
QString dbusPath() const { return "/modules/kdeconnect/devices/"+id(); }
|
||||
QString iconName() const;
|
||||
|
||||
//Add and remove links
|
||||
void addLink(const NetworkPackage& identityPackage, DeviceLink*);
|
||||
|
|
|
@ -55,6 +55,7 @@ DevicesModel::DevicesModel(QObject *parent)
|
|||
//Role names for QML
|
||||
QHash<int, QByteArray> names = roleNames();
|
||||
names.insert(IdModelRole, "deviceId");
|
||||
names.insert(IconNameRole, "iconName");
|
||||
setRoleNames(names);
|
||||
}
|
||||
|
||||
|
@ -167,6 +168,8 @@ QVariant DevicesModel::data(const QModelIndex& index, int role) const
|
|||
}
|
||||
return status;
|
||||
}
|
||||
case IconNameRole:
|
||||
return device->iconName();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
IconModelRole = Qt::DecorationRole,
|
||||
StatusModelRole = Qt::InitialSortOrderRole,
|
||||
IdModelRole = Qt::UserRole,
|
||||
IconNameRole
|
||||
};
|
||||
enum StatusFlags {
|
||||
StatusUnknown = 0x00,
|
||||
|
|
Loading…
Reference in a new issue