2023-11-07 12:57:00 +08:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Layouts
|
2024-01-25 03:23:29 +08:00
|
|
|
import Fk
|
2023-11-07 12:57:00 +08: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-25 03:23:29 +08:00
|
|
|
title.text: luatr("$Choice").arg(luatr(skill_name))
|
2023-11-07 12:57:00 +08: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 18:35:10 +08:00
|
|
|
Layout.fillWidth: true
|
2024-01-25 03:23:29 +08:00
|
|
|
text: Util.processPrompt(modelData)
|
|
|
|
enabled: options.indexOf(modelData) !== -1
|
|
|
|
&& (root.result.length < max_num || triggered)
|
2023-11-07 12:57:00 +08: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-25 03:23:29 +08:00
|
|
|
text: Util.processPrompt("OK")
|
2023-11-07 12:57:00 +08:00
|
|
|
enabled: root.result.length >= min_num
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
root.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MetroButton {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: processPrompt("Cancel")
|
|
|
|
visible: cancelable
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
root.result = [];
|
|
|
|
root.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|