2023-08-02 13:40:00 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
RowLayout {
|
2024-01-26 06:02:55 +00:00
|
|
|
Layout.fillWidth: true
|
2023-08-02 13:40:00 +00:00
|
|
|
anchors.rightMargin: 8
|
|
|
|
spacing: 16
|
|
|
|
Text {
|
2024-01-24 19:23:29 +00:00
|
|
|
text: luatr("Ban List")
|
2023-08-02 13:40:00 +00:00
|
|
|
}
|
|
|
|
ComboBox {
|
|
|
|
id: banCombo
|
|
|
|
textRole: "name"
|
2024-01-26 06:02:55 +00:00
|
|
|
Layout.fillWidth: true
|
2023-08-02 13:40:00 +00:00
|
|
|
model: ListModel {
|
|
|
|
id: banComboList
|
|
|
|
}
|
|
|
|
|
|
|
|
onCurrentIndexChanged: {
|
2024-01-26 06:02:55 +00:00
|
|
|
word.text = "";
|
|
|
|
config.disableSchemes[config.currentDisableIdx] = config.curScheme;
|
|
|
|
config.currentDisableIdx = currentIndex;
|
|
|
|
config.curScheme = config.disableSchemes[currentIndex];
|
2023-08-02 13:40:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-26 06:02:55 +00:00
|
|
|
GridLayout {
|
|
|
|
columns: 2
|
|
|
|
|
|
|
|
Button {
|
|
|
|
text: luatr("New")
|
|
|
|
onClicked: {
|
|
|
|
const i = config.disableSchemes.length;
|
|
|
|
banComboList.append({
|
|
|
|
name: luatr("List") + (i + 1),
|
|
|
|
});
|
|
|
|
config.disableSchemes.push({
|
|
|
|
name: "",
|
|
|
|
banPkg: {},
|
|
|
|
normalPkg: {},
|
|
|
|
banCardPkg: [],
|
|
|
|
});
|
|
|
|
}
|
2023-08-02 13:40:00 +00:00
|
|
|
}
|
|
|
|
|
2024-01-26 06:02:55 +00:00
|
|
|
Button {
|
|
|
|
text: luatr("Clear")
|
|
|
|
onClicked: {
|
|
|
|
config.curScheme.banPkg = {};
|
|
|
|
config.curScheme.normalPkg = {};
|
|
|
|
config.curScheme.banCardPkg = [];
|
|
|
|
config.curSchemeChanged();
|
|
|
|
}
|
2023-08-02 13:40:00 +00:00
|
|
|
}
|
|
|
|
|
2024-01-26 06:02:55 +00:00
|
|
|
Button {
|
|
|
|
text: luatr("Export")
|
|
|
|
onClicked: {
|
|
|
|
Backend.copyToClipboard(JSON.stringify(config.curScheme));
|
|
|
|
toast.show(luatr("Export Success"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
text: luatr("Import")
|
|
|
|
onClicked: {
|
|
|
|
const str = Backend.readClipboard();
|
|
|
|
let data;
|
|
|
|
try {
|
|
|
|
data = JSON.parse(str);
|
|
|
|
} catch (e) {
|
|
|
|
toast.show(luatr("Not Legal"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!data instanceof Object || !data.banPkg || !data.normalPkg
|
|
|
|
|| !data.banCardPkg) {
|
|
|
|
toast.show(luatr("Not JSON"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
config.curScheme = data;
|
|
|
|
if (data.name) {
|
|
|
|
banComboList.get(banCombo.currentIndex).name = data.name;
|
|
|
|
}
|
|
|
|
}
|
2023-08-02 13:40:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-26 06:02:55 +00:00
|
|
|
TextField {
|
|
|
|
id: word
|
|
|
|
clip: true
|
|
|
|
leftPadding: 5
|
|
|
|
rightPadding: 5
|
|
|
|
}
|
|
|
|
|
2023-08-02 13:40:00 +00:00
|
|
|
Button {
|
2024-01-26 06:02:55 +00:00
|
|
|
text: luatr("Rename")
|
|
|
|
enabled: word.text !== ""
|
2023-08-02 13:40:00 +00:00
|
|
|
onClicked: {
|
2024-01-26 06:02:55 +00:00
|
|
|
banComboList.get(banCombo.currentIndex).name = word.text;
|
|
|
|
config.curScheme.name = word.text;
|
|
|
|
word.text = "";
|
2023-08-02 13:40:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-06 13:07:35 +00:00
|
|
|
Text {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.margins: 8
|
|
|
|
wrapMode: Text.WrapAnywhere
|
2024-01-24 19:23:29 +00:00
|
|
|
text: luatr("Help_Ban_List")
|
2023-12-06 13:07:35 +00:00
|
|
|
}
|
|
|
|
|
2024-01-26 06:02:55 +00:00
|
|
|
GridLayout {
|
|
|
|
id: grid
|
|
|
|
flow: GridLayout.TopToBottom
|
|
|
|
rows: 2
|
2023-08-02 13:40:00 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2024-01-26 06:02:55 +00:00
|
|
|
|
|
|
|
Text {
|
|
|
|
wrapMode: Text.WrapAnywhere
|
|
|
|
text: luatr("Ban_Generals")
|
|
|
|
font.pixelSize: 18
|
|
|
|
font.bold: true
|
|
|
|
}
|
|
|
|
|
|
|
|
GridView {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
clip: true
|
|
|
|
cellWidth: width / 2
|
|
|
|
cellHeight: 24
|
|
|
|
model: {
|
|
|
|
let ret = [], k;
|
|
|
|
const s = config.curScheme;
|
|
|
|
for (k in s.normalPkg) {
|
|
|
|
ret.push(...s.normalPkg[k]);
|
2023-08-02 13:40:00 +00:00
|
|
|
}
|
2024-01-26 06:02:55 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
delegate: Text {
|
|
|
|
//width: banChara.width
|
|
|
|
text: {
|
|
|
|
const prefix = modelData.split("__")[0];
|
|
|
|
let name = luatr(modelData);
|
|
|
|
if (prefix !== modelData) {
|
|
|
|
name += (" (" + luatr(prefix) + ")");
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
font.pixelSize: 16
|
2023-08-02 13:40:00 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-26 06:02:55 +00:00
|
|
|
|
|
|
|
Text {
|
|
|
|
wrapMode: Text.WrapAnywhere
|
|
|
|
text: luatr("Ban_Packages")
|
|
|
|
font.pixelSize: 18
|
|
|
|
font.bold: true
|
|
|
|
}
|
|
|
|
|
|
|
|
GridView {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
clip: true
|
|
|
|
cellWidth: width / 2
|
|
|
|
cellHeight: 24
|
|
|
|
model: {
|
|
|
|
let ret = [], k;
|
|
|
|
const s = config.curScheme;
|
|
|
|
for (k in s.banPkg) {
|
|
|
|
ret.push(k);
|
|
|
|
}
|
|
|
|
ret.push(...s.banCardPkg)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
delegate: Text {
|
2024-06-10 06:58:48 +00:00
|
|
|
width: parent.width / 2
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
fontSizeMode: Text.HorizontalFit
|
|
|
|
minimumPixelSize: 14
|
|
|
|
elide: Text.ElideRight
|
|
|
|
height: 24
|
2024-01-26 06:02:55 +00:00
|
|
|
text: luatr(modelData)
|
|
|
|
font.pixelSize: 16
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
wrapMode: Text.WrapAnywhere
|
|
|
|
text: luatr("Whitelist_Generals")
|
|
|
|
font.pixelSize: 18
|
|
|
|
font.bold: true
|
|
|
|
}
|
|
|
|
|
|
|
|
GridView {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
clip: true
|
|
|
|
cellWidth: width / 2
|
|
|
|
cellHeight: 24
|
|
|
|
model: {
|
|
|
|
let ret = [], k;
|
|
|
|
const s = config.curScheme;
|
|
|
|
for (k in s.banPkg) {
|
|
|
|
ret.push(...s.banPkg[k]);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
delegate: Text {
|
|
|
|
text: {
|
|
|
|
const prefix = modelData.split("__")[0];
|
|
|
|
let name = luatr(modelData);
|
|
|
|
if (prefix !== modelData) {
|
|
|
|
name += (" (" + luatr(prefix) + ")");
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
font.pixelSize: 16
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-02 13:40:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
2024-01-26 06:02:55 +00:00
|
|
|
for (let i = 0; i < config.disableSchemes.length; i++) {
|
2023-08-02 13:40:00 +00:00
|
|
|
banComboList.append({
|
2024-01-26 06:02:55 +00:00
|
|
|
name: config.disableSchemes[i]?.name || (luatr("List") + (i + 1)),
|
2023-08-02 13:40:00 +00:00
|
|
|
});
|
|
|
|
}
|
2024-01-26 06:02:55 +00:00
|
|
|
banCombo.currentIndex = config.currentDisableIdx;
|
2023-08-02 13:40:00 +00:00
|
|
|
}
|
|
|
|
}
|