diff --git a/Modules/energy/package/contents/ui/main.qml b/Modules/energy/package/contents/ui/main.qml --- a/Modules/energy/package/contents/ui/main.qml +++ b/Modules/energy/package/contents/ui/main.qml @@ -17,10 +17,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -import QtQuick 2.2 +import QtQuick 2.5 import QtQuick.Controls 1.3 -import QtQuick.Controls 2.0 as QQC2 +import QtQuick.Controls 2.3 as QQC2 import QtQuick.Layouts 1.1 +import org.kde.kirigami 2.5 as Kirigami import org.kde.kquickcontrolsaddons 2.0 import org.kde.kinfocenter.energy.private 1.0 @@ -411,13 +412,12 @@ Repeater { model: root.details - ColumnLayout { - spacing: 0//units.smallSpacing + Kirigami.FormLayout { - PlasmaExtras.Heading { + Kirigami.Heading { + Kirigami.FormData.label: modelData.title + Kirigami.FormData.isSection: true level: 4 - color: sysPal.text - text: modelData.title // HACK hide section header if all labels are invisible visible: { for (var i = 0, length = detailsRepeater.count; i < length; ++i) { @@ -433,59 +433,60 @@ Repeater { id: detailsRepeater - model: modelData.data || [] - - RowLayout { - Layout.fillWidth: true - spacing: units.smallSpacing * 2 - visible: valueLabel.text !== "" - - QQC2.Label { - Layout.minimumWidth: detailsColumn.legendWidth + units.gridUnit - horizontalAlignment: Text.AlignRight - text: i18n("%1:", modelData.label) - wrapMode: Text.NoWrap - opacity: 0.8 - onPaintedWidthChanged: { - if (paintedWidth > detailsColumn.legendWidth) { - detailsColumn.legendWidth = paintedWidth - } - } - } - - QQC2.Label { - id: valueLabel + model: modelData.data || [] + + RowLayout { Layout.fillWidth: true - text: { - var value = currentBattery[modelData.value] - - if (typeof value === "boolean") { - if (value) { - return i18n("Yes") - } else { - return i18n("No") + spacing: units.smallSpacing * 2 + visible: valueLabel.text !== "" + + QQC2.Label { + Layout.minimumWidth: detailsColumn.legendWidth + units.gridUnit + horizontalAlignment: Text.AlignRight + text: i18n("%1:", modelData.label) + wrapMode: Text.NoWrap + color: sysPal.text + onPaintedWidthChanged: { + if (paintedWidth > detailsColumn.legendWidth) { + detailsColumn.legendWidth = paintedWidth } } + } - if (!value) { - return "" - } + QQC2.Label { + id: valueLabel + Layout.fillWidth: true + color: sysPal.text + text: { + var value = currentBattery[modelData.value] + + if (typeof value === "boolean") { + if (value) { + return i18n("Yes") + } else { + return i18n("No") + } + } - var precision = modelData.precision - if (typeof precision === "number") { // round to decimals - value = Number(value).toLocaleString(Qt.locale(), "f", precision) - } + if (!value) { + return "" + } - if (modelData.modifier && root["modifier_" + modelData.modifier]) { - value = root["modifier_" + modelData.modifier](value) - } + var precision = modelData.precision + if (typeof precision === "number") { // round to decimals + value = Number(value).toLocaleString(Qt.locale(), "f", precision) + } - if (modelData.unit) { - value = i18nc("%1 is value, %2 is unit", "%1 %2", value, modelData.unit) - } + if (modelData.modifier && root["modifier_" + modelData.modifier]) { + value = root["modifier_" + modelData.modifier](value) + } - return value - } + if (modelData.unit) { + value = i18nc("%1 is value, %2 is unit", "%1 %2", value, modelData.unit) + } + + return value + } } } }