Serial-Studio/assets/qml/Dashboard/ViewOptionsDelegate.qml

81 lines
1.8 KiB
QML
Raw Normal View History

import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
2021-09-28 14:43:06 -05:00
import "../Widgets" as Widgets
ColumnLayout {
id: root
2021-09-26 05:42:22 -05:00
visible: count > 0
spacing: app.spacing
property int count: 0
property var titles:[""]
property string icon: ""
property string title: ""
signal checkedChanged(var index, var checked)
2021-09-27 03:40:43 -05:00
Connections {
target: Cpp_UI_Dashboard
function onDataReset() {
hideAll.checked = false
}
}
RowLayout {
spacing: app.spacing
visible: root.count > 0
2021-09-28 14:43:06 -05:00
Widgets.Icon {
width: 18
height: 18
source: root.icon
2021-09-30 19:07:39 -05:00
color: palette.text
opacity: hideAll.checked ? 0.5 : 1
}
Label {
font.bold: true
text: root.title
opacity: hideAll.checked ? 0.5 : 1
}
Item {
Layout.fillWidth: true
}
RoundButton {
id: hideAll
width: 24
height: 24
flat: true
checkable: true
icon.color: palette.text
Layout.rightMargin: -app.spacing
icon.source: checked ? "qrc:/icons/show-all.svg" : "qrc:/icons/hide-all.svg"
onCheckedChanged: {
for (var i = 0; i < root.count; ++i)
root.checkedChanged(i, !checked)
}
}
}
Repeater {
model: hideAll.checked ? 0 : root.count
delegate: Switch {
checked: true
Layout.fillWidth: true
text: root.titles[index]
onCheckedChanged: root.checkedChanged(index, checked)
palette.highlight: Cpp_ThemeManager.alternativeHighlight
}
}
Item {
2021-09-26 05:42:22 -05:00
height: app.spacing
visible: !hideAll.checked && count > 0
}
}