Commit a94e6888 authored by Marco Martin's avatar Marco Martin
Browse files

new face: Horizontal bars

this new face draws horizontal bars with rounded edges (to look kinda
breeze-y) though they are just rounded Rectangles in order to alwys
support correct custom coloring for bars.
Legends are immediately below the bar instead of grouped, which makes it
much more readable in this case.

It looks also pretty similar to the old partitions monitor, effectively
fixing
BUG:421512
parent d4134e42
......@@ -502,7 +502,6 @@ QQuickItem *SensorFaceController::fullRepresentation()
}
d->fullRepresentation = d->createGui(d->facePackage.filePath("ui", QStringLiteral("FullRepresentation.qml")));
return d->fullRepresentation;
}
......
......@@ -7,3 +7,4 @@ install_sensorchart_face(barchart)
install_sensorchart_face(linechart)
install_sensorchart_face(piechart)
install_sensorchart_face(textonly)
install_sensorchart_face(horizontalbars)
#! /usr/bin/env bash
$XGETTEXT `find . -name \*.qml` -o $podir/ksysguard_face_org.kde.ksysguard.horizontalbars.pot
[Config]
SupportsSensorsColors=true
SupportsTotalSensors=false
SupportsLowPrioritySensors=true
/*
* Copyright 2020 Marco Martin <mart@kde.org>
* Copyright 2019 David Edmundson <davidedmundson@kde.org>
* Copyright 2019 Arjen Hiemstra <ahiemstra@heimr.nl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library 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.9
import QtQuick.Layouts 1.1
import org.kde.kirigami 2.13 as Kirigami
import org.kde.ksysguard.sensors 1.0 as Sensors
import org.kde.ksysguard.faces 1.0 as Faces
import org.kde.quickcharts 1.0 as Charts
import org.kde.quickcharts.controls 1.0 as ChartsControls
Rectangle {
id: bar
Layout.fillWidth: true
implicitHeight: Math.round(Kirigami.Units.gridUnit / 3)
color: Kirigami.ColorUtils.adjustColor(Kirigami.Theme.textColor, {"alpha": 40})
radius: height/2
property Sensors.Sensor sensor
Rectangle {
anchors {
left: parent.left
top: parent.top
bottom: parent.bottom
}
color: root.colorSource.map[modelData]
radius: height/2
width: Math.min(Math.max(height, parent.width * (bar.sensor.value / bar.sensor.maximum)), parent.width)
}
}
/*
* Copyright 2019 Marco Martin <mart@kde.org>
* Copyright 2019 David Edmundson <davidedmundson@kde.org>
* Copyright 2019 Arjen Hiemstra <ahiemstra@heimr.nl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library 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.9
import QtQuick.Layouts 1.1
import org.kde.kirigami 2.8 as Kirigami
import org.kde.ksysguard.sensors 1.0 as Sensors
import org.kde.ksysguard.faces 1.0 as Faces
import org.kde.quickcharts 1.0 as Charts
import org.kde.quickcharts.controls 1.0 as ChartsControls
Faces.SensorFace {
id: root
Layout.minimumWidth: root.formFactor == Faces.SensorFace.Vertical ? Kirigami.Units.gridUnit : Kirigami.Units.gridUnit * 2
Layout.minimumHeight: root.formFactor == Faces.SensorFace.Vertical ? contentItem.implicitHeight : Kirigami.Units.gridUnit
contentItem: ColumnLayout {
spacing: Kirigami.Units.smallSpacing
Repeater {
model: root.controller.highPrioritySensorIds
Bar {
Layout.preferredHeight: Math.min(implicitHeight, Math.max(root.height / root.controller.highPrioritySensorIds.length - Kirigami.Units.smallSpacing * (root.controller.highPrioritySensorIds.length - 1), Kirigami.Units.smallSpacing))
opacity: y + height <= root.height
sensor: sensor
Sensors.Sensor {
id: sensor
sensorId: modelData
}
}
}
}
}
/*
* Copyright 2019 Marco Martin <mart@kde.org>
* Copyright 2019 David Edmundson <davidedmundson@kde.org>
* Copyright 2019 Arjen Hiemstra <ahiemstra@heimr.nl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library 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.9
import QtQuick.Layouts 1.1
import org.kde.kirigami 2.13 as Kirigami
import org.kde.ksysguard.sensors 1.0 as Sensors
import org.kde.ksysguard.faces 1.0 as Faces
import org.kde.quickcharts 1.0 as Charts
import org.kde.quickcharts.controls 1.0 as ChartsControls
Faces.SensorFace {
id: root
// Arbitrary minimumWidth to make easier to align plasmoids in a predictable way
Layout.minimumWidth: Kirigami.Units.gridUnit * 8
Layout.preferredWidth: titleMetrics.width
contentItem: ColumnLayout {
spacing: Kirigami.Units.smallspacing
Kirigami.Heading {
id: heading
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
text: root.controller.title
visible: text.length > 0
level: 2
TextMetrics {
id: titleMetrics
font: heading.font
text: heading.text
}
}
Item { Layout.fillWidth: true; Layout.fillHeight: true }
Repeater {
model: root.controller.highPrioritySensorIds
ColumnLayout {
Layout.fillWidth: true
Layout.bottomMargin: Kirigami.Units.smallSpacing
spacing: 0
Bar {
sensor: sensor
}
ChartsControls.LegendDelegate {
readonly property bool isTextOnly: index >= root.controller.highPrioritySensorIds.length
Layout.fillWidth: true
Layout.minimumHeight: isTextOnly ? 0 : implicitHeight
name: sensor.shortName
value: sensor.formattedValue
colorVisible: false
layoutWidth: root.width
valueWidth: Kirigami.Units.gridUnit * 2
Sensors.Sensor {
id: sensor
sensorId: modelData
}
}
}
}
Kirigami.Separator {
Layout.fillWidth: true
visible: root.controller.lowPrioritySensorIds.length > 0
}
Repeater {
model: root.controller.lowPrioritySensorIds
ChartsControls.LegendDelegate {
Layout.fillWidth: true
Layout.minimumHeight: implicitHeight
name: sensor.shortName
value: sensor.formattedValue
colorVisible: false
layoutWidth: root.width
valueWidth: Kirigami.Units.gridUnit * 2
Sensors.Sensor {
id: sensor
sensorId: modelData
}
}
}
Item { Layout.fillWidth: true; Layout.fillHeight: true }
}
}
[Desktop Entry]
Name=Horizontal Bars
Icon=view-list-text
Type=Service
X-KDE-ServiceTypes=KSysguard/SensorFace
X-KDE-ParentApp=org.kde.plasmashell
X-KDE-PluginInfo-Author=Marco Martin
X-KDE-PluginInfo-Email=mart@kde.org
X-KDE-PluginInfo-License=LGPLv2+
X-KDE-PluginInfo-Name=org.kde.ksysguard.horizontalbars
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=https://kde.org
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