OSDN Git Service

plasma: remove hidden and disabled by default option to show show remaining time
authorIvailo Monev <xakepa10@gmail.com>
Wed, 27 Apr 2022 11:59:10 +0000 (14:59 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Wed, 27 Apr 2022 11:59:10 +0000 (14:59 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
plasma/applets/batterymonitor/contents/config/main.xml [deleted file]
plasma/applets/batterymonitor/contents/ui/BatteryItem.qml
plasma/applets/batterymonitor/contents/ui/PopupDialog.qml
plasma/applets/batterymonitor/contents/ui/batterymonitor.qml
plasma/dataengines/powermanagement/powermanagementengine.cpp
plasma/dataengines/powermanagement/powermanagementengine.h

diff --git a/plasma/applets/batterymonitor/contents/config/main.xml b/plasma/applets/batterymonitor/contents/config/main.xml
deleted file mode 100644 (file)
index 5e9e31d..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
-      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-      xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
-      http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
-  <kcfgfile name=""/>
-
-  <group name="General">
-    <entry name="showRemainingTime" type="Bool">
-      <default>false</default>
-    </entry>
-  </group>
-
-</kcfg>
index b4902fc..8fc6271 100644 (file)
@@ -40,8 +40,6 @@ Item {
     // UPower seems to set the Present property false when a device is added but not probed yet
     property bool isPresent: model["Plugged in"]
 
-    property int remainingTime
-
     KLocale.Locale { id: locale }
 
     function updateSelection() {
@@ -225,19 +223,6 @@ Item {
                     onPaintedWidthChanged: {
                         if (paintedWidth > parent.width) { parent.width = paintedWidth; }
                     }
-                    // FIXME Bound to AC adapter plugged in, not battery charging, see below
-                    text: pluggedIn ? i18n("Time To Full:") : i18n("Time To Empty:")
-                    visible: remainingTimeLabel.visible
-                    font.pointSize: theme.smallestFont.pointSize
-                    color: "#99"+(theme.textColor.toString().substr(1))
-                }
-                Components.Label {
-                    height: paintedHeight
-                    width: parent.width
-                    horizontalAlignment: Text.AlignRight
-                    onPaintedWidthChanged: {
-                        if (paintedWidth > parent.width) { parent.width = paintedWidth; }
-                    }
                     text: i18n("Capacity:")
                     visible: capacityLabel.visible
                     font.pointSize: theme.smallestFont.pointSize
@@ -270,17 +255,6 @@ Item {
             }
             Column {
                 width: parent.width - labelsColumn.width - parent.spacing * 2
-                Components.Label { // Remaining Time
-                    id: remainingTimeLabel
-                    height: paintedHeight
-                    width: parent.width
-                    elide: Text.ElideRight
-                    // FIXME Uses overall remaining time, not bound to individual battery
-                    text: locale.prettyFormatDuration(dialogItem.remainingTime)
-                    visible: showRemainingTime && model["Is Power Supply"] && model["State"] != "FullyCharged" && text != "" && dialogItem.remainingTime > 0
-                    font.pointSize: theme.smallestFont.pointSize
-                    color: "#99"+(theme.textColor.toString().substr(1))
-                }
                 Components.Label { // Capacity
                     id: capacityLabel
                     height: paintedHeight
index 298929c..a3c6d90 100644 (file)
@@ -32,9 +32,6 @@ FocusScope {
     property alias model: batteryList.model
     property bool pluggedIn
 
-    property int remainingTime
-    property bool showRemainingTime
-
     property bool popupShown // somehow plasmoid.popupShowing isn't working
 
     property int pmSwitchWidth: padding.margins.left + pmSwitch.implicitWidth + padding.margins.right
index 9282963..88db2ab 100644 (file)
@@ -29,22 +29,15 @@ Item {
     property int minimumHeight: dialogItem.actualHeight
     property int maximumHeight: dialogItem.actualHeight
 
-    property bool show_remaining_time: false
-
     LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft
     LayoutMirroring.childrenInherit: true
 
     Component.onCompleted: {
         plasmoid.aspectRatioMode = IgnoreAspectRatio
         updateLogic();
-        plasmoid.addEventListener('ConfigChanged', configChanged);
         plasmoid.popupEvent.connect(popupEventSlot);
     }
 
-    function configChanged() {
-        show_remaining_time = plasmoid.readConfig("showRemainingTime");
-    }
-
     function updateLogic() {
         Logic.updateCumulative();
 
@@ -117,9 +110,6 @@ Item {
         anchors.fill: parent
         focus: true
 
-        showRemainingTime: show_remaining_time
-        remainingTime: Number(pmSource.data["Battery"]["Remaining msec"])
-
         pluggedIn: pmSource.data["AC Adapter"]["Plugged in"]
 
         property int cookie1: -1
index 158d4c5..369d2aa 100644 (file)
@@ -64,17 +64,8 @@ void PowermanagementEngine::init()
     connect(Solid::DeviceNotifier::instance(), SIGNAL(deviceRemoved(QString)),
             this,                              SLOT(deviceRemoved(QString)));
 
-    // FIXME This check doesn't work, connect seems to always return true, hence the hack below
     if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.freedesktop.PowerManagement")) {
         sourceRequestEvent("PowerDevil");
-
-        if (!QDBusConnection::sessionBus().connect("org.freedesktop.PowerManagement",
-                                                   "/org/freedesktop/PowerManagement",
-                                                   "org.freedesktop.PowerManagement",
-                                                   "BatteryRemainingTimeChanged", this,
-                                                   SLOT(batteryRemainingTimeChanged(qulonglong)))) {
-            kDebug() << "error connecting to remaining time changes";
-        }
     }
 }
 
@@ -136,14 +127,6 @@ bool PowermanagementEngine::sourceRequestEvent(const QString &name)
         setData("Battery", "Has Battery", !batterySources.isEmpty());
         if (!batterySources.isEmpty()) {
             setData("Battery", "Sources", batterySources);
-            QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.PowerManagement",
-                                                              "/org/freedesktop/PowerManagement",
-                                                              "org.freedesktop.PowerManagement",
-                                                              "BatteryRemainingTimeChanged");
-            QDBusPendingReply<qulonglong> reply = QDBusConnection::sessionBus().asyncCall(msg);
-            QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
-            QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
-                             this, SLOT(batteryRemainingTimeReply(QDBusPendingCallWatcher*)));
         }
 
         m_sources = basicSourceNames() + batterySources;
@@ -359,24 +342,6 @@ void PowermanagementEngine::deviceAdded(const QString& udi)
     }
 }
 
-void PowermanagementEngine::batteryRemainingTimeChanged(qulonglong time)
-{
-    //kDebug() << "Remaining time 2:" << time;
-    setData("Battery", "Remaining msec", time);
-}
-
-void PowermanagementEngine::batteryRemainingTimeReply(QDBusPendingCallWatcher *watcher)
-{
-    QDBusPendingReply<qulonglong> reply = *watcher;
-    if (reply.isError()) {
-        kDebug() << "Error getting battery remaining time: " << reply.error().message();
-    } else {
-        batteryRemainingTimeChanged(reply.value());
-    }
-
-    watcher->deleteLater();
-}
-
 K_EXPORT_PLASMA_DATAENGINE(powermanagement, PowermanagementEngine)
 
 #include "moc_powermanagementengine.cpp"
index 36542f9..047408d 100644 (file)
@@ -60,8 +60,6 @@ private slots:
 
     void deviceRemoved(const QString& udi);
     void deviceAdded(const QString& udi);
-    void batteryRemainingTimeChanged(qulonglong time);
-    void batteryRemainingTimeReply(QDBusPendingCallWatcher*);
 
 private:
     QString batteryType(const Solid::Battery *battery);