[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:26:39 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=213e8ea

The following commit has been merged in the master branch:
commit 213e8ea9ad96dad17de3666bb70073ebee2fa6e0
Author: Albert Vaca <albertvaka at gmail.com>
Date:   Tue Jul 2 15:22:05 2013 +0200

    Fixed android app bug
---
 daemon/daemon.cpp               | 25 ++++++++++++++++++++---
 daemon/daemon.h                 |  1 +
 daemon/devicelinks/devicelink.h |  1 +
 kcm/devicesmodel.cpp            |  2 +-
 kcm/devicesmodel.h              |  3 ++-
 kcm/kcm.cpp                     | 44 +++++++++++++++++++++++------------------
 kcm/kcm.h                       |  8 ++++----
 kcm/kcm.ui                      |  4 ++--
 kcm/wizard.cpp                  |  1 -
 9 files changed, 58 insertions(+), 31 deletions(-)

diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp
index 9148525..46c2ac2 100644
--- a/daemon/daemon.cpp
+++ b/daemon/daemon.cpp
@@ -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;
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 37c4dc0..532f7c3 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -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);
diff --git a/daemon/devicelinks/devicelink.h b/daemon/devicelinks/devicelink.h
index c6959cd..670fa08 100644
--- a/daemon/devicelinks/devicelink.h
+++ b/daemon/devicelinks/devicelink.h
@@ -33,6 +33,7 @@ class DeviceLink
     Q_OBJECT
 
 public:
+    //TODO: Add QObject* parent
     DeviceLink(Device* d);
 
     Device* device() { return mDevice; }
diff --git a/kcm/devicesmodel.cpp b/kcm/devicesmodel.cpp
index c186501..e7c4bf0 100644
--- a/kcm/devicesmodel.cpp
+++ b/kcm/devicesmodel.cpp
@@ -27,7 +27,7 @@
 #include <KConfigGroup>
 
 DevicesModel::DevicesModel(QObject *parent)
-    : QAbstractItemModel(parent)
+    : QAbstractListModel(parent)
 {
 
 }
diff --git a/kcm/devicesmodel.h b/kcm/devicesmodel.h
index 531d02f..e153a0f 100644
--- a/kcm/devicesmodel.h
+++ b/kcm/devicesmodel.h
@@ -25,11 +25,12 @@
 
 
 #include <QAbstractItemModel>
+#include <QAbstractListModel>
 #include <QPixmap>
 #include <QList>
 
 class DevicesModel
-    : public QAbstractItemModel
+    : public QAbstractListModel
 {
 public:
     enum ModelRoles {
diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp
index 8f7c7ce..f3715ff 100644
--- a/kcm/kcm.cpp
+++ b/kcm/kcm.cpp
@@ -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)
 {
-    qDebug() << "Succesfully paired: " + id;
+    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::currentChanged(const QModelIndex& current, const QModelIndex& previous)
+void KdeConnectKcm::deviceSelected(const QModelIndex& current)
 {
-
+    qDebug() << "PENIS";
+    kcmUi->removeButton->setEnabled(current.isValid());
 }
 
 
-#include "kcm.moc"
diff --git a/kcm/kcm.h b/kcm/kcm.h
index 9c66b2d..3d875cf 100644
--- a/kcm/kcm.h
+++ b/kcm/kcm.h
@@ -52,14 +52,14 @@ public:
 private Q_SLOTS:
     void addButtonClicked();
     void removeButtonClicked();
-    void currentChanged(const QModelIndex& current, const QModelIndex& previous);
+    void deviceSelected(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;
 
 };
diff --git a/kcm/kcm.ui b/kcm/kcm.ui
index e8b0261..2d64cd0 100644
--- a/kcm/kcm.ui
+++ b/kcm/kcm.ui
@@ -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">
diff --git a/kcm/wizard.cpp b/kcm/wizard.cpp
index 4707d30..4ef0ad0 100644
--- a/kcm/wizard.cpp
+++ b/kcm/wizard.cpp
@@ -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();

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list