2023-04-09 13:35:35 +08:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-03-14 14:12:13 +08:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
|
|
|
Flickable {
|
|
|
|
id: root
|
|
|
|
flickableDirection: Flickable.AutoFlickIfNeeded
|
|
|
|
clip: true
|
|
|
|
contentHeight: layout.height
|
2023-08-11 03:19:59 +08:00
|
|
|
property bool loading: false
|
2023-03-14 14:12:13 +08:00
|
|
|
ScrollBar.vertical: ScrollBar {
|
|
|
|
parent: root.parent
|
|
|
|
anchors.top: root.top
|
|
|
|
anchors.right: root.right
|
|
|
|
anchors.bottom: root.bottom
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: layout
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 8
|
|
|
|
|
2024-09-18 23:53:38 +08:00
|
|
|
/*
|
2023-04-28 19:19:45 +08:00
|
|
|
Switch {
|
2024-01-25 03:23:29 +08:00
|
|
|
text: luatr("Disable Extension")
|
2023-03-14 14:12:13 +08:00
|
|
|
}
|
2024-09-18 23:53:38 +08:00
|
|
|
*/
|
2023-03-14 14:12:13 +08:00
|
|
|
|
2023-06-16 13:26:02 +08:00
|
|
|
RowLayout {
|
|
|
|
Text {
|
2024-01-25 03:23:29 +08:00
|
|
|
text: luatr("General Packages")
|
2023-06-16 13:26:02 +08:00
|
|
|
font.bold: true
|
|
|
|
}
|
|
|
|
Button {
|
2024-01-25 03:23:29 +08:00
|
|
|
text: luatr("Select All")
|
2023-06-16 13:26:02 +08:00
|
|
|
onClicked: {
|
|
|
|
for (let i = 0; i < gpacks.count; i++) {
|
|
|
|
const item = gpacks.itemAt(i);
|
|
|
|
item.checked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button {
|
2024-01-25 03:23:29 +08:00
|
|
|
text: luatr("Revert Selection")
|
2023-06-16 13:26:02 +08:00
|
|
|
onClicked: {
|
|
|
|
for (let i = 0; i < gpacks.count; i++) {
|
|
|
|
const item = gpacks.itemAt(i);
|
|
|
|
item.checked = !item.checked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-14 14:12:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GridLayout {
|
2023-12-06 21:07:35 +08:00
|
|
|
columns: 4
|
2023-03-14 14:12:13 +08:00
|
|
|
|
|
|
|
Repeater {
|
2023-06-16 13:26:02 +08:00
|
|
|
id: gpacks
|
2023-03-14 14:12:13 +08:00
|
|
|
model: ListModel {
|
|
|
|
id: gpacklist
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckBox {
|
|
|
|
text: name
|
|
|
|
checked: pkg_enabled
|
|
|
|
enabled: orig_name !== "test_p_0"
|
|
|
|
|
|
|
|
onCheckedChanged: {
|
2023-08-11 03:19:59 +08:00
|
|
|
if (!loading) {
|
|
|
|
checkPackage(orig_name, checked);
|
|
|
|
}
|
2023-03-14 14:12:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-16 13:26:02 +08:00
|
|
|
RowLayout {
|
|
|
|
Text {
|
2024-01-25 03:23:29 +08:00
|
|
|
text: luatr("Card Packages")
|
2023-06-16 13:26:02 +08:00
|
|
|
font.bold: true
|
|
|
|
}
|
|
|
|
Button {
|
2024-01-25 03:23:29 +08:00
|
|
|
text: luatr("Select All")
|
2023-06-16 13:26:02 +08:00
|
|
|
onClicked: {
|
|
|
|
for (let i = 0; i < cpacks.count; i++) {
|
|
|
|
const item = cpacks.itemAt(i);
|
|
|
|
item.checked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button {
|
2024-01-25 03:23:29 +08:00
|
|
|
text: luatr("Revert Selection")
|
2023-06-16 13:26:02 +08:00
|
|
|
onClicked: {
|
|
|
|
for (let i = 0; i < cpacks.count; i++) {
|
|
|
|
const item = cpacks.itemAt(i);
|
|
|
|
item.checked = !item.checked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-14 14:12:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GridLayout {
|
2023-12-06 21:07:35 +08:00
|
|
|
columns: 4
|
2023-03-14 14:12:13 +08:00
|
|
|
|
|
|
|
Repeater {
|
2023-06-16 13:26:02 +08:00
|
|
|
id: cpacks
|
2023-03-14 14:12:13 +08:00
|
|
|
model: ListModel {
|
|
|
|
id: cpacklist
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckBox {
|
|
|
|
text: name
|
|
|
|
checked: pkg_enabled
|
|
|
|
|
|
|
|
onCheckedChanged: {
|
2024-01-26 14:02:55 +08:00
|
|
|
const packs = config.curScheme.banCardPkg;
|
|
|
|
if (checked) {
|
|
|
|
const idx = packs.indexOf(orig_name);
|
|
|
|
if (idx !== -1) packs.splice(idx, 1);
|
|
|
|
} else {
|
|
|
|
packs.push(orig_name);
|
|
|
|
}
|
|
|
|
lcall("UpdatePackageEnable", orig_name, checked);
|
|
|
|
config.curSchemeChanged();
|
2023-03-14 14:12:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-16 13:26:02 +08:00
|
|
|
function checkPackage(orig_name, checked) {
|
2024-01-26 14:02:55 +08:00
|
|
|
const s = config.curScheme;
|
|
|
|
if (!checked) {
|
|
|
|
s.banPkg[orig_name] = [];
|
2024-01-26 16:01:41 +08:00
|
|
|
delete s.normalPkg[orig_name];
|
2023-06-16 13:26:02 +08:00
|
|
|
} else {
|
2024-01-26 16:01:41 +08:00
|
|
|
delete s.normalPkg[orig_name];
|
|
|
|
delete s.banPkg[orig_name];
|
2023-06-16 13:26:02 +08:00
|
|
|
}
|
2024-01-25 03:23:29 +08:00
|
|
|
lcall("UpdatePackageEnable", orig_name, checked);
|
2024-01-26 14:02:55 +08:00
|
|
|
config.curSchemeChanged();
|
2023-06-16 13:26:02 +08:00
|
|
|
}
|
|
|
|
|
2023-03-14 14:12:13 +08:00
|
|
|
Component.onCompleted: {
|
2023-08-11 03:19:59 +08:00
|
|
|
loading = true;
|
2024-01-25 03:23:29 +08:00
|
|
|
const g = lcall("GetAllGeneralPack");
|
|
|
|
let orig;
|
|
|
|
for (orig of g) {
|
2023-08-03 15:24:17 +08:00
|
|
|
if (config.serverHiddenPacks.includes(orig)) {
|
|
|
|
continue;
|
|
|
|
}
|
2023-03-14 14:12:13 +08:00
|
|
|
gpacklist.append({
|
2024-01-25 03:23:29 +08:00
|
|
|
name: luatr(orig),
|
2023-03-14 14:12:13 +08:00
|
|
|
orig_name: orig,
|
2024-01-26 14:02:55 +08:00
|
|
|
pkg_enabled: !config.curScheme.banPkg[orig],
|
2023-03-14 14:12:13 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-01-25 03:23:29 +08:00
|
|
|
const c = lcall("GetAllCardPack");
|
|
|
|
for (orig of c) {
|
2023-08-03 15:24:17 +08:00
|
|
|
if (config.serverHiddenPacks.includes(orig)) {
|
|
|
|
continue;
|
|
|
|
}
|
2023-03-14 14:12:13 +08:00
|
|
|
cpacklist.append({
|
2024-01-25 03:23:29 +08:00
|
|
|
name: luatr(orig),
|
2023-03-14 14:12:13 +08:00
|
|
|
orig_name: orig,
|
2024-01-26 14:02:55 +08:00
|
|
|
pkg_enabled: !config.curScheme.banCardPkg.includes(orig),
|
2023-03-14 14:12:13 +08:00
|
|
|
});
|
|
|
|
}
|
2023-08-11 03:19:59 +08:00
|
|
|
loading = false;
|
2023-03-14 14:12:13 +08:00
|
|
|
}
|
|
|
|
}
|