Reputation: 1
I'm trying to create a plasmoid for KDE Plasma 6 with toggle switches.
in the config.qml configuration file, the switches are dynamically generated in a list, this list therefore gives the order of creation of the switches.
in the main.qml file The switches: JSON contains the model data of the switches defined in config.qml (name, switchId, isMaster, isMain, checked, ect...)
the isMaster and isMaster are 2 types of switches which are defined in switches, the isMaster controls the isMains which are below him until there is another isMaster which in turn controls the isMains which are after him.
The goal is that in main.qml I would like each time an isMaster is displayed to create a column, so if for example I have 3 isMasters and 6 isMains it will look like this:
First isMaster | Second isMaster | third isMaster
First isMain | third isMain | fifth isMAin
second isMain | fourth isMAin | sixth isMain
I do not know how to do.
Here is the main.qml:
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import org.kde.plasma.plasmoid
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.plasma5support as Plasma5Support
import org.kde.plasma.components as PlasmaComponents3
import org.kde.kirigami as Kirigami
PlasmoidItem {
id: root
readonly property var switches: JSON.parse(Plasmoid.configuration.switches)
preferredRepresentation: fullRepresentation
fullRepresentation: GridLayout {
id: fullRoot
Repeater {
id: switchRepeater
model: root.switches
delegate: RowLayout {
PlasmaComponents3.Switch {
checked: modelData.defaultPosition
onCheckedChanged: root.toggleAction(modelData.switchId, checked)
Layout.alignment: Qt.AlignHLeft | Qt.AlignVCenter
}
PlasmaComponents3.Label {
text: modelData.displayName ? modelData.name : ""
color: modelData.switchNameColor
Layout.alignment: Qt.AlignHLeft | Qt.AlignVCenter
}
}
}
}
}
Upvotes: 0
Views: 30