This commit is contained in:
恍兮惚兮 2024-07-11 14:53:06 +08:00
parent 0486332653
commit 22604a0eb5
20 changed files with 98 additions and 64 deletions

View File

@ -363,7 +363,7 @@ def uisetting(self):
),
],
[
("锁定工具栏"),
"锁定工具栏",
D_getsimpleswitch(
globalconfig,
"locktools",
@ -383,6 +383,12 @@ def uisetting(self):
callback=lambda _: toolcolorchange(),
),
"",
"延申",
D_getsimpleswitch(
globalconfig,
"extendtools",
callback=gobject.baseobject.translation_ui.changeextendstated_1
),
],
),
),

View File

@ -8,28 +8,11 @@ from gui.usefulwidget import getQMessageBox
class Textbrowser(QLabel):
contentsChanged = pyqtSignal(QSize)
_padding = 5
def __makeborder(self, size: QSize):
_padding = self._padding
self.masklabel_right.move(self.width() - _padding, 0)
self.masklabel_bottom.move(0, 0 + size.height() - _padding)
self.masklabel_left.resize(_padding, size.height())
self.masklabel_right.resize(_padding, size.height())
self.masklabel_bottom.resize(size.width(), _padding)
def resizeEvent(self, event: QResizeEvent):
_padding = self._padding
self.textbrowser.setGeometry(
_padding,
0,
event.size().width() - 2 * _padding,
event.size().height() - _padding,
)
self.__makeborder(event.size())
self.textbrowser.resize(event.size())
def _contentsChanged(self, size: QSize):
self.contentsChanged.emit(QSize(size.width(), size.height()))
self.contentsChanged.emit(size)
def loadinternal(self):
__ = globalconfig["rendertext_using"]
@ -63,15 +46,6 @@ class Textbrowser(QLabel):
self.setMouseTracking(True)
self.cleared = True
self.loadinternal()
self.masklabel_left = QLabel(self)
self.masklabel_left.setMouseTracking(True)
# self.masklabel_left.setStyleSheet('background-color:red')
self.masklabel_right = QLabel(self)
# self.masklabel_right.setStyleSheet('background-color:red')
self.masklabel_right.setMouseTracking(True)
self.masklabel_bottom = QLabel(self)
self.masklabel_bottom.setMouseTracking(True)
# self.masklabel_bottom.setStyleSheet('background-color:red')
def iter_append(self, iter_context_class, origin, atcenter, text, color):
cleared = self.cleared

View File

@ -270,12 +270,12 @@ class QUnFrameWindow(resizableframeless):
self.buttons[name].setIconSize(
QSize(globalconfig["buttonsize"], globalconfig["buttonsize"])
)
self.translate_text.move(0, int(globalconfig["buttonsize"] * 1.5))
self.setMinimumHeight(int(globalconfig["buttonsize"] * 1.5 + 10))
self.setMinimumWidth(globalconfig["buttonsize"] * 2)
self.setMinimumWidth(globalconfig["buttonsize"] * 10)
self.set_color_transparency()
self.seteffect()
self.adjustbuttons()
self.changeextendstated()
def ocr_once_function(self):
@threader
@ -416,6 +416,14 @@ class QUnFrameWindow(resizableframeless):
belong,
)
def changeextendstated(self):
self.translate_text.move(0, self.dynamicextraheight())
def changeextendstated_1(self, extend):
self.changeextendstated()
self.resize(self.width(), self.height() + [-1, 1][extend])
def hide_(self):
if globalconfig["showintab"]:
windows.ShowWindow(int(self.winId()), windows.SW_SHOWMINIMIZED)
@ -581,6 +589,7 @@ class QUnFrameWindow(resizableframeless):
self.translate_text = Textbrowser(self)
self.translate_text.contentsChanged.connect(self.textAreaChanged)
self.translate_text.textbrowser.setselectable(globalconfig["selectable"])
self._TitleLabel.raise_()
t = QTimer(self)
t.setInterval(100)
self._isentered = False
@ -646,13 +655,11 @@ class QUnFrameWindow(resizableframeless):
)
topr = self.createborderradiusstring(
rate * use_r1,
globalconfig["yuanjiao_merge"] and self._TitleLabel.isVisible(),
globalconfig["extendtools"] and self._TitleLabel.isVisible(),
False,
)
bottomr3 = self.createborderradiusstring(use_r2, False)
bottomr = self.createborderradiusstring(
rate * use_r2, globalconfig["yuanjiao_merge"], True
)
bottomr = self.createborderradiusstring(rate * use_r2, True, True)
self.translate_text.setStyleSheet(
"Textbrowser{border-width: 0;%s;background-color: %s}"
@ -834,6 +841,9 @@ class QUnFrameWindow(resizableframeless):
globalconfig["locktools"] = not globalconfig["locktools"]
self.refreshtoolicon()
def dynamicextraheight(self):
return int(globalconfig["extendtools"]) * int(globalconfig["buttonsize"] * 1.5)
def textAreaChanged(self, size: QSize):
if self.translate_text.cleared:
@ -841,9 +851,7 @@ class QUnFrameWindow(resizableframeless):
if not globalconfig["adaptive_height"]:
return
limit = min(size.height(), self.screen().geometry().height())
newHeight = (
limit + self.translate_text._padding + int(globalconfig["buttonsize"] * 1.5)
)
newHeight = limit + self.dynamicextraheight()
size = QSize(self.width(), newHeight)
self.autoresizesig = uuid.uuid4()
if newHeight > self.height():
@ -854,7 +862,7 @@ class QUnFrameWindow(resizableframeless):
@threader
def delaymaybeshrink(self, size: QSize, sig):
time.sleep(0.1)
time.sleep(0.2)
if sig != self.autoresizesig:
return
self.resizesignal.emit(size)
@ -884,8 +892,6 @@ class QUnFrameWindow(resizableframeless):
def toolbarhidedelay(self):
for button in self.buttons.values():
button.hide()
self._TitleLabel.hide()
self.set_color_transparency()
@ -929,8 +935,6 @@ class QUnFrameWindow(resizableframeless):
self.toolbarhidedelaysignal.emit()
def enterfunction(self, delay=None):
for button in self.showbuttons:
button.show()
self._TitleLabel.show()
self.set_color_transparency()
@ -938,7 +942,7 @@ class QUnFrameWindow(resizableframeless):
def resizeEvent(self, e: QResizeEvent):
super().resizeEvent(e)
wh = globalconfig["buttonsize"] * 1.5
wh = self.dynamicextraheight()
height = self.height() - wh
self.translate_text.resize(self.width(), int(height))
@ -999,7 +1003,7 @@ class QUnFrameWindow(resizableframeless):
def takusanbuttons(self, _type, clickfunc, tips, name, belong=None):
if clickfunc:
button = QPushButton(self)
button = QPushButton(self._TitleLabel)
button.clicked.connect(functools.partial(self.callwrap, clickfunc))
else:
@ -1007,6 +1011,7 @@ class QUnFrameWindow(resizableframeless):
def __init__(self, p):
super().__init__(p)
self._lb = QLabel(p)
self._lb.setStyleSheet("background-color: transparent;")
self._lb.raise_()
def hideEvent(self, _):
@ -1021,7 +1026,7 @@ class QUnFrameWindow(resizableframeless):
def resizeEvent(self, event):
self._lb.resize(event.size())
button = __(self)
button = __(self._TitleLabel)
if tips:
button.setToolTip(_TR(tips))

View File

@ -11,11 +11,30 @@ testsavejs = False
class TextBrowser(QWidget, dataget):
contentsChanged = pyqtSignal(QSize)
_padding = 5
def __makeborder(self, size: QSize):
_padding = self._padding
self.masklabel_top.setGeometry(0, 0, size.width(), _padding)
self.masklabel_left.setGeometry(0, 0, _padding, size.height())
self.masklabel_right.setGeometry(
self.width() - _padding, 0, _padding, size.height()
)
self.masklabel_bottom.setGeometry(
0, size.height() - _padding, size.width(), _padding
)
@tryprint
def resizeEvent(self, event: QResizeEvent):
self.webivewwidget.resize(event.size())
self.webivewwidget.setGeometry(
self._padding,
self._padding,
event.size().width() - 2 * self._padding,
event.size().height() - 2 * self._padding,
)
self.masklabel.resize(event.size())
self.__makeborder(event.size())
def setselectable(self, b):
self.masklabel.setHidden(b)
@ -29,6 +48,18 @@ class TextBrowser(QWidget, dataget):
# webview2当会执行alert之类的弹窗js时若qt窗口不可视会卡住
self.webivewwidget = WebivewWidget(self)
self.masklabel_left = QLabel(self)
self.masklabel_left.setMouseTracking(True)
# self.masklabel_left.setStyleSheet('background-color:red')
self.masklabel_right = QLabel(self)
# self.masklabel_right.setStyleSheet('background-color:red')
self.masklabel_right.setMouseTracking(True)
self.masklabel_bottom = QLabel(self)
self.masklabel_bottom.setMouseTracking(True)
self.masklabel_top = QLabel(self)
self.masklabel_top.setMouseTracking(True)
# self.masklabel_bottom.setStyleSheet('background-color:red')
self.masklabel = QLabel(self.webivewwidget)
self.masklabel.setMouseTracking(True)
self.webivewwidget.navigate(
@ -126,7 +157,10 @@ class TextBrowser(QWidget, dataget):
def calllunaheightchange(self, h):
self.contentsChanged.emit(
QSize(self.width(), int(h * self.webivewwidget.get_zoom()))
QSize(
self.width(),
1 + self._padding * 2 + int(h * self.webivewwidget.get_zoom()),
)
)
def calllunaclickedword(self, wordinfo):

View File

@ -349,7 +349,6 @@
"maxBufferSize": 3000,
"maxHistorySize": 1000000,
"yuanjiao_r": 0,
"yuanjiao_merge": true,
"qwebinspectgeo": [
100,
100,
@ -459,6 +458,7 @@
"backcolor_tool": "#3f3f3f",
"isshowhira": false,
"locktools": true,
"extendtools": true,
"showfanyisource": false,
"use_yapi": false,
"showfanyi": true,

View File

@ -815,5 +815,6 @@
"音量": "حجم",
"固定翻译显示顺序": "ترجمة ثابتة عرض تسلسل",
"显示顺序": "عرض تسلسل",
"安装": "تركيب ."
"安装": "تركيب .",
"延申": "تمديد"
}

View File

@ -815,5 +815,6 @@
"音量": "音量",
"固定翻译显示顺序": "固定翻譯顯示順序",
"显示顺序": "顯示順序",
"安装": "安裝"
"安装": "安裝",
"延申": "延申"
}

View File

@ -815,5 +815,6 @@
"音量": "Volume",
"固定翻译显示顺序": "Fixed translation display order",
"显示顺序": "Display order",
"安装": "install"
"安装": "install",
"延申": "Extension"
}

View File

@ -815,5 +815,6 @@
"音量": "Volumen",
"固定翻译显示顺序": "Orden fijo de visualización de la traducción",
"显示顺序": "Orden de visualización",
"安装": "Instalación"
"安装": "Instalación",
"延申": "Extensión"
}

View File

@ -815,5 +815,6 @@
"音量": "Volume",
"固定翻译显示顺序": "Ordre fixe d'affichage de la traduction",
"显示顺序": "Ordre d'affichage",
"安装": "Installation"
"安装": "Installation",
"延申": "Yanshin"
}

View File

@ -815,5 +815,6 @@
"音量": "volume",
"固定翻译显示顺序": "Ordine fisso di visualizzazione della traduzione",
"显示顺序": "Ordine di visualizzazione",
"安装": "installa"
"安装": "installa",
"延申": "Estensione"
}

View File

@ -815,5 +815,6 @@
"音量": "音量",
"固定翻译显示顺序": "固定翻訳表示順序",
"显示顺序": "表示順序",
"安装": "インストール"
"安装": "インストール",
"延申": "に言及"
}

View File

@ -815,5 +815,6 @@
"音量": "볼륨",
"固定翻译显示顺序": "고정 번역 표시 순서",
"显示顺序": "표시 순서",
"安装": "설치"
"安装": "설치",
"延申": "연장"
}

View File

@ -815,5 +815,6 @@
"音量": "objętość",
"固定翻译显示顺序": "Stała kolejność wyświetlania tłumaczeń",
"显示顺序": "Kolejność wyświetlania",
"安装": "instaluj"
"安装": "instaluj",
"延申": "Rozszerzenie"
}

View File

@ -815,5 +815,6 @@
"音量": "Громкость",
"固定翻译显示顺序": "Фиксированный перевод Показать порядок",
"显示顺序": "Показать последовательность",
"安装": "Монтаж"
"安装": "Монтаж",
"延申": "Яньшэнь"
}

View File

@ -815,5 +815,6 @@
"音量": "ระดับเสียง",
"固定翻译显示顺序": "ลำดับการแสดงผลการแปลคงที่",
"显示顺序": "แสดงลำดับ",
"安装": "การติดตั้ง"
"安装": "การติดตั้ง",
"延申": "ยันชิน"
}

View File

@ -815,5 +815,6 @@
"音量": "volume",
"固定翻译显示顺序": "Fikir çeviri gösterme düzeni",
"显示顺序": "Gösterim düzeni",
"安装": "Kur"
"安装": "Kur",
"延申": "Uzantı"
}

View File

@ -815,5 +815,6 @@
"音量": "гучність",
"固定翻译显示顺序": "Визначений порядок показу перекладу",
"显示顺序": "Порядок показу",
"安装": "встановити"
"安装": "встановити",
"延申": "Розширення"
}

View File

@ -815,5 +815,6 @@
"音量": "Âm lượng",
"固定翻译显示顺序": "Trình tự hiển thị bản dịch cố định",
"显示顺序": "Thứ tự hiển thị",
"安装": "Cài đặt"
"安装": "Cài đặt",
"延申": "Dương Thân"
}

View File

@ -815,5 +815,6 @@
"音量": "",
"固定翻译显示顺序": "",
"显示顺序": "",
"安装": ""
"安装": "",
"延申": ""
}