This commit is contained in:
恍兮惚兮 2025-01-12 08:51:55 +08:00
parent 082fac5614
commit f9a6d5110a
43 changed files with 337 additions and 405 deletions

View File

@ -362,7 +362,7 @@ namespace
} // unnamed namespace } // unnamed namespace
namespace namespace
{ {
// flutter of birds鳥達の羽ばたき // flutter of birds鳥達の羽ばたき WIN10版本
// https://vndb.org/v2379 // https://vndb.org/v2379
// 需要注意的是不能把文本跳到最快不然2~4行无法显示。 // 需要注意的是不能把文本跳到最快不然2~4行无法显示。
// 这个有一大堆候选 // 这个有一大堆候选

View File

@ -8,7 +8,7 @@ public:
check_by = CHECK_BY::CUSTOM; check_by = CHECK_BY::CUSTOM;
check_by_target = []() check_by_target = []()
{ {
// flutter of birds鳥達の羽ばたき // flutter of birds鳥達の羽ばたき WIN10版本
// https://vndb.org/v2379 // https://vndb.org/v2379
// 很奇怪FindFirstFileW在win7上true在win11上false但PathFileExists在两者都是true // 很奇怪FindFirstFileW在win7上true在win11上false但PathFileExists在两者都是true
auto paks = {L"data.arc", L"effect.arc", L"mes.arc"}; auto paks = {L"data.arc", L"effect.arc", L"mes.arc"};

View File

@ -721,10 +721,49 @@ bool Silkysveryveryold_attach_function()
hp.type = USING_STRING; hp.type = USING_STRING;
return NewHook(hp, "SilkysX"); return NewHook(hp, "SilkysX");
} }
namespace
{
// flutter of birds鳥達の羽ばたき 旧版本
// https://vndb.org/v2379
bool bird()
{
const BYTE bytes[] = {
0x8b, 0x45, 0xf4,
0x33, 0xc9,
0x8a, 0x88, XX4,
0x81, 0xf9, 0x81, 0x00, 0x00, 0x00,
0x0f, 0x85, XX4,
0x8b, 0x55, 0xf4,
0x33, 0xc0,
0x8a, 0x82, XX4,
0x83, 0xf8, 0x75,
0x74, 0x14,
0x8b, 0x4d, 0xf4,
0x33, 0xd2,
0x8a, 0x91, XX4,
0x83, 0xfa, 0x77,
0x0f, 0x85, XX4,
0x8b, 0x45, 0xf4,
0x50};
ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress);
if (!addr)
return false;
addr = findfuncstart(addr);
if (!addr)
return false;
HookParam hp;
hp.address = addr;
hp.type = USING_STRING | EMBED_ABLE | EMBED_AFTER_NEW | EMBED_DYNA_SJIS;
hp.embed_hook_font = F_TextOutA;
hp.offset = stackoffset(1);
hp.lineSeparator = L"\\n";
return NewHook(hp, "SilkysX");
}
}
bool Silkysveryveryold::attach_function() bool Silkysveryveryold::attach_function()
{ {
return Silkysveryveryold_attach_function() || fob2(); return Silkysveryveryold_attach_function() || fob2() || bird();
} }
bool Aisystem6::attach_function() bool Aisystem6::attach_function()

View File

@ -59,7 +59,7 @@ public:
// https://vndb.org/v2380 // https://vndb.org/v2380
check_by = CHECK_BY::CUSTOM; check_by = CHECK_BY::CUSTOM;
check_by_target = []() check_by_target = []()
{ return Util::CheckFile(L"*SYS.ifl") || Util::CheckFile_exits(L"ANSYS.ifl", true); }; // L"*SYS.ifl"; { return Util::CheckFile_exits(L"*SYS*.ifl", true); }; // L"*SYS.ifl";
}; };
bool attach_function(); bool attach_function();
}; };

View File

@ -1,7 +1,7 @@
set(VERSION_MAJOR 6) set(VERSION_MAJOR 6)
set(VERSION_MINOR 19) set(VERSION_MINOR 20)
set(VERSION_PATCH 6) set(VERSION_PATCH 0)
set(VERSION_REVISION 0) set(VERSION_REVISION 0)
set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}") set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}")
add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp) add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp)

View File

@ -76,7 +76,6 @@ class MAINUI:
self.AttachProcessDialog = None self.AttachProcessDialog = None
self.edittextui = None self.edittextui = None
self.edittextui_cached = None self.edittextui_cached = None
self.edittextui_sync = True
self.notifyonce = set() self.notifyonce = set()
self.audioplayer = series_audioplayer(playovercallback=self.ttsautoforward) self.audioplayer = series_audioplayer(playovercallback=self.ttsautoforward)
self._internal_reader = None self._internal_reader = None

View File

@ -51,3 +51,9 @@ global_dialog_savedgame_new = None
global_dialog_setting_game = None global_dialog_setting_game = None
serverindex = 0 serverindex = 0
edittrans = None edittrans = None
class Consts:
buttoncolor = "#FF69B4"
buttoncolor_disable = "#afafaf"
btnscale = 1.2

View File

@ -22,9 +22,7 @@ from gui.usefulwidget import (
saveposwindow, saveposwindow,
getboxlayout, getboxlayout,
IconButton, IconButton,
statusbutton,
getsimplecombobox, getsimplecombobox,
threeswitch,
FQLineEdit, FQLineEdit,
FocusCombo, FocusCombo,
) )
@ -45,6 +43,36 @@ from gui.dialog_savedgame_common import (
) )
class threeswitch(QWidget):
btnclicked = pyqtSignal(int)
def selectlayout(self, i):
try:
self.btns[(i + 0) % 3].setEnabled(False)
self.btns[(i + 1) % 3].setEnabled(False)
self.btns[(i + 2) % 3].setEnabled(False)
self.btns[(i + 0) % 3].setChecked(True)
self.btns[(i + 1) % 3].setChecked(False)
self.btns[(i + 2) % 3].setChecked(False)
self.btnclicked.emit(i)
self.btns[(i + 1) % 3].setEnabled(True)
self.btns[(i + 2) % 3].setEnabled(True)
except:
pass
def __init__(self, p, icons):
super().__init__(p)
self.btns = []
hv = QHBoxLayout(self)
hv.setContentsMargins(0, 0, 0, 0)
hv.setSpacing(0)
for i, icon in enumerate(icons):
btn = IconButton(parent=self, icon=icon, checkable=True)
btn.clicked.connect(functools.partial(self.selectlayout, i))
self.btns.append(btn)
hv.addWidget(btn)
@Singleton_close @Singleton_close
class dialog_savedgame_integrated(saveposwindow): class dialog_savedgame_integrated(saveposwindow):
@ -67,6 +95,17 @@ class dialog_savedgame_integrated(saveposwindow):
except: except:
print_exc() print_exc()
def event(self, a0: QEvent) -> bool:
if a0.type() == QEvent.Type.FontChange:
h = QFontMetricsF(self.font()).height()
h = int(h * gobject.Consts.btnscale)
sz = QSize(h, h)
self.syssettingbtn.setFixedSize(sz)
sz = QSize(h * 3, h)
self.switch.setFixedSize(sz)
self.do_resize()
return super().event(a0)
def __init__(self, parent) -> None: def __init__(self, parent) -> None:
super().__init__( super().__init__(
parent, parent,
@ -85,6 +124,7 @@ class dialog_savedgame_integrated(saveposwindow):
self.setCentralWidget(w) self.setCentralWidget(w)
self.switch = threeswitch(self, icons=["fa.list", "fa.th-list", "fa.th"]) self.switch = threeswitch(self, icons=["fa.list", "fa.th-list", "fa.th"])
self.switch.setFixedSize(QSize(75, 25))
self.switch.btnclicked.connect(self.selectlayout) self.switch.btnclicked.connect(self.selectlayout)
self.syssettingbtn = IconButton(icon="fa.gear", parent=self) self.syssettingbtn = IconButton(icon="fa.gear", parent=self)
self.syssettingbtn.setFixedSize(QSize(25, 25)) self.syssettingbtn.setFixedSize(QSize(25, 25))
@ -99,7 +139,10 @@ class dialog_savedgame_integrated(saveposwindow):
) )
def resizeEvent(self, e: QResizeEvent): def resizeEvent(self, e: QResizeEvent):
x = e.size().width() - self.switch.width() self.do_resize()
def do_resize(self):
x = self.width() - self.switch.width()
self.switch.move(x, 0) self.switch.move(x, 0)
x -= self.syssettingbtn.width() x -= self.syssettingbtn.width()
self.syssettingbtn.move(x, 0) self.syssettingbtn.move(x, 0)
@ -649,6 +692,13 @@ class dialog_savedgame_new(QWidget):
) )
self.setStyleSheet(style) self.setStyleSheet(style)
def event(self, a0: QEvent) -> bool:
if a0.type() == QEvent.Type.FontChange:
h = QFontMetricsF(self.font()).height()
h = int(h * gobject.Consts.btnscale)
self.___.setFixedWidth(4 * h)
return super().event(a0)
def __init__(self, parent) -> None: def __init__(self, parent) -> None:
super().__init__(parent) super().__init__(parent)
self._parent = parent self._parent = parent
@ -668,7 +718,8 @@ class dialog_savedgame_new(QWidget):
self.currtags = tuple() self.currtags = tuple()
self.tagswidget.tagschanged.connect(self.tagschanged) self.tagswidget.tagschanged.connect(self.tagschanged)
_ = QLabel() _ = QLabel()
_.setFixedWidth(80) _.setFixedWidth(100)
self.___ = _
layout.addWidget(self.tagswidget) layout.addWidget(self.tagswidget)
layout.addWidget(_) layout.addWidget(_)
formLayout.addLayout(layout) formLayout.addLayout(layout)

View File

@ -1,5 +1,5 @@
from qtsymbols import * from qtsymbols import *
import functools, threading import functools, threading, gobject
from myutils.config import savehook_new_list, savehook_new_data, get_launchpath from myutils.config import savehook_new_list, savehook_new_data, get_launchpath
from myutils.hwnd import getExeIcon from myutils.hwnd import getExeIcon
from gui.usefulwidget import ( from gui.usefulwidget import (
@ -234,6 +234,14 @@ class dialog_savedgame_legacy(QWidget):
_ = QLabel() _ = QLabel()
_.setFixedHeight(20) _.setFixedHeight(20)
_.setStyleSheet("background:transparent") _.setStyleSheet("background:transparent")
self.___ = _
formLayout.addWidget(_) formLayout.addWidget(_)
formLayout.addWidget(table) formLayout.addWidget(table)
formLayout.addLayout(bottom) formLayout.addLayout(bottom)
def event(self, a0: QEvent) -> bool:
if a0.type() == QEvent.Type.FontChange:
h = QFontMetricsF(self.font()).height()
h = int(h * gobject.Consts.btnscale)
self.___.setFixedHeight(h)
return super().event(a0)

View File

@ -22,7 +22,7 @@ from gui.inputdialog import autoinitdialog
from gui.specialwidget import stackedlist, shrinkableitem, shownumQPushButton from gui.specialwidget import stackedlist, shrinkableitem, shownumQPushButton
from gui.usefulwidget import ( from gui.usefulwidget import (
pixmapviewer, pixmapviewer,
statusbutton, IconButton,
makesubtab_lazy, makesubtab_lazy,
tabadd_lazy, tabadd_lazy,
listediter, listediter,
@ -362,12 +362,12 @@ class viewpixmap_x(QWidget):
self.centerwidget = QWidget(self) self.centerwidget = QWidget(self)
self.centerwidgetlayout = QVBoxLayout(self.centerwidget) self.centerwidgetlayout = QVBoxLayout(self.centerwidget)
audio = QHBoxLayout() audio = QHBoxLayout()
self.recordbtn = statusbutton(icons=["fa.microphone", "fa.stop"]) self.recordbtn = IconButton(icon=["fa.microphone", "fa.stop"], checkable=True)
self.recordbtn.clicked.connect(self.startorendrecord) self.recordbtn.clicked.connect(self.startorendrecord)
self.centerwidgetlayout.addWidget(self.commentedit) self.centerwidgetlayout.addWidget(self.commentedit)
self.centerwidgetlayout.addLayout(audio) self.centerwidgetlayout.addLayout(audio)
audio.addWidget(self.recordbtn) audio.addWidget(self.recordbtn)
self.btnplay = statusbutton(icons=["fa.play", "fa.stop"]) self.btnplay = IconButton(icon=["fa.play", "fa.stop"], checkable=True)
audio.addWidget(self.btnplay) audio.addWidget(self.btnplay)
self.btnplay.clicked.connect(self.playorstop) self.btnplay.clicked.connect(self.playorstop)
gobject.baseobject.hualang_recordbtn = self.recordbtn gobject.baseobject.hualang_recordbtn = self.recordbtn

View File

@ -3,7 +3,12 @@ import threading, windows
import gobject, qtawesome, os, json import gobject, qtawesome, os, json
from myutils.config import globalconfig, savehook_new_data, translatorsetting from myutils.config import globalconfig, savehook_new_data, translatorsetting
from myutils.wrapper import Singleton_close from myutils.wrapper import Singleton_close
from gui.usefulwidget import saveposwindow, getsimplecombobox from gui.usefulwidget import (
saveposwindow,
getsimplecombobox,
getIconButton,
IconButton,
)
from gui.dynalang import LPushButton, LMainWindow from gui.dynalang import LPushButton, LMainWindow
from gui.setting_textinput import loadvalidtss from gui.setting_textinput import loadvalidtss
@ -19,7 +24,6 @@ class edittext(saveposwindow):
def __init__(self, parent, cached): def __init__(self, parent, cached):
super().__init__(parent, poslist=globalconfig["edit_geo"]) super().__init__(parent, poslist=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("编辑") self.setWindowTitle("编辑")
@ -38,23 +42,11 @@ class edittext(saveposwindow):
qv = QHBoxLayout(w) qv = QHBoxLayout(w)
self.setCentralWidget(w) self.setCentralWidget(w)
bt1 = QPushButton( bt1 = getIconButton(icon="fa.rotate-right")
icon=qtawesome.icon("fa.rotate-right", color=globalconfig["buttoncolor"]) bt2 = IconButton(icon=["fa.play", "fa.forward"], checkable=True)
) bt2.setChecked(True)
bt2 = QPushButton(
icon=qtawesome.icon(
"fa.forward" if gobject.baseobject.edittextui_sync else "fa.play",
color=(
"#FF69B4"
if gobject.baseobject.edittextui_sync
else globalconfig["buttoncolor"]
),
)
)
self.bt2 = bt2 self.bt2 = bt2
self.bt1 = bt1 self.bt1 = bt1
bt2.clicked.connect(self.changestate)
bt1.clicked.connect(self.run) bt1.clicked.connect(self.run)
qvb = QVBoxLayout() qvb = QVBoxLayout()
qvb.addWidget(bt1) qvb.addWidget(bt1)
@ -69,21 +61,8 @@ class edittext(saveposwindow):
args=(self.textOutput.toPlainText(), False), args=(self.textOutput.toPlainText(), False),
).start() ).start()
def changestate(self):
gobject.baseobject.edittextui_sync = not gobject.baseobject.edittextui_sync
self.bt2.setIcon(
qtawesome.icon(
"fa.forward" if gobject.baseobject.edittextui_sync else "fa.play",
color=(
"#FF69B4"
if gobject.baseobject.edittextui_sync
else globalconfig["buttoncolor"]
),
)
)
def getnewsentence(self, sentence): def getnewsentence(self, sentence):
if gobject.baseobject.edittextui_sync: if self.bt2.isChecked():
self.textOutput.setPlainText(sentence) self.textOutput.setPlainText(sentence)

View File

@ -21,6 +21,7 @@ from gui.usefulwidget import (
SplitLine, SplitLine,
getIconButton, getIconButton,
VisLFormLayout, VisLFormLayout,
getcolorbutton,
) )
from gui.dynalang import ( from gui.dynalang import (
LFormLayout, LFormLayout,
@ -797,14 +798,13 @@ class multicolorset(LDialog):
functools.partial(globalconfig["cixingcolorshow"].__setitem__, k) functools.partial(globalconfig["cixingcolorshow"].__setitem__, k)
) )
p = QPushButton( p = getcolorbutton(
qtawesome.icon("fa.paint-brush", color=globalconfig["cixingcolor"][k]), globalconfig["cixingcolor"],
"", k,
name="miaobian_color_button",
parent=self,
) )
p.setIconSize(QSize(20, 20))
p.setStyleSheet("background: transparent;")
p.clicked.connect( p.clicked.connect(
functools.partial(selectcolor, self, globalconfig["cixingcolor"], k, p) functools.partial(selectcolor, self, globalconfig["cixingcolor"], k, p)
) )

View File

@ -15,6 +15,7 @@ from gui.usefulwidget import (
getsimpleswitch, getsimpleswitch,
FocusSpin, FocusSpin,
FocusCombo, FocusCombo,
IconButton,
TableViewW, TableViewW,
) )
from gui.dynalang import ( from gui.dynalang import (
@ -612,7 +613,7 @@ class hookselect(closeashidewindow):
self.userhookinsert.clicked.connect(self.inserthook) self.userhookinsert.clicked.connect(self.inserthook)
self.searchtextlayout.addWidget(self.userhookinsert) self.searchtextlayout.addWidget(self.userhookinsert)
self.userhookinsert = QPushButton(icon=qtawesome.icon("fa.question")) self.userhookinsert = IconButton("fa.question")
self.userhookinsert.clicked.connect( self.userhookinsert.clicked.connect(
lambda: gobject.baseobject.openlink( lambda: gobject.baseobject.openlink(
dynamiclink("{docs_server}/#/zh/hooksettings?id=hookcode") dynamiclink("{docs_server}/#/zh/hooksettings?id=hookcode")

View File

@ -32,9 +32,7 @@ class dialog_selecticon(LDialog):
layout.addWidget( layout.addWidget(
getIconButton( getIconButton(
functools.partial(self.selectcallback, "fa." + name), functools.partial(self.selectcallback, "fa." + name),
qicon=qtawesome.icon( icon="fa." + name,
"fa." + name, color=globalconfig["buttoncolor2"]
),
), ),
i // 30, i // 30,
i % 30, i % 30,
@ -124,10 +122,7 @@ def createbuttonwidget(self, lay):
globalconfig["toolbutton"]["buttons"][k], globalconfig["toolbutton"]["buttons"][k],
"icon", "icon",
), ),
qicon=qtawesome.icon( icon=globalconfig["toolbutton"]["buttons"][k]["icon"],
globalconfig["toolbutton"]["buttons"][k]["icon"],
color=globalconfig["buttoncolor2"],
),
), ),
getsmalllabel(), getsmalllabel(),
] ]
@ -140,10 +135,7 @@ def createbuttonwidget(self, lay):
globalconfig["toolbutton"]["buttons"][k], globalconfig["toolbutton"]["buttons"][k],
"icon2", "icon2",
), ),
qicon=qtawesome.icon( icon=globalconfig["toolbutton"]["buttons"][k]["icon2"],
globalconfig["toolbutton"]["buttons"][k]["icon2"],
color=globalconfig["buttoncolor2"],
),
), ),
) )
else: else:

View File

@ -298,7 +298,7 @@ def xianshigrid_style(self):
"", "",
"字体大小", "字体大小",
D_getspinbox( D_getspinbox(
1, 5,
100, 100,
globalconfig, globalconfig,
"fontsizeori", "fontsizeori",

View File

@ -532,10 +532,11 @@ def otheruisetting(self):
[ [
"字体", "字体",
(createfontcombo, 0), (createfontcombo, 0),
"", ],
[
"字体大小", "字体大小",
D_getspinbox( D_getspinbox(
1, 5,
100, 100,
globalconfig, globalconfig,
"settingfontsize", "settingfontsize",
@ -543,36 +544,6 @@ def otheruisetting(self):
step=0.1, step=0.1,
callback=lambda _: gobject.baseobject.setcommonstylesheet(), callback=lambda _: gobject.baseobject.setcommonstylesheet(),
), ),
],
[
"按钮颜色",
D_getcolorbutton(
globalconfig,
"buttoncolor2",
callback=lambda: selectcolor(
self,
globalconfig,
"buttoncolor2",
self.buttoncolorbutton2,
),
name="buttoncolorbutton2",
parent=self,
),
D_getcolorbutton(
globalconfig,
"buttoncolor3",
callback=lambda: selectcolor(
self,
globalconfig,
"buttoncolor3",
self.buttoncolorbutton3,
),
name="buttoncolorbutton3",
parent=self,
),
"",
"按钮大小",
D_getspinbox(5, 100, globalconfig, "buttonsize2"),
"", "",
"任务栏中显示", "任务栏中显示",
D_getsimpleswitch( D_getsimpleswitch(

View File

@ -23,6 +23,7 @@ from gui.usefulwidget import (
makegrid, makegrid,
makesubtab_lazy, makesubtab_lazy,
makescrollgrid, makescrollgrid,
IconButton
) )
from gui.dynalang import LPushButton, LLabel, LAction from gui.dynalang import LPushButton, LLabel, LAction
from gui.setting_about import offlinelinks from gui.setting_about import offlinelinks
@ -261,15 +262,7 @@ def btnpluscallback(self, countnum, btnplus):
) )
def createbtn(self, countnum, btnplus): class Shit(QGroupBox):
btn = QPushButton(self)
btn.setIcon(qtawesome.icon("fa.plus"))
btn.clicked.connect(functools.partial(btnpluscallback, self, countnum, btnplus))
setattr(self, "btnadd" + btnplus, btn)
return btn
class Shit(QWidget):
pass pass
@ -318,20 +311,17 @@ def createmanybtn(self, countnum, btnplus):
hbox = QHBoxLayout(w) hbox = QHBoxLayout(w)
hbox.setContentsMargins(0, 0, 0, 0) hbox.setContentsMargins(0, 0, 0, 0)
btn = QPushButton(self) btn = IconButton("fa.plus")
btn.setIcon(qtawesome.icon("fa.plus"))
btn.clicked.connect(functools.partial(btnpluscallback, self, countnum, btnplus)) btn.clicked.connect(functools.partial(btnpluscallback, self, countnum, btnplus))
hbox.addWidget(btn) hbox.addWidget(btn)
btn = QPushButton(self) btn = IconButton("fa.minus")
btn.setIcon(qtawesome.icon("fa.minus"))
btn.clicked.connect(functools.partial(btndeccallback, self, countnum, btnplus)) btn.clicked.connect(functools.partial(btndeccallback, self, countnum, btnplus))
hbox.addWidget(btn) hbox.addWidget(btn)
btn = QPushButton(self) btn = IconButton("fa.question")
btn.setIcon(qtawesome.icon("fa.question"))
if btnplus == "offline": if btnplus == "offline":
btn.clicked.connect( btn.clicked.connect(
lambda: gobject.baseobject.openlink( lambda: gobject.baseobject.openlink(

View File

@ -17,11 +17,10 @@ from myutils.ocrutil import imageCut, ocr_run
from gui.rangeselect import rangeselct_function from gui.rangeselect import rangeselct_function
from gui.usefulwidget import ( from gui.usefulwidget import (
closeashidewindow, closeashidewindow,
statusbutton,
getQMessageBox, getQMessageBox,
auto_select_webview, auto_select_webview,
WebivewWidget, WebivewWidget,
mshtmlWidget, IconButton,
getboxlayout, getboxlayout,
getspinbox, getspinbox,
getsimplecombobox, getsimplecombobox,
@ -460,19 +459,19 @@ class AnkiWindow(QWidget):
self.recorders = {} self.recorders = {}
wid = QWidget() wid = QWidget()
layout = QVBoxLayout(wid) layout = QVBoxLayout(wid)
soundbutton = QPushButton(qtawesome.icon("fa.music"), "") soundbutton = IconButton("fa.music")
soundbutton.clicked.connect(self.langdu) soundbutton.clicked.connect(self.langdu)
soundbutton2 = QPushButton(qtawesome.icon("fa.music"), "") soundbutton2 = IconButton("fa.music")
soundbutton2.clicked.connect(self.langdu2) soundbutton2.clicked.connect(self.langdu2)
cropbutton = QPushButton(qtawesome.icon("fa.crop"), "") cropbutton = IconButton("fa.crop")
cropbutton.clicked.connect(functools.partial(self.crophide, False)) cropbutton.clicked.connect(functools.partial(self.crophide, False))
cropbutton.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) cropbutton.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
cropbutton.customContextMenuRequested.connect( cropbutton.customContextMenuRequested.connect(
functools.partial(self.crophide, True) functools.partial(self.crophide, True)
) )
grabwindowbtn = QPushButton(qtawesome.icon("fa.camera"), "") grabwindowbtn = IconButton("fa.camera")
grabwindowbtn.clicked.connect( grabwindowbtn.clicked.connect(
lambda: grabwindow( lambda: grabwindow(
getimageformat(), getimageformat(),
@ -481,7 +480,7 @@ class AnkiWindow(QWidget):
) )
def createtbn(target: QLineEdit): def createtbn(target: QLineEdit):
clearbtn = QPushButton(qtawesome.icon("fa.times"), "") clearbtn = IconButton("fa.times")
clearbtn.clicked.connect(lambda: target.clear()) clearbtn.clicked.connect(lambda: target.clear())
return clearbtn return clearbtn
@ -527,11 +526,11 @@ class AnkiWindow(QWidget):
self.example.textChanged.connect(__) self.example.textChanged.connect(__)
self.remarks = ctrlbedit() self.remarks = ctrlbedit()
recordbtn1 = statusbutton(icons=["fa.microphone", "fa.stop"]) recordbtn1 = IconButton(icon=["fa.microphone", "fa.stop"], checkable=True)
recordbtn1.clicked.connect( recordbtn1.clicked.connect(
functools.partial(self.startorendrecord, 1, self.audiopath) functools.partial(self.startorendrecord, 1, self.audiopath)
) )
recordbtn2 = statusbutton(icons=["fa.microphone", "fa.stop"]) recordbtn2 = IconButton(icon=["fa.microphone", "fa.stop"], checkable=True)
recordbtn2.clicked.connect( recordbtn2.clicked.connect(
functools.partial(self.startorendrecord, 2, self.audiopath_sentence) functools.partial(self.startorendrecord, 2, self.audiopath_sentence)
) )
@ -554,13 +553,13 @@ class AnkiWindow(QWidget):
lb = QLabel("DeckName") lb = QLabel("DeckName")
lb.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Preferred) lb.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Preferred)
folder_open = QPushButton(qtawesome.icon("fa.folder-open"), "") folder_open = IconButton("fa.folder-open")
folder_open.clicked.connect(functools.partial(self.selecfile, self.audiopath)) folder_open.clicked.connect(functools.partial(self.selecfile, self.audiopath))
folder_open2 = QPushButton(qtawesome.icon("fa.folder-open"), "") folder_open2 = IconButton("fa.folder-open")
folder_open2.clicked.connect( folder_open2.clicked.connect(
functools.partial(self.selecfile, self.audiopath_sentence) functools.partial(self.selecfile, self.audiopath_sentence)
) )
folder_open3 = QPushButton(qtawesome.icon("fa.folder-open"), "") folder_open3 = IconButton("fa.folder-open")
folder_open3.clicked.connect(functools.partial(self.selecfile2, self.editpath)) folder_open3.clicked.connect(functools.partial(self.selecfile2, self.editpath))
def createadd(): def createadd():
@ -1175,6 +1174,18 @@ class searchwordW(closeashidewindow):
if action == auto: if action == auto:
globalconfig["is_search_word_auto_tts"] = auto.isChecked() globalconfig["is_search_word_auto_tts"] = auto.isChecked()
def historymenu(self):
menu = QMenu(self)
__ = []
for word in self.historys:
act = QAction(word)
__.append(act)
menu.addAction(act)
action = menu.exec(QCursor.pos())
if action:
self.searchtext.setText(action.text())
self.search(action.text())
def setupUi(self): def setupUi(self):
self.setWindowTitle("查词") self.setWindowTitle("查词")
self.ankiwindow = AnkiWindow(self) self.ankiwindow = AnkiWindow(self)
@ -1188,34 +1199,24 @@ class searchwordW(closeashidewindow):
self.searchtext = FQLineEdit() self.searchtext = FQLineEdit()
self.searchtext.textChanged.connect(self.ankiwindow.reset) self.searchtext.textChanged.connect(self.ankiwindow.reset)
self.dictbutton = statusbutton( self.dictbutton = IconButton(icon="fa.book", checkable=True)
icons="fa.book", colors=["", globalconfig["buttoncolor2"]] self.historys = []
) self.history_btn = IconButton(icon="fa.history")
self.history_last_btn = statusbutton(icons=["fa.arrow-left", "fa.arrow-left"]) self.history_btn.setEnabled(False)
self.history_last_btn.clicked.connect( self.history_btn.clicked.connect(self.historymenu)
functools.partial(self.__move_history_search, -1)
)
self.history_next_btn = statusbutton(icons=["fa.arrow-right", "fa.arrow-right"])
self.history_next_btn.clicked.connect(
functools.partial(self.__move_history_search, 1)
)
self.trace_history = []
self.trace_history_idx = -1
self.__set_history_btn_able()
self.searchlayout.addWidget(self.dictbutton) self.searchlayout.addWidget(self.dictbutton)
self.searchlayout.addWidget(self.history_last_btn) self.searchlayout.addWidget(self.history_btn)
self.searchlayout.addWidget(self.history_next_btn)
self.searchlayout.addWidget(self.searchtext) self.searchlayout.addWidget(self.searchtext)
searchbutton = QPushButton(qtawesome.icon("fa.search"), "") searchbutton = IconButton("fa.search")
searchbutton.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) searchbutton.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
searchbutton.customContextMenuRequested.connect(self._createnewwindowsearch) searchbutton.customContextMenuRequested.connect(self._createnewwindowsearch)
self.searchtext.returnPressed.connect(searchbutton.clicked.emit) self.searchtext.returnPressed.connect(searchbutton.clicked.emit)
searchbutton.clicked.connect(self.__search_by_click_search_btn) searchbutton.clicked.connect(lambda: self.search(self.searchtext.text()))
self.searchlayout.addWidget(searchbutton) self.searchlayout.addWidget(searchbutton)
soundbutton = QPushButton(qtawesome.icon("fa.music"), "") soundbutton = IconButton("fa.music")
soundbutton.clicked.connect( soundbutton.clicked.connect(
lambda: gobject.baseobject.read_text(self.searchtext.text()) lambda: gobject.baseobject.read_text(self.searchtext.text())
) )
@ -1224,9 +1225,7 @@ class searchwordW(closeashidewindow):
self.soundbutton = soundbutton self.soundbutton = soundbutton
self.searchlayout.addWidget(soundbutton) self.searchlayout.addWidget(soundbutton)
ankiconnect = statusbutton( ankiconnect = IconButton(icon="fa.adn", checkable=True)
icons="fa.adn", colors=["", globalconfig["buttoncolor2"]]
)
ankiconnect.clicked.connect(self.onceaddankiwindow) ankiconnect.clicked.connect(self.onceaddankiwindow)
ankiconnect.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) ankiconnect.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
ankiconnect.customContextMenuRequested.connect( ankiconnect.customContextMenuRequested.connect(
@ -1344,12 +1343,7 @@ class searchwordW(closeashidewindow):
if append: if append:
word = self.searchtext.text() + word word = self.searchtext.text() + word
self.searchtext.setText(word) self.searchtext.setText(word)
self.search(word) self.search(word)
if len(self.trace_history) == 0 or self.trace_history[-1] != word:
self.trace_history.append(word)
self.trace_history_idx = len(self.trace_history) - 1
self.__set_history_btn_able()
self.ankiwindow.example.setPlainText(gobject.baseobject.currenttext) self.ankiwindow.example.setPlainText(gobject.baseobject.currenttext)
if globalconfig["ankiconnect"]["autoruntts"]: if globalconfig["ankiconnect"]["autoruntts"]:
self.ankiwindow.langdu() self.ankiwindow.langdu()
@ -1364,34 +1358,19 @@ class searchwordW(closeashidewindow):
), ),
) )
def __set_history_btn_able(self): def __parsehistory(self, word):
self.history_next_btn.setEnabled( if word in self.historys:
self.trace_history_idx < len(self.trace_history) - 1 self.historys.remove(word)
) self.historys.insert(0, word)
self.history_last_btn.setEnabled(self.trace_history_idx > 0) self.history_btn.setEnabled(True)
def __move_history_search(self, offset):
self.trace_history_idx += offset
word = self.trace_history[self.trace_history_idx]
self.__set_history_btn_able()
self.searchtext.setText(word)
self.search(word)
def __search_by_click_search_btn(self):
word = self.searchtext.text()
self.search(word)
if len(self.trace_history) == 0 or self.trace_history[-1] != word:
self.trace_history.append(word)
self.trace_history_idx = len(self.trace_history) - 1
self.__set_history_btn_able()
def search(self, word): def search(self, word):
current = time.time() current = time.time()
self.current = current self.current = current
word = word.strip() word = word.strip()
if word == "": if not word:
return return
self.__parsehistory(word)
if globalconfig["is_search_word_auto_tts"]: if globalconfig["is_search_word_auto_tts"]:
gobject.baseobject.read_text(self.searchtext.text()) gobject.baseobject.read_text(self.searchtext.text())
self.ankiwindow.reset(word) self.ankiwindow.reset(word)

View File

@ -29,28 +29,27 @@ from gui.setting_about import doupdate
from gui.dialog_memory import dialog_memory from gui.dialog_memory import dialog_memory
from gui.textbrowser import Textbrowser, TextType from gui.textbrowser import Textbrowser, TextType
from gui.rangeselect import rangeselct_function from gui.rangeselect import rangeselct_function
from gui.usefulwidget import ( from gui.usefulwidget import resizableframeless, getQMessageBox, findnearestscreen
resizableframeless,
getQMessageBox,
LIconLabel,
findnearestscreen,
)
from gui.edittext import edittrans from gui.edittext import edittrans
from gui.dialog_savedgame import dialog_savedgame_integrated from gui.dialog_savedgame import dialog_savedgame_integrated
from gui.dialog_savedgame_setting import favorites, calculate_centered_rect from gui.dialog_savedgame_setting import favorites, calculate_centered_rect
from gui.dialog_savedgame_common import startgame from gui.dialog_savedgame_common import startgame
from gui.dynalang import LDialog from gui.dynalang import LDialog, LLabel
class ButtonX(QWidget): class IconLabelX(LLabel):
clicked = pyqtSignal()
rightclick = pyqtSignal()
def __init__(self, *argc): def __init__(self, *argc):
super().__init__(*argc) super().__init__(*argc)
self.reflayout = None self.reflayout = None
self._icon = QIcon()
self._size = QSize()
self.setMouseTracking(True) self.setMouseTracking(True)
self.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Expanding) self.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Expanding)
def showinlayout(self, layout): def showinlayout(self, layout: QHBoxLayout):
layout.addWidget(self) layout.addWidget(self)
self.show() self.show()
@ -64,15 +63,37 @@ class ButtonX(QWidget):
_.removeWidget(self) _.removeWidget(self)
self.hide() self.hide()
def resizeEvent(self, e): def resizeEvent(self, e: QResizeEvent):
h = int(e.size().height() / 1.5) h = int(e.size().height() / 1.5)
self.setFixedWidth(int(self.height() * 2 / 1.5)) self.setFixedWidth(int(self.height() * 2 / 1.5))
self.setIconSize(QSize(h, h)) self.setIconSize(QSize(h, h))
def setIcon(self, icon: QIcon):
self._icon = icon
self.update()
class IconLabelX(LIconLabel, ButtonX): def setIconSize(self, size: QSize):
clicked = pyqtSignal() self._size = size
rightclick = pyqtSignal() self.update()
def paintEvent(self, a0: QPaintEvent) -> None:
painter = QPainter(self)
if self._size.isEmpty():
return
rect = QRect(
(self.width() - self._size.width()) // 2,
(self.height() - self._size.height()) // 2,
self._size.width(),
self._size.height(),
)
self._icon.paint(
painter,
rect,
Qt.AlignmentFlag.AlignCenter,
QIcon.Mode.Normal,
QIcon.State.On,
)
def mousePressEvent(self, ev: QMouseEvent) -> None: def mousePressEvent(self, ev: QMouseEvent) -> None:
if QObject.receivers(self, self.clicked) == 0: if QObject.receivers(self, self.clicked) == 0:

View File

@ -376,11 +376,6 @@ def getQMessageBox(
cancelcallback() cancelcallback()
def makerect(_):
x, y, w, h = _
return [x, x + w, y, y + h]
def findnearestscreen(rect: QRect): def findnearestscreen(rect: QRect):
# QScreen ,distance # QScreen ,distance
# -1时是有交集 # -1时是有交集
@ -480,17 +475,6 @@ class closeashidewindow(saveposwindow):
super().closeEvent(event) super().closeEvent(event)
class commonsolveevent(QWidget):
def event(self, a0: QEvent) -> bool:
if a0.type() == QEvent.Type.MouseButtonDblClick:
return True
elif a0.type() == QEvent.Type.EnabledChange:
self.setEnabled(not self.isEnabled())
return True
return super().event(a0)
def disablecolor(__: QColor): def disablecolor(__: QColor):
if __.rgb() == 0xFF000000: if __.rgb() == 0xFF000000:
return Qt.GlobalColor.gray return Qt.GlobalColor.gray
@ -505,29 +489,38 @@ def disablecolor(__: QColor):
return __ return __
class MySwitch(commonsolveevent): class MySwitch(QWidget):
clicked = pyqtSignal(bool) clicked = pyqtSignal(bool)
clicksignal = pyqtSignal() clicksignal = pyqtSignal()
def event(self, a0: QEvent) -> bool:
if a0.type() == QEvent.Type.MouseButtonDblClick:
return True
elif a0.type() == QEvent.Type.EnabledChange:
self.setEnabled(not self.isEnabled())
return True
elif a0.type() == QEvent.Type.FontChange:
h = QFontMetricsF(self.font()).height()
sz = QSize(
int(1.62 * h * gobject.Consts.btnscale),
int(h * gobject.Consts.btnscale),
)
self.setFixedSize(sz)
return super().event(a0)
def click(self): def click(self):
self.setChecked(not self.checked) self.setChecked(not self.checked)
self.clicked.emit(self.checked) self.clicked.emit(self.checked)
def sizeHint(self): def __init__(self, parent=None, sign=True, enable=True):
return QSize(
int(1.62 * globalconfig["buttonsize2"]), globalconfig["buttonsize2"]
)
def __init__(self, parent=None, sign=True, enable=True, icon=None):
super().__init__(parent) super().__init__(parent)
self.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
self.checked = sign self.checked = sign
self.setCursor(Qt.CursorShape.PointingHandCursor) self.setCursor(Qt.CursorShape.PointingHandCursor)
self.clicksignal.connect(self.click) self.clicksignal.connect(self.click)
self.__currv = 0 self.__currv = 0
if sign: if sign:
self.__currv = 20 self.__currv = 20
self.icon = icon
self.animation = QVariantAnimation() self.animation = QVariantAnimation()
self.animation.setDuration(80) self.animation.setDuration(80)
@ -551,18 +544,12 @@ class MySwitch(commonsolveevent):
if check == self.checked: if check == self.checked:
return return
self.checked = check self.checked = check
self.runanimeorshowicon() self.runanime()
def update11(self): def update11(self):
self.__currv = self.animation.currentValue() self.__currv = self.animation.currentValue()
self.update() self.update()
def runanimeorshowicon(self):
if self.icon:
self.update()
else:
self.runanime()
def runanime(self): def runanime(self):
self.animation.setDirection( self.animation.setDirection(
QVariantAnimation.Direction.Forward QVariantAnimation.Direction.Forward
@ -574,7 +561,9 @@ class MySwitch(commonsolveevent):
def getcurrentcolor(self): def getcurrentcolor(self):
__ = QColor( __ = QColor(
[globalconfig["buttoncolor3"], globalconfig["buttoncolor2"]][self.checked] [gobject.Consts.buttoncolor_disable, gobject.Consts.buttoncolor][
self.checked
]
) )
if not self.enable: if not self.enable:
__ = disablecolor(__) __ = disablecolor(__)
@ -583,46 +572,36 @@ class MySwitch(commonsolveevent):
def paintanime(self, painter: QPainter): def paintanime(self, painter: QPainter):
painter.setBrush(self.getcurrentcolor()) painter.setBrush(self.getcurrentcolor())
bigw = self.size().width() - self.sizeHint().width() wb = self.width() * 0.1
bigh = self.size().height() - self.sizeHint().height() hb = self.height() * 0.125
x = bigw // 2
y = bigh // 2
painter.drawRoundedRect( painter.drawRoundedRect(
QRect(x, y, self.sizeHint().width(), self.sizeHint().height()), QRectF(
self.sizeHint().height() // 2, wb,
self.sizeHint().height() // 2, hb,
) self.width() - 2 * wb,
self.height() - 2 * hb,
offset = int( ),
self.__currv * (self.sizeHint().width() - self.sizeHint().height()) / 20 self.height() / 2 - hb,
self.height() / 2 - hb,
) )
r = self.height() * 0.275
rb = self.height() / 2 - hb - r
offset = self.__currv * (self.width() - 2 * wb - 2 * r - 2 * rb) / 20
painter.setBrush(QColor(255, 255, 255)) painter.setBrush(QColor(255, 255, 255))
painter.drawEllipse( painter.drawEllipse(
QPoint( QPointF(
x + self.sizeHint().height() // 2 + offset, (wb + r + rb) + offset,
y + self.sizeHint().height() // 2, (self.height() / 2),
), ),
int(self.sizeHint().height() * 0.35), r,
int(self.sizeHint().height() * 0.35), r,
) )
def painticon(self, painter: QPainter): def paintEvent(self, _):
icon: QIcon = qtawesome.icon(self.icon, color=self.getcurrentcolor())
bigw = self.size().width() - self.sizeHint().width()
bigh = self.size().height() - self.sizeHint().height()
x = bigw // 2
y = bigh // 2
painter.drawPixmap(x, y, icon.pixmap(self.sizeHint()))
def paintEvent(self, event):
painter = QPainter(self) painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing) painter.setRenderHint(QPainter.RenderHint.Antialiasing)
painter.setPen(Qt.PenStyle.NoPen) painter.setPen(Qt.PenStyle.NoPen)
if self.icon: self.paintanime(painter)
self.painticon(painter)
else:
self.paintanime(painter)
def mouseReleaseEvent(self, event) -> None: def mouseReleaseEvent(self, event) -> None:
if not self.enable: if not self.enable:
@ -632,7 +611,7 @@ class MySwitch(commonsolveevent):
try: try:
self.checked = not self.checked self.checked = not self.checked
self.clicked.emit(self.checked) self.clicked.emit(self.checked)
self.runanimeorshowicon() self.runanime()
# 父窗口deletelater # 父窗口deletelater
except: except:
pass pass
@ -913,21 +892,17 @@ def D_getIconButton(callback=None, icon="fa.paint-brush", enable=True, qicon=Non
def getcolorbutton( def getcolorbutton(
d, d,
key, key,
callback, callback=None,
name=None, name=None,
parent=None, parent=None,
icon="fa.paint-brush", icon="fa.paint-brush",
constcolor=None, constcolor=None,
enable=True, enable=True,
qicon=None, qicon=None,
sizefixed=False,
): ):
if qicon is None: if qicon is None:
qicon = qtawesome.icon(icon, color=constcolor if constcolor else d[key]) qicon = qtawesome.icon(icon, color=constcolor if constcolor else d[key])
b = IconButton(None, enable=enable, parent=parent, qicon=qicon) b = IconButton(None, enable=enable, parent=parent, qicon=qicon)
sz = int(1.42 * globalconfig["buttonsize2"])
if sizefixed:
b.setFixedSize(QSize(sz, sz))
if callback: if callback:
b.clicked.connect(callback) b.clicked.connect(callback)
if name: if name:
@ -945,7 +920,6 @@ def D_getcolorbutton(
constcolor=None, constcolor=None,
enable=True, enable=True,
qicon=None, qicon=None,
sizefixed=False,
): ):
return lambda: getcolorbutton( return lambda: getcolorbutton(
d, d,
@ -957,7 +931,6 @@ def D_getcolorbutton(
constcolor, constcolor,
enable, enable,
qicon, qicon,
sizefixed,
) )
@ -1621,43 +1594,6 @@ class auto_select_webview(QWidget):
return browser return browser
class threeswitch(QWidget):
btnclicked = pyqtSignal(int)
def selectlayout(self, i):
self.btns[(i + 0) % 3].setEnabled(False)
self.btns[(i + 1) % 3].setEnabled(False)
self.btns[(i + 2) % 3].setEnabled(False)
self.btns[(i + 0) % 3].setChecked(True)
self.btns[(i + 1) % 3].setChecked(False)
self.btns[(i + 2) % 3].setChecked(False)
self.btnclicked.emit(i)
self.btns[(i + 1) % 3].setEnabled(True)
self.btns[(i + 2) % 3].setEnabled(True)
def __init__(self, p, icons):
super().__init__(p)
self.btns = []
for i, icon in enumerate(icons):
btn = statusbutton(
p=self,
icons=icon,
border=False,
colors=["", globalconfig["buttoncolor2"]],
)
btn.clicked.connect(functools.partial(self.selectlayout, i))
btn.setFixedSize(QSize(20, 25))
self.btns.append(btn)
self.setFixedSize(QSize(60, 75))
def resizeEvent(self, a0):
x, y = 0, 0
for btn in self.btns:
btn.move(x, y)
x += btn.width()
return super().resizeEvent(a0)
class threebuttons(QWidget): class threebuttons(QWidget):
btn1clicked = pyqtSignal() btn1clicked = pyqtSignal()
btn2clicked = pyqtSignal() btn2clicked = pyqtSignal()
@ -2402,58 +2338,30 @@ class pixmapviewer(QWidget):
return super().paintEvent(e) return super().paintEvent(e)
class statusbutton(QPushButton):
def __init__(self, icons, colors=None, border=True, p=None):
super().__init__(p)
if colors:
self.colors = colors
else:
self.colors = ["", ""]
if isinstance(icons, str):
self.icons = [icons, icons]
else:
self.icons = icons
self.setCheckable(True)
self.seticon()
self.clicked.connect(self.seticon)
if not border:
self.setStyleSheet("border:transparent")
def seticon(self):
color = QColor(self.colors[self.isChecked()])
if not self.isEnabled():
color = disablecolor(color)
icon = qtawesome.icon(self.icons[self.isChecked()], color=color)
self.setIcon(icon)
def setChecked(self, a0):
super().setChecked(a0)
self.seticon()
def setEnabled(self, _):
super().setEnabled(_)
self.seticon()
class IconButton(QPushButton): class IconButton(QPushButton):
clicked_1 = pyqtSignal() clicked_1 = pyqtSignal()
def sizeHint(self): def event(self, e):
return QSize( if e.type() == QEvent.Type.FontChange:
int(1.42 * globalconfig["buttonsize2"]), h = QFontMetricsF(self.font()).height()
int(1.42 * globalconfig["buttonsize2"]), h = int(h * gobject.Consts.btnscale)
) sz = QSize(h, h)
self.setFixedSize(sz)
self.setIconSize(sz)
elif e.type() == QEvent.Type.EnabledChange:
self.seticon()
return super().event(e)
def __init__(self, icon, enable=True, qicon=None, parent=None): def __init__(self, icon, enable=True, qicon=None, parent=None, checkable=False):
super().__init__(parent) super().__init__(parent)
self._icon = icon self._icon = icon
self.clicked.connect(self.clicked_1) self.clicked.connect(self.clicked_1)
self.clicked.connect(self.seticon)
self._qicon = qicon self._qicon = qicon
self.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed) self.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
self.setCursor(Qt.CursorShape.PointingHandCursor) self.setCursor(Qt.CursorShape.PointingHandCursor)
self.setIconSize(self.sizeHint()) self.setStyleSheet("border:transparent;padding: 0px;")
self.setStyleSheet("border:transparent") self.setCheckable(checkable)
self.setEnabled(enable) self.setEnabled(enable)
self.setFocusPolicy(Qt.FocusPolicy.NoFocus) self.setFocusPolicy(Qt.FocusPolicy.NoFocus)
@ -2461,10 +2369,20 @@ class IconButton(QPushButton):
if self._qicon: if self._qicon:
icon = self._qicon icon = self._qicon
else: else:
__ = QColor(globalconfig["buttoncolor2"]) if self.isCheckable():
if isinstance(self._icon, str):
icons = [self._icon, self._icon]
else:
icons = self._icon
icon = icons[self.isChecked()]
colors = ["", gobject.Consts.buttoncolor]
color = QColor(colors[self.isChecked()])
else:
color = QColor(gobject.Consts.buttoncolor)
icon = self._icon
if not self.isEnabled(): if not self.isEnabled():
__ = disablecolor(__) color = disablecolor(color)
icon: QIcon = qtawesome.icon(self._icon, color=__) icon = qtawesome.icon(icon, color=color)
self.setIcon(icon) self.setIcon(icon)
def setChecked(self, a0): def setChecked(self, a0):
@ -2476,42 +2394,6 @@ class IconButton(QPushButton):
self.seticon() self.seticon()
class LIconLabel(LLabel):
def __init__(self, *argc):
super().__init__(*argc)
self._icon = QIcon()
self._size = QSize()
def setIcon(self, icon: QIcon):
self._icon = icon
self.update()
def setIconSize(self, size: QSize):
self._size = size
self.update()
def paintEvent(self, a0: QPaintEvent) -> None:
painter = QPainter(self)
if self._size.isEmpty():
size = self.size()
else:
size = self._size
rect = QRect(
(self.width() - size.width()) // 2,
(self.height() - size.height()) // 2,
size.width(),
size.height(),
)
self._icon.paint(
painter,
rect,
Qt.AlignmentFlag.AlignCenter,
QIcon.Mode.Normal,
QIcon.State.On,
)
class SplitLine(QFrame): class SplitLine(QFrame):
def __init__(self, *argc): def __init__(self, *argc):
super().__init__(*argc) super().__init__(*argc)
@ -2703,12 +2585,7 @@ class editswitchTextBrowser(QWidget):
l = QHBoxLayout(self) l = QHBoxLayout(self)
l.setContentsMargins(0, 0, 0, 0) l.setContentsMargins(0, 0, 0, 0)
l.addWidget(stack) l.addWidget(stack)
self.switch = statusbutton( self.switch = IconButton(parent=self, icon="fa.edit", checkable=True)
p=self,
icons="fa.edit",
colors=["", globalconfig["buttoncolor2"]],
border=False,
)
self.switch.setFixedSize(QSize(25, 25)) self.switch.setFixedSize(QSize(25, 25))
self.switch.raise_() self.switch.raise_()
self.switch.clicked.connect(stack.setCurrentIndex) self.switch.clicked.connect(stack.setCurrentIndex)

View File

@ -7,7 +7,7 @@ from ocrengines.baseocrclass import baseocr
from qtsymbols import * from qtsymbols import *
from gui.dynalang import LPushButton, LLabel from gui.dynalang import LPushButton, LLabel
from gui.dynalang import LPushButton, LFormLayout, LLabel from gui.dynalang import LPushButton, LFormLayout, LLabel
from gui.usefulwidget import SuperCombo, getboxlayout from gui.usefulwidget import SuperCombo, getboxlayout, IconButton
import threading, qtawesome import threading, qtawesome
from language import Languages from language import Languages
from myutils.subproc import subproc_w from myutils.subproc import subproc_w
@ -97,7 +97,7 @@ def question():
lst.append(combo) lst.append(combo)
lst.append(btninstall) lst.append(btninstall)
threading.Thread(target=loadlist, args=(combo,)).start() threading.Thread(target=loadlist, args=(combo,)).start()
btndownload = QPushButton(icon=qtawesome.icon("fa.question")) btndownload = IconButton("fa.question")
btndownload.clicked.connect( btndownload.clicked.connect(
lambda: gobject.baseobject.openlink( lambda: gobject.baseobject.openlink(
dynamiclink("{docs_server}/#/zh/useapis/ocrapi?id=windowsocr") dynamiclink("{docs_server}/#/zh/useapis/ocrapi?id=windowsocr")

View File

@ -474,6 +474,7 @@ class texthook(basetext):
savehook_new_data[self.gameuid]["title"], "<msg_info_refresh>" savehook_new_data[self.gameuid]["title"], "<msg_info_refresh>"
) )
self.flashembedsettings(pid) self.flashembedsettings(pid)
self.setsettings()
def InsertPCHooks(self, which): def InsertPCHooks(self, which):
for pid in self.pids: for pid in self.pids:

View File

@ -509,8 +509,6 @@
"accept_use_unicode_start": 0, "accept_use_unicode_start": 0,
"accept_use_unicode_end": 65535, "accept_use_unicode_end": 65535,
"buttoncolor": "#2e2eff", "buttoncolor": "#2e2eff",
"buttoncolor2": "#FF69B4",
"buttoncolor3": "#afafaf",
"buttoncolor_1": "#ff03f2", "buttoncolor_1": "#ff03f2",
"premtsimi2": 90, "premtsimi2": 90,
"ocrrangecolor": "#000000", "ocrrangecolor": "#000000",

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "التعرف على الحروف المطبوعة ( متعدد اللغات )", "印刷文字识别(多语种)": "التعرف على الحروف المطبوعة ( متعدد اللغات )",
"通用文字识别 intsig": "التعرف على الحروف العالمية", "通用文字识别 intsig": "التعرف على الحروف العالمية",
"音高": "الملعب", "音高": "الملعب",
"强制直角": "اضطر زاوية الحق" "强制直角": "اضطر زاوية الحق",
"链接": "لينك ."
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "印刷文字識別(多語種)", "印刷文字识别(多语种)": "印刷文字識別(多語種)",
"通用文字识别 intsig": "通用文字識別intsig", "通用文字识别 intsig": "通用文字識別intsig",
"音高": "音高", "音高": "音高",
"强制直角": "強制直角" "强制直角": "強制直角",
"链接": "鏈接"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "Rozpoznávání tisku textu (vícejazyčné)", "印刷文字识别(多语种)": "Rozpoznávání tisku textu (vícejazyčné)",
"通用文字识别 intsig": "Univerzální rozpoznávání textu Intsig", "通用文字识别 intsig": "Univerzální rozpoznávání textu Intsig",
"音高": "výška", "音高": "výška",
"强制直角": "Vynucený pravý úhel" "强制直角": "Vynucený pravý úhel",
"链接": "odkaz"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "Drucktexterkennung (mehrsprachig)", "印刷文字识别(多语种)": "Drucktexterkennung (mehrsprachig)",
"通用文字识别 intsig": "Universelle Texterkennung Intsig", "通用文字识别 intsig": "Universelle Texterkennung Intsig",
"音高": "Tonhöhe", "音高": "Tonhöhe",
"强制直角": "Rechter Winkel erzwungen" "强制直角": "Rechter Winkel erzwungen",
"链接": "Link"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "Printing text recognition (multilingual)", "印刷文字识别(多语种)": "Printing text recognition (multilingual)",
"通用文字识别 intsig": "Universal Text Recognition Intsig", "通用文字识别 intsig": "Universal Text Recognition Intsig",
"音高": "pitch", "音高": "pitch",
"强制直角": "Forced right angle" "强制直角": "Forced right angle",
"链接": "link"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "Reconocimiento de texto impreso (multilingüe)", "印刷文字识别(多语种)": "Reconocimiento de texto impreso (multilingüe)",
"通用文字识别 intsig": "Reconocimiento de texto universal intsig", "通用文字识别 intsig": "Reconocimiento de texto universal intsig",
"音高": "Tono", "音高": "Tono",
"强制直角": "ángulo recto forzado" "强制直角": "ángulo recto forzado",
"链接": "Enlaces"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "Reconnaissance de texte imprimée (multilingue)", "印刷文字识别(多语种)": "Reconnaissance de texte imprimée (multilingue)",
"通用文字识别 intsig": "Reconnaissance de texte générique intsig", "通用文字识别 intsig": "Reconnaissance de texte générique intsig",
"音高": "Hauteur de ton", "音高": "Hauteur de ton",
"强制直角": "Angle droit forcé" "强制直角": "Angle droit forcé",
"链接": "Liens"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "Riconoscimento del testo stampato (multilingue)", "印刷文字识别(多语种)": "Riconoscimento del testo stampato (multilingue)",
"通用文字识别 intsig": "Riconoscimento universale del testo Intsig", "通用文字识别 intsig": "Riconoscimento universale del testo Intsig",
"音高": "pitch", "音高": "pitch",
"强制直角": "Angolo retto forzato" "强制直角": "Angolo retto forzato",
"链接": "link"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "印刷文字認識(多言語)", "印刷文字识别(多语种)": "印刷文字認識(多言語)",
"通用文字识别 intsig": "共通文字認識intsig", "通用文字识别 intsig": "共通文字認識intsig",
"音高": "おんきょうのたかさ", "音高": "おんきょうのたかさ",
"强制直角": "きょうせいちょつかく" "强制直角": "きょうせいちょつかく",
"链接": "リンク#リンク#"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "인쇄 문자 인식 (다국어)", "印刷文字识别(多语种)": "인쇄 문자 인식 (다국어)",
"通用文字识别 intsig": "일반 문자 인식 intsig", "通用文字识别 intsig": "일반 문자 인식 intsig",
"音高": "음고", "音高": "음고",
"强制直角": "강제 직각" "强制直角": "강제 직각",
"链接": "링크"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "Tekstherkenning afdrukken (meertalig)", "印刷文字识别(多语种)": "Tekstherkenning afdrukken (meertalig)",
"通用文字识别 intsig": "Universele tekstherkenning Intsig", "通用文字识别 intsig": "Universele tekstherkenning Intsig",
"音高": "toonhoogte", "音高": "toonhoogte",
"强制直角": "Regte hoek dwingen" "强制直角": "Regte hoek dwingen",
"链接": "link"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "Rozpoznawanie tekstu drukowania (wielojęzyczne)", "印刷文字识别(多语种)": "Rozpoznawanie tekstu drukowania (wielojęzyczne)",
"通用文字识别 intsig": "Uniwersalne rozpoznawanie tekstu Intsig", "通用文字识别 intsig": "Uniwersalne rozpoznawanie tekstu Intsig",
"音高": "stopień", "音高": "stopień",
"强制直角": "Wymuszony kąt prosty" "强制直角": "Wymuszony kąt prosty",
"链接": "link"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "Impressão de reconhecimento de texto (multilingue)", "印刷文字识别(多语种)": "Impressão de reconhecimento de texto (multilingue)",
"通用文字识别 intsig": "Intsig de Reconhecimento Universal de Texto", "通用文字识别 intsig": "Intsig de Reconhecimento Universal de Texto",
"音高": "pitch", "音高": "pitch",
"强制直角": "Ângulo reto forçado" "强制直角": "Ângulo reto forçado",
"链接": "link"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "Распознавание печатного текста (многоязычие)", "印刷文字识别(多语种)": "Распознавание печатного текста (многоязычие)",
"通用文字识别 intsig": "Универсальное распознавание текста intsig", "通用文字识别 intsig": "Универсальное распознавание текста intsig",
"音高": "Высота звука", "音高": "Высота звука",
"强制直角": "Обязательный прямой угол" "强制直角": "Обязательный прямой угол",
"链接": "Ссылки"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "Skriva ut textigenkänning (flerspråkig)", "印刷文字识别(多语种)": "Skriva ut textigenkänning (flerspråkig)",
"通用文字识别 intsig": "Universal textigenkänning Intsig", "通用文字识别 intsig": "Universal textigenkänning Intsig",
"音高": "pitch", "音高": "pitch",
"强制直角": "Tvingad rätvinkel" "强制直角": "Tvingad rätvinkel",
"链接": "länk"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "การจดจำคำพิมพ์ (หลายภาษา)", "印刷文字识别(多语种)": "การจดจำคำพิมพ์ (หลายภาษา)",
"通用文字识别 intsig": "การจดจำคำทั่วไป intsig", "通用文字识别 intsig": "การจดจำคำทั่วไป intsig",
"音高": "ระดับเสียง", "音高": "ระดับเสียง",
"强制直角": "บังคับมุมขวา" "强制直角": "บังคับมุมขวา",
"链接": "ลิงค์"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "Metin tanımlaması (çoklu dil)", "印刷文字识别(多语种)": "Metin tanımlaması (çoklu dil)",
"通用文字识别 intsig": "Universal Text Recognition Intsig", "通用文字识别 intsig": "Universal Text Recognition Intsig",
"音高": "Piç", "音高": "Piç",
"强制直角": "Güçlü sağ açı" "强制直角": "Güçlü sağ açı",
"链接": "bağ"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "Друк розпізнавання тексту (багатомове)", "印刷文字识别(多语种)": "Друк розпізнавання тексту (багатомове)",
"通用文字识别 intsig": "Універсальне розпізнавання тексту Intsig", "通用文字识别 intsig": "Універсальне розпізнавання тексту Intsig",
"音高": "виставка", "音高": "виставка",
"强制直角": "Примусовий правий кут" "强制直角": "Примусовий правий кут",
"链接": "посилання"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "Nhận dạng văn bản in (đa ngôn ngữ)", "印刷文字识别(多语种)": "Nhận dạng văn bản in (đa ngôn ngữ)",
"通用文字识别 intsig": "Nhận dạng văn bản chung intsig", "通用文字识别 intsig": "Nhận dạng văn bản chung intsig",
"音高": "Cao độ", "音高": "Cao độ",
"强制直角": "Buộc góc phải" "强制直角": "Buộc góc phải",
"链接": "Liên kết"
} }

View File

@ -767,5 +767,6 @@
"印刷文字识别(多语种)": "", "印刷文字识别(多语种)": "",
"通用文字识别 intsig": "", "通用文字识别 intsig": "",
"音高": "", "音高": "",
"强制直角": "" "强制直角": "",
"链接": ""
} }