Save changed device name and type
This commit is contained in:
parent
79164ca8ba
commit
f3656d962c
3 changed files with 19 additions and 2 deletions
|
@ -276,7 +276,7 @@ void Device::addLink(const NetworkPacket& identityPacket, DeviceLink* link)
|
||||||
//qCDebug(KDECONNECT_CORE) << "Adding link to" << id() << "via" << link->provider();
|
//qCDebug(KDECONNECT_CORE) << "Adding link to" << id() << "via" << link->provider();
|
||||||
|
|
||||||
setName(identityPacket.get<QString>(QStringLiteral("deviceName")));
|
setName(identityPacket.get<QString>(QStringLiteral("deviceName")));
|
||||||
d->m_deviceType = str2type(identityPacket.get<QString>(QStringLiteral("deviceType")));
|
setType(identityPacket.get<QString>(QStringLiteral("deviceType")));
|
||||||
|
|
||||||
if (d->m_deviceLinks.contains(link)) {
|
if (d->m_deviceLinks.contains(link)) {
|
||||||
return;
|
return;
|
||||||
|
@ -506,10 +506,21 @@ void Device::setName(const QString& name)
|
||||||
{
|
{
|
||||||
if (d->m_deviceName != name) {
|
if (d->m_deviceName != name) {
|
||||||
d->m_deviceName = name;
|
d->m_deviceName = name;
|
||||||
|
KdeConnectConfig::instance().setDeviceProperty(d->m_deviceId, QStringLiteral("name"), name);
|
||||||
Q_EMIT nameChanged(name);
|
Q_EMIT nameChanged(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Device::setType(const QString& strtype)
|
||||||
|
{
|
||||||
|
auto type = str2type(strtype);
|
||||||
|
if (d->m_deviceType != type) {
|
||||||
|
d->m_deviceType = type;
|
||||||
|
KdeConnectConfig::instance().setDeviceProperty(d->m_deviceId, QStringLiteral("type"), strtype);
|
||||||
|
Q_EMIT typeChanged(strtype);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
KdeConnectPlugin* Device::plugin(const QString& pluginName) const
|
KdeConnectPlugin* Device::plugin(const QString& pluginName) const
|
||||||
{
|
{
|
||||||
return d->m_plugins[pluginName];
|
return d->m_plugins[pluginName];
|
||||||
|
|
|
@ -36,7 +36,7 @@ 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 type READ type CONSTANT)
|
Q_PROPERTY(QString type READ type NOTIFY typeChanged)
|
||||||
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
||||||
Q_PROPERTY(QString iconName READ iconName CONSTANT)
|
Q_PROPERTY(QString iconName READ iconName CONSTANT)
|
||||||
Q_PROPERTY(QString statusIconName READ statusIconName NOTIFY statusIconNameChanged)
|
Q_PROPERTY(QString statusIconName READ statusIconName NOTIFY statusIconNameChanged)
|
||||||
|
@ -134,6 +134,7 @@ Q_SIGNALS:
|
||||||
Q_SCRIPTABLE void trustedChanged(bool trusted);
|
Q_SCRIPTABLE void trustedChanged(bool trusted);
|
||||||
Q_SCRIPTABLE void pairingError(const QString& error);
|
Q_SCRIPTABLE void pairingError(const QString& error);
|
||||||
Q_SCRIPTABLE void nameChanged(const QString& name);
|
Q_SCRIPTABLE void nameChanged(const QString& name);
|
||||||
|
Q_SCRIPTABLE void typeChanged(const QString& type);
|
||||||
Q_SCRIPTABLE void statusIconNameChanged();
|
Q_SCRIPTABLE void statusIconNameChanged();
|
||||||
|
|
||||||
Q_SCRIPTABLE void hasPairingRequestsChanged(bool hasPairingRequests);
|
Q_SCRIPTABLE void hasPairingRequestsChanged(bool hasPairingRequests);
|
||||||
|
@ -143,6 +144,7 @@ private: //Methods
|
||||||
static QString type2str(DeviceType deviceType);
|
static QString type2str(DeviceType deviceType);
|
||||||
|
|
||||||
void setName(const QString& name);
|
void setName(const QString& name);
|
||||||
|
void setType(const QString& strtype);
|
||||||
QString iconForStatus(bool reachable, bool paired) const;
|
QString iconForStatus(bool reachable, bool paired) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -195,6 +195,10 @@ void KdeConnectConfig::removeTrustedDevice(const QString& deviceId)
|
||||||
// Utility functions to set and get a value
|
// Utility functions to set and get a value
|
||||||
void KdeConnectConfig::setDeviceProperty(const QString& deviceId, const QString& key, const QString& value)
|
void KdeConnectConfig::setDeviceProperty(const QString& deviceId, const QString& key, const QString& value)
|
||||||
{
|
{
|
||||||
|
// do not store values for untrusted devices (it would make them trusted)
|
||||||
|
if (!trustedDevices().contains(deviceId))
|
||||||
|
return;
|
||||||
|
|
||||||
d->m_trustedDevices->beginGroup(deviceId);
|
d->m_trustedDevices->beginGroup(deviceId);
|
||||||
d->m_trustedDevices->setValue(key, value);
|
d->m_trustedDevices->setValue(key, value);
|
||||||
d->m_trustedDevices->endGroup();
|
d->m_trustedDevices->endGroup();
|
||||||
|
|
Loading…
Reference in a new issue