plasma: remove hidden and disabled by default option to show show remaining time

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-04-27 14:59:10 +03:00
parent 2b429f894b
commit ab00b7e964
6 changed files with 0 additions and 90 deletions

View file

@ -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>

View 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() {
@ -218,19 +216,6 @@ Item {
Column {
id: labelsColumn
Components.Label {
height: paintedHeight
width: parent.width
horizontalAlignment: Text.AlignRight
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
@ -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

View 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

View 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

View 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"

View 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);