diff --git a/applets/batterymonitor/package/contents/config/config.qml b/applets/batterymonitor/package/contents/config/config.qml new file mode 100644 --- /dev/null +++ b/applets/batterymonitor/package/contents/config/config.qml @@ -0,0 +1,30 @@ +/*************************************************************************** + * Copyright 2013 by Sebastian Kügler * + * * + * 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) 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 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 org.kde.plasma.configuration 2.0 + +ConfigModel { + ConfigCategory { + name: i18n("General") + icon: "battery" + source: "ConfigGeneral.qml" + } +} diff --git a/applets/batterymonitor/package/contents/config/main.xml b/applets/batterymonitor/package/contents/config/main.xml new file mode 100644 --- /dev/null +++ b/applets/batterymonitor/package/contents/config/main.xml @@ -0,0 +1,16 @@ + + + + + + + + false + + + + + diff --git a/applets/batterymonitor/package/contents/ui/CompactRepresentation.qml b/applets/batterymonitor/package/contents/ui/CompactRepresentation.qml --- a/applets/batterymonitor/package/contents/ui/CompactRepresentation.qml +++ b/applets/batterymonitor/package/contents/ui/CompactRepresentation.qml @@ -59,27 +59,33 @@ property real iconSize: Math.min(width, height) - Column { + BatteryIcon { + id: batteryIcon anchors.centerIn: parent + hasBattery: batteryContainer.hasBattery + percent: batteryContainer.percent + pluggedIn: batteryContainer.pluggedIn + height: isConstrained ? batteryContainer.iconSize : batteryContainer.iconSize - batteryLabel.height + width: height + } - BatteryIcon { - id: batteryIcon - anchors.horizontalCenter: isConstrained ? undefined : parent.horizontalCenter - hasBattery: batteryContainer.hasBattery - percent: batteryContainer.percent - pluggedIn: batteryContainer.pluggedIn - height: isConstrained ? batteryContainer.iconSize : batteryContainer.iconSize - batteryLabel.height - width: height + Rectangle { + anchors { + right: parent.right + bottom: parent.bottom } - + visible: plasmoid.configuration.showPercentage + color: theme.backgroundColor + width: batteryLabel.width + units.devicePixelRatio * 2 + height: batteryLabel.height + radius: units.devicePixelRatio * 3 Components.Label { id: batteryLabel - width: parent.width - height: visible ? paintedHeight : 0 + anchors.centerIn: parent + height: paintedHeight horizontalAlignment: Text.AlignHCenter text: i18nc("battery percentage below battery icon", "%1%", percent) - font.pixelSize: Math.max(batteryContainer.iconSize/8, theme.mSize(theme.smallestFont).height) - visible: false//!isConstrained() + font.pixelSize: Math.max(batteryIcon.height/8, theme.smallestFont.pointSize) } } } diff --git a/applets/batterymonitor/package/contents/ui/CompactRepresentation.qml b/applets/batterymonitor/package/contents/ui/CompactRepresentationCircle.qml copy from applets/batterymonitor/package/contents/ui/CompactRepresentation.qml copy to applets/batterymonitor/package/contents/ui/CompactRepresentationCircle.qml --- a/applets/batterymonitor/package/contents/ui/CompactRepresentation.qml +++ b/applets/batterymonitor/package/contents/ui/CompactRepresentationCircle.qml @@ -51,37 +51,46 @@ id: batteryContainer property bool hasBattery: view.singleBattery ? view.hasBattery : model["Plugged in"] - property int percent: view.singleBattery ? pmSource.data["Battery"]["Percent"] : model["Percent"] + property int percent: 72//view.singleBattery ? pmSource.data["Battery"]["Percent"] : model["Percent"] property bool pluggedIn: pmSource.data["AC Adapter"] && pmSource.data["AC Adapter"]["Plugged in"] && (view.singleBattery || model["Is Power Supply"]) height: root.itemSize width: root.width/view.count property real iconSize: Math.min(width, height) - Column { - anchors.centerIn: parent - BatteryIcon { - id: batteryIcon - anchors.horizontalCenter: isConstrained ? undefined : parent.horizontalCenter - hasBattery: batteryContainer.hasBattery - percent: batteryContainer.percent - pluggedIn: batteryContainer.pluggedIn - height: isConstrained ? batteryContainer.iconSize : batteryContainer.iconSize - batteryLabel.height - width: height - } + Canvas { + id: canvas + anchors.fill: parent + + onPaint: { + var ctx = getContext("2d"); + ctx.save(); + ctx.clearRect(0,0,canvas.width, canvas.height); - Components.Label { - id: batteryLabel - width: parent.width - height: visible ? paintedHeight : 0 - horizontalAlignment: Text.AlignHCenter - text: i18nc("battery percentage below battery icon", "%1%", percent) - font.pixelSize: Math.max(batteryContainer.iconSize/8, theme.mSize(theme.smallestFont).height) - visible: false//!isConstrained() + var start = -Math.PI/2; + var radians = percent/100 * 2 * Math.PI; + ctx.fillStyle = "transparent" + ctx.strokeStyle = theme.textColor + ctx.lineWidth = units.smallSpacing/2 + ctx.beginPath(); + ctx.arc(width/2, height/2, height/2 - units.smallSpacing, start, radians + start, false); + ctx.stroke(); + ctx.fill(); + ctx.restore(); } } + + Components.Label { + id: batteryLabel + anchors.centerIn: parent + width: parent.width + height: visible ? paintedHeight : 0 + horizontalAlignment: Text.AlignHCenter + text: i18nc("battery percentage in battery icon", "%1%", percent) + font.pixelSize: Math.max(parent.height/4, theme.smallestFont.pixelSize) + } } } } diff --git a/applets/batterymonitor/package/contents/ui/ConfigGeneral.qml b/applets/batterymonitor/package/contents/ui/ConfigGeneral.qml new file mode 100644 --- /dev/null +++ b/applets/batterymonitor/package/contents/ui/ConfigGeneral.qml @@ -0,0 +1,50 @@ +/* + * Copyright 2016 Marco Martin + * + * 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) 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 General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. + */ + +import QtQuick 2.0 +import QtQuick.Controls 1.0 as QtControls +import QtQuick.Layouts 1.0 as QtLayouts + +import org.kde.plasma.core 2.0 as PlasmaCore + +Item { + id: root + + signal configurationChanged + + width: childrenRect.width + height: childrenRect.height + implicitWidth: pageColumn.implicitWidth + implicitHeight: pageColumn.implicitHeight + + property alias cfg_showPercentage: showPercentage.checked + + SystemPalette { + id: palette + } + + QtLayouts.ColumnLayout { + id: pageColumn + anchors.left: parent.left + + QtControls.CheckBox { + id: showPercentage + text: i18n("Show percentage") + } + } +} diff --git a/applets/batterymonitor/package/contents/ui/batterymonitor.qml b/applets/batterymonitor/package/contents/ui/batterymonitor.qml --- a/applets/batterymonitor/package/contents/ui/batterymonitor.qml +++ b/applets/batterymonitor/package/contents/ui/batterymonitor.qml @@ -130,7 +130,6 @@ Component.onCompleted: { Logic.updateBrightness(batterymonitor, pmSource); - plasmoid.removeAction("configure"); Logic.updateInhibitions(batterymonitor, pmSource) if (batterymonitor.kcmsAuthorized) {