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

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:27:21 UTC 2016


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

The following commit has been merged in the master branch:
commit 776543409d5aac50ededebc48a902a89a103f286
Author: Samoilenko Yuri <kinnalru at gmail.com>
Date:   Fri Jan 31 14:06:21 2014 +0400

    button works
---
 .../kdeconnectdeclarativeplugin.cpp                |  8 ++--
 plasmoid/declarativeplugin/responsewaiter.cpp      | 19 ++++++++--
 plasmoid/declarativeplugin/responsewaiter.h        | 44 ++++++++++++----------
 plasmoid/package/contents/ui/DeviceDelegate.qml    | 40 +++++++++-----------
 4 files changed, 60 insertions(+), 51 deletions(-)

diff --git a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp
index 366d322..9fb0f80 100644
--- a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp
+++ b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp
@@ -43,7 +43,7 @@ QObject* createSftpInterface(QVariant deviceId)
 
 QObject* createDBusResponse()
 {
-    return new DBusResponse();
+    return new DBusAsyncResponse();
 }
 
 void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
@@ -54,7 +54,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
     qmlRegisterType<NotificationsModel>("org.kde.kdeconnect", 1, 0, "NotificationsModel");
     qmlRegisterType<BatteryInterface>("org.kde.kdeconnect", 1, 0, "BatteryInterface");
     
-    qmlRegisterType<DBusResponse>("org.kde.kdeconnect", 1, 0, "DBusResponse");
+    qmlRegisterType<DBusAsyncResponse>("org.kde.kdeconnect", 1, 0, "DBusResponse");
 }
 
 void KdeConnectDeclarativePlugin::initializeEngine(QDeclarativeEngine* engine, const char* uri)
@@ -68,6 +68,6 @@ void KdeConnectDeclarativePlugin::initializeEngine(QDeclarativeEngine* engine, c
     engine->rootContext()->setContextProperty("DBusResponseFactory"
       , new ObjectFactory(engine, createDBusResponse));    
     
-    engine->rootContext()->setContextProperty("ResponseWaiter"
-      , new DBusResponseWaiter());    
+    engine->rootContext()->setContextProperty("DBusResponseWaiter"
+      , DBusResponseWaiter::instance());    
 }
diff --git a/plasmoid/declarativeplugin/responsewaiter.cpp b/plasmoid/declarativeplugin/responsewaiter.cpp
index 2a817c4..b8327a9 100644
--- a/plasmoid/declarativeplugin/responsewaiter.cpp
+++ b/plasmoid/declarativeplugin/responsewaiter.cpp
@@ -15,6 +15,17 @@ Q_DECLARE_METATYPE(QDBusPendingReply<bool>)
 Q_DECLARE_METATYPE(QDBusPendingReply<int>)
 Q_DECLARE_METATYPE(QDBusPendingReply<QString>)
 
+DBusResponseWaiter* DBusResponseWaiter::m_instance = 0;
+
+DBusResponseWaiter* DBusResponseWaiter::instance()
+{
+    if (!m_instance)
+    {
+        m_instance = new DBusResponseWaiter();
+    }
+    return m_instance;
+}
+
 DBusResponseWaiter::DBusResponseWaiter()
     : QObject()
 {
@@ -42,9 +53,9 @@ QVariant DBusResponseWaiter::waitForReply(QVariant variant) const
     return QVariant();
 }
 
-void DBusResponse::setPendingCall(QVariant variant)
+void DBusAsyncResponse::setPendingCall(QVariant variant)
 {
-    if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(DBusResponseWaiter().extractPendingCall(variant)))
+    if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(DBusResponseWaiter::instance()->extractPendingCall(variant)))
     {  
         QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(*call);
         watcher->setProperty("pengingCall", variant);
@@ -54,11 +65,11 @@ void DBusResponse::setPendingCall(QVariant variant)
 }
 
 
-void DBusResponse::onCallFinished(QDBusPendingCallWatcher* watcher)
+void DBusAsyncResponse::onCallFinished(QDBusPendingCallWatcher* watcher)
 {
     QVariant variant = watcher->property("pengingCall");
     
-    if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(DBusResponseWaiter().extractPendingCall(variant)))
+    if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(DBusResponseWaiter::instance()->extractPendingCall(variant)))
     {
         if (call->isError())
         {
diff --git a/plasmoid/declarativeplugin/responsewaiter.h b/plasmoid/declarativeplugin/responsewaiter.h
index 55869f0..ea57370 100644
--- a/plasmoid/declarativeplugin/responsewaiter.h
+++ b/plasmoid/declarativeplugin/responsewaiter.h
@@ -11,15 +11,36 @@
 class QDBusPendingCall;
 class QDBusPendingCallWatcher;
 
-class DBusResponse : public QObject
+class DBusResponseWaiter : public QObject
+{
+    Q_OBJECT
+    
+public:
+  
+    static DBusResponseWaiter* instance();
+  
+    ///extract QDbusPendingCall from \p variant and blocks untill completed
+    Q_INVOKABLE QVariant waitForReply(QVariant variant) const;
+    
+    const QDBusPendingCall* extractPendingCall(QVariant& variant) const;
+  
+private:
+    DBusResponseWaiter();
+    
+    static DBusResponseWaiter* m_instance;
+    QList<int> m_registered;
+};
+
+
+class DBusAsyncResponse : public QObject
 {
     Q_OBJECT
     
     Q_PROPERTY(QVariant pendingCall WRITE setPendingCall)
     
 public:
-    DBusResponse(QObject* parent = 0) : QObject(parent) {}
-    virtual ~DBusResponse() {};
+    DBusAsyncResponse(QObject* parent = 0) : QObject(parent) {}
+    virtual ~DBusAsyncResponse() {};
 
     void setPendingCall(QVariant e);
     
@@ -31,22 +52,5 @@ private Q_SLOTS:
     void onCallFinished(QDBusPendingCallWatcher* watcher);
 };
 
-class DBusResponseWaiter : public QObject
-{
-    Q_OBJECT
-    
-public:
-  
-    DBusResponseWaiter();
-    
-    virtual ~DBusResponseWaiter(){};
-    
-    ///extract QDbusPendingCall from \p variant and blocks untill completed
-    Q_INVOKABLE QVariant waitForReply(QVariant variant) const;
-    
-    const QDBusPendingCall* extractPendingCall(QVariant& variant) const;
-  
-    QList<int> m_registered;
-};
 
 #endif
diff --git a/plasmoid/package/contents/ui/DeviceDelegate.qml b/plasmoid/package/contents/ui/DeviceDelegate.qml
index cf5207c..8851bf8 100644
--- a/plasmoid/package/contents/ui/DeviceDelegate.qml
+++ b/plasmoid/package/contents/ui/DeviceDelegate.qml
@@ -31,13 +31,23 @@ PlasmaComponents.ListItem
 
 
     Component.onCompleted: {
+      
+        sftp.mounted.connect( function() {
+            browse.state = "MOUNTED"
+        })
+        
+        sftp.unmounted.connect( function() {
+          console.log(222)
+            browse.state = "UNMOUNTED"
+        })
+        
         var response = DBusResponseFactory.create()
         response.success.connect( function(result) {
             if (result) {
-                state = "MOUNTED"
+                browse.state = "MOUNTED"
             }
             else {
-                state = "UNMOUNTED"
+                browse.state = "UNMOUNTED"
             }
         })
                         
@@ -62,47 +72,31 @@ PlasmaComponents.ListItem
             
             PlasmaComponents.Button {
                 id: browse
-                text: "Browse"
+                checkable: true
                 state: "UNMOUNTED"
                 
                 onClicked: {
                     if (state == "UNMOUNTED") {
                         state = "MOUNTING"
-                        var response = DBusResponseFactory.create()
-                        response.success.connect( function(result){
-                            if (result) {
-                                state = "MOUNTED"
-                            }
-                            else {
-                                state = "UNMOUNTED"
-                            }
-                        })
-                        
-                        response.error.connect( function(message) {
-                            console.error("Error:" + message)
-                            state = "UNMOUNTED"
-                        })
-                                        
-                        response.pendingCall = sftp.startBrowsing()
+                        sftp.startBrowsing()
                     }
                     else {
                         sftp.umount()
-                        state = "UNMOUNTED"
                     }
                 }
                 
                 states: [
                   State {
                       name: "UNMOUNTED"
-                      PropertyChanges { target: browse; text: "Browse"}
+                      PropertyChanges { target: browse; checked: false; text: "Browse"}
                   },
                   State {
                       name: "MOUNTING"
-                      PropertyChanges { target: browse; text: "Mounting..."}
+                      PropertyChanges { target: browse; checked: true; text: "Mounting..."}
                   },
                   State {
                       name: "MOUNTED"
-                      PropertyChanges { target: browse; text: "Unmount"}
+                      PropertyChanges { target: browse; checked: false; text: "Unmount"}
                   }
               ]
                 

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list