Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
KDE Connect
Commits
f3656d96
Commit
f3656d96
authored
Aug 02, 2020
by
Richard Liebscher
Browse files
Save changed device name and type
parent
79164ca8
Pipeline
#29408
canceled with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
core/device.cpp
View file @
f3656d96
...
...
@@ -276,7 +276,7 @@ void Device::addLink(const NetworkPacket& identityPacket, DeviceLink* link)
//qCDebug(KDECONNECT_CORE) << "Adding link to" << id() << "via" << link->provider();
setName
(
identityPacket
.
get
<
QString
>
(
QStringLiteral
(
"deviceName"
)));
d
->
m_deviceType
=
str2t
ype
(
identityPacket
.
get
<
QString
>
(
QStringLiteral
(
"deviceType"
)));
setT
ype
(
identityPacket
.
get
<
QString
>
(
QStringLiteral
(
"deviceType"
)));
if
(
d
->
m_deviceLinks
.
contains
(
link
))
{
return
;
...
...
@@ -506,10 +506,21 @@ void Device::setName(const QString& name)
{
if
(
d
->
m_deviceName
!=
name
)
{
d
->
m_deviceName
=
name
;
KdeConnectConfig
::
instance
().
setDeviceProperty
(
d
->
m_deviceId
,
QStringLiteral
(
"name"
),
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
{
return
d
->
m_plugins
[
pluginName
];
...
...
core/device.h
View file @
f3656d96
...
...
@@ -36,7 +36,7 @@ class KDECONNECTCORE_EXPORT Device
{
Q_OBJECT
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
iconName
READ
iconName
CONSTANT
)
Q_PROPERTY
(
QString
statusIconName
READ
statusIconName
NOTIFY
statusIconNameChanged
)
...
...
@@ -134,6 +134,7 @@ Q_SIGNALS:
Q_SCRIPTABLE
void
trustedChanged
(
bool
trusted
);
Q_SCRIPTABLE
void
pairingError
(
const
QString
&
error
);
Q_SCRIPTABLE
void
nameChanged
(
const
QString
&
name
);
Q_SCRIPTABLE
void
typeChanged
(
const
QString
&
type
);
Q_SCRIPTABLE
void
statusIconNameChanged
();
Q_SCRIPTABLE
void
hasPairingRequestsChanged
(
bool
hasPairingRequests
);
...
...
@@ -143,6 +144,7 @@ private: //Methods
static
QString
type2str
(
DeviceType
deviceType
);
void
setName
(
const
QString
&
name
);
void
setType
(
const
QString
&
strtype
);
QString
iconForStatus
(
bool
reachable
,
bool
paired
)
const
;
private:
...
...
core/kdeconnectconfig.cpp
View file @
f3656d96
...
...
@@ -195,6 +195,10 @@ void KdeConnectConfig::removeTrustedDevice(const QString& deviceId)
// Utility functions to set and get a 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
->
setValue
(
key
,
value
);
d
->
m_trustedDevices
->
endGroup
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment