Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Weixuan Xiao
kdeconnect-kde
Commits
213e8ea9
Commit
213e8ea9
authored
Jul 02, 2013
by
Albert Vaca Cintora
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed android app bug
parent
669edf8e
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
58 additions
and
31 deletions
+58
-31
daemon/daemon.cpp
daemon/daemon.cpp
+22
-3
daemon/daemon.h
daemon/daemon.h
+1
-0
daemon/devicelinks/devicelink.h
daemon/devicelinks/devicelink.h
+1
-0
kcm/devicesmodel.cpp
kcm/devicesmodel.cpp
+1
-1
kcm/devicesmodel.h
kcm/devicesmodel.h
+2
-1
kcm/kcm.cpp
kcm/kcm.cpp
+25
-19
kcm/kcm.h
kcm/kcm.h
+4
-4
kcm/kcm.ui
kcm/kcm.ui
+2
-2
kcm/wizard.cpp
kcm/wizard.cpp
+0
-1
No files found.
daemon/daemon.cpp
View file @
213e8ea9
...
...
@@ -50,6 +50,12 @@ void Daemon::linkTo(DeviceLink* dl)
pr
,
SLOT
(
receivePackage
(
const
NetworkPackage
&
)));
}
KNotification
*
notification
=
new
KNotification
(
"pingReceived"
);
//KNotification::Persistent
notification
->
setPixmap
(
KIcon
(
"dialog-ok"
).
pixmap
(
48
,
48
));
notification
->
setComponentData
(
KComponentData
(
"kdeconnect"
,
"kdeconnect"
));
notification
->
setTitle
(
dl
->
device
()
->
name
());
notification
->
setText
(
"Succesfully connected"
);
}
Daemon
::
Daemon
(
QObject
*
parent
,
const
QList
<
QVariant
>&
)
...
...
@@ -124,15 +130,28 @@ void Daemon::startDiscovery(int timeOut)
bool
Daemon
::
pairDevice
(
QString
id
)
{
if
(
!
visibleDevices
.
contains
(
id
))
return
false
;
if
(
!
visibleDevices
.
contains
(
id
))
{
return
false
;
}
config
->
group
(
"devices"
).
group
(
"paired"
).
group
(
id
).
writeEntry
(
"name"
,
visibleDevices
[
id
]
->
device
()
->
name
());
linkTo
(
visibleDevices
[
id
]);
return
true
;
}
bool
Daemon
::
unpairDevice
(
QString
id
)
{
/*qDebug() << "M'han passat" << id;
foreach(QString c, config->group("devices").group("paired").groupList()) {
qDebug() << "Tinc" << c;
}*/
if
(
!
config
->
group
(
"devices"
).
group
(
"paired"
).
hasGroup
(
id
))
{
return
false
;
}
config
->
group
(
"devices"
).
group
(
"paired"
).
deleteGroup
(
id
);
return
true
;
}
QString
Daemon
::
listLinkedDevices
()
{
QString
ret
;
...
...
daemon/daemon.h
View file @
213e8ea9
...
...
@@ -66,6 +66,7 @@ public Q_SLOTS:
Q_SCRIPTABLE
QString
listVisibleDevices
();
Q_SCRIPTABLE
bool
pairDevice
(
QString
id
);
Q_SCRIPTABLE
bool
unpairDevice
(
QString
id
);
/*
Q_SCRIPTABLE QString listPairedDevices(QString id);
...
...
daemon/devicelinks/devicelink.h
View file @
213e8ea9
...
...
@@ -33,6 +33,7 @@ class DeviceLink
Q_OBJECT
public:
//TODO: Add QObject* parent
DeviceLink
(
Device
*
d
);
Device
*
device
()
{
return
mDevice
;
}
...
...
kcm/devicesmodel.cpp
View file @
213e8ea9
...
...
@@ -27,7 +27,7 @@
#include <KConfigGroup>
DevicesModel
::
DevicesModel
(
QObject
*
parent
)
:
QAbstract
Item
Model
(
parent
)
:
QAbstract
List
Model
(
parent
)
{
}
...
...
kcm/devicesmodel.h
View file @
213e8ea9
...
...
@@ -25,11 +25,12 @@
#include <QAbstractItemModel>
#include <QAbstractListModel>
#include <QPixmap>
#include <QList>
class
DevicesModel
:
public
QAbstract
Item
Model
:
public
QAbstract
List
Model
{
public:
enum
ModelRoles
{
...
...
kcm/kcm.cpp
View file @
213e8ea9
...
...
@@ -41,27 +41,27 @@ K_EXPORT_PLUGIN(KdeConnectKcmFactory("kdeconnect-kcm", "kdeconnect-kcm"))
KdeConnectKcm
::
KdeConnectKcm
(
QWidget
*
parent
,
const
QVariantList
&
)
:
KCModule
(
KdeConnectKcmFactory
::
componentData
(),
parent
)
,
kcmUi
(
new
Ui
::
KdeConnectKcmUi
())
,
dbusInterface
(
this
)
,
pairedDevicesList
(
this
)
,
addDeviceWizard
(
this
)
,
m_
dbusInterface
(
new
DaemonDbusInterface
(
this
)
)
,
pairedDevicesList
(
new
DevicesModel
(
this
)
)
,
addDeviceWizard
(
new
AddDeviceWizard
(
this
)
)
,
config
(
KSharedConfig
::
openConfig
(
"kdeconnectrc"
))
{
config
->
group
(
"devices"
).
group
(
"paired"
).
group
(
"123456"
).
writeEntry
(
"name"
,
"Ultra-fake device"
);
config
->
group
(
"devices"
).
group
(
"paired"
).
group
(
"987654"
).
writeEntry
(
"name"
,
"Ultra-fake device"
);
pairedDevicesList
.
loadPaired
();
pairedDevicesList
->
loadPaired
();
kcmUi
->
setupUi
(
this
);
//config->group("devices").group("paired").group("123456").writeEntry("name","Ultra-fake device");
//config->group("devices").group("paired").group("987654").writeEntry("name","Ultra-fake device");
//pairedDevicesList.updateFromConfig();
kcmUi
->
deviceList
->
setIconSize
(
QSize
(
32
,
32
));
kcmUi
->
deviceList
->
setModel
(
&
pairedDevicesList
);
kcmUi
->
deviceList
->
setModel
(
pairedDevicesList
);
connect
(
kcmUi
->
addButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
addButtonClicked
()));
connect
(
kcmUi
->
removeButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
removeButtonClicked
()));
connect
(
&
addDeviceWizard
,
SIGNAL
(
deviceAdded
(
QString
,
QString
)),
this
,
SLOT
(
deviceAdded
(
QString
,
QString
)));
connect
(
kcmUi
->
deviceList
,
SIGNAL
(
pressed
(
QModelIndex
)),
this
,
SLOT
(
deviceSelected
(
QModelIndex
)));
connect
(
addDeviceWizard
,
SIGNAL
(
deviceAdded
(
QString
,
QString
)),
this
,
SLOT
(
deviceAdded
(
QString
,
QString
)));
}
KdeConnectKcm
::~
KdeConnectKcm
()
...
...
@@ -71,28 +71,34 @@ KdeConnectKcm::~KdeConnectKcm()
void
KdeConnectKcm
::
addButtonClicked
()
{
addDeviceWizard
.
show
();
addDeviceWizard
->
show
();
}
void
KdeConnectKcm
::
removeButtonClicked
()
{
QModelIndex
selectedIndex
=
kcmUi
->
deviceList
->
currentIndex
();
if
(
selectedIndex
.
isValid
()
&&
selectedIndex
.
row
()
>=
0
&&
selectedIndex
.
row
()
<
pairedDevicesList
->
rowCount
())
{
QString
id
=
pairedDevicesList
->
data
(
selectedIndex
,
DevicesModel
::
IdModelRole
).
toString
();
if
(
m_dbusInterface
->
unpairDevice
(
id
))
{;
pairedDevicesList
->
loadPaired
();
}
}
}
void
KdeConnectKcm
::
deviceAdded
(
QString
id
,
QString
name
)
{
if
(
m_dbusInterface
->
pairDevice
(
id
))
{
qDebug
()
<<
"Succesfully paired: "
+
id
;
pairedDevicesList
->
loadPaired
();
}
//TODO: Do not use kconf directly but talk to daemon
dbusInterface
.
pairDevice
(
id
);
pairedDevicesList
.
loadPaired
();
}
void
KdeConnectKcm
::
currentChang
ed
(
const
QModelIndex
&
current
,
const
QModelIndex
&
previous
)
void
KdeConnectKcm
::
deviceSelect
ed
(
const
QModelIndex
&
current
)
{
qDebug
()
<<
"PENIS"
;
kcmUi
->
removeButton
->
setEnabled
(
current
.
isValid
());
}
#include "kcm.moc"
kcm/kcm.h
View file @
213e8ea9
...
...
@@ -52,14 +52,14 @@ public:
private
Q_SLOTS
:
void
addButtonClicked
();
void
removeButtonClicked
();
void
currentChang
ed
(
const
QModelIndex
&
current
,
const
QModelIndex
&
previous
);
void
deviceSelect
ed
(
const
QModelIndex
&
current
);
void
deviceAdded
(
QString
id
,
QString
name
);
private:
Ui
::
KdeConnectKcmUi
*
kcmUi
;
DaemonDbusInterface
dbusInterface
;
DevicesModel
pairedDevicesList
;
AddDeviceWizard
addDeviceWizard
;
DaemonDbusInterface
*
m_
dbusInterface
;
DevicesModel
*
pairedDevicesList
;
AddDeviceWizard
*
addDeviceWizard
;
KSharedConfigPtr
config
;
};
...
...
kcm/kcm.ui
View file @
213e8ea9
...
...
@@ -62,7 +62,7 @@
<item>
<widget
class=
"QPushButton"
name=
"addButton"
>
<property
name=
"text"
>
<string
/
>
<string
>
Add
</string
>
</property>
<property
name=
"icon"
>
<iconset
theme=
"list-add"
>
...
...
@@ -77,7 +77,7 @@
<bool>
false
</bool>
</property>
<property
name=
"text"
>
<string
/
>
<string
>
Remove
</string
>
</property>
<property
name=
"icon"
>
<iconset
theme=
"list-remove"
>
...
...
kcm/wizard.cpp
View file @
213e8ea9
...
...
@@ -54,7 +54,6 @@ AddDeviceWizard::AddDeviceWizard(QWidget* parent)
void
AddDeviceWizard
::
wizardFinished
()
{
if
(
selectedIndex
.
isValid
()
&&
selectedIndex
.
row
()
>=
0
&&
selectedIndex
.
row
()
<
discoveredDevicesList
->
rowCount
())
{
QString
name
=
discoveredDevicesList
->
data
(
selectedIndex
,
DevicesModel
::
NameModelRole
).
toString
();
QString
id
=
discoveredDevicesList
->
data
(
selectedIndex
,
DevicesModel
::
IdModelRole
).
toString
();
...
...
Write
Preview
Markdown
is supported
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