| 1 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 2 |
// Copyright 2019 Juan Palacios <[email protected]> |
| 3 |
|
| 4 |
import QtQuick 2.15 |
| 5 |
import QtQuick.Controls 2.15 |
| 6 |
import CoreCtrl.UIComponents 1.0 |
| 7 |
import "Style.js" as Style |
| 8 |
import "Settings.js" as Settings |
| 9 |
|
| 10 |
GPU { |
| 11 |
id: gpu |
| 12 |
objectName: "GPU" |
| 13 |
|
| 14 |
onNewGraphItem: item => { |
| 15 |
sensorGraph.addItem(item) |
| 16 |
Settings.addComponentData("GPU" + gpu.index, "GPU " + gpu.index, |
| 17 |
item.name, |
| 18 |
qsTranslate("SensorGraph", item.name)) |
| 19 |
} |
| 20 |
|
| 21 |
Connections { |
| 22 |
target: settings |
| 23 |
|
| 24 |
function onSettingChanged(key, value) { |
| 25 |
if (key === "Workarounds/ignoredSensors") { |
| 26 |
var sensors = Settings.componentIgnoredSensors("GPU" + gpu.index, |
| 27 |
value) |
| 28 |
sensorGraph.ignoredSensors(sensors) |
| 29 |
} |
| 30 |
else if (key === "UI/splitview-sysmodel-sensorgraph-height") { |
| 31 |
sensorGraph.SplitView.preferredHeight = value |
| 32 |
} |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
CSplitView { |
| 37 |
anchors.fill: parent |
| 38 |
orientation: Qt.Vertical |
| 39 |
|
| 40 |
onResizingChanged: { |
| 41 |
if (!resizing) { |
| 42 |
settings.setValue("UI/splitview-sysmodel-sensorgraph-height", |
| 43 |
sensorGraph.SplitView.preferredHeight) |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
SensorGraph { |
| 48 |
id: sensorGraph |
| 49 |
} |
| 50 |
|
| 51 |
Pane { |
| 52 |
padding: 0 |
| 53 |
SplitView.fillHeight: true |
| 54 |
|
| 55 |
ScrollView { |
| 56 |
id: scrollview |
| 57 |
anchors.fill: parent |
| 58 |
clip: true |
| 59 |
ScrollBar.horizontal.policy: ScrollBar.AlwaysOn |
| 60 |
ScrollBar.vertical.policy: ScrollBar.AlwaysOn |
| 61 |
ScrollBar.horizontal.visible: ScrollBar.horizontal.size < 1 |
| 62 |
ScrollBar.vertical.visible: ScrollBar.vertical.size < 1 |
| 63 |
|
| 64 |
Flow { |
| 65 |
id: flow |
| 66 |
objectName: "GPU_Plug" |
| 67 |
width: scrollview.availableWidth |
| 68 |
height: scrollview.availableHeight |
| 69 |
spacing: Style.Controls.items_spacing |
| 70 |
|
| 71 |
property var childrenAdded: [] |
| 72 |
onChildrenChanged: { |
| 73 |
for (var i = 0; i < children.length; ++i) |
| 74 |
if (childrenAdded[children[i].objectName] === undefined) { |
| 75 |
childrenAdded[children[i].objectName] = children[i] |
| 76 |
gpu.setupChild(children[i]) |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
move: Transition { |
| 81 |
NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad } |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
Component.onCompleted: { |
| 86 |
// BUG Scroll on control views does not work. |
| 87 |
// ScrollView will interfere with any children that uses MouseArea. |
| 88 |
// This stops that behaviour, but also disables scroll on the ScrollView. |
| 89 |
scrollview.contentItem.interactive = false |
| 90 |
} |
| 91 |
} |
| 92 |
} |
| 93 |
} |
| 94 |
} |