Commit b7420146 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Expose the icon name from the device instance

parent 61fcf3f4
......@@ -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,8 +168,10 @@ QVariant DevicesModel::data(const QModelIndex& index, int role) const
}
return status;
}
case IconNameRole:
return device->iconName();
default:
return QVariant();
return QVariant();
}
}
......
......@@ -44,6 +44,7 @@ public:
IconModelRole = Qt::DecorationRole,
StatusModelRole = Qt::InitialSortOrderRole,
IdModelRole = Qt::UserRole,
IconNameRole
};
enum StatusFlags {
StatusUnknown = 0x00,
......
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