Changeset View
Changeset View
Standalone View
Standalone View
Modules/energy/package/contents/ui/main.qml
| Show All 11 Lines | |||||
| 12 | * GNU General Public License for more details. * | 12 | * GNU General Public License for more details. * | ||
| 13 | * * | 13 | * * | ||
| 14 | * You should have received a copy of the GNU General Public License * | 14 | * You should have received a copy of the GNU General Public License * | ||
| 15 | * along with this program; if not, write to the * | 15 | * along with this program; if not, write to the * | ||
| 16 | * Free Software Foundation, Inc., * | 16 | * Free Software Foundation, Inc., * | ||
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | ||
| 18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
| 19 | 19 | | |||
| 20 | import QtQuick 2.2 | 20 | import QtQuick 2.5 | ||
| 21 | import QtQuick.Controls 1.3 | 21 | import QtQuick.Controls 1.3 | ||
broulik: and also getting rid of QQC1 | |||||
| 22 | import QtQuick.Controls 2.0 as QQC2 | 22 | import QtQuick.Controls 2.3 as QQC2 | ||
| 23 | import QtQuick.Layouts 1.1 | 23 | import QtQuick.Layouts 1.1 | ||
I might be too aggressive here, what would be the best version to set here ? meven: I might be too aggressive here, what would be the best version to set here ? | |||||
ngraham: 2.5 is always a safe bet. | |||||
| 24 | import org.kde.kirigami 2.5 as Kirigami | ||||
| 24 | 25 | | |||
| 25 | import org.kde.kquickcontrolsaddons 2.0 | 26 | import org.kde.kquickcontrolsaddons 2.0 | ||
| 26 | import org.kde.kinfocenter.energy.private 1.0 | 27 | import org.kde.kinfocenter.energy.private 1.0 | ||
| 27 | 28 | | |||
| 28 | //We need units from it | 29 | //We need units from it | ||
| 29 | import org.kde.plasma.core 2.0 as PlasmaCore | 30 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
broulik: A goal is to get rid of these plasma imports, too | |||||
Now that you've imported Kirigami, you can use Kirigami.Units and drop the PlasmaCore import filipf: Now that you've imported Kirigami, you can use Kirigami.Units and drop the PlasmaCore import | |||||
| 30 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 31 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
| 31 | 32 | | |||
| 32 | import org.kde.plasma.workspace.components 2.0 as WorkspaceComponents | 33 | import org.kde.plasma.workspace.components 2.0 as WorkspaceComponents | ||
| 33 | 34 | | |||
| 34 | Item { | 35 | Item { | ||
| 35 | id: root | 36 | id: root | ||
| 36 | property QtObject currentBattery: null | 37 | property QtObject currentBattery: null | ||
| 37 | property string currentUdi: "" | 38 | property string currentUdi: "" | ||
| 38 | property bool compact: (root.width / units.gridUnit) < 25 | 39 | property bool compact: (root.width / units.gridUnit) < 25 | ||
| 39 | 40 | | |||
| 40 | onCurrentBatteryChanged: { | 41 | onCurrentBatteryChanged: { | ||
| 41 | if (!currentBattery) { | 42 | if (!currentBattery) { | ||
| 42 | currentBattery = kcm.batteries.get(0) | 43 | currentBattery = kcm.batteries.get(0) | ||
| 43 | currentUdi = kcm.batteries.udi(0) | 44 | currentUdi = kcm.batteries.udi(0) | ||
| 44 | } | 45 | } | ||
| 45 | } | 46 | } | ||
| 46 | 47 | | |||
| 47 | SystemPalette { id: sysPal; colorGroup: SystemPalette.Active } | 48 | SystemPalette { id: sysPal; colorGroup: SystemPalette.Active } | ||
| 48 | 49 | | |||
filipf: there is trailing space in this row | |||||
| 49 | property bool showWakeUps: true | 50 | property bool showWakeUps: true | ||
| 50 | property int historyType: HistoryModel.ChargeType | 51 | property int historyType: HistoryModel.ChargeType | ||
| 51 | 52 | | |||
| 52 | readonly property var details: [ | 53 | readonly property var details: [ | ||
| 53 | { | 54 | { | ||
| 54 | title: i18n("Battery"), | 55 | title: i18n("Battery"), | ||
| 55 | data: [ | 56 | data: [ | ||
| 56 | {label: i18n("Rechargeable"), value: "rechargeable"}, | 57 | {label: i18n("Rechargeable"), value: "rechargeable"}, | ||
| ▲ Show 20 Lines • Show All 349 Lines • ▼ Show 20 Line(s) | 404 | ColumnLayout { | |||
| 406 | 407 | | |||
| 407 | Layout.fillWidth: true | 408 | Layout.fillWidth: true | ||
| 408 | spacing: 0 | 409 | spacing: 0 | ||
| 409 | visible: !!currentBattery | 410 | visible: !!currentBattery | ||
| 410 | 411 | | |||
| 411 | Repeater { | 412 | Repeater { | ||
| 412 | model: root.details | 413 | model: root.details | ||
| 413 | 414 | | |||
| 414 | ColumnLayout { | 415 | Kirigami.FormLayout { | ||
| 415 | spacing: 0//units.smallSpacing | | |||
| 416 | 416 | | |||
| 417 | PlasmaExtras.Heading { | 417 | Kirigami.Heading { | ||
| 418 | Kirigami.FormData.label: modelData.title | ||||
| 419 | Kirigami.FormData.isSection: true | ||||
| 418 | level: 4 | 420 | level: 4 | ||
| 419 | color: sysPal.text | | |||
| 420 | text: modelData.title | | |||
| 421 | // HACK hide section header if all labels are invisible | 421 | // HACK hide section header if all labels are invisible | ||
| 422 | visible: { | 422 | visible: { | ||
| 423 | for (var i = 0, length = detailsRepeater.count; i < length; ++i) { | 423 | for (var i = 0, length = detailsRepeater.count; i < length; ++i) { | ||
| 424 | var item = detailsRepeater.itemAt(i) | 424 | var item = detailsRepeater.itemAt(i) | ||
| 425 | if (item && item.visible) { | 425 | if (item && item.visible) { | ||
| 426 | return true | 426 | return true | ||
| 427 | } | 427 | } | ||
| 428 | } | 428 | } | ||
| 429 | 429 | | |||
| 430 | return false | 430 | return false | ||
| 431 | } | 431 | } | ||
| 432 | } | 432 | } | ||
| 433 | 433 | | |||
| 434 | Repeater { | 434 | Repeater { | ||
| 435 | id: detailsRepeater | 435 | id: detailsRepeater | ||
| 436 | model: modelData.data || [] | 436 | model: modelData.data || [] | ||
| 437 | 437 | | |||
filipf: trailing space her as well, as well as in the preceding row | |||||
| 438 | RowLayout { | 438 | RowLayout { | ||
| 439 | Layout.fillWidth: true | 439 | Layout.fillWidth: true | ||
| 440 | spacing: units.smallSpacing * 2 | 440 | spacing: units.smallSpacing * 2 | ||
| 441 | visible: valueLabel.text !== "" | 441 | visible: valueLabel.text !== "" | ||
| 442 | 442 | | |||
| 443 | QQC2.Label { | 443 | QQC2.Label { | ||
| 444 | Layout.minimumWidth: detailsColumn.legendWidth + units.gridUnit | 444 | Layout.minimumWidth: detailsColumn.legendWidth + units.gridUnit | ||
| 445 | horizontalAlignment: Text.AlignRight | 445 | horizontalAlignment: Text.AlignRight | ||
| 446 | text: i18n("%1:", modelData.label) | 446 | text: i18n("%1:", modelData.label) | ||
| 447 | wrapMode: Text.NoWrap | 447 | wrapMode: Text.NoWrap | ||
| 448 | opacity: 0.8 | 448 | color: sysPal.text | ||
| 449 | onPaintedWidthChanged: { | 449 | onPaintedWidthChanged: { | ||
| 450 | if (paintedWidth > detailsColumn.legendWidth) { | 450 | if (paintedWidth > detailsColumn.legendWidth) { | ||
| 451 | detailsColumn.legendWidth = paintedWidth | 451 | detailsColumn.legendWidth = paintedWidth | ||
| 452 | } | 452 | } | ||
| 453 | } | 453 | } | ||
| 454 | } | 454 | } | ||
| 455 | 455 | | |||
| 456 | QQC2.Label { | 456 | QQC2.Label { | ||
| 457 | id: valueLabel | 457 | id: valueLabel | ||
| 458 | Layout.fillWidth: true | 458 | Layout.fillWidth: true | ||
| 459 | color: sysPal.text | ||||
broulik: Shouldn't be neccessary as it's `QQC2.Label` | |||||
For breeze dark this makes the label, dark gray on a dark background. See before screenshot. Could it be a breeze dark bug ? meven: For breeze dark this makes the label, dark gray on a dark background. See before screenshot. | |||||
| 459 | text: { | 460 | text: { | ||
| 460 | var value = currentBattery[modelData.value] | 461 | var value = currentBattery[modelData.value] | ||
| 461 | 462 | | |||
| 462 | if (typeof value === "boolean") { | 463 | if (typeof value === "boolean") { | ||
| 463 | if (value) { | 464 | if (value) { | ||
| 464 | return i18n("Yes") | 465 | return i18n("Yes") | ||
| 465 | } else { | 466 | } else { | ||
| 466 | return i18n("No") | 467 | return i18n("No") | ||
| Show All 31 Lines | |||||
and also getting rid of QQC1