[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:27:22 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=22718a0
The following commit has been merged in the master branch:
commit 22718a0bd93dd6f23a72352e32983e9865dd4e0f
Author: Samoilenko Yuri <kinnalru at gmail.com>
Date: Thu Feb 6 00:37:55 2014 +0400
DeclarativePlugin::BatteryInterface removed
Due to bug occured in QML property access(when object derived from QDBusAbstract interface) C++
part of BatteryPlugin in plasmoid rewritten in pure QML.
BatteryPluginDBusInterface fixed to avoid this bug.
Bug occuring when QML try to access any property of any object derived from
QDBusAvstractInterface - QML engine crashes.
---
kded/plugins/battery/batterydbusinterface.cpp | 3 +-
kded/plugins/battery/batterydbusinterface.h | 9 ++-
plasmoid/declarativeplugin/CMakeLists.txt | 1 -
plasmoid/declarativeplugin/batteryinterface.cpp | 73 -------------------
plasmoid/declarativeplugin/batteryinterface.h | 65 -----------------
.../kdeconnectdeclarativeplugin.cpp | 17 ++++-
plasmoid/package/contents/ui/Battery.qml | 81 ++++++++++++++++++++++
plasmoid/package/contents/ui/DeviceDelegate.qml | 12 ++--
8 files changed, 110 insertions(+), 151 deletions(-)
diff --git a/kded/plugins/battery/batterydbusinterface.cpp b/kded/plugins/battery/batterydbusinterface.cpp
index 4a7ee29..6b760f2 100644
--- a/kded/plugins/battery/batterydbusinterface.cpp
+++ b/kded/plugins/battery/batterydbusinterface.cpp
@@ -37,7 +37,8 @@ void BatteryDbusInterface::updateValues(bool isCharging, int currentCharge)
mIsCharging = isCharging;
mCharge = currentCharge;
- Q_EMIT chargingChange();
+ Q_EMIT stateChanged(mIsCharging);
+ Q_EMIT chargeChanged(mCharge);
}
diff --git a/kded/plugins/battery/batterydbusinterface.h b/kded/plugins/battery/batterydbusinterface.h
index 4de6731..d9f412e 100644
--- a/kded/plugins/battery/batterydbusinterface.h
+++ b/kded/plugins/battery/batterydbusinterface.h
@@ -28,20 +28,19 @@ class BatteryDbusInterface
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.battery")
- Q_PROPERTY( int charge READ charge NOTIFY chargingChange )
- Q_PROPERTY( bool isCharging READ isCharging NOTIFY chargingChange )
public:
explicit BatteryDbusInterface(QObject *parent);
virtual ~BatteryDbusInterface();
- int charge() { return mCharge; }
- bool isCharging() { return mIsCharging; }
+ Q_SCRIPTABLE int charge() { return mCharge; }
+ Q_SCRIPTABLE bool isCharging() { return mIsCharging; }
void updateValues(bool isCharging, int currentCharge);
Q_SIGNALS:
- Q_SCRIPTABLE void chargingChange();
+ Q_SCRIPTABLE void stateChanged(bool charging);
+ Q_SCRIPTABLE void chargeChanged(int charge);
private:
int mCharge;
diff --git a/plasmoid/declarativeplugin/CMakeLists.txt b/plasmoid/declarativeplugin/CMakeLists.txt
index 3b7b5d6..4919d47 100644
--- a/plasmoid/declarativeplugin/CMakeLists.txt
+++ b/plasmoid/declarativeplugin/CMakeLists.txt
@@ -4,7 +4,6 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_BINARY_DIR})
set(kdeconnectdeclarativeplugin_SRC
- batteryinterface.cpp
kdeconnectdeclarativeplugin.cpp
responsewaiter.cpp
)
diff --git a/plasmoid/declarativeplugin/batteryinterface.cpp b/plasmoid/declarativeplugin/batteryinterface.cpp
deleted file mode 100644
index 4b8d0c9..0000000
--- a/plasmoid/declarativeplugin/batteryinterface.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * 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
deleted file mode 100644
index daf1c0d..0000000
--- a/plasmoid/declarativeplugin/batteryinterface.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * 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 7c63a5c..9d8970b 100644
--- a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp
+++ b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp
@@ -35,12 +35,21 @@
Q_EXPORT_PLUGIN2(kdeconnectdeclarativeplugin, KdeConnectDeclarativePlugin);
+QObject* createDeviceDbusInterface(QVariant deviceId)
+{
+ return new DeviceDbusInterface(deviceId.toString());
+}
+
+QObject* createDeviceBatteryDbusInterface(QVariant deviceId)
+{
+ return new DeviceBatteryDbusInterface(deviceId.toString());
+}
+
QObject* createSftpInterface(QVariant deviceId)
{
return new SftpDbusInterface(deviceId.toString());
}
-
QObject* createDBusResponse()
{
return new DBusAsyncResponse();
@@ -60,6 +69,12 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
void KdeConnectDeclarativePlugin::initializeEngine(QDeclarativeEngine* engine, const char* uri)
{
QDeclarativeExtensionPlugin::initializeEngine(engine, uri);
+
+ engine->rootContext()->setContextProperty("DeviceDbusInterfaceFactory"
+ , new ObjectFactory(engine, createDeviceDbusInterface));
+
+ engine->rootContext()->setContextProperty("DeviceBatteryDbusInterfaceFactory"
+ , new ObjectFactory(engine, createDeviceBatteryDbusInterface));
engine->rootContext()->setContextProperty("SftpDbusInterfaceFactory"
, new ObjectFactory(engine, createSftpInterface));
diff --git a/plasmoid/package/contents/ui/Battery.qml b/plasmoid/package/contents/ui/Battery.qml
new file mode 100644
index 0000000..8ccf558
--- /dev/null
+++ b/plasmoid/package/contents/ui/Battery.qml
@@ -0,0 +1,81 @@
+/**
+ * Copyright 2014 Samoilenko Yuri <kinnalru 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/>.
+ */
+
+import QtQuick 1.1
+import org.kde.plasma.core 0.1 as PlasmaCore
+import org.kde.plasma.components 0.1 as PlasmaComponents
+import org.kde.kdeconnect 1.0
+
+QtObject {
+
+ id: root
+
+ property string deviceId: ""
+ property bool available: false
+ property bool state: false
+ property int charge: -1
+ property string displayString: (state) ? ("Charging, " + charge) : ("Discharging, " + charge)
+
+ property variant device: DeviceDbusInterfaceFactory.create(deviceId)
+ property variant battery: null
+
+ property variant nested1: DBusAsyncResponse {
+ id: startupCheck1
+ autoDelete: false
+ onSuccess: state = result
+ }
+
+ property variant nested2: DBusAsyncResponse {
+ id: startupCheck2
+ autoDelete: false
+ onSuccess: charge = result
+ }
+
+ onAvailableChanged: {
+ if (available) {
+ battery = DeviceBatteryDbusInterfaceFactory.create(deviceId)
+
+ battery.stateChanged.connect(function(charging) {root.state = charging})
+ battery.chargeChanged.connect(function(charge) {root.charge = charge})
+
+ startupCheck1.pendingCall = battery.isCharging()
+ startupCheck2.pendingCall = battery.charge()
+ }
+ else {
+ battery = null
+ }
+ }
+
+ function pluginsChanged() {
+ var result = DBusResponseWaiter.waitForReply(device.hasPlugin("kdeconnect_battery"))
+
+ if (result && result != "error") {
+ available = true
+ }
+ else {
+ available = false
+ }
+ }
+
+ Component.onCompleted: {
+ device.pluginsChanged.connect(pluginsChanged)
+ device.pluginsChanged()
+ }
+}
diff --git a/plasmoid/package/contents/ui/DeviceDelegate.qml b/plasmoid/package/contents/ui/DeviceDelegate.qml
index adbe075..cfe6aca 100644
--- a/plasmoid/package/contents/ui/DeviceDelegate.qml
+++ b/plasmoid/package/contents/ui/DeviceDelegate.qml
@@ -90,18 +90,20 @@ PlasmaComponents.ListItem
//Battery
PlasmaComponents.ListItem {
- BatteryInterface {
- id: batteryInterface
- device: root.deviceId
+
+ Battery {
+ id: battery
+ deviceId: root.deviceId
}
+
sectionDelegate: true
- visible: batteryInterface.available
+ visible: battery.available
PlasmaComponents.Label {
//font.bold: true
text: i18n("Battery")
}
PlasmaComponents.Label {
- text: batteryInterface.displayString
+ text: battery.displayString
anchors.right: parent.right
}
}
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list