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 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 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/BadgeOverlay.qml b/applets/batterymonitor/package/contents/ui/BadgeOverlay.qml new file mode 100644 --- /dev/null +++ b/applets/batterymonitor/package/contents/ui/BadgeOverlay.qml @@ -0,0 +1,55 @@ +/*************************************************************************** + * Copyright (C) 2016 Kai Uwe Broulik * + * Copyright (C) 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 02110-1301 USA . * + ***************************************************************************/ + +import QtQuick 2.4 +import QtGraphicalEffects 1.0 +import org.kde.plasma.components 2.0 as PlasmaComponents + +Item { + property alias text: label.text + property Item icon + + Rectangle { + id: badgeRect + anchors { + right: parent.right + bottom: parent.bottom + } + color: theme.backgroundColor + width: label.width + units.devicePixelRatio * 2 + height: label.height + radius: units.devicePixelRatio * 3 + + PlasmaComponents.Label { + id: label + anchors.centerIn: parent + height: paintedHeight + font.pixelSize: Math.max(icon.height/4, theme.smallestFont.pixelSize*0.8) + } + } + layer.enabled: true + layer.effect: DropShadow { + horizontalOffset: 0 + verticalOffset: 0 + radius: units.devicePixelRatio * 2 + samples: radius*2 + color: Qt.rgba(0, 0, 0, 0.5) + } +} 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,28 +59,21 @@ 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 - } - - 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() - } + BadgeOverlay { + anchors.fill: batteryIcon + text: i18nc("battery percentage below battery icon", "%1%", percent) + icon: batteryIcon + visible: plasmoid.configuration.showPercentage } } } 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,42 @@ +/* + * 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 + + implicitWidth: pageColumn.implicitWidth + implicitHeight: pageColumn.implicitHeight + + property alias cfg_showPercentage: showPercentage.checked + + 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) {