2023-04-09 13:35:35 +08:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-02-15 19:54:35 +08:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
2023-05-19 10:08:36 +08:00
|
|
|
import Fk.RoomElement
|
2023-02-15 19:54:35 +08:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
anchors.fill: parent
|
2023-04-28 19:19:45 +08:00
|
|
|
property var generalModel
|
2023-02-15 19:54:35 +08:00
|
|
|
property var extra_data: ({})
|
|
|
|
|
|
|
|
signal finish()
|
|
|
|
|
2023-04-28 19:19:45 +08:00
|
|
|
ToolBar {
|
|
|
|
id: bar
|
|
|
|
width: parent.width
|
|
|
|
RowLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
ToolButton {
|
|
|
|
opacity: stack.depth > 1 ? 1 : 0
|
|
|
|
Behavior on opacity { NumberAnimation { duration: 100 } }
|
2024-01-25 03:23:29 +08:00
|
|
|
text: luatr("Back")
|
2023-04-28 19:19:45 +08:00
|
|
|
onClicked: stack.pop()
|
|
|
|
}
|
2023-12-06 21:07:35 +08:00
|
|
|
|
2023-04-28 19:19:45 +08:00
|
|
|
Label {
|
2024-01-25 03:23:29 +08:00
|
|
|
text: luatr("Enable free assign")
|
2023-04-28 19:19:45 +08:00
|
|
|
elide: Label.ElideRight
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
verticalAlignment: Qt.AlignVCenter
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2023-12-06 21:07:35 +08:00
|
|
|
|
|
|
|
TextField {
|
|
|
|
id: word
|
|
|
|
placeholderText: "Search..."
|
|
|
|
clip: true
|
|
|
|
verticalAlignment: Qt.AlignVCenter
|
|
|
|
background: Rectangle {
|
|
|
|
implicitHeight: 16
|
|
|
|
implicitWidth: 120
|
|
|
|
color: "transparent"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-28 19:19:45 +08:00
|
|
|
ToolButton {
|
2024-01-25 03:23:29 +08:00
|
|
|
text: luatr("Search")
|
2023-12-06 21:07:35 +08:00
|
|
|
enabled: word.text !== ""
|
|
|
|
onClicked: {
|
|
|
|
if (stack.depth > 1) stack.pop();
|
2024-01-25 03:23:29 +08:00
|
|
|
generalModel = lcall("SearchAllGenerals", word.text);
|
2023-12-06 21:07:35 +08:00
|
|
|
stack.push(generalList);
|
|
|
|
word.text = "";
|
|
|
|
}
|
2023-04-28 19:19:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2023-12-06 21:07:35 +08:00
|
|
|
cellWidth: width / 5
|
2023-04-28 19:19:45 +08:00
|
|
|
cellHeight: 40
|
|
|
|
|
|
|
|
delegate: ItemDelegate {
|
2023-12-06 21:07:35 +08:00
|
|
|
width: listView.width / 5
|
2023-04-28 19:19:45 +08:00
|
|
|
height: 40
|
|
|
|
|
|
|
|
Text {
|
2024-01-25 03:23:29 +08:00
|
|
|
text: luatr(name)
|
2023-12-06 21:07:35 +08:00
|
|
|
color: "#E4D5A0"
|
2023-04-28 19:19:45 +08:00
|
|
|
anchors.centerIn: parent
|
2023-02-15 19:54:35 +08:00
|
|
|
}
|
|
|
|
|
2023-04-28 19:19:45 +08:00
|
|
|
onClicked: {
|
2024-01-25 03:23:29 +08:00
|
|
|
generalModel = lcall("GetGenerals", packages.get(index).name);
|
2023-04-28 19:19:45 +08:00
|
|
|
stack.push(generalList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: generalList
|
|
|
|
ColumnLayout {
|
|
|
|
clip: true
|
|
|
|
width: stack.width
|
|
|
|
height: stack.height
|
|
|
|
Item { height: 6 }
|
|
|
|
GridView {
|
2023-06-16 23:53:44 +08:00
|
|
|
clip: true
|
2023-04-28 19:19:45 +08:00
|
|
|
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-29 00:51:32 +08:00
|
|
|
stack.pop();
|
2023-04-28 19:19:45 +08:00
|
|
|
extra_data.card.name = modelData;
|
|
|
|
root.finish();
|
2023-02-15 19:54:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function load() {
|
2024-01-25 03:23:29 +08:00
|
|
|
const packs = lcall("GetAllGeneralPack");
|
2023-02-15 19:54:35 +08:00
|
|
|
packs.forEach((name) => packages.append({ name: name }));
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
load();
|
|
|
|
}
|
|
|
|
}
|