mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
Remove clone of battery monitor from plasma-phone-components
Summary: Clone of battery monitor was done for two reasons, - Showing only single battery instead of 3 dummy - Simplified user interface instead of one in desktop However upon investigation battery monitor showing 3 dummy battery is possibly bug in upower, and those needs to be blacklisted in either, powermanagement dataengine or battery monitor. And as for simplifying the user interface, I guess desktop battery monitor should adapt based on platform it is being used in. Reviewers: broulik, mart, #plasma, graesslin Reviewed By: #plasma, graesslin Subscribers: plasma-devel Differential Revision: https://phabricator.kde.org/D2411
This commit is contained in:
parent
c26c6a1bdf
commit
b536182f01
7 changed files with 1 additions and 420 deletions
|
|
@ -1,5 +1,2 @@
|
||||||
|
|
||||||
plasma_install_package(clock org.kde.phone.clock)
|
plasma_install_package(clock org.kde.phone.clock)
|
||||||
plasma_install_package(notifications org.kde.phone.notifications)
|
plasma_install_package(notifications org.kde.phone.notifications)
|
||||||
|
|
||||||
add_subdirectory(battery)
|
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
plasma_install_package(package org.kde.plasma.phone.battery)
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
#! /usr/bin/env bash
|
|
||||||
$EXTRACTRC `find . -name \*.rc -o -name \*.ui -o -name \*.kcfg` >> rc.cpp
|
|
||||||
$XGETTEXT `find . -name \*.js -o -name \*.qml -o -name \*.cpp` -o $podir/plasma_applet_org.kde.plasma.phone.battery.pot
|
|
||||||
rm -f rc.cpp
|
|
||||||
|
|
@ -1,197 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2011 Sebastian Kügler <sebas@kde.org>
|
|
||||||
* Copyright 2011 Viranch Mehta <viranch.mehta@gmail.com>
|
|
||||||
* Copyright 2013-2015 Kai Uwe Broulik <kde@privat.broulik.de>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* 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 Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
import QtQuick.Layouts 1.1
|
|
||||||
|
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
||||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
|
||||||
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
|
||||||
import org.kde.kquickcontrolsaddons 2.0
|
|
||||||
import org.kde.plasma.workspace.components 2.0
|
|
||||||
|
|
||||||
FocusScope {
|
|
||||||
id: dialog
|
|
||||||
focus: true
|
|
||||||
|
|
||||||
//property alias model: batteryList.model
|
|
||||||
property bool pluggedIn
|
|
||||||
|
|
||||||
property int remainingTime
|
|
||||||
|
|
||||||
property bool isBrightnessAvailable: false // FIXME: brightness...
|
|
||||||
|
|
||||||
property QtObject model: pmSource.data["Battery0"]
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
// setup handler on slider value manually to avoid change on creation
|
|
||||||
|
|
||||||
brightnessSlider.valueChanged.connect(function() {
|
|
||||||
batterymonitor.screenBrightness = brightnessSlider.value
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Column {
|
|
||||||
id: settingsColumn
|
|
||||||
anchors.fill: parent
|
|
||||||
spacing: Math.round(units.gridUnit / 2)
|
|
||||||
|
|
||||||
PlasmaComponents.Label {
|
|
||||||
// this is just for metrics, TODO use TextMetrics in 5.4 instead
|
|
||||||
id: percentageMeasurementLabel
|
|
||||||
text: i18nc("Used for measurement", "100%")
|
|
||||||
visible: false
|
|
||||||
}
|
|
||||||
RowLayout {
|
|
||||||
id: infoRow
|
|
||||||
width: parent.width
|
|
||||||
spacing: units.gridUnit
|
|
||||||
|
|
||||||
BatteryIcon {
|
|
||||||
id: batteryIcon
|
|
||||||
Layout.alignment: Qt.AlignTop
|
|
||||||
width: units.iconSizes.large
|
|
||||||
height: width
|
|
||||||
batteryType: model["Type"]
|
|
||||||
percent: pmSource.data["Battery0"]["Percent"]
|
|
||||||
hasBattery: true
|
|
||||||
pluggedIn: pmSource.data["Battery0"]["State"] === "Charging"
|
|
||||||
}
|
|
||||||
|
|
||||||
Column {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.alignment: Qt.AlignTop
|
|
||||||
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
width: parent.width
|
|
||||||
height: units.gridUnit
|
|
||||||
spacing: units.smallSpacing
|
|
||||||
|
|
||||||
// Rectangle {
|
|
||||||
// color: "blue"
|
|
||||||
// opacity: 0.4
|
|
||||||
// anchors.fill: parent
|
|
||||||
// }
|
|
||||||
|
|
||||||
PlasmaComponents.Label {
|
|
||||||
id: batteryNameLabel
|
|
||||||
Layout.fillWidth: true
|
|
||||||
height: implicitHeight
|
|
||||||
elide: Text.ElideRight
|
|
||||||
text: model["Pretty Name"]
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Label {
|
|
||||||
text: stringForBatteryState(pmSource.data["Battery0"])
|
|
||||||
height: implicitHeight
|
|
||||||
//visible: model["Is Power Supply"]
|
|
||||||
opacity: 0.6
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Label {
|
|
||||||
id: batteryPercent
|
|
||||||
height: paintedHeight
|
|
||||||
horizontalAlignment: Text.AlignRight
|
|
||||||
//visible: batteryItem.isPresent
|
|
||||||
text: i18nc("Placeholder is battery percentage", "%1%", pmSource.data["Battery"]["Percent"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.ProgressBar {
|
|
||||||
width: parent.width
|
|
||||||
minimumValue: 0
|
|
||||||
maximumValue: 100
|
|
||||||
visible: model["Plugged in"]
|
|
||||||
value: Number(pmSource.data["Battery0"]["Percent"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
|
|
||||||
visible: isBrightnessAvailable
|
|
||||||
|
|
||||||
property alias icon: brightnessIcon.source
|
|
||||||
property alias label: brightnessLabel.text
|
|
||||||
property alias value: brightnessSlider.value
|
|
||||||
property alias maximumValue: brightnessSlider.maximumValue
|
|
||||||
width: parent.width
|
|
||||||
|
|
||||||
// KeyNavigation.tab: keyboardBrightnessSlider
|
|
||||||
// KeyNavigation.backtab: batteryList
|
|
||||||
|
|
||||||
// Manually dragging the slider around breaks the binding
|
|
||||||
spacing: units.gridUnit
|
|
||||||
|
|
||||||
PlasmaCore.IconItem {
|
|
||||||
id: brightnessIcon
|
|
||||||
source: "video-display-brightness"
|
|
||||||
Layout.alignment: Qt.AlignTop
|
|
||||||
width: units.iconSizes.medium
|
|
||||||
height: width
|
|
||||||
}
|
|
||||||
|
|
||||||
Column {
|
|
||||||
id: brightnessColumn
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.alignment: Qt.AlignTop
|
|
||||||
spacing: 0
|
|
||||||
|
|
||||||
PlasmaComponents.Label {
|
|
||||||
id: brightnessLabel
|
|
||||||
width: parent.width
|
|
||||||
height: paintedHeight
|
|
||||||
text: i18n("Screen Brightness")
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.Slider {
|
|
||||||
id: brightnessSlider
|
|
||||||
width: parent.width
|
|
||||||
// Don't allow the slider to turn off the screen
|
|
||||||
// Please see https://git.reviewboard.kde.org/r/122505/ for more information
|
|
||||||
value: batterymonitor.screenBrightness
|
|
||||||
minimumValue: maximumValue > 100 ? 1 : 0
|
|
||||||
maximumValue: batterymonitor.maximumScreenBrightness
|
|
||||||
stepSize: 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Connections {
|
|
||||||
target: batterymonitor
|
|
||||||
onScreenBrightnessChanged: brightnessSlider.value = batterymonitor.screenBrightness
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
PlasmaExtras.Heading {
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
leftMargin: -Math.round(units.gridUnit / 2)
|
|
||||||
right: parent.right
|
|
||||||
}
|
|
||||||
level: 3
|
|
||||||
opacity: 0.6
|
|
||||||
visible: !isBrightnessAvailable
|
|
||||||
text: i18n("Changing screen brightness is not supported")
|
|
||||||
wrapMode: Text.Wrap
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,190 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2011, 2015 Sebastian Kügler <sebas@kde.org>
|
|
||||||
* Copyright 2011 Viranch Mehta <viranch.mehta@gmail.com>
|
|
||||||
* Copyright 2013-2015 Kai Uwe Broulik <kde@privat.broulik.de>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* 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 Library General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQuick 2.2
|
|
||||||
import QtQuick.Layouts 1.1
|
|
||||||
import org.kde.plasma.plasmoid 2.0
|
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
||||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
|
||||||
import org.kde.plasma.workspace.components 2.0
|
|
||||||
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: batterymonitor
|
|
||||||
width: units.gridUnit * 11
|
|
||||||
height: units.gridUnit * 11
|
|
||||||
Plasmoid.switchWidth: units.gridUnit * 10
|
|
||||||
Plasmoid.switchHeight: units.gridUnit * 10
|
|
||||||
|
|
||||||
LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft
|
|
||||||
LayoutMirroring.childrenInherit: true
|
|
||||||
|
|
||||||
property bool disableBrightnessUpdate: false
|
|
||||||
|
|
||||||
property int screenBrightness
|
|
||||||
readonly property int maximumScreenBrightness: pmSource.data["PowerDevil"] ? pmSource.data["PowerDevil"]["Maximum Screen Brightness"] || 0 : 0
|
|
||||||
|
|
||||||
|
|
||||||
onScreenBrightnessChanged: {
|
|
||||||
if (disableBrightnessUpdate) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var service = pmSource.serviceForSource("PowerDevil");
|
|
||||||
var operation = service.operationDescription("setBrightness");
|
|
||||||
operation.brightness = screenBrightness;
|
|
||||||
// show OSD only when the plasmoid isn't expanded since the moving slider is feedback enough
|
|
||||||
operation.silent = plasmoid.expanded
|
|
||||||
service.startOperationCall(operation);
|
|
||||||
}
|
|
||||||
|
|
||||||
function action_powerdevilkcm() {
|
|
||||||
// FIXME: replace
|
|
||||||
KCMShell.open(["powerdevilprofilesconfig", "powerdevilactivitiesconfig", "powerdevilglobalconfig"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateBrightness(rootItem, source) {
|
|
||||||
if (!source.data["PowerDevil"]) {
|
|
||||||
print("No powerdevil");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we don't want passive brightness change send setBrightness call
|
|
||||||
rootItem.disableBrightnessUpdate = true;
|
|
||||||
|
|
||||||
if (typeof source.data["PowerDevil"]["Screen Brightness"] === 'number') {
|
|
||||||
rootItem.screenBrightness = source.data["PowerDevil"]["Screen Brightness"];
|
|
||||||
}
|
|
||||||
rootItem.disableBrightnessUpdate = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
updateBrightness(batterymonitor, pmSource);
|
|
||||||
plasmoid.removeAction("configure");
|
|
||||||
plasmoid.setAction("powerdevilkcm", i18n("&Configure Power Saving..."), "preferences-system-power-management");
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateLogic() {
|
|
||||||
plasmoid.status = plasmoidStatus();
|
|
||||||
// Logic.updateTooltip(batterymonitor.remainingTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
function stringForBatteryState(batteryData) {
|
|
||||||
if (batteryData["Plugged in"]) {
|
|
||||||
switch(batteryData["State"]) {
|
|
||||||
case "NoCharge": return i18n("Not Charging");
|
|
||||||
case "Discharging": return i18n("Discharging");
|
|
||||||
case "FullyCharged": return i18n("Fully Charged");
|
|
||||||
default: return i18n("Charging");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return i18nc("Battery is currently not present in the bay","Not present");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function plasmoidStatus() {
|
|
||||||
var status = PlasmaCore.Types.PassiveStatus;
|
|
||||||
if (powermanagementDisabled) {
|
|
||||||
status = PlasmaCore.Types.ActiveStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pmSource.data["Battery"]["Has Cumulative"]) {
|
|
||||||
if (pmSource.data["Battery"]["State"] !== "Charging" && pmSource.data["Battery"]["Percent"] <= 5) {
|
|
||||||
status = PlasmaCore.Types.NeedsAttentionStatus
|
|
||||||
} else if (pmSource.data["Battery"]["State"] !== "FullyCharged") {
|
|
||||||
status = PlasmaCore.Types.ActiveStatus
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
Plasmoid.compactRepresentation: MouseArea {
|
|
||||||
Layout.minimumWidth: batteryLayout.implicitWidth
|
|
||||||
Layout.minimumHeight: batteryLayout.implicitHeight
|
|
||||||
|
|
||||||
property bool wasExpanded: false
|
|
||||||
onPressed: {
|
|
||||||
if (mouse.button == Qt.LeftButton) {
|
|
||||||
wasExpanded = plasmoid.expanded;
|
|
||||||
} else if (mouse.button == Qt.MiddleButton) {
|
|
||||||
muteVolume();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
if (mouse.button == Qt.LeftButton) {
|
|
||||||
plasmoid.expanded = !wasExpanded;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RowLayout {
|
|
||||||
id: batteryLayout
|
|
||||||
anchors.fill: parent
|
|
||||||
spacing: -10
|
|
||||||
PlasmaComponents.Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: true
|
|
||||||
font.pixelSize: theme.smallestFont.pixelSize
|
|
||||||
text: pmSource.data["Battery"]["Percent"]
|
|
||||||
horizontalAlignment: Text.AlignRight
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
}
|
|
||||||
BatteryIcon {
|
|
||||||
id: batteryIcon
|
|
||||||
Layout.minimumWidth: height
|
|
||||||
Layout.maximumWidth: height
|
|
||||||
Layout.fillHeight: true
|
|
||||||
hasBattery: true
|
|
||||||
percent: pmSource.data["Battery"]["Percent"]
|
|
||||||
pluggedIn: pmSource.data["Battery"]["State"] == "Charging"
|
|
||||||
//FIXME: AC Adapter is not present there
|
|
||||||
//pmSource.data["AC Adapter"]["Plugged in"]
|
|
||||||
// height: batteryContainer.iconSize
|
|
||||||
// width: height
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Plasmoid.fullRepresentation: ExpandedRepresentation {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
property QtObject pmSource: PlasmaCore.DataSource {
|
|
||||||
id: pmSource
|
|
||||||
engine: "powermanagement"
|
|
||||||
connectedSources: sources
|
|
||||||
onSourceAdded: {
|
|
||||||
disconnectSource(source);
|
|
||||||
connectSource(source);
|
|
||||||
}
|
|
||||||
onSourceRemoved: {
|
|
||||||
disconnectSource(source);
|
|
||||||
}
|
|
||||||
/* FIXME: Brightness-related, but needs support lower in the stack first
|
|
||||||
onDataChanged: {
|
|
||||||
updateBrightness(batterymonitor, pmSource)
|
|
||||||
}
|
|
||||||
Component.onCompleted: {
|
|
||||||
print("Connecting powerdevil");
|
|
||||||
connectSource("PowerDevil");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
[Desktop Entry]
|
|
||||||
Name=Battery and Brightness
|
|
||||||
Comment=See the power status of your device
|
|
||||||
Encoding=UTF-8
|
|
||||||
Keywords=Power Management;Battery;System;Energy;Device;
|
|
||||||
Icon=battery
|
|
||||||
Type=Service
|
|
||||||
X-KDE-ServiceTypes=Plasma/Applet,Plasma/PopupApplet
|
|
||||||
X-Plasma-API=declarativeappletscript
|
|
||||||
|
|
||||||
X-Plasma-MainScript=ui/battery.qml
|
|
||||||
X-Plasma-NotificationArea=true
|
|
||||||
X-Plasma-Provides=org.kde.plasma.powermanagement
|
|
||||||
|
|
||||||
X-KDE-PluginInfo-Author=Sebastian Kügler
|
|
||||||
X-KDE-PluginInfo-Category=System Information
|
|
||||||
X-KDE-PluginInfo-Email=sebas@kde.org
|
|
||||||
X-KDE-PluginInfo-License=GPL
|
|
||||||
X-KDE-PluginInfo-Name=org.kde.plasma.phone.battery
|
|
||||||
X-KDE-PluginInfo-Version=1.0
|
|
||||||
X-KDE-PluginInfo-Website=http://vizZzion.org
|
|
||||||
X-KDE-PluginInfo-Depends=
|
|
||||||
X-KDE-PluginInfo-EnabledByDefault=true
|
|
||||||
X-Plasma-DBusActivationService=org.kde.Solid.PowerManagement
|
|
||||||
|
|
@ -14,7 +14,7 @@ desktopsArray[0].addWidget("org.kde.plasma.analogclock");
|
||||||
var panel = new Panel("org.kde.phone.panel");
|
var panel = new Panel("org.kde.phone.panel");
|
||||||
panel.addWidget("org.kde.plasma.notifications");
|
panel.addWidget("org.kde.plasma.notifications");
|
||||||
panel.addWidget("org.kde.plasma.networkmanagement");
|
panel.addWidget("org.kde.plasma.networkmanagement");
|
||||||
panel.addWidget("org.kde.plasma.phone.battery");
|
panel.addWidget("org.kde.plasma.battery");
|
||||||
panel.addWidget("org.kde.plasma.volume");
|
panel.addWidget("org.kde.plasma.volume");
|
||||||
panel.height = 60;
|
panel.height = 60;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue