This commit is contained in:
恍兮惚兮 2024-06-01 08:56:56 +08:00
parent 0cd736be4e
commit 4b37f8194f
49 changed files with 2112 additions and 1681 deletions

View File

@ -1,5 +1,5 @@
import time import time
import os, threading import os, threading, sys
from qtsymbols import * from qtsymbols import *
from traceback import print_exc from traceback import print_exc
from myutils.config import ( from myutils.config import (
@ -22,16 +22,16 @@ from myutils.utils import (
) )
from myutils.wrapper import threader from myutils.wrapper import threader
from gui.showword import searchwordW from gui.showword import searchwordW
from myutils.hwnd import getpidexe, ListProcess from myutils.hwnd import getpidexe, ListProcess, getExeIcon
from textsource.copyboard import copyboard from textsource.copyboard import copyboard
from textsource.texthook import texthook from textsource.texthook import texthook
from textsource.ocrtext import ocrtext from textsource.ocrtext import ocrtext
import gui.selecthook from gui.selecthook import hookselect
import gui.translatorUI from gui.translatorUI import QUnFrameWindow
from gui.languageset import languageset from gui.languageset import languageset
import zhconv, functools import zhconv, functools
import gui.transhist from gui.transhist import transhist
import gui.edittext from gui.edittext import edittext
import importlib, qtawesome import importlib, qtawesome
from functools import partial from functools import partial
from gui.settin import Settin from gui.settin import Settin
@ -44,6 +44,14 @@ from winsharedutils import pid_running, isDark
from myutils.post import POSTSOLVE from myutils.post import POSTSOLVE
class commonstylebase(QWidget):
setstylesheetsignal = pyqtSignal()
def __init__(self, parent) -> None:
super().__init__(parent)
self.setstylesheetsignal.connect(gobject.baseobject.setcommonstylesheet)
class MAINUI: class MAINUI:
def __init__(self) -> None: def __init__(self) -> None:
super().__init__() super().__init__()
@ -54,6 +62,7 @@ class MAINUI:
self.textsource_p = None self.textsource_p = None
self.currentmd5 = "0" self.currentmd5 = "0"
self.currenttext = "" self.currenttext = ""
self.currenttranslate = ""
self.currentread = "" self.currentread = ""
self.refresh_on_get_trans_signature = 0 self.refresh_on_get_trans_signature = 0
self.currentsignature = None self.currentsignature = None
@ -62,6 +71,12 @@ class MAINUI:
self.outputers = {} self.outputers = {}
self.processmethods = [] self.processmethods = []
self.zhanweifu = 0 self.zhanweifu = 0
self.showocrimage = None
self.showocrimage_cached = None
self.AttachProcessDialog = None
self.edittextui = None
self.edittextui_cached = None
self.edittextui_sync=True
@property @property
def textsource(self): def textsource(self):
@ -366,7 +381,7 @@ class MAINUI:
self.textsource.sqlqueueput((contentraw, classname, res)) self.textsource.sqlqueueput((contentraw, classname, res))
except: except:
pass pass
self.currenttranslate = res
if ( if (
globalconfig["embedded"]["as_fast_as_posible"] globalconfig["embedded"]["as_fast_as_posible"]
or classname == globalconfig["embedded"]["translator_2"] or classname == globalconfig["embedded"]["translator_2"]
@ -456,12 +471,15 @@ class MAINUI:
def starttextsource(self, use=None, checked=True): def starttextsource(self, use=None, checked=True):
self.translation_ui.showhidestate = False self.translation_ui.showhidestate = False
self.translation_ui.refreshtooliconsignal.emit() self.translation_ui.refreshtooliconsignal.emit()
self.settin_ui.selectbutton.setEnabled( try:
globalconfig["sourcestatus2"]["texthook"]["use"] self.settin_ui.selectbutton.setEnabled(
) globalconfig["sourcestatus2"]["texthook"]["use"]
self.settin_ui.selecthookbutton.setEnabled( )
globalconfig["sourcestatus2"]["texthook"]["use"] self.settin_ui.selecthookbutton.setEnabled(
) globalconfig["sourcestatus2"]["texthook"]["use"]
)
except:
pass
self.textsource = None self.textsource = None
if checked: if checked:
classes = {"ocr": ocrtext, "copy": copyboard, "texthook": None} classes = {"ocr": ocrtext, "copy": copyboard, "texthook": None}
@ -589,11 +607,39 @@ class MAINUI:
return aclass(type_) return aclass(type_)
def maybesetimage(self, pair):
if self.showocrimage:
self.showocrimage.setimage.emit(pair)
self.showocrimage_cached = pair
def createshowocrimage(self):
self.showocrimage = showocrimage(self.settin_ui, self.showocrimage_cached)
if self.showocrimage:
self.showocrimage.show()
def maybesetedittext(self, text):
if self.edittextui:
self.edittextui.getnewsentencesignal.emit(text)
self.edittextui_cached = text
def createedittextui(self):
self.edittextui = edittext(self.settin_ui, self.edittextui_cached)
if self.edittextui:
self.edittextui.show()
def createattachprocess(self):
self.AttachProcessDialog = AttachProcessDialog(
self.settin_ui, self.selectprocess, self.hookselectdialog
)
if self.AttachProcessDialog:
self.AttachProcessDialog.show()
def onwindowloadautohook(self): def onwindowloadautohook(self):
textsourceusing = globalconfig["sourcestatus2"]["texthook"]["use"] textsourceusing = globalconfig["sourcestatus2"]["texthook"]["use"]
if not (globalconfig["autostarthook"] and textsourceusing): if not (globalconfig["autostarthook"] and textsourceusing):
return return
elif self.AttachProcessDialog.isVisible(): elif self.AttachProcessDialog and self.AttachProcessDialog.isVisible():
return return
else: else:
try: try:
@ -631,9 +677,14 @@ class MAINUI:
"onloadautoswitchsrclang" "onloadautoswitchsrclang"
] ]
if onloadautoswitchsrclang > 0: if onloadautoswitchsrclang > 0:
self.settin_ui.srclangswitcher.setCurrentIndex( try:
onloadautoswitchsrclang - 1 self.settin_ui.srclangswitcher.setCurrentIndex(
) onloadautoswitchsrclang - 1
)
except:
globalconfig["srclang3"] = (
onloadautoswitchsrclang - 1
)
break break
else: else:
@ -727,32 +778,6 @@ class MAINUI:
int(widget.winId()), dark, globalconfig["WindowBackdrop"] int(widget.winId()), dark, globalconfig["WindowBackdrop"]
) )
def aa(self):
class WindowEventFilter(QObject):
def eventFilter(_, obj, event):
if event.type() == QEvent.Type.WinIdChange:
hwnd = obj.winId()
if hwnd: # window create/destroy,when destroy winId is None
if self.currentisdark is not None:
self.setdarktheme(obj, self.currentisdark)
windows.SetProp(
int(obj.winId()),
"Magpie.WindowType.ToolWindow",
windows.HANDLE(1),
)
self.setshowintab_checked(obj)
return False
self.currentisdark = None
self.__filter = WindowEventFilter() # keep ref
QApplication.instance().installEventFilter(self.__filter)
self.translation_ui = gui.translatorUI.QUnFrameWindow()
self.translation_ui.show()
self.mainuiloadafter()
def checkgameplayingthread(self): def checkgameplayingthread(self):
self.tracestarted = False self.tracestarted = False
while True: while True:
@ -839,7 +864,18 @@ class MAINUI:
trayMenu.addAction(settingAction) trayMenu.addAction(settingAction)
trayMenu.addSeparator() trayMenu.addSeparator()
trayMenu.addAction(quitAction) trayMenu.addAction(quitAction)
self.translation_ui.tray.setContextMenu(trayMenu) self.tray = QSystemTrayIcon()
icon = getExeIcon(sys.argv[0]) #'./LunaTranslator.exe')# QIcon()
self.tray.setIcon(icon)
self.tray.activated.connect(self.translation_ui.leftclicktray)
self.tray.show()
self.tray.setContextMenu(trayMenu)
def destroytray(self):
self.tray.hide()
self.tray = None
def setshowintab(self): def setshowintab(self):
for widget in QApplication.topLevelWidgets(): for widget in QApplication.topLevelWidgets():
@ -885,28 +921,28 @@ class MAINUI:
+ (globalconfig["settingfonttype"]) + (globalconfig["settingfonttype"])
+ "' ; }" + "' ; }"
) )
self.settin_ui.setStyleSheet(style) self.__commonstylebase.setStyleSheet(style)
def loadui(self):
self.installeventfillter()
self.translation_ui = QUnFrameWindow()
self.translation_ui.show()
self.translation_ui.aftershowdosomething()
self.mainuiloadafter()
def mainuiloadafter(self): def mainuiloadafter(self):
self.setshowintab()
self.safeloadprocessmodels() self.safeloadprocessmodels()
self.prepare() self.prepare()
self.startxiaoxueguan() self.startxiaoxueguan()
self.starthira() self.starthira()
self.startoutputer() self.startoutputer()
self.settin_ui = Settin(self.translation_ui) self.__commonstylebase = commonstylebase(self.translation_ui)
self.inittray()
self.setcommonstylesheet() self.setcommonstylesheet()
self.transhis = gui.transhist.transhist(self.settin_ui) self.settin_ui = Settin(self.__commonstylebase)
self.transhis = transhist(self.settin_ui)
self.startreader() self.startreader()
self.edittextui = gui.edittext.edittext(self.settin_ui)
self.searchwordW = searchwordW(self.settin_ui) self.searchwordW = searchwordW(self.settin_ui)
self.hookselectdialog = gui.selecthook.hookselect(self.settin_ui) self.hookselectdialog = hookselect(self.settin_ui)
self.showocrimage = showocrimage(self.settin_ui)
self.AttachProcessDialog = AttachProcessDialog(
self.settin_ui, self.selectprocess, self.hookselectdialog
)
self.starttextsource() self.starttextsource()
threading.Thread(target=self.autocheckhwndexists).start() threading.Thread(target=self.autocheckhwndexists).start()
threading.Thread(target=self.autohookmonitorthread).start() threading.Thread(target=self.autohookmonitorthread).start()
@ -914,6 +950,38 @@ class MAINUI:
target=minmaxmoveobservefunc, args=(self.translation_ui,) target=minmaxmoveobservefunc, args=(self.translation_ui,)
).start() ).start()
threading.Thread(target=self.checkgameplayingthread).start() threading.Thread(target=self.checkgameplayingthread).start()
threading.Thread(target=self.darklistener).start()
self.inittray()
def darklistener(self):
sema = winsharedutils.startdarklistener()
while True:
# 会触发两次
windows.WaitForSingleObject(sema, windows.INFINITE)
if globalconfig["darklight"] == 2:
self.__commonstylebase.setstylesheetsignal.emit()
windows.WaitForSingleObject(sema, windows.INFINITE)
def installeventfillter(self):
class WindowEventFilter(QObject):
def eventFilter(_, obj, event):
if event.type() == QEvent.Type.WinIdChange:
hwnd = obj.winId()
if hwnd: # window create/destroy,when destroy winId is None
if self.currentisdark is not None:
self.setdarktheme(obj, self.currentisdark)
windows.SetProp(
int(obj.winId()),
"Magpie.WindowType.ToolWindow",
windows.HANDLE(1),
)
self.setshowintab_checked(obj)
return False
self.currentisdark = None
self.__filter = WindowEventFilter() # keep ref
QApplication.instance().installEventFilter(self.__filter)
def checklang(self): def checklang(self):
if globalconfig["language_setted_2.4.5"] == False: if globalconfig["language_setted_2.4.5"] == False:

View File

@ -1,5 +1,5 @@
import sys, windows import sys, windows
import platform, os import platform, os, time
if __name__ == "__main__": if __name__ == "__main__":
_lock = windows.AutoHandle(windows.CreateMutex(False, "LUNA_UPDATER_BLOCK")) _lock = windows.AutoHandle(windows.CreateMutex(False, "LUNA_UPDATER_BLOCK"))
@ -18,8 +18,6 @@ if __name__ == "__main__":
0, "./LunaTranslator/network/" + ["winhttp", "libcurl"][globalconfig["network"]] 0, "./LunaTranslator/network/" + ["winhttp", "libcurl"][globalconfig["network"]]
) )
from gui.usefulwidget import getQMessageBox
from LunaTranslator import MAINUI
import gobject import gobject
gobject.overridepathexists() gobject.overridepathexists()
@ -60,6 +58,8 @@ if __name__ == "__main__":
if os.path.exists(f) == False: if os.path.exists(f) == False:
collect.append(f) collect.append(f)
if len(collect): if len(collect):
from gui.usefulwidget import getQMessageBox
getQMessageBox( getQMessageBox(
None, None,
_TR("错误"), _TR("错误"),
@ -72,7 +72,9 @@ if __name__ == "__main__":
) )
os._exit(0) os._exit(0)
from LunaTranslator import MAINUI
gobject.baseobject = MAINUI() gobject.baseobject = MAINUI()
gobject.baseobject.checklang() gobject.baseobject.checklang()
gobject.baseobject.aa() gobject.baseobject.loadui()
app.exit(app.exec()) app.exit(app.exec())

View File

@ -3,7 +3,8 @@ from winsharedutils import getpidhwndfirst
import functools import functools
from myutils.config import globalconfig, _TR from myutils.config import globalconfig, _TR
import windows import windows
import os import os, gobject
from myutils.wrapper import Singleton_close
from myutils.hwnd import ( from myutils.hwnd import (
getpidexe, getpidexe,
ListProcess, ListProcess,
@ -12,10 +13,11 @@ from myutils.hwnd import (
) )
import qtawesome import qtawesome
from gui.usefulwidget import closeashidewindow, getQMessageBox from gui.usefulwidget import saveposwindow, getQMessageBox
class AttachProcessDialog(closeashidewindow): @Singleton_close
class AttachProcessDialog(saveposwindow):
setcurrentpidpnamesignal = pyqtSignal(int, int) setcurrentpidpnamesignal = pyqtSignal(int, int)
@ -37,10 +39,12 @@ class AttachProcessDialog(closeashidewindow):
self.windowtext.setText(windows.GetWindowText(hwnd)) self.windowtext.setText(windows.GetWindowText(hwnd))
self.selectedp = (_pids, name, hwnd) self.selectedp = (_pids, name, hwnd)
def closeEvent(self, e):
gobject.baseobject.AttachProcessDialog = None
super().closeEvent(e)
def __init__(self, parent, callback, hookselectdialog=None): def __init__(self, parent, callback, hookselectdialog=None):
super(AttachProcessDialog, self).__init__( super().__init__(parent, globalconfig, "attachprocessgeo")
parent, globalconfig, "attachprocessgeo"
)
self.setcurrentpidpnamesignal.connect(self.selectwindowcallback) self.setcurrentpidpnamesignal.connect(self.selectwindowcallback)
self.iconcache = {} self.iconcache = {}

View File

@ -473,7 +473,8 @@ class browserdialog(saveposwindow):
def __init__(self, parent, exepath=None) -> None: def __init__(self, parent, exepath=None) -> None:
super().__init__(parent, globalconfig, "browserwidget") super().__init__(parent, globalconfig, "browserwidget")
if exepath:
self.setWindowIcon(getExeIcon(exepath, cache=True))
self.browser = auto_select_webview(self) self.browser = auto_select_webview(self)
self.tagswidget = TagWidget(self) self.tagswidget = TagWidget(self)

View File

@ -3,22 +3,28 @@ import qtawesome
import threading, windows import threading, windows
import gobject, time import gobject, time
from myutils.config import globalconfig, _TR, _TRL from myutils.config import globalconfig, _TR, _TRL
from gui.usefulwidget import closeashidewindow, getsimplecombobox from gui.usefulwidget import saveposwindow, getsimplecombobox
from myutils.utils import str2rgba from myutils.utils import str2rgba
from myutils.wrapper import Singleton_close, threader from myutils.wrapper import Singleton_close, threader
class edittext(closeashidewindow): @Singleton_close
class edittext(saveposwindow):
getnewsentencesignal = pyqtSignal(str) getnewsentencesignal = pyqtSignal(str)
def __init__(self, parent): def closeEvent(self, e):
super(edittext, self).__init__(parent, globalconfig, "edit_geo") gobject.baseobject.edittextui = None
self.sync = True super().closeEvent(e)
def __init__(self, parent, cached):
super().__init__(parent, globalconfig, "edit_geo")
self.setupUi() self.setupUi()
# self.setWindowFlags(self.windowFlags()&~Qt.WindowMinimizeButtonHint) # self.setWindowFlags(self.windowFlags()&~Qt.WindowMinimizeButtonHint)
self.getnewsentencesignal.connect(self.getnewsentence) self.getnewsentencesignal.connect(self.getnewsentence)
self.setWindowTitle(_TR("编辑")) self.setWindowTitle(_TR("编辑"))
if cached:
self.getnewsentence(cached)
def setupUi(self): def setupUi(self):
self.setWindowIcon(qtawesome.icon("fa.edit")) self.setWindowIcon(qtawesome.icon("fa.edit"))
@ -43,8 +49,12 @@ class edittext(closeashidewindow):
) )
bt2 = QPushButton( bt2 = QPushButton(
icon=qtawesome.icon( icon=qtawesome.icon(
"fa.forward" if self.sync else "fa.play", "fa.forward" if gobject.baseobject.edittextui_sync else "fa.play",
color="#FF69B4" if self.sync else globalconfig["buttoncolor"], color=(
"#FF69B4"
if gobject.baseobject.edittextui_sync
else globalconfig["buttoncolor"]
),
) )
) )
@ -66,11 +76,15 @@ class edittext(closeashidewindow):
).start() ).start()
def changestate(self): def changestate(self):
self.sync = not self.sync gobject.baseobject.edittextui_sync = not gobject.baseobject.edittextui_sync
self.bt2.setIcon( self.bt2.setIcon(
qtawesome.icon( qtawesome.icon(
"fa.forward" if self.sync else "fa.play", "fa.forward" if gobject.baseobject.edittextui_sync else "fa.play",
color="#FF69B4" if self.sync else globalconfig["buttoncolor"], color=(
"#FF69B4"
if gobject.baseobject.edittextui_sync
else globalconfig["buttoncolor"]
),
) )
) )
@ -83,7 +97,7 @@ class edittext(closeashidewindow):
self.textOutput.clear() self.textOutput.clear()
def getnewsentence(self, sentence): def getnewsentence(self, sentence):
if self.sync: if gobject.baseobject.edittextui_sync:
self.textOutput.setPlainText(sentence) self.textOutput.setPlainText(sentence)

View File

@ -0,0 +1,171 @@
import functools
from qtsymbols import *
from myutils.config import globalconfig, _TR, _TRL
from myutils.wrapper import Singleton
import qtawesome, gobject, json
from gui.usefulwidget import (
D_getsimplecombobox,
D_getcolorbutton,
getcolorbutton,
makescrollgrid,
D_getsimpleswitch,
)
@Singleton
class dialog_selecticon(QDialog):
def __init__(self, parent, dict, key, _nouse_for_click_arg) -> None:
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
self.dict = dict
self.key = key
self.setWindowTitle(_TR("选择图标"))
with open(
"./files/fonts/fontawesome4.7-webfont-charmap.json", "r", encoding="utf8"
) as ff:
js = json.load(ff)
layout = QGridLayout()
self.setLayout(layout)
for i, name in enumerate(js):
layout.addWidget(
getcolorbutton(
"",
"",
functools.partial(self.selectcallback, "fa." + name),
qicon=qtawesome.icon(
"fa." + name, color=globalconfig["buttoncolor"]
),
),
i // 30,
i % 30,
)
self.show()
def selectcallback(self, _):
print(_)
self.dict[self.key] = _
self.close()
def doadjust():
gobject.baseobject.translation_ui.enterfunction(delay=3)
gobject.baseobject.translation_ui.adjustbuttons()
def changerank(item, up, sortlist, savelist, savelay):
idx = sortlist.index(item)
idx2 = idx + (-1 if up else 1)
if idx2 < 0 or idx2 >= len(sortlist):
return
headoffset = 1
idx2 = idx + (-1 if up else 1)
sortlist[idx], sortlist[idx2] = sortlist[idx2], sortlist[idx]
for i, ww in enumerate(savelist[idx + headoffset]):
w1 = savelay[0].indexOf(ww)
w2 = savelay[0].indexOf(savelist[idx2 + headoffset][i])
p1 = savelay[0].getItemPosition(w1)
p2 = savelay[0].getItemPosition(w2)
savelay[0].removeWidget(ww)
savelay[0].removeWidget(savelist[idx2 + headoffset][i])
savelay[0].addWidget(savelist[idx2 + headoffset][i], *p1)
savelay[0].addWidget(ww, *p2)
savelist[idx + headoffset], savelist[idx2 + headoffset] = (
savelist[idx2 + headoffset],
savelist[idx + headoffset],
)
doadjust()
def createbuttonwidget(self, lay):
# return table
grids = [["显示", "", "", "对齐", "图标", "图标2", "说明"]]
sortlist = globalconfig["toolbutton"]["rank2"]
savelist = []
savelay = []
for i, k in enumerate(sortlist):
button_up = D_getcolorbutton(
globalconfig,
"",
callback=functools.partial(
changerank, k, True, sortlist, savelist, savelay
),
icon="fa.arrow-up",
constcolor="#FF69B4",
)
button_down = D_getcolorbutton(
globalconfig,
"",
callback=functools.partial(
changerank, k, False, sortlist, savelist, savelay
),
icon="fa.arrow-down",
constcolor="#FF69B4",
)
l = [
D_getsimpleswitch(
globalconfig["toolbutton"]["buttons"][k],
"use",
callback=lambda _: doadjust(),
),
button_up,
button_down,
D_getsimplecombobox(
_TRL(["居左", "居右", "居中"]),
globalconfig["toolbutton"]["buttons"][k],
"align",
callback=lambda _: doadjust(),
fixedsize=True,
),
D_getcolorbutton(
"",
"",
functools.partial(
dialog_selecticon,
self,
globalconfig["toolbutton"]["buttons"][k],
"icon",
),
qicon=qtawesome.icon(
globalconfig["toolbutton"]["buttons"][k]["icon"],
color=globalconfig["buttoncolor"],
),
),
]
if "icon2" in globalconfig["toolbutton"]["buttons"][k]:
l.append(
D_getcolorbutton(
"",
"",
functools.partial(
dialog_selecticon,
self,
globalconfig["toolbutton"]["buttons"][k],
"icon2",
),
qicon=qtawesome.icon(
globalconfig["toolbutton"]["buttons"][k]["icon2"],
color=globalconfig["buttoncolor"],
),
),
)
else:
l.append("")
if "belong" in globalconfig["toolbutton"]["buttons"][k]:
belong = (
"_"
+ ""
+ "_"
+ " ".join(globalconfig["toolbutton"]["buttons"][k]["belong"])
)
else:
belong = ""
l.append(globalconfig["toolbutton"]["buttons"][k]["tip"] + belong)
grids.append(l)
makescrollgrid(grids, lay, True, savelist, savelay)

View File

@ -0,0 +1,327 @@
import functools
from qtsymbols import *
from myutils.config import globalconfig, magpie_config, static_data
from gui.inputdialog import getsomepath1
from gui.usefulwidget import (
D_getsimplecombobox,
makegrid,
D_getspinbox,
getvboxwidget,
D_getcolorbutton,
makesubtab_lazy,
makescrollgrid,
D_getsimpleswitch,
)
def makescalew(self, lay):
commonfsgrid = [
[
("缩放方式", 4),
(
D_getsimplecombobox(
static_data["scalemethods_vis"],
globalconfig,
"fullscreenmethod_4",
),
6,
),
]
]
losslessgrid = [
[
("Magpie_路径", 4),
(
D_getcolorbutton(
globalconfig,
"",
callback=lambda x: getsomepath1(
self,
"Magpie_路径",
globalconfig,
"magpiepath",
"Magpie_路径",
isdir=True,
),
icon="fa.gear",
constcolor="#FF69B4",
),
1,
),
],
[
("Hook Magpie进程使其不会退出缩放", 4),
D_getsimpleswitch(globalconfig, "hookmagpie"),
],
]
innermagpie = [
[("常规", -1)],
[
("", 1),
("缩放模式", 4),
(
D_getsimplecombobox(
[_["name"] for _ in magpie_config["scalingModes"]],
magpie_config["profiles"][globalconfig["profiles_index"]],
"scalingMode",
),
6,
),
"",
],
[
("", 1),
("捕获模式", 4),
(
D_getsimplecombobox(
[
"Graphics Capture",
"Desktop Duplication",
"GDI",
"DwmSharedSurface",
],
magpie_config["profiles"][globalconfig["profiles_index"]],
"captureMethod",
),
6,
),
],
[
("", 1),
("3D游戏模式", 4),
(
D_getsimpleswitch(
magpie_config["profiles"][globalconfig["profiles_index"]],
"3DGameMode",
)
),
],
[("性能", -1)],
[
("", 1),
("显示帧率", 4),
(
D_getsimpleswitch(
magpie_config["profiles"][globalconfig["profiles_index"]],
"showFPS",
)
),
],
[
("", 1),
("限制帧率", 4),
(
D_getsimpleswitch(
magpie_config["profiles"][globalconfig["profiles_index"]],
"frameRateLimiterEnabled",
)
),
],
[
("", 1),
("最大帧率", 4),
(
D_getspinbox(
0,
9999,
magpie_config["profiles"][globalconfig["profiles_index"]],
"maxFrameRate",
),
2,
),
],
[("源窗口", -1)],
[
("", 1),
("缩放时禁用窗口大小调整", 4),
(
D_getsimpleswitch(
magpie_config["profiles"][globalconfig["profiles_index"]],
"disableWindowResizing",
)
),
],
[
("", 1),
("捕获标题栏", 4),
(
D_getsimpleswitch(
magpie_config["profiles"][globalconfig["profiles_index"]],
"captureTitleBar",
)
),
],
[
("", 1),
("自定义剪裁", 4),
(
D_getsimpleswitch(
magpie_config["profiles"][globalconfig["profiles_index"]],
"croppingEnabled",
)
),
],
[("光标", -1)],
[
("", 1),
("绘制光标", 4),
(
D_getsimpleswitch(
magpie_config["profiles"][globalconfig["profiles_index"]],
"drawCursor",
)
),
],
[
("", 1),
("绘制光标_缩放系数", 4),
(
D_getsimplecombobox(
["0.5x", "0.75x", "无缩放", "1.25x", "1.5x", "2x", "和源窗口相同"],
magpie_config["profiles"][globalconfig["profiles_index"]],
"cursorScaling",
),
6,
),
],
[
("", 1),
("绘制光标_插值算法", 4),
(
D_getsimplecombobox(
["最邻近", "双线性"],
magpie_config["profiles"][globalconfig["profiles_index"]],
"cursorInterpolationMode",
),
6,
),
],
[
("", 1),
("缩放时调整光标速度", 4),
(
D_getsimpleswitch(
magpie_config["profiles"][globalconfig["profiles_index"]],
"adjustCursorSpeed",
)
),
],
[("高级", -1)],
[
("", 1),
("禁用DirectFlip", 4),
(
D_getsimpleswitch(
magpie_config["profiles"][globalconfig["profiles_index"]],
"disableDirectFlip",
)
),
],
[
("", 1),
("允许缩放最大化或全屏的窗口", 4),
(D_getsimpleswitch(magpie_config, "allowScalingMaximized")),
],
[
("", 1),
("缩放时模拟独占全屏", 4),
(D_getsimpleswitch(magpie_config, "simulateExclusiveFullscreen")),
],
[
("", 1),
("内联效果参数", 4),
(D_getsimpleswitch(magpie_config, "inlineParams")),
],
[("开发者选项", -1)],
[
("", 1),
("调试模式", 4),
(
D_getsimpleswitch(
magpie_config,
"debugMode",
)
),
],
[
("", 1),
("禁用效果缓存", 4),
(
D_getsimpleswitch(
magpie_config,
"disableEffectCache",
)
),
],
[
("", 1),
("禁用字体缓存", 4),
(
D_getsimpleswitch(
magpie_config,
"disableFontCache",
)
),
],
[
("", 1),
("解析效果时保存源代码", 4),
(
D_getsimpleswitch(
magpie_config,
"saveEffectSources",
)
),
],
[
("", 1),
("编译效果时将警告视为错误", 4),
(
D_getsimpleswitch(
magpie_config,
"warningsAreErrors",
)
),
],
[
("", 1),
("检测重复帧", 4),
(
D_getsimplecombobox(
["总是检测", "动态检测", "从不检测"],
magpie_config,
"duplicateFrameDetectionMode",
),
6,
),
],
[
("", 1),
("启用动态检测统计", 4),
(
D_getsimpleswitch(
magpie_config,
"enableStatisticsForDynamicDetection",
)
),
],
]
vw, vl = getvboxwidget()
lay.addWidget(vw)
gw, gd = makegrid(commonfsgrid, delay=True)
vl.addWidget(gw)
tw, td = makesubtab_lazy(
["Magpie", "外部缩放软件"],
[
functools.partial(makescrollgrid, innermagpie),
functools.partial(makescrollgrid, losslessgrid),
],
delay=True,
)
vl.addWidget(tw)
gd()
td()

View File

@ -0,0 +1,231 @@
import functools
from qtsymbols import *
from gui.inputdialog import multicolorset
from myutils.config import globalconfig, _TRL
import gobject
from gui.usefulwidget import (
D_getsimplecombobox,
getsimpleswitch,
D_getspinbox,
getspinbox,
D_getcolorbutton,
D_getsimpleswitch,
selectcolor,
)
def maybehavefontsizespin(self, t):
if "fontSize_spinBox" in dir(self):
self.fontSize_spinBox.setValue(self.fontSize_spinBox.value() + 0.5 * t)
else:
globalconfig["fontsize"] += 0.5 * t
def createfontsizespin(self):
self.fontSize_spinBox = getspinbox(
1, 100, globalconfig, "fontsize", double=True, step=0.1
)
return self.fontSize_spinBox
def __changeuibuttonstate(self, x):
gobject.baseobject.translation_ui.refreshtoolicon()
try:
self.show_hira_switch.setEnabled(x)
self.show_fenciswitch.setEnabled(x)
except:
pass
def createtextfontcom(key):
font_comboBox = QFontComboBox()
font_comboBox.currentTextChanged.connect(lambda x: globalconfig.__setitem__(key, x))
font_comboBox.setCurrentFont(QFont(globalconfig[key]))
return font_comboBox
def createshoworiginswitch(self):
self.show_original_switch = getsimpleswitch(
globalconfig, "isshowrawtext", callback=lambda x: __changeuibuttonstate(self, x)
)
return self.show_original_switch
def createhiraswitch(self):
self.show_hira_switch = getsimpleswitch(
globalconfig, "isshowhira", enable=globalconfig["isshowrawtext"]
)
return self.show_hira_switch
def createfenciwitch(self):
self.show_fenciswitch = getsimpleswitch(
globalconfig, "show_fenci", enable=globalconfig["isshowrawtext"]
)
return self.show_fenciswitch
def xianshigrid(self):
textgrid = [
[
("原文字体", 3),
(functools.partial(createtextfontcom, "fonttype"), 6),
("", 5),
],
[
("译文字体", 3),
(functools.partial(createtextfontcom, "fonttype2"), 6),
],
[
("字体大小", 3),
(functools.partial(createfontsizespin, self), 3),
"",
("额外的行间距", 3),
(D_getspinbox(-100, 100, globalconfig, "extra_space"), 3),
],
[
("居中显示", 5),
D_getsimpleswitch(globalconfig, "showatcenter"),
"",
("加粗字体", 5),
D_getsimpleswitch(globalconfig, "showbold"),
],
[
"",
],
[
("字体样式", 3),
(
D_getsimplecombobox(
_TRL(
[
"普通字体",
"空心字体",
"描边字体",
"描边字体_2",
"描边字体_2_投影",
"发光字体",
]
),
globalconfig,
"zitiyangshi2",
),
6,
),
],
[
("特殊字体样式填充颜色", 5),
D_getcolorbutton(
globalconfig,
"miaobiancolor",
transparent=False,
callback=lambda: selectcolor(
self, globalconfig, "miaobiancolor", self.miaobian_color_button
),
name="miaobian_color_button",
parent=self,
),
],
[
("空心线宽", 3),
(
D_getspinbox(
0.1, 100, globalconfig, "miaobianwidth", double=True, step=0.1
),
3,
),
"",
("描边宽度", 3),
(
D_getspinbox(
0.1, 100, globalconfig, "miaobianwidth2", double=True, step=0.1
),
3,
),
],
[
("发光亮度", 3),
(D_getspinbox(1, 100, globalconfig, "shadowforce"), 3),
"",
("投影距离", 3),
(
D_getspinbox(
0.1, 100, globalconfig, "traceoffset", double=True, step=0.1
),
3,
),
],
[],
[
("显示原文", 5),
functools.partial(createshoworiginswitch, self),
"",
("显示翻译", 5),
(D_getsimpleswitch(globalconfig, "showfanyi"), 1),
],
[
("原文颜色", 5),
D_getcolorbutton(
globalconfig,
"rawtextcolor",
callback=lambda: selectcolor(
self, globalconfig, "rawtextcolor", self.original_color_button
),
name="original_color_button",
parent=self,
),
"",
("显示翻译器名称", 5),
(D_getsimpleswitch(globalconfig, "showfanyisource"), 1),
],
[
("最长显示字数", 3),
(D_getspinbox(0, 1000000, globalconfig, "maxoriginlength"), 3),
],
[],
[
("显示日语注音", 5),
functools.partial(createhiraswitch, self),
],
[
("注音颜色", 5),
D_getcolorbutton(
globalconfig,
"jiamingcolor",
callback=lambda: selectcolor(
self, globalconfig, "jiamingcolor", self.jiamingcolor_b
),
name="jiamingcolor_b",
parent=self,
),
"",
("注音字体缩放", 3),
(
D_getspinbox(
0.05, 1, globalconfig, "kanarate", double=True, step=0.05, dec=2
),
3,
),
],
[
("语法加亮", 5),
functools.partial(createfenciwitch, self),
"",
("词性颜色(需要Mecab)", 5),
D_getcolorbutton(
globalconfig,
"",
callback=lambda: multicolorset(self),
icon="fa.gear",
constcolor="#FF69B4",
),
],
[],
[
("收到翻译结果时才刷新", 5),
D_getsimpleswitch(globalconfig, "refresh_on_get_trans"),
],
]
return textgrid

View File

@ -0,0 +1,271 @@
import functools
from qtsymbols import *
from myutils.config import globalconfig, _TRL, static_data
import gobject
from gui.usefulwidget import (
D_getsimplecombobox,
D_getspinbox,
D_getcolorbutton,
D_getsimpleswitch,
selectcolor,
)
def changeHorizontal(self):
globalconfig["transparent"] = self.horizontal_slider.value()
try:
self.horizontal_slider_label.setText("{}%".format(globalconfig["transparent"]))
except:
pass
#
gobject.baseobject.translation_ui.set_color_transparency()
def createhorizontal_slider(self):
self.horizontal_slider = QSlider()
self.horizontal_slider.setMaximum(100)
self.horizontal_slider.setMinimum(1)
self.horizontal_slider.setOrientation(Qt.Orientation.Horizontal)
self.horizontal_slider.setValue(0)
self.horizontal_slider.setValue(globalconfig["transparent"])
self.horizontal_slider.valueChanged.connect(
functools.partial(changeHorizontal, self)
)
return self.horizontal_slider
def createhorizontal_slider_label(self):
self.horizontal_slider_label = QLabel()
self.horizontal_slider_label.setText("{}%".format(globalconfig["transparent"]))
return self.horizontal_slider_label
def changeHorizontal_tool(self):
globalconfig["transparent_tool"] = self.horizontal_slider_tool.value()
try:
self.horizontal_slider_tool_label.setText(
"{}%".format(globalconfig["transparent_tool"])
)
except:
pass
#
gobject.baseobject.translation_ui.set_color_transparency()
def createhorizontal_slider_tool(self):
self.horizontal_slider_tool = QSlider()
self.horizontal_slider_tool.setMaximum(100)
self.horizontal_slider_tool.setMinimum(1)
self.horizontal_slider_tool.setOrientation(Qt.Orientation.Horizontal)
self.horizontal_slider_tool.setValue(0)
self.horizontal_slider_tool.setValue(globalconfig["transparent_tool"])
self.horizontal_slider_tool.valueChanged.connect(
functools.partial(changeHorizontal_tool, self)
)
return self.horizontal_slider_tool
def createhorizontal_slider_tool_label(self):
self.horizontal_slider_tool_label = QLabel()
self.horizontal_slider_tool_label.setText(
"{}%".format(globalconfig["transparent_tool"])
)
return self.horizontal_slider_tool_label
def createfontcombo():
sfont_comboBox = QFontComboBox()
def callback(x):
globalconfig.__setitem__("settingfonttype", x)
gobject.baseobject.setcommonstylesheet()
sfont_comboBox.setCurrentFont(QFont(globalconfig["settingfonttype"]))
sfont_comboBox.currentTextChanged.connect(callback)
return sfont_comboBox
def uisetting(self):
def themelist(t):
return [_["name"] for _ in static_data["themes"][t]]
uigrid = [
[("设置界面字体", 4), (createfontcombo, 5)],
[
("字体大小", 4),
(
D_getspinbox(
1,
100,
globalconfig,
"settingfontsize",
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
),
2,
),
],
[
("不透明度_翻译窗口", 4),
(functools.partial(createhorizontal_slider, self), 8),
(functools.partial(createhorizontal_slider_label, self), 2),
],
[
("不透明度_工具栏", 4),
(functools.partial(createhorizontal_slider_tool, self), 8),
(functools.partial(createhorizontal_slider_tool_label, self), 2),
],
[
("背景颜色_翻译窗口", 4),
D_getcolorbutton(
globalconfig,
"backcolor",
callback=lambda: selectcolor(
self,
globalconfig,
"backcolor",
self.back_color_button,
callback=gobject.baseobject.translation_ui.set_color_transparency,
),
name="back_color_button",
parent=self,
),
"",
"",
("背景颜色_工具栏", 4),
D_getcolorbutton(
globalconfig,
"backcolor_tool",
callback=lambda: selectcolor(
self,
globalconfig,
"backcolor_tool",
self.back_color_button_tool,
callback=gobject.baseobject.translation_ui.set_color_transparency,
),
name="back_color_button_tool",
parent=self,
),
],
[
("工具按钮颜色", 4),
D_getcolorbutton(
globalconfig,
"buttoncolor",
callback=lambda: selectcolor(
self,
globalconfig,
"buttoncolor",
self.buttoncolorbutton,
callback=lambda: gobject.baseobject.translation_ui.refreshtooliconsignal.emit(),
),
name="buttoncolorbutton",
parent=self,
),
"",
"",
("工具按钮大小", 4),
(
D_getspinbox(
5,
100,
globalconfig,
"buttonsize",
callback=lambda _: gobject.baseobject.translation_ui.refreshtooliconsignal.emit(),
),
2,
),
],
[
("圆角_半径", 4),
(
D_getspinbox(
0,
100,
globalconfig,
"yuanjiao_r",
callback=lambda _: gobject.baseobject.translation_ui.set_color_transparency(),
),
2,
),
"",
("圆角_合并", 4),
D_getsimpleswitch(
globalconfig,
"yuanjiao_merge",
callback=lambda _: gobject.baseobject.translation_ui.set_color_transparency(),
),
],
[],
[
("明暗", 4),
(
D_getsimplecombobox(
_TRL(["明亮", "黑暗", "跟随系统"]),
globalconfig,
"darklight",
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
),
5,
),
],
[
("明亮主题", 4),
(
D_getsimplecombobox(
_TRL(["默认"]) + themelist("light"),
globalconfig,
"lighttheme",
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
),
5,
),
],
[
("黑暗主题", 4),
(
D_getsimplecombobox(
themelist("dark"),
globalconfig,
"darktheme",
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
),
5,
),
],
[],
[
("窗口特效_翻译窗口", 4),
(
D_getsimplecombobox(
["Disable", "Acrylic", "Aero"],
globalconfig,
"WindowEffect",
callback=lambda _: [
gobject.baseobject.translation_ui.set_color_transparency(),
gobject.baseobject.translation_ui.seteffect(),
],
),
5,
),
],
[
("窗口特效_其他", 4),
(
D_getsimplecombobox(
["Solid", "Acrylic", "Mica", "MicaAlt"],
globalconfig,
"WindowBackdrop",
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
),
5,
),
],
]
return uigrid

View File

@ -18,7 +18,7 @@ from gui.usefulwidget import (
getsimpleswitch, getsimpleswitch,
textbrowappendandmovetoend, textbrowappendandmovetoend,
) )
from myutils.utils import checkchaos from myutils.utils import checkchaos, get_time_stamp
from gui.dialog_savedgame import dialog_setting_game from gui.dialog_savedgame import dialog_setting_game
@ -379,7 +379,6 @@ class hookselect(closeashidewindow):
def __init__(self, parent): def __init__(self, parent):
super(hookselect, self).__init__(parent, globalconfig, "selecthookgeo") super(hookselect, self).__init__(parent, globalconfig, "selecthookgeo")
self.setupUi() self.setupUi()
self.changeprocessclearsignal.connect(self.changeprocessclear) self.changeprocessclearsignal.connect(self.changeprocessclear)
self.removehooksignal.connect(self.removehook) self.removehooksignal.connect(self.removehook)
self.addnewhooksignal.connect(self.addnewhook) self.addnewhooksignal.connect(self.addnewhook)
@ -576,12 +575,14 @@ class hookselect(closeashidewindow):
) )
def setupUi(self): def setupUi(self):
self.widget = QWidget() self.widget = QWidget()
self.setCentralWidget(self.widget)
self.setWindowIcon(qtawesome.icon("fa.gear")) self.setWindowIcon(qtawesome.icon("fa.gear"))
self.hboxlayout = QHBoxLayout() self.hboxlayout = QHBoxLayout()
self.widget.setLayout(self.hboxlayout) self.widget.setLayout(self.hboxlayout)
self.vboxlayout = QVBoxLayout() self.vboxlayout = QVBoxLayout()
self.hboxlayout.addLayout(self.vboxlayout)
self.ttCombomodelmodel = QStandardItemModel() self.ttCombomodelmodel = QStandardItemModel()
self.tttable = QTableView() self.tttable = QTableView()
@ -643,11 +644,9 @@ class hookselect(closeashidewindow):
self.searchtextbutton.clicked.connect(self.searchtextfunc) self.searchtextbutton.clicked.connect(self.searchtextfunc)
self.searchtextlayout.addWidget(self.searchtextbutton) self.searchtextlayout.addWidget(self.searchtextbutton)
################### ###################
self.ttCombomodelmodel2 = QStandardItemModel(self) self.ttCombomodelmodel2 = QStandardItemModel()
# self.ttCombomodelmodel.setColumnCount(2) self.tttable2 = QTableView()
self.ttCombomodelmodel2.setHorizontalHeaderLabels(_TRL(["HOOK", "文本"])) self.vboxlayout.addWidget(self.tttable2)
self.tttable2 = QTableView(self)
self.tttable2.setModel(self.ttCombomodelmodel2) self.tttable2.setModel(self.ttCombomodelmodel2)
# self.tttable2 .horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents) # self.tttable2 .horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)
self.tttable2.horizontalHeader().setStretchLastSection(True) self.tttable2.horizontalHeader().setStretchLastSection(True)
@ -658,7 +657,6 @@ class hookselect(closeashidewindow):
self.tttable2.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers) self.tttable2.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
self.tttable2.clicked.connect(self.ViewThread2) self.tttable2.clicked.connect(self.ViewThread2)
self.vboxlayout.addWidget(self.tttable2)
self.searchtextlayout2 = QHBoxLayout() self.searchtextlayout2 = QHBoxLayout()
self.vboxlayout.addLayout(self.searchtextlayout2) self.vboxlayout.addLayout(self.searchtextlayout2)
self.searchtext2 = QLineEdit() self.searchtext2 = QLineEdit()
@ -685,16 +683,12 @@ class hookselect(closeashidewindow):
self.sysOutput.setReadOnly(True) self.sysOutput.setReadOnly(True)
self.tabwidget = QTabWidget() self.tabwidget = QTabWidget()
self.vboxlayout.addWidget(self.tabwidget)
self.tabwidget.setTabPosition(QTabWidget.TabPosition.East) self.tabwidget.setTabPosition(QTabWidget.TabPosition.East)
self.tabwidget.addTab(self.textOutput, _TR("文本")) self.tabwidget.addTab(self.textOutput, _TR("文本"))
self.tabwidget.addTab(self.sysOutput, _TR("系统")) self.tabwidget.addTab(self.sysOutput, _TR("系统"))
self.vboxlayout.addWidget(self.tabwidget)
self.hboxlayout.addLayout(self.vboxlayout)
self.setCentralWidget(self.widget)
self.changeprocessclear() self.changeprocessclear()
def showmenu(self, p: QPoint): def showmenu(self, p: QPoint):
r = self.tttable.currentIndex().row() r = self.tttable.currentIndex().row()
if r < 0: if r < 0:
@ -895,7 +889,8 @@ class hookselect(closeashidewindow):
print_exc() print_exc()
def showEvent(self, e): def showEvent(self, e):
gobject.baseobject.AttachProcessDialog.realshowhide.emit(False) if gobject.baseobject.AttachProcessDialog:
gobject.baseobject.AttachProcessDialog.close()
try: try:
for i in range(len(self.save)): for i in range(len(self.save)):
if self.save[i] in gobject.baseobject.textsource.selectedhook: if self.save[i] in gobject.baseobject.textsource.selectedhook:
@ -904,18 +899,11 @@ class hookselect(closeashidewindow):
except: except:
print_exc() print_exc()
def get_time_stamp(self):
ct = time.time()
local_time = time.localtime(ct)
data_head = time.strftime("%Y-%m-%d %H:%M:%S", local_time)
data_secs = (ct - int(ct)) * 1000
time_stamp = "%s.%03d" % (data_head, data_secs)
return time_stamp
def sysmessage(self, sentence): def sysmessage(self, sentence):
textbrowappendandmovetoend( textbrowappendandmovetoend(
self.sysOutput, self.get_time_stamp() + " " + sentence self.sysOutput, get_time_stamp() + " " + sentence
) )
def getnewsentence(self, sentence): def getnewsentence(self, sentence):

View File

@ -1,18 +1,24 @@
from qtsymbols import * from qtsymbols import *
import qtawesome, gobject import qtawesome
import threading, windows, winsharedutils import functools
from myutils.config import globalconfig, _TR from myutils.config import globalconfig, _TR
from myutils.utils import wavmp3player from myutils.utils import wavmp3player
from gui.settingpage1 import setTabOne, setTabOne_direct from gui.settingpage1 import setTabOne_lazy
from gui.settingpage2 import setTabTwo, settab2d from gui.settingpage2 import setTabTwo_lazy, checkconnected
from gui.settingpage_xianshishezhi import setTabThree, setTabThree_direct from gui.settingpage_xianshishezhi import setTabThree_lazy
from gui.settingpage_tts import setTab5, setTab5_direct from gui.gui_xianshi_text import maybehavefontsizespin
from gui.settingpage_tts import setTab5, showvoicelist
from gui.settingpage_cishu import setTabcishu from gui.settingpage_cishu import setTabcishu
from gui.settingpage_quick import setTab_quick, setTab_quick_direct from gui.settingpage_quick import setTab_quick, registrhotkeys
from gui.setting_lang import setTablang, setTablangd from gui.setting_lang import setTablang
from gui.setting_proxy import setTab_proxy from gui.setting_proxy import setTab_proxy
from gui.settingpage7 import setTab7, settab7direct from gui.settingpage7 import setTab7_lazy, delaysetcomparetext
from gui.settingpage_about import setTab_about, setTab_about_dicrect from gui.settingpage_about import (
setTab_aboutlazy,
versionlabelmaybesettext,
updateprogress,
getversion,
)
from gui.usefulwidget import closeashidewindow, makesubtab_lazy from gui.usefulwidget import closeashidewindow, makesubtab_lazy
@ -62,63 +68,73 @@ class Settin(closeashidewindow):
versiontextsignal = pyqtSignal(str) versiontextsignal = pyqtSignal(str)
progresssignal = pyqtSignal(str, int) progresssignal = pyqtSignal(str, int)
fontbigsmallsignal = pyqtSignal(int) fontbigsmallsignal = pyqtSignal(int)
clicksourcesignal = pyqtSignal(str)
opensolvetextsig = pyqtSignal() opensolvetextsig = pyqtSignal()
showandsolvesig = pyqtSignal(str) showandsolvesig = pyqtSignal(str)
setstylesheetsignal = pyqtSignal()
def __init__(self, parent): def __init__(self, parent):
super(Settin, self).__init__(parent, globalconfig, "setting_geo_2") super(Settin, self).__init__(parent, globalconfig, "setting_geo_2")
self.setWindowIcon(qtawesome.icon("fa.gear"))
self.mp3player = wavmp3player() self.mp3player = wavmp3player()
self.mp3playsignal.connect(self.mp3player.mp3playfunction) self.mp3playsignal.connect(self.mp3player.mp3playfunction)
self.opensolvetextsig.connect(self.opensolvetextfun) self.opensolvetextsig.connect(self.opensolvetextfun)
self.showandsolvesig.connect(functools.partial(delaysetcomparetext, self))
self.fontbigsmallsignal.connect(functools.partial(maybehavefontsizespin, self))
self.voicelistsignal.connect(functools.partial(showvoicelist, self))
self.versiontextsignal.connect(
functools.partial(versionlabelmaybesettext, self)
)
self.progresssignal.connect(lambda text, val: updateprogress(self, text, val))
self.isfirst = True
getversion(self)
checkconnected(self)
registrhotkeys(self)
def showEvent(self, e: QShowEvent):
if self.isfirst:
self.isfirst = False
self.firstshow()
super().showEvent(e)
def firstshow(self):
self.setMinimumSize(100, 100) self.setMinimumSize(100, 100)
self.list_width = 100
self.window_height = 500
self.savelastrect = None
self.hooks = []
self.usevoice = 0
setTabOne_direct(self)
settab2d(self)
settab7direct(self)
setTabThree_direct(self)
setTab5_direct(self)
setTab_quick_direct(self)
setTablangd(self)
setTab_about_dicrect(self)
self.setstylesheetsignal.connect(gobject.baseobject.setcommonstylesheet)
threading.Thread(target=self.darklistener).start()
self.setWindowTitle(_TR("设置")) self.setWindowTitle(_TR("设置"))
self.setWindowIcon(qtawesome.icon("fa.gear"))
self.tab_widget = makesubtab_lazy(klass=TabWidget) self.tab_widget, do = makesubtab_lazy(
[
"文本输入",
"翻译设置",
"显示设置",
"文本处理",
"辞书设置",
"语音合成",
"快捷按键",
"语言设置",
"代理设置",
"其他设置",
],
[
functools.partial(setTabOne_lazy, self),
functools.partial(setTabTwo_lazy, self),
functools.partial(setTabThree_lazy, self),
functools.partial(setTab7_lazy, self),
functools.partial(setTabcishu, self),
functools.partial(setTab5, self),
functools.partial(setTab_quick, self),
functools.partial(setTablang, self),
functools.partial(setTab_proxy, self),
functools.partial(setTab_aboutlazy, self),
],
klass=TabWidget,
delay=True,
)
self.setCentralWidget(self.tab_widget) self.setCentralWidget(self.tab_widget)
do()
self.tab_widget.setStyleSheet( self.tab_widget.setStyleSheet(
"""QListWidget { """QListWidget {
font:16pt ; } font:16pt ; }
""" """
) )
# self.tab_widget.setTabPosition(QTabWidget.West)
setTabOne(self)
setTabTwo(self)
setTabThree(self)
setTab7(self)
setTabcishu(self)
setTab5(self)
setTab_quick(self)
setTablang(self)
setTab_proxy(self)
setTab_about(self)
width = 0 width = 0
fn = QFont() fn = QFont()
fn.setPixelSize(16) fn.setPixelSize(16)
@ -128,17 +144,7 @@ class Settin(closeashidewindow):
width = max(fm.size(0, title).width(), width) width = max(fm.size(0, title).width(), width)
width += 100 width += 100
self.tab_widget.list_widget.setFixedWidth(width) self.tab_widget.list_widget.setFixedWidth(width)
self.list_width = width
def opensolvetextfun(self): def opensolvetextfun(self):
self.show() self.show()
self.tab_widget.setCurrentIndex(3) self.tab_widget.setCurrentIndex(3)
def darklistener(self):
sema = winsharedutils.startdarklistener()
while True:
# 会触发两次
windows.WaitForSingleObject(sema, windows.INFINITE)
if globalconfig["darklight"] == 2:
self.setstylesheetsignal.emit()
windows.WaitForSingleObject(sema, windows.INFINITE)

View File

@ -1,35 +1,31 @@
import os import os, functools
from myutils.config import globalconfig, _TRL, static_data, getlanguse from myutils.config import globalconfig, _TRL, static_data, getlanguse
from gui.usefulwidget import ( from gui.usefulwidget import (
D_getsimplecombobox,
getsimplecombobox, getsimplecombobox,
getcolorbutton, D_getcolorbutton,
makegrid, makescrollgrid,
tabadd_lazy,
makescroll,
) )
def setTablang(self): def createlangs(self):
tabadd_lazy(self.tab_widget, ("语言设置"), lambda: setTablanglz(self))
def setTablangd(self):
self.srclangswitcher = getsimplecombobox( self.srclangswitcher = getsimplecombobox(
_TRL(static_data["language_list_translator"]), globalconfig, "srclang3" _TRL(static_data["language_list_translator"]), globalconfig, "srclang3"
) )
return self.srclangswitcher
def setTablanglz(self): def setTablanglz(self):
grids = [ return [
[("翻译及OCR语言", 15)], [("翻译及OCR语言", 15)],
[ [
("源语言", 5), ("源语言", 5),
(self.srclangswitcher, 5), (functools.partial(createlangs, self), 5),
], ],
[ [
("目标语言", 5), ("目标语言", 5),
( (
getsimplecombobox( D_getsimplecombobox(
_TRL(static_data["language_list_translator"]), _TRL(static_data["language_list_translator"]),
globalconfig, globalconfig,
"tgtlang3", "tgtlang3",
@ -41,13 +37,13 @@ def setTablanglz(self):
[ [
("本软件显示语言(重启生效)", 5), ("本软件显示语言(重启生效)", 5),
( (
getsimplecombobox( D_getsimplecombobox(
(static_data["language_list_show"]), globalconfig, "languageuse" (static_data["language_list_show"]), globalconfig, "languageuse"
), ),
5, 5,
), ),
( (
getcolorbutton( D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=lambda: os.startfile( callback=lambda: os.startfile(
@ -62,7 +58,6 @@ def setTablanglz(self):
[], [],
] ]
gridlayoutwidget = makegrid(grids)
gridlayoutwidget = makescroll(gridlayoutwidget)
return gridlayoutwidget def setTablang(self, l):
makescrollgrid(setTablanglz(self), l)

View File

@ -3,14 +3,13 @@ from myutils.config import _TR
from myutils.config import globalconfig from myutils.config import globalconfig
from myutils.utils import splittranslatortypes from myutils.utils import splittranslatortypes
from gui.usefulwidget import ( from gui.usefulwidget import (
getsimpleswitch, D_getsimpleswitch,
makegrid, makegrid,
makesubtab_lazy, makesubtab_lazy,
tabadd_lazy, getvboxwidget,
makevbox, makescrollgrid,
makescroll,
) )
import os import os, functools
def getall(l, item="fanyi", name=""): def getall(l, item="fanyi", name=""):
@ -28,7 +27,7 @@ def getall(l, item="fanyi", name=""):
line += [ line += [
(globalconfig[item][fanyi]["name"], 6), (globalconfig[item][fanyi]["name"], 6),
getsimpleswitch(globalconfig[item][fanyi], "useproxy", default=True), D_getsimpleswitch(globalconfig[item][fanyi], "useproxy", default=True),
"", "",
] ]
if i % 3 == 0: if i % 3 == 0:
@ -41,35 +40,50 @@ def getall(l, item="fanyi", name=""):
return grids return grids
def setTab_proxy_lazy(self): def createcheckbtn(self):
proxy = QLineEdit(globalconfig["proxy"])
btn = QPushButton(_TR("确定")) btn = QPushButton(_TR("确定"))
btn.clicked.connect(lambda x: globalconfig.__setitem__("proxy", proxy.text())) btn.clicked.connect(
lambda x: globalconfig.__setitem__("proxy", self.__proxyedit.text())
)
self.__checkproxybtn = btn
_ifusesysproxy(self, globalconfig["usesysproxy"])
return btn
def _ifusesysproxy(x):
proxy.setEnabled(not x)
btn.setEnabled(not x)
_ifusesysproxy(globalconfig["usesysproxy"]) def createproxyedit(self):
proxy = QLineEdit(globalconfig["proxy"])
self.__proxyedit = proxy
return proxy
def _ifusesysproxy(self, x):
self.__proxyedit.setEnabled(not x)
self.__checkproxybtn.setEnabled(not x)
def setTab_proxy_lazy(self, basel):
grid1 = [ grid1 = [
[("使用代理", 5), (getsimpleswitch(globalconfig, "useproxy"), 1), ("", 10)], [("使用代理", 5), (D_getsimpleswitch(globalconfig, "useproxy"), 1), ("", 10)],
[ [
("自动获取系统代理", 5), ("自动获取系统代理", 5),
( (
getsimpleswitch( D_getsimpleswitch(
globalconfig, "usesysproxy", callback=lambda x: _ifusesysproxy(x) globalconfig,
"usesysproxy",
callback=lambda x: _ifusesysproxy(self, x),
) )
), ),
], ],
[ [
("手动设置代理(ip:port)", 5), ("手动设置代理(ip:port)", 5),
(proxy, 5), (functools.partial(createproxyedit, self), 5),
(btn, 2), (functools.partial(createcheckbtn, self), 2),
], ],
[], [],
[("使用代理的项目", 5)], [("使用代理的项目", -1)],
] ]
lixians, pre, mianfei, develop, shoufei = splittranslatortypes() lixians, pre, mianfei, develop, shoufei = splittranslatortypes()
@ -80,18 +94,23 @@ def setTab_proxy_lazy(self):
item="ocr", item="ocr",
name="./Lunatranslator/ocrengines/%s.py", name="./Lunatranslator/ocrengines/%s.py",
) )
tab = makesubtab_lazy( vw, vl = getvboxwidget()
basel.addWidget(vw)
gridlayoutwidget, do = makegrid(grid1, delay=True)
vl.addWidget(gridlayoutwidget)
tab, dotab = makesubtab_lazy(
["在线翻译", "注册在线翻译", "在线OCR"], ["在线翻译", "注册在线翻译", "在线OCR"],
[ [
lambda: makescroll(makegrid(mianfei)), functools.partial(makescrollgrid, mianfei),
lambda: makescroll(makegrid(shoufei)), functools.partial(makescrollgrid, shoufei),
lambda: makescroll(makegrid(ocrs)), functools.partial(makescrollgrid, ocrs),
], ],
delay=True,
) )
vl.addWidget(tab)
gridlayoutwidget = makegrid(grid1) do()
return makevbox([gridlayoutwidget, tab]) dotab()
def setTab_proxy(self): def setTab_proxy(self, l):
tabadd_lazy(self.tab_widget, ("代理设置"), lambda: setTab_proxy_lazy(self)) setTab_proxy_lazy(self, l)

View File

@ -7,16 +7,16 @@ from gui.dialog_savedgame import dialog_savedgame_new
import gobject import gobject
from gui.inputdialog import regexedit from gui.inputdialog import regexedit
from gui.usefulwidget import ( from gui.usefulwidget import (
getsimplecombobox, D_getsimplecombobox,
getspinbox, D_getspinbox,
makescroll, D_getcolorbutton,
getcolorbutton,
makegrid, makegrid,
tabadd_lazy, tabadd_lazy,
yuitsu_switch, yuitsu_switch,
makevbox, getvboxwidget,
getsimpleswitch, D_getsimpleswitch,
makesubtab_lazy, makesubtab_lazy,
makescrollgrid,
) )
from gui.codeacceptdialog import codeacceptdialog from gui.codeacceptdialog import codeacceptdialog
from myutils.utils import makehtml, getfilemd5 from myutils.utils import makehtml, getfilemd5
@ -30,17 +30,40 @@ def gethookgrid(self):
(makehtml("https://github.com/HIllya51/LunaHook"), 8, "link"), (makehtml("https://github.com/HIllya51/LunaHook"), 8, "link"),
], ],
[], [],
[("选择游戏", 5), self.selectbutton, ("", 5)], [
[("选择文本", 5), self.selecthookbutton], ("选择游戏", 5),
D_getcolorbutton(
globalconfig,
"",
gobject.baseobject.createattachprocess,
name="selectbutton",
parent=self,
icon="fa.gear",
constcolor="#FF69B4",
),
("", 5),
],
[
("选择文本", 5),
D_getcolorbutton(
globalconfig,
"",
lambda: gobject.baseobject.hookselectdialog.showsignal.emit(),
name="selecthookbutton",
parent=self,
icon="fa.gear",
constcolor="#FF69B4",
),
],
[], [],
[ [
("检测到游戏时自动开始", 5), ("检测到游戏时自动开始", 5),
(getsimpleswitch(globalconfig, "autostarthook"), 1), (D_getsimpleswitch(globalconfig, "autostarthook"), 1),
], ],
[ [
("已保存游戏", 5), ("已保存游戏", 5),
( (
getcolorbutton( D_getcolorbutton(
globalconfig, globalconfig,
"", "",
icon="fa.gamepad", icon="fa.gamepad",
@ -53,12 +76,12 @@ def gethookgrid(self):
[], [],
[ [
("过滤反复刷新的句子", 5), ("过滤反复刷新的句子", 5),
(getsimpleswitch(globalconfig, "direct_filterrepeat"), 1), (D_getsimpleswitch(globalconfig, "direct_filterrepeat"), 1),
], ],
[ [
("刷新延迟(ms)", 5), ("刷新延迟(ms)", 5),
( (
getspinbox( D_getspinbox(
0, 0,
10000, 10000,
globalconfig, globalconfig,
@ -71,7 +94,7 @@ def gethookgrid(self):
[ [
("最大缓冲区长度", 5), ("最大缓冲区长度", 5),
( (
getspinbox( D_getspinbox(
0, 0,
1000000, 1000000,
globalconfig, globalconfig,
@ -84,7 +107,7 @@ def gethookgrid(self):
[ [
("最大缓存文本长度", 5), ("最大缓存文本长度", 5),
( (
getspinbox( D_getspinbox(
0, 0,
1000000000, 1000000000,
globalconfig, globalconfig,
@ -97,9 +120,9 @@ def gethookgrid(self):
[], [],
[ [
("过滤包含乱码的文本行", 5), ("过滤包含乱码的文本行", 5),
(getsimpleswitch(globalconfig, "filter_chaos_code"), 1), (D_getsimpleswitch(globalconfig, "filter_chaos_code"), 1),
( (
getcolorbutton( D_getcolorbutton(
globalconfig, globalconfig,
"", "",
icon="fa.gear", icon="fa.gear",
@ -110,8 +133,8 @@ def gethookgrid(self):
), ),
], ],
[], [],
[("区分人名和文本", 5), getsimpleswitch(globalconfig, "allow_set_text_name")], [("区分人名和文本", 5), D_getsimpleswitch(globalconfig, "allow_set_text_name")],
[("使用YAPI注入", 5), getsimpleswitch(globalconfig, "use_yapi")], [("使用YAPI注入", 5), D_getsimpleswitch(globalconfig, "use_yapi")],
] ]
return grids return grids
@ -223,8 +246,9 @@ def exportchspatch(self):
ff.write("{}") ff.write("{}")
def gethookembedgrid(self): def creategamefont_comboBox():
self.gamefont_comboBox = QFontComboBox()
gamefont_comboBox = QFontComboBox()
def callback(x): def callback(x):
globalconfig["embedded"].__setitem__("changefont_font", x) globalconfig["embedded"].__setitem__("changefont_font", x)
@ -233,14 +257,16 @@ def gethookembedgrid(self):
except: except:
pass pass
self.gamefont_comboBox.currentTextChanged.connect(callback) gamefont_comboBox.currentTextChanged.connect(callback)
self.gamefont_comboBox.setCurrentFont( gamefont_comboBox.setCurrentFont(QFont(globalconfig["embedded"]["changefont_font"]))
QFont(globalconfig["embedded"]["changefont_font"]) return gamefont_comboBox
)
def gethookembedgrid(self):
grids = [ grids = [
[ [
("导出翻译补丁", 5), ("导出翻译补丁", 5),
getcolorbutton( D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=lambda x: exportchspatch(self), callback=lambda x: exportchspatch(self),
@ -252,7 +278,7 @@ def gethookembedgrid(self):
[ [
("保留原文", 5), ("保留原文", 5),
( (
getsimpleswitch( D_getsimpleswitch(
globalconfig["embedded"], globalconfig["embedded"],
"keeprawtext", "keeprawtext",
callback=lambda _: gobject.baseobject.textsource.flashembedsettings(), callback=lambda _: gobject.baseobject.textsource.flashembedsettings(),
@ -264,7 +290,7 @@ def gethookembedgrid(self):
("翻译等待时间(s)", 5), ("翻译等待时间(s)", 5),
"", "",
( (
getspinbox( D_getspinbox(
0, 0,
30, 30,
globalconfig["embedded"], globalconfig["embedded"],
@ -278,13 +304,13 @@ def gethookembedgrid(self):
], ],
[ [
("使用最快翻译而非指定翻译器", 5), ("使用最快翻译而非指定翻译器", 5),
(getsimpleswitch(globalconfig["embedded"], "as_fast_as_posible"), 1), (D_getsimpleswitch(globalconfig["embedded"], "as_fast_as_posible"), 1),
], ],
[ [
("内嵌的翻译器", 5), ("内嵌的翻译器", 5),
"", "",
( (
getsimplecombobox( D_getsimplecombobox(
_TRL( _TRL(
[ [
globalconfig["fanyi"][x]["name"] globalconfig["fanyi"][x]["name"]
@ -300,13 +326,13 @@ def gethookembedgrid(self):
], ],
[ [
("将汉字转换成繁体/日式汉字", 5), ("将汉字转换成繁体/日式汉字", 5),
(getsimpleswitch(globalconfig["embedded"], "trans_kanji"), 1), (D_getsimpleswitch(globalconfig["embedded"], "trans_kanji"), 1),
], ],
[ [
("在重叠显示的字间插入空格", 5), ("在重叠显示的字间插入空格", 5),
"", "",
( (
getsimplecombobox( D_getsimplecombobox(
_TRL(["不插入空格", "每个字后插入空格", "仅在无法编码的字后插入"]), _TRL(["不插入空格", "每个字后插入空格", "仅在无法编码的字后插入"]),
globalconfig["embedded"], globalconfig["embedded"],
"insertspace_policy", "insertspace_policy",
@ -318,20 +344,20 @@ def gethookembedgrid(self):
[ [
("修改游戏字体", 5), ("修改游戏字体", 5),
( (
getsimpleswitch( D_getsimpleswitch(
globalconfig["embedded"], globalconfig["embedded"],
"changefont", "changefont",
callback=lambda _: gobject.baseobject.textsource.flashembedsettings(), callback=lambda _: gobject.baseobject.textsource.flashembedsettings(),
), ),
1, 1,
), ),
(self.gamefont_comboBox, 5), (creategamefont_comboBox, 5),
], ],
[], [],
[ [
("内嵌安全性检查", 5), ("内嵌安全性检查", 5),
getsimpleswitch(globalconfig["embedded"], "safecheck_use"), D_getsimpleswitch(globalconfig["embedded"], "safecheck_use"),
getcolorbutton( D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=lambda x: regexedit( callback=lambda x: regexedit(
@ -341,7 +367,6 @@ def gethookembedgrid(self):
constcolor="#FF69B4", constcolor="#FF69B4",
), ),
], ],
# [('修改字体字符集',5),(getsimpleswitch( globalconfig['embedded'] ,'changecharset',callback=lambda _:gobject.baseobject.textsource.flashembedsettings()),1) ,(getsimplecombobox(_TRL(static_data["charsetmapshow"]),globalconfig['embedded'],'changecharset_charset',callback=lambda _:gobject.baseobject.textsource.flashembedsettings()),5)],
] ]
return grids return grids
@ -352,7 +377,7 @@ def getTabclip(self):
grids = [ grids = [
[ [
("排除复制自翻译器的文本", 3), ("排除复制自翻译器的文本", 3),
getsimpleswitch(globalconfig, "excule_from_self"), D_getsimpleswitch(globalconfig, "excule_from_self"),
("", 3), ("", 3),
] ]
] ]
@ -362,20 +387,20 @@ def getTabclip(self):
def outputgrid(self): def outputgrid(self):
grids = [ grids = [
[("自动输出提取的文本", 10)], [("自动输出提取的文本", 15)],
[], [],
[("剪贴板", 10)], [("剪贴板", 0)],
[ [
"", "",
("输出到剪贴板", 5), ("输出到剪贴板", 5),
(getsimpleswitch(globalconfig["textoutputer"]["clipboard"], "use"), 1), (D_getsimpleswitch(globalconfig["textoutputer"]["clipboard"], "use"), 1),
], ],
[("WebSocket", 10)], [("WebSocket", -1)],
[ [
"", "",
("输出到WebSocket", 5), ("输出到WebSocket", 5),
( (
getsimpleswitch( D_getsimpleswitch(
globalconfig["textoutputer"]["websocket"], globalconfig["textoutputer"]["websocket"],
"use", "use",
callback=lambda _: gobject.baseobject.startoutputer_re("websocket"), callback=lambda _: gobject.baseobject.startoutputer_re("websocket"),
@ -387,7 +412,7 @@ def outputgrid(self):
"", "",
("端口号", 5), ("端口号", 5),
( (
getspinbox( D_getspinbox(
0, 0,
65535, 65535,
globalconfig["textoutputer"]["websocket"], globalconfig["textoutputer"]["websocket"],
@ -401,14 +426,17 @@ def outputgrid(self):
return grids return grids
def setTabOne_direct(self): def setTabOne(self):
tabadd_lazy(self.tab_widget, ("文本输入"), lambda l: setTabOne_lazy(self, l))
self.tab1grids = [
[("选择文本输入源", 8)], def setTabOne_lazy(self, basel):
tab1grids = [
[("选择文本输入源", -1)],
[ [
("HOOK", 3), ("HOOK", 3),
( (
getsimpleswitch( D_getsimpleswitch(
globalconfig["sourcestatus2"]["texthook"], globalconfig["sourcestatus2"]["texthook"],
"use", "use",
name="texthook", name="texthook",
@ -428,7 +456,7 @@ def setTabOne_direct(self):
"", "",
("OCR", 3), ("OCR", 3),
( (
getsimpleswitch( D_getsimpleswitch(
globalconfig["sourcestatus2"]["ocr"], globalconfig["sourcestatus2"]["ocr"],
"use", "use",
name="ocr", name="ocr",
@ -448,7 +476,7 @@ def setTabOne_direct(self):
"", "",
("剪贴板", 3), ("剪贴板", 3),
( (
getsimpleswitch( D_getsimpleswitch(
globalconfig["sourcestatus2"]["copy"], globalconfig["sourcestatus2"]["copy"],
"use", "use",
name="copy", name="copy",
@ -469,57 +497,21 @@ def setTabOne_direct(self):
], ],
] ]
getcolorbutton( vw, vl = getvboxwidget()
globalconfig, basel.addWidget(vw)
"", gridlayoutwidget, do = makegrid(tab1grids, delay=True)
name="selectbutton", vl.addWidget(gridlayoutwidget)
parent=self, tab, dotab = makesubtab_lazy(
icon="fa.gear",
constcolor="#FF69B4",
callback=lambda: gobject.baseobject.AttachProcessDialog.showsignal.emit(),
)
getcolorbutton(
globalconfig,
"",
name="selectbuttonembed",
parent=self,
icon="fa.gear",
constcolor="#FF69B4",
callback=lambda: gobject.baseobject.AttachProcessDialog.showsignal.emit(),
)
getcolorbutton(
globalconfig,
"",
name="selecthookbutton",
parent=self,
icon="fa.gear",
constcolor="#FF69B4",
callback=lambda: gobject.baseobject.hookselectdialog.showsignal.emit(),
)
self.clicksourcesignal.connect(lambda k: getattr(self, "sourceswitchs")[k].click())
self.threshold1label = QLabel()
self.threshold2label = QLabel()
self.Scriptscombo = QComboBox()
def setTabOne(self):
tabadd_lazy(self.tab_widget, ("文本输入"), lambda: setTabOne_lazy(self))
def setTabOne_lazy(self):
tab = makesubtab_lazy(
["HOOK设置", "OCR设置", "剪贴板", "内嵌翻译", "文本输出"], ["HOOK设置", "OCR设置", "剪贴板", "内嵌翻译", "文本输出"],
[ [
lambda: makescroll(makegrid(gethookgrid(self))), lambda l: makescrollgrid(gethookgrid(self), l),
lambda: makescroll(makegrid(getocrgrid(self))), lambda l: makescrollgrid(getocrgrid(self), l),
lambda: makescroll(makegrid(getTabclip(self))), lambda l: makescrollgrid(getTabclip(self), l),
lambda: makescroll(makegrid(gethookembedgrid(self))), lambda l: makescrollgrid(gethookembedgrid(self), l),
lambda: makescroll(makegrid(outputgrid(self))), lambda l: makescrollgrid(outputgrid(self), l),
], ],
delay=True,
) )
vl.addWidget(tab)
gridlayoutwidget = makegrid(self.tab1grids) do()
return makevbox([gridlayoutwidget, tab]) dotab()

View File

@ -6,19 +6,20 @@ from myutils.subproc import subproc_w
from gui.pretransfile import sqlite2json from gui.pretransfile import sqlite2json
from myutils.config import globalconfig, _TR from myutils.config import globalconfig, _TR
from myutils.utils import selectdebugfile, splittranslatortypes, checkportavailable from myutils.utils import selectdebugfile, splittranslatortypes, checkportavailable
import os, time, requests, threading import os, time, requests
from gui.inputdialog import autoinitdialog, autoinitdialog_items from gui.inputdialog import autoinitdialog, autoinitdialog_items
from gui.usefulwidget import ( from gui.usefulwidget import (
D_getspinbox,
getspinbox, getspinbox,
getcolorbutton, D_getcolorbutton,
getsimpleswitch, D_getsimpleswitch,
selectcolor, selectcolor,
makegrid, makegrid,
makesubtab_lazy, makesubtab_lazy,
makescroll, makescrollgrid,
makevbox, getvboxwidget,
tabadd_lazy,
) )
from myutils.wrapper import threader
import time, hashlib import time, hashlib
@ -45,7 +46,7 @@ def initsome11(self, l, label=None):
if fanyi in translatorsetting: if fanyi in translatorsetting:
items = autoinitdialog_items(translatorsetting[fanyi]) items = autoinitdialog_items(translatorsetting[fanyi])
last = getcolorbutton( last = D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=functools.partial( callback=functools.partial(
@ -59,7 +60,7 @@ def initsome11(self, l, label=None):
constcolor="#FF69B4", constcolor="#FF69B4",
) )
elif fanyi == "selfbuild": elif fanyi == "selfbuild":
last = getcolorbutton( last = D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=lambda: selectdebugfile("./userconfig/selfbuild.py"), callback=lambda: selectdebugfile("./userconfig/selfbuild.py"),
@ -70,12 +71,12 @@ def initsome11(self, l, label=None):
last = "" last = ""
line += [ line += [
(globalconfig["fanyi"][fanyi]["name"], 6), (globalconfig["fanyi"][fanyi]["name"], 6),
getsimpleswitch( D_getsimpleswitch(
globalconfig["fanyi"][fanyi], globalconfig["fanyi"][fanyi],
"use", "use",
callback=functools.partial(gobject.baseobject.prepare, fanyi), callback=functools.partial(gobject.baseobject.prepare, fanyi),
), ),
getcolorbutton( D_getcolorbutton(
globalconfig["fanyi"][fanyi], globalconfig["fanyi"][fanyi],
"color", "color",
parent=self, parent=self,
@ -103,83 +104,98 @@ def initsome11(self, l, label=None):
return grids return grids
def setTabTwo(self): def statuslabelsettext(self, text):
tabadd_lazy(self.tab_widget, ("翻译设置"), lambda: setTabTwo_lazy(self)) try:
self.statuslabel.setText(text)
except:
pass
def settab2d(self): def createstatuslabel(self):
self.statuslabel = QLabel() self.statuslabel = QLabel()
return self.statuslabel
def checkconnected():
lixians, pre, mianfei, develop, shoufei = splittranslatortypes()
while True:
port = globalconfig["debugport"]
_path = None
for syspath in [
globalconfig["chromepath"],
r"C:\Program Files\Google\Chrome\Application\chrome.exe",
r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe",
]:
if os.path.exists(syspath) and os.path.isfile(syspath):
_path = syspath
break
needstart = (
any([globalconfig["fanyi"][dev]["use"] for dev in develop]) and _path
)
try:
@threader
def checkconnected(self):
lixians, pre, mianfei, develop, shoufei = splittranslatortypes()
while True:
port = globalconfig["debugport"]
_path = None
for syspath in [
globalconfig["chromepath"],
r"C:\Program Files\Google\Chrome\Application\chrome.exe",
r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe",
]:
if os.path.exists(syspath) and os.path.isfile(syspath):
_path = syspath
break
needstart = (
any([globalconfig["fanyi"][dev]["use"] for dev in develop]) and _path
)
try:
if needstart:
requests.get("http://127.0.0.1:{}/json/list".format(port)).json()
statuslabelsettext(self, _TR("连接成功"))
except:
if checkportavailable(port):
statuslabelsettext(self, _TR("连接失败"))
if needstart: if needstart:
requests.get("http://127.0.0.1:{}/json/list".format(port)).json() call = (
self.statuslabel.setText(_TR("连接成功")) '"%s" --disable-extensions --remote-allow-origins=* --disable-gpu --no-first-run --remote-debugging-port=%d --user-data-dir="%s"'
except: % (
if checkportavailable(port): _path,
self.statuslabel.setText(_TR("连接失败")) port,
if needstart: os.path.abspath("./chrome_cache/" + hashtext(_path)),
call = (
'"%s" --disable-extensions --remote-allow-origins=* --disable-gpu --no-first-run --remote-debugging-port=%d --user-data-dir="%s"'
% (
_path,
port,
os.path.abspath("./chrome_cache/" + hashtext(_path)),
)
) )
print(call) )
self.engine = subproc_w(call) print(call)
else: self.engine = subproc_w(call)
self.statuslabel.setText(_TR("端口冲突")) else:
time.sleep(1) statuslabelsettext(self, _TR("端口冲突"))
time.sleep(1)
threading.Thread(target=checkconnected).start()
def setTabTwo_lazy(self): def createbtnexport(self):
bt = QPushButton(_TR("导出翻译记录为json文件")) bt = QPushButton(_TR("导出翻译记录为json文件"))
bt.clicked.connect(lambda x: sqlite2json(self)) bt.clicked.connect(lambda x: sqlite2json(self))
return bt
def createfuzspin(self):
_fuzainum = getspinbox(1, 99999, globalconfig, "loadbalance_oncenum", step=1) _fuzainum = getspinbox(1, 99999, globalconfig, "loadbalance_oncenum", step=1)
_fuzainum.setEnabled(globalconfig["loadbalance"]) _fuzainum.setEnabled(globalconfig["loadbalance"])
self._fuzainum = _fuzainum
return _fuzainum
def setTabTwo_lazy(self, basel):
grids = [ grids = [
[ [
("最短翻译字数", 7), ("最短翻译字数", 7),
(getspinbox(0, 9999, globalconfig, "minlength"), 3), (D_getspinbox(0, 9999, globalconfig, "minlength"), 3),
"", "",
("最长翻译字数", 7), ("最长翻译字数", 7),
(getspinbox(0, 9999, globalconfig, "maxlength"), 3), (D_getspinbox(0, 9999, globalconfig, "maxlength"), 3),
"", "",
], ],
[ [
("使用翻译缓存", 8), ("使用翻译缓存", 8),
(getsimpleswitch(globalconfig, "uselongtermcache")), (D_getsimpleswitch(globalconfig, "uselongtermcache")),
"", "",
"", "",
("显示错误信息", 8), ("显示错误信息", 8),
(getsimpleswitch(globalconfig, "showtranexception"), 1), (D_getsimpleswitch(globalconfig, "showtranexception"), 1),
"", "",
"", "",
("翻译请求间隔(s)", 7), ("翻译请求间隔(s)", 7),
( (
getspinbox( D_getspinbox(
0, 9999, globalconfig, "requestinterval", step=0.1, double=True 0, 9999, globalconfig, "requestinterval", step=0.1, double=True
), ),
3, 3,
@ -188,29 +204,29 @@ def setTabTwo_lazy(self):
[ [
("均衡负载", 8), ("均衡负载", 8),
( (
getsimpleswitch( D_getsimpleswitch(
globalconfig, globalconfig,
"loadbalance", "loadbalance",
callback=lambda x: _fuzainum.setEnabled(x), callback=lambda x: self._fuzainum.setEnabled(x),
) )
), ),
"", "",
"", "",
("单次负载个数", 7), ("单次负载个数", 7),
(_fuzainum, 3), (functools.partial(createfuzspin, self), 3),
], ],
] ]
online_reg_grid = [[("若有多个api key用|将每个key连接后填入即可轮流使用", 24)]] online_reg_grid = [[("若有多个api key用|将每个key连接后填入即可轮流使用", -1)]]
pretransgrid = [ pretransgrid = [
[ [
("预翻译采用模糊匹配", 8), ("预翻译采用模糊匹配", 8),
(getsimpleswitch(globalconfig, "premtsimiuse"), 1), (D_getsimpleswitch(globalconfig, "premtsimiuse"), 1),
"", "",
("模糊匹配_相似度_%", 8), ("模糊匹配_相似度_%", 8),
(getspinbox(0, 100, globalconfig, "premtsimi2"), 3), (D_getspinbox(0, 100, globalconfig, "premtsimi2"), 3),
], ],
[ [
(bt, 12), (functools.partial(createbtnexport, self), 12),
], ],
[], [],
] ]
@ -230,7 +246,7 @@ def setTabTwo_lazy(self):
[ [
("Chromium_路径", 8), ("Chromium_路径", 8),
( (
getcolorbutton( D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=functools.partial( callback=functools.partial(
@ -243,9 +259,9 @@ def setTabTwo_lazy(self):
], ],
[ [
("端口号", 8), ("端口号", 8),
(getspinbox(0, 65535, globalconfig, "debugport"), 4), (D_getspinbox(0, 65535, globalconfig, "debugport"), 4),
], ],
[(self.statuslabel, 16)], [(functools.partial(createstatuslabel, self), 16)],
[], [],
] ]
lixians, pre, mianfei, develop, shoufei = splittranslatortypes() lixians, pre, mianfei, develop, shoufei = splittranslatortypes()
@ -255,16 +271,23 @@ def setTabTwo_lazy(self):
developgrid += initsome11(self, develop) developgrid += initsome11(self, develop)
online_reg_grid += initsome11(self, shoufei) online_reg_grid += initsome11(self, shoufei)
pretransgrid += initsome11(self, pre) pretransgrid += initsome11(self, pre)
tab = makesubtab_lazy( vw, vl = getvboxwidget()
basel.addWidget(vw)
gridlayoutwidget, do = makegrid(grids, delay=True)
vl.addWidget(gridlayoutwidget)
tab, dotab = makesubtab_lazy(
["在线翻译", "develop", "注册在线翻译", "离线翻译", "预翻译"], ["在线翻译", "develop", "注册在线翻译", "离线翻译", "预翻译"],
[ [
lambda: makescroll(makegrid(onlinegrid)), functools.partial(makescrollgrid, onlinegrid),
lambda: makescroll(makegrid(developgrid)), functools.partial(makescrollgrid, developgrid),
lambda: makescroll(makegrid(online_reg_grid)), functools.partial(makescrollgrid, online_reg_grid),
lambda: makescroll(makegrid(offlinegrid)), functools.partial(makescrollgrid, offlinegrid),
lambda: makescroll(makegrid(pretransgrid)), functools.partial(makescrollgrid, pretransgrid),
], ],
delay=True,
) )
vl.addWidget(tab)
gridlayoutwidget = makegrid(grids) do()
return makevbox([gridlayoutwidget, tab]) dotab()

View File

@ -1,21 +1,20 @@
import functools import functools, copy, os, gobject
from qtsymbols import * from qtsymbols import *
from traceback import print_exc from traceback import print_exc
from myutils.config import ( from myutils.config import (
globalconfig, globalconfig,
postprocessconfig, postprocessconfig,
static_data, static_data,
savehook_new_data,
_TR, _TR,
) )
import functools, gobject
from gui.usefulwidget import ( from gui.usefulwidget import (
getcolorbutton, getcolorbutton,
getsimpleswitch, D_getcolorbutton,
makevbox, D_getsimpleswitch,
makescroll, makescrollgrid,
makegrid, getvboxwidget,
makesubtab_lazy, makesubtab_lazy,
tabadd_lazy,
) )
from gui.codeacceptdialog import codeacceptdialog from gui.codeacceptdialog import codeacceptdialog
from gui.inputdialog import ( from gui.inputdialog import (
@ -28,8 +27,6 @@ from myutils.utils import (
checkpostlangmatch, checkpostlangmatch,
loadpostsettingwindowmethod, loadpostsettingwindowmethod,
) )
from myutils.config import savehook_new_data
import copy, os
from myutils.post import POSTSOLVE from myutils.post import POSTSOLVE
@ -67,12 +64,13 @@ def savegameprocesstext():
print_exc() print_exc()
def settab7direct(self): def delaysetcomparetext(self, s):
self.comparelayout = getcomparelayout(self) try:
self.__fromtext.setPlainText(s)
self.__totext.setPlainText(POSTSOLVE(s))
def setTab7(self): except:
tabadd_lazy(self.tab_widget, ("文本处理"), lambda: setTab7_lazy(self)) self.__fromtext_cache = s
self.__totext_cache = POSTSOLVE(s)
def getcomparelayout(self): def getcomparelayout(self):
@ -93,16 +91,17 @@ def getcomparelayout(self):
layout.addWidget(totext) layout.addWidget(totext)
w = QWidget() w = QWidget()
w.setLayout(layout) w.setLayout(layout)
self.__fromtext = fromtext
def _(s): self.__totext = totext
fromtext.setPlainText(s) try:
totext.setPlainText(POSTSOLVE(fromtext.toPlainText())) fromtext.setPlainText(self.__fromtext_cache)
totext.setPlainText(self.__totext_cache)
self.showandsolvesig.connect(_) except:
pass
return w return w
def setTab7_lazy(self): def setTab7_lazy(self, basel):
grids = [[("预处理方法", 6), "", "", ("调整执行顺序", 6)]] grids = [[("预处理方法", 6), "", "", ("调整执行顺序", 6)]]
if set(postprocessconfig.keys()) != set(globalconfig["postprocess_rank"]): if set(postprocessconfig.keys()) != set(globalconfig["postprocess_rank"]):
globalconfig["postprocess_rank"] = list(postprocessconfig.keys()) globalconfig["postprocess_rank"] = list(postprocessconfig.keys())
@ -137,7 +136,7 @@ def setTab7_lazy(self):
for i, post in enumerate(sortlist): for i, post in enumerate(sortlist):
if post == "_11": if post == "_11":
config = getcolorbutton( config = D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=lambda: selectdebugfile("./userconfig/mypost.py"), callback=lambda: selectdebugfile("./userconfig/mypost.py"),
@ -148,7 +147,7 @@ def setTab7_lazy(self):
if post not in postprocessconfig: if post not in postprocessconfig:
continue continue
if post == "_remove_chaos": if post == "_remove_chaos":
config = getcolorbutton( config = D_getcolorbutton(
globalconfig, globalconfig,
"", "",
icon="fa.gear", icon="fa.gear",
@ -172,7 +171,7 @@ def setTab7_lazy(self):
600, 600,
items, items,
) )
config = getcolorbutton( config = D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=callback, callback=callback,
@ -182,14 +181,14 @@ def setTab7_lazy(self):
else: else:
config = "" config = ""
button_up = getcolorbutton( button_up = D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=functools.partial(changerank, post, True), callback=functools.partial(changerank, post, True),
icon="fa.arrow-up", icon="fa.arrow-up",
constcolor="#FF69B4", constcolor="#FF69B4",
) )
button_down = getcolorbutton( button_down = D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=functools.partial(changerank, post, False), callback=functools.partial(changerank, post, False),
@ -199,7 +198,7 @@ def setTab7_lazy(self):
l = [ l = [
((postprocessconfig[post]["name"]), 6), ((postprocessconfig[post]["name"]), 6),
getsimpleswitch(postprocessconfig[post], "use"), D_getsimpleswitch(postprocessconfig[post], "use"),
config, config,
button_up, button_up,
button_down, button_down,
@ -211,7 +210,7 @@ def setTab7_lazy(self):
visname = item["visname"] visname = item["visname"]
if checkpostlangmatch(name): if checkpostlangmatch(name):
grids2.append( grids2.append(
[((visname), 6), getsimpleswitch(globalconfig["transoptimi"], name)] [((visname), 6), D_getsimpleswitch(globalconfig["transoptimi"], name)]
) )
setting = loadpostsettingwindowmethod(name) setting = loadpostsettingwindowmethod(name)
@ -220,7 +219,7 @@ def setTab7_lazy(self):
if setting: if setting:
grids2[-1].append( grids2[-1].append(
getcolorbutton( D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=functools.partial(__, setting, self), callback=functools.partial(__, setting, self),
@ -230,8 +229,10 @@ def setTab7_lazy(self):
) )
grids2 += [[("", 12)]] grids2 += [[("", 12)]]
def __(): def ___(lay):
_w = makescroll(makegrid(grids, True, savelist, savelay)) vboxw, vbox = getvboxwidget()
lay.addWidget(vboxw)
_w = makescrollgrid(grids, vbox, True, savelist, savelay)
_w.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) _w.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
def showmenu(p: QPoint): def showmenu(p: QPoint):
@ -249,11 +250,13 @@ def setTab7_lazy(self):
pass pass
_w.customContextMenuRequested.connect(showmenu) _w.customContextMenuRequested.connect(showmenu)
return _w
tab = makesubtab_lazy( vbox.addWidget(getcomparelayout(self))
tab, dotab = makesubtab_lazy(
["文本预处理", "翻译优化"], ["文本预处理", "翻译优化"],
[lambda: __(), lambda: makescroll(makegrid(grids2))], [___, functools.partial(makescrollgrid, grids2)],
delay=True,
) )
basel.addWidget(tab)
return makevbox([tab, self.comparelayout]) dotab()

View File

@ -1,17 +1,15 @@
from qtsymbols import * from qtsymbols import *
from gui.usefulwidget import ( from gui.usefulwidget import (
getsimpleswitch, D_getsimpleswitch,
getsimplecombobox, D_getsimplecombobox,
makegrid, makescrollgrid,
makescroll,
makesubtab_lazy, makesubtab_lazy,
tabadd_lazy,
) )
from myutils.config import globalconfig, _TR, static_data from myutils.config import globalconfig, _TR, static_data
from myutils.wrapper import threader from myutils.wrapper import threader
import platform, winsharedutils, sys, os import platform, winsharedutils, sys, os
from myutils.utils import makehtml, getimageformatlist from myutils.utils import makehtml, getimageformatlist
from functools import partial import functools
from myutils.githubupdate import updatemethod, getvesionmethod from myutils.githubupdate import updatemethod, getvesionmethod
@ -19,6 +17,7 @@ from myutils.githubupdate import updatemethod, getvesionmethod
def getversion(self): def getversion(self):
version = winsharedutils.queryversion(sys.argv[0]) version = winsharedutils.queryversion(sys.argv[0])
if version is None: if version is None:
self.versiontextsignal.emit("unknown")
return return
versionstring = f"v{version[0]}.{version[1]}.{version[2]}" versionstring = f"v{version[0]}.{version[1]}.{version[2]}"
self.versiontextsignal.emit( self.versiontextsignal.emit(
@ -49,18 +48,15 @@ def getversion(self):
def updateprogress(self, text, val): def updateprogress(self, text, val):
self.downloadprogress.setValue(val) try:
self.downloadprogress.setFormat(text) self.downloadprogress.setValue(val)
self.downloadprogress.setFormat(text)
except:
self.downloadprogress_cache = val, text
def setTab_about_dicrect(self): def createdownloadprogress(self):
self.versionlabel = QLabel()
self.versionlabel.setOpenExternalLinks(True)
self.versionlabel.setTextInteractionFlags(
Qt.TextInteractionFlag.LinksAccessibleByMouse
)
self.versiontextsignal.connect(lambda x: self.versionlabel.setText(x))
self.downloadprogress = QProgressBar() self.downloadprogress = QProgressBar()
self.downloadprogress.setRange(0, 10000) self.downloadprogress.setRange(0, 10000)
@ -68,19 +64,37 @@ def setTab_about_dicrect(self):
self.downloadprogress.setAlignment( self.downloadprogress.setAlignment(
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter
) )
self.progresssignal.connect(lambda text, val: updateprogress(self, text, val)) try:
getversion(self) val, text = self.downloadprogress_cache
self.downloadprogress.setValue(val)
self.downloadprogress.setFormat(text)
except:
pass
return self.downloadprogress
def setTab_about(self): def createversionlabel(self):
tabadd_lazy(self.tab_widget, ("其他设置"), lambda: setTab_aboutlazy(self))
self.versionlabel = QLabel()
self.versionlabel.setOpenExternalLinks(True)
self.versionlabel.setTextInteractionFlags(
Qt.TextInteractionFlag.LinksAccessibleByMouse
)
try:
self.versionlabel.setText(self.versionlabel_cache)
except:
pass
return self.versionlabel
def double_(self, grid): def versionlabelmaybesettext(self, x):
return makescroll(makegrid(grid)) try:
self.versionlabel.setText(x)
except:
self.versionlabel_cache = x
def resourcegrid(self): def resourcegrid(self, l):
titles = [] titles = []
makewidgetsfunctions = [] makewidgetsfunctions = []
for sourcetype in static_data["aboutsource"]: for sourcetype in static_data["aboutsource"]:
@ -106,11 +120,27 @@ def resourcegrid(self):
else: else:
__ = True __ = True
grid.append([(_TR(name), 1, ""), (makehtml(link, __), 2, "link")]) grid.append([(_TR(name), 1, ""), (makehtml(link, __), 2, "link")])
makewidgetsfunctions.append(partial(double_, self, grid)) makewidgetsfunctions.append(functools.partial(makescrollgrid, grid))
return makesubtab_lazy(titles, makewidgetsfunctions) tab, dotab = makesubtab_lazy(titles, makewidgetsfunctions, delay=True)
l.addWidget(tab)
dotab()
def setTab_aboutlazy(self): def createimageview(self):
lb = QLabel()
img = QPixmap.fromImage(QImage("./files/zan.jpg"))
img.setDevicePixelRatio(self.devicePixelRatioF())
img = img.scaled(
600,
600,
Qt.AspectRatioMode.KeepAspectRatio,
Qt.TransformationMode.SmoothTransformation,
)
lb.setPixmap(img)
return lb
def setTab_aboutlazy(self, basel):
webviews = ["IEFrame", "WebView2"] webviews = ["IEFrame", "WebView2"]
if os.path.exists("./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5WebEngineCore.dll"): if os.path.exists("./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5WebEngineCore.dll"):
webviews.append("QWebEngine") webviews.append("QWebEngine")
@ -118,22 +148,22 @@ def setTab_aboutlazy(self):
[ [
("自动下载更新(需要连接github)", 5), ("自动下载更新(需要连接github)", 5),
( (
getsimpleswitch( D_getsimpleswitch(
globalconfig, "autoupdate", callback=lambda x: getversion(self) globalconfig, "autoupdate", callback=lambda x: getversion(self)
), ),
1, 1,
), ),
("", 10), ("", 10),
], ],
[(self.versionlabel, 10)], [(functools.partial(createversionlabel, self), 10)],
[(self.downloadprogress, 10)], [(functools.partial(createdownloadprogress, self), 10)],
[], [],
[("Internet", 5)], [("网络请求", -1)],
[(getsimplecombobox(["winhttp", "libcurl"], globalconfig, "network"), 5)], [(D_getsimplecombobox(["winhttp", "libcurl"], globalconfig, "network"), 5)],
[("WebView", 5)], [("网页显示", -1)],
[ [
( (
getsimplecombobox( D_getsimplecombobox(
webviews, webviews,
globalconfig, globalconfig,
"usewebview", "usewebview",
@ -141,8 +171,8 @@ def setTab_aboutlazy(self):
5, 5,
) )
], ],
[("截图保存格式", 5)], [("截图保存格式", -1)],
[(getsimplecombobox(getimageformatlist(), globalconfig, "imageformat"), 5)], [(D_getsimplecombobox(getimageformatlist(), globalconfig, "imageformat"), 5)],
] ]
shuominggrid = [ shuominggrid = [
@ -170,19 +200,10 @@ def setTab_aboutlazy(self):
(makehtml("https://qm.qq.com/q/qE32v9NYBO", show=912525396), 3, "link"), (makehtml("https://qm.qq.com/q/qE32v9NYBO", show=912525396), 3, "link"),
], ],
[], [],
[("如果你感觉该软件对你有帮助,欢迎微信扫码赞助,谢谢~", 0)], [("如果你感觉该软件对你有帮助,欢迎微信扫码赞助,谢谢~", -1)],
] ]
lb = QLabel(self)
img = QPixmap.fromImage(QImage("./files/zan.jpg")) shuominggrid += [[(functools.partial(createimageview, self), -1)]]
img.setDevicePixelRatio(self.devicePixelRatioF())
img = img.scaled(
600,
600,
Qt.AspectRatioMode.KeepAspectRatio,
Qt.TransformationMode.SmoothTransformation,
)
lb.setPixmap(img)
shuominggrid += [[(lb, 0)]]
else: else:
shuominggrid += [ shuominggrid += [
[], [],
@ -202,14 +223,14 @@ def setTab_aboutlazy(self):
], ],
] ]
tab = makesubtab_lazy( tab, dotab = makesubtab_lazy(
["相关说明", "其他设置", "资源下载"], ["相关说明", "其他设置", "资源下载"],
[ [
lambda: makescroll( functools.partial(makescrollgrid, shuominggrid),
makegrid(shuominggrid), functools.partial(makescrollgrid, grid2),
), functools.partial(resourcegrid, self),
lambda: makescroll(makegrid(grid2)),
lambda: resourcegrid(self),
], ],
delay=True,
) )
return tab basel.addWidget(tab)
dotab()

View File

@ -2,19 +2,17 @@ import functools, os
from myutils.config import globalconfig, _TRL from myutils.config import globalconfig, _TRL
from gui.inputdialog import autoinitdialog, autoinitdialog_items from gui.inputdialog import autoinitdialog, autoinitdialog_items
from gui.usefulwidget import ( from gui.usefulwidget import (
getcolorbutton, D_getcolorbutton,
yuitsu_switch, yuitsu_switch,
makescroll, makescrollgrid,
makegrid, D_getsimpleswitch,
tabadd_lazy, D_getsimplecombobox,
getsimpleswitch,
getsimplecombobox,
) )
import gobject import gobject
def setTabcishu(self): def setTabcishu(self, basel):
tabadd_lazy(self.tab_widget, ("辞书设置"), lambda: setTabcishu_l(self)) makescrollgrid(setTabcishu_l(self), basel)
def gethiragrid(self): def gethiragrid(self):
@ -31,7 +29,7 @@ def gethiragrid(self):
if "args" in globalconfig["hirasetting"][name]: if "args" in globalconfig["hirasetting"][name]:
items = autoinitdialog_items(globalconfig["hirasetting"][name]) items = autoinitdialog_items(globalconfig["hirasetting"][name])
items[-1]["callback"] = gobject.baseobject.starthira items[-1]["callback"] = gobject.baseobject.starthira
_3 = getcolorbutton( _3 = D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=functools.partial( callback=functools.partial(
@ -51,7 +49,7 @@ def gethiragrid(self):
line += [ line += [
((globalconfig["hirasetting"][name]["name"]), 6), ((globalconfig["hirasetting"][name]["name"]), 6),
( (
getsimpleswitch( D_getsimpleswitch(
globalconfig["hirasetting"][name], globalconfig["hirasetting"][name],
"use", "use",
name=name, name=name,
@ -85,11 +83,11 @@ def setTabcishu_l(self):
grids = ( grids = (
[ [
[("分词&假名分析器", 10)], [("分词&假名分析器", -1)],
[ [
("日语注音方案", 6), ("日语注音方案", 6),
( (
getsimplecombobox( D_getsimplecombobox(
_TRL(["平假名", "片假名", "罗马音"]), _TRL(["平假名", "片假名", "罗马音"]),
globalconfig, globalconfig,
"hira_vis_type", "hira_vis_type",
@ -104,8 +102,8 @@ def setTabcishu_l(self):
[], [],
[ [
("点击单词查词", 6), ("点击单词查词", 6),
(getsimpleswitch(globalconfig, "usesearchword"), 1), (D_getsimpleswitch(globalconfig, "usesearchword"), 1),
getcolorbutton( D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=lambda: gobject.baseobject.searchwordW.showsignal.emit(), callback=lambda: gobject.baseobject.searchwordW.showsignal.emit(),
@ -114,14 +112,14 @@ def setTabcishu_l(self):
), ),
"", "",
("点击单词复制", 6), ("点击单词复制", 6),
(getsimpleswitch(globalconfig, "usecopyword"), 1), (D_getsimpleswitch(globalconfig, "usecopyword"), 1),
], ],
[ [
("使用原型查询", 6), ("使用原型查询", 6),
(getsimpleswitch(globalconfig, "usewordorigin"), 1), (D_getsimpleswitch(globalconfig, "usewordorigin"), 1),
], ],
[], [],
[("辞书", 10)], [("辞书", -1)],
] ]
) )
@ -138,12 +136,12 @@ def setTabcishu_l(self):
) )
line += [ line += [
(globalconfig["cishu"][cishu]["name"], 6), (globalconfig["cishu"][cishu]["name"], 6),
getsimpleswitch( D_getsimpleswitch(
globalconfig["cishu"][cishu], globalconfig["cishu"][cishu],
"use", "use",
callback=functools.partial(gobject.baseobject.startxiaoxueguan, cishu), callback=functools.partial(gobject.baseobject.startxiaoxueguan, cishu),
), ),
getcolorbutton( D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=functools.partial( callback=functools.partial(
@ -166,8 +164,4 @@ def setTabcishu_l(self):
i += 1 i += 1
if len(line): if len(line):
grids.append(line) grids.append(line)
return grids
gridlayoutwidget = makegrid(grids)
gridlayoutwidget = makescroll(gridlayoutwidget)
return gridlayoutwidget

View File

@ -1,17 +1,28 @@
import functools, os import functools, os
from myutils.config import globalconfig, ocrsetting, _TRL, ocrerrorfix from myutils.config import globalconfig, ocrsetting, _TRL, ocrerrorfix
from gui.usefulwidget import ( from gui.usefulwidget import (
getsimplecombobox, D_getsimplecombobox,
getspinbox, D_getspinbox,
getcolorbutton, D_getcolorbutton,
yuitsu_switch, yuitsu_switch,
getsimpleswitch, D_getsimpleswitch,
selectcolor, selectcolor,
) )
from qtsymbols import *
from gui.inputdialog import autoinitdialog, postconfigdialog, autoinitdialog_items from gui.inputdialog import autoinitdialog, postconfigdialog, autoinitdialog_items
import gobject import gobject
def __label1(self):
self.threshold1label = QLabel()
return self.threshold1label
def __label2(self):
self.threshold2label = QLabel()
return self.threshold2label
def getocrgrid(self): def getocrgrid(self):
grids = [] grids = []
@ -26,7 +37,7 @@ def getocrgrid(self):
continue continue
if name in ocrsetting: if name in ocrsetting:
items = autoinitdialog_items(ocrsetting[name]) items = autoinitdialog_items(ocrsetting[name])
_3 = getcolorbutton( _3 = D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=functools.partial( callback=functools.partial(
@ -42,7 +53,7 @@ def getocrgrid(self):
line += [ line += [
((globalconfig["ocr"][name]["name"]), 6), ((globalconfig["ocr"][name]["name"]), 6),
( (
getsimpleswitch( D_getsimpleswitch(
globalconfig["ocr"][name], globalconfig["ocr"][name],
"use", "use",
name=name, name=name,
@ -72,13 +83,13 @@ def getocrgrid(self):
grids += [ grids += [
[], [],
[(("竖向OCR识别"), 12), getsimpleswitch(globalconfig, "verticalocr")], [(("竖向OCR识别"), 12), D_getsimpleswitch(globalconfig, "verticalocr")],
[(("合并多行识别结果"), 12), getsimpleswitch(globalconfig, "ocrmergelines")], [(("合并多行识别结果"), 12), D_getsimpleswitch(globalconfig, "ocrmergelines")],
[], [],
[ [
("OCR预处理方法", 8), ("OCR预处理方法", 8),
( (
getsimplecombobox( D_getsimplecombobox(
_TRL(["不处理", "灰度化", "阈值二值化", "OTSU二值化"]), _TRL(["不处理", "灰度化", "阈值二值化", "OTSU二值化"]),
globalconfig, globalconfig,
"ocr_presolve_method", "ocr_presolve_method",
@ -89,22 +100,22 @@ def getocrgrid(self):
], ],
[ [
("查看处理效果", 6), ("查看处理效果", 6),
getcolorbutton( D_getcolorbutton(
globalconfig, globalconfig,
"", "",
gobject.baseobject.createshowocrimage,
icon="fa.picture-o", icon="fa.picture-o",
constcolor="#FF69B4", constcolor="#FF69B4",
callback=gobject.baseobject.showocrimage.showsignal.emit,
), ),
"", "",
(("二值化阈值"), 8), (("二值化阈值"), 8),
(getspinbox(0, 255, globalconfig, "binary_thresh"), 4), (D_getspinbox(0, 255, globalconfig, "binary_thresh"), 4),
], ],
[], [],
[ [
("OCR自动化方法", 8), ("OCR自动化方法", 8),
( (
getsimplecombobox( D_getsimplecombobox(
_TRL(["分析图像更新", "周期执行", "分析图像更新+周期执行"]), _TRL(["分析图像更新", "周期执行", "分析图像更新+周期执行"]),
globalconfig, globalconfig,
"ocr_auto_method", "ocr_auto_method",
@ -115,7 +126,7 @@ def getocrgrid(self):
[ [
(("执行周期(s)"), 8), (("执行周期(s)"), 8),
( (
getspinbox( D_getspinbox(
0.1, 100, globalconfig, "ocr_interval", double=True, step=0.1 0.1, 100, globalconfig, "ocr_interval", double=True, step=0.1
), ),
4, 4,
@ -124,35 +135,35 @@ def getocrgrid(self):
[ [
(("图像稳定性阈值"), 8), (("图像稳定性阈值"), 8),
( (
getspinbox( D_getspinbox(
0, 1, globalconfig, "ocr_stable_sim", double=True, step=0.01, dec=3 0, 1, globalconfig, "ocr_stable_sim", double=True, step=0.01, dec=3
), ),
4, 4,
), ),
(self.threshold1label, 4), (functools.partial(__label1, self), 0),
], ],
[ [
(("图像一致性阈值"), 8), (("图像一致性阈值"), 8),
( (
getspinbox( D_getspinbox(
0, 1, globalconfig, "ocr_diff_sim", double=True, step=0.01, dec=3 0, 1, globalconfig, "ocr_diff_sim", double=True, step=0.01, dec=3
), ),
4, 4,
), ),
(self.threshold2label, 4), (functools.partial(__label2, self), 0),
], ],
[ [
(("文本相似度阈值"), 8), (("文本相似度阈值"), 8),
(getspinbox(0, 100000, globalconfig, "ocr_text_diff"), 4), (D_getspinbox(0, 100000, globalconfig, "ocr_text_diff"), 4),
], ],
[], [],
[(("多重区域模式"), 12), getsimpleswitch(globalconfig, "multiregion")], [(("多重区域模式"), 12), D_getsimpleswitch(globalconfig, "multiregion")],
[(("记忆选定区域"), 12), getsimpleswitch(globalconfig, "rememberocrregions")], [(("记忆选定区域"), 12), D_getsimpleswitch(globalconfig, "rememberocrregions")],
[], [],
[ [
(("OCR范围框颜色"), 12), (("OCR范围框颜色"), 12),
( (
getcolorbutton( D_getcolorbutton(
globalconfig, globalconfig,
"ocrrangecolor", "ocrrangecolor",
callback=lambda: selectcolor( callback=lambda: selectcolor(
@ -171,7 +182,7 @@ def getocrgrid(self):
[ [
(("OCR范围框宽度"), 12), (("OCR范围框宽度"), 12),
( (
getspinbox( D_getspinbox(
1, 1,
100, 100,
globalconfig, globalconfig,
@ -183,16 +194,16 @@ def getocrgrid(self):
], ],
[ [
(("选取OCR范围后立即进行一次识别"), 12), (("选取OCR范围后立即进行一次识别"), 12),
getsimpleswitch(globalconfig, "ocrafterrangeselect"), D_getsimpleswitch(globalconfig, "ocrafterrangeselect"),
], ],
[ [
(("选取OCR范围后显示范围框"), 12), (("选取OCR范围后显示范围框"), 12),
getsimpleswitch(globalconfig, "showrangeafterrangeselect"), D_getsimpleswitch(globalconfig, "showrangeafterrangeselect"),
], ],
[ [
(("OCR识别易错内容修正"), 12), (("OCR识别易错内容修正"), 12),
getsimpleswitch(ocrerrorfix, "use"), D_getsimpleswitch(ocrerrorfix, "use"),
getcolorbutton( D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=functools.partial( callback=functools.partial(

View File

@ -2,27 +2,40 @@ import functools
from myutils.config import globalconfig, _TR from myutils.config import globalconfig, _TR
from myutils.winsyshotkey import SystemHotkey, registerException from myutils.winsyshotkey import SystemHotkey, registerException
import winsharedutils import winsharedutils
import gobject, windows import gobject, windows, functools
from qtsymbols import * from qtsymbols import *
from gui.usefulwidget import ( from gui.usefulwidget import (
getsimpleswitch, D_getsimpleswitch,
getsimplekeyseq, D_getsimplekeyseq,
makegrid, makescrollgrid,
tabadd_lazy,
makescroll,
) )
from myutils.hwnd import grabwindow from myutils.hwnd import grabwindow
from myutils.utils import getimageformat, parsekeystringtomodvkcode, unsupportkey from myutils.utils import getimageformat, parsekeystringtomodvkcode, unsupportkey
def setTab_quick_direct(self): def delaycreatereferlabels(self, name):
referlabel = QLabel()
self.referlabels[name] = referlabel
try:
referlabel.setText(self.referlabels_data[name])
except:
pass
return referlabel
def maybesetreferlabels(self, name, text):
try:
self.referlabels[name].setText(text)
except:
self.referlabels_data[name] = text
def registrhotkeys(self):
self.hotkeymanager = SystemHotkey() self.hotkeymanager = SystemHotkey()
self.referlabels = {} self.referlabels = {}
self.referlabels_data = {}
self.registok = {} self.registok = {}
self.bindfunctions = { self.bindfunctions = {
"_A": lambda: gobject.baseobject.settin_ui.clicksourcesignal.emit("copy"),
"_B": lambda: gobject.baseobject.settin_ui.clicksourcesignal.emit("ocr"),
"_C": lambda: gobject.baseobject.settin_ui.clicksourcesignal.emit("texthook"),
"_1": gobject.baseobject.translation_ui.startTranslater, "_1": gobject.baseobject.translation_ui.startTranslater,
"_2": gobject.baseobject.translation_ui.changeTranslateMode, "_2": gobject.baseobject.translation_ui.changeTranslateMode,
"_3": self.showsignal.emit, "_3": self.showsignal.emit,
@ -33,7 +46,7 @@ def setTab_quick_direct(self):
"_8": lambda: gobject.baseobject.translation_ui.changemousetransparentstate(0), "_8": lambda: gobject.baseobject.translation_ui.changemousetransparentstate(0),
"_9": gobject.baseobject.translation_ui.changetoolslockstate, "_9": gobject.baseobject.translation_ui.changetoolslockstate,
"_10": lambda: gobject.baseobject.translation_ui.showsavegame_signal.emit(), "_10": lambda: gobject.baseobject.translation_ui.showsavegame_signal.emit(),
"_11": lambda: gobject.baseobject.AttachProcessDialog.showsignal.emit(), "_11": gobject.baseobject.createattachprocess,
"_12": lambda: gobject.baseobject.hookselectdialog.showsignal.emit(), "_12": lambda: gobject.baseobject.hookselectdialog.showsignal.emit(),
"_13": lambda: gobject.baseobject.translation_ui.clickRange_signal.emit(False), "_13": lambda: gobject.baseobject.translation_ui.clickRange_signal.emit(False),
"_14": gobject.baseobject.translation_ui.showhide_signal.emit, "_14": gobject.baseobject.translation_ui.showhide_signal.emit,
@ -52,18 +65,19 @@ def setTab_quick_direct(self):
), ),
"_26": gobject.baseobject.translation_ui.ocr_once_signal.emit, "_26": gobject.baseobject.translation_ui.ocr_once_signal.emit,
"_27": gobject.baseobject.translation_ui.simulate_key_enter, "_27": gobject.baseobject.translation_ui.simulate_key_enter,
"_28": lambda: winsharedutils.clipboard_set(
gobject.baseobject.currenttranslate
),
} }
for name in globalconfig["quick_setting"]["all"]: for name in globalconfig["quick_setting"]["all"]:
if name not in self.bindfunctions: if name not in self.bindfunctions:
continue continue
referlabel = QLabel()
self.referlabels[name] = referlabel
regist_or_not_key(self, name) regist_or_not_key(self, name)
def setTab_quick(self): def setTab_quick(self, l):
tabadd_lazy(self.tab_widget, ("快捷按键"), lambda: setTab_quick_lazy(self)) makescrollgrid(setTab_quick_lazy(self), l)
def setTab_quick_lazy(self): def setTab_quick_lazy(self):
@ -71,7 +85,7 @@ def setTab_quick_lazy(self):
grids = [ grids = [
[ [
(("是否使用快捷键"), 4), (("是否使用快捷键"), 4),
getsimpleswitch( D_getsimpleswitch(
globalconfig["quick_setting"], globalconfig["quick_setting"],
"use", "use",
callback=functools.partial(__enable, self), callback=functools.partial(__enable, self),
@ -86,26 +100,23 @@ def setTab_quick_lazy(self):
grids.append( grids.append(
[ [
((globalconfig["quick_setting"]["all"][name]["name"]), 4), ((globalconfig["quick_setting"]["all"][name]["name"]), 4),
getsimpleswitch( D_getsimpleswitch(
globalconfig["quick_setting"]["all"][name], globalconfig["quick_setting"]["all"][name],
"use", "use",
callback=functools.partial(fanyiselect, self, name), callback=functools.partial(fanyiselect, self, name),
), ),
( (
getsimplekeyseq( D_getsimplekeyseq(
globalconfig["quick_setting"]["all"][name], globalconfig["quick_setting"]["all"][name],
"keystring", "keystring",
functools.partial(regist_or_not_key, self, name), functools.partial(regist_or_not_key, self, name),
), ),
2, 2,
), ),
(self.referlabels[name], 4), (functools.partial(delaycreatereferlabels, self, name), 4),
] ]
) )
gridlayoutwidget = makegrid(grids) return grids
gridlayoutwidget = makescroll(gridlayoutwidget)
return gridlayoutwidget
# self.yitiaolong("快捷按键",grids)
def __enable(self, x): def __enable(self, x):
@ -120,7 +131,7 @@ def fanyiselect(self, who, checked):
def regist_or_not_key(self, name): def regist_or_not_key(self, name):
self.referlabels[name].setText("") maybesetreferlabels(self, name, "")
if name in self.registok: if name in self.registok:
self.hotkeymanager.unregister(self.registok[name]) self.hotkeymanager.unregister(self.registok[name])
@ -137,11 +148,11 @@ def regist_or_not_key(self, name):
try: try:
mode, vkcode = parsekeystringtomodvkcode(keystring) mode, vkcode = parsekeystringtomodvkcode(keystring)
except unsupportkey as e: except unsupportkey as e:
self.referlabels[name].setText(_TR("不支持的键位") + ",".join(e.args[0])) maybesetreferlabels(self, name, _TR("不支持的键位") + ",".join(e.args[0]))
return return
try: try:
self.hotkeymanager.register((mode, vkcode), callback=self.bindfunctions[name]) self.hotkeymanager.register((mode, vkcode), callback=self.bindfunctions[name])
self.registok[name] = (mode, vkcode) self.registok[name] = (mode, vkcode)
except registerException: except registerException:
self.referlabels[name].setText(_TR("快捷键冲突")) maybesetreferlabels(self, name, _TR("快捷键冲突"))

View File

@ -5,25 +5,50 @@ from myutils.config import globalconfig, _TRL
import os, functools import os, functools
import gobject import gobject
from gui.usefulwidget import ( from gui.usefulwidget import (
getsimplecombobox, D_getsimplecombobox,
getspinbox, D_getspinbox,
makegrid, makescrollgrid,
makescroll, D_getcolorbutton,
getcolorbutton,
tabadd_lazy,
yuitsu_switch, yuitsu_switch,
getsimpleswitch, D_getsimpleswitch,
) )
def setTab5_direct(self): def showvoicelist(self, vl, idx):
try:
self.voicecombo.blockSignals(True)
self.voicecombo.clear()
self.voicecombo.addItems(vl)
if idx >= 0:
self.voicecombo.setCurrentIndex(idx)
self.voicecombo.blockSignals(False)
except:
self.voicecombo_cache = vl, idx
def changevoice(self, text):
globalconfig["reader"][gobject.baseobject.reader_usevoice]["voice"] = (
gobject.baseobject.reader.voicelist[self.voicecombo.currentIndex()]
)
def createvoicecombo(self):
self.voicecombo = QComboBox() self.voicecombo = QComboBox()
self.voicelistsignal.connect(functools.partial(showvoicelist, self))
self.voicecombo.currentTextChanged.connect(lambda x: changevoice(self, x)) self.voicecombo.currentTextChanged.connect(lambda x: changevoice(self, x))
try:
vl, idx = self.voicecombo_cache
self.voicecombo.addItems(vl)
if idx >= 0:
self.voicecombo.setCurrentIndex(idx)
except:
pass
return self.voicecombo
def setTab5(self): def setTab5(self, l):
tabadd_lazy(self.tab_widget, ("语音合成"), lambda: setTab5lz(self)) makescrollgrid(setTab5lz(self), l)
def getttsgrid(self): def getttsgrid(self):
@ -40,7 +65,7 @@ def getttsgrid(self):
if "args" in globalconfig["reader"][name]: if "args" in globalconfig["reader"][name]:
items = autoinitdialog_items(globalconfig["reader"][name]) items = autoinitdialog_items(globalconfig["reader"][name])
items[-1]["callback"] = gobject.baseobject.startreader items[-1]["callback"] = gobject.baseobject.startreader
_3 = getcolorbutton( _3 = D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=functools.partial( callback=functools.partial(
@ -60,7 +85,7 @@ def getttsgrid(self):
line += [ line += [
((globalconfig["reader"][name]["name"]), 6), ((globalconfig["reader"][name]["name"]), 6),
( (
getsimpleswitch( D_getsimpleswitch(
globalconfig["reader"][name], globalconfig["reader"][name],
"use", "use",
name=name, name=name,
@ -95,29 +120,29 @@ def setTab5lz(self):
grids = getttsgrid(self) grids = getttsgrid(self)
grids += [ grids += [
[], [],
[("选择声音", 6), (self.voicecombo, 15)], [("选择声音", 6), (functools.partial(createvoicecombo, self), 15)],
[ [
("语速:(-10~10)", 6), ("语速:(-10~10)", 6),
(getspinbox(-10, 10, globalconfig["ttscommon"], "rate"), 3), (D_getspinbox(-10, 10, globalconfig["ttscommon"], "rate"), 3),
], ],
[ [
("音量:(0~100)", 6), ("音量:(0~100)", 6),
(getspinbox(0, 100, globalconfig["ttscommon"], "volume"), 3), (D_getspinbox(0, 100, globalconfig["ttscommon"], "volume"), 3),
], ],
[("自动朗读", 6), (getsimpleswitch(globalconfig, "autoread"), 1)], [("自动朗读", 6), (D_getsimpleswitch(globalconfig, "autoread"), 1)],
[("不被打断", 6), (getsimpleswitch(globalconfig, "ttsnointerrupt"), 1)], [("不被打断", 6), (D_getsimpleswitch(globalconfig, "ttsnointerrupt"), 1)],
[ [
("朗读原文", 6), ("朗读原文", 6),
(getsimpleswitch(globalconfig, "read_raw"), 1), (D_getsimpleswitch(globalconfig, "read_raw"), 1),
"", "",
"", "",
("朗读翻译", 6), ("朗读翻译", 6),
(getsimpleswitch(globalconfig, "read_trans"), 1), (D_getsimpleswitch(globalconfig, "read_trans"), 1),
], ],
[ [
("朗读的翻译", 6), ("朗读的翻译", 6),
( (
getsimplecombobox( D_getsimplecombobox(
_TRL( _TRL(
[ [
globalconfig["fanyi"][x]["name"] globalconfig["fanyi"][x]["name"]
@ -133,8 +158,8 @@ def setTab5lz(self):
[], [],
[ [
("语音修正", 6), ("语音修正", 6),
getsimpleswitch(globalconfig["ttscommon"], "tts_repair"), D_getsimpleswitch(globalconfig["ttscommon"], "tts_repair"),
getcolorbutton( D_getcolorbutton(
globalconfig, globalconfig,
"", "",
callback=lambda x: noundictconfigdialog1( callback=lambda x: noundictconfigdialog1(
@ -149,22 +174,4 @@ def setTab5lz(self):
), ),
], ],
] ]
gridlayoutwidget = makegrid(grids) return grids
gridlayoutwidget = makescroll(gridlayoutwidget)
return gridlayoutwidget
def changevoice(self, text):
globalconfig["reader"][gobject.baseobject.reader_usevoice]["voice"] = (
gobject.baseobject.reader.voicelist[self.voicecombo.currentIndex()]
)
def showvoicelist(self, vl, idx):
self.voicecombo.blockSignals(True)
self.voicecombo.clear()
self.voicecombo.addItems(vl)
if idx >= 0:
self.voicecombo.setCurrentIndex(idx)
self.voicecombo.blockSignals(False)

View File

@ -1,18 +1,23 @@
from qtsymbols import * from qtsymbols import *
import qtawesome import qtawesome, gobject
from myutils.ocrutil import imagesolve from myutils.ocrutil import imagesolve
from gui.usefulwidget import closeashidewindow from gui.usefulwidget import saveposwindow
from myutils.config import globalconfig, _TR from myutils.config import globalconfig, _TR
from myutils.config import globalconfig from myutils.wrapper import Singleton_close
class showocrimage(closeashidewindow): @Singleton_close
class showocrimage(saveposwindow):
setimage = pyqtSignal(list) setimage = pyqtSignal(list)
def __init__(self, parent): def closeEvent(self, e):
gobject.baseobject.showocrimage = None
super().closeEvent(e)
def __init__(self, parent, cached):
self.img1 = None self.img1 = None
self.originimage = None self.originimage = None
super(showocrimage, self).__init__(parent, globalconfig, "showocrgeo") super().__init__(parent, globalconfig, "showocrgeo")
self.setWindowIcon(qtawesome.icon("fa.picture-o")) self.setWindowIcon(qtawesome.icon("fa.picture-o"))
self.setWindowTitle(_TR("查看处理效果")) self.setWindowTitle(_TR("查看处理效果"))
self.originlabel = QLabel(self) self.originlabel = QLabel(self)
@ -32,6 +37,8 @@ class showocrimage(closeashidewindow):
self.layout1.addWidget(button) self.layout1.addWidget(button)
self.layout1.addWidget(self.solvedlabel) self.layout1.addWidget(self.solvedlabel)
self.setimage.connect(self.setimagefunction) self.setimage.connect(self.setimagefunction)
if cached:
self.setimagefunction(cached)
def retest(self): def retest(self):
if self.originimage is None: if self.originimage is None:

View File

@ -192,14 +192,14 @@ class AnkiWindow(QWidget):
html = f'<style>{model_css}</style><div class="card">{html}</div>' html = f'<style>{model_css}</style><div class="card">{html}</div>'
self.htmlbrowser.setHtml(html) self.htmlbrowser.setHtml(html)
def creattemplatetab(self): def creattemplatetab(self, baselay):
layout = QHBoxLayout() layout = QHBoxLayout()
layout.setContentsMargins(0, 0, 0, 0) layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0) layout.setSpacing(0)
wid = QWidget() wid = QWidget()
wid.setLayout(layout) wid.setLayout(layout)
baselay.addWidget(wid)
edittemptab = QTabWidget() edittemptab = QTabWidget()
self.previewtab = QTabBar() self.previewtab = QTabBar()
revertbtn = QPushButton(_TR("恢复")) revertbtn = QPushButton(_TR("恢复"))
@ -241,7 +241,6 @@ class AnkiWindow(QWidget):
self.backtext.textChanged.connect(lambda: self.refreshhtml.emit()) self.backtext.textChanged.connect(lambda: self.refreshhtml.emit())
self.csstext.textChanged.connect(lambda: self.refreshhtml.emit()) self.csstext.textChanged.connect(lambda: self.refreshhtml.emit())
self.previewtab.currentChanged.connect(lambda: self.refreshhtml.emit()) self.previewtab.currentChanged.connect(lambda: self.refreshhtml.emit())
return wid
def loadedits(self): def loadedits(self):
for text, object in zip( for text, object in zip(
@ -335,10 +334,11 @@ class AnkiWindow(QWidget):
with open("userconfig/anki/style.css", "w", encoding="utf8") as ff: with open("userconfig/anki/style.css", "w", encoding="utf8") as ff:
ff.write(model_css) ff.write(model_css)
def creatsetdtab(self): def creatsetdtab(self, baselay):
layout = QFormLayout() layout = QFormLayout()
wid = QWidget() wid = QWidget()
wid.setLayout(layout) wid.setLayout(layout)
baselay.addWidget(wid)
layout.addRow( layout.addRow(
_TR("端口号"), getspinbox(0, 65536, globalconfig["ankiconnect"], "port") _TR("端口号"), getspinbox(0, 65536, globalconfig["ankiconnect"], "port")
) )
@ -409,7 +409,6 @@ class AnkiWindow(QWidget):
makewidget=True, makewidget=True,
), ),
) )
return wid
@threader @threader
def simulate_key(self, i): def simulate_key(self, i):

View File

@ -220,7 +220,6 @@ class Textbrowser(QLabel):
def __init__(self, parent): def __init__(self, parent):
super().__init__(parent) super().__init__(parent)
self.setMouseTracking(True) self.setMouseTracking(True)
self.atback2 = QLabel(parent) self.atback2 = QLabel(parent)

View File

@ -2,6 +2,7 @@ from qtsymbols import *
import qtawesome, functools, winsharedutils import qtawesome, functools, winsharedutils
from gui.usefulwidget import closeashidewindow from gui.usefulwidget import closeashidewindow
from myutils.config import globalconfig, _TR from myutils.config import globalconfig, _TR
from myutils.utils import get_time_stamp
class transhist(closeashidewindow): class transhist(closeashidewindow):
@ -17,6 +18,7 @@ class transhist(closeashidewindow):
self.getnewtranssignal.connect(self.getnewtrans) self.getnewtranssignal.connect(self.getnewtrans)
self.hiderawflag = False self.hiderawflag = False
self.hideapiflag = False self.hideapiflag = False
self.hidetime = True
self.setWindowTitle(_TR("历史翻译")) self.setWindowTitle(_TR("历史翻译"))
@ -45,6 +47,7 @@ class transhist(closeashidewindow):
copy = QAction(_TR("复制到剪贴板")) copy = QAction(_TR("复制到剪贴板"))
hideshowraw = QAction(_TR("显示原文" if self.hiderawflag else "不显示原文")) hideshowraw = QAction(_TR("显示原文" if self.hiderawflag else "不显示原文"))
hideshowapi = QAction(_TR("显示api" if self.hideapiflag else "不显示api")) hideshowapi = QAction(_TR("显示api" if self.hideapiflag else "不显示api"))
hidetime = QAction(_TR("显示时间" if self.hidetime else "不显示时间"))
menu.addAction(qingkong) menu.addAction(qingkong)
menu.addAction(baocun) menu.addAction(baocun)
if len(self.textOutput.textCursor().selectedText()): if len(self.textOutput.textCursor().selectedText()):
@ -52,6 +55,7 @@ class transhist(closeashidewindow):
if flag == 1: if flag == 1:
menu.addAction(hideshowraw) menu.addAction(hideshowraw)
menu.addAction(hideshowapi) menu.addAction(hideshowapi)
menu.addAction(hidetime)
action = menu.exec(QCursor.pos()) action = menu.exec(QCursor.pos())
if action == qingkong: if action == qingkong:
@ -67,20 +71,27 @@ class transhist(closeashidewindow):
elif action == hideshowraw: elif action == hideshowraw:
self.hiderawflag = not self.hiderawflag self.hiderawflag = not self.hiderawflag
elif action == hidetime:
self.hidetime = not self.hidetime
elif action == hideshowapi: elif action == hideshowapi:
self.hideapiflag = not self.hideapiflag self.hideapiflag = not self.hideapiflag
def getnewsentence(self, sentence): def getnewsentence(self, sentence):
sentence = "\n" + sentence
if self.hiderawflag: if self.hiderawflag:
sentence = "" sentence = ""
else:
if not self.hidetime:
sentence = get_time_stamp() + " " + sentence
sentence = "\n" + sentence
self.textOutput.appendPlainText(sentence) self.textOutput.appendPlainText(sentence)
def getnewtrans(self, api, sentence): def getnewtrans(self, api, sentence):
if self.hideapiflag: if not self.hideapiflag:
res = sentence sentence = api + " " + sentence
else: if not self.hidetime:
res = api + " " + sentence sentence = get_time_stamp() + " " + sentence
self.textOutput.appendPlainText(res)
self.textOutput.appendPlainText(sentence)

View File

@ -130,7 +130,7 @@ class QUnFrameWindow(resizableframeless):
else: else:
self.showline(clear=clear) self.showline(clear=clear)
gobject.baseobject.edittextui.getnewsentencesignal.emit(text) gobject.baseobject.maybesetedittext(text)
def showstatus(self, res, color, clear, origin): def showstatus(self, res, color, clear, origin):
self.showline(clear=clear, text=res, color=color, origin=origin) self.showline(clear=clear, text=res, color=color, origin=origin)
@ -234,6 +234,7 @@ class QUnFrameWindow(resizableframeless):
) )
if hira: if hira:
@threader @threader
def callback(word, append): def callback(word, append):
if globalconfig["usewordorigin"] == False: if globalconfig["usewordorigin"] == False:
@ -265,6 +266,7 @@ class QUnFrameWindow(resizableframeless):
self.lastrefreshtime = time.time() self.lastrefreshtime = time.time()
self.autohidestart = True self.autohidestart = True
@threader
def autohidedelaythread(self): def autohidedelaythread(self):
while True: while True:
if globalconfig["autodisappear"] and self.autohidestart: if globalconfig["autodisappear"] and self.autohidestart:
@ -295,7 +297,6 @@ class QUnFrameWindow(resizableframeless):
self.showhideui() self.showhideui()
def refreshtoolicon(self): def refreshtoolicon(self):
iconstate = { iconstate = {
"fullscreen": self.isletgamefullscreened, "fullscreen": self.isletgamefullscreened,
"muteprocess": self.processismuteed, "muteprocess": self.processismuteed,
@ -383,7 +384,7 @@ class QUnFrameWindow(resizableframeless):
"copy", "copy",
lambda: winsharedutils.clipboard_set(gobject.baseobject.currenttext), lambda: winsharedutils.clipboard_set(gobject.baseobject.currenttext),
), ),
("edit", lambda: gobject.baseobject.edittextui.showsignal.emit()), ("edit", gobject.baseobject.createedittextui),
("edittrans", lambda: edittrans(gobject.baseobject.settin_ui)), ("edittrans", lambda: edittrans(gobject.baseobject.settin_ui)),
("showraw", self.changeshowhideraw), ("showraw", self.changeshowhideraw),
("history", lambda: gobject.baseobject.transhis.showsignal.emit()), ("history", lambda: gobject.baseobject.transhis.showsignal.emit()),
@ -406,7 +407,7 @@ class QUnFrameWindow(resizableframeless):
("gamepad_new", lambda: dialog_savedgame_new(gobject.baseobject.settin_ui)), ("gamepad_new", lambda: dialog_savedgame_new(gobject.baseobject.settin_ui)),
( (
"selectgame", "selectgame",
lambda: gobject.baseobject.AttachProcessDialog.showsignal.emit(), lambda: gobject.baseobject.createattachprocess(),
), ),
( (
"selecttext", "selecttext",
@ -492,19 +493,13 @@ class QUnFrameWindow(resizableframeless):
self.show() self.show()
windows.SetForegroundWindow(int(self.winId())) windows.SetForegroundWindow(int(self.winId()))
def showEvent(self, a0) -> None: def aftershowdosomething(self):
if self.isfirstshow: self.showline(clear=True, text=_TR("欢迎使用"), origin=False)
self.showline(clear=True, text=_TR("欢迎使用"), origin=False)
self.tray.activated.connect(self.leftclicktray) windows.SetForegroundWindow(int(self.winId()))
self.refreshtoolicon()
self.tray.show() self.setontopthread()
windows.SetForegroundWindow(int(self.winId())) self.autohidedelaythread()
self.isfirstshow = False
self.setontopthread()
self.refreshtoolicon()
return super().showEvent(a0)
def canceltop(self): def canceltop(self):
windows.SetWindowPos( windows.SetWindowPos(
@ -554,26 +549,24 @@ class QUnFrameWindow(resizableframeless):
windows.SWP_NOACTIVATE | windows.SWP_NOSIZE | windows.SWP_NOMOVE, windows.SWP_NOACTIVATE | windows.SWP_NOSIZE | windows.SWP_NOMOVE,
) )
@threader
def setontopthread(self): def setontopthread(self):
def _(): self.settop()
self.settop() while globalconfig["keepontop"]:
while globalconfig["keepontop"]:
try: try:
hwnd = windows.GetForegroundWindow() hwnd = windows.GetForegroundWindow()
pid = windows.GetWindowThreadProcessId(hwnd) pid = windows.GetWindowThreadProcessId(hwnd)
if pid == os.getpid(): if pid == os.getpid():
pass pass
elif globalconfig["focusnotop"] and self.thistimenotsetop: elif globalconfig["focusnotop"] and self.thistimenotsetop:
pass pass
else: else:
self.settop() self.settop()
except: except:
print_exc() print_exc()
time.sleep(0.5) time.sleep(0.5)
self.canceltop() self.canceltop()
threading.Thread(target=_).start()
def seteffect(self): def seteffect(self):
if globalconfig["WindowEffect"] == 0: if globalconfig["WindowEffect"] == 0:
@ -583,33 +576,31 @@ class QUnFrameWindow(resizableframeless):
elif globalconfig["WindowEffect"] == 2: elif globalconfig["WindowEffect"] == 2:
winsharedutils.setAeroEffect(int(self.winId())) winsharedutils.setAeroEffect(int(self.winId()))
def __init__(self): def initvalues(self):
super(QUnFrameWindow, self).__init__(
None,
flags=Qt.WindowType.FramelessWindowHint
| Qt.WindowType.WindowMinimizeButtonHint,
dic=globalconfig,
key="transuigeo",
) # 设置为顶级窗口,无边框
icon = getExeIcon(sys.argv[0]) #'./LunaTranslator.exe')# QIcon()
# icon.addPixmap(QPixmap('./files/luna.png'), QIcon.Normal, QIcon.On)
self.setWindowIcon(icon)
self.tray = QSystemTrayIcon()
self.tray.setIcon(icon)
self.isfirstshow = True
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
self.setAttribute(Qt.WidgetAttribute.WA_ShowWithoutActivating, True)
self.setWindowTitle("LunaTranslator")
self.hidesignal.connect(self.hide_)
self.lastrefreshtime = time.time() self.lastrefreshtime = time.time()
self.autohidestart = False self.autohidestart = False
threading.Thread(target=self.autohidedelaythread).start() self.enter_sig = 0
self.muteprocessignal.connect(self.muteprocessfuntion) self.fullscreenmanager_busy = False
self.toolbarhidedelaysignal.connect(self.toolbarhidedelay) self.isletgamefullscreened = False
self.fullscreenmanager = None
self.fullscreenmethod = None
self._isTracking = False
self.isontop = True
self.showhidestate = False
self.processismuteed = False
self.mousetransparent = False
self.thistimenotsetop = False
self.backtransparent = False
self.isbindedwindow = False
self.buttons = {}
self.showbuttons = []
self.stylebuttons = {}
self.saveiterclasspointer = {}
def initsignals(self):
self.hidesignal.connect(self.hide_)
self.ocr_once_signal.connect(self.ocr_once_function) self.ocr_once_signal.connect(self.ocr_once_function)
self.enter_sig = 0
self.entersignal.connect(self.enterfunction) self.entersignal.connect(self.enterfunction)
self.displaystatus.connect(self.showstatus) self.displaystatus.connect(self.showstatus)
self.showhideuisignal.connect(self.showhideui) self.showhideuisignal.connect(self.showhideui)
@ -628,28 +619,32 @@ class QUnFrameWindow(resizableframeless):
self.quitf_signal.connect(self.close) self.quitf_signal.connect(self.close)
self.fullsgame_signal.connect(self._fullsgame) self.fullsgame_signal.connect(self._fullsgame)
self.fullscreenmanager_busy = False self.muteprocessignal.connect(self.muteprocessfuntion)
self.isletgamefullscreened = False self.toolbarhidedelaysignal.connect(self.toolbarhidedelay)
self.fullscreenmanager = None
self.fullscreenmethod = None def __init__(self):
self._isTracking = False
self.isontop = True super(QUnFrameWindow, self).__init__(
None,
flags=Qt.WindowType.FramelessWindowHint
| Qt.WindowType.WindowMinimizeButtonHint,
dic=globalconfig,
key="transuigeo",
) # 设置为顶级窗口,无边框
icon = getExeIcon(sys.argv[0]) #'./LunaTranslator.exe')# QIcon()
# icon.addPixmap(QPixmap('./files/luna.png'), QIcon.Normal, QIcon.On)
self.setWindowIcon(icon)
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
self.setAttribute(Qt.WidgetAttribute.WA_ShowWithoutActivating, True)
self.setWindowTitle("LunaTranslator")
self.initvalues()
self.initsignals()
self._TitleLabel = QLabel(self) self._TitleLabel = QLabel(self)
self._TitleLabel.move(0, 0)
self.showhidestate = False
self.processismuteed = False
self.mousetransparent = False
self.backtransparent = False
self.isbindedwindow = False
self.buttons = {}
self.showbuttons = []
self.stylebuttons = {}
self.saveiterclasspointer = {}
self.addbuttons() self.addbuttons()
self.translate_text = Textbrowser(self) self.translate_text = Textbrowser(self)
self.translate_text.contentsChanged.connect(self.textAreaChanged) self.translate_text.contentsChanged.connect(self.textAreaChanged)
self.thistimenotsetop = False
def createborderradiusstring(self, r, merge, top=False): def createborderradiusstring(self, r, merge, top=False):
if merge: if merge:
@ -868,7 +863,10 @@ class QUnFrameWindow(resizableframeless):
self.refreshtoolicon() self.refreshtoolicon()
def changeshowhideraw(self): def changeshowhideraw(self):
gobject.baseobject.settin_ui.show_original_switch.click() try:
gobject.baseobject.settin_ui.show_original_switch.click()
except:
pass
def changeTranslateMode(self): def changeTranslateMode(self):
globalconfig["autorun"] = not globalconfig["autorun"] globalconfig["autorun"] = not globalconfig["autorun"]
@ -1061,8 +1059,6 @@ class QUnFrameWindow(resizableframeless):
if self.fullscreenmanager: if self.fullscreenmanager:
self.fullscreenmanager.endX() self.fullscreenmanager.endX()
gobject.baseobject.isrunning = False gobject.baseobject.isrunning = False
self.tray.hide()
self.tray = None
self.hide() self.hide()
if gobject.baseobject.textsource: if gobject.baseobject.textsource:
@ -1073,4 +1069,5 @@ class QUnFrameWindow(resizableframeless):
endsubprocs() endsubprocs()
self.tryremoveuseless() self.tryremoveuseless()
gobject.baseobject.destroytray()
os._exit(0) os._exit(0)

View File

@ -399,6 +399,10 @@ def getsimplecombobox(lst, d, k, callback=None, fixedsize=False, internallist=No
return s return s
def D_getsimplecombobox(lst, d, k, callback=None, fixedsize=False, internallist=None):
return lambda: getsimplecombobox(lst, d, k, callback, fixedsize, internallist)
def getlineedit(d, key, callback=None, readonly=False): def getlineedit(d, key, callback=None, readonly=False):
s = QLineEdit() s = QLineEdit()
s.setText(d[key]) s.setText(d[key])
@ -422,6 +426,10 @@ def getspinbox(mini, maxi, d, key, double=False, step=1, callback=None, dec=1):
return s return s
def D_getspinbox(mini, maxi, d, key, double=False, step=1, callback=None, dec=1):
return lambda: getspinbox(mini, maxi, d, key, double, step, callback, dec)
def getcolorbutton( def getcolorbutton(
d, d,
key, key,
@ -457,6 +465,34 @@ def getcolorbutton(
return b return b
def D_getcolorbutton(
d,
key,
callback,
name=None,
parent=None,
icon="fa.paint-brush",
constcolor=None,
enable=True,
transparent=True,
qicon=None,
sizefixed=False,
):
return lambda: getcolorbutton(
d,
key,
callback,
name,
parent,
icon,
constcolor,
enable,
transparent,
qicon,
sizefixed,
)
def yuitsu_switch(parent, configdict, dictobjectn, key, callback, checked): def yuitsu_switch(parent, configdict, dictobjectn, key, callback, checked):
dictobject = getattr(parent, dictobjectn) dictobject = getattr(parent, dictobjectn)
if checked: if checked:
@ -487,6 +523,14 @@ def getsimpleswitch(
return b return b
def D_getsimpleswitch(
d, key, enable=True, callback=None, name=None, pair=None, parent=None, default=None
):
return lambda: getsimpleswitch(
d, key, enable, callback, name, pair, parent, default
)
def selectcolor( def selectcolor(
parent, configdict, configkey, button, item=None, name=None, callback=None parent, configdict, configkey, button, item=None, name=None, callback=None
): ):
@ -506,24 +550,39 @@ def selectcolor(
print_exc() print_exc()
def getboxlayout(widgets, lc=QHBoxLayout, margin0=False, makewidget=False): def getboxlayout(
widgets, lc=QHBoxLayout, margin0=False, makewidget=False, delay=False, both=False
):
cp_layout = lc() cp_layout = lc()
for w in widgets:
if isinstance(w, QWidget): def __do(cp_layout, widgets):
cp_layout.addWidget(w) for w in widgets:
elif isinstance(w, QLayout): if callable(w):
cp_layout.addLayout(w) w = w()
if isinstance(w, QWidget):
cp_layout.addWidget(w)
elif isinstance(w, QLayout):
cp_layout.addLayout(w)
_do = functools.partial(__do, cp_layout, widgets)
if margin0: if margin0:
cp_layout.setContentsMargins(0, 0, 0, 0) cp_layout.setContentsMargins(0, 0, 0, 0)
if not delay:
_do()
if makewidget: if makewidget:
w = QWidget() w = QWidget()
w.setLayout(cp_layout) w.setLayout(cp_layout)
if delay:
return w, _do
if both:
return w, cp_layout
if makewidget:
return w return w
return cp_layout return cp_layout
def makevbox(wids): def getvboxwidget():
return getboxlayout(wids, lc=QVBoxLayout, margin0=True, makewidget=True) return getboxlayout([], lc=QVBoxLayout, margin0=True, makewidget=True, both=True)
def textbrowappendandmovetoend(textOutput, sentence, addspace=True): def textbrowappendandmovetoend(textOutput, sentence, addspace=True):
@ -660,6 +719,10 @@ def getsimplekeyseq(dic, key, callback=None):
return key1 return key1
def D_getsimplekeyseq(dic, key, callback=None):
return lambda: getsimplekeyseq(dic, key, callback)
class QWebWrap(QWidget): class QWebWrap(QWidget):
on_load = pyqtSignal(str) on_load = pyqtSignal(str)
html_limit = 2 * 1024 * 1024 html_limit = 2 * 1024 * 1024
@ -789,7 +852,7 @@ def tabadd_lazy(tab, title, getrealwidgetfunction):
v = QVBoxLayout() v = QVBoxLayout()
q.setLayout(v) q.setLayout(v)
v.setContentsMargins(0, 0, 0, 0) v.setContentsMargins(0, 0, 0, 0)
q.lazyfunction = lambda: v.addWidget(getrealwidgetfunction()) q.lazyfunction = functools.partial(getrealwidgetfunction, v)
tab.addTab(q, _TR(title)) tab.addTab(q, _TR(title))
@ -835,9 +898,11 @@ def automakegrid(grid: QGridLayout, lis, save=False, savelist=None):
if cols > 0: if cols > 0:
col = cols col = cols
elif cols == 0: elif cols == 0:
col = maxl col = maxl - nowc
else: else:
col = -maxl // cols col = -maxl // cols
if callable(wid):
wid = wid()
grid.addWidget(wid, nowr, nowc, 1, col) grid.addWidget(wid, nowr, nowc, 1, col)
if save: if save:
ll.append(wid) ll.append(wid)
@ -847,7 +912,7 @@ def automakegrid(grid: QGridLayout, lis, save=False, savelist=None):
grid.setRowMinimumHeight(nowr, 25) grid.setRowMinimumHeight(nowr, 25)
def makegrid(grid, save=False, savelist=None, savelay=None): def makegrid(grid=None, save=False, savelist=None, savelay=None, delay=False):
class gridwidget(QWidget): class gridwidget(QWidget):
pass pass
@ -858,13 +923,38 @@ def makegrid(grid, save=False, savelist=None, savelay=None):
gridlayoutwidget.setLayout(gridlay) gridlayoutwidget.setLayout(gridlay)
gridlayoutwidget.setStyleSheet("gridwidget{background-color:transparent;}") gridlayoutwidget.setStyleSheet("gridwidget{background-color:transparent;}")
automakegrid(gridlay, grid, save, savelist) def do(gridlay, grid, save, savelist, savelay):
if save: automakegrid(gridlay, grid, save, savelist)
savelay.append(gridlay) if save:
return gridlayoutwidget savelay.append(gridlay)
__do = functools.partial(do, gridlay, grid, save, savelist, savelay)
if not delay:
__do()
return gridlayoutwidget
return gridlayoutwidget, __do
def makesubtab_lazy(titles=None, functions=None, klass=None, callback=None): def makescroll(widget):
scroll = QScrollArea()
# scroll.setHorizontalScrollBarPolicy(1)
scroll.setStyleSheet("""QScrollArea{background-color:transparent;border:0px}""")
scroll.setWidgetResizable(True)
return scroll
def makescrollgrid(grid, lay, save=False, savelist=None, savelay=None):
wid, do = makegrid(grid, save, savelist, savelay, delay=True)
swid = makescroll(wid)
lay.addWidget(swid)
swid.setWidget(wid)
do()
return wid
def makesubtab_lazy(
titles=None, functions=None, klass=None, callback=None, delay=False
):
if klass: if klass:
tab = klass() tab = klass()
else: else:
@ -882,16 +972,15 @@ def makesubtab_lazy(titles=None, functions=None, klass=None, callback=None):
callback(i) callback(i)
tab.currentChanged.connect(functools.partial(__, tab)) tab.currentChanged.connect(functools.partial(__, tab))
if titles and functions:
for i, func in enumerate(functions):
tabadd_lazy(tab, titles[i], func)
return tab
def __do(tab, titles, functions):
if titles and functions:
for i, func in enumerate(functions):
tabadd_lazy(tab, titles[i], func)
def makescroll(widget): ___do = functools.partial(__do, tab, titles, functions)
scroll = QScrollArea() if not delay:
# scroll.setHorizontalScrollBarPolicy(1) ___do()
scroll.setStyleSheet("""QScrollArea{background-color:transparent;border:0px}""") return tab
scroll.setWidgetResizable(True) else:
scroll.setWidget(widget) return tab, ___do
return scroll

View File

@ -76,7 +76,7 @@ def imageCut(hwnd, x1, y1, x2, y2, viscompare=True, rawimage=False) -> QImage:
return image return image
image2 = imagesolve(image) image2 = imagesolve(image)
if viscompare: if viscompare:
gobject.baseobject.showocrimage.setimage.emit([image, image2]) gobject.baseobject.maybesetimage([image, image2])
return image2 return image2

View File

@ -632,3 +632,11 @@ def str2rgba(string, alpha100):
int(string[5:7], 16), int(string[5:7], 16),
alpha100 / 100, alpha100 / 100,
) )
def get_time_stamp():
ct = time.time()
local_time = time.localtime(ct)
data_head = time.strftime("%Y-%m-%d %H:%M:%S", local_time)
data_secs = (ct - int(ct)) * 1000
time_stamp = "%s.%03d" % (data_head, data_secs)
return time_stamp

View File

@ -1,7 +1,7 @@
try: try:
from PyQt5 import QtSvg from PyQt5 import QtSvg
from PyQt5.QtWidgets import QFrame,QListView,QCheckBox,QAbstractItemView,QTextEdit,QTableView,QHeaderView,QColorDialog,QSpinBox,QDoubleSpinBox,QComboBox,QDialogButtonBox,QMainWindow,QMessageBox,QDialog,QGridLayout,QTextBrowser,QGraphicsDropShadowEffect,QWidget,QSizePolicy,QScrollArea,QApplication,QPushButton,QSystemTrayIcon,QPlainTextEdit,QAction,QMenu,QFileDialog,QKeySequenceEdit,QLabel,QSpacerItem,QWidgetItem,QLayout,QTextBrowser,QLineEdit,QFormLayout,QSizePolicy,QTabWidget,QTabBar,QSplitter,QListWidget,QListWidgetItem,QHBoxLayout,QVBoxLayout,QSizeGrip,QFontComboBox,QProgressBar,QRadioButton,QButtonGroup,QSlider from PyQt5.QtWidgets import QFrame,QListView,QCheckBox,QAbstractItemView,QTextEdit,QTableView,QHeaderView,QColorDialog,QSpinBox,QDoubleSpinBox,QComboBox,QDialogButtonBox,QMainWindow,QMessageBox,QDialog,QGridLayout,QTextBrowser,QGraphicsDropShadowEffect,QWidget,QSizePolicy,QScrollArea,QApplication,QPushButton,QSystemTrayIcon,QPlainTextEdit,QAction,QMenu,QFileDialog,QKeySequenceEdit,QLabel,QSpacerItem,QWidgetItem,QLayout,QTextBrowser,QLineEdit,QFormLayout,QSizePolicy,QTabWidget,QTabBar,QSplitter,QListWidget,QListWidgetItem,QHBoxLayout,QVBoxLayout,QSizeGrip,QFontComboBox,QProgressBar,QRadioButton,QButtonGroup,QSlider
from PyQt5.QtGui import QIconEngine,QIntValidator,QStandardItem,QStandardItemModel,QImageWriter,QIcon,QTextCharFormat,QTextBlockFormat,QResizeEvent,QTextCursor,QFontMetricsF,QMouseEvent,QImage,QPainter,QRegion,QCloseEvent,QFontDatabase,QKeySequence,QPixmap,QCursor,QColor,QFont,QPen,QPainterPath,QBrush,QFontMetrics from PyQt5.QtGui import QIconEngine,QIntValidator,QStandardItem,QStandardItemModel,QImageWriter,QIcon,QTextCharFormat,QTextBlockFormat,QResizeEvent,QTextCursor,QFontMetricsF,QMouseEvent,QImage,QPainter,QRegion,QCloseEvent,QFontDatabase,QKeySequence,QPixmap,QCursor,QColor,QFont,QPen,QPainterPath,QBrush,QFontMetrics,QShowEvent
from PyQt5.QtCore import QObject,pyqtSignal,Qt,QSize,QByteArray,QBuffer,QPointF,QPoint,QRect,QEvent,QModelIndex from PyQt5.QtCore import QObject,pyqtSignal,Qt,QSize,QByteArray,QBuffer,QPointF,QPoint,QRect,QEvent,QModelIndex
isqt5 = True isqt5 = True
except: except:
@ -9,6 +9,6 @@ except:
#print_exc() #print_exc()
from PyQt6 import QtSvg from PyQt6 import QtSvg
from PyQt6.QtWidgets import QFrame,QListView,QCheckBox,QAbstractItemView,QTextEdit,QTableView,QHeaderView,QColorDialog,QSpinBox,QDoubleSpinBox,QComboBox,QDialogButtonBox,QMainWindow,QMessageBox,QDialog,QGridLayout,QTextBrowser,QGraphicsDropShadowEffect,QWidget,QSizePolicy,QScrollArea,QApplication,QPushButton,QSystemTrayIcon,QPlainTextEdit,QMenu,QFileDialog,QKeySequenceEdit,QLabel,QSpacerItem,QWidgetItem,QLayout,QTextBrowser,QLineEdit,QFormLayout,QSizePolicy,QTabWidget,QTabBar,QSplitter,QListWidget,QListWidgetItem,QHBoxLayout,QVBoxLayout,QSizeGrip,QFontComboBox,QProgressBar,QRadioButton,QButtonGroup,QSlider from PyQt6.QtWidgets import QFrame,QListView,QCheckBox,QAbstractItemView,QTextEdit,QTableView,QHeaderView,QColorDialog,QSpinBox,QDoubleSpinBox,QComboBox,QDialogButtonBox,QMainWindow,QMessageBox,QDialog,QGridLayout,QTextBrowser,QGraphicsDropShadowEffect,QWidget,QSizePolicy,QScrollArea,QApplication,QPushButton,QSystemTrayIcon,QPlainTextEdit,QMenu,QFileDialog,QKeySequenceEdit,QLabel,QSpacerItem,QWidgetItem,QLayout,QTextBrowser,QLineEdit,QFormLayout,QSizePolicy,QTabWidget,QTabBar,QSplitter,QListWidget,QListWidgetItem,QHBoxLayout,QVBoxLayout,QSizeGrip,QFontComboBox,QProgressBar,QRadioButton,QButtonGroup,QSlider
from PyQt6.QtGui import QIconEngine,QIntValidator,QAction,QStandardItem,QStandardItemModel,QImageWriter,QIcon,QTextCharFormat,QTextBlockFormat,QResizeEvent,QTextCursor,QFontMetricsF,QMouseEvent,QImage,QPainter,QRegion,QCloseEvent,QFontDatabase,QKeySequence,QPixmap,QCursor,QColor,QFont,QPen,QPainterPath,QBrush,QFontMetrics from PyQt6.QtGui import QIconEngine,QIntValidator,QAction,QStandardItem,QStandardItemModel,QImageWriter,QIcon,QTextCharFormat,QTextBlockFormat,QResizeEvent,QTextCursor,QFontMetricsF,QMouseEvent,QImage,QPainter,QRegion,QCloseEvent,QFontDatabase,QKeySequence,QPixmap,QCursor,QColor,QFont,QPen,QPainterPath,QBrush,QFontMetrics,QShowEvent
from PyQt6.QtCore import QObject,pyqtSignal,Qt,QSize,QByteArray,QBuffer,QPointF,QPoint,QRect,QEvent,QModelIndex from PyQt6.QtCore import QObject,pyqtSignal,Qt,QSize,QByteArray,QBuffer,QPointF,QPoint,QRect,QEvent,QModelIndex
isqt5 = False isqt5 = False

View File

@ -105,9 +105,12 @@ class ocrtext(basetext):
else: else:
image_score = 0 image_score = 0
if i == 0: if i == 0:
gobject.baseobject.settin_ui.threshold1label.setText( try:
str(image_score) gobject.baseobject.settin_ui.threshold1label.setText(
) str(image_score)
)
except:
pass
self.savelastimg[i] = imgr1 self.savelastimg[i] = imgr1
if image_score > globalconfig["ocr_stable_sim"]: if image_score > globalconfig["ocr_stable_sim"]:
@ -118,9 +121,12 @@ class ocrtext(basetext):
else: else:
image_score2 = 0 image_score2 = 0
if i == 0: if i == 0:
gobject.baseobject.settin_ui.threshold2label.setText( try:
str(image_score2) gobject.baseobject.settin_ui.threshold2label.setText(
) str(image_score2)
)
except:
pass
if image_score2 > globalconfig["ocr_diff_sim"]: if image_score2 > globalconfig["ocr_diff_sim"]:
ok = False ok = False
else: else:

View File

@ -562,21 +562,6 @@
"quick_setting": { "quick_setting": {
"use": false, "use": false,
"all": { "all": {
"_A": {
"use": false,
"name": "选择翻译源_剪贴板",
"keystring": ""
},
"_B": {
"use": false,
"name": "选择翻译源_OCR",
"keystring": ""
},
"_C": {
"use": false,
"name": "选择翻译源_HOOK",
"keystring": ""
},
"_1": { "_1": {
"use": false, "use": false,
"name": "重新翻译", "name": "重新翻译",
@ -706,6 +691,11 @@
"use": false, "use": false,
"name": "模拟按键Enter", "name": "模拟按键Enter",
"keystring": "" "keystring": ""
},
"_28": {
"use": false,
"name": "复制到剪贴板_翻译",
"keystring": ""
} }
} }
}, },

View File

@ -620,7 +620,6 @@
"过长惩罚": "عقوبة طويلة", "过长惩罚": "عقوبة طويلة",
"重复惩罚": "تكرار العقوبة", "重复惩罚": "تكرار العقوبة",
"OCR语言包": "التعرف الضوئي على الحروف حزمة اللغة", "OCR语言包": "التعرف الضوئي على الحروف حزمة اللغة",
"选择翻译源": "اختيار مصدر الترجمة",
"最长显示字数": "أقصى عرض الكلمات", "最长显示字数": "أقصى عرض الكلمات",
"显示日语注音": "عرض صوتي ياباني", "显示日语注音": "عرض صوتي ياباني",
"注音颜色": "لون صوتي", "注音颜色": "لون صوتي",
@ -804,5 +803,9 @@
"窗口特效": "نافذة المؤثرات الخاصة", "窗口特效": "نافذة المؤثرات الخاصة",
"实时编辑": "في الوقت الحقيقي تحرير", "实时编辑": "في الوقت الحقيقي تحرير",
"翻译记录": "سجل الترجمة", "翻译记录": "سجل الترجمة",
"遍历目录中的全部词典文件": "اجتياز جميع ملفات القاموس في الدليل" "遍历目录中的全部词典文件": "اجتياز جميع ملفات القاموس في الدليل",
"网络请求": "طلب شبكة",
"网页显示": "عرض الصفحة",
"显示时间": "عرض الوقت",
"不显示时间": "لا وقت العرض"
} }

View File

@ -620,7 +620,6 @@
"过长惩罚": "過長懲罰", "过长惩罚": "過長懲罰",
"重复惩罚": "重複懲罰", "重复惩罚": "重複懲罰",
"OCR语言包": "OCR語言包", "OCR语言包": "OCR語言包",
"选择翻译源": "選擇翻譯源",
"最长显示字数": "最長顯示字數", "最长显示字数": "最長顯示字數",
"显示日语注音": "顯示日語注音", "显示日语注音": "顯示日語注音",
"注音颜色": "注音顏色", "注音颜色": "注音顏色",
@ -804,5 +803,9 @@
"窗口特效": "視窗特效", "窗口特效": "視窗特效",
"实时编辑": "實时編輯", "实时编辑": "實时編輯",
"翻译记录": "翻譯記錄", "翻译记录": "翻譯記錄",
"遍历目录中的全部词典文件": "遍歷目錄中的全部詞典檔案" "遍历目录中的全部词典文件": "遍歷目錄中的全部詞典檔案",
"网络请求": "網絡請求",
"网页显示": "網頁顯示",
"显示时间": "顯示時間",
"不显示时间": "不顯示時間"
} }

View File

@ -620,7 +620,6 @@
"过长惩罚": "Excessive punishment", "过长惩罚": "Excessive punishment",
"重复惩罚": "Repetitive punishment", "重复惩罚": "Repetitive punishment",
"OCR语言包": "OCR Language Pack", "OCR语言包": "OCR Language Pack",
"选择翻译源": "Select Translation Source",
"最长显示字数": "Maximum number of displayed words", "最长显示字数": "Maximum number of displayed words",
"显示日语注音": "Display Japanese Pinyin", "显示日语注音": "Display Japanese Pinyin",
"注音颜色": "Pinyin color", "注音颜色": "Pinyin color",
@ -804,5 +803,9 @@
"窗口特效": "Window effects", "窗口特效": "Window effects",
"实时编辑": "Real time editing", "实时编辑": "Real time editing",
"翻译记录": "Translation records", "翻译记录": "Translation records",
"遍历目录中的全部词典文件": "Traverse all dictionary files in the directory" "遍历目录中的全部词典文件": "Traverse all dictionary files in the directory",
"网络请求": "Network request",
"网页显示": "Web page display",
"显示时间": "Display time",
"不显示时间": "Do not display time"
} }

View File

@ -620,7 +620,6 @@
"过长惩罚": "Castigo excesivo", "过长惩罚": "Castigo excesivo",
"重复惩罚": "Repetir el castigo", "重复惩罚": "Repetir el castigo",
"OCR语言包": "Paquete lingüístico OCR", "OCR语言包": "Paquete lingüístico OCR",
"选择翻译源": "Selección de la fuente de traducción",
"最长显示字数": "Número máximo de palabras mostradas", "最长显示字数": "Número máximo de palabras mostradas",
"显示日语注音": "Muestra la fonética japonesa", "显示日语注音": "Muestra la fonética japonesa",
"注音颜色": "Color de la nota", "注音颜色": "Color de la nota",
@ -804,5 +803,9 @@
"窗口特效": "Efectos especiales de la ventana", "窗口特效": "Efectos especiales de la ventana",
"实时编辑": "Edición en tiempo real", "实时编辑": "Edición en tiempo real",
"翻译记录": "Registros de traducción", "翻译记录": "Registros de traducción",
"遍历目录中的全部词典文件": "Recorrer todos los archivos del diccionario en el catálogo" "遍历目录中的全部词典文件": "Recorrer todos los archivos del diccionario en el catálogo",
"网络请求": "Solicitud de red",
"网页显示": "Pantalla de la página web",
"显示时间": "Tiempo de visualización",
"不显示时间": "No muestra el tiempo"
} }

View File

@ -620,7 +620,6 @@
"过长惩罚": "Pénalité trop longue", "过长惩罚": "Pénalité trop longue",
"重复惩罚": "Punition répétée", "重复惩罚": "Punition répétée",
"OCR语言包": "Pack de langue ocr", "OCR语言包": "Pack de langue ocr",
"选择翻译源": "Choisir une source de traduction",
"最长显示字数": "Nombre maximal de mots affichés", "最长显示字数": "Nombre maximal de mots affichés",
"显示日语注音": "Afficher les notes en japonais", "显示日语注音": "Afficher les notes en japonais",
"注音颜色": "Couleur d'accent", "注音颜色": "Couleur d'accent",
@ -804,5 +803,9 @@
"窗口特效": "Effets spéciaux de fenêtre", "窗口特效": "Effets spéciaux de fenêtre",
"实时编辑": "Edit en temps réel", "实时编辑": "Edit en temps réel",
"翻译记录": "Record de traduction", "翻译记录": "Record de traduction",
"遍历目录中的全部词典文件": "Parcourir tous les fichiers de dictionnaire dans le Répertoire" "遍历目录中的全部词典文件": "Parcourir tous les fichiers de dictionnaire dans le Répertoire",
"网络请求": "Demande de réseau",
"网页显示": "Affichage de la page Web",
"显示时间": "Afficher l'heure",
"不显示时间": "Ne pas afficher l'heure"
} }

View File

@ -620,7 +620,6 @@
"过长惩罚": "Pena eccessiva", "过长惩罚": "Pena eccessiva",
"重复惩罚": "Pena ripetitiva", "重复惩罚": "Pena ripetitiva",
"OCR语言包": "Pacchetto linguistico OCR", "OCR语言包": "Pacchetto linguistico OCR",
"选择翻译源": "Seleziona sorgente di traduzione",
"最长显示字数": "Numero massimo di parole visualizzate", "最长显示字数": "Numero massimo di parole visualizzate",
"显示日语注音": "Mostra pinyin giapponese", "显示日语注音": "Mostra pinyin giapponese",
"注音颜色": "Colore pinyin", "注音颜色": "Colore pinyin",
@ -804,5 +803,9 @@
"窗口特效": "Effetti finestra", "窗口特效": "Effetti finestra",
"实时编辑": "Modifica in tempo reale", "实时编辑": "Modifica in tempo reale",
"翻译记录": "Record di traduzione", "翻译记录": "Record di traduzione",
"遍历目录中的全部词典文件": "Attraversa tutti i file del dizionario nella directory" "遍历目录中的全部词典文件": "Attraversa tutti i file del dizionario nella directory",
"网络请求": "Richiesta di rete",
"网页显示": "Visualizzazione pagina web",
"显示时间": "Tempo di visualizzazione",
"不显示时间": "Non visualizzare l'ora"
} }

View File

@ -620,7 +620,6 @@
"过长惩罚": "長すぎる罰", "过长惩罚": "長すぎる罰",
"重复惩罚": "繰り返し罰する.", "重复惩罚": "繰り返し罰する.",
"OCR语言包": "OCR言語パック", "OCR语言包": "OCR言語パック",
"选择翻译源": "翻訳ソースの選択",
"最长显示字数": "最長表示文字数", "最长显示字数": "最長表示文字数",
"显示日语注音": "日本語のルビを表示", "显示日语注音": "日本語のルビを表示",
"注音颜色": "ルビの色", "注音颜色": "ルビの色",
@ -804,5 +803,9 @@
"窗口特效": "ウィンドウ効果", "窗口特效": "ウィンドウ効果",
"实时编辑": "リアルタイム編集", "实时编辑": "リアルタイム編集",
"翻译记录": "翻訳レコード", "翻译记录": "翻訳レコード",
"遍历目录中的全部词典文件": "ディレクトリ内のすべての辞書ファイルを巡回" "遍历目录中的全部词典文件": "ディレクトリ内のすべての辞書ファイルを巡回",
"网络请求": "ネットワーク要求",
"网页显示": "Webページ表示",
"显示时间": "表示時間",
"不显示时间": "時間を表示しない"
} }

View File

@ -620,7 +620,6 @@
"过长惩罚": "과도한 처벌", "过长惩罚": "과도한 처벌",
"重复惩罚": "반복 처벌", "重复惩罚": "반복 처벌",
"OCR语言包": "OCR 언어 팩", "OCR语言包": "OCR 언어 팩",
"选择翻译源": "번역 소스 선택",
"最长显示字数": "최대 표시 단어 수", "最长显示字数": "최대 표시 단어 수",
"显示日语注音": "일본어 메모 표시", "显示日语注音": "일본어 메모 표시",
"注音颜色": "주음 색상", "注音颜色": "주음 색상",
@ -804,5 +803,9 @@
"窗口特效": "창 효과", "窗口特效": "창 효과",
"实时编辑": "실시간 편집", "实时编辑": "실시간 편집",
"翻译记录": "번역 기록", "翻译记录": "번역 기록",
"遍历目录中的全部词典文件": "디렉토리의 모든 사전 파일 반복" "遍历目录中的全部词典文件": "디렉토리의 모든 사전 파일 반복",
"网络请求": "네트워크 요청",
"网页显示": "웹 페이지 표시",
"显示时间": "표시 시간",
"不显示时间": "시간 표시 안 함"
} }

View File

@ -620,7 +620,6 @@
"过长惩罚": "Nadmierna kara", "过长惩罚": "Nadmierna kara",
"重复惩罚": "Kary powtarzające się", "重复惩罚": "Kary powtarzające się",
"OCR语言包": "Pakiet językowy OCR", "OCR语言包": "Pakiet językowy OCR",
"选择翻译源": "Wybierz źródło tłumaczenia",
"最长显示字数": "Maksymalna liczba wyświetlanych słów", "最长显示字数": "Maksymalna liczba wyświetlanych słów",
"显示日语注音": "Wyświetl japoński pinyin", "显示日语注音": "Wyświetl japoński pinyin",
"注音颜色": "Kolor pinyin", "注音颜色": "Kolor pinyin",
@ -804,5 +803,9 @@
"窗口特效": "Efekty okien", "窗口特效": "Efekty okien",
"实时编辑": "Edycja w czasie rzeczywistym", "实时编辑": "Edycja w czasie rzeczywistym",
"翻译记录": "Zapisy tłumaczeń", "翻译记录": "Zapisy tłumaczeń",
"遍历目录中的全部词典文件": "Przejrzyj wszystkie pliki słownika w katalogu" "遍历目录中的全部词典文件": "Przejrzyj wszystkie pliki słownika w katalogu",
"网络请求": "Żądanie sieci",
"网页显示": "Wyświetlanie strony internetowej",
"显示时间": "Czas wyświetlania",
"不显示时间": "Nie wyświetlaj czasu"
} }

View File

@ -620,7 +620,6 @@
"过长惩罚": "Слишком длительное наказание", "过长惩罚": "Слишком длительное наказание",
"重复惩罚": "Повторное наказание", "重复惩罚": "Повторное наказание",
"OCR语言包": "Языковый пакет OCR", "OCR语言包": "Языковый пакет OCR",
"选择翻译源": "Выберите источник перевода",
"最长显示字数": "Максимальное количество слов", "最长显示字数": "Максимальное количество слов",
"显示日语注音": "Показать японское произношение", "显示日语注音": "Показать японское произношение",
"注音颜色": "Цвет звука", "注音颜色": "Цвет звука",
@ -804,5 +803,9 @@
"窗口特效": "Специальные эффекты окон", "窗口特效": "Специальные эффекты окон",
"实时编辑": "Редактирование в реальном времени", "实时编辑": "Редактирование в реальном времени",
"翻译记录": "Перевод записей", "翻译记录": "Перевод записей",
"遍历目录中的全部词典文件": "Все словарные файлы в каталоге" "遍历目录中的全部词典文件": "Все словарные файлы в каталоге",
"网络请求": "Сетевой запрос",
"网页显示": "Показать страницу",
"显示时间": "Показать время",
"不显示时间": "Не показывать время"
} }

View File

@ -620,7 +620,6 @@
"过长惩罚": "การลงโทษที่ยาวนานเกินไป", "过长惩罚": "การลงโทษที่ยาวนานเกินไป",
"重复惩罚": "การลงโทษซ้ำ", "重复惩罚": "การลงโทษซ้ำ",
"OCR语言包": "แพคภาษา OCR", "OCR语言包": "แพคภาษา OCR",
"选择翻译源": "เลือกแหล่งที่มาของการแปล",
"最长显示字数": "แสดงจำนวนคำที่ยาวที่สุด", "最长显示字数": "แสดงจำนวนคำที่ยาวที่สุด",
"显示日语注音": "แสดงหมายเหตุภาษาญี่ปุ่น", "显示日语注音": "แสดงหมายเหตุภาษาญี่ปุ่น",
"注音颜色": "สี Injection", "注音颜色": "สี Injection",
@ -804,5 +803,9 @@
"窗口特效": "เทคนิคพิเศษของหน้าต่าง", "窗口特效": "เทคนิคพิเศษของหน้าต่าง",
"实时编辑": "แก้ไขแบบเรียลไทม์", "实时编辑": "แก้ไขแบบเรียลไทม์",
"翻译记录": "บันทึกการแปล", "翻译记录": "บันทึกการแปล",
"遍历目录中的全部词典文件": "ผ่านไฟล์พจนานุกรมทั้งหมดในไดเรกทอรี" "遍历目录中的全部词典文件": "ผ่านไฟล์พจนานุกรมทั้งหมดในไดเรกทอรี",
"网络请求": "คำขอเครือข่าย",
"网页显示": "แสดงหน้าเว็บ",
"显示时间": "แสดงเวลา",
"不显示时间": "ไม่แสดงเวลา"
} }

View File

@ -620,7 +620,6 @@
"过长惩罚": "Çok fazla ceza", "过长惩罚": "Çok fazla ceza",
"重复惩罚": "Tekrar cezalandırıcı", "重复惩罚": "Tekrar cezalandırıcı",
"OCR语言包": "OCR Language Pack", "OCR语言包": "OCR Language Pack",
"选择翻译源": "Çeviri Kaynağını Seç",
"最长显示字数": "Gösterilen sözlerin en yüksek sayısı", "最长显示字数": "Gösterilen sözlerin en yüksek sayısı",
"显示日语注音": "Display Japanese Pinyin", "显示日语注音": "Display Japanese Pinyin",
"注音颜色": "Pinyin rengi", "注音颜色": "Pinyin rengi",
@ -804,5 +803,9 @@
"窗口特效": "Pencere etkileri", "窗口特效": "Pencere etkileri",
"实时编辑": "Gerçek zamanlı düzenleme", "实时编辑": "Gerçek zamanlı düzenleme",
"翻译记录": "Çeviri kayıtları", "翻译记录": "Çeviri kayıtları",
"遍历目录中的全部词典文件": "Dizindeki bütün sözlük dosyalarını yolla" "遍历目录中的全部词典文件": "Dizindeki bütün sözlük dosyalarını yolla",
"网络请求": "Network request",
"网页显示": "Web sayfası gösterisi",
"显示时间": "Display time",
"不显示时间": "Zamanı gösterme"
} }

View File

@ -620,7 +620,6 @@
"过长惩罚": "Великий покарання", "过长惩罚": "Великий покарання",
"重复惩罚": "Повторює покарання", "重复惩罚": "Повторює покарання",
"OCR语言包": "Пакет мови OCR", "OCR语言包": "Пакет мови OCR",
"选择翻译源": "Виберіть джерело перекладу",
"最长显示字数": "Максимальна кількість показаних слів", "最长显示字数": "Максимальна кількість показаних слів",
"显示日语注音": "Показувати японський пінін", "显示日语注音": "Показувати японський пінін",
"注音颜色": "Колір пініна", "注音颜色": "Колір пініна",
@ -804,5 +803,9 @@
"窗口特效": "Ефекти вікна", "窗口特效": "Ефекти вікна",
"实时编辑": "Редагування реального часу", "实时编辑": "Редагування реального часу",
"翻译记录": "Записи перекладів", "翻译记录": "Записи перекладів",
"遍历目录中的全部词典文件": "Пересунути всі файли словника у каталозі" "遍历目录中的全部词典文件": "Пересунути всі файли словника у каталозі",
"网络请求": "Запит на мережу",
"网页显示": "Показ веб- сторінок",
"显示时间": "Час показу",
"不显示时间": "Не показувати час"
} }

View File

@ -620,7 +620,6 @@
"过长惩罚": "Hình phạt quá dài", "过长惩罚": "Hình phạt quá dài",
"重复惩罚": "Hình phạt lặp lại", "重复惩罚": "Hình phạt lặp lại",
"OCR语言包": "Gói ngôn ngữ OCR", "OCR语言包": "Gói ngôn ngữ OCR",
"选择翻译源": "Chọn nguồn dịch",
"最长显示字数": "Hiển thị tối đa số từ", "最长显示字数": "Hiển thị tối đa số từ",
"显示日语注音": "Hiện chú thích tiếng Nhật", "显示日语注音": "Hiện chú thích tiếng Nhật",
"注音颜色": "Màu chú thích", "注音颜色": "Màu chú thích",
@ -804,5 +803,9 @@
"窗口特效": "Hiệu ứng cửa sổ", "窗口特效": "Hiệu ứng cửa sổ",
"实时编辑": "Chỉnh sửa thời gian thực", "实时编辑": "Chỉnh sửa thời gian thực",
"翻译记录": "Bản dịch", "翻译记录": "Bản dịch",
"遍历目录中的全部词典文件": "Đi qua tất cả các tập tin từ điển trong thư mục" "遍历目录中的全部词典文件": "Đi qua tất cả các tập tin từ điển trong thư mục",
"网络请求": "Yêu cầu mạng",
"网页显示": "Hiển thị trang web",
"显示时间": "Thời gian hiển thị",
"不显示时间": "Không hiển thị thời gian"
} }

View File

@ -619,7 +619,6 @@
"过长惩罚": "", "过长惩罚": "",
"重复惩罚": "", "重复惩罚": "",
"OCR语言包": "", "OCR语言包": "",
"选择翻译源": "",
"最长显示字数": "", "最长显示字数": "",
"显示日语注音": "", "显示日语注音": "",
"注音颜色": "", "注音颜色": "",
@ -804,5 +803,9 @@
"窗口特效": "", "窗口特效": "",
"实时编辑": "", "实时编辑": "",
"翻译记录": "", "翻译记录": "",
"遍历目录中的全部词典文件": "" "遍历目录中的全部词典文件": "",
"网络请求": "",
"网页显示": "",
"显示时间": "",
"不显示时间": ""
} }

View File

@ -28,8 +28,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/version)
include(generate_product_version) include(generate_product_version)
set(VERSION_MAJOR 3) set(VERSION_MAJOR 3)
set(VERSION_MINOR 0) set(VERSION_MINOR 1)
set(VERSION_PATCH 6) set(VERSION_PATCH 0)
add_library(pch pch.cpp) add_library(pch pch.cpp)
target_precompile_headers(pch PUBLIC pch.h) target_precompile_headers(pch PUBLIC pch.h)