This commit is contained in:
恍兮惚兮 2024-11-03 16:09:42 +08:00
parent 16cd0fd6e2
commit 22aceb3814
31 changed files with 144 additions and 84 deletions

View File

@ -8,7 +8,7 @@ from gui.usefulwidget import (
threebuttons,
getlineedit,
TableViewW,
LFocusCombo,
SuperCombo,
)
from gui.dynalang import LStandardItemModel, LDialog, LCheckBox, LLabel
@ -67,7 +67,7 @@ class codeacceptdialog(LDialog):
itemsaver = QStandardItem()
self.model.setItem(row, 0, itemsaver)
index = self.model.index(row, 0)
codecombox = LFocusCombo()
codecombox = SuperCombo()
codecombox.addItems((nowsuppertcodes))
codecombox.setCurrentIndex(idx)
self.table.setIndexWidget(index, codecombox)
@ -114,7 +114,7 @@ class codeacceptdialog(LDialog):
def clicked1(self):
itemsaver = QStandardItem()
self.model.insertRow(0, [itemsaver])
codecombox = LFocusCombo()
codecombox = SuperCombo()
codecombox.addItems((nowsuppertcodes))
self._setcode_i(codecombox, itemsaver)
codecombox.currentIndexChanged.connect(

View File

@ -324,18 +324,26 @@ class dialog_setting_game_internal(QWidget):
print_exc()
def metadataorigin(self, formLayout: LFormLayout, gameuid):
formLayout.addRow(
"首选的",
getsimplecombobox(
list(targetmod.keys()),
globalconfig,
"primitivtemetaorigin",
internal=list(targetmod.keys()),
static=True,
),
combo = getsimplecombobox(
[""] + list(targetmod.keys()),
globalconfig,
"primitivtemetaorigin",
internal=[None] + list(targetmod.keys()),
)
formLayout.addRow("首选的", combo)
formLayout.addRow(None, QLabel())
for key in targetmod:
def valid(idx, x):
if x:
if combo.currentIndex() == 0:
combo.setCurrentIndex(idx + 1)
combo.setRowVisible(idx + 1, True)
else:
if combo.currentIndex() == idx + 1:
combo.setCurrentIndex(0)
combo.setRowVisible(idx + 1, False)
for i, key in enumerate(targetmod):
try:
idname = targetmod[key].idname
@ -351,8 +359,14 @@ class dialog_setting_game_internal(QWidget):
vndbid.returnPressed.connect(
functools.partial(gamdidchangedtask, key, idname, gameuid)
)
if not globalconfig["metadata"][key]["auto"]:
combo.setRowVisible(i + 1, False)
_vbox_internal = [
getsimpleswitch(globalconfig["metadata"][key], "auto"),
getsimpleswitch(
globalconfig["metadata"][key],
"auto",
callback=functools.partial(valid, i),
),
vndbid,
getIconButton(
functools.partial(self.openrefmainpage, key, idname, gameuid),

View File

@ -14,7 +14,7 @@ from gui.usefulwidget import (
TableViewW,
getsimplepatheditor,
FocusSpin,
LFocusCombo,
SuperCombo,
getsimplecombobox,
getspinbox,
SplitLine,
@ -261,7 +261,7 @@ class yuyinzhidingsetting(LDialog):
self.table.setindexdata(self.model.index(row, 3), item['target'])
def createacombox(self, config):
com = LFocusCombo()
com = SuperCombo()
com.addItems(["跳过", "默认", "选择声音"])
target = config.get("target", "skip")
com.target = target
@ -278,7 +278,7 @@ class yuyinzhidingsetting(LDialog):
)
return com
def __comchange(self, com: LFocusCombo, config, idx):
def __comchange(self, com: SuperCombo, config, idx):
if idx == 0:
com.target = "skip"
if com.count() > 3:
@ -527,7 +527,7 @@ class autoinitdialog__(LDialog):
lineW = listediterline(line["name"], line["header"], __list)
regist[key] = functools.partial(__getv, __list)
elif line["type"] == "combo":
lineW = LFocusCombo()
lineW = SuperCombo()
if "list_function" in line:
try:
func = getattr(
@ -546,10 +546,10 @@ class autoinitdialog__(LDialog):
elif line["type"] == "lineedit_or_combo":
line1 = QLineEdit()
lineW = QHBoxLayout()
combo = LFocusCombo()
combo = SuperCombo()
combo.setLineEdit(line1)
def __refresh(regist, line, combo: LFocusCombo):
def __refresh(regist, line, combo: SuperCombo):
try:
func = getattr(
importlib.import_module(modelfile), line["list_function"]

View File

@ -3,7 +3,7 @@ import sqlite3, os, json, functools
from traceback import print_exc
from myutils.config import globalconfig, _TR
from myutils.utils import autosql, dynamicapiname
from gui.usefulwidget import getQMessageBox, LFocusCombo
from gui.usefulwidget import getQMessageBox, SuperCombo
from gui.dynalang import LFormLayout, LPushButton, LDialog
from textsource.texthook import splitembedlines
from collections import Counter
@ -43,15 +43,14 @@ def sqlite2json2(
for _, __ in Counter(collect).most_common():
if _ in globalconfig["fanyi"]:
_collect.append(_)
collect = _collect
dialog = LDialog(self, Qt.WindowType.WindowCloseButtonHint) # 自定义一个dialog
dialog.setWindowTitle("导出翻译记录为json文件")
dialog.resize(QSize(800, 10))
formLayout = LFormLayout(dialog) # 配置layout
dialog.setLayout(formLayout)
combo = LFocusCombo()
combo.addItems([dynamicapiname(_) for _ in collect])
combo = SuperCombo()
combo.addItems([dynamicapiname(_) for _ in _collect], _collect)
formLayout.addRow("首选翻译", combo)
e = QLineEdit(sqlitefile[: -(len(".sqlite"))])
@ -81,8 +80,8 @@ def sqlite2json2(
button.rejected.connect(dialog.close)
def __savefunction(target, existsmerge, isforembed):
if len(collect) > 0:
transkirokuuse = collect[combo.currentIndex()]
if len(_collect) > 0:
transkirokuuse = combo.getIndexData(combo.currentIndex())
for k in js_format2:
js_format2[k] = js_format2[k].get(transkirokuuse, "")

View File

@ -23,9 +23,8 @@ from gui.usefulwidget import (
selectcolor,
listediter,
FocusFontCombo,
LFocusCombo,
SuperCombo,
getspinbox,
LLabel,
getsmalllabel,
SplitLine,
)
@ -244,7 +243,7 @@ def resetgroudswitchcallback(self, group):
return
clearlayout(self.goodfontsettingsformlayout)
goodfontgroupswitch = LFocusCombo()
goodfontgroupswitch = SuperCombo()
self.seletengeinecombo.lastindex = self.seletengeinecombo.currentIndex()
if group == "webview" or group == "QWebEngine":
_btn = LPushButton("编辑")

View File

@ -18,7 +18,7 @@ from gui.usefulwidget import (
saveposwindow,
pixmapviewer,
LStandardItemModel,
LFocusCombo,
SuperCombo,
threebuttons,
)
import gobject, qtawesome
@ -93,11 +93,11 @@ class triggereditor(LDialog):
self.vkeys = list(static_data["vkcode_map"].keys())
for row, k in enumerate(self.list): # 2
self.hcmodel.insertRow(row, [QStandardItem(), QStandardItem()])
combo = LFocusCombo()
combo = SuperCombo()
combo.addItems(self.vkeys)
combo.setCurrentIndex(self.vkeys.index(k["vkey"]))
self.hctable.setIndexWidget(self.hcmodel.index(row, 0), combo)
combo = LFocusCombo()
combo = SuperCombo()
combo.addItems(["按下", "松开"])
combo.setCurrentIndex(k["event"])
self.hctable.setIndexWidget(self.hcmodel.index(row, 1), combo)
@ -122,10 +122,10 @@ class triggereditor(LDialog):
def click1(self):
self.hcmodel.insertRow(0, [QStandardItem(), QStandardItem()])
combo = LFocusCombo()
combo = SuperCombo()
combo.addItems(self.vkeys)
self.hctable.setIndexWidget(self.hcmodel.index(0, 0), combo)
combo = LFocusCombo()
combo = SuperCombo()
combo.addItems(["按下", "松开"])
self.hctable.setIndexWidget(self.hcmodel.index(0, 1), combo)

View File

@ -34,24 +34,54 @@ class FocusCombo(QComboBox):
else:
return super().wheelEvent(e)
class SuperCombo(FocusCombo):
Visoriginrole = Qt.ItemDataRole.UserRole + 1
Internalrole = Visoriginrole + 1
class LFocusCombo(FocusCombo):
def __init__(self, parent: QWidget = None) -> None:
def __init__(self, parent=None, static=False) -> None:
super().__init__(parent)
self.__items = None
self.mo = QStandardItemModel()
self.static = static
self.setModel(self.mo)
self.vu = QListView()
self.setView(self.vu)
def addItems(self, items):
self.__items = items
super().addItems(_TRL(items))
def addItem(self, item, internal=None):
item1 = QStandardItem(_TR(item) if not self.static else item)
item1.setData(item, self.Visoriginrole)
item1.setData(internal, self.Internalrole)
self.mo.appendRow(item1)
def clear(self):
self.__items = []
super().clear()
self.mo.clear()
def addItems(self, items, internals=None):
for i, item in enumerate(items):
iternal = None
if internals and i < len(internals):
iternal = internals[i]
self.addItem(item, iternal)
def updatelangtext(self):
if self.__items:
for i in range(self.count()):
self.setItemText(i, _TR(self.__items[i]))
if self.static:
return
for _ in range(self.mo.rowCount()):
item = self.mo.item(_, 0)
item.setData(
_TR(item.data(self.Visoriginrole)), Qt.ItemDataRole.DisplayRole
)
def getIndexData(self, index):
item = self.mo.item(index, 0)
return item.data(self.Internalrole)
def setRowVisible(self, row, vis):
self.vu.setRowHidden(row, not vis)
item = self.mo.item(row, 0)
if vis:
item.setFlags(item.flags() | Qt.ItemFlag.ItemIsEnabled)
else:
item.setFlags(item.flags() & ~Qt.ItemFlag.ItemIsEnabled)
class FocusFontCombo(QFontComboBox, FocusCombo):
@ -860,8 +890,8 @@ def callbackwrap(d, k, call, _):
print_exc()
def comboboxcallbackwrap(internal, d, k, call, _):
_ = internal[_]
def comboboxcallbackwrap(s: SuperCombo, d, k, call, _):
_ = s.getIndexData(_)
d[k] = _
if call:
@ -874,12 +904,8 @@ def comboboxcallbackwrap(internal, d, k, call, _):
def getsimplecombobox(
lst, d, k, callback=None, fixedsize=False, internal=None, static=False, emit=False
):
if static:
s = FocusCombo()
else:
s = LFocusCombo()
s.addItems(lst)
s = SuperCombo(static=static)
s.addItems(lst, internal)
if internal:
if len(internal):
@ -888,7 +914,7 @@ def getsimplecombobox(
s.setCurrentIndex(internal.index(d[k]))
s.currentIndexChanged.connect(
functools.partial(comboboxcallbackwrap, internal, d, k, callback)
functools.partial(comboboxcallbackwrap, s, d, k, callback)
)
else:
if len(lst):
@ -1908,7 +1934,7 @@ class listediter(LDialog):
self.hcmodel.insertRow(row, [item])
if candidates:
combo = LFocusCombo()
combo = SuperCombo()
_vis = self.candidates
if self.namemapfunction:
_vis = [self.namemapfunction(_) for _ in _vis]
@ -2021,7 +2047,7 @@ class listediter(LDialog):
self.internalrealname.insert(0, self.candidates[0])
item = QStandardItem("")
self.hcmodel.insertRow(0, [item])
combo = LFocusCombo()
combo = SuperCombo()
_vis = self.candidates
if self.namemapfunction:
_vis = [self.namemapfunction(_) for _ in _vis]
@ -2357,6 +2383,7 @@ class FQLineEdit(QLineEdit):
class LRButton(LPushButton):
rightclick = pyqtSignal()
def mouseReleaseEvent(self, ev: QMouseEvent) -> None:
if self.rect().contains(ev.pos()):
if ev.button() == Qt.MouseButton.RightButton:

View File

@ -6,7 +6,7 @@ from gui.usefulwidget import (
getsimplecombobox,
getspinbox,
getsimpleswitch,
LFocusCombo,
SuperCombo,
getspinbox,
SplitLine,
getsimplepatheditor,
@ -63,7 +63,7 @@ class settingxx:
def settingxx(self, layout, config, call1, call2):
switch = LFocusCombo()
switch = SuperCombo()
switch.addItems(["外部", "内置"])
lay1 = LFormLayout()
lay2 = LFormLayout()

View File

@ -216,7 +216,9 @@ def trysearchforid_1(gameuid, searchargs: list, target=None):
infoid = None
if target is None:
primitivtemetaorigin = globalconfig["primitivtemetaorigin"]
__ = [primitivtemetaorigin]
__ = []
if primitivtemetaorigin:
__.append(primitivtemetaorigin)
for k in targetmod:
if k == primitivtemetaorigin:
continue
@ -1040,7 +1042,6 @@ def is_ascii_control(c: str):
return cinranges(c, (0, 0x1F), (0x7F, 0xA0))
def checkchaos(text):
code = globalconfig["accept_encoding"]
text = filter(lambda x: x not in globalconfig["accept_character"], text)
@ -1048,7 +1049,7 @@ def checkchaos(text):
if globalconfig["accept_use_unicode"]:
_start = globalconfig["accept_use_unicode_start"]
_end = globalconfig["accept_use_unicode_end"]
return not all(cinranges(c,(_start, _end)) for c in text)
return not all(cinranges(c, (_start, _end)) for c in text)
else:
text = "".join(text)
for c in code:

View File

@ -17,7 +17,7 @@ import os
import gobject, functools
from traceback import print_exc
from qtsymbols import *
from gui.usefulwidget import LFocusCombo, getboxlayout, getQMessageBox
from gui.usefulwidget import SuperCombo, getboxlayout, getQMessageBox
from gui.dynalang import LPushButton, LFormLayout, LLabel
@ -156,7 +156,7 @@ def question(dialog: QDialog):
dialog.setLayout(formLayout)
supportlang = LLabel()
formLayout.addRow("当前支持的语言", supportlang)
combo = LFocusCombo()
combo = SuperCombo()
allsupports = []
def callback():

View File

@ -810,5 +810,6 @@
"清除OCR范围": "مسح نطاق التعرف الضوئي على الحروف",
"重命名": "إعادة تسمية",
"应用ID": "معرف التطبيق",
"应用密钥": "مفتاح التطبيق"
"应用密钥": "مفتاح التطبيق",
"无": "لا"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "清除OCR範圍",
"重命名": "重命名",
"应用ID": "應用ID",
"应用密钥": "應用金鑰"
"应用密钥": "應用金鑰",
"无": "無"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "Vymazat rozsah OCR",
"重命名": "přejmenovat",
"应用ID": "ID aplikace",
"应用密钥": "Klíč aplikace"
"应用密钥": "Klíč aplikace",
"无": "nic"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "OCR-Bereich löschen",
"重命名": "umbenennen",
"应用ID": "Anwendungs-ID",
"应用密钥": "Anwendungsschlüssel"
"应用密钥": "Anwendungsschlüssel",
"无": "nichts"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "Clear OCR range",
"重命名": "rename",
"应用ID": "Application ID",
"应用密钥": "Application key"
"应用密钥": "Application key",
"无": "nothing"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "Eliminar el rango OCR",
"重命名": "Cambiar el nombre",
"应用ID": "ID de la aplicación",
"应用密钥": "Clave de aplicación"
"应用密钥": "Clave de aplicación",
"无": "Ninguno"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "Effacer la plage ocr",
"重命名": "Renommer",
"应用ID": "Id de l'application",
"应用密钥": "Appliquer la clé"
"应用密钥": "Appliquer la clé",
"无": "Aucun"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "Cancella intervallo OCR",
"重命名": "rinomina",
"应用ID": "ID dell'applicazione",
"应用密钥": "Chiave dell'applicazione"
"应用密钥": "Chiave dell'applicazione",
"无": "niente"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "OCR範囲のクリア",
"重命名": "名前を変更",
"应用ID": "アプリケーションID",
"应用密钥": "キーの適用"
"应用密钥": "キーの適用",
"无": "なし"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "OCR 범위 지우기",
"重命名": "이름 바꾸기",
"应用ID": "적용 ID",
"应用密钥": "키 적용"
"应用密钥": "키 적용",
"无": "없음"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "OCR-bereik wissen",
"重命名": "hernoemen",
"应用ID": "Applicatie-ID",
"应用密钥": "Toepassingssleutel"
"应用密钥": "Toepassingssleutel",
"无": "niets"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "Wyczyść zakres OCR",
"重命名": "zmień nazwę",
"应用ID": "Identyfikator aplikacji",
"应用密钥": "Klucz aplikacji"
"应用密钥": "Klucz aplikacji",
"无": "nic"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "Limpar o intervalo de OCR",
"重命名": "renomear",
"应用ID": "ID da Aplicação",
"应用密钥": "Chave da aplicação"
"应用密钥": "Chave da aplicação",
"无": "nada"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "Очистить диапазон OCR",
"重命名": "Переименовать",
"应用ID": "Использовать ID",
"应用密钥": "Применить ключ"
"应用密钥": "Применить ключ",
"无": "Нет"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "Rensa OCR-område",
"重命名": "Byt namn",
"应用ID": "Program- ID",
"应用密钥": "Programnyckel"
"应用密钥": "Programnyckel",
"无": "ingenting"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "ล้างช่วง OCR",
"重命名": "เปลี่ยนชื่อ",
"应用ID": "สมัคร ID",
"应用密钥": "ใช้คีย์"
"应用密钥": "ใช้คีย์",
"无": "ไม่มี"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "OCR aralığını temizle",
"重命名": "Yeniden Adlandır",
"应用ID": "Uygulama Kimliği",
"应用密钥": "Uygulama anahtarı"
"应用密钥": "Uygulama anahtarı",
"无": "Hiçbir şey yok."
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "Очистити діапазон OCR",
"重命名": "перейменувати",
"应用ID": "ІД програми",
"应用密钥": "Ключ програми"
"应用密钥": "Ключ програми",
"无": "нічого"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "Xóa dải OCR",
"重命名": "Thay tên",
"应用ID": "Ứng dụng ID",
"应用密钥": "Khóa ứng dụng"
"应用密钥": "Khóa ứng dụng",
"无": "Không"
}

View File

@ -810,5 +810,6 @@
"清除OCR范围": "",
"重命名": "",
"应用ID": "",
"应用密钥": ""
"应用密钥": "",
"无": ""
}

View File

@ -29,7 +29,7 @@ include(generate_product_version)
set(VERSION_MAJOR 5)
set(VERSION_MINOR 53)
set(VERSION_PATCH 10)
set(VERSION_PATCH 11)
add_library(pch pch.cpp)
target_precompile_headers(pch PUBLIC pch.h)