diff --git a/core/device.cpp b/core/device.cpp index c8a28bdb3..264e78b70 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -456,7 +456,7 @@ QStringList Device::availableLinks() const Device::DeviceType Device::str2type(QString deviceType) { if (deviceType == "desktop") return Desktop; if (deviceType == "laptop") return Laptop; - if (deviceType == "phone") return Phone; + if (deviceType == "smartphone" || deviceType == "phone") return Phone; if (deviceType == "tablet") return Tablet; return Unknown; } @@ -464,26 +464,35 @@ Device::DeviceType Device::str2type(QString deviceType) { QString Device::type2str(Device::DeviceType deviceType) { if (deviceType == Desktop) return "desktop"; if (deviceType == Laptop) return "laptop"; - if (deviceType == Phone) return "phone"; + if (deviceType == Phone) return "smartphone"; if (deviceType == Tablet) return "tablet"; return "unknown"; } +QString Device::statusIconName() const +{ + return iconForStatus(isReachable(), isPaired()); +} + 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 iconForStatus(true, false); +} + +QString Device::iconForStatus(bool reachable, bool paired) const +{ + Device::DeviceType deviceType = m_deviceType; + if (deviceType == Device::Unknown) { + deviceType = Device::Phone; //Assume phone if we don't know the type + } else if (deviceType == Device::Desktop) { + deviceType = Device::Device::Laptop; // We don't have desktop icon yet } - return QString(); + + QString status = (reachable? (paired? QStringLiteral("connected") : QStringLiteral("disconnected")) : QStringLiteral("trusted")); + QString type = type2str(deviceType); + + return type+"-"+status; } void Device::setName(const QString &name) diff --git a/core/device.h b/core/device.h index c2d743a76..f1610c2ed 100644 --- a/core/device.h +++ b/core/device.h @@ -40,9 +40,12 @@ class KDECONNECTCORE_EXPORT Device Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device") Q_PROPERTY(QString id READ id CONSTANT) - Q_PROPERTY(QString iconName READ iconName CONSTANT) + Q_PROPERTY(QString type READ type CONSTANT) Q_PROPERTY(QString name READ name NOTIFY nameChanged) + Q_PROPERTY(QString iconName READ iconName CONSTANT) + Q_PROPERTY(QString statusIconName READ statusIconName) Q_PROPERTY(bool isReachable READ isReachable NOTIFY reachableStatusChanged) + Q_PROPERTY(bool isPaired READ isPaired) enum PairStatus { NotPaired, @@ -81,12 +84,14 @@ public: QString id() const { return m_deviceId; } QString name() const { return m_deviceName; } QString dbusPath() const { return "/modules/kdeconnect/devices/"+id(); } + QString type() const { return type2str(m_deviceType); }; QString iconName() const; + QString statusIconName() const; //Add and remove links void addLink(const NetworkPackage& identityPackage, DeviceLink*); void removeLink(DeviceLink*); - + Q_SCRIPTABLE bool isPaired() const { return m_pairStatus==Device::Paired; } Q_SCRIPTABLE bool pairRequested() const { return m_pairStatus==Device::Requested; } @@ -123,10 +128,14 @@ Q_SIGNALS: Q_SCRIPTABLE void unpaired(); Q_SCRIPTABLE void nameChanged(const QString& name); -private: +private: //Methods void setName(const QString &name); + QString iconForStatus(bool reachable, bool paired) const; void unpairInternal(); + void setAsPaired(); + bool sendOwnPublicKey(); +private: //Fields (TODO: dPointer!) const QString m_deviceId; QString m_deviceName; DeviceType m_deviceType; @@ -143,9 +152,6 @@ private: const QSet m_incomingCapabilities; const QSet m_outgoingCapabilities; - void setAsPaired(); - bool sendOwnPublicKey(); - }; Q_DECLARE_METATYPE(Device*) diff --git a/icon/32-status-laptop-connected.png b/icon/32-status-laptop-connected.png new file mode 100644 index 000000000..423d27f80 Binary files /dev/null and b/icon/32-status-laptop-connected.png differ diff --git a/icon/32-status-laptop-disconnected.png b/icon/32-status-laptop-disconnected.png new file mode 100644 index 000000000..77e6fcd2b Binary files /dev/null and b/icon/32-status-laptop-disconnected.png differ diff --git a/icon/32-status-laptop-trusted.png b/icon/32-status-laptop-trusted.png new file mode 100644 index 000000000..68e327117 Binary files /dev/null and b/icon/32-status-laptop-trusted.png differ diff --git a/icon/32-status-smartphone-connected.png b/icon/32-status-smartphone-connected.png new file mode 100644 index 000000000..991f79a63 Binary files /dev/null and b/icon/32-status-smartphone-connected.png differ diff --git a/icon/32-status-smartphone-disconnected.png b/icon/32-status-smartphone-disconnected.png new file mode 100644 index 000000000..11ebffc95 Binary files /dev/null and b/icon/32-status-smartphone-disconnected.png differ diff --git a/icon/32-status-smartphone-trusted.png b/icon/32-status-smartphone-trusted.png new file mode 100644 index 000000000..70f4fe26a Binary files /dev/null and b/icon/32-status-smartphone-trusted.png differ diff --git a/icon/32-status-tablet-connected.png b/icon/32-status-tablet-connected.png new file mode 100644 index 000000000..7d660ba24 Binary files /dev/null and b/icon/32-status-tablet-connected.png differ diff --git a/icon/32-status-tablet-disconnected.png b/icon/32-status-tablet-disconnected.png new file mode 100644 index 000000000..20abfff31 Binary files /dev/null and b/icon/32-status-tablet-disconnected.png differ diff --git a/icon/32-status-tablet-trusted.png b/icon/32-status-tablet-trusted.png new file mode 100644 index 000000000..000f5d0ff Binary files /dev/null and b/icon/32-status-tablet-trusted.png differ diff --git a/icon/CMakeLists.txt b/icon/CMakeLists.txt index df6da35a8..44378f53b 100644 --- a/icon/CMakeLists.txt +++ b/icon/CMakeLists.txt @@ -13,3 +13,28 @@ ICONS DESTINATION ${ICON_INSTALL_DIR} ) + +ecm_install_icons( +ICONS + 32-status-laptop-connected.png + 32-status-laptop-disconnected.png + 32-status-laptop-trusted.png + 32-status-smartphone-connected.png + 32-status-smartphone-disconnected.png + 32-status-smartphone-trusted.png + 32-status-tablet-connected.png + 32-status-tablet-disconnected.png + 32-status-tablet-trusted.png + sc-status-laptop-connected.svg + sc-status-laptop-disconnected.svg + sc-status-laptop-trusted.svg + sc-status-smartphone-connected.svg + sc-status-smartphone-disconnected.svg + sc-status-smartphone-trusted.svg + sc-status-tablet-connected.svg + sc-status-tablet-disconnected.svg + sc-status-tablet-trusted.svg +DESTINATION + ${ICON_INSTALL_DIR} +) + diff --git a/icon/sc-status-laptop-connected.svg b/icon/sc-status-laptop-connected.svg new file mode 100644 index 000000000..c044edebe --- /dev/null +++ b/icon/sc-status-laptop-connected.svg @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/icon/sc-status-laptop-disconnected.svg b/icon/sc-status-laptop-disconnected.svg new file mode 100644 index 000000000..b99c42bca --- /dev/null +++ b/icon/sc-status-laptop-disconnected.svg @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/icon/sc-status-laptop-trusted.svg b/icon/sc-status-laptop-trusted.svg new file mode 100644 index 000000000..cd1822413 --- /dev/null +++ b/icon/sc-status-laptop-trusted.svg @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/icon/sc-status-smartphone-connected.svg b/icon/sc-status-smartphone-connected.svg new file mode 100644 index 000000000..917894669 --- /dev/null +++ b/icon/sc-status-smartphone-connected.svg @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/icon/sc-status-smartphone-disconnected.svg b/icon/sc-status-smartphone-disconnected.svg new file mode 100644 index 000000000..f4275f714 --- /dev/null +++ b/icon/sc-status-smartphone-disconnected.svg @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/icon/sc-status-smartphone-trusted.svg b/icon/sc-status-smartphone-trusted.svg new file mode 100644 index 000000000..dd0f58aa4 --- /dev/null +++ b/icon/sc-status-smartphone-trusted.svg @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/icon/sc-status-tablet-connected.svg b/icon/sc-status-tablet-connected.svg new file mode 100644 index 000000000..9229cf3dd --- /dev/null +++ b/icon/sc-status-tablet-connected.svg @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/icon/sc-status-tablet-disconnected.svg b/icon/sc-status-tablet-disconnected.svg new file mode 100644 index 000000000..283b2d0fe --- /dev/null +++ b/icon/sc-status-tablet-disconnected.svg @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/icon/sc-status-tablet-trusted.svg b/icon/sc-status-tablet-trusted.svg new file mode 100644 index 000000000..37bfd5a87 --- /dev/null +++ b/icon/sc-status-tablet-trusted.svg @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/interfaces/devicesmodel.cpp b/interfaces/devicesmodel.cpp index 9b06ffc9c..90f0b5b0b 100644 --- a/interfaces/devicesmodel.cpp +++ b/interfaces/devicesmodel.cpp @@ -24,7 +24,9 @@ #include #include +#include #include +#include #include #include "dbusinterfaces.h" @@ -198,7 +200,7 @@ QVariant DevicesModel::data(const QModelIndex& index, int role) const return QVariant(); } - DeviceDbusInterface* device = m_deviceList[index.row()]; + const DeviceDbusInterface* device = m_deviceList[index.row()]; //This function gets called lots of times, producing lots of dbus calls. Add a cache? switch (role) { @@ -225,7 +227,7 @@ QVariant DevicesModel::data(const QModelIndex& index, int role) const return status; } case IconNameRole: - return device->iconName(); + return device->statusIconName(); default: return QVariant(); }