Commit 864c0bf2 authored by Nate Graham's avatar Nate Graham 🔩

[System Load Viewer] Port settings window to QQC2+Kirigami FormLayout and modernize UI

Summary:
- Port to QQC2+Kirigami FormLayout style, except for the SpinBox which cannot handle decimal values well in the QQC2 version
- Use standard import names
- Adjust some strings to sound a bit more natural

Test Plan:
- All features still work
- Settings loaded correctly when the window appears and saved correctly

{F6813478}

{F6813479}

{F6813480}

Reviewers: #vdg, #plasma, filipf

Reviewed By: #vdg, filipf

Subscribers: filipf, plasma-devel

Tags: #plasma

Maniphest Tasks: T10586

Differential Revision: https://phabricator.kde.org/D21056
parent 13609c5a
/*
* Copyright (C) 2014 Martin Yrjölä <martin.yrjola@gmail.com>
* Copyright (C) 2019 Nate Graham <nate@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -18,12 +19,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.0
import QtQuick 2.5
import QtQuick.Controls 2.5 as QQC2
import org.kde.kirigami 2.5 as Kirigami
import org.kde.kquickcontrols 2.0 as KQuickControls
ColumnLayout {
Kirigami.FormLayout {
id: colorSettings
property alias cfg_memApplicationColor: memApplicationColorPicker.color
......@@ -35,129 +37,95 @@ ColumnLayout {
property alias cfg_swapUsedColor: swapUsedColorPicker.color
property alias cfg_cacheDirtyColor: cacheDirtyColorPicker.color
property alias cfg_cacheWritebackColor: cacheWritebackColorPicker.color
property alias cfg_setColorsManually: setColorsManuallyGroupBox.checked
GroupBox {
id: setColorsManuallyGroupBox
Layout.fillWidth: true
flat: true
title: i18nc("@option:check", "Set Colors Manually")
checkable: true
GridLayout {
columns: 2
Label {
text: i18nc("@title:group", "CPU")
Layout.columnSpan: 2
font.bold: true
}
Label {
text: i18nc("@label:chooser", "User:")
Layout.alignment: Qt.AlignRight
}
KQuickControls.ColorButton {
id: cpuUserColorPicker
}
Label {
text: i18nc("@label:chooser", "IOWait:")
Layout.alignment: Qt.AlignRight
}
KQuickControls.ColorButton {
id: cpuIOWaitColorPicker
}
Label {
text: i18nc("@label:chooser", "Sys:")
Layout.alignment: Qt.AlignRight
}
KQuickControls.ColorButton {
id: cpuSysColorPicker
}
Label {
text: i18nc("@label:chooser", "Nice:")
Layout.alignment: Qt.AlignRight
}
KQuickControls.ColorButton {
id: cpuNiceColorPicker
}
Label {
text: i18nc("@title:group", "Memory")
Layout.columnSpan: 2
font.bold: true
}
Label {
text: i18nc("@label:chooser", "Application:")
Layout.alignment: Qt.AlignRight
}
KQuickControls.ColorButton {
id: memApplicationColorPicker
}
Label {
text: i18nc("@label:chooser", "Buffers:")
Layout.alignment: Qt.AlignRight
}
KQuickControls.ColorButton {
id: memBuffersColorPicker
}
Label {
text: i18nc("@title:group", "Swap")
Layout.columnSpan: 2
font.bold: true
}
Label {
text: i18nc("@label:chooser", "Used swap:")
Layout.alignment: Qt.AlignRight
}
KQuickControls.ColorButton {
id: swapUsedColorPicker
}
Label {
text: i18nc("@title:group", "Cache")
Layout.columnSpan: 2
font.bold: true
}
Label {
text: i18nc("@label:chooser", "Dirty memory:")
Layout.alignment: Qt.AlignRight
}
KQuickControls.ColorButton {
id: cacheDirtyColorPicker
}
Label {
text: i18nc("@label:chooser", "Writeback memory:")
Layout.alignment: Qt.AlignRight
}
KQuickControls.ColorButton {
id: cacheWritebackColorPicker
}
}
property alias cfg_setColorsManually: setColorsManually.checked
QQC2.CheckBox {
id: setColorsManually
text: i18nc("@option:check", "Set Colors Manually")
}
Item {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18nc("@title:group", "CPU")
enabled: setColorsManually.checked
}
KQuickControls.ColorButton {
id: cpuUserColorPicker
Kirigami.FormData.label: i18nc("@label:chooser", "User:")
enabled: setColorsManually.checked
}
KQuickControls.ColorButton {
id: cpuIOWaitColorPicker
Kirigami.FormData.label: i18nc("@label:chooser", "IOWait:")
enabled: setColorsManually.checked
}
KQuickControls.ColorButton {
id: cpuSysColorPicker
Kirigami.FormData.label: i18nc("@label:chooser", "Sys:")
enabled: setColorsManually.checked
}
KQuickControls.ColorButton {
id: cpuNiceColorPicker
Kirigami.FormData.label: i18nc("@label:chooser", "Nice:")
enabled: setColorsManually.checked
}
Item {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18nc("@title:group", "Memory")
enabled: setColorsManually.checked
}
KQuickControls.ColorButton {
id: memApplicationColorPicker
Kirigami.FormData.label: i18nc("@label:chooser", "Application:")
enabled: setColorsManually.checked
}
KQuickControls.ColorButton {
id: memBuffersColorPicker
Kirigami.FormData.label: i18nc("@label:chooser", "Buffers:")
enabled: setColorsManually.checked
}
Item {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18nc("@title:group", "Swap")
enabled: setColorsManually.checked
}
KQuickControls.ColorButton {
id: swapUsedColorPicker
Kirigami.FormData.label: i18nc("@label:chooser", "Used swap:")
enabled: setColorsManually.checked
}
Item {
Layout.fillHeight: true
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18nc("@title:group", "Cache")
enabled: setColorsManually.checked
}
KQuickControls.ColorButton {
id: cacheDirtyColorPicker
Kirigami.FormData.label: i18nc("@label:chooser", "Dirty memory:")
enabled: setColorsManually.checked
}
KQuickControls.ColorButton {
id: cacheWritebackColorPicker
Kirigami.FormData.label: i18nc("@label:chooser", "Writeback memory:")
enabled: setColorsManually.checked
}
}
/*
* Copyright (C) 2014 Martin Yrjölä <martin.yrjola@gmail.com>
* Copyright (C) 2019 Nate Graham <nate@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -18,11 +19,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.0
import QtQuick 2.5
import QtQuick.Controls 1.4 as QQC1
import QtQuick.Controls 2.5 as QQC2
import QtQuick.Layouts 1.3
ColumnLayout {
import org.kde.kirigami 2.5 as Kirigami
Kirigami.FormLayout {
id: generalSettings
property alias cfg_cpuActivated: cpuActivatedCheckBox.checked
......@@ -33,124 +37,104 @@ ColumnLayout {
property alias cfg_updateInterval: updateIntervalSpinBox.value
property int cfg_monitorType: plasmoid.configuration.monitorType
onCfg_monitorTypeChanged: {
switch (cfg_monitorType) {
default: case 0: monitorTypeGroup.current = barMonitorRadio; break;
case 1: monitorTypeGroup.current = circularMonitorRadio; break;
case 2: monitorTypeGroup.current = compactBarMonitorRadio; break;
}
QQC2.ButtonGroup {
id: monitorTypeGroup
}
ExclusiveGroup {
id: monitorTypeGroup
QQC2.CheckBox {
id: cpuActivatedCheckBox
Kirigami.FormData.label: i18nc("@label", "Show:")
text: i18nc("@option:check", "CPU monitor")
onCheckedChanged: if (!checked) {cpuAllActivatedCheckBox.checked = false;}
}
GridLayout {
columns: 2
RowLayout {
Layout.fillWidth: true
Label {
Layout.row: 0
Layout.column: 0
Layout.alignment: Qt.AlignRight
text: i18nc("@label", "Show:")
Item {
width: Kirigami.Units.gridUnit
}
QQC2.CheckBox {
id: cpuAllActivatedCheckBox
CheckBox {
id: cpuActivatedCheckBox
Layout.row: 0
Layout.column: 1
text: i18nc("@option:check", "CPU monitor")
onCheckedChanged: if (!checked) {cpuAllActivatedCheckBox.checked = false;}
}
Layout.fillWidth: true
Row {
Layout.row: 1
Layout.column: 1
Item { height: 1; width: 50; }
CheckBox {
id: cpuAllActivatedCheckBox
text: i18nc("@option:check", "CPUs separately")
enabled: cpuActivatedCheckBox.checked && cfg_monitorType === 2
}
text: i18nc("@option:check", "CPUs separately")
enabled: cpuActivatedCheckBox.checked && cfg_monitorType === 2
}
}
CheckBox {
id: memoryActivatedCheckBox
Layout.row: 2
Layout.column: 1
text: i18nc("@option:check", "Memory monitor")
}
QQC2.CheckBox {
id: memoryActivatedCheckBox
text: i18nc("@option:check", "Memory monitor")
}
CheckBox {
id: swapActivatedCheckBox
Layout.row: 3
Layout.column: 1
text: i18nc("@option:check", "Swap monitor")
}
QQC2.CheckBox {
id: swapActivatedCheckBox
text: i18nc("@option:check", "Swap monitor")
}
CheckBox {
id: cacheActivatedCheckBox
Layout.row: 4
Layout.column: 1
text: i18nc("@option:check", "Cache monitor")
}
QQC2.CheckBox {
id: cacheActivatedCheckBox
text: i18nc("@option:check", "Cache monitor")
}
Label {
Layout.row: 5
Layout.column: 0
Layout.alignment: Qt.AlignRight
text: i18nc("@label", "Monitor type:")
}
RadioButton {
id: barMonitorRadio
Layout.row: 5
Layout.column: 1
exclusiveGroup: monitorTypeGroup
text: i18nc("@option:radio", "Bar")
onCheckedChanged: if (checked) {cfg_monitorType = 0; cpuAllActivatedCheckBox.checked = false;}
}
Item {
Kirigami.FormData.isSection: true
}
RadioButton {
id: circularMonitorRadio
Layout.row: 6
Layout.column: 1
exclusiveGroup: monitorTypeGroup
text: i18nc("@option:radio", "Circular")
onCheckedChanged: if (checked) {cfg_monitorType = 1; cpuAllActivatedCheckBox.checked = false;}
}
RadioButton {
id: compactBarMonitorRadio
Layout.row: 7
Layout.column: 1
exclusiveGroup: monitorTypeGroup
text: i18nc("@option:radio", "Compact bar")
onCheckedChanged: if (checked) cfg_monitorType = 2;
}
QQC2.RadioButton {
id: barMonitorRadio
QQC2.ButtonGroup.group: monitorTypeGroup
Label {
Layout.row: 8
Layout.column: 0
Layout.alignment: Qt.AlignRight
text: i18nc("@label:spinbox", "Update interval:")
}
Kirigami.FormData.label: i18nc("@label", "Monitor type:")
SpinBox {
id: updateIntervalSpinBox
Layout.row: 8
Layout.column: 1
decimals: 1
stepSize: 0.1
minimumValue: 0.1
suffix: i18nc("@item:valuesuffix spacing to number + unit (seconds)", " s")
}
text: i18nc("@option:radio", "Bar")
checked: cfg_monitorType == 0
onClicked: if (checked) {cfg_monitorType = 0; cpuAllActivatedCheckBox.checked = false;}
}
QQC2.RadioButton {
id: circularMonitorRadio
QQC2.ButtonGroup.group: monitorTypeGroup
text: i18nc("@option:radio", "Circular")
checked: cfg_monitorType == 1
onClicked: if (checked) {cfg_monitorType = 1; cpuAllActivatedCheckBox.checked = false;}
}
QQC2.RadioButton {
id: compactBarMonitorRadio
QQC2.ButtonGroup.group: monitorTypeGroup
text: i18nc("@option:radio", "Compact bar")
checked: cfg_monitorType == 2
onClicked: if (checked) cfg_monitorType = 2;
}
Item { // tighten layout
Layout.fillHeight: true
Item {
Kirigami.FormData.isSection: true
}
Component.onCompleted: cfg_monitorTypeChanged()
// QQC2 SpinBox doesn't cleanly support non-integer values, which can be worked
// around, but the code is messy and the user experience is somewhat poor.
// So for now, we stick with the QQC1 SpinBox
QQC1.SpinBox {
id: updateIntervalSpinBox
Kirigami.FormData.label: i18nc("@label:spinbox", "Update interval:")
decimals: 1
stepSize: 0.1
minimumValue: 0.1
suffix: i18ncp("@item:valuesuffix spacing to number + unit (seconds)", " second", " seconds")
}
}
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