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";
|
if (deviceType == Tablet) return "tablet";
|
||||||
return "unknown";
|
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_OBJECT
|
||||||
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device")
|
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)
|
Q_PROPERTY(QString name READ name)
|
||||||
|
|
||||||
enum PairStatus {
|
enum PairStatus {
|
||||||
|
@ -78,6 +79,7 @@ public:
|
||||||
QString id() const { return m_deviceId; }
|
QString id() const { return m_deviceId; }
|
||||||
QString name() const { return m_deviceName; }
|
QString name() const { return m_deviceName; }
|
||||||
QString dbusPath() const { return "/modules/kdeconnect/devices/"+id(); }
|
QString dbusPath() const { return "/modules/kdeconnect/devices/"+id(); }
|
||||||
|
QString iconName() const;
|
||||||
|
|
||||||
//Add and remove links
|
//Add and remove links
|
||||||
void addLink(const NetworkPackage& identityPackage, DeviceLink*);
|
void addLink(const NetworkPackage& identityPackage, DeviceLink*);
|
||||||
|
|
|
@ -55,6 +55,7 @@ DevicesModel::DevicesModel(QObject *parent)
|
||||||
//Role names for QML
|
//Role names for QML
|
||||||
QHash<int, QByteArray> names = roleNames();
|
QHash<int, QByteArray> names = roleNames();
|
||||||
names.insert(IdModelRole, "deviceId");
|
names.insert(IdModelRole, "deviceId");
|
||||||
|
names.insert(IconNameRole, "iconName");
|
||||||
setRoleNames(names);
|
setRoleNames(names);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,8 +168,10 @@ QVariant DevicesModel::data(const QModelIndex& index, int role) const
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
case IconNameRole:
|
||||||
|
return device->iconName();
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
IconModelRole = Qt::DecorationRole,
|
IconModelRole = Qt::DecorationRole,
|
||||||
StatusModelRole = Qt::InitialSortOrderRole,
|
StatusModelRole = Qt::InitialSortOrderRole,
|
||||||
IdModelRole = Qt::UserRole,
|
IdModelRole = Qt::UserRole,
|
||||||
|
IconNameRole
|
||||||
};
|
};
|
||||||
enum StatusFlags {
|
enum StatusFlags {
|
||||||
StatusUnknown = 0x00,
|
StatusUnknown = 0x00,
|
||||||
|
|
Loading…
Reference in a new issue