Changeset View
Changeset View
Standalone View
Standalone View
applets/systemmonitor/systemmonitor/package/contents/ui/main.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2019 Marco Martin <mart@kde.org> | ||||
3 | * Copyright 2019 David Edmundson <davidedmundson@kde.org> | ||||
4 | * Copyright 2019 Arjen Hiemstra <ahiemstra@heimr.nl> | ||||
5 | * | ||||
6 | * This program is free software; you can redistribute it and/or modify | ||||
7 | * it under the terms of the GNU Library General Public License as | ||||
8 | * published by the Free Software Foundation; either version 2, or | ||||
9 | * (at your option) any later version. | ||||
10 | * | ||||
11 | * This program is distributed in the hope that it will be useful, | ||||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
14 | * GNU General Public License for more details | ||||
15 | * | ||||
16 | * You should have received a copy of the GNU Library General Public | ||||
17 | * License along with this program; if not, write to the | ||||
18 | * Free Software Foundation, Inc., | ||||
19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
20 | */ | ||||
21 | | ||||
22 | import QtQuick 2.0 | ||||
23 | import QtQuick.Layouts 1.1 | ||||
24 | import QtQuick.Window 2.12 | ||||
25 | | ||||
26 | import org.kde.plasma.core 2.0 as PlasmaCore | ||||
27 | import org.kde.plasma.plasmoid 2.0 | ||||
28 | | ||||
29 | import org.kde.quickcharts 1.0 as Charts | ||||
30 | | ||||
31 | Item { | ||||
32 | Plasmoid.backgroundHints: PlasmaCore.Types.DefaultBackground | PlasmaCore.Types.ConfigurableBackground | ||||
33 | | ||||
34 | Plasmoid.switchWidth: Plasmoid.fullRepresentationItem ? Plasmoid.fullRepresentationItem.Layout.minimumWidth : units.gridUnit * 8 | ||||
35 | Plasmoid.switchHeight: Plasmoid.fullRepresentationItem ? Plasmoid.fullRepresentationItem.Layout.minimumHeight : units.gridUnit * 12 | ||||
36 | | ||||
37 | Plasmoid.title: plasmoid.configuration.title || i18n("System Monitor") | ||||
38 | Plasmoid.toolTipSubText: "" | ||||
39 | | ||||
40 | Plasmoid.compactRepresentation: CompactRepresentation { | ||||
41 | } | ||||
42 | Plasmoid.fullRepresentation: FullRepresentation { | ||||
43 | } | ||||
44 | | ||||
45 | Plasmoid.configurationRequired: plasmoid.configuration.sensorIds.length == 0 && plasmoid.configuration.textOnlySensorIds.length == 0 && plasmoid.configuration.totalSensor.length == 0 | ||||
46 | | ||||
47 | //FIXME: things in faces refer to this id in the global context, should probably be fixed | ||||
48 | Charts.ColorGradientSource { | ||||
49 | id: colorSource | ||||
50 | // originally ColorGenerator used Kirigami.Theme.highlightColor | ||||
51 | baseColor: theme.highlightColor | ||||
52 | itemCount: plasmoid.configuration.sensorIds.length | ||||
53 | | ||||
54 | onItemCountChanged: generate() | ||||
55 | Component.onCompleted: generate() | ||||
56 | | ||||
57 | function generate() { | ||||
58 | var colors = colorSource.colors; | ||||
59 | var savedColors = plasmoid.configuration.sensorColors; | ||||
60 | for (var i = 0; i < plasmoid.configuration.sensorIds.length; ++i) { | ||||
61 | if (savedColors.length <= i) { | ||||
62 | savedColors.push(colors[i]); | ||||
63 | } else { | ||||
64 | // Use the darker trick to make Qt validate the scring as a valid color; | ||||
65 | var currentColor = Qt.darker(savedColors[i], 1); | ||||
66 | if (!currentColor) { | ||||
67 | savedColors[i] = (colors[i]); | ||||
68 | } | ||||
69 | } | ||||
70 | } | ||||
71 | plasmoid.configuration.sensorColors = savedColors; | ||||
72 | } | ||||
73 | } | ||||
74 | } |