1.4 KiB · text History e43831b
import QtQuick
import QtQuick.Layouts
import org.kde.plasma.components as PlasmaComponents3
import org.kde.kirigami as Kirigami

// Start a machine from the library the server pushes on join: pick a
// class, then one of its entries.
RowLayout {
    id: row

    required property var store

    // the library is only replaced when the server pushes it again, so this
    // doesn't reset the dropdowns on every publish
    readonly property var classes: Object.keys(store.library).sort()
    readonly property string currentClass: cls.currentIndex >= 0 ? classes[cls.currentIndex] || "" : ""
    readonly property var entries: currentClass !== "" ? Object.keys(store.library[currentClass] || {}).sort() : []

    spacing: Kirigami.Units.smallSpacing
    enabled: store.connected && classes.length > 0

    PlasmaComponents3.ComboBox {
        id: cls
        Layout.fillWidth: true
        Layout.preferredWidth: 1
        model: row.classes
    }

    PlasmaComponents3.ComboBox {
        id: entry
        Layout.fillWidth: true
        Layout.preferredWidth: 1
        model: row.entries
    }

    PlasmaComponents3.Button {
        icon.name: "media-playback-start"
        text: i18n("Start")
        enabled: row.currentClass !== "" && entry.currentIndex >= 0
        onClicked: row.store.libraryAdd(row.currentClass, row.entries[entry.currentIndex])
        PlasmaComponents3.ToolTip { text: i18n("Start this library machine") }
    }
}