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

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


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

The following commit has been merged in the master branch:
commit 553a6c518e734d72e129ed0d46bf8f090f0d3258
Author: Albert Vaca <albertvaka at gmail.com>
Date:   Fri Nov 15 17:41:33 2013 +0100

    Plasmoid now displays the devices' battery
    
    BUG: 326883
---
 plasmoid/declarativeplugin/CMakeLists.txt          |  2 +
 plasmoid/declarativeplugin/batteryinterface.cpp    | 73 ++++++++++++++++++++++
 plasmoid/declarativeplugin/batteryinterface.h      | 65 +++++++++++++++++++
 .../kdeconnectdeclarativeplugin.cpp                |  2 +
 plasmoid/package/contents/ui/DeviceDelegate.qml    | 29 +++++++--
 plasmoid/package/contents/ui/kdeconnect.qml        | 11 +++-
 6 files changed, 174 insertions(+), 8 deletions(-)

diff --git a/plasmoid/declarativeplugin/CMakeLists.txt b/plasmoid/declarativeplugin/CMakeLists.txt
index ec99225..9e5f10a 100644
--- a/plasmoid/declarativeplugin/CMakeLists.txt
+++ b/plasmoid/declarativeplugin/CMakeLists.txt
@@ -3,8 +3,10 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}
                     ${CMAKE_SOURCE_DIR}
                     ${CMAKE_BINARY_DIR})
 set(kdeconnectdeclarativeplugin_SRC
+    batteryinterface.cpp
     kdeconnectdeclarativeplugin.cpp
 )
+
 kde4_add_library(kdeconnectdeclarativeplugin SHARED ${kdeconnectdeclarativeplugin_SRC})
 add_dependencies(kdeconnectdeclarativeplugin libkdeconnect)
 target_link_libraries(kdeconnectdeclarativeplugin
diff --git a/plasmoid/declarativeplugin/batteryinterface.cpp b/plasmoid/declarativeplugin/batteryinterface.cpp
new file mode 100644
index 0000000..4b8d0c9
--- /dev/null
+++ b/plasmoid/declarativeplugin/batteryinterface.cpp
@@ -0,0 +1,73 @@
+/**
+ * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "batteryinterface.h"
+
+BatteryInterface::BatteryInterface(QObject* parent)
+    : QObject(parent)
+    , m_device(0)
+    , m_battery(0)
+{
+
+}
+
+void BatteryInterface::setDevice(const QString& deviceId)
+{
+    if (m_device) {
+        delete m_device;
+    }
+    m_device = new DeviceDbusInterface(deviceId, this);
+    connect(m_device, SIGNAL(pluginsChanged()), this, SLOT(devicePluginsChanged()));
+    devicePluginsChanged();
+}
+
+void BatteryInterface::devicePluginsChanged()
+{
+    if (m_device->hasPlugin("kdeconnect_battery")) {
+        m_battery = new DeviceBatteryDbusInterface(m_device->id(), this);
+        connect(m_battery, SIGNAL(chargingChange()), this, SIGNAL(infoChanged()));
+        Q_EMIT infoChanged();
+    } else {
+        delete m_battery;
+        m_battery = 0;
+    }
+
+    Q_EMIT availableChanged();
+}
+
+bool BatteryInterface::available() const
+{
+    return m_battery && m_battery->isValid();
+}
+
+QString BatteryInterface::displayString() const
+{
+
+    if (!m_battery) {
+        return i18n("No info");
+    }
+
+    if (isCharging()) {
+        return i18n("Charging, %1%", chargePercent());
+    } else {
+        return i18n("Discharging, %1%", chargePercent());
+    }
+
+}
diff --git a/plasmoid/declarativeplugin/batteryinterface.h b/plasmoid/declarativeplugin/batteryinterface.h
new file mode 100644
index 0000000..daf1c0d
--- /dev/null
+++ b/plasmoid/declarativeplugin/batteryinterface.h
@@ -0,0 +1,65 @@
+/**
+ * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BATTERYINTERFACE_H
+#define BATTERYINTERFACE_H
+
+#include <QObject>
+#include <QString>
+#include <KLocalizedString>
+#include "libkdeconnect/dbusinterfaces.h"
+
+//Wrapper to use it from QML
+class BatteryInterface
+    : public QObject
+{
+    Q_OBJECT
+
+    Q_PROPERTY(QString device READ device WRITE setDevice NOTIFY deviceChanged)
+    Q_PROPERTY(bool available READ available NOTIFY availableChanged)
+    Q_PROPERTY(QString displayString READ displayString NOTIFY infoChanged)
+    //Q_PROPERTY(bool displayString READ isCharging NOTIFY infoChanged)
+    //Q_PROPERTY(int chargePercent READ chargePercent NOTIFY infoChanged)
+
+public:
+    BatteryInterface(QObject* parent = 0);
+    void setDevice(const QString& deviceId);
+    QString device() const { return m_device->id(); }
+
+    bool available() const; //True if the interface is accessible
+
+    QString displayString() const; //Human readable string with the battery status
+    bool isCharging() const { return m_battery->isCharging(); }
+    int chargePercent() const { return m_battery->charge(); }
+
+Q_SIGNALS:
+    void availableChanged();
+    void infoChanged();
+    void deviceChanged();
+
+private:
+    DeviceDbusInterface* m_device;
+    mutable DeviceBatteryDbusInterface* m_battery;
+
+public Q_SLOTS:
+    void devicePluginsChanged();
+};
+
+#endif // BATTERYINTERFACE_H
diff --git a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp
index 94c66ee..bf3c54e 100644
--- a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp
+++ b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp
@@ -24,10 +24,12 @@
 
 #include "libkdeconnect/devicesmodel.h"
 #include "libkdeconnect/notificationsmodel.h"
+#include "batteryinterface.h"
 
 void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
 {
     Q_UNUSED(uri);
     qmlRegisterType<DevicesModel>("org.kde.kdeconnect", 1, 0, "DevicesModel");
     qmlRegisterType<NotificationsModel>("org.kde.kdeconnect", 1, 0, "NotificationsModel");
+    qmlRegisterType<BatteryInterface>("org.kde.kdeconnect", 1, 0, "BatteryInterface");
 }
diff --git a/plasmoid/package/contents/ui/DeviceDelegate.qml b/plasmoid/package/contents/ui/DeviceDelegate.qml
index 0ba38e6..fd5e97b 100644
--- a/plasmoid/package/contents/ui/DeviceDelegate.qml
+++ b/plasmoid/package/contents/ui/DeviceDelegate.qml
@@ -37,12 +37,33 @@ PlasmaComponents.ListItem
             text: display
         }
 
+        //Battery
+        PlasmaComponents.ListItem {
+            BatteryInterface {
+                id: batteryInterface
+                device: root.deviceId
+            }
+            sectionDelegate: true
+            visible: batteryInterface.available
+            PlasmaComponents.Label {
+                //font.bold: true
+                text: i18n("Battery")
+            }
+            PlasmaComponents.Label {
+                text: batteryInterface.displayString
+                anchors.right: parent.right
+            }
+        }
+
         //Notifications
         PlasmaComponents.ListItem {
             visible: notificationsModel.count>0
             enabled: true
             sectionDelegate: true
-            PlasmaComponents.Label { text: i18n("Notifications") }
+            PlasmaComponents.Label {
+                //font.bold: true
+                text: i18n("Notifications")
+            }
             PlasmaComponents.ToolButton {
                 enabled: true
                 visible: notificationsModel.isAnyDimissable;
@@ -79,11 +100,7 @@ PlasmaComponents.ListItem
             //Repeater.onItemAdded: plasmoid.status = "NeedsAttentionStatus";
         }
 
-        //Other information could be here (battery, etc.)
-        /*PlasmaComponents.ListItem {
-            sectionDelegate: true
-            PlasmaComponents.Label { text: "This is some random info about the device" }
-        }*/
+        //TODO: Other information could be displayed here
 
     }
 }
diff --git a/plasmoid/package/contents/ui/kdeconnect.qml b/plasmoid/package/contents/ui/kdeconnect.qml
index 4037a86..889afad 100644
--- a/plasmoid/package/contents/ui/kdeconnect.qml
+++ b/plasmoid/package/contents/ui/kdeconnect.qml
@@ -35,18 +35,25 @@ Item {
     property Component compactRepresentation: CompactRepresentation { }
 
     PlasmaComponents.Label {
-        id: header
         visible: devicesView.count==0
         text: i18n("No paired devices available")
         anchors.fill: parent
         horizontalAlignment: Text.AlignHCenter
     }
 
+    /*
+    //Startup arguments
+    PlasmaComponents.Label {
+        visible: (startupArguments.length > 0)
+        text: (""+startupArguments)
+        anchors.fill: parent
+    }
+    */
+
     PlasmaExtras.ScrollArea {
         id: dialogItem
         anchors.fill: parent
 
-
         flickableItem: ListView {
             id: devicesView
             anchors.fill: parent

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list