97 lines
2 KiB
QML
97 lines
2 KiB
QML
|
import QtQuick 2.0
|
||
|
import QtQuick.Controls 2.9
|
||
|
import QtQuick.Controls.Material 2.0
|
||
|
|
||
|
ItemDelegate {
|
||
|
id: control
|
||
|
|
||
|
property var model: []
|
||
|
property string currentText: model[currentIndex]
|
||
|
property int currentIndex: 0
|
||
|
|
||
|
onClicked: {
|
||
|
if(currentText != "")
|
||
|
currentIndex = model.indexOf(currentText)
|
||
|
else
|
||
|
currentIndex = 0
|
||
|
|
||
|
textEditDialog.open()
|
||
|
}
|
||
|
|
||
|
Text {
|
||
|
anchors {
|
||
|
right: nextPageIconText.left
|
||
|
verticalCenter: parent.verticalCenter
|
||
|
rightMargin: control.padding
|
||
|
}
|
||
|
|
||
|
font.pixelSize: parent.font.pixelSize
|
||
|
|
||
|
color: control.Material.foreground
|
||
|
|
||
|
text: currentText === "" ? "Not set": currentText
|
||
|
}
|
||
|
|
||
|
Text {
|
||
|
id: nextPageIconText
|
||
|
|
||
|
anchors {
|
||
|
right: parent.right
|
||
|
verticalCenter: parent.verticalCenter
|
||
|
rightMargin: control.padding
|
||
|
}
|
||
|
|
||
|
font.pixelSize: parent.height * 0.5
|
||
|
|
||
|
verticalAlignment: Text.AlignVCenter
|
||
|
|
||
|
color: control.Material.foreground
|
||
|
|
||
|
text: ">"
|
||
|
}
|
||
|
|
||
|
Dialog {
|
||
|
id: textEditDialog
|
||
|
parent: Overlay.overlay
|
||
|
|
||
|
x: (parent.width - width) / 2
|
||
|
y: (parent.height - height) / 2
|
||
|
|
||
|
width: parent.width * 0.9
|
||
|
|
||
|
Material.theme: control.Material.theme
|
||
|
Material.accent: control.Material.accent
|
||
|
modal: true
|
||
|
|
||
|
title: control.text
|
||
|
|
||
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
||
|
|
||
|
contentItem: ListView {
|
||
|
id: listView
|
||
|
|
||
|
implicitHeight: childrenRect.height
|
||
|
|
||
|
delegate: RadioDelegate {
|
||
|
width: parent.width
|
||
|
checked: index === control.currentIndex
|
||
|
ButtonGroup.group: buttonGroup
|
||
|
text: modelData
|
||
|
}
|
||
|
}
|
||
|
|
||
|
onAboutToShow: {
|
||
|
listView.model = []
|
||
|
listView.model = control.model
|
||
|
}
|
||
|
|
||
|
onAccepted: {
|
||
|
control.currentText = buttonGroup.checkedButton.text
|
||
|
}
|
||
|
|
||
|
ButtonGroup {
|
||
|
id: buttonGroup
|
||
|
}
|
||
|
}
|
||
|
}
|