Commit 8a463c40 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Move "Choices" into the Faces QML plugin

So we can use it externally if we need a control to select sensors.
parent 35d7f0d1
......@@ -131,7 +131,7 @@ ColumnLayout {
text: i18ndp("KSysGuardSensorFaces", "Total Sensor", "Total Sensors", controller.maxTotalSensors)
visible: controller.supportsTotalSensors
}
Local.Choices {
Faces.Choices {
id: totalChoice
Layout.fillWidth: true
visible: controller.supportsTotalSensors
......@@ -149,7 +149,7 @@ ColumnLayout {
QQC2.Label {
text: i18nd("KSysGuardSensorFaces", "Sensors")
}
Local.Choices {
Faces.Choices {
id: highPriorityChoice
Layout.fillWidth: true
supportsColors: controller.supportsSensorsColors
......@@ -176,7 +176,7 @@ ColumnLayout {
text: i18nd("KSysGuardSensorFaces", "Text-Only Sensors")
visible: controller.supportsLowPrioritySensors
}
Local.Choices {
Faces.Choices {
id: lowPriorityChoice
Layout.fillWidth: true
visible: controller.supportsLowPrioritySensors
......
......@@ -10,5 +10,6 @@ install(FILES
ExtendedLegend.qml
SensorFace.qml
SensorRangeSpinBox.qml
Choices.qml
DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/ksysguard/faces
)
......@@ -6,11 +6,11 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.14
import QtQuick.Window 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import QtQml.Models 2.12
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQml.Models 2.15
import org.kde.kirigami 2.12 as Kirigami
import org.kde.kitemmodels 1.0 as KItemModels
......@@ -49,6 +49,8 @@ Control {
readOnly: true
hoverEnabled: false
placeholderText: control.selected.length == 0 ? i18nc("@label", "Click to select a sensor…") : ""
onFocusChanged: {
if (focus && (maxAllowedSensors <= 0 || repeater.count < maxAllowedSensors)) {
popup.open()
......@@ -112,7 +114,7 @@ Control {
DragHandler {
id: drag
//TODO: uncomment as soon as we can depend from 5.15
//cursorShape: active ? Qt.ClosedHandCursor : Qt.OpenHandCursor
cursorShape: active ? Qt.ClosedHandCursor : Qt.OpenHandCursor
enabled: selectedModel.count > 1
onActiveChanged: {
if (active) {
......@@ -211,7 +213,12 @@ Control {
Label {
id: label
Layout.fillWidth: true
text: control.labels[sensor.sensorId] || sensor.name
text: {
if (!control.labels || !control.labels[sensor.sensorId]) {
return sensor.name
}
return control.labels[sensor.sensorId]
}
elide: Text.ElideRight
HoverHandler { id: handler }
......
......@@ -3,3 +3,4 @@ plugin FacesPlugin
ExtendedLegend 1.0 ExtendedLegend.qml
SensorFace 1.0 SensorFace.qml
SensorRangeSpinBox 1.0 SensorRangeSpinBox.qml
Choices 1.0 Choices.qml
......@@ -2,7 +2,6 @@
<qresource prefix="/">
<file>ConfigAppearance.qml</file>
<file>ConfigSensors.qml</file>
<file>Choices.qml</file>
<file>FaceDetailsConfig.qml</file>
</qresource>
</RCC>
Supports Markdown
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