Commit 5973bda7 authored by Nate Graham's avatar Nate Graham 🔩
Browse files

[applets/batterymonitor] Port to PlasmaComponents3

This fixes a few layout bugs in PC2 so we can remove some hacks,
and also the checkbox text now elides properly instead of overflowing.
parent 20c5edd9
......@@ -21,7 +21,7 @@
import QtQuick 2.4
import QtGraphicalEffects 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.components 3.0 as PlasmaComponents3
Item {
property alias text: label.text
......@@ -40,10 +40,9 @@ Item {
opacity: 0.9
}
PlasmaComponents.Label {
PlasmaComponents3.Label {
id: label
anchors.centerIn: badgeRect
height: paintedHeight
font.pixelSize: Math.max(icon.height/4, theme.smallestFont.pixelSize*0.8)
}
......
......@@ -22,7 +22,7 @@ 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.components 3.0 as PlasmaComponents3
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.workspace.components 2.0
import org.kde.kcoreaddons 1.0 as KCoreAddons
......@@ -46,7 +46,7 @@ Item {
property int leftColumnWidth: 0
width: units.gridUnit * 11
PlasmaComponents.Label {
PlasmaComponents3.Label {
id: brokenBatteryLabel
width: parent ? parent.width : implicitWidth
wrapMode: Text.WordWrap
......@@ -59,7 +59,7 @@ Item {
id: detailsRepeater
model: Logic.batteryDetails(batteryItem.battery, batterymonitor.remainingTime)
PlasmaComponents.Label {
PlasmaComponents3.Label {
id: detailsLabel
width: modelData.value && parent ? parent.width - detailsLayout.leftColumnWidth - units.smallSpacing : detailsLayout.leftColumnWidth + units.smallSpacing
wrapMode: Text.NoWrap
......@@ -89,7 +89,7 @@ Item {
Column {
width: parent.width
spacing: 0
spacing: units.smallSpacing
PlasmaCore.ToolTipArea {
width: parent.width
......@@ -158,39 +158,37 @@ Item {
Column {
Layout.fillWidth: true
Layout.alignment: batteryItem.isPresent ? Qt.AlignTop : Qt.AlignVCenter
spacing: units.smallSpacing
RowLayout {
width: parent.width
spacing: units.smallSpacing
PlasmaComponents.Label {
PlasmaComponents3.Label {
id: batteryNameLabel
Layout.fillWidth: true
height: implicitHeight
elide: Text.ElideRight
text: model["Pretty Name"]
}
PlasmaComponents.Label {
PlasmaComponents3.Label {
text: Logic.stringForBatteryState(model)
height: implicitHeight
visible: model["Is Power Supply"]
opacity: 0.6
}
PlasmaComponents.Label {
PlasmaComponents3.Label {
id: batteryPercent
height: paintedHeight
horizontalAlignment: Text.AlignRight
visible: batteryItem.isPresent
text: i18nc("Placeholder is battery percentage", "%1%", model.Percent)
}
}
PlasmaComponents.ProgressBar {
PlasmaComponents3.ProgressBar {
width: parent.width
minimumValue: 0
maximumValue: 100
from: 0
to: 100
visible: batteryItem.isPresent
value: Number(model.Percent)
}
......
......@@ -22,8 +22,7 @@ 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 Components
import org.kde.plasma.components 3.0 as Components3
import org.kde.plasma.components 3.0 as PlasmaComponents3
RowLayout {
id: item
......@@ -49,13 +48,12 @@ RowLayout {
Layout.alignment: Qt.AlignTop
spacing: 0
Components.Label {
PlasmaComponents3.Label {
id: brightnessLabel
width: parent.width
height: paintedHeight
}
Components3.Slider {
PlasmaComponents3.Slider {
id: brightnessSlider
width: parent.width
// Don't allow the slider to turn off the screen
......
......@@ -22,7 +22,6 @@
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 Components
import org.kde.plasma.workspace.components 2.0
MouseArea {
......
......@@ -20,7 +20,7 @@
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 Components
import org.kde.plasma.components 3.0 as PlasmaComponents3
RowLayout {
property alias iconSource: iconItem.source
......@@ -35,10 +35,9 @@ RowLayout {
visible: valid
}
Components.Label {
PlasmaComponents3.Label {
id: label
Layout.fillWidth: true
height: implicitHeight
font: theme.smallestFont
wrapMode: Text.WordWrap
elide: Text.ElideRight
......
......@@ -20,7 +20,6 @@
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as Components
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.kquickcontrolsaddons 2.0
......
......@@ -21,7 +21,7 @@
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 Components
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.kquickcontrolsaddons 2.0
ColumnLayout {
......@@ -33,18 +33,21 @@ ColumnLayout {
Layout.fillWidth: true
Layout.leftMargin: units.smallSpacing
Components.CheckBox {
PlasmaComponents3.CheckBox {
id: pmCheckBox
Layout.fillWidth: true
text: i18nc("Minimize the length of this string as much as possible", "Allow automatic sleep and screen locking")
checked: true
}
Components.ToolButton {
iconSource: "configure"
PlasmaComponents3.ToolButton {
icon.name: "configure"
onClicked: batterymonitor.action_powerdevilkcm()
tooltip: i18n("Configure Power Saving...")
visible: batterymonitor.kcmsAuthorized
PlasmaComponents3.ToolTip {
text: i18n("Configure Power Saving...")
}
}
}
......@@ -60,7 +63,7 @@ ColumnLayout {
text: i18nc("Minimize the length of this string as much as possible", "Your notebook is configured not to sleep when closing the lid while an external monitor is connected.")
}
Components.Label {
PlasmaComponents3.Label {
id: inhibitionExplanation
Layout.fillWidth: true
// Don't need to show the inhibitions when power management
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment