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 {
|
|
|
|
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"
|
|
|
|
model: ListModel {
|
|
|
|
id: banComboList
|
|
|
|
}
|
|
|
|
|
|
|
|
onCurrentIndexChanged: {
|
|
|
|
config.disableSchemeIdx = currentIndex;
|
|
|
|
config.disabledGenerals = config.disableGeneralSchemes[currentIndex];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
2024-01-24 19:23:29 +00:00
|
|
|
text: luatr("New")
|
2023-08-02 13:40:00 +00:00
|
|
|
onClicked: {
|
|
|
|
const i = config.disableGeneralSchemes.length;
|
|
|
|
banComboList.append({
|
2024-01-24 19:23:29 +00:00
|
|
|
name: luatr("List") + (i + 1),
|
2023-08-02 13:40:00 +00:00
|
|
|
});
|
|
|
|
config.disableGeneralSchemes.push([]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
2024-01-24 19:23:29 +00:00
|
|
|
text: luatr("Clear")
|
2023-08-02 13:40:00 +00:00
|
|
|
onClicked: {
|
|
|
|
config.disabledGenerals = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
2024-01-24 19:23:29 +00:00
|
|
|
text: luatr("Export")
|
2023-08-02 13:40:00 +00:00
|
|
|
onClicked: {
|
|
|
|
Backend.copyToClipboard(JSON.stringify(config.disabledGenerals));
|
2024-01-24 19:23:29 +00:00
|
|
|
toast.show(luatr("Export Success"));
|
2023-08-02 13:40:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
2024-01-24 19:23:29 +00:00
|
|
|
text: luatr("Import")
|
2023-08-02 13:40:00 +00:00
|
|
|
onClicked: {
|
|
|
|
const str = Backend.readClipboard();
|
|
|
|
let data;
|
|
|
|
try {
|
|
|
|
data = JSON.parse(str);
|
|
|
|
} catch (e) {
|
2024-01-24 19:23:29 +00:00
|
|
|
toast.show(luatr("Not Legal"));
|
2023-08-02 13:40:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!data instanceof Array) {
|
2024-01-24 19:23:29 +00:00
|
|
|
toast.show(luatr("Not JSON"));
|
2023-08-02 13:40:00 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-08-03 07:24:17 +00:00
|
|
|
let d = [];
|
2023-08-02 13:40:00 +00:00
|
|
|
for (let e of data) {
|
2024-01-24 19:23:29 +00:00
|
|
|
if (typeof e === "string" && luatr(e) !== e) {
|
2023-08-03 07:24:17 +00:00
|
|
|
d.push(e);
|
2023-08-02 13:40:00 +00:00
|
|
|
}
|
|
|
|
}
|
2023-08-03 07:24:17 +00:00
|
|
|
config.disabledGenerals = d;
|
2024-01-24 19:23:29 +00:00
|
|
|
toast.show(luatr("Import Success"));
|
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
|
|
|
}
|
|
|
|
|
2023-08-02 13:40:00 +00:00
|
|
|
GridView {
|
|
|
|
id: listView
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
clip: true
|
2023-12-06 13:07:35 +00:00
|
|
|
cellWidth: width / 4
|
2023-08-02 13:40:00 +00:00
|
|
|
cellHeight: 24
|
|
|
|
model: config.disabledGenerals
|
|
|
|
delegate: Text {
|
|
|
|
width: listView.width
|
|
|
|
text: {
|
|
|
|
const prefix = modelData.split("__")[0];
|
2024-01-24 19:23:29 +00:00
|
|
|
let name = luatr(modelData);
|
2023-08-02 13:40:00 +00:00
|
|
|
if (prefix !== modelData) {
|
2024-01-24 19:23:29 +00:00
|
|
|
name += (" (" + luatr(prefix) + ")");
|
2023-08-02 13:40:00 +00:00
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
font.pixelSize: 16
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
for (let i = 0; i < config.disableGeneralSchemes.length; i++) {
|
|
|
|
banComboList.append({
|
2024-01-24 19:23:29 +00:00
|
|
|
name: luatr("List") + (i + 1),
|
2023-08-02 13:40:00 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
banCombo.currentIndex = config.disableSchemeIdx;
|
|
|
|
}
|
|
|
|
}
|