2023-04-09 05:35:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-02-15 11:54:35 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
2023-05-19 02:08:36 +00:00
|
|
|
import Fk.RoomElement
|
2023-02-15 11:54:35 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
anchors.fill: parent
|
2023-04-28 11:19:45 +00:00
|
|
|
property var generalModel
|
2023-02-15 11:54:35 +00:00
|
|
|
property var extra_data: ({})
|
|
|
|
|
|
|
|
signal finish()
|
|
|
|
|
2023-04-28 11:19:45 +00:00
|
|
|
ToolBar {
|
|
|
|
id: bar
|
|
|
|
width: parent.width
|
|
|
|
RowLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
ToolButton {
|
|
|
|
opacity: stack.depth > 1 ? 1 : 0
|
|
|
|
Behavior on opacity { NumberAnimation { duration: 100 } }
|
|
|
|
text: Backend.translate("Back")
|
|
|
|
onClicked: stack.pop()
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
text: Backend.translate("Enable free assign")
|
|
|
|
elide: Label.ElideRight
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
verticalAlignment: Qt.AlignVCenter
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
ToolButton {
|
|
|
|
opacity: 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StackView {
|
|
|
|
id: stack
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height - bar.height
|
|
|
|
anchors.top: bar.bottom
|
|
|
|
initialItem: pkgList
|
|
|
|
}
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id: packages
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: pkgList
|
|
|
|
GridView {
|
|
|
|
id: listView
|
|
|
|
width: parent.width
|
|
|
|
height: stack.height
|
|
|
|
ScrollBar.vertical: ScrollBar {}
|
|
|
|
model: packages
|
|
|
|
clip: true
|
|
|
|
cellWidth: width / 3
|
|
|
|
cellHeight: 40
|
|
|
|
|
|
|
|
delegate: ItemDelegate {
|
|
|
|
width: listView.width / 3
|
|
|
|
height: 40
|
|
|
|
|
|
|
|
Text {
|
|
|
|
text: Backend.translate(name)
|
|
|
|
anchors.centerIn: parent
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
|
|
|
|
2023-04-28 11:19:45 +00:00
|
|
|
onClicked: {
|
|
|
|
generalModel = JSON.parse(Backend.callLuaFunction("GetGenerals",
|
|
|
|
[packages.get(index).name]));
|
|
|
|
stack.push(generalList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: generalList
|
|
|
|
ColumnLayout {
|
|
|
|
clip: true
|
|
|
|
width: stack.width
|
|
|
|
height: stack.height
|
|
|
|
Item { height: 6 }
|
|
|
|
GridView {
|
|
|
|
Layout.preferredWidth: stack.width - stack.width % 100 + 10
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
model: generalModel
|
|
|
|
ScrollBar.vertical: ScrollBar {}
|
|
|
|
|
|
|
|
cellHeight: 140
|
|
|
|
cellWidth: 100
|
|
|
|
|
|
|
|
delegate: GeneralCardItem {
|
|
|
|
autoBack: false
|
|
|
|
name: modelData
|
|
|
|
onClicked: {
|
2023-04-28 16:51:32 +00:00
|
|
|
stack.pop();
|
2023-04-28 11:19:45 +00:00
|
|
|
extra_data.card.name = modelData;
|
|
|
|
root.finish();
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function load() {
|
|
|
|
let packs = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", []));
|
|
|
|
packs.forEach((name) => packages.append({ name: name }));
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
load();
|
|
|
|
}
|
|
|
|
}
|