This commit is contained in:
恍兮惚兮 2024-11-09 15:47:42 +08:00
parent 7bc0f9391a
commit 0212261546
7 changed files with 44 additions and 26 deletions

View File

@ -2,7 +2,7 @@ from qtsymbols import *
import sqlite3, os, json, functools import sqlite3, os, json, functools
from traceback import print_exc from traceback import print_exc
from myutils.config import globalconfig, _TR from myutils.config import globalconfig, _TR
from myutils.utils import autosql, dynamicapiname from myutils.utils import autosql, getannotatedapiname
from gui.usefulwidget import getQMessageBox, SuperCombo from gui.usefulwidget import getQMessageBox, SuperCombo
from gui.dynalang import LFormLayout, LPushButton, LDialog from gui.dynalang import LFormLayout, LPushButton, LDialog
from textsource.texthook import splitembedlines from textsource.texthook import splitembedlines
@ -50,7 +50,7 @@ def sqlite2json2(
dialog.setLayout(formLayout) dialog.setLayout(formLayout)
combo = SuperCombo() combo = SuperCombo()
combo.addItems([dynamicapiname(_) for _ in _collect], _collect) combo.addItems([getannotatedapiname(_) for _ in _collect], _collect)
formLayout.addRow("首选翻译", combo) formLayout.addRow("首选翻译", combo)
e = QLineEdit(sqlitefile[: -(len(".sqlite"))]) e = QLineEdit(sqlitefile[: -(len(".sqlite"))])

View File

@ -1,7 +1,7 @@
import functools, os import functools, os
import gobject import gobject
from myutils.utils import splitocrtypes from myutils.utils import splitocrtypes
from myutils.config import globalconfig from myutils.config import globalconfig, _TR
from gui.inputdialog import autoinitdialog, autoinitdialog_items from gui.inputdialog import autoinitdialog, autoinitdialog_items
from gui.usefulwidget import ( from gui.usefulwidget import (
yuitsu_switch, yuitsu_switch,
@ -109,7 +109,7 @@ def vistranslate_rank(self):
"显示顺序", "显示顺序",
globalconfig["cishuvisrank"], globalconfig["cishuvisrank"],
isrankeditor=True, isrankeditor=True,
namemapfunction=lambda k: globalconfig["cishu"][k]["name"], namemapfunction=lambda k: _TR(globalconfig["cishu"][k]["name"]),
) )

View File

@ -1,10 +1,10 @@
from qtsymbols import * from qtsymbols import *
import functools, platform import functools, platform
import gobject, os, zipfile import gobject, os, zipfile
from myutils.config import globalconfig, static_data from myutils.config import globalconfig, static_data, _TR
from gui.inputdialog import multicolorset, autoinitdialog from gui.inputdialog import multicolorset, autoinitdialog
from myutils.wrapper import tryprint from myutils.wrapper import tryprint
from myutils.utils import dynamiclink, translate_exits, copytree, dynamicapiname from myutils.utils import dynamiclink, translate_exits, copytree, getannotatedapiname
from gui.usefulwidget import ( from gui.usefulwidget import (
D_getsimplecombobox, D_getsimplecombobox,
getsimplecombobox, getsimplecombobox,
@ -332,7 +332,7 @@ def vistranslate_rank(self):
("显示顺序"), ("显示顺序"),
globalconfig["fix_translate_rank_rank"], globalconfig["fix_translate_rank_rank"],
isrankeditor=True, isrankeditor=True,
namemapfunction=lambda k: dynamicapiname(k), namemapfunction=lambda k: _TR(getannotatedapiname(k))
) )

View File

@ -1,7 +1,7 @@
from qtsymbols import * from qtsymbols import *
import functools, os, json import functools, os, json
import windows, gobject import windows, gobject
from myutils.utils import translate_exits, dynamicapiname from myutils.utils import translate_exits, getannotatedapiname, sortAwithB
from myutils.config import ( from myutils.config import (
globalconfig, globalconfig,
_TR, _TR,
@ -274,22 +274,10 @@ def loadvalidtss():
continue continue
if not translate_exits(x): if not translate_exits(x):
continue continue
tp = globalconfig["fanyi"][x].get("type", "free") alltransvis.append(getannotatedapiname(x))
alltransvis.append(
dynamicapiname(x)
+ "_("
+ {
"free": "在线翻译",
"api": "注册在线翻译",
"dev": "调试浏览器",
"pre": "预翻译",
"offline": "离线翻译",
}.get(tp, "unknown type")
+ ")"
)
alltrans.append(x) alltrans.append(x)
sorted_pairs = sorted(zip(alltransvis, alltrans)) sortAwithB(alltransvis, alltrans)
return [x[1] for x in sorted_pairs], [x[0] for x in sorted_pairs] return alltrans, alltransvis
def gethookembedgrid(self): def gethookembedgrid(self):

View File

@ -61,7 +61,10 @@ class triggereditor(LDialog):
self.hctable.removeselectedrows() self.hctable.removeselectedrows()
def moverank(self, dy): def moverank(self, dy):
src, tgt = self.hctable.moverank(dy) _pair = self.hctable.moverank(dy)
if not _pair:
return
src, tgt = _pair
self.internalrealname.insert(tgt, self.internalrealname.pop(src)) self.internalrealname.insert(tgt, self.internalrealname.pop(src))
def __init__(self, parent) -> None: def __init__(self, parent) -> None:

View File

@ -34,6 +34,7 @@ class FocusCombo(QComboBox):
else: else:
return super().wheelEvent(e) return super().wheelEvent(e)
class SuperCombo(FocusCombo): class SuperCombo(FocusCombo):
Visoriginrole = Qt.ItemDataRole.UserRole + 1 Visoriginrole = Qt.ItemDataRole.UserRole + 1
Internalrole = Visoriginrole + 1 Internalrole = Visoriginrole + 1
@ -1877,7 +1878,10 @@ class listediter(LDialog):
self.moverank(1) self.moverank(1)
def moverank(self, dy): def moverank(self, dy):
src, tgt = self.hctable.moverank(dy) _pair = self.hctable.moverank(dy)
if not _pair:
return
src, tgt = _pair
self.internalrealname.insert(tgt, self.internalrealname.pop(src)) self.internalrealname.insert(tgt, self.internalrealname.pop(src))
def __init__( def __init__(

View File

@ -836,7 +836,9 @@ class audiocapture:
self.data = None self.data = None
self.cb1 = CFUNCTYPE(None, c_void_p, c_size_t)(self.__datacollect) self.cb1 = CFUNCTYPE(None, c_void_p, c_size_t)(self.__datacollect)
self.cb2 = CFUNCTYPE(None, c_void_p)(self.__mutexcb) self.cb2 = CFUNCTYPE(None, c_void_p)(self.__mutexcb)
threading.Thread(target=winsharedutils.StartCaptureAsync, args=(self.cb1, self.cb2)).start() threading.Thread(
target=winsharedutils.StartCaptureAsync, args=(self.cb1, self.cb2)
).start()
class loopbackrecorder: class loopbackrecorder:
@ -1034,6 +1036,27 @@ def dynamicapiname(apiuid):
) )
def getannotatedapiname(x):
tp = globalconfig["fanyi"][x].get("type", "free")
return (
dynamicapiname(x)
+ "_("
+ {
"free": "在线翻译",
"api": "注册在线翻译",
"dev": "调试浏览器",
"pre": "预翻译",
"offline": "离线翻译",
}.get(tp, "unknown type")
+ ")"
)
def sortAwithB(l1, l2):
sorted_pairs = sorted(zip(l1, l2))
return [x[0] for x in sorted_pairs], [x[1] for x in sorted_pairs]
def inrange(n, s, e): def inrange(n, s, e):
return n >= s and n <= e return n >= s and n <= e