mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
update
This commit is contained in:
parent
7df03810a1
commit
95877df877
@ -79,7 +79,7 @@ def setTab7(self):
|
||||
def getcomparelayout(self):
|
||||
|
||||
layout = QHBoxLayout()
|
||||
fromtext =QPlainTextEdit()
|
||||
fromtext = QPlainTextEdit()
|
||||
totext = QPlainTextEdit()
|
||||
solvebutton = getcolorbutton(
|
||||
globalconfig,
|
||||
@ -113,28 +113,27 @@ def setTab7_lazy(self):
|
||||
|
||||
def changerank(item, up):
|
||||
|
||||
ii = sortlist.index(item)
|
||||
if up and ii == 0:
|
||||
return
|
||||
if up == False and ii == len(sortlist) - 1:
|
||||
idx = sortlist.index(item)
|
||||
idx2 = idx + (-1 if up else 1)
|
||||
if idx2 < 0 or idx2 >= len(sortlist):
|
||||
return
|
||||
headoffset = 1
|
||||
toexchangei = ii + (-1 if up else 1)
|
||||
sortlist[ii], sortlist[toexchangei] = sortlist[toexchangei], sortlist[ii]
|
||||
for i, ww in enumerate(savelist[ii + headoffset]):
|
||||
idx2 = idx + (-1 if up else 1)
|
||||
sortlist[idx], sortlist[idx2] = sortlist[idx2], sortlist[idx]
|
||||
for i, ww in enumerate(savelist[idx + headoffset]):
|
||||
|
||||
w1 = savelay[0].indexOf(ww)
|
||||
w2 = savelay[0].indexOf(savelist[toexchangei + headoffset][i])
|
||||
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[toexchangei + headoffset][i])
|
||||
savelay[0].removeWidget(savelist[idx2 + headoffset][i])
|
||||
|
||||
savelay[0].addWidget(savelist[toexchangei + headoffset][i], *p1)
|
||||
savelay[0].addWidget(savelist[idx2 + headoffset][i], *p1)
|
||||
savelay[0].addWidget(ww, *p2)
|
||||
savelist[ii + headoffset], savelist[toexchangei + headoffset] = (
|
||||
savelist[toexchangei + headoffset],
|
||||
savelist[ii + headoffset],
|
||||
savelist[idx + headoffset], savelist[idx2 + headoffset] = (
|
||||
savelist[idx2 + headoffset],
|
||||
savelist[idx + headoffset],
|
||||
)
|
||||
|
||||
for i, post in enumerate(sortlist):
|
||||
|
@ -60,14 +60,14 @@ class dialog_toolbutton(QDialog):
|
||||
super().__init__(parent, Qt.WindowCloseButtonHint)
|
||||
self.setWindowTitle(_TR("窗口按钮设置"))
|
||||
model = QStandardItemModel()
|
||||
model.setHorizontalHeaderLabels(_TRL(["显示", "图标", "图标2", "说明"]))
|
||||
model.setHorizontalHeaderLabels(
|
||||
_TRL(["显示", "", "", "对齐", "图标", "图标2", "说明"])
|
||||
)
|
||||
|
||||
layout = QVBoxLayout(self) #
|
||||
self.model = model
|
||||
|
||||
table = QTableView()
|
||||
table.setDragEnabled(True)
|
||||
table.setAcceptDrops(True)
|
||||
|
||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
|
||||
table.horizontalHeader().setStretchLastSection(True)
|
||||
@ -77,13 +77,31 @@ class dialog_toolbutton(QDialog):
|
||||
table.setWordWrap(False)
|
||||
table.setModel(model)
|
||||
self.table = table
|
||||
for row, k in enumerate(globalconfig["toolbutton"]["rank"]):
|
||||
for row, k in enumerate(globalconfig["toolbutton"]["rank2"]):
|
||||
self.newline(row, k)
|
||||
layout.addWidget(table)
|
||||
|
||||
self.resize(QSize(800, 400))
|
||||
self.show()
|
||||
|
||||
def changerank2(self, key, up):
|
||||
idx = globalconfig["toolbutton"]["rank2"].index(key)
|
||||
idx2 = idx + (-1 if up else 1)
|
||||
if idx2 < 0 or idx2 >= len(globalconfig["toolbutton"]["rank2"]):
|
||||
return
|
||||
idx2 = idx + (-1 if up else 1)
|
||||
(
|
||||
globalconfig["toolbutton"]["rank2"][idx],
|
||||
globalconfig["toolbutton"]["rank2"][idx2],
|
||||
) = (
|
||||
globalconfig["toolbutton"]["rank2"][idx2],
|
||||
globalconfig["toolbutton"]["rank2"][idx],
|
||||
)
|
||||
|
||||
self.model.removeRow(idx2)
|
||||
self.newline(idx, globalconfig["toolbutton"]["rank2"][idx]),
|
||||
gobject.baseobject.translation_ui.adjustbuttons()
|
||||
|
||||
def newline(self, row, k):
|
||||
if "belong" in globalconfig["toolbutton"]["buttons"][k]:
|
||||
belong = (
|
||||
@ -97,6 +115,9 @@ class dialog_toolbutton(QDialog):
|
||||
self.model.insertRow(
|
||||
row,
|
||||
[
|
||||
QStandardItem(),
|
||||
QStandardItem(),
|
||||
QStandardItem(),
|
||||
QStandardItem(),
|
||||
QStandardItem(),
|
||||
QStandardItem(),
|
||||
@ -110,12 +131,43 @@ class dialog_toolbutton(QDialog):
|
||||
getsimpleswitch(
|
||||
globalconfig["toolbutton"]["buttons"][k],
|
||||
"use",
|
||||
callback=lambda _: gobject.baseobject.translation_ui.showhidetoolbuttons(),
|
||||
callback=lambda _: gobject.baseobject.translation_ui.adjustbuttons(),
|
||||
),
|
||||
)
|
||||
button_up = getcolorbutton(
|
||||
globalconfig,
|
||||
"",
|
||||
callback=functools.partial(self.changerank2, k, True),
|
||||
icon="fa.arrow-up",
|
||||
constcolor="#FF69B4",
|
||||
)
|
||||
button_down = getcolorbutton(
|
||||
globalconfig,
|
||||
"",
|
||||
callback=functools.partial(self.changerank2, k, False),
|
||||
icon="fa.arrow-down",
|
||||
constcolor="#FF69B4",
|
||||
)
|
||||
self.table.setIndexWidget(
|
||||
self.model.index(row, 1),
|
||||
button_up,
|
||||
)
|
||||
self.table.setIndexWidget(
|
||||
self.model.index(row, 2),
|
||||
button_down,
|
||||
)
|
||||
|
||||
self.table.setIndexWidget(
|
||||
self.model.index(row, 1),
|
||||
self.model.index(row, 3),
|
||||
getsimplecombobox(
|
||||
["居左", "居右", "居中"],
|
||||
globalconfig["toolbutton"]["buttons"][k],
|
||||
"align",
|
||||
callback=lambda _: gobject.baseobject.translation_ui.adjustbuttons(),
|
||||
),
|
||||
)
|
||||
self.table.setIndexWidget(
|
||||
self.model.index(row, 4),
|
||||
getcolorbutton(
|
||||
"",
|
||||
"",
|
||||
@ -130,7 +182,7 @@ class dialog_toolbutton(QDialog):
|
||||
)
|
||||
if "icon2" in globalconfig["toolbutton"]["buttons"][k]:
|
||||
self.table.setIndexWidget(
|
||||
self.model.index(row, 2),
|
||||
self.model.index(row, 5),
|
||||
getcolorbutton(
|
||||
"",
|
||||
"",
|
||||
|
@ -11,6 +11,7 @@ from PyQt5.QtWidgets import (
|
||||
QTabWidget,
|
||||
QFileDialog,
|
||||
QTabBar,
|
||||
QSplitter,
|
||||
QLabel,
|
||||
)
|
||||
from myutils.hwnd import grabwindow
|
||||
@ -172,6 +173,7 @@ class AnkiWindow(QWidget):
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||
self.setWindowTitle("Anki Connect")
|
||||
self.currentword = ""
|
||||
self.tabs = QTabWidget()
|
||||
@ -798,18 +800,25 @@ class searchwordW(closeashidewindow):
|
||||
self.cache_results = {}
|
||||
self.hiding = True
|
||||
|
||||
self.spliter = QSplitter()
|
||||
|
||||
tablayout = QVBoxLayout()
|
||||
tablayout.addWidget(self.tab)
|
||||
tablayout.addWidget(self.textOutput)
|
||||
tablayout.setContentsMargins(0, 0, 0, 0)
|
||||
tablayout.setSpacing(0)
|
||||
self.vboxlayout.addLayout(tablayout)
|
||||
tablayout.addWidget(self.tab)
|
||||
tablayout.addWidget(self.textOutput)
|
||||
w = QWidget()
|
||||
w.setLayout(tablayout)
|
||||
self.vboxlayout.addWidget(self.spliter)
|
||||
self.isfirstshowanki = True
|
||||
self.spliter.setOrientation(Qt.Vertical)
|
||||
|
||||
self.spliter.addWidget(w)
|
||||
|
||||
def onceaddankiwindow(self, idx):
|
||||
if idx == 1:
|
||||
if self.isfirstshowanki:
|
||||
self.vboxlayout.addWidget(self.ankiwindow)
|
||||
self.spliter.addWidget(self.ankiwindow)
|
||||
else:
|
||||
self.ankiwindow.show()
|
||||
else:
|
||||
|
@ -1,4 +1,4 @@
|
||||
from PyQt5.QtCore import Qt, QPoint, QPointF
|
||||
from PyQt5.QtCore import Qt, QPoint, QPointF, pyqtSignal
|
||||
from PyQt5.QtGui import (
|
||||
QTextCharFormat,
|
||||
QTextBlockFormat,
|
||||
@ -178,41 +178,36 @@ class BorderedLabel(ShadowLabel):
|
||||
painter.drawPixmap(0, 0, self._pix)
|
||||
|
||||
|
||||
class Textbrowser:
|
||||
def movep(self, x, y):
|
||||
self.savey = y
|
||||
self.atback.move(0, int(y))
|
||||
if globalconfig["isshowhira"] and globalconfig["isshowrawtext"]:
|
||||
if self.jiaming_y_delta > 0:
|
||||
y = y + self.jiaming_y_delta
|
||||
self.textbrowser.move(int(x), int(y))
|
||||
class Textbrowser(QLabel):
|
||||
contentsChanged = pyqtSignal(int, int)
|
||||
|
||||
self.atback2.move(0, int(y))
|
||||
self.toplabel2.move(0, int(y))
|
||||
def move(self, x, y):
|
||||
super().move(x, y)
|
||||
self.textbrowser.move(x, y)
|
||||
|
||||
self.atback2.move(x, y)
|
||||
self.toplabel2.move(x, y)
|
||||
|
||||
def resizeEvent(self, event):
|
||||
self.atback2.resize(event.size())
|
||||
self.toplabel2.resize(event.size())
|
||||
|
||||
def contentchangedfunction(self):
|
||||
sz = self.textbrowser.document().size().toSize()
|
||||
self.textbrowser.resize(self.width(), sz.height())
|
||||
self.contentsChanged.emit(sz.width(), sz.height())
|
||||
|
||||
def __init__(self, parent):
|
||||
self.parent = parent
|
||||
self.savey = 0
|
||||
# self.shadowlabel=QLabel(parent)
|
||||
# self.shadowlabel.savetext=''
|
||||
self.align = False
|
||||
super().__init__(parent)
|
||||
|
||||
self.atback = QLabel(parent)
|
||||
|
||||
self.atback.setMouseTracking(True)
|
||||
self.setMouseTracking(True)
|
||||
|
||||
self.atback2 = QLabel(parent)
|
||||
|
||||
self.toplabel2 = QLabel(parent)
|
||||
self.atback2.setMouseTracking(True)
|
||||
self.textbrowser = QTextBrowser(parent)
|
||||
|
||||
def __resizeevent(event: QResizeEvent):
|
||||
self.atback.resize(event.size())
|
||||
self.atback2.resize(event.size())
|
||||
self.toplabel2.resize(event.size())
|
||||
|
||||
self.textbrowser.resizeEvent = __resizeevent
|
||||
self.textbrowser.document().contentsChanged.connect(self.contentchangedfunction)
|
||||
self.tranparentcolor = QColor()
|
||||
self.tranparentcolor.setAlpha(0)
|
||||
self.textbrowser.setTextColor(self.tranparentcolor)
|
||||
@ -244,7 +239,6 @@ class Textbrowser:
|
||||
self.yinyingpos = 0
|
||||
self.yinyingposline = 0
|
||||
self.lastcolor = None
|
||||
self.jiaming_y_delta = 0
|
||||
self.setselectable()
|
||||
self.blockcount = 0
|
||||
self.iteryinyinglabelsave = {}
|
||||
@ -252,15 +246,6 @@ class Textbrowser:
|
||||
def setselectable(self):
|
||||
self.masklabel.setHidden(globalconfig["selectable"])
|
||||
|
||||
def setStyleSheet(self, x):
|
||||
self.atback.setStyleSheet(x)
|
||||
|
||||
def document(self):
|
||||
return self.textbrowser.document()
|
||||
|
||||
def resize(self, _1, _2):
|
||||
self.textbrowser.resize(int(_1), int(_2))
|
||||
|
||||
def setnextfont(self, origin):
|
||||
if origin:
|
||||
self.font.setFamily(globalconfig["fonttype"])
|
||||
@ -277,19 +262,8 @@ class Textbrowser:
|
||||
c.setCharFormat(f)
|
||||
self.textbrowser.setTextCursor(c)
|
||||
|
||||
def setGeometry(self, _1, _2, _3, _4):
|
||||
self.textbrowser.setGeometry(_1, _2, _3, _4)
|
||||
|
||||
self.savey = _2
|
||||
# self.shadowlabel.setGeometry(_1,_2,_3,_4)
|
||||
# self.shadowlabel.resize(_3,_4)
|
||||
|
||||
def setAlignment(self, x):
|
||||
self.textbrowser.setAlignment(x)
|
||||
if Qt.AlignCenter == x:
|
||||
self.align = True
|
||||
else:
|
||||
self.align = False
|
||||
|
||||
def append(self, x, tag, color):
|
||||
if self.cleared:
|
||||
@ -317,8 +291,6 @@ class Textbrowser:
|
||||
if len(tag) > 0:
|
||||
self.addtag(tag)
|
||||
|
||||
self.movep(0, self.savey)
|
||||
|
||||
self.showyinyingtext(b1, b2, color)
|
||||
|
||||
def getcurrpointer(self):
|
||||
@ -429,7 +401,8 @@ class Textbrowser:
|
||||
idx = 0
|
||||
guesswidth = []
|
||||
guesslinehead = None
|
||||
wwww = self.parent.width()
|
||||
wwww = self.width()
|
||||
heigth, __, _ = self.getfh(False)
|
||||
for word in x:
|
||||
idx += 1
|
||||
l = len(word["orig"])
|
||||
@ -473,14 +446,14 @@ class Textbrowser:
|
||||
guesswidth1 = gw * len(word["orig"])
|
||||
tailx = wwww - guesslinehead
|
||||
pos1 = (
|
||||
tl1.x() + 2,
|
||||
tl1.x(),
|
||||
tl1.y(),
|
||||
tailx - tl1.x() - 4,
|
||||
tl4.y() - tl1.y(),
|
||||
tailx - tl1.x(),
|
||||
heigth,
|
||||
)
|
||||
xx = int(guesswidth1 - (tailx - tl1.x()))
|
||||
guesslinehead = None
|
||||
pos2 = tl3.x() - xx + 2, tl3.y(), xx - 4, tl4.y() - tl1.y()
|
||||
pos2 = tl3.x() - xx, tl3.y(), xx, heigth
|
||||
if (
|
||||
globalconfig["usesearchword"]
|
||||
or globalconfig["usecopyword"]
|
||||
@ -526,10 +499,10 @@ class Textbrowser:
|
||||
len(word["orig"])
|
||||
)
|
||||
pos1 = (
|
||||
tl1.x() + 2,
|
||||
tl1.x(),
|
||||
tl1.y(),
|
||||
tl2.x() - tl1.x() - 4,
|
||||
tl2.y() - tl1.y(),
|
||||
tl2.x() - tl1.x(),
|
||||
heigth,
|
||||
)
|
||||
if (
|
||||
globalconfig["usesearchword"]
|
||||
@ -585,30 +558,21 @@ class Textbrowser:
|
||||
font.setPointSizeF((globalconfig["fontsize"]))
|
||||
fm = QFontMetricsF(font)
|
||||
|
||||
fhall = fm.height()
|
||||
|
||||
return fhall, font
|
||||
return fm.height(), fm.ascent(), font
|
||||
|
||||
def addtag(self, x):
|
||||
pos = 0
|
||||
|
||||
fhall, fontorig = self.getfh(False)
|
||||
fhhalf, fonthira = self.getfh(True)
|
||||
fasall, _, fontorig = self.getfh(False)
|
||||
fha, fascent, fonthira = self.getfh(True)
|
||||
for i in range(0, self.textbrowser.document().blockCount()):
|
||||
b = self.textbrowser.document().findBlockByNumber(i)
|
||||
|
||||
tf = b.blockFormat()
|
||||
tf.setLineHeight(fhall + fhhalf, QTextBlockFormat.FixedHeight)
|
||||
|
||||
tf.setLineHeight(fasall + fha, QTextBlockFormat.FixedHeight)
|
||||
self.textcursor.setPosition(b.position())
|
||||
self.textcursor.setBlockFormat(tf)
|
||||
self.textbrowser.setTextCursor(self.textcursor)
|
||||
if i == 0:
|
||||
tl1 = self.textbrowser.cursorRect(self.textcursor).topLeft().y()
|
||||
|
||||
if self.jiaming_y_delta + tl1 - fhhalf != 0:
|
||||
self.jiaming_y_delta = fhhalf - tl1
|
||||
self.movep(0, self.savey)
|
||||
x = self.nearmerge(x, pos, fonthira, fontorig)
|
||||
self.settextposcursor(pos)
|
||||
for word in x:
|
||||
@ -626,7 +590,7 @@ class Textbrowser:
|
||||
if word["orig"] == " ":
|
||||
continue
|
||||
self.savetaglabels.append(
|
||||
self.solvejiaminglabel(word, fonthira, tl1, tl2, fhhalf)
|
||||
self.solvejiaminglabel(word, fonthira, tl1, tl2, fascent)
|
||||
)
|
||||
|
||||
def settextposcursor(self, pos):
|
||||
@ -730,9 +694,8 @@ class Textbrowser:
|
||||
|
||||
def solvejiaminglabel(self, word, font, tl1, tl2, fh):
|
||||
_ = self.guesscreatelabel(
|
||||
self.parent, globalconfig["jiamingcolor"], rate=globalconfig["kanarate"]
|
||||
self.atback2, globalconfig["jiamingcolor"], rate=globalconfig["kanarate"]
|
||||
)
|
||||
|
||||
_.setText(word["hira"])
|
||||
_.setFont(font)
|
||||
_.adjustSize()
|
||||
@ -750,8 +713,6 @@ class Textbrowser:
|
||||
else:
|
||||
x = tl1.x() / 2 + tl2.x() / 2 - w / 2
|
||||
y = tl2.y() - fh
|
||||
y += globalconfig["buttonsize"] * 1.5
|
||||
y += self.jiaming_y_delta
|
||||
|
||||
_.move(QPoint(int(x), int(y)))
|
||||
|
||||
|
@ -318,8 +318,7 @@ class QUnFrameWindow(resizableframeless):
|
||||
onstatecolor = "#FF69B4"
|
||||
|
||||
self._TitleLabel.setFixedHeight(int(globalconfig["buttonsize"] * 1.5))
|
||||
for i in range(len(self.buttons)):
|
||||
name = self.buttons[i].name
|
||||
for name in self.buttons:
|
||||
if name in colorstate:
|
||||
color = (
|
||||
onstatecolor if colorstate[name] else globalconfig["buttoncolor"]
|
||||
@ -334,23 +333,20 @@ class QUnFrameWindow(resizableframeless):
|
||||
)
|
||||
else:
|
||||
icon = globalconfig["toolbutton"]["buttons"][name]["icon"]
|
||||
self.buttons[i].setIcon(qtawesome.icon(icon, color=color)) # (icon[i])
|
||||
self.buttons[i].resize(
|
||||
self.buttons[name].setIcon(qtawesome.icon(icon, color=color)) # (icon[i])
|
||||
self.buttons[name].resize(
|
||||
int(globalconfig["buttonsize"] * 2),
|
||||
int(globalconfig["buttonsize"] * 1.5),
|
||||
)
|
||||
|
||||
if self.buttons[i].adjast:
|
||||
self.buttons[i].adjast()
|
||||
self.buttons[i].setIconSize(
|
||||
self.buttons[name].setIconSize(
|
||||
QSize(globalconfig["buttonsize"], globalconfig["buttonsize"])
|
||||
)
|
||||
self.showhidetoolbuttons()
|
||||
self.translate_text.movep(0, globalconfig["buttonsize"] * 1.5)
|
||||
self.textAreaChanged()
|
||||
self.translate_text.move(0, int(globalconfig["buttonsize"] * 1.5))
|
||||
self.setMinimumHeight(int(globalconfig["buttonsize"] * 1.5 + 10))
|
||||
self.setMinimumWidth(globalconfig["buttonsize"] * 2)
|
||||
self.set_color_transparency()
|
||||
self.adjustbuttons()
|
||||
|
||||
def ocr_once_function(self):
|
||||
@threader
|
||||
@ -474,7 +470,6 @@ class QUnFrameWindow(resizableframeless):
|
||||
("minmize", self.hide_),
|
||||
("quit", self.close),
|
||||
)
|
||||
adjast = {"minmize": -2, "quit": -1}
|
||||
_type = {"quit": 2}
|
||||
|
||||
for btn, func in functions:
|
||||
@ -483,12 +478,10 @@ class QUnFrameWindow(resizableframeless):
|
||||
if "belong" in globalconfig["toolbutton"]["buttons"][btn]
|
||||
else None
|
||||
)
|
||||
_adjast = adjast[btn] if btn in adjast else 0
|
||||
tp = _type[btn] if btn in _type else 1
|
||||
self.takusanbuttons(
|
||||
tp,
|
||||
func,
|
||||
_adjast,
|
||||
globalconfig["toolbutton"]["buttons"][btn]["tip"],
|
||||
btn,
|
||||
belong,
|
||||
@ -518,7 +511,7 @@ class QUnFrameWindow(resizableframeless):
|
||||
self.isfirstshow = False
|
||||
self.setontopthread()
|
||||
self.refreshtoolicon()
|
||||
|
||||
|
||||
return super().showEvent(a0)
|
||||
|
||||
def canceltop(self):
|
||||
@ -648,17 +641,14 @@ class QUnFrameWindow(resizableframeless):
|
||||
self.mousetransparent = False
|
||||
self.backtransparent = False
|
||||
self.isbindedwindow = False
|
||||
self.buttons = []
|
||||
self.stylebuttons = {}
|
||||
self.buttons = {}
|
||||
self.showbuttons = []
|
||||
self.stylebuttons = {}
|
||||
self.saveiterclasspointer = {}
|
||||
self.addbuttons()
|
||||
self.translate_text = Textbrowser(self)
|
||||
|
||||
# 翻译框根据内容自适应大小
|
||||
self.document = self.translate_text.document()
|
||||
|
||||
self.document.contentsChanged.connect(self.textAreaChanged)
|
||||
self.translate_text.contentsChanged.connect(self.textAreaChanged)
|
||||
self.thistimenotsetop = False
|
||||
|
||||
def createborderradiusstring(self, r, merge, top=False):
|
||||
@ -889,12 +879,13 @@ class QUnFrameWindow(resizableframeless):
|
||||
globalconfig["locktools"] = not globalconfig["locktools"]
|
||||
self.refreshtoolicon()
|
||||
|
||||
def textAreaChanged(self):
|
||||
def textAreaChanged(self, w, h):
|
||||
|
||||
if globalconfig["fixedheight"]:
|
||||
return
|
||||
if self.translate_text.cleared:
|
||||
return
|
||||
newHeight = self.document.size().height()
|
||||
newHeight = h
|
||||
width = self.width()
|
||||
self.resize(
|
||||
width,
|
||||
@ -930,7 +921,7 @@ class QUnFrameWindow(resizableframeless):
|
||||
|
||||
def toolbarhidedelay(self):
|
||||
|
||||
for button in self.buttons:
|
||||
for button in self.buttons.values():
|
||||
button.hide()
|
||||
self._TitleLabel.hide()
|
||||
self.set_color_transparency()
|
||||
@ -940,7 +931,7 @@ class QUnFrameWindow(resizableframeless):
|
||||
|
||||
def enterfunction(self):
|
||||
|
||||
for button in self.buttons[-2:] + self.showbuttons:
|
||||
for button in self.showbuttons:
|
||||
button.show()
|
||||
self._TitleLabel.show()
|
||||
|
||||
@ -964,16 +955,17 @@ class QUnFrameWindow(resizableframeless):
|
||||
height = self.height() - wh
|
||||
|
||||
self.translate_text.resize(self.width(), height)
|
||||
for button in self.buttons[-2:]:
|
||||
button.adjast()
|
||||
# 自定义窗口调整大小事件
|
||||
self.adjustbuttons()
|
||||
self._TitleLabel.setFixedWidth(self.width())
|
||||
|
||||
def showhidetoolbuttons(self):
|
||||
showed = 0
|
||||
self.showbuttons = []
|
||||
|
||||
for i, button in enumerate(self.buttons[:-2]):
|
||||
def adjustbuttons(self):
|
||||
left = []
|
||||
right = []
|
||||
center = []
|
||||
self.showbuttons.clear()
|
||||
__ = [left, right, center]
|
||||
for name in globalconfig["toolbutton"]["rank2"]:
|
||||
button = self.buttons[name]
|
||||
if button.belong:
|
||||
hide = True
|
||||
for k in button.belong:
|
||||
@ -987,17 +979,29 @@ class QUnFrameWindow(resizableframeless):
|
||||
button.hide()
|
||||
continue
|
||||
if (
|
||||
button.name in globalconfig["toolbutton"]["buttons"]
|
||||
and globalconfig["toolbutton"]["buttons"][button.name]["use"] == False
|
||||
name in globalconfig["toolbutton"]["buttons"]
|
||||
and globalconfig["toolbutton"]["buttons"][name]["use"] == False
|
||||
):
|
||||
button.hide()
|
||||
continue
|
||||
|
||||
button.move(showed * button.width(), 0)
|
||||
__[globalconfig["toolbutton"]["buttons"][name]["align"]].append(button)
|
||||
self.showbuttons.append(button)
|
||||
# button.show()
|
||||
showed += 1
|
||||
self.enterEvent(None)
|
||||
|
||||
leftmax = 0
|
||||
rightmax = self.width()
|
||||
for button in left:
|
||||
button.move(leftmax, 0)
|
||||
leftmax += button.width()
|
||||
for button in reversed(right):
|
||||
rightmax -= button.width()
|
||||
button.move(rightmax, 0)
|
||||
sumwidth = 0
|
||||
for button in center:
|
||||
sumwidth += button.width()
|
||||
leftstart = leftmax + (rightmax - leftmax - sumwidth) / 2
|
||||
for button in center:
|
||||
button.move(leftstart, 0)
|
||||
leftstart += button.width()
|
||||
|
||||
def callwrap(self, call, _):
|
||||
try:
|
||||
@ -1005,9 +1009,7 @@ class QUnFrameWindow(resizableframeless):
|
||||
except:
|
||||
print_exc()
|
||||
|
||||
def takusanbuttons(
|
||||
self, _type, clickfunc, adjast=None, tips=None, save=None, belong=None
|
||||
):
|
||||
def takusanbuttons(self, _type, clickfunc, tips, name, belong=None):
|
||||
|
||||
button = QPushButton(self)
|
||||
if tips:
|
||||
@ -1020,15 +1022,8 @@ class QUnFrameWindow(resizableframeless):
|
||||
else:
|
||||
button.lower()
|
||||
|
||||
button.name = save
|
||||
button.belong = belong
|
||||
if adjast < 0:
|
||||
button.adjast = lambda: button.move(
|
||||
self.width() + adjast * button.width(), 0
|
||||
)
|
||||
else:
|
||||
button.adjast = None
|
||||
self.buttons.append(button)
|
||||
self.buttons[name] = button
|
||||
|
||||
def closeEvent(self, a0) -> None:
|
||||
if self.fullscreenmanager:
|
||||
|
@ -645,6 +645,9 @@ class auto_select_webview(QWidget):
|
||||
print("file://" + self.lastcachehtml.replace("\\", "/"))
|
||||
self.internal.navigate("file://" + self.lastcachehtml.replace("\\", "/"))
|
||||
|
||||
def sizeHint(self):
|
||||
return QSize(256, 192)
|
||||
|
||||
def clearcache(self):
|
||||
if self.lastcachehtml and os.path.exists(self.lastcachehtml):
|
||||
lastcachehtml = self.lastcachehtml
|
||||
|
@ -181,13 +181,15 @@ if ocrerrorfix == {}:
|
||||
ocrerrorfix = ocrerrorfixdefault
|
||||
syncconfig(postprocessconfig, defaultpost, True, 3)
|
||||
|
||||
if len(globalconfig["toolbutton"]["rank"]) != len(
|
||||
globalconfig["toolbutton"]["buttons"].keys()
|
||||
):
|
||||
globalconfig["toolbutton"]["rank"] += list(
|
||||
set(globalconfig["toolbutton"]["buttons"].keys())
|
||||
- set(globalconfig["toolbutton"]["rank"])
|
||||
)
|
||||
for key in defaultglobalconfig["toolbutton"]["buttons"]:
|
||||
if key not in globalconfig["toolbutton"]["rank2"]:
|
||||
globalconfig["toolbutton"]["rank2"].append(key)
|
||||
___ = []
|
||||
for key in globalconfig["toolbutton"]["rank2"]:
|
||||
if key not in defaultglobalconfig["toolbutton"]["buttons"]:
|
||||
___.append(key)
|
||||
for key in ___:
|
||||
globalconfig["toolbutton"]["rank2"].remove(key)
|
||||
|
||||
|
||||
def getlanguse():
|
||||
|
@ -240,59 +240,98 @@
|
||||
"profiles_index": 0,
|
||||
"ocrautobindwindow": true,
|
||||
"toolbutton": {
|
||||
"rank": [
|
||||
"rank2": [
|
||||
"move",
|
||||
"retrans",
|
||||
"automodebutton",
|
||||
"setting",
|
||||
"automodebutton"
|
||||
"copy",
|
||||
"edit",
|
||||
"showraw",
|
||||
"history",
|
||||
"noundict",
|
||||
"fix",
|
||||
"langdu",
|
||||
"mousetransbutton",
|
||||
"backtransbutton",
|
||||
"locktoolsbutton",
|
||||
"gamepad_new",
|
||||
"selectgame",
|
||||
"selecttext",
|
||||
"selectocrrange",
|
||||
"hideocrrange",
|
||||
"bindwindow",
|
||||
"resize",
|
||||
"fullscreen",
|
||||
"grabwindow",
|
||||
"muteprocess",
|
||||
"memory",
|
||||
"keepontop",
|
||||
"simulate_key_ctrl",
|
||||
"simulate_key_enter",
|
||||
"copy_once",
|
||||
"open_relative_link",
|
||||
"open_game_setting",
|
||||
"ocr_once",
|
||||
"minmize",
|
||||
"quit"
|
||||
],
|
||||
"buttons": {
|
||||
"retrans": {
|
||||
"use": true,
|
||||
"tip": "重新翻译",
|
||||
"icon": "fa.rotate-right"
|
||||
"icon": "fa.rotate-right",
|
||||
"align": 0
|
||||
},
|
||||
"automodebutton": {
|
||||
"use": true,
|
||||
"tip": "自动翻译",
|
||||
"icon": "fa.forward",
|
||||
"icon2": "fa.play"
|
||||
"icon2": "fa.play",
|
||||
"align": 0
|
||||
},
|
||||
"setting": {
|
||||
"use": true,
|
||||
"tip": "打开设置",
|
||||
"icon": "fa.gear"
|
||||
"icon": "fa.gear",
|
||||
"align": 0
|
||||
},
|
||||
"copy_once": {
|
||||
"use": false,
|
||||
"tip": "读取剪贴板",
|
||||
"icon": "fa.file-o"
|
||||
"icon": "fa.file-o",
|
||||
"align": 0
|
||||
},
|
||||
"open_relative_link": {
|
||||
"use": false,
|
||||
"tip": "打开关联页面",
|
||||
"icon": "fa.sitemap"
|
||||
"icon": "fa.sitemap",
|
||||
"align": 0
|
||||
},
|
||||
"open_game_setting": {
|
||||
"use": false,
|
||||
"tip": "游戏设置",
|
||||
"icon": "fa.futbol-o"
|
||||
"icon": "fa.futbol-o",
|
||||
"align": 0
|
||||
},
|
||||
"mousetransbutton": {
|
||||
"use": true,
|
||||
"tip": "鼠标穿透窗口",
|
||||
"icon": "fa.mouse-pointer"
|
||||
"icon": "fa.mouse-pointer",
|
||||
"align": 0
|
||||
},
|
||||
"backtransbutton": {
|
||||
"use": true,
|
||||
"tip": "背景窗口透明",
|
||||
"icon": "fa.lightbulb-o"
|
||||
"icon": "fa.lightbulb-o",
|
||||
"align": 0
|
||||
},
|
||||
"locktoolsbutton": {
|
||||
"use": true,
|
||||
"tip": "锁定工具栏",
|
||||
"icon": "fa.lock",
|
||||
"icon2": "fa.unlock"
|
||||
"icon2": "fa.unlock",
|
||||
"align": 0
|
||||
},
|
||||
"selectgame": {
|
||||
"use": true,
|
||||
@ -300,7 +339,8 @@
|
||||
"belong": [
|
||||
"texthook"
|
||||
],
|
||||
"icon": "fa.link"
|
||||
"icon": "fa.link",
|
||||
"align": 0
|
||||
},
|
||||
"selecttext": {
|
||||
"use": true,
|
||||
@ -308,7 +348,8 @@
|
||||
"belong": [
|
||||
"texthook"
|
||||
],
|
||||
"icon": "fa.tasks"
|
||||
"icon": "fa.tasks",
|
||||
"align": 0
|
||||
},
|
||||
"selectocrrange": {
|
||||
"use": true,
|
||||
@ -316,12 +357,14 @@
|
||||
"belong": [
|
||||
"ocr"
|
||||
],
|
||||
"icon": "fa.crop"
|
||||
"icon": "fa.crop",
|
||||
"align": 0
|
||||
},
|
||||
"ocr_once": {
|
||||
"use": false,
|
||||
"tip": "进行一次OCR",
|
||||
"icon": "fa.crop"
|
||||
"icon": "fa.crop",
|
||||
"align": 0
|
||||
},
|
||||
"hideocrrange": {
|
||||
"use": true,
|
||||
@ -329,110 +372,131 @@
|
||||
"belong": [
|
||||
"ocr"
|
||||
],
|
||||
"icon": "fa.square"
|
||||
"icon": "fa.square",
|
||||
"align": 0
|
||||
},
|
||||
"fix": {
|
||||
"use": false,
|
||||
"tip": "翻译结果修正",
|
||||
"icon": "fa.won"
|
||||
"icon": "fa.won",
|
||||
"align": 0
|
||||
},
|
||||
"noundict": {
|
||||
"use": false,
|
||||
"tip": "专有名词翻译设置",
|
||||
"icon": "fa.book"
|
||||
"icon": "fa.book",
|
||||
"align": 0
|
||||
},
|
||||
"minmize": {
|
||||
"use": true,
|
||||
"tip": "最小化到托盘",
|
||||
"icon": "fa.minus"
|
||||
"icon": "fa.minus",
|
||||
"align": 1
|
||||
},
|
||||
"quit": {
|
||||
"use": true,
|
||||
"tip": "退出",
|
||||
"icon": "fa.times"
|
||||
"icon": "fa.times",
|
||||
"align": 1
|
||||
},
|
||||
"move": {
|
||||
"use": false,
|
||||
"tip": "移动",
|
||||
"icon": "fa.hand-paper-o"
|
||||
"icon": "fa.hand-paper-o",
|
||||
"align": 0
|
||||
},
|
||||
"fullscreen": {
|
||||
"use": true,
|
||||
"tip": "缩放/恢复游戏窗口",
|
||||
"icon": "fa.compress",
|
||||
"icon2": "fa.expand"
|
||||
"icon2": "fa.expand",
|
||||
"align": 0
|
||||
},
|
||||
"grabwindow": {
|
||||
"use": false,
|
||||
"tip": "窗口截图",
|
||||
"icon": "fa.camera"
|
||||
"icon": "fa.camera",
|
||||
"align": 0
|
||||
},
|
||||
"resize": {
|
||||
"use": false,
|
||||
"tip": "调整游戏窗口",
|
||||
"icon": "fa.arrows"
|
||||
"icon": "fa.arrows",
|
||||
"align": 0
|
||||
},
|
||||
"muteprocess": {
|
||||
"use": false,
|
||||
"tip": "游戏静音",
|
||||
"icon": "fa.volume-off",
|
||||
"icon2": "fa.volume-up"
|
||||
"icon2": "fa.volume-up",
|
||||
"align": 0
|
||||
},
|
||||
"showraw": {
|
||||
"use": true,
|
||||
"tip": "显示/隐藏原文",
|
||||
"icon": "fa.eye",
|
||||
"icon2": "fa.eye-slash"
|
||||
"icon2": "fa.eye-slash",
|
||||
"align": 0
|
||||
},
|
||||
"langdu": {
|
||||
"use": true,
|
||||
"tip": "朗读",
|
||||
"icon": "fa.music"
|
||||
"icon": "fa.music",
|
||||
"align": 0
|
||||
},
|
||||
"copy": {
|
||||
"use": true,
|
||||
"tip": "复制到剪贴板",
|
||||
"icon": "fa.copy"
|
||||
"icon": "fa.copy",
|
||||
"align": 0
|
||||
},
|
||||
"history": {
|
||||
"use": true,
|
||||
"tip": "显示/隐藏历史翻译",
|
||||
"icon": "fa.rotate-left"
|
||||
"icon": "fa.rotate-left",
|
||||
"align": 0
|
||||
},
|
||||
"gamepad_new": {
|
||||
"use": true,
|
||||
"tip": "游戏管理",
|
||||
"icon": "fa.gamepad"
|
||||
"icon": "fa.gamepad",
|
||||
"align": 0
|
||||
},
|
||||
"edit": {
|
||||
"use": false,
|
||||
"tip": "编辑",
|
||||
"icon": "fa.edit"
|
||||
"icon": "fa.edit",
|
||||
"align": 0
|
||||
},
|
||||
"simulate_key_ctrl": {
|
||||
"use": false,
|
||||
"tip": "模拟按键Ctrl",
|
||||
"icon": "fa.download"
|
||||
"icon": "fa.download",
|
||||
"align": 0
|
||||
},
|
||||
"simulate_key_enter": {
|
||||
"use": false,
|
||||
"tip": "模拟按键Enter",
|
||||
"icon": "fa.download"
|
||||
"icon": "fa.download",
|
||||
"align": 0
|
||||
},
|
||||
"memory": {
|
||||
"use": false,
|
||||
"tip": "备忘录",
|
||||
"icon": "fa.list-ul"
|
||||
"icon": "fa.list-ul",
|
||||
"align": 0
|
||||
},
|
||||
"bindwindow": {
|
||||
"use": true,
|
||||
"tip": "绑定窗口(部分软件不支持)(点击自己取消)",
|
||||
"icon": "fa.windows"
|
||||
"icon": "fa.windows",
|
||||
"align": 0
|
||||
},
|
||||
"keepontop": {
|
||||
"use": true,
|
||||
"tip": "窗口置顶",
|
||||
"icon": "fa.neuter"
|
||||
"icon": "fa.neuter",
|
||||
"align": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "لقطة التلقائي",
|
||||
"模糊匹配": "غامض مطابقة",
|
||||
"相似度": "درجة التشابه",
|
||||
"编辑距离": "تحرير بالجو"
|
||||
"编辑距离": "تحرير بالجو",
|
||||
"对齐": "محاذاة"
|
||||
}
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "自動截圖",
|
||||
"模糊匹配": "模糊匹配",
|
||||
"相似度": "相似度",
|
||||
"编辑距离": "編輯距離"
|
||||
"编辑距离": "編輯距離",
|
||||
"对齐": "對齊"
|
||||
}
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "Automatic screenshot",
|
||||
"模糊匹配": "Fuzzy matching",
|
||||
"相似度": "Similarity",
|
||||
"编辑距离": "Edit distance"
|
||||
"编辑距离": "Edit distance",
|
||||
"对齐": "alignment"
|
||||
}
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "Captura de pantalla automática",
|
||||
"模糊匹配": "Coincidencia inútil",
|
||||
"相似度": "Similitud",
|
||||
"编辑距离": "Distancia de edición"
|
||||
"编辑距离": "Distancia de edición",
|
||||
"对齐": "Alinear"
|
||||
}
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "Capture d'écran automatique",
|
||||
"模糊匹配": "Correspondance floue",
|
||||
"相似度": "Similarité",
|
||||
"编辑距离": "Modifier la distance"
|
||||
"编辑距离": "Modifier la distance",
|
||||
"对齐": "Alignement"
|
||||
}
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "Schermata automatica",
|
||||
"模糊匹配": "Corrispondenza sfocata",
|
||||
"相似度": "Similitudine",
|
||||
"编辑距离": "Modifica distanza"
|
||||
"编辑距离": "Modifica distanza",
|
||||
"对齐": "allineamento"
|
||||
}
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "自動スクリーンショット",
|
||||
"模糊匹配": "ファジィマッチング",
|
||||
"相似度": "そうじど",
|
||||
"编辑距离": "距離の編集"
|
||||
"编辑距离": "距離の編集",
|
||||
"对齐": "配置"
|
||||
}
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "자동 캡처",
|
||||
"模糊匹配": "흐림 일치",
|
||||
"相似度": "유사도",
|
||||
"编辑距离": "거리 편집"
|
||||
"编辑距离": "거리 편집",
|
||||
"对齐": "정렬"
|
||||
}
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "Automatyczny zrzut ekranu",
|
||||
"模糊匹配": "Dopasowanie rozmyte",
|
||||
"相似度": "Podobieństwo",
|
||||
"编辑距离": "Edytuj odległość"
|
||||
"编辑距离": "Edytuj odległość",
|
||||
"对齐": "wyrównanie"
|
||||
}
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "Автоматический снимок экрана",
|
||||
"模糊匹配": "Нечеткое согласование",
|
||||
"相似度": "Сходство",
|
||||
"编辑距离": "Изменить расстояние"
|
||||
"编辑距离": "Изменить расстояние",
|
||||
"对齐": "Выровнять"
|
||||
}
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "ภาพหน้าจออัตโนมัติ",
|
||||
"模糊匹配": "จับคู่เบลอ",
|
||||
"相似度": "ความคล้ายคลึงกัน",
|
||||
"编辑距离": "แก้ไขระยะทาง"
|
||||
"编辑距离": "แก้ไขระยะทาง",
|
||||
"对齐": "จัดตำแหน่ง"
|
||||
}
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "Otomatik ekran fotoğrafı",
|
||||
"模糊匹配": "Çılgın eşleşme",
|
||||
"相似度": "Görünüşe benziyor",
|
||||
"编辑距离": "Edit distance"
|
||||
"编辑距离": "Edit distance",
|
||||
"对齐": "yönlendirme"
|
||||
}
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "Автоматичний знімок екрана",
|
||||
"模糊匹配": "Незрозуміле збігання",
|
||||
"相似度": "Схожість",
|
||||
"编辑距离": "Змінити відстань"
|
||||
"编辑距离": "Змінити відстань",
|
||||
"对齐": "вирівнювання"
|
||||
}
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "Ảnh chụp màn hình tự động",
|
||||
"模糊匹配": "Phù hợp mờ",
|
||||
"相似度": "Tương tự",
|
||||
"编辑距离": "Chỉnh sửa khoảng cách"
|
||||
"编辑距离": "Chỉnh sửa khoảng cách",
|
||||
"对齐": "Canh lề"
|
||||
}
|
@ -794,5 +794,6 @@
|
||||
"自动截图": "",
|
||||
"模糊匹配": "",
|
||||
"相似度": "",
|
||||
"编辑距离": ""
|
||||
"编辑距离": "",
|
||||
"对齐": ""
|
||||
}
|
@ -29,7 +29,7 @@ include(generate_product_version)
|
||||
|
||||
set(VERSION_MAJOR 2)
|
||||
set(VERSION_MINOR 52)
|
||||
set(VERSION_PATCH 4)
|
||||
set(VERSION_PATCH 5)
|
||||
|
||||
add_library(pch pch.cpp)
|
||||
target_precompile_headers(pch PUBLIC pch.h)
|
||||
|
Loading…
x
Reference in New Issue
Block a user