This commit is contained in:
恍兮惚兮 2024-05-28 18:28:05 +08:00
parent 278a8a944d
commit 1091508dab
40 changed files with 517 additions and 513 deletions

View File

@ -3,6 +3,7 @@ import os, threading
from traceback import print_exc
from myutils.config import (
globalconfig,
_TR,
savehook_new_list,
savehook_new_data,
setlanguage,
@ -18,7 +19,7 @@ from myutils.utils import (
getpostfile,
stringfyerror,
)
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QApplication, QMenu, QAction, QFrame
from PyQt5.QtCore import Qt, QObject, QEvent
from myutils.wrapper import threader
from gui.showword import searchwordW
@ -32,7 +33,7 @@ from gui.languageset import languageset
import zhconv, functools
import gui.transhist
import gui.edittext
import importlib
import importlib, qtawesome
from functools import partial
from gui.settin import Settin
from gui.showocrimage import showocrimage
@ -40,7 +41,7 @@ from gui.attachprocessdialog import AttachProcessDialog
import windows
import gobject
import winsharedutils
from winsharedutils import pid_running
from winsharedutils import pid_running, isDark
from myutils.post import POSTSOLVE
@ -108,7 +109,7 @@ class MAINUI:
context = None
try:
if method["object"].using:
if 'process_before' in dir(method["object"]):
if "process_before" in dir(method["object"]):
content, context = method["object"].process_before(content)
except:
print_exc()
@ -121,7 +122,7 @@ class MAINUI:
context = mp[i]
try:
if method["object"].using:
if 'process_after' in dir(method["object"]):
if "process_after" in dir(method["object"]):
res = method["object"].process_after(res, context)
except:
print_exc()
@ -720,6 +721,13 @@ class MAINUI:
time.sleep(0.5)
def setdarktheme(self, widget, dark):
if widget.testAttribute(Qt.WA_TranslucentBackground):
return
winsharedutils.SetTheme(
int(widget.winId()), dark, globalconfig["WindowBackdrop"]
)
def aa(self):
class WindowEventFilter(QObject):
def eventFilter(_, obj, event):
@ -727,18 +735,12 @@ class MAINUI:
hwnd = obj.winId()
if hwnd: # window create/destroy,when destroy winId is None
if (
self.currentisdark is not None
and obj.testAttribute(Qt.WA_TranslucentBackground) == False
):
winsharedutils.SetTheme(
int(obj.winId()),
self.currentisdark,
globalconfig["WindowBackdrop"],
)
if self.currentisdark is not None:
self.setdarktheme(obj, self.currentisdark)
windows.SetProp(
int(obj.winId()), "Magpie.ToolWindow", windows.HANDLE(1)
)
self.setshowintab_checked(obj)
return False
self.currentisdark = None
@ -789,14 +791,101 @@ class MAINUI:
except:
print_exc()
def mainuiloadafter(self):
def setshowintab_checked(self, widget):
if widget == self.translation_ui:
winsharedutils.showintab(int(widget.winId()), globalconfig["showintab"])
return
window_flags = widget.windowFlags()
if Qt.FramelessWindowHint & window_flags == Qt.FramelessWindowHint:
return
if isinstance(widget, QMenu):
return
if isinstance(widget, QFrame):
return
winsharedutils.showintab(int(widget.winId()), globalconfig["showintab_sub"])
def inittray(self):
trayMenu = QMenu(self.settin_ui)
showAction = QAction(
_TR("&显示"),
trayMenu,
triggered=self.translation_ui.show_,
)
settingAction = QAction(
qtawesome.icon("fa.gear"),
_TR("&设置"),
trayMenu,
triggered=lambda: self.settin_ui.showsignal.emit(),
)
quitAction = QAction(
qtawesome.icon("fa.times"),
_TR("&退出"),
trayMenu,
triggered=self.translation_ui.close,
)
trayMenu.addAction(showAction)
trayMenu.addAction(settingAction)
trayMenu.addSeparator()
trayMenu.addAction(quitAction)
self.translation_ui.tray.setContextMenu(trayMenu)
def setshowintab(self):
for widget in QApplication.topLevelWidgets():
self.setshowintab_checked(widget)
def setcommonstylesheet(self):
dl = globalconfig["darklight"]
if dl == 0:
dark = False
elif dl == 1:
dark = True
elif dl == 2:
dark = isDark()
darklight = ["light", "dark"][dark]
self.currentisdark = dark
for widget in QApplication.topLevelWidgets():
self.setdarktheme(widget, dark)
style = ""
for _ in (0,):
try:
idx = globalconfig[darklight + "theme"] - int(not dark)
if idx == -1:
break
_fn = static_data["themes"][darklight][idx]["file"]
if _fn.endswith(".py"):
style = importlib.import_module(
"files.themes." + _fn[:-3]
).stylesheet()
elif _fn.endswith(".qss"):
with open(
"./files/themes/{}".format(_fn),
"r",
) as ff:
style = ff.read()
except:
print_exc()
style += (
"*{font: %spt '" % (globalconfig["settingfontsize"])
+ (globalconfig["settingfonttype"])
+ "' ; }"
)
self.settin_ui.setStyleSheet(style)
def mainuiloadafter(self):
self.setshowintab()
self.safeloadprocessmodels()
self.prepare()
self.startxiaoxueguan()
self.starthira()
self.startoutputer()
self.settin_ui = Settin(self.translation_ui)
self.inittray()
self.setcommonstylesheet()
self.transhis = gui.transhist.transhist(self.settin_ui)
self.startreader()

View File

@ -1,4 +1,4 @@
from PyQt5.QtWidgets import QPushButton, QVBoxLayout, QFileDialog
from PyQt5.QtWidgets import QPushButton, QFileDialog
from PyQt5.QtWidgets import QHBoxLayout, QVBoxLayout, QTextEdit, QWidget
from PyQt5.QtGui import QTextCursor
@ -6,7 +6,6 @@ from PyQt5.QtCore import Qt
from myutils.config import _TR, globalconfig
from gui.usefulwidget import saveposwindow
from myutils.wrapper import Singleton_close
from winsharedutils import showintab
import os
@ -32,8 +31,6 @@ class dialog_memory(saveposwindow):
key="memorydialoggeo",
)
self.setWindowTitle(_TR("备忘录"))
if globalconfig["showintab_sub"]:
showintab(int(self.winId()), True)
self.gamemd5 = gamemd5
formLayout = QVBoxLayout() #
self.showtext = QTextEdit()

View File

@ -1,4 +1,4 @@
import functools, time
import time
from datetime import datetime, timedelta
from gui.specialwidget import ScrollFlow, chartwidget, lazyscrollflow
from PyQt5.QtWidgets import (
@ -10,20 +10,11 @@ from PyQt5.QtWidgets import (
QLineEdit,
QComboBox,
QFormLayout,
)
import functools, threading
from traceback import print_exc
from PyQt5.QtWidgets import (
QHBoxLayout,
QTableView,
QAbstractItemView,
QLabel,
QTabWidget,
)
import windows
from PyQt5.QtCore import QRect, QSize, Qt, pyqtSignal, QObject
import os
from PyQt5.QtWidgets import (
QApplication,
QSizePolicy,
QWidget,
@ -31,6 +22,11 @@ from PyQt5.QtWidgets import (
QAction,
QTabBar,
)
import functools, threading
from traceback import print_exc
import windows
from PyQt5.QtCore import QRect, QSize, Qt, pyqtSignal, QObject
import os
from PyQt5.QtGui import (
QCloseEvent,
QIntValidator,
@ -38,8 +34,9 @@ from PyQt5.QtGui import (
QPixmap,
QPainter,
QPen,
QStandardItem,
QStandardItemModel,
)
from PyQt5.QtCore import Qt
from gui.usefulwidget import (
getsimplecombobox,
getspinbox,
@ -48,11 +45,7 @@ from gui.usefulwidget import (
getspinbox,
selectcolor,
)
from PyQt5.QtCore import QRect, QSize, Qt, pyqtSignal
import os
from winsharedutils import showintab
from PyQt5.QtGui import QStandardItem, QStandardItemModel
from PyQt5.QtCore import Qt, QSize
from myutils.config import savehook_new_list, savehook_new_data, vndbtagdata
from myutils.hwnd import getExeIcon
import gobject
@ -1462,6 +1455,7 @@ class dialog_savedgame_new(saveposwindow):
if path.lower().endswith(".exe") == False:
continue
if path not in savehook_new_list:
checkifnewgame(path)
self.newline(path, True)
def clicked3(self):
@ -1472,6 +1466,7 @@ class dialog_savedgame_new(saveposwindow):
if res != "":
res = res.replace("/", "\\")
if res not in savehook_new_list:
checkifnewgame(res)
self.newline(res, True)
def tagschanged(self, tags):
@ -1568,8 +1563,6 @@ class dialog_savedgame_new(saveposwindow):
global _global_dialog_savedgame_new
_global_dialog_savedgame_new = self
self.setWindowTitle(_TR("游戏管理"))
if globalconfig["showintab_sub"]:
showintab(int(self.winId()), True)
formLayout = QVBoxLayout()
layout = QHBoxLayout()
@ -1728,7 +1721,6 @@ class dialog_savedgame_new(saveposwindow):
return gameitem
def newline(self, k, first=False):
checkifnewgame(k)
itemw = globalconfig["dialog_savegame_layout"]["itemw"]
itemh = globalconfig["dialog_savegame_layout"]["itemh"]

View File

@ -1,4 +1,4 @@
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QCursor
from PyQt5.QtWidgets import (
QPlainTextEdit,
QAction,
@ -90,7 +90,7 @@ class edittext(closeashidewindow):
menu = QMenu(self.textOutput)
qingkong = QAction(_TR("清空"))
menu.addAction(qingkong)
action = menu.exec(self.mapToGlobal(self.textOutput.pos()) + point)
action = menu.exec(QCursor.pos())
if action == qingkong:
self.textOutput.clear()

View File

@ -1,16 +1,12 @@
from PyQt5.QtWidgets import (
QMenu,
QApplication,
QMainWindow,
QLabel,
QAction,
QDialog,
QDesktopWidget,
)
from PyQt5.QtGui import QPainter, QPen, QColor, QResizeEvent
from PyQt5.QtCore import Qt, QPoint, QRect, QEvent
from PyQt5.QtGui import QPainter, QPen, QColor, QCursor
from PyQt5.QtCore import Qt, QPoint, QRect
from myutils.config import _TR
import gobject
from myutils.config import globalconfig
from gui.resizeablemainwindow import Mainw
import windows, winsharedutils
@ -38,7 +34,7 @@ class rangeadjust(Mainw):
menu = QMenu(self)
close = QAction(_TR("关闭"))
menu.addAction(close)
action = menu.exec(self.mapToGlobal(p))
action = menu.exec(QCursor.pos())
if action == close:
self._rect = None
self.close()

View File

@ -716,6 +716,9 @@ class hookselect(closeashidewindow):
self.changeprocessclear()
def showmenu(self, p: QPoint):
r = self.tttable.currentIndex().row()
if r < 0:
return
menu = QMenu(self.tttable)
remove = QAction(_TR("移除"))
copy = QAction(_TR("复制特殊码"))
@ -723,9 +726,6 @@ class hookselect(closeashidewindow):
menu.addAction(copy)
action = menu.exec(self.tttable.cursor().pos())
r = self.tttable.currentIndex().row()
if r < 0:
return
hc, hn, tp = self.save[r]
if action == remove:
pid = tp.processId

View File

@ -1,26 +1,18 @@
from PyQt5.QtCore import pyqtSignal, Qt, QSize, QObject, QEvent
from PyQt5.QtCore import pyqtSignal, Qt, QSize
from PyQt5.QtWidgets import (
QLabel,
QScrollArea,
QWidget,
QGridLayout,
QVBoxLayout,
QListWidget,
QHBoxLayout,
QListWidgetItem,
QMenu,
QAction,
QApplication,
)
from PyQt5.QtGui import QResizeEvent, QFont, QFontMetrics
from PyQt5.QtGui import QFont, QFontMetrics
from PyQt5.QtWidgets import QTabWidget
import qtawesome, gobject, importlib, sys
import functools, threading, windows, winsharedutils
from traceback import print_exc
from winsharedutils import isDark
import qtawesome, gobject
import threading, windows, winsharedutils
from myutils.config import globalconfig, _TR
from myutils.utils import wavmp3player
from myutils.config import static_data
from gui.settingpage1 import setTabOne, setTabOne_direct
from gui.settingpage2 import setTabTwo, settab2d
from gui.settingpage_xianshishezhi import setTabThree, setTabThree_direct
@ -31,11 +23,7 @@ from gui.setting_lang import setTablang, setTablangd
from gui.setting_proxy import setTab_proxy
from gui.settingpage7 import setTab7, settab7direct
from gui.settingpage_about import setTab_about, setTab_about_dicrect
from gui.usefulwidget import closeashidewindow, tabadd_lazy
class gridwidget(QWidget):
pass
from gui.usefulwidget import closeashidewindow, makesubtab_lazy
class TabWidget(QWidget):
@ -89,60 +77,7 @@ class Settin(closeashidewindow):
showandsolvesig = pyqtSignal(str)
setstylesheetsignal = pyqtSignal()
def resizefunction(self):
ww = self.size().width() - self.list_width - 30
for w in self.needfitwidgets:
w.setFixedWidth(int(ww))
for grid, maxl in self.needfitcols:
for c in range(maxl):
grid.setColumnMinimumWidth(
c,
int(ww / maxl),
)
def resizeEvent(self, a0: QResizeEvent) -> None:
self.resizefunction()
return super().resizeEvent(a0)
def automakegrid(self, grid, lis, save=False, savelist=None):
maxl = 0
for nowr, line in enumerate(lis):
nowc = 0
if save:
ll = []
for i in line:
if type(i) == str:
cols = 1
wid = QLabel(_TR(i))
elif type(i) != tuple:
wid, cols = i, 1
elif len(i) == 2:
wid, cols = i
if type(wid) == str:
wid = QLabel(_TR(wid))
elif len(i) == 3:
wid, cols, arg = i
if type(wid) == str:
wid = QLabel((wid))
if arg == "link":
wid.setOpenExternalLinks(True)
grid.addWidget(wid, nowr, nowc, 1, cols)
if save:
ll.append(wid)
nowc += cols
maxl = max(maxl, nowc)
if save:
savelist.append(ll)
grid.setRowMinimumHeight(nowr, 35)
self.needfitcols.append([grid, maxl])
def __init__(self, parent):
self.needfitwidgets = []
self.needfitcols = []
super(Settin, self).__init__(parent, globalconfig, "setting_geo_2")
# self.setWindowFlag(Qt.Tool,False)
# self.setWindowFlags(self.windowFlags()&~Qt.WindowMinimizeButtonHint)
@ -158,7 +93,6 @@ class Settin(closeashidewindow):
self.hooks = []
self.usevoice = 0
self.inittray()
setTabOne_direct(self)
settab2d(self)
settab7direct(self)
@ -168,14 +102,13 @@ class Settin(closeashidewindow):
setTablangd(self)
setTab_about_dicrect(self)
self.setstylesheet()
self.setstylesheetsignal.connect(self.setstylesheet)
self.setstylesheetsignal.connect(gobject.baseobject.setcommonstylesheet)
threading.Thread(target=self.darklistener).start()
self.setWindowTitle(_TR("设置"))
self.setWindowIcon(qtawesome.icon("fa.gear"))
self.tab_widget = self.makesubtab_lazy(klass=TabWidget)
self.tab_widget = makesubtab_lazy(klass=TabWidget)
self.setCentralWidget(self.tab_widget)
self.tab_widget.setStyleSheet(
@ -209,28 +142,6 @@ class Settin(closeashidewindow):
self.tab_widget.list_widget.setFixedWidth(width)
self.list_width = width
def inittray(self):
showAction = QAction(
_TR("&显示"),
self,
triggered=gobject.baseobject.translation_ui.show_,
)
settingAction = QAction(
_TR("&设置"),
self,
triggered=lambda: gobject.baseobject.settin_ui.showsignal.emit(),
)
quitAction = QAction(
_TR("&退出"), self, triggered=gobject.baseobject.translation_ui.close
)
self.trayMenu = QMenu(self)
self.trayMenu.addAction(showAction)
self.trayMenu.addAction(settingAction)
self.trayMenu.addSeparator()
self.trayMenu.addAction(quitAction)
gobject.baseobject.translation_ui.tray.setContextMenu(self.trayMenu)
def opensolvetextfun(self):
self.show()
self.tab_widget.setCurrentIndex(3)
@ -243,114 +154,3 @@ class Settin(closeashidewindow):
if globalconfig["darklight"] == 2:
self.setstylesheetsignal.emit()
windows.WaitForSingleObject(sema, windows.INFINITE)
def setstylesheet(self):
dl = globalconfig["darklight"]
if dl == 0:
dark = False
elif dl == 1:
dark = True
elif dl == 2:
dark = isDark()
darklight = ["light", "dark"][dark]
gobject.baseobject.currentisdark = dark
for widget in QApplication.topLevelWidgets():
if widget.testAttribute(Qt.WA_TranslucentBackground):
continue
winsharedutils.SetTheme(
int(widget.winId()), dark, globalconfig["WindowBackdrop"]
)
style = ""
for _ in (0,):
try:
idx = globalconfig[darklight + "theme"] - int(not dark)
if idx == -1:
break
_fn = static_data["themes"][darklight][idx]["file"]
if _fn.endswith(".py"):
style = importlib.import_module(
"files.themes." + _fn[:-3]
).stylesheet()
elif _fn.endswith(".qss"):
with open(
"./files/themes/{}".format(_fn),
"r",
) as ff:
style = ff.read()
except:
print_exc()
style = ""
style += (
"*{font: %spt '" % (globalconfig["settingfontsize"])
+ (globalconfig["settingfonttype"])
+ "' ; }"
)
self.setStyleSheet(style)
def makevbox(self, wids):
q = QWidget()
v = QVBoxLayout()
q.setLayout(v)
v.setContentsMargins(0, 0, 0, 0)
for wid in wids:
v.addWidget(wid)
return q
def makegrid(self, grid, save=False, savelist=None, savelay=None):
gridlayoutwidget = gridwidget()
gridlay = QGridLayout()
gridlayoutwidget.setLayout(gridlay)
gridlayoutwidget.setStyleSheet("gridwidget{background-color:transparent;}")
self.needfitwidgets.append(gridlayoutwidget)
gridlayoutwidget.setFixedHeight(len(grid) * 35)
margins = gridlay.contentsMargins()
gridlay.setContentsMargins(margins.left(), 0, margins.right(), 0)
self.automakegrid(gridlay, grid, save, savelist)
if save:
savelay.append(gridlay)
return gridlayoutwidget
def makescroll(self, widget):
scroll = QScrollArea()
scroll.setHorizontalScrollBarPolicy(1)
scroll.setStyleSheet("""QScrollArea{background-color:transparent;border:0px}""")
self.needfitwidgets.append(widget)
scroll.setWidget(widget)
return scroll
def makesubtab(self, titles, widgets):
tab = QTabWidget()
for i, wid in enumerate(widgets):
tab.addTab(wid, _TR(titles[i]))
return tab
def makesubtab_lazy(self, titles=None, functions=None, klass=None):
if klass:
tab = klass()
else:
tab = QTabWidget()
def __(t, i):
try:
w = t.currentWidget()
if "lazyfunction" in dir(w):
w.lazyfunction()
delattr(w, "lazyfunction")
self.resizefunction()
except:
print_exc()
tab.currentChanged.connect(functools.partial(__, tab))
if titles and functions:
for i, func in enumerate(functions):
self.tabadd_lazy(tab, titles[i], func)
return tab
def tabadd_lazy(self, tab, title, getrealwidgetfunction):
tabadd_lazy(tab, title, getrealwidgetfunction)

View File

@ -1,10 +1,16 @@
import os
from myutils.config import globalconfig, _TRL, static_data,getlanguse
from gui.usefulwidget import getsimplecombobox, getcolorbutton
from myutils.config import globalconfig, _TRL, static_data, getlanguse
from gui.usefulwidget import (
getsimplecombobox,
getcolorbutton,
makegrid,
tabadd_lazy,
makescroll,
)
def setTablang(self):
self.tabadd_lazy(self.tab_widget, ("语言设置"), lambda: setTablanglz(self))
tabadd_lazy(self.tab_widget, ("语言设置"), lambda: setTablanglz(self))
def setTablangd(self):
@ -45,9 +51,7 @@ def setTablanglz(self):
globalconfig,
"",
callback=lambda: os.startfile(
os.path.abspath(
"./files/lang/{}.json".format(getlanguse())
)
os.path.abspath("./files/lang/{}.json".format(getlanguse()))
),
icon="fa.gear",
constcolor="#FF69B4",
@ -58,7 +62,7 @@ def setTablanglz(self):
[],
]
gridlayoutwidget = self.makegrid(grids)
gridlayoutwidget = self.makescroll(gridlayoutwidget)
gridlayoutwidget = makegrid(grids)
gridlayoutwidget = makescroll(gridlayoutwidget)
return gridlayoutwidget

View File

@ -2,7 +2,14 @@ from PyQt5.QtWidgets import QLineEdit, QPushButton
from myutils.config import _TR
from myutils.config import globalconfig
from myutils.utils import splittranslatortypes
from gui.usefulwidget import getsimpleswitch
from gui.usefulwidget import (
getsimpleswitch,
makegrid,
makesubtab_lazy,
tabadd_lazy,
makevbox,
makescroll,
)
import os
@ -77,18 +84,18 @@ def setTab_proxy_lazy(self):
item="ocr",
name="./Lunatranslator/ocrengines/%s.py",
)
tab = self.makesubtab_lazy(
tab = makesubtab_lazy(
["在线翻译", "注册在线翻译", "在线OCR"],
[
lambda: self.makescroll(self.makegrid(mianfei)),
lambda: self.makescroll(self.makegrid(shoufei)),
lambda: self.makescroll(self.makegrid(ocrs)),
lambda: makescroll(makegrid(mianfei)),
lambda: makescroll(makegrid(shoufei)),
lambda: makescroll(makegrid(ocrs)),
],
)
gridlayoutwidget = self.makegrid(grid1)
return self.makevbox([gridlayoutwidget, tab])
gridlayoutwidget = makegrid(grid1)
return makevbox([gridlayoutwidget, tab])
def setTab_proxy(self):
self.tabadd_lazy(self.tab_widget, ("代理设置"), lambda: setTab_proxy_lazy(self))
tabadd_lazy(self.tab_widget, ("代理设置"), lambda: setTab_proxy_lazy(self))

View File

@ -19,9 +19,14 @@ from gui.inputdialog import regexedit
from gui.usefulwidget import (
getsimplecombobox,
getspinbox,
makescroll,
getcolorbutton,
makegrid,
tabadd_lazy,
yuitsu_switch,
makevbox,
getsimpleswitch,
makesubtab_lazy,
)
from gui.codeacceptdialog import codeacceptdialog
from myutils.utils import makehtml, getfilemd5
@ -507,21 +512,21 @@ def setTabOne_direct(self):
def setTabOne(self):
self.tabadd_lazy(self.tab_widget, ("文本输入"), lambda: setTabOne_lazy(self))
tabadd_lazy(self.tab_widget, ("文本输入"), lambda: setTabOne_lazy(self))
def setTabOne_lazy(self):
tab = self.makesubtab_lazy(
tab = makesubtab_lazy(
["HOOK设置", "OCR设置", "剪贴板", "内嵌翻译", "文本输出"],
[
lambda: self.makescroll(self.makegrid(gethookgrid(self))),
lambda: self.makescroll(self.makegrid(getocrgrid(self))),
lambda: self.makescroll(self.makegrid(getTabclip(self))),
lambda: self.makescroll(self.makegrid(gethookembedgrid(self))),
lambda: self.makescroll(self.makegrid(outputgrid(self))),
lambda: makescroll(makegrid(gethookgrid(self))),
lambda: makescroll(makegrid(getocrgrid(self))),
lambda: makescroll(makegrid(getTabclip(self))),
lambda: makescroll(makegrid(gethookembedgrid(self))),
lambda: makescroll(makegrid(outputgrid(self))),
],
)
gridlayoutwidget = self.makegrid(self.tab1grids)
return self.makevbox([gridlayoutwidget, tab])
gridlayoutwidget = makegrid(self.tab1grids)
return makevbox([gridlayoutwidget, tab])

View File

@ -8,7 +8,17 @@ from myutils.config import globalconfig, _TR
from myutils.utils import selectdebugfile, splittranslatortypes, checkportavailable
import os, time, requests, threading
from gui.inputdialog import autoinitdialog, autoinitdialog_items
from gui.usefulwidget import getspinbox, getcolorbutton, getsimpleswitch, selectcolor
from gui.usefulwidget import (
getspinbox,
getcolorbutton,
getsimpleswitch,
selectcolor,
makegrid,
makesubtab_lazy,
makescroll,
makevbox,
tabadd_lazy,
)
import time, hashlib
@ -94,7 +104,7 @@ def initsome11(self, l, label=None):
def setTabTwo(self):
self.tabadd_lazy(self.tab_widget, ("翻译设置"), lambda: setTabTwo_lazy(self))
tabadd_lazy(self.tab_widget, ("翻译设置"), lambda: setTabTwo_lazy(self))
def settab2d(self):
@ -245,16 +255,16 @@ def setTabTwo_lazy(self):
developgrid += initsome11(self, develop)
online_reg_grid += initsome11(self, shoufei)
pretransgrid += initsome11(self, pre)
tab = self.makesubtab_lazy(
tab = makesubtab_lazy(
["在线翻译", "develop", "注册在线翻译", "离线翻译", "预翻译"],
[
lambda: self.makescroll(self.makegrid(onlinegrid)),
lambda: self.makescroll(self.makegrid(developgrid)),
lambda: self.makescroll(self.makegrid(online_reg_grid)),
lambda: self.makescroll(self.makegrid(offlinegrid)),
lambda: self.makescroll(self.makegrid(pretransgrid)),
lambda: makescroll(makegrid(onlinegrid)),
lambda: makescroll(makegrid(developgrid)),
lambda: makescroll(makegrid(online_reg_grid)),
lambda: makescroll(makegrid(offlinegrid)),
lambda: makescroll(makegrid(pretransgrid)),
],
)
gridlayoutwidget = self.makegrid(grids)
return self.makevbox([gridlayoutwidget, tab])
gridlayoutwidget = makegrid(grids)
return makevbox([gridlayoutwidget, tab])

View File

@ -17,7 +17,15 @@ from myutils.config import (
_TR,
)
import functools, gobject
from gui.usefulwidget import getcolorbutton, getsimpleswitch
from gui.usefulwidget import (
getcolorbutton,
getsimpleswitch,
makevbox,
makescroll,
makegrid,
makesubtab_lazy,
tabadd_lazy,
)
from gui.codeacceptdialog import codeacceptdialog
from gui.inputdialog import (
postconfigdialog,
@ -73,7 +81,7 @@ def settab7direct(self):
def setTab7(self):
self.tabadd_lazy(self.tab_widget, ("文本处理"), lambda: setTab7_lazy(self))
tabadd_lazy(self.tab_widget, ("文本处理"), lambda: setTab7_lazy(self))
def getcomparelayout(self):
@ -229,9 +237,10 @@ def setTab7_lazy(self):
constcolor="#FF69B4",
)
)
grids2 += [[("", 12)]]
def __():
_w = self.makescroll(self.makegrid(grids, True, savelist, savelay))
_w = makescroll(makegrid(grids, True, savelist, savelay))
_w.setContextMenuPolicy(Qt.CustomContextMenu)
def showmenu(p: QPoint):
@ -251,9 +260,9 @@ def setTab7_lazy(self):
_w.customContextMenuRequested.connect(showmenu)
return _w
tab = self.makesubtab_lazy(
tab = makesubtab_lazy(
["文本预处理", "翻译优化"],
[lambda: __(), lambda: self.makescroll(self.makegrid(grids2))],
[lambda: __(), lambda: makescroll(makegrid(grids2))],
)
return self.makevbox([tab, self.comparelayout])
return makevbox([tab, self.comparelayout])

View File

@ -1,7 +1,14 @@
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap, QImage
from PyQt5.QtWidgets import QWidget, QLabel, QProgressBar
from gui.usefulwidget import getsimpleswitch, getsimplecombobox
from PyQt5.QtWidgets import QLabel, QProgressBar
from gui.usefulwidget import (
getsimpleswitch,
getsimplecombobox,
makegrid,
makescroll,
makesubtab_lazy,
tabadd_lazy,
)
from myutils.config import globalconfig, _TR, static_data
from myutils.wrapper import threader
import platform, winsharedutils, sys
@ -64,11 +71,11 @@ def setTab_about_dicrect(self):
def setTab_about(self):
self.tabadd_lazy(self.tab_widget, ("其他设置"), lambda: setTab_aboutlazy(self))
tabadd_lazy(self.tab_widget, ("其他设置"), lambda: setTab_aboutlazy(self))
def double_(self, grid):
return self.makescroll(self.makegrid(grid))
return makescroll(makegrid(grid))
def resourcegrid(self):
@ -98,7 +105,7 @@ def resourcegrid(self):
__ = True
grid.append([(_TR(name), 1, ""), (makehtml(link, __), 2, "link")])
makewidgetsfunctions.append(partial(double_, self, grid))
return self.makesubtab_lazy(titles, makewidgetsfunctions)
return makesubtab_lazy(titles, makewidgetsfunctions)
def setTab_aboutlazy(self):
@ -149,8 +156,19 @@ def setTab_aboutlazy(self):
(makehtml("https://qm.qq.com/q/qE32v9NYBO", show=912525396), 3, "link"),
],
[],
[("如果你感觉该软件对你有帮助,欢迎微信扫码赞助,谢谢~", 4)],
[("如果你感觉该软件对你有帮助,欢迎微信扫码赞助,谢谢~", 0)],
]
lb = QLabel(self)
img = QPixmap.fromImage(QImage("./files/zan.jpg"))
img.setDevicePixelRatio(self.devicePixelRatioF())
img = img.scaled(
600,
600,
Qt.KeepAspectRatio,
Qt.SmoothTransformation,
)
lb.setPixmap(img)
shuominggrid += [[(lb, 0)]]
else:
shuominggrid += [
[],
@ -169,41 +187,15 @@ def setTab_aboutlazy(self):
)
],
]
tab = self.makesubtab_lazy(
tab = makesubtab_lazy(
["相关说明", "其他设置", "资源下载"],
[
lambda: self.makevbox(
[
self.makegrid(shuominggrid),
(
imgwidget("./files/zan.jpg")
if globalconfig["languageuse"] == 0
else QLabel()
),
]
lambda: makescroll(
makegrid(shuominggrid),
),
lambda: self.makescroll(self.makegrid(grid2)),
lambda: makescroll(makegrid(grid2)),
lambda: resourcegrid(self),
],
)
return tab
class imgwidget(QWidget):
def __init__(self, src) -> None:
super().__init__()
self.lb = QLabel(self)
rate = self.devicePixelRatioF()
self.img = QPixmap.fromImage(QImage(src))
self.img.setDevicePixelRatio(rate)
def paintEvent(self, a0) -> None:
self.lb.resize(self.size())
self.lb.setPixmap(
self.img.scaled(
self.size() * self.devicePixelRatioF(),
Qt.KeepAspectRatio,
Qt.SmoothTransformation,
)
)
return super().paintEvent(a0)

View File

@ -4,6 +4,9 @@ from gui.inputdialog import autoinitdialog, autoinitdialog_items
from gui.usefulwidget import (
getcolorbutton,
yuitsu_switch,
makescroll,
makegrid,
tabadd_lazy,
getsimpleswitch,
getsimplecombobox,
)
@ -11,7 +14,7 @@ import gobject
def setTabcishu(self):
self.tabadd_lazy(self.tab_widget, ("辞书设置"), lambda: setTabcishu_l(self))
tabadd_lazy(self.tab_widget, ("辞书设置"), lambda: setTabcishu_l(self))
def gethiragrid(self):
@ -171,7 +174,7 @@ def setTabcishu_l(self):
(getsimpleswitch(globalconfig, "searchwordusewebview"), 1),
],
)
gridlayoutwidget = self.makegrid(grids)
gridlayoutwidget = self.makescroll(gridlayoutwidget)
gridlayoutwidget = makegrid(grids)
gridlayoutwidget = makescroll(gridlayoutwidget)
return gridlayoutwidget

View File

@ -1,11 +1,16 @@
import functools
from myutils.config import globalconfig, static_data, _TR
from myutils.config import globalconfig, _TR
from myutils.winsyshotkey import SystemHotkey, registerException
from PyQt5.QtGui import QKeySequence
import winsharedutils
import gobject, windows
from PyQt5.QtWidgets import QLabel
from gui.usefulwidget import getsimpleswitch, getsimplekeyseq
from gui.usefulwidget import (
getsimpleswitch,
getsimplekeyseq,
makegrid,
tabadd_lazy,
makescroll,
)
from myutils.hwnd import grabwindow
from myutils.utils import getimageformat, parsekeystringtomodvkcode, unsupportkey
@ -58,7 +63,7 @@ def setTab_quick_direct(self):
def setTab_quick(self):
self.tabadd_lazy(self.tab_widget, ("快捷按键"), lambda: setTab_quick_lazy(self))
tabadd_lazy(self.tab_widget, ("快捷按键"), lambda: setTab_quick_lazy(self))
def setTab_quick_lazy(self):
@ -97,8 +102,8 @@ def setTab_quick_lazy(self):
(self.referlabels[name], 4),
]
)
gridlayoutwidget = self.makegrid(grids)
gridlayoutwidget = self.makescroll(gridlayoutwidget)
gridlayoutwidget = makegrid(grids)
gridlayoutwidget = makescroll(gridlayoutwidget)
return gridlayoutwidget
# self.yitiaolong("快捷按键",grids)

View File

@ -8,7 +8,10 @@ import gobject
from gui.usefulwidget import (
getsimplecombobox,
getspinbox,
makegrid,
makescroll,
getcolorbutton,
tabadd_lazy,
yuitsu_switch,
getsimpleswitch,
)
@ -21,7 +24,7 @@ def setTab5_direct(self):
def setTab5(self):
self.tabadd_lazy(self.tab_widget, ("语音合成"), lambda: setTab5lz(self))
tabadd_lazy(self.tab_widget, ("语音合成"), lambda: setTab5lz(self))
def getttsgrid(self):
@ -147,8 +150,8 @@ def setTab5lz(self):
),
],
]
gridlayoutwidget = self.makegrid(grids)
gridlayoutwidget = self.makescroll(gridlayoutwidget)
gridlayoutwidget = makegrid(grids)
gridlayoutwidget = makescroll(gridlayoutwidget)
return gridlayoutwidget

View File

@ -1,10 +1,9 @@
import functools
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QTableView, QAbstractItemView, QLabel, QVBoxLayout
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QHeaderView
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtWidgets import QTableView, QAbstractItemView
from PyQt5.QtWidgets import QHeaderView
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QStandardItem, QStandardItemModel
from PyQt5.QtWidgets import QLabel, QSlider, QFontComboBox, QDialog, QGridLayout
@ -16,8 +15,13 @@ from winsharedutils import showintab
from gui.inputdialog import getsomepath1
from gui.usefulwidget import (
getsimplecombobox,
makegrid,
getspinbox,
tabadd_lazy,
makescroll,
makevbox,
getcolorbutton,
makesubtab_lazy,
getsimpleswitch,
selectcolor,
)
@ -51,110 +55,74 @@ def setTabThree_direct(self):
def setTabThree(self):
self.tabadd_lazy(self.tab_widget, ("显示设置"), lambda: setTabThree_lazy(self))
tabadd_lazy(self.tab_widget, ("显示设置"), lambda: setTabThree_lazy(self))
def createbuttonwidget(self):
# return table
grids = [["显示", "", "", "对齐", "图标", "图标2", "说明"]]
sortlist = globalconfig["toolbutton"]["rank2"]
savelist = []
savelay = []
model = QStandardItemModel()
model.setHorizontalHeaderLabels(
_TRL(["显示", "", "", "对齐", "图标", "图标2", "说明"])
)
def changerank(item, up):
table = QTableView()
table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
table.horizontalHeader().setStretchLastSection(True)
table.setEditTriggers(QAbstractItemView.NoEditTriggers)
table.setSelectionBehavior(QAbstractItemView.SelectRows)
table.setSelectionMode((QAbstractItemView.SingleSelection))
table.setWordWrap(False)
table.setModel(model)
def changerank2(key, up):
idx = globalconfig["toolbutton"]["rank2"].index(key)
idx = sortlist.index(item)
idx2 = idx + (-1 if up else 1)
if idx2 < 0 or idx2 >= len(globalconfig["toolbutton"]["rank2"]):
if idx2 < 0 or idx2 >= len(sortlist):
return
headoffset = 1
idx2 = idx + (-1 if up else 1)
(
globalconfig["toolbutton"]["rank2"][idx],
globalconfig["toolbutton"]["rank2"][idx2],
) = (
globalconfig["toolbutton"]["rank2"][idx2],
globalconfig["toolbutton"]["rank2"][idx],
)
sortlist[idx], sortlist[idx2] = sortlist[idx2], sortlist[idx]
for i, ww in enumerate(savelist[idx + headoffset]):
model.removeRow(idx2)
newline(idx, globalconfig["toolbutton"]["rank2"][idx]),
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],
)
gobject.baseobject.translation_ui.adjustbuttons()
def newline(row, k):
if "belong" in globalconfig["toolbutton"]["buttons"][k]:
belong = (
"("
+ _TR("")
+ " ".join(globalconfig["toolbutton"]["buttons"][k]["belong"])
+ ")"
)
else:
belong = ""
model.insertRow(
row,
[
QStandardItem(),
QStandardItem(),
QStandardItem(),
QStandardItem(),
QStandardItem(),
QStandardItem(),
QStandardItem(
_TR(globalconfig["toolbutton"]["buttons"][k]["tip"]) + " " + belong
),
],
)
table.setIndexWidget(
model.index(row, 0),
getsimpleswitch(
globalconfig["toolbutton"]["buttons"][k],
"use",
callback=lambda _: gobject.baseobject.translation_ui.adjustbuttons(),
),
)
for i, k in enumerate(sortlist):
button_up = getcolorbutton(
globalconfig,
"",
callback=functools.partial(changerank2, k, True),
callback=functools.partial(changerank, k, True),
icon="fa.arrow-up",
constcolor="#FF69B4",
)
button_down = getcolorbutton(
globalconfig,
"",
callback=functools.partial(changerank2, k, False),
callback=functools.partial(changerank, k, False),
icon="fa.arrow-down",
constcolor="#FF69B4",
)
table.setIndexWidget(
model.index(row, 1),
button_up,
)
table.setIndexWidget(
model.index(row, 2),
button_down,
)
table.setIndexWidget(
model.index(row, 3),
l = [
getsimpleswitch(
globalconfig["toolbutton"]["buttons"][k],
"use",
callback=lambda _: gobject.baseobject.translation_ui.adjustbuttons(),
),
button_up,
button_down,
getsimplecombobox(
_TRL(["居左", "居右", "居中"]),
globalconfig["toolbutton"]["buttons"][k],
"align",
callback=lambda _: gobject.baseobject.translation_ui.adjustbuttons(),
fixedsize=True,
),
)
table.setIndexWidget(
model.index(row, 4),
getcolorbutton(
"",
"",
@ -166,10 +134,9 @@ def createbuttonwidget(self):
color=globalconfig["buttoncolor"],
),
),
)
]
if "icon2" in globalconfig["toolbutton"]["buttons"][k]:
table.setIndexWidget(
model.index(row, 5),
l.append(
getcolorbutton(
"",
"",
@ -182,11 +149,20 @@ def createbuttonwidget(self):
),
),
)
for row, k in enumerate(globalconfig["toolbutton"]["rank2"]):
newline(row, k)
return table
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)
return makescroll(makegrid(grids, True, savelist, savelay))
@Singleton
@ -268,7 +244,7 @@ def setTabThree_lazy(self):
def callback(x):
globalconfig.__setitem__("settingfonttype", x)
self.setstylesheet()
gobject.baseobject.setcommonstylesheet()
self.sfont_comboBox.activated[str].connect(callback)
self.sfont_comboBox.setCurrentFont(QFont(globalconfig["settingfonttype"]))
@ -437,14 +413,6 @@ def setTabThree_lazy(self):
],
]
def __changefontsize(x):
self.setstylesheet()
self.resizefunction()
def __changeshowintab(x):
gobject.baseobject.translation_ui.showintab = x
showintab(int(gobject.baseobject.translation_ui.winId()), x)
def themelist(t):
return [_["name"] for _ in static_data["themes"][t]]
@ -474,10 +442,21 @@ def setTabThree_lazy(self):
(getspinbox(1, 100, globalconfig, "disappear_delay"), 2),
],
[
("任务栏中显示", 6),
getsimpleswitch(globalconfig, "showintab", callback=__changeshowintab),
("任务栏中显示_翻译窗口", 6),
getsimpleswitch(
globalconfig,
"showintab",
callback=lambda _: gobject.baseobject.setshowintab(),
),
],
[
("任务栏中显示_其他", 6),
getsimpleswitch(
globalconfig,
"showintab_sub",
callback=lambda _: gobject.baseobject.setshowintab(),
),
],
[("子窗口任务栏中显示", 6), getsimpleswitch(globalconfig, "showintab_sub")],
[
("选择文本窗口中文本框只读", 6),
getsimpleswitch(
@ -495,7 +474,11 @@ def setTabThree_lazy(self):
("字体大小", 4),
(
getspinbox(
1, 100, globalconfig, "settingfontsize", callback=__changefontsize
1,
100,
globalconfig,
"settingfontsize",
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
),
2,
),
@ -592,7 +575,6 @@ def setTabThree_lazy(self):
),
],
[],
[],
[
("明暗", 6),
(
@ -600,7 +582,7 @@ def setTabThree_lazy(self):
_TRL(["明亮", "黑暗", "跟随系统"]),
globalconfig,
"darklight",
callback=lambda _: self.setstylesheet(),
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
),
5,
),
@ -612,7 +594,7 @@ def setTabThree_lazy(self):
_TRL(["默认"]) + themelist("light"),
globalconfig,
"lighttheme",
callback=lambda _: self.setstylesheet(),
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
),
5,
),
@ -624,13 +606,14 @@ def setTabThree_lazy(self):
themelist("dark"),
globalconfig,
"darktheme",
callback=lambda _: self.setstylesheet(),
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
),
5,
),
],
[],
[
("WindowEffect", 6),
("窗口特效_翻译窗口", 6),
(
getsimplecombobox(
["Disable", "Acrylic", "Aero"],
@ -645,13 +628,13 @@ def setTabThree_lazy(self):
),
],
[
("WindowBackdrop", 6),
("窗口特效_其他", 6),
(
getsimplecombobox(
["Solid", "Acrylic", "Mica", "MicaAlt"],
globalconfig,
"WindowBackdrop",
callback=lambda _: self.setstylesheet(),
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
),
5,
),
@ -950,21 +933,21 @@ def setTabThree_lazy(self):
getsimpleswitch(globalconfig, "hookmagpie"),
],
]
tab = self.makesubtab_lazy(
tab = makesubtab_lazy(
["文本设置", "界面主题", "窗口行为", "工具按钮", "窗口缩放"],
[
lambda: self.makescroll(self.makegrid(textgrid)),
lambda: self.makescroll(self.makegrid(uigrid)),
lambda: self.makescroll(self.makegrid(xingweigrid)),
lambda: makescroll(makegrid(textgrid)),
lambda: makescroll(makegrid(uigrid)),
lambda: makescroll(makegrid(xingweigrid)),
lambda: createbuttonwidget(self),
lambda: self.makevbox(
lambda: makevbox(
[
self.makegrid(commonfsgrid),
self.makesubtab_lazy(
makegrid(commonfsgrid),
makesubtab_lazy(
["Magpie", "外部缩放软件"],
[
lambda: self.makescroll(self.makegrid(innermagpie)),
lambda: self.makescroll(self.makegrid(losslessgrid)),
lambda: makescroll(makegrid(innermagpie)),
lambda: makescroll(makegrid(losslessgrid)),
],
),
]

View File

@ -327,7 +327,7 @@ class lazyscrollflow(QWidget):
self.widgets = []
self.fakegeos = []
self._spacing = 6
self._margin = 9
self._margin = self._spacing # 9
self.lock = threading.Lock()
self.internalwid = QWidget(self)
self.qscrollarea = ScrollArea(self)

View File

@ -1,5 +1,6 @@
from PyQt5.QtWidgets import QPlainTextEdit, QAction, QMenu, QFileDialog
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtGui import QCursor
import qtawesome, functools, winsharedutils
from gui.usefulwidget import closeashidewindow
from myutils.config import globalconfig, _TR
@ -54,7 +55,7 @@ class transhist(closeashidewindow):
menu.addAction(hideshowraw)
menu.addAction(hideshowapi)
action = menu.exec(self.mapToGlobal(p))
action = menu.exec(QCursor.pos())
if action == qingkong:
tb.clear()
elif action == copy:

View File

@ -258,8 +258,8 @@ class QUnFrameWindow(resizableframeless):
self.translate_text.addsearchwordmask(hira, text, callback)
if globalconfig["autodisappear"]:
flag = (self.showintab and self.isMinimized()) or (
not self.showintab and self.isHidden()
flag = (globalconfig['showintab'] and self.isMinimized()) or (
not globalconfig['showintab'] and self.isHidden()
)
if flag:
@ -282,8 +282,8 @@ class QUnFrameWindow(resizableframeless):
if self._move_drag:
return
flag = (self.showintab and self.isMinimized()) or (
not self.showintab and self.isHidden()
flag = (globalconfig['showintab'] and self.isMinimized()) or (
not globalconfig['showintab'] and self.isHidden()
)
if flag:
@ -481,13 +481,13 @@ class QUnFrameWindow(resizableframeless):
)
def hide_(self):
if self.showintab:
if globalconfig['showintab']:
windows.ShowWindow(int(self.winId()), windows.SW_SHOWMINIMIZED)
else:
self.hide()
def show_(self):
if self.showintab:
if globalconfig['showintab']:
windows.ShowWindow(int(self.winId()), windows.SW_SHOWNOACTIVATE)
else:
self.show()
@ -597,11 +597,9 @@ class QUnFrameWindow(resizableframeless):
self.setWindowIcon(icon)
self.tray = QSystemTrayIcon()
self.tray.setIcon(icon)
showintab(int(self.winId()), globalconfig["showintab"])
self.isfirstshow = True
self.setAttribute(Qt.WA_TranslucentBackground)
self.setAttribute(Qt.WA_ShowWithoutActivating, True)
self.showintab = globalconfig["showintab"]
self.setWindowTitle("LunaTranslator")
self.hidesignal.connect(self.hide_)
self.lastrefreshtime = time.time()

View File

@ -4,8 +4,11 @@ from PyQt5.QtWidgets import (
QApplication,
QPushButton,
QMessageBox,
QTabWidget,
QScrollArea,
QDialog,
QLabel,
QGridLayout,
QSizePolicy,
QHBoxLayout,
QWidget,
@ -39,7 +42,7 @@ from PyQt5.QtWidgets import (
from traceback import print_exc
import qtawesome, functools, threading, time
from myutils.wrapper import Singleton
from winsharedutils import showintab, HTMLBrowser
from winsharedutils import HTMLBrowser
import windows, os, platform
@ -137,8 +140,6 @@ class closeashidewindow(saveposwindow):
super().__init__(parent, dic, key)
self.showsignal.connect(self.showfunction)
self.realshowhide.connect(self.realshowhidefunction)
if globalconfig["showintab_sub"]:
showintab(int(self.winId()), True)
def realshowhidefunction(self, show):
if show:
@ -392,13 +393,15 @@ def callbackwrap(d, k, call, _):
print_exc()
def getsimplecombobox(lst, d, k, callback=None):
def getsimplecombobox(lst, d, k, callback=None, fixedsize=False):
s = QComboBox()
s.addItems(lst)
if (k not in d) or (d[k] >= len(lst)):
d[k] = 0
s.setCurrentIndex(d[k])
s.currentIndexChanged.connect(functools.partial(callbackwrap, d, k, callback))
if fixedsize:
s.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
return s
@ -525,6 +528,10 @@ def getboxlayout(widgets, lc=QHBoxLayout, margin0=False, makewidget=False):
return cp_layout
def makevbox(wids):
return getboxlayout(wids, lc=QVBoxLayout, margin0=True, makewidget=True)
def textbrowappendandmovetoend(textOutput, sentence, addspace=True):
scrollbar = textOutput.verticalScrollBar()
atBottom = (
@ -654,6 +661,7 @@ def getsimplekeyseq(dic, key, callback=None):
key1.changeedvent.connect(functools.partial(__, dic, key, callback))
return key1
class auto_select_webview(QWidget):
on_load = pyqtSignal(str)
@ -756,3 +764,105 @@ def tabadd_lazy(tab, title, getrealwidgetfunction):
v.setContentsMargins(0, 0, 0, 0)
q.lazyfunction = lambda: v.addWidget(getrealwidgetfunction())
tab.addTab(q, _TR(title))
def automakegrid(grid: QGridLayout, lis, save=False, savelist=None):
maxl = 0
for nowr, line in enumerate(lis):
nowc = 0
for i in line:
if type(i) == str:
cols = 1
elif type(i) != tuple:
wid, cols = i, 1
elif len(i) == 2:
wid, cols = i
elif len(i) == 3:
wid, cols, arg = i
nowc += cols
maxl = max(maxl, nowc)
for nowr, line in enumerate(lis):
nowc = 0
if save:
ll = []
for i in line:
if type(i) == str:
cols = 1
wid = QLabel(_TR(i))
elif type(i) != tuple:
wid, cols = i, 1
elif len(i) == 2:
wid, cols = i
if type(wid) == str:
wid = QLabel(_TR(wid))
elif len(i) == 3:
wid, cols, arg = i
if type(wid) == str:
wid = QLabel((wid))
if arg == "link":
wid.setOpenExternalLinks(True)
if cols > 0:
col = cols
elif cols == 0:
col = maxl
else:
col = -maxl // cols
grid.addWidget(wid, nowr, nowc, 1, col)
if save:
ll.append(wid)
nowc += cols
if save:
savelist.append(ll)
grid.setRowMinimumHeight(nowr, 30)
def makegrid(grid, save=False, savelist=None, savelay=None):
class gridwidget(QWidget):
pass
gridlayoutwidget = gridwidget()
gridlay = QGridLayout()
gridlay.setAlignment(Qt.AlignTop)
gridlayoutwidget.setLayout(gridlay)
gridlayoutwidget.setStyleSheet("gridwidget{background-color:transparent;}")
automakegrid(gridlay, grid, save, savelist)
if save:
savelay.append(gridlay)
return gridlayoutwidget
def makesubtab_lazy(titles=None, functions=None, klass=None):
if klass:
tab = klass()
else:
tab = QTabWidget()
def __(t, i):
try:
w = t.currentWidget()
if "lazyfunction" in dir(w):
w.lazyfunction()
delattr(w, "lazyfunction")
except:
print_exc()
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 makescroll(widget):
scroll = QScrollArea()
# scroll.setHorizontalScrollBarPolicy(1)
scroll.setStyleSheet("""QScrollArea{background-color:transparent;border:0px}""")
scroll.setWidgetResizable(True)
scroll.setWidget(widget)
return scroll

View File

@ -71,6 +71,7 @@
"uselongtermcache": false,
"fixedheight": false,
"showintab": true,
"showintab_sub": true,
"remove_useless_hook": false,
"button_color_close": "#D32424",
"button_color_normal": "#FFFFFF",
@ -209,7 +210,6 @@
],
"searchwordusewebview": false,
"settingfonttype": "Arial",
"showintab_sub": false,
"setting_geo_2": [
100,
100,

View File

@ -15,7 +15,7 @@
},
{
"file": "dark_win11like.py",
"name": "win11like"
"name": "QTWin11"
}
],
"light": [
@ -33,7 +33,7 @@
},
{
"file": "light_win11like.py",
"name": "win11like"
"name": "QTWin11"
}
]
},

View File

@ -570,7 +570,6 @@
"过滤反复刷新的句子": "تصفية الجمل التي يتم تحديثها مرارا وتكرارا",
"选择图标": "اختيار الرموز",
"图标2": "أيقونات",
"子窗口任务栏中显示": "عرض في شريط المهام نافذة الطفل",
"刷新": "منعش",
"读取剪贴板": "قراءة الحافظة",
"进行一次OCR": "التعرف الضوئي على الحروف",
@ -802,5 +801,6 @@
"翻译窗口": "نافذة الترجمة",
"工具按钮": "أداة زر",
"界面主题": "واجهة الموضوع",
"窗口行为": "نافذة السلوك"
"窗口行为": "نافذة السلوك",
"窗口特效": "نافذة المؤثرات الخاصة"
}

View File

@ -570,7 +570,6 @@
"过滤反复刷新的句子": "過濾反復重繪的句子",
"选择图标": "選擇圖標",
"图标2": "圖標2",
"子窗口任务栏中显示": "子視窗工作列中顯示",
"刷新": "刷新",
"读取剪贴板": "讀取剪貼板",
"进行一次OCR": "進行一次OCR",
@ -802,5 +801,6 @@
"翻译窗口": "翻譯視窗",
"工具按钮": "工具按鈕",
"界面主题": "介面主題",
"窗口行为": "視窗行為"
"窗口行为": "視窗行為",
"窗口特效": "視窗特效"
}

View File

@ -570,7 +570,6 @@
"过滤反复刷新的句子": "Filter repeatedly refreshed sentences",
"选择图标": "Select icon",
"图标2": "Icon 2",
"子窗口任务栏中显示": "Display in the sub window Taskbar",
"刷新": "Refresh",
"读取剪贴板": "Read clipboard",
"进行一次OCR": "Conduct an OCR",
@ -802,5 +801,6 @@
"翻译窗口": "Translation Window",
"工具按钮": "Tool buttons",
"界面主题": "Interface Theme",
"窗口行为": "Window behavior"
"窗口行为": "Window behavior",
"窗口特效": "Window effects"
}

View File

@ -570,7 +570,6 @@
"过滤反复刷新的句子": "Filtrar oraciones actualizadas repetidamente",
"选择图标": "Seleccionar icono",
"图标2": "Icono 2",
"子窗口任务栏中显示": "Se muestra en la barra de tareas de la ventana hijo",
"刷新": "Refrescar",
"读取剪贴板": "Leer el portapapeles",
"进行一次OCR": "Realizar un OCR",
@ -802,5 +801,6 @@
"翻译窗口": "Ventana de traducción",
"工具按钮": "Botones de herramientas",
"界面主题": "Tema de la interfaz",
"窗口行为": "Comportamiento de la ventana"
"窗口行为": "Comportamiento de la ventana",
"窗口特效": "Efectos especiales de la ventana"
}

View File

@ -570,7 +570,6 @@
"过滤反复刷新的句子": "Filtrer phrases rafraîchies à plusieurs reprises",
"选择图标": "Sélectionner une icône",
"图标2": "Icône 2",
"子窗口任务栏中显示": "Affichage dans la barre des tâches de la Sous - fenêtre",
"刷新": "Rafraîchir",
"读取剪贴板": "Lire le presse - papiers",
"进行一次OCR": "Faites une ocr",
@ -802,5 +801,6 @@
"翻译窗口": "Fenêtre de traduction",
"工具按钮": "Le bouton outils",
"界面主题": "Thème de l'interface",
"窗口行为": "Comportement de la fenêtre"
"窗口行为": "Comportement de la fenêtre",
"窗口特效": "Effets spéciaux de fenêtre"
}

View File

@ -570,7 +570,6 @@
"过滤反复刷新的句子": "Filtra frasi aggiornate ripetutamente",
"选择图标": "Seleziona icona",
"图标2": "Icona 2",
"子窗口任务栏中显示": "Mostra nella barra delle applicazioni della sottofinestra",
"刷新": "Aggiorna",
"读取剪贴板": "Leggi gli appunti",
"进行一次OCR": "Condurre un OCR",
@ -802,5 +801,6 @@
"翻译窗口": "Finestra di traduzione",
"工具按钮": "Pulsanti strumenti",
"界面主题": "Tema interfaccia",
"窗口行为": "Comportamento delle finestre"
"窗口行为": "Comportamento delle finestre",
"窗口特效": "Effetti finestra"
}

View File

@ -570,7 +570,6 @@
"过滤反复刷新的句子": "繰り返し更新された文をフィルタリングする",
"选择图标": "アイコンを選択",
"图标2": "アイコン2",
"子窗口任务栏中显示": "サブウィンドウタスクバーに表示",
"刷新": "リフレッシュ",
"读取剪贴板": "クリップボードを読み込む",
"进行一次OCR": "OCRを1回実行する",
@ -802,5 +801,6 @@
"翻译窗口": "翻訳ウィンドウ",
"工具按钮": "ツールボタン",
"界面主题": "インタフェーストピック",
"窗口行为": "ウィンドウの動作"
"窗口行为": "ウィンドウの動作",
"窗口特效": "ウィンドウ効果"
}

View File

@ -570,7 +570,6 @@
"过滤反复刷新的句子": "반복적으로 새로 고친 문장 필터링",
"选择图标": "아이콘 선택",
"图标2": "아이콘 2",
"子窗口任务栏中显示": "하위 창 작업 표시줄에 표시",
"刷新": "새로 고침",
"读取剪贴板": "클립보드 읽기",
"进行一次OCR": "OCR을 한번 진행해보도록 하겠습니다.",
@ -802,5 +801,6 @@
"翻译窗口": "번역 창",
"工具按钮": "도구 단추",
"界面主题": "인터페이스 주제",
"窗口行为": "창 동작"
"窗口行为": "창 동작",
"窗口特效": "창 효과"
}

View File

@ -570,7 +570,6 @@
"过滤反复刷新的句子": "Filtruj wielokrotnie odświeżane zdania",
"选择图标": "Wybierz ikonę",
"图标2": "Ikona 2",
"子窗口任务栏中显示": "Wyświetlanie w podoknie Pasek zadań",
"刷新": "Odśwież",
"读取剪贴板": "Odczytaj schowek",
"进行一次OCR": "Przeprowadzenie OCR",
@ -802,5 +801,6 @@
"翻译窗口": "Okno tłumaczenia",
"工具按钮": "Przyciski narzędziowe",
"界面主题": "Motyw interfejsu",
"窗口行为": "Zachowanie okna"
"窗口行为": "Zachowanie okna",
"窗口特效": "Efekty okien"
}

View File

@ -570,7 +570,6 @@
"过滤反复刷新的句子": "Фильтровать повторяющиеся предложения",
"选择图标": "Выберите значок",
"图标2": "Значок 2",
"子窗口任务栏中显示": "Показать панель задач подсветки",
"刷新": "Обновить",
"读取剪贴板": "Прочитать буфер обмена",
"进行一次OCR": "Выполнить OCR",
@ -802,5 +801,6 @@
"翻译窗口": "Окно перевода",
"工具按钮": "Кнопки инструментов",
"界面主题": "Интерфейсная тема",
"窗口行为": "Поведение окна"
"窗口行为": "Поведение окна",
"窗口特效": "Специальные эффекты окон"
}

View File

@ -396,7 +396,6 @@
"相关说明": "คำแนะนำที่เกี่ยวข้อง",
"字体": "แบบอักษร",
"韩语(CP949,EUC-KR)": "เกาหลี (CP949, EUC-KR)",
"子窗口任务栏中显示": "แสดงในแถบงานของหน้าต่างย่อย",
"分词": "แยกคำ",
"基本设置": "การตั้งค่าพื้นฐาน",
"光标缩放系数": "ค่าสัมประสิทธิ์การซูมเคอร์เซอร์",
@ -802,5 +801,6 @@
"翻译窗口": "หน้าต่างการแปล",
"工具按钮": "ปุ่มเครื่องมือ",
"界面主题": "ธีมอินเตอร์เฟซ",
"窗口行为": "พฤติกรรมของหน้าต่าง"
"窗口行为": "พฤติกรรมของหน้าต่าง",
"窗口特效": "เทคนิคพิเศษของหน้าต่าง"
}

View File

@ -570,7 +570,6 @@
"过滤反复刷新的句子": "Süzgücü tekrar yenilenmiş cümleler",
"选择图标": "İşaretçiyi seç",
"图标2": "İşaretçi 2",
"子窗口任务栏中显示": "Alt pencere Görev Çubuğunda Gösterin",
"刷新": "Tazele",
"读取剪贴板": "Pano Oku",
"进行一次OCR": "OCR yap",
@ -802,5 +801,6 @@
"翻译窗口": "Çeviri Penceresi",
"工具按钮": "Araç düğmeleri",
"界面主题": "Interface Theme",
"窗口行为": "Pencere davranışları"
"窗口行为": "Pencere davranışları",
"窗口特效": "Pencere etkileri"
}

View File

@ -570,7 +570,6 @@
"过滤反复刷新的句子": "Фільтрувати повторно оновлені речення",
"选择图标": "Виберіть піктограму",
"图标2": "Піктограма 2",
"子窗口任务栏中显示": "Показати у панелі завдань підвікна",
"刷新": "Оновити",
"读取剪贴板": "Читати буфер обміну даними",
"进行一次OCR": "Виконати OCR",
@ -802,5 +801,6 @@
"翻译窗口": "Вікно перекладу",
"工具按钮": "Кнопки інструментів",
"界面主题": "Тема інтерфейсу",
"窗口行为": "Поведінка вікон"
"窗口行为": "Поведінка вікон",
"窗口特效": "Ефекти вікна"
}

View File

@ -570,7 +570,6 @@
"过滤反复刷新的句子": "Lọc các câu được làm mới nhiều lần",
"选择图标": "Chọn biểu tượng",
"图标2": "Biểu tượng 2",
"子窗口任务栏中显示": "Hiển thị trong thanh tác vụ cửa sổ con",
"刷新": "Làm mới",
"读取剪贴板": "Đọc bảng nháp",
"进行一次OCR": "Thực hiện OCR",
@ -802,5 +801,6 @@
"翻译窗口": "Cửa sổ dịch",
"工具按钮": "Nút công cụ",
"界面主题": "Giao diện sắc thái",
"窗口行为": "Ứng xử cửa sổ"
"窗口行为": "Ứng xử cửa sổ",
"窗口特效": "Hiệu ứng cửa sổ"
}

View File

@ -391,7 +391,6 @@
"相关说明": "",
"字体": "",
"韩语(CP949,EUC-KR)": "",
"子窗口任务栏中显示": "",
"分词": "",
"基本设置": "",
"光标缩放系数": "",
@ -802,5 +801,6 @@
"翻译窗口": "",
"工具按钮": "",
"界面主题": "",
"窗口行为": ""
"窗口行为": "",
"窗口特效": ""
}

View File

@ -27,9 +27,9 @@ include(libs/libs.cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/version)
include(generate_product_version)
set(VERSION_MAJOR 2)
set(VERSION_MINOR 53)
set(VERSION_PATCH 3)
set(VERSION_MAJOR 3)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)
add_library(pch pch.cpp)
target_precompile_headers(pch PUBLIC pch.h)

View File

@ -6,12 +6,12 @@ DECLARE void showintab(HWND hwnd, bool show)
if (show)
{
style_ex |= WS_EX_APPWINDOW;
style_ex &= ~WS_EX_TOOLWINDOW;
// style_ex &= ~WS_EX_TOOLWINDOW;
}
else
{
style_ex &= ~WS_EX_APPWINDOW;
style_ex |= WS_EX_TOOLWINDOW;
// style_ex |= WS_EX_TOOLWINDOW;
}
SetWindowLong(hwnd, GWL_EXSTYLE, style_ex);
}