2023-11-07 04:57:00 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Layouts
|
2024-01-24 19:23:29 +00:00
|
|
|
import Fk
|
2023-11-07 04:57:00 +00:00
|
|
|
import Fk.Pages
|
|
|
|
|
|
|
|
GraphicsBox {
|
|
|
|
property var options: []
|
|
|
|
property var all_options: []
|
|
|
|
property bool cancelable: false
|
|
|
|
property int min_num: 0
|
|
|
|
property int max_num: 0
|
|
|
|
property string skill_name: ""
|
|
|
|
property var result: []
|
|
|
|
|
|
|
|
id: root
|
2024-01-24 19:23:29 +00:00
|
|
|
title.text: luatr("$Choice").arg(luatr(skill_name))
|
2023-11-07 04:57:00 +00:00
|
|
|
width: Math.max(140, body.width + 20)
|
|
|
|
height: buttons.height + body.height + title.height + 20
|
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
id: body
|
|
|
|
// x: 10
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
y: title.height + 5
|
|
|
|
flow: GridLayout.TopToBottom
|
|
|
|
rows: 8
|
|
|
|
columnSpacing: 10
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: all_options
|
|
|
|
|
|
|
|
MetroToggleButton {
|
2024-01-11 10:35:10 +00:00
|
|
|
Layout.fillWidth: true
|
2024-01-24 19:23:29 +00:00
|
|
|
text: Util.processPrompt(modelData)
|
|
|
|
enabled: options.indexOf(modelData) !== -1
|
|
|
|
&& (root.result.length < max_num || triggered)
|
2023-11-07 04:57:00 +00:00
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
if (triggered) {
|
|
|
|
root.result.push(index);
|
|
|
|
} else {
|
|
|
|
root.result.splice(root.result.indexOf(index), 1);
|
|
|
|
}
|
|
|
|
root.result = root.result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Row {
|
|
|
|
id: buttons
|
|
|
|
anchors.margins: 8
|
|
|
|
anchors.top: body.bottom
|
|
|
|
anchors.horizontalCenter: root.horizontalCenter
|
|
|
|
spacing: 32
|
|
|
|
|
|
|
|
MetroButton {
|
|
|
|
Layout.fillWidth: true
|
2024-01-26 06:56:07 +00:00
|
|
|
text: luatr("OK")
|
2023-11-07 04:57:00 +00:00
|
|
|
enabled: root.result.length >= min_num
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
root.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MetroButton {
|
|
|
|
Layout.fillWidth: true
|
2024-01-26 06:56:07 +00:00
|
|
|
text: luatr("Cancel")
|
2023-11-07 04:57:00 +00:00
|
|
|
visible: cancelable
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
root.result = [];
|
|
|
|
root.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|