mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 00:24:13 +08:00
qt6
This commit is contained in:
parent
0b15cf8461
commit
39a28f050a
@ -1,5 +1,6 @@
|
|||||||
import time
|
import time
|
||||||
import os, threading
|
import os, threading
|
||||||
|
from qtsymbols import *
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from myutils.config import (
|
from myutils.config import (
|
||||||
globalconfig,
|
globalconfig,
|
||||||
@ -19,8 +20,6 @@ from myutils.utils import (
|
|||||||
getpostfile,
|
getpostfile,
|
||||||
stringfyerror,
|
stringfyerror,
|
||||||
)
|
)
|
||||||
from PyQt5.QtWidgets import QApplication, QMenu, QAction, QFrame
|
|
||||||
from PyQt5.QtCore import Qt, QObject, QEvent
|
|
||||||
from myutils.wrapper import threader
|
from myutils.wrapper import threader
|
||||||
from gui.showword import searchwordW
|
from gui.showword import searchwordW
|
||||||
from myutils.hwnd import getpidexe, ListProcess
|
from myutils.hwnd import getpidexe, ListProcess
|
||||||
@ -723,7 +722,7 @@ class MAINUI:
|
|||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
def setdarktheme(self, widget, dark):
|
def setdarktheme(self, widget, dark):
|
||||||
if widget.testAttribute(Qt.WA_TranslucentBackground):
|
if widget.testAttribute(Qt.WidgetAttribute.WA_TranslucentBackground):
|
||||||
return
|
return
|
||||||
winsharedutils.SetTheme(
|
winsharedutils.SetTheme(
|
||||||
int(widget.winId()), dark, globalconfig["WindowBackdrop"]
|
int(widget.winId()), dark, globalconfig["WindowBackdrop"]
|
||||||
@ -739,7 +738,9 @@ class MAINUI:
|
|||||||
if self.currentisdark is not None:
|
if self.currentisdark is not None:
|
||||||
self.setdarktheme(obj, self.currentisdark)
|
self.setdarktheme(obj, self.currentisdark)
|
||||||
windows.SetProp(
|
windows.SetProp(
|
||||||
int(obj.winId()), "Magpie.ToolWindow", windows.HANDLE(1)
|
int(obj.winId()),
|
||||||
|
"Magpie.WindowType.ToolWindow",
|
||||||
|
windows.HANDLE(1),
|
||||||
)
|
)
|
||||||
self.setshowintab_checked(obj)
|
self.setshowintab_checked(obj)
|
||||||
return False
|
return False
|
||||||
@ -797,12 +798,22 @@ class MAINUI:
|
|||||||
winsharedutils.showintab(int(widget.winId()), globalconfig["showintab"])
|
winsharedutils.showintab(int(widget.winId()), globalconfig["showintab"])
|
||||||
return
|
return
|
||||||
window_flags = widget.windowFlags()
|
window_flags = widget.windowFlags()
|
||||||
if Qt.FramelessWindowHint & window_flags == Qt.FramelessWindowHint:
|
if (
|
||||||
|
Qt.WindowType.FramelessWindowHint & window_flags
|
||||||
|
== Qt.WindowType.FramelessWindowHint
|
||||||
|
):
|
||||||
return
|
return
|
||||||
if isinstance(widget, QMenu):
|
if isinstance(widget, QMenu):
|
||||||
return
|
return
|
||||||
if isinstance(widget, QFrame):
|
if isinstance(widget, QFrame):
|
||||||
return
|
return
|
||||||
|
if (
|
||||||
|
isinstance(widget, QWidget)
|
||||||
|
and widget.parent() is None
|
||||||
|
and len(widget.children()) == 0
|
||||||
|
):
|
||||||
|
# combobox的下拉框,然后这个widget会迅速销毁,会导致任务栏闪一下。没别的办法了姑且这样过滤一下
|
||||||
|
return
|
||||||
winsharedutils.showintab(int(widget.winId()), globalconfig["showintab_sub"])
|
winsharedutils.showintab(int(widget.winId()), globalconfig["showintab_sub"])
|
||||||
|
|
||||||
def inittray(self):
|
def inittray(self):
|
||||||
|
@ -11,7 +11,7 @@ if __name__ == "__main__":
|
|||||||
) # win7 no vcredist2015
|
) # win7 no vcredist2015
|
||||||
|
|
||||||
from myutils.config import _TR, static_data, globalconfig
|
from myutils.config import _TR, static_data, globalconfig
|
||||||
|
|
||||||
sys.path.append("./")
|
sys.path.append("./")
|
||||||
sys.path.append("./userconfig")
|
sys.path.append("./userconfig")
|
||||||
sys.path.insert(
|
sys.path.insert(
|
||||||
@ -23,16 +23,14 @@ if __name__ == "__main__":
|
|||||||
import gobject
|
import gobject
|
||||||
|
|
||||||
gobject.overridepathexists()
|
gobject.overridepathexists()
|
||||||
|
from qtsymbols import *
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
if isqt5:
|
||||||
from PyQt5.QtWidgets import QApplication
|
QApplication.addLibraryPath(
|
||||||
from PyQt5.QtGui import QFont
|
"./LunaTranslator/runtime/PyQt5/Qt5/plugins"
|
||||||
|
) # 中文字符下不能自动加载
|
||||||
QApplication.addLibraryPath(
|
QApplication.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling)
|
||||||
"./LunaTranslator/runtime/PyQt5/Qt5/plugins"
|
QApplication.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps)
|
||||||
) # 中文字符下不能自动加载
|
|
||||||
QApplication.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling)
|
|
||||||
QApplication.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps)
|
|
||||||
QApplication.setHighDpiScaleFactorRoundingPolicy(
|
QApplication.setHighDpiScaleFactorRoundingPolicy(
|
||||||
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough
|
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough
|
||||||
)
|
)
|
||||||
@ -70,4 +68,4 @@ if __name__ == "__main__":
|
|||||||
gobject.baseobject = MAINUI()
|
gobject.baseobject = MAINUI()
|
||||||
gobject.baseobject.checklang()
|
gobject.baseobject.checklang()
|
||||||
gobject.baseobject.aa()
|
gobject.baseobject.aa()
|
||||||
app.exit(app.exec_())
|
app.exit(app.exec())
|
||||||
|
@ -1,20 +1,7 @@
|
|||||||
from PyQt5.QtCore import pyqtSignal
|
from qtsymbols import *
|
||||||
from PyQt5.QtWidgets import (
|
|
||||||
QWidget,
|
|
||||||
QVBoxLayout,
|
|
||||||
QHBoxLayout,
|
|
||||||
QLabel,
|
|
||||||
QLineEdit,
|
|
||||||
QListView,
|
|
||||||
QDialogButtonBox,
|
|
||||||
QApplication,
|
|
||||||
QPushButton,
|
|
||||||
)
|
|
||||||
from winsharedutils import getpidhwndfirst
|
from winsharedutils import getpidhwndfirst
|
||||||
from PyQt5.QtGui import QStandardItemModel, QStandardItem
|
|
||||||
import functools
|
import functools
|
||||||
from myutils.config import globalconfig, _TR
|
from myutils.config import globalconfig, _TR
|
||||||
import sys
|
|
||||||
import windows
|
import windows
|
||||||
import os
|
import os
|
||||||
from myutils.hwnd import (
|
from myutils.hwnd import (
|
||||||
@ -98,7 +85,9 @@ class AttachProcessDialog(closeashidewindow):
|
|||||||
self.layout2.addWidget(self.windowtextlayoutwidgets[1])
|
self.layout2.addWidget(self.windowtextlayoutwidgets[1])
|
||||||
self.processList = QListView()
|
self.processList = QListView()
|
||||||
self.buttonBox = QDialogButtonBox()
|
self.buttonBox = QDialogButtonBox()
|
||||||
self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
self.buttonBox.setStandardButtons(
|
||||||
|
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
|
||||||
|
)
|
||||||
self.layout1.addLayout(self.layout2)
|
self.layout1.addLayout(self.layout2)
|
||||||
self.layout1.addLayout(self.layout3)
|
self.layout1.addLayout(self.layout3)
|
||||||
self.layout1.addWidget(self.processList)
|
self.layout1.addWidget(self.processList)
|
||||||
@ -192,11 +181,3 @@ class AttachProcessDialog(closeashidewindow):
|
|||||||
# return
|
# return
|
||||||
self.close()
|
self.close()
|
||||||
self.callback(self.selectedp)
|
self.callback(self.selectedp)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
app = QApplication(sys.argv)
|
|
||||||
a = AttachProcessDialog()
|
|
||||||
a.show()
|
|
||||||
|
|
||||||
app.exit(app.exec_())
|
|
||||||
|
@ -1,17 +1,5 @@
|
|||||||
import functools
|
import functools
|
||||||
from PyQt5.QtWidgets import (
|
from qtsymbols import *
|
||||||
QCheckBox,
|
|
||||||
QLabel,
|
|
||||||
QLineEdit,
|
|
||||||
QPushButton,
|
|
||||||
QDialog,
|
|
||||||
QVBoxLayout,
|
|
||||||
QHeaderView,
|
|
||||||
)
|
|
||||||
from PyQt5.QtWidgets import QHBoxLayout, QTableView
|
|
||||||
from PyQt5.QtGui import QStandardItem, QStandardItemModel
|
|
||||||
from PyQt5.QtWidgets import QComboBox
|
|
||||||
from PyQt5.QtCore import Qt, QSize
|
|
||||||
from gui.usefulwidget import getspinbox, threebuttons, getlineedit
|
from gui.usefulwidget import getspinbox, threebuttons, getlineedit
|
||||||
from myutils.utils import checkencoding
|
from myutils.utils import checkencoding
|
||||||
from myutils.config import globalconfig, _TR, _TRL
|
from myutils.config import globalconfig, _TR, _TRL
|
||||||
@ -49,7 +37,7 @@ class codeacceptdialog(QDialog):
|
|||||||
itemsaver_.setText(code)
|
itemsaver_.setText(code)
|
||||||
|
|
||||||
def __init__(self, parent) -> None:
|
def __init__(self, parent) -> None:
|
||||||
super().__init__(parent, Qt.WindowCloseButtonHint)
|
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||||
title = "接受的编码"
|
title = "接受的编码"
|
||||||
self.setWindowTitle(_TR(title))
|
self.setWindowTitle(_TR(title))
|
||||||
# self.setWindowModality(Qt.ApplicationModal)
|
# self.setWindowModality(Qt.ApplicationModal)
|
||||||
@ -61,7 +49,9 @@ class codeacceptdialog(QDialog):
|
|||||||
self.model.setHorizontalHeaderLabels(_TRL(["接受的编码"]))
|
self.model.setHorizontalHeaderLabels(_TRL(["接受的编码"]))
|
||||||
self.table = QTableView(self)
|
self.table = QTableView(self)
|
||||||
self.table.setModel(self.model)
|
self.table.setModel(self.model)
|
||||||
self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
self.table.horizontalHeader().setSectionResizeMode(
|
||||||
|
QHeaderView.ResizeMode.Stretch
|
||||||
|
)
|
||||||
|
|
||||||
row = 0
|
row = 0
|
||||||
for code in globalconfig["accept_encoding"]: # 2
|
for code in globalconfig["accept_encoding"]: # 2
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
from PyQt5.QtWidgets import QPushButton, QFileDialog
|
from qtsymbols import *
|
||||||
from PyQt5.QtWidgets import QHBoxLayout, QVBoxLayout, QTextEdit, QWidget
|
|
||||||
|
|
||||||
from PyQt5.QtGui import QTextCursor
|
|
||||||
from PyQt5.QtCore import Qt
|
|
||||||
from myutils.config import _TR, globalconfig
|
from myutils.config import _TR, globalconfig
|
||||||
from gui.usefulwidget import saveposwindow
|
from gui.usefulwidget import saveposwindow
|
||||||
from myutils.wrapper import Singleton_close
|
from myutils.wrapper import Singleton_close
|
||||||
@ -26,7 +22,8 @@ class dialog_memory(saveposwindow):
|
|||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
parent,
|
parent,
|
||||||
flags=Qt.WindowCloseButtonHint | Qt.WindowMinMaxButtonsHint,
|
flags=Qt.WindowType.WindowCloseButtonHint
|
||||||
|
| Qt.WindowType.WindowMinMaxButtonsHint,
|
||||||
dic=globalconfig,
|
dic=globalconfig,
|
||||||
key="memorydialoggeo",
|
key="memorydialoggeo",
|
||||||
)
|
)
|
||||||
@ -42,7 +39,7 @@ class dialog_memory(saveposwindow):
|
|||||||
except:
|
except:
|
||||||
text = ""
|
text = ""
|
||||||
self.showtext.insertHtml(text)
|
self.showtext.insertHtml(text)
|
||||||
self.showtext.moveCursor(QTextCursor.Start)
|
self.showtext.moveCursor(QTextCursor.MoveOperation.Start)
|
||||||
formLayout.addWidget(self.showtext)
|
formLayout.addWidget(self.showtext)
|
||||||
|
|
||||||
x = QHBoxLayout()
|
x = QHBoxLayout()
|
||||||
|
@ -1,42 +1,12 @@
|
|||||||
import time
|
import time
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from gui.specialwidget import ScrollFlow, chartwidget, lazyscrollflow
|
from gui.specialwidget import ScrollFlow, chartwidget, lazyscrollflow
|
||||||
from PyQt5.QtWidgets import (
|
from qtsymbols import *
|
||||||
QPushButton,
|
|
||||||
QDialog,
|
|
||||||
QVBoxLayout,
|
|
||||||
QHeaderView,
|
|
||||||
QFileDialog,
|
|
||||||
QLineEdit,
|
|
||||||
QComboBox,
|
|
||||||
QFormLayout,
|
|
||||||
QHBoxLayout,
|
|
||||||
QTableView,
|
|
||||||
QAbstractItemView,
|
|
||||||
QLabel,
|
|
||||||
QTabWidget,
|
|
||||||
QApplication,
|
|
||||||
QSizePolicy,
|
|
||||||
QWidget,
|
|
||||||
QMenu,
|
|
||||||
QAction,
|
|
||||||
QTabBar,
|
|
||||||
)
|
|
||||||
import functools, threading
|
import functools, threading
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
import windows
|
import windows
|
||||||
from PyQt5.QtCore import QRect, QSize, Qt, pyqtSignal, QObject
|
|
||||||
import os
|
import os
|
||||||
from PyQt5.QtGui import (
|
|
||||||
QCloseEvent,
|
|
||||||
QIntValidator,
|
|
||||||
QResizeEvent,
|
|
||||||
QPixmap,
|
|
||||||
QPainter,
|
|
||||||
QPen,
|
|
||||||
QStandardItem,
|
|
||||||
QStandardItemModel,
|
|
||||||
)
|
|
||||||
from gui.usefulwidget import (
|
from gui.usefulwidget import (
|
||||||
getsimplecombobox,
|
getsimplecombobox,
|
||||||
getspinbox,
|
getspinbox,
|
||||||
@ -144,7 +114,7 @@ class ItemWidget(QWidget):
|
|||||||
self._lb.setText(file)
|
self._lb.setText(file)
|
||||||
self._lb.setWordWrap(True)
|
self._lb.setWordWrap(True)
|
||||||
self._lb.setStyleSheet("background-color: rgba(255,255,255, 0);")
|
self._lb.setStyleSheet("background-color: rgba(255,255,255, 0);")
|
||||||
self._lb.setAlignment(Qt.AlignCenter)
|
self._lb.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||||
layout.addWidget(self._lb)
|
layout.addWidget(self._lb)
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
self.exe = exe
|
self.exe = exe
|
||||||
@ -192,10 +162,10 @@ class IMGWidget(QLabel):
|
|||||||
rate = self.devicePixelRatioF()
|
rate = self.devicePixelRatioF()
|
||||||
newpixmap = QPixmap(self.size() * rate)
|
newpixmap = QPixmap(self.size() * rate)
|
||||||
newpixmap.setDevicePixelRatio(rate)
|
newpixmap.setDevicePixelRatio(rate)
|
||||||
newpixmap.fill(Qt.transparent)
|
newpixmap.fill(Qt.GlobalColor.transparent)
|
||||||
painter = QPainter(newpixmap)
|
painter = QPainter(newpixmap)
|
||||||
painter.setRenderHint(QPainter.SmoothPixmapTransform)
|
painter.setRenderHint(QPainter.RenderHint.SmoothPixmapTransform)
|
||||||
painter.setRenderHint(QPainter.Antialiasing)
|
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||||
painter.drawPixmap(self.getrect(pixmap.size()), pixmap)
|
painter.drawPixmap(self.getrect(pixmap.size()), pixmap)
|
||||||
painter.end()
|
painter.end()
|
||||||
|
|
||||||
@ -231,7 +201,7 @@ class CustomTabBar(QTabBar):
|
|||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
index = self.tabAt(event.pos())
|
index = self.tabAt(event.pos())
|
||||||
if index == self.count() - 1 and event.button() == Qt.LeftButton:
|
if index == self.count() - 1 and event.button() == Qt.MouseButton.LeftButton:
|
||||||
self.lastclick.emit()
|
self.lastclick.emit()
|
||||||
else:
|
else:
|
||||||
super().mousePressEvent(event)
|
super().mousePressEvent(event)
|
||||||
@ -246,7 +216,7 @@ class ClickableLabel(QLabel):
|
|||||||
self._clickable = clickable
|
self._clickable = clickable
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
if self._clickable and event.button() == Qt.LeftButton:
|
if self._clickable and event.button() == Qt.MouseButton.LeftButton:
|
||||||
self.clicked.emit()
|
self.clicked.emit()
|
||||||
|
|
||||||
clicked = pyqtSignal()
|
clicked = pyqtSignal()
|
||||||
@ -277,17 +247,17 @@ class tagitem(QWidget):
|
|||||||
|
|
||||||
def paintEvent(self, event):
|
def paintEvent(self, event):
|
||||||
painter = QPainter(self)
|
painter = QPainter(self)
|
||||||
painter.setRenderHint(QPainter.Antialiasing)
|
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||||
if self._type == tagitem.TYPE_RAND:
|
if self._type == tagitem.TYPE_RAND:
|
||||||
border_color = Qt.black
|
border_color = Qt.GlobalColor.black
|
||||||
elif self._type == tagitem.TYPE_DEVELOPER:
|
elif self._type == tagitem.TYPE_DEVELOPER:
|
||||||
border_color = Qt.red
|
border_color = Qt.GlobalColor.red
|
||||||
elif self._type == tagitem.TYPE_TAG:
|
elif self._type == tagitem.TYPE_TAG:
|
||||||
border_color = Qt.green
|
border_color = Qt.GlobalColor.green
|
||||||
elif self._type == tagitem.TYPE_USERTAG:
|
elif self._type == tagitem.TYPE_USERTAG:
|
||||||
border_color = Qt.blue
|
border_color = Qt.GlobalColor.blue
|
||||||
elif self._type == tagitem.TYPE_EXISTS:
|
elif self._type == tagitem.TYPE_EXISTS:
|
||||||
border_color = Qt.yellow
|
border_color = Qt.GlobalColor.yellow
|
||||||
border_width = 1
|
border_width = 1
|
||||||
pen = QPen(border_color)
|
pen = QPen(border_color)
|
||||||
pen.setWidth(border_width)
|
pen.setWidth(border_width)
|
||||||
@ -338,10 +308,12 @@ class TagWidget(QWidget):
|
|||||||
lambda: self.linepressedenter.emit(self.lineEdit.currentText())
|
lambda: self.linepressedenter.emit(self.lineEdit.currentText())
|
||||||
)
|
)
|
||||||
|
|
||||||
self.lineEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
|
self.lineEdit.setSizePolicy(
|
||||||
|
QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Maximum
|
||||||
|
)
|
||||||
|
|
||||||
layout.addWidget(self.lineEdit)
|
layout.addWidget(self.lineEdit)
|
||||||
self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
|
self.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed)
|
||||||
|
|
||||||
self.tag2widget = {}
|
self.tag2widget = {}
|
||||||
|
|
||||||
@ -539,7 +511,7 @@ class browserdialog(saveposwindow):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
_topw = QWidget()
|
_topw = QWidget()
|
||||||
_topw.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
|
_topw.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed)
|
||||||
_topw.setLayout(hlay)
|
_topw.setLayout(hlay)
|
||||||
layout = QVBoxLayout()
|
layout = QVBoxLayout()
|
||||||
layout.setContentsMargins(*(0 for i in range(4)))
|
layout.setContentsMargins(*(0 for i in range(4)))
|
||||||
@ -620,7 +592,7 @@ class dialog_setting_game(QDialog):
|
|||||||
return super().closeEvent(a0)
|
return super().closeEvent(a0)
|
||||||
|
|
||||||
def __init__(self, parent, exepath) -> None:
|
def __init__(self, parent, exepath) -> None:
|
||||||
super().__init__(parent, Qt.WindowCloseButtonHint)
|
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||||
global _global_dialog_setting_game
|
global _global_dialog_setting_game
|
||||||
_global_dialog_setting_game = self
|
_global_dialog_setting_game = self
|
||||||
self.isopened = True
|
self.isopened = True
|
||||||
@ -676,7 +648,7 @@ class dialog_setting_game(QDialog):
|
|||||||
|
|
||||||
vndbid = QLineEdit(str(savehook_new_data[exepath]["vid"]))
|
vndbid = QLineEdit(str(savehook_new_data[exepath]["vid"]))
|
||||||
vndbid.setValidator(QIntValidator())
|
vndbid.setValidator(QIntValidator())
|
||||||
vndbid.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
|
vndbid.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed)
|
||||||
|
|
||||||
vndbid.textEdited.connect(functools.partial(vidchangedtask, exepath))
|
vndbid.textEdited.connect(functools.partial(vidchangedtask, exepath))
|
||||||
|
|
||||||
@ -755,7 +727,7 @@ class dialog_setting_game(QDialog):
|
|||||||
def selectbackupdir(self, edit):
|
def selectbackupdir(self, edit):
|
||||||
res = QFileDialog.getExistingDirectory(
|
res = QFileDialog.getExistingDirectory(
|
||||||
directory=edit.text(),
|
directory=edit.text(),
|
||||||
options=QFileDialog.DontResolveSymlinks,
|
options=QFileDialog.Option.DontResolveSymlinks,
|
||||||
)
|
)
|
||||||
if not res:
|
if not res:
|
||||||
return
|
return
|
||||||
@ -885,8 +857,12 @@ class dialog_setting_game(QDialog):
|
|||||||
self.chart = chart
|
self.chart = chart
|
||||||
self._timelabel = QLabel()
|
self._timelabel = QLabel()
|
||||||
self._wordlabel = QLabel()
|
self._wordlabel = QLabel()
|
||||||
self._wordlabel.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
|
self._wordlabel.setSizePolicy(
|
||||||
self._timelabel.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
|
QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed
|
||||||
|
)
|
||||||
|
self._timelabel.setSizePolicy(
|
||||||
|
QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed
|
||||||
|
)
|
||||||
formLayout.addLayout(getboxlayout([QLabel(_TR("文字计数")), self._wordlabel]))
|
formLayout.addLayout(getboxlayout([QLabel(_TR("文字计数")), self._wordlabel]))
|
||||||
formLayout.addLayout(getboxlayout([QLabel(_TR("游戏时间")), self._timelabel]))
|
formLayout.addLayout(getboxlayout([QLabel(_TR("游戏时间")), self._timelabel]))
|
||||||
|
|
||||||
@ -1034,7 +1010,7 @@ class dialog_setting_game(QDialog):
|
|||||||
def getttssetting(self, exepath):
|
def getttssetting(self, exepath):
|
||||||
_w = QWidget()
|
_w = QWidget()
|
||||||
formLayout = QVBoxLayout()
|
formLayout = QVBoxLayout()
|
||||||
formLayout.setAlignment(Qt.AlignTop)
|
formLayout.setAlignment(Qt.AlignmentFlag.AlignTop)
|
||||||
_w.setLayout(formLayout)
|
_w.setLayout(formLayout)
|
||||||
|
|
||||||
formLayout.addLayout(
|
formLayout.addLayout(
|
||||||
@ -1154,11 +1130,13 @@ class dialog_setting_game(QDialog):
|
|||||||
self.hcmodel = model
|
self.hcmodel = model
|
||||||
|
|
||||||
table = QTableView()
|
table = QTableView()
|
||||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
|
table.horizontalHeader().setSectionResizeMode(
|
||||||
|
QHeaderView.ResizeMode.ResizeToContents
|
||||||
|
)
|
||||||
table.horizontalHeader().setStretchLastSection(True)
|
table.horizontalHeader().setStretchLastSection(True)
|
||||||
# table.setEditTriggers(QAbstractItemView.NoEditTriggers);
|
# table.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers);
|
||||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
table.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
|
||||||
table.setSelectionMode((QAbstractItemView.SingleSelection))
|
table.setSelectionMode((QAbstractItemView.SelectionMode.SingleSelection))
|
||||||
table.setWordWrap(False)
|
table.setWordWrap(False)
|
||||||
table.setModel(model)
|
table.setModel(model)
|
||||||
self.hctable = table
|
self.hctable = table
|
||||||
@ -1207,7 +1185,7 @@ class dialog_setting_game(QDialog):
|
|||||||
class dialog_syssetting(QDialog):
|
class dialog_syssetting(QDialog):
|
||||||
|
|
||||||
def __init__(self, parent) -> None:
|
def __init__(self, parent) -> None:
|
||||||
super().__init__(parent, Qt.WindowCloseButtonHint)
|
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||||
self.setWindowTitle(_TR("其他设置"))
|
self.setWindowTitle(_TR("其他设置"))
|
||||||
formLayout = QFormLayout(self)
|
formLayout = QFormLayout(self)
|
||||||
formLayout.addRow(
|
formLayout.addRow(
|
||||||
@ -1365,11 +1343,13 @@ class listediter(QDialog):
|
|||||||
self.hcmodel = model
|
self.hcmodel = model
|
||||||
|
|
||||||
table = QTableView()
|
table = QTableView()
|
||||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
|
table.horizontalHeader().setSectionResizeMode(
|
||||||
|
QHeaderView.ResizeMode.ResizeToContents
|
||||||
|
)
|
||||||
table.horizontalHeader().setStretchLastSection(True)
|
table.horizontalHeader().setStretchLastSection(True)
|
||||||
# table.setEditTriggers(QAbstractItemView.NoEditTriggers);
|
# table.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers);
|
||||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
table.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
|
||||||
table.setSelectionMode((QAbstractItemView.SingleSelection))
|
table.setSelectionMode((QAbstractItemView.SelectionMode.SingleSelection))
|
||||||
table.setWordWrap(False)
|
table.setWordWrap(False)
|
||||||
table.setModel(model)
|
table.setModel(model)
|
||||||
self.hctable = table
|
self.hctable = table
|
||||||
@ -1447,7 +1427,9 @@ class dialog_savedgame_new(saveposwindow):
|
|||||||
opendir(self.currentfocuspath)
|
opendir(self.currentfocuspath)
|
||||||
|
|
||||||
def clicked3_batch(self):
|
def clicked3_batch(self):
|
||||||
res = QFileDialog.getExistingDirectory(options=QFileDialog.DontResolveSymlinks)
|
res = QFileDialog.getExistingDirectory(
|
||||||
|
options=QFileDialog.Option.DontResolveSymlinks
|
||||||
|
)
|
||||||
if res != "":
|
if res != "":
|
||||||
for _dir, _, _fs in os.walk(res):
|
for _dir, _, _fs in os.walk(res):
|
||||||
for _f in _fs:
|
for _f in _fs:
|
||||||
@ -1460,7 +1442,7 @@ class dialog_savedgame_new(saveposwindow):
|
|||||||
|
|
||||||
def clicked3(self):
|
def clicked3(self):
|
||||||
|
|
||||||
f = QFileDialog.getOpenFileName(options=QFileDialog.DontResolveSymlinks)
|
f = QFileDialog.getOpenFileName(options=QFileDialog.Option.DontResolveSymlinks)
|
||||||
|
|
||||||
res = f[0]
|
res = f[0]
|
||||||
if res != "":
|
if res != "":
|
||||||
@ -1556,7 +1538,8 @@ class dialog_savedgame_new(saveposwindow):
|
|||||||
def __init__(self, parent) -> None:
|
def __init__(self, parent) -> None:
|
||||||
super().__init__(
|
super().__init__(
|
||||||
parent,
|
parent,
|
||||||
flags=Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint,
|
flags=Qt.WindowType.WindowMinMaxButtonsHint
|
||||||
|
| Qt.WindowType.WindowCloseButtonHint,
|
||||||
dic=globalconfig,
|
dic=globalconfig,
|
||||||
key="savegamedialoggeo",
|
key="savegamedialoggeo",
|
||||||
)
|
)
|
||||||
@ -1614,7 +1597,7 @@ class dialog_savedgame_new(saveposwindow):
|
|||||||
layout.addWidget(self.tagswidget)
|
layout.addWidget(self.tagswidget)
|
||||||
formLayout.addLayout(layout)
|
formLayout.addLayout(layout)
|
||||||
self.flow = lazyscrollflow()
|
self.flow = lazyscrollflow()
|
||||||
self.setContextMenuPolicy(Qt.CustomContextMenu)
|
self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
||||||
self.customContextMenuRequested.connect(self.showmenu)
|
self.customContextMenuRequested.connect(self.showmenu)
|
||||||
formLayout.addWidget(self.flow)
|
formLayout.addWidget(self.flow)
|
||||||
self.formLayout = formLayout
|
self.formLayout = formLayout
|
||||||
@ -1687,7 +1670,7 @@ class dialog_savedgame_new(saveposwindow):
|
|||||||
if save:
|
if save:
|
||||||
self.savebutton.append((button5, exists))
|
self.savebutton.append((button5, exists))
|
||||||
button5.clicked.connect(callback)
|
button5.clicked.connect(callback)
|
||||||
button5.setFocusPolicy(Qt.NoFocus)
|
button5.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
||||||
self.buttonlayout.addWidget(button5)
|
self.buttonlayout.addWidget(button5)
|
||||||
return button5
|
return button5
|
||||||
|
|
||||||
|
@ -1,16 +1,4 @@
|
|||||||
from PyQt5.QtGui import QCursor
|
from qtsymbols import *
|
||||||
from PyQt5.QtWidgets import (
|
|
||||||
QPlainTextEdit,
|
|
||||||
QAction,
|
|
||||||
QMenu,
|
|
||||||
QHBoxLayout,
|
|
||||||
QMainWindow,
|
|
||||||
QLineEdit,
|
|
||||||
QWidget,
|
|
||||||
QPushButton,
|
|
||||||
QVBoxLayout,
|
|
||||||
)
|
|
||||||
from PyQt5.QtCore import Qt, pyqtSignal, QPoint, QSize
|
|
||||||
import qtawesome
|
import qtawesome
|
||||||
import threading, windows
|
import threading, windows
|
||||||
import gobject, time
|
import gobject, time
|
||||||
@ -37,7 +25,7 @@ class edittext(closeashidewindow):
|
|||||||
|
|
||||||
self.textOutput = QPlainTextEdit(self)
|
self.textOutput = QPlainTextEdit(self)
|
||||||
|
|
||||||
self.textOutput.setContextMenuPolicy(Qt.CustomContextMenu)
|
self.textOutput.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
||||||
|
|
||||||
self.textOutput.customContextMenuRequested.connect(self.showmenu)
|
self.textOutput.customContextMenuRequested.connect(self.showmenu)
|
||||||
# self.setCentralWidget(self.textOutput)
|
# self.setCentralWidget(self.textOutput)
|
||||||
@ -106,8 +94,8 @@ class edittrans(QMainWindow):
|
|||||||
swsignal = pyqtSignal()
|
swsignal = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super().__init__(parent, Qt.FramelessWindowHint)
|
super().__init__(parent, Qt.WindowType.FramelessWindowHint)
|
||||||
self.setAttribute(Qt.WA_TranslucentBackground)
|
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||||
self.setStyleSheet(
|
self.setStyleSheet(
|
||||||
"background-color: rgba(%s, %s, %s, %s)"
|
"background-color: rgba(%s, %s, %s, %s)"
|
||||||
% (
|
% (
|
||||||
|
@ -1,23 +1,5 @@
|
|||||||
import functools
|
import functools
|
||||||
from PyQt5.QtWidgets import (
|
from qtsymbols import *
|
||||||
QDialogButtonBox,
|
|
||||||
QDialog,
|
|
||||||
QHeaderView,
|
|
||||||
QComboBox,
|
|
||||||
QFormLayout,
|
|
||||||
QDoubleSpinBox,
|
|
||||||
QSpinBox,
|
|
||||||
QHBoxLayout,
|
|
||||||
QLineEdit,
|
|
||||||
QFileDialog,
|
|
||||||
QPushButton,
|
|
||||||
QLabel,
|
|
||||||
QTableView,
|
|
||||||
QVBoxLayout,
|
|
||||||
)
|
|
||||||
from PyQt5.QtCore import Qt, QSize
|
|
||||||
from PyQt5.QtGui import QCloseEvent, QStandardItem, QStandardItemModel
|
|
||||||
|
|
||||||
import qtawesome, importlib
|
import qtawesome, importlib
|
||||||
from myutils.config import globalconfig, _TR, _TRL
|
from myutils.config import globalconfig, _TR, _TRL
|
||||||
from gui.usefulwidget import MySwitch, selectcolor, getsimpleswitch, threebuttons
|
from gui.usefulwidget import MySwitch, selectcolor, getsimpleswitch, threebuttons
|
||||||
@ -37,7 +19,7 @@ class noundictconfigdialog1(QDialog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, parent, configdict, configkey, title, label) -> None:
|
def __init__(self, parent, configdict, configkey, title, label) -> None:
|
||||||
super().__init__(parent, Qt.WindowCloseButtonHint)
|
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||||
|
|
||||||
self.setWindowTitle(_TR(title))
|
self.setWindowTitle(_TR(title))
|
||||||
# self.setWindowModality(Qt.ApplicationModal)
|
# self.setWindowModality(Qt.ApplicationModal)
|
||||||
@ -49,9 +31,11 @@ class noundictconfigdialog1(QDialog):
|
|||||||
table = QTableView(self)
|
table = QTableView(self)
|
||||||
table.setModel(self.model)
|
table.setModel(self.model)
|
||||||
|
|
||||||
table.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch)
|
table.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeMode.Stretch)
|
||||||
table.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
|
table.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeMode.Stretch)
|
||||||
table.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeToContents)
|
table.horizontalHeader().setSectionResizeMode(
|
||||||
|
0, QHeaderView.ResizeMode.ResizeToContents
|
||||||
|
)
|
||||||
|
|
||||||
self.table = table
|
self.table = table
|
||||||
for row, item in enumerate(configdict[configkey]):
|
for row, item in enumerate(configdict[configkey]):
|
||||||
@ -127,7 +111,7 @@ class noundictconfigdialog1(QDialog):
|
|||||||
@Singleton
|
@Singleton
|
||||||
class regexedit(QDialog):
|
class regexedit(QDialog):
|
||||||
def __init__(self, parent, regexlist) -> None:
|
def __init__(self, parent, regexlist) -> None:
|
||||||
super().__init__(parent, Qt.WindowCloseButtonHint)
|
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||||
self.regexlist = regexlist
|
self.regexlist = regexlist
|
||||||
self.setWindowTitle(_TR("正则匹配"))
|
self.setWindowTitle(_TR("正则匹配"))
|
||||||
|
|
||||||
@ -138,7 +122,7 @@ class regexedit(QDialog):
|
|||||||
table = QTableView(self)
|
table = QTableView(self)
|
||||||
table.setModel(self.model)
|
table.setModel(self.model)
|
||||||
|
|
||||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
|
||||||
|
|
||||||
self.table = table
|
self.table = table
|
||||||
for row, regex in enumerate(regexlist):
|
for row, regex in enumerate(regexlist):
|
||||||
@ -197,7 +181,7 @@ def autoinitdialog_items(dic):
|
|||||||
@Singleton
|
@Singleton
|
||||||
class autoinitdialog(QDialog):
|
class autoinitdialog(QDialog):
|
||||||
def __init__(self, parent, title, width, lines, _=None) -> None:
|
def __init__(self, parent, title, width, lines, _=None) -> None:
|
||||||
super().__init__(parent, Qt.WindowCloseButtonHint)
|
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||||
|
|
||||||
self.setWindowTitle(_TR(title))
|
self.setWindowTitle(_TR(title))
|
||||||
self.resize(QSize(width, 10))
|
self.resize(QSize(width, 10))
|
||||||
@ -262,7 +246,10 @@ class autoinitdialog(QDialog):
|
|||||||
functools.partial(dd.__setitem__, key)
|
functools.partial(dd.__setitem__, key)
|
||||||
)
|
)
|
||||||
elif line["type"] == "okcancel":
|
elif line["type"] == "okcancel":
|
||||||
lineW = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
lineW = QDialogButtonBox(
|
||||||
|
QDialogButtonBox.StandardButton.Ok
|
||||||
|
| QDialogButtonBox.StandardButton.Cancel
|
||||||
|
)
|
||||||
lineW.rejected.connect(self.close)
|
lineW.rejected.connect(self.close)
|
||||||
lineW.accepted.connect(
|
lineW.accepted.connect(
|
||||||
functools.partial(
|
functools.partial(
|
||||||
@ -270,8 +257,10 @@ class autoinitdialog(QDialog):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
lineW.button(QDialogButtonBox.Ok).setText(_TR("确定"))
|
lineW.button(QDialogButtonBox.StandardButton.Ok).setText(_TR("确定"))
|
||||||
lineW.button(QDialogButtonBox.Cancel).setText(_TR("取消"))
|
lineW.button(QDialogButtonBox.StandardButton.Cancel).setText(
|
||||||
|
_TR("取消")
|
||||||
|
)
|
||||||
elif line["type"] == "lineedit":
|
elif line["type"] == "lineedit":
|
||||||
try:
|
try:
|
||||||
lineW = QLineEdit(dd[key])
|
lineW = QLineEdit(dd[key])
|
||||||
@ -344,7 +333,7 @@ def getsomepath1(
|
|||||||
@Singleton
|
@Singleton
|
||||||
class multicolorset(QDialog):
|
class multicolorset(QDialog):
|
||||||
def __init__(self, parent) -> None:
|
def __init__(self, parent) -> None:
|
||||||
super().__init__(parent, Qt.WindowCloseButtonHint)
|
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||||
self.setWindowTitle(_TR("颜色设置"))
|
self.setWindowTitle(_TR("颜色设置"))
|
||||||
self.resize(QSize(300, 10))
|
self.resize(QSize(300, 10))
|
||||||
formLayout = QFormLayout(self) # 配置layout
|
formLayout = QFormLayout(self) # 配置layout
|
||||||
@ -411,7 +400,7 @@ class postconfigdialog_(QDialog):
|
|||||||
self.configdict[self.key] = newdict
|
self.configdict[self.key] = newdict
|
||||||
|
|
||||||
def __init__(self, parent, configdict, title) -> None:
|
def __init__(self, parent, configdict, title) -> None:
|
||||||
super().__init__(parent, Qt.WindowCloseButtonHint)
|
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||||
print(title)
|
print(title)
|
||||||
self.setWindowTitle(_TR(title))
|
self.setWindowTitle(_TR(title))
|
||||||
# self.setWindowModality(Qt.ApplicationModal)
|
# self.setWindowModality(Qt.ApplicationModal)
|
||||||
@ -438,8 +427,8 @@ class postconfigdialog_(QDialog):
|
|||||||
table = QTableView(self)
|
table = QTableView(self)
|
||||||
table.setModel(model)
|
table.setModel(model)
|
||||||
table.setWordWrap(False)
|
table.setWordWrap(False)
|
||||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
|
||||||
# table.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
# table.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
|
||||||
# table.clicked.connect(self.show_info)
|
# table.clicked.connect(self.show_info)
|
||||||
button = threebuttons()
|
button = threebuttons()
|
||||||
|
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
from PyQt5.QtCore import Qt
|
from qtsymbols import *
|
||||||
from PyQt5.QtWidgets import QVBoxLayout, QComboBox, QPushButton, QDialog
|
|
||||||
from PyQt5.QtGui import QFont
|
|
||||||
from PyQt5.QtCore import Qt, pyqtSignal
|
|
||||||
import qtawesome
|
import qtawesome
|
||||||
|
|
||||||
|
|
||||||
@ -13,7 +10,7 @@ class languageset(QDialog):
|
|||||||
def __init__(self, language_list):
|
def __init__(self, language_list):
|
||||||
|
|
||||||
super(languageset, self).__init__(
|
super(languageset, self).__init__(
|
||||||
None, Qt.WindowStaysOnTopHint
|
None, Qt.WindowType.WindowStaysOnTopHint
|
||||||
) # 设置为顶级窗口,无边框
|
) # 设置为顶级窗口,无边框
|
||||||
self.setWindowIcon(qtawesome.icon("fa.language"))
|
self.setWindowIcon(qtawesome.icon("fa.language"))
|
||||||
self.setMinimumSize(400, 100)
|
self.setMinimumSize(400, 100)
|
||||||
|
@ -1,15 +1,4 @@
|
|||||||
from PyQt5.QtWidgets import (
|
from qtsymbols import *
|
||||||
QComboBox,
|
|
||||||
QPushButton,
|
|
||||||
QFormLayout,
|
|
||||||
QHBoxLayout,
|
|
||||||
QDialogButtonBox,
|
|
||||||
QDialog,
|
|
||||||
QLineEdit,
|
|
||||||
QFileDialog,
|
|
||||||
)
|
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QSize
|
|
||||||
import sqlite3, os
|
import sqlite3, os
|
||||||
import json
|
import json
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
@ -54,7 +43,7 @@ def sqlite2json2(self, sqlitefile, targetjson=None, existsmerge=False):
|
|||||||
_collect.append(_)
|
_collect.append(_)
|
||||||
collect = _collect
|
collect = _collect
|
||||||
|
|
||||||
dialog = QDialog(self, Qt.WindowCloseButtonHint) # 自定义一个dialog
|
dialog = QDialog(self, Qt.WindowType.WindowCloseButtonHint) # 自定义一个dialog
|
||||||
dialog.setWindowTitle(_TR("导出翻译记录为json文件"))
|
dialog.setWindowTitle(_TR("导出翻译记录为json文件"))
|
||||||
dialog.resize(QSize(800, 10))
|
dialog.resize(QSize(800, 10))
|
||||||
formLayout = QFormLayout(dialog) # 配置layout
|
formLayout = QFormLayout(dialog) # 配置layout
|
||||||
@ -85,7 +74,9 @@ def sqlite2json2(self, sqlitefile, targetjson=None, existsmerge=False):
|
|||||||
if targetjson is None:
|
if targetjson is None:
|
||||||
formLayout.addRow(_TR("保存路径"), hori)
|
formLayout.addRow(_TR("保存路径"), hori)
|
||||||
|
|
||||||
button = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
button = QDialogButtonBox(
|
||||||
|
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
|
||||||
|
)
|
||||||
formLayout.addRow(button)
|
formLayout.addRow(button)
|
||||||
button.rejected.connect(dialog.close)
|
button.rejected.connect(dialog.close)
|
||||||
|
|
||||||
@ -114,8 +105,8 @@ def sqlite2json2(self, sqlitefile, targetjson=None, existsmerge=False):
|
|||||||
dialog.close()
|
dialog.close()
|
||||||
|
|
||||||
button.accepted.connect(functools.partial(__savefunction, targetjson, existsmerge))
|
button.accepted.connect(functools.partial(__savefunction, targetjson, existsmerge))
|
||||||
button.button(QDialogButtonBox.Ok).setText(_TR("确定"))
|
button.button(QDialogButtonBox.StandardButton.Ok).setText(_TR("确定"))
|
||||||
button.button(QDialogButtonBox.Cancel).setText(_TR("取消"))
|
button.button(QDialogButtonBox.StandardButton.Cancel).setText(_TR("取消"))
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,4 @@
|
|||||||
from PyQt5.QtWidgets import (
|
from qtsymbols import *
|
||||||
QMenu,
|
|
||||||
QMainWindow,
|
|
||||||
QLabel,
|
|
||||||
QAction,
|
|
||||||
)
|
|
||||||
from PyQt5.QtGui import QPainter, QPen, QColor, QCursor
|
|
||||||
from PyQt5.QtCore import Qt, QPoint, QRect
|
|
||||||
from myutils.config import _TR
|
from myutils.config import _TR
|
||||||
from myutils.config import globalconfig
|
from myutils.config import globalconfig
|
||||||
from gui.resizeablemainwindow import Mainw
|
from gui.resizeablemainwindow import Mainw
|
||||||
@ -23,9 +16,13 @@ class rangeadjust(Mainw):
|
|||||||
self.drag_label.setGeometry(0, 0, 4000, 2000)
|
self.drag_label.setGeometry(0, 0, 4000, 2000)
|
||||||
self._isTracking = False
|
self._isTracking = False
|
||||||
self._rect = None
|
self._rect = None
|
||||||
self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.Tool)
|
self.setWindowFlags(
|
||||||
self.setAttribute(Qt.WA_TranslucentBackground)
|
Qt.WindowType.WindowStaysOnTopHint
|
||||||
self.setContextMenuPolicy(Qt.CustomContextMenu)
|
| Qt.WindowType.FramelessWindowHint
|
||||||
|
| Qt.WindowType.Tool
|
||||||
|
)
|
||||||
|
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||||
|
self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
||||||
self.customContextMenuRequested.connect(self.showmenu)
|
self.customContextMenuRequested.connect(self.showmenu)
|
||||||
for s in self.cornerGrips:
|
for s in self.cornerGrips:
|
||||||
s.raise_()
|
s.raise_()
|
||||||
@ -51,12 +48,12 @@ class rangeadjust(Mainw):
|
|||||||
self.move(self.pos() + self._endPos)
|
self.move(self.pos() + self._endPos)
|
||||||
|
|
||||||
def mousePressEvent(self, e):
|
def mousePressEvent(self, e):
|
||||||
if e.button() == Qt.LeftButton:
|
if e.button() == Qt.MouseButton.LeftButton:
|
||||||
self._isTracking = True
|
self._isTracking = True
|
||||||
self._startPos = QPoint(e.x(), e.y())
|
self._startPos = QPoint(e.x(), e.y())
|
||||||
|
|
||||||
def mouseReleaseEvent(self, e):
|
def mouseReleaseEvent(self, e):
|
||||||
if e.button() == Qt.LeftButton:
|
if e.button() == Qt.MouseButton.LeftButton:
|
||||||
self._isTracking = False
|
self._isTracking = False
|
||||||
self._startPos = None
|
self._startPos = None
|
||||||
self._endPos = None
|
self._endPos = None
|
||||||
@ -122,13 +119,13 @@ class rangeselct(QMainWindow):
|
|||||||
|
|
||||||
super(rangeselct, self).__init__(parent)
|
super(rangeselct, self).__init__(parent)
|
||||||
self.setWindowFlags(
|
self.setWindowFlags(
|
||||||
Qt.FramelessWindowHint | Qt.Tool
|
Qt.WindowType.FramelessWindowHint | Qt.WindowType.Tool
|
||||||
) # |Qt.WindowStaysOnTopHint )
|
) # |Qt.WindowStaysOnTopHint )
|
||||||
self.rectlabel = QLabel(self)
|
self.rectlabel = QLabel(self)
|
||||||
# self.setAttribute(Qt.WA_TranslucentBackground)
|
# self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||||
self.setWindowOpacity(0.5)
|
self.setWindowOpacity(0.5)
|
||||||
self.setMouseTracking(True)
|
self.setMouseTracking(True)
|
||||||
self.setCursor(Qt.CrossCursor)
|
self.setCursor(Qt.CursorShape.CrossCursor)
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
@ -180,7 +177,7 @@ class rangeselct(QMainWindow):
|
|||||||
self.rectlabel.setGeometry(QRect(_sp, _ep))
|
self.rectlabel.setGeometry(QRect(_sp, _ep))
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
if event.button() == Qt.LeftButton:
|
if event.button() == Qt.MouseButton.LeftButton:
|
||||||
if self.clickrelease:
|
if self.clickrelease:
|
||||||
self.clickrelease = False
|
self.clickrelease = False
|
||||||
self.mouseReleaseEvent(event)
|
self.mouseReleaseEvent(event)
|
||||||
@ -216,7 +213,7 @@ class rangeselct(QMainWindow):
|
|||||||
return ((x1, y1), (x2, y2))
|
return ((x1, y1), (x2, y2))
|
||||||
|
|
||||||
def mouseReleaseEvent(self, event):
|
def mouseReleaseEvent(self, event):
|
||||||
if event.button() == Qt.LeftButton:
|
if event.button() == Qt.MouseButton.LeftButton:
|
||||||
self.end_point = event.pos()
|
self.end_point = event.pos()
|
||||||
self.__end = windows.GetCursorPos()
|
self.__end = windows.GetCursorPos()
|
||||||
|
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
from PyQt5 import QtCore, QtWidgets
|
from qtsymbols import *
|
||||||
|
|
||||||
|
|
||||||
class SideGrip(QtWidgets.QWidget):
|
class SideGrip(QWidget):
|
||||||
def __init__(self, parent, edge):
|
def __init__(self, parent, edge):
|
||||||
QtWidgets.QWidget.__init__(self, parent)
|
QWidget.__init__(self, parent)
|
||||||
if edge == QtCore.Qt.LeftEdge:
|
if edge == Qt.Edge.LeftEdge:
|
||||||
self.setCursor(QtCore.Qt.SizeHorCursor)
|
self.setCursor(Qt.CursorShape.SizeHorCursor)
|
||||||
self.resizeFunc = self.resizeLeft
|
self.resizeFunc = self.resizeLeft
|
||||||
elif edge == QtCore.Qt.TopEdge:
|
elif edge == Qt.Edge.TopEdge:
|
||||||
self.setCursor(QtCore.Qt.SizeVerCursor)
|
self.setCursor(Qt.CursorShape.SizeVerCursor)
|
||||||
self.resizeFunc = self.resizeTop
|
self.resizeFunc = self.resizeTop
|
||||||
elif edge == QtCore.Qt.RightEdge:
|
elif edge == Qt.Edge.RightEdge:
|
||||||
self.setCursor(QtCore.Qt.SizeHorCursor)
|
self.setCursor(Qt.CursorShape.SizeHorCursor)
|
||||||
self.resizeFunc = self.resizeRight
|
self.resizeFunc = self.resizeRight
|
||||||
else:
|
else:
|
||||||
self.setCursor(QtCore.Qt.SizeVerCursor)
|
self.setCursor(Qt.CursorShape.SizeVerCursor)
|
||||||
self.resizeFunc = self.resizeBottom
|
self.resizeFunc = self.resizeBottom
|
||||||
self.mousePos = None
|
self.mousePos = None
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class SideGrip(QtWidgets.QWidget):
|
|||||||
window.resize(window.width(), height)
|
window.resize(window.width(), height)
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
if event.button() == QtCore.Qt.LeftButton:
|
if event.button() == Qt.MouseButton.LeftButton:
|
||||||
self.mousePos = event.pos()
|
self.mousePos = event.pos()
|
||||||
|
|
||||||
def mouseMoveEvent(self, event):
|
def mouseMoveEvent(self, event):
|
||||||
@ -55,24 +55,24 @@ class SideGrip(QtWidgets.QWidget):
|
|||||||
self.mousePos = None
|
self.mousePos = None
|
||||||
|
|
||||||
|
|
||||||
class Mainw(QtWidgets.QMainWindow):
|
class Mainw(QMainWindow):
|
||||||
_gripSize = 8
|
_gripSize = 8
|
||||||
|
|
||||||
def __init__(self, x):
|
def __init__(self, x):
|
||||||
QtWidgets.QMainWindow.__init__(self, x)
|
QMainWindow.__init__(self, x)
|
||||||
|
|
||||||
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
|
self.setWindowFlags(Qt.WindowType.FramelessWindowHint)
|
||||||
|
|
||||||
self.sideGrips = [
|
self.sideGrips = [
|
||||||
SideGrip(self, QtCore.Qt.LeftEdge),
|
SideGrip(self, Qt.Edge.LeftEdge),
|
||||||
SideGrip(self, QtCore.Qt.TopEdge),
|
SideGrip(self, Qt.Edge.TopEdge),
|
||||||
SideGrip(self, QtCore.Qt.RightEdge),
|
SideGrip(self, Qt.Edge.RightEdge),
|
||||||
SideGrip(self, QtCore.Qt.BottomEdge),
|
SideGrip(self, Qt.Edge.BottomEdge),
|
||||||
]
|
]
|
||||||
# corner grips should be "on top" of everything, otherwise the side grips
|
# corner grips should be "on top" of everything, otherwise the side grips
|
||||||
# will take precedence on mouse events, so we are adding them *after*;
|
# will take precedence on mouse events, so we are adding them *after*;
|
||||||
# alternatively, widget.raise_() can be used
|
# alternatively, widget.raise_() can be used
|
||||||
self.cornerGrips = [QtWidgets.QSizeGrip(self) for i in range(4)]
|
self.cornerGrips = [QSizeGrip(self) for i in range(4)]
|
||||||
for s in self.cornerGrips:
|
for s in self.cornerGrips:
|
||||||
s.setStyleSheet(""" background-color: transparent; """)
|
s.setStyleSheet(""" background-color: transparent; """)
|
||||||
|
|
||||||
@ -96,20 +96,18 @@ class Mainw(QtWidgets.QMainWindow):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# top left
|
# top left
|
||||||
self.cornerGrips[0].setGeometry(
|
self.cornerGrips[0].setGeometry(QRect(outRect.topLeft(), inRect.topLeft()))
|
||||||
QtCore.QRect(outRect.topLeft(), inRect.topLeft())
|
|
||||||
)
|
|
||||||
# top right
|
# top right
|
||||||
self.cornerGrips[1].setGeometry(
|
self.cornerGrips[1].setGeometry(
|
||||||
QtCore.QRect(outRect.topRight(), inRect.topRight()).normalized()
|
QRect(outRect.topRight(), inRect.topRight()).normalized()
|
||||||
)
|
)
|
||||||
# bottom right
|
# bottom right
|
||||||
self.cornerGrips[2].setGeometry(
|
self.cornerGrips[2].setGeometry(
|
||||||
QtCore.QRect(inRect.bottomRight(), outRect.bottomRight())
|
QRect(inRect.bottomRight(), outRect.bottomRight())
|
||||||
)
|
)
|
||||||
# bottom left
|
# bottom left
|
||||||
self.cornerGrips[3].setGeometry(
|
self.cornerGrips[3].setGeometry(
|
||||||
QtCore.QRect(outRect.bottomLeft(), inRect.bottomLeft()).normalized()
|
QRect(outRect.bottomLeft(), inRect.bottomLeft()).normalized()
|
||||||
)
|
)
|
||||||
|
|
||||||
# left edge
|
# left edge
|
||||||
@ -126,11 +124,11 @@ class Mainw(QtWidgets.QMainWindow):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def resizeEvent(self, event):
|
def resizeEvent(self, event):
|
||||||
QtWidgets.QMainWindow.resizeEvent(self, event)
|
QMainWindow.resizeEvent(self, event)
|
||||||
self.updateGrips()
|
self.updateGrips()
|
||||||
|
|
||||||
|
|
||||||
# app = QtWidgets.QApplication([])
|
# app = QApplication([])
|
||||||
# m = Mainw()
|
# m = Mainw()
|
||||||
# m.show()
|
# m.show()
|
||||||
# m.resize(240, 160)
|
# m.resize(240, 160)
|
||||||
|
@ -1,33 +1,7 @@
|
|||||||
import functools, json, windows
|
import functools, json, windows
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from PyQt5.QtCore import Qt
|
from qtsymbols import *
|
||||||
from PyQt5.QtWidgets import (
|
|
||||||
QSizePolicy,
|
|
||||||
QWidget,
|
|
||||||
QHBoxLayout,
|
|
||||||
QDialog,
|
|
||||||
QAction,
|
|
||||||
QVBoxLayout,
|
|
||||||
QMenu,
|
|
||||||
QPlainTextEdit,
|
|
||||||
QTabWidget,
|
|
||||||
QComboBox,
|
|
||||||
QLineEdit,
|
|
||||||
QPushButton,
|
|
||||||
QTableView,
|
|
||||||
QAbstractItemView,
|
|
||||||
QRadioButton,
|
|
||||||
QButtonGroup,
|
|
||||||
QHeaderView,
|
|
||||||
QCheckBox,
|
|
||||||
QSpinBox,
|
|
||||||
QFormLayout,
|
|
||||||
QLabel,
|
|
||||||
)
|
|
||||||
from myutils.config import savehook_new_data, static_data
|
from myutils.config import savehook_new_data, static_data
|
||||||
from PyQt5.QtGui import QStandardItem, QStandardItemModel
|
|
||||||
from PyQt5.QtGui import QTextCursor
|
|
||||||
from PyQt5.QtCore import Qt, pyqtSignal, QModelIndex, QPoint
|
|
||||||
import qtawesome
|
import qtawesome
|
||||||
import subprocess
|
import subprocess
|
||||||
import winsharedutils
|
import winsharedutils
|
||||||
@ -221,7 +195,7 @@ class searchhookparam(QDialog):
|
|||||||
return space_hex_str
|
return space_hex_str
|
||||||
|
|
||||||
def __init__(self, parent) -> None:
|
def __init__(self, parent) -> None:
|
||||||
super().__init__(parent, Qt.WindowCloseButtonHint)
|
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||||
windows.SetWindowPos(
|
windows.SetWindowPos(
|
||||||
int(int(self.winId())),
|
int(int(self.winId())),
|
||||||
windows.HWND_TOPMOST,
|
windows.HWND_TOPMOST,
|
||||||
@ -450,17 +424,17 @@ class hookselect(closeashidewindow):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.tttable.horizontalHeader().setSectionResizeMode(
|
self.tttable.horizontalHeader().setSectionResizeMode(
|
||||||
2, QHeaderView.Interactive
|
2, QHeaderView.ResizeMode.Interactive
|
||||||
)
|
)
|
||||||
self.tttable.horizontalHeader().setSectionResizeMode(
|
self.tttable.horizontalHeader().setSectionResizeMode(
|
||||||
3, QHeaderView.Interactive
|
3, QHeaderView.ResizeMode.Interactive
|
||||||
)
|
)
|
||||||
|
|
||||||
self.tttable.horizontalHeader().setSectionResizeMode(
|
self.tttable.horizontalHeader().setSectionResizeMode(
|
||||||
0, QHeaderView.ResizeToContents
|
0, QHeaderView.ResizeMode.ResizeToContents
|
||||||
)
|
)
|
||||||
self.tttable.horizontalHeader().setSectionResizeMode(
|
self.tttable.horizontalHeader().setSectionResizeMode(
|
||||||
1, QHeaderView.ResizeToContents
|
1, QHeaderView.ResizeMode.ResizeToContents
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.ttCombomodelmodel.setHorizontalHeaderLabels(
|
self.ttCombomodelmodel.setHorizontalHeaderLabels(
|
||||||
@ -468,14 +442,14 @@ class hookselect(closeashidewindow):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.tttable.horizontalHeader().setSectionResizeMode(
|
self.tttable.horizontalHeader().setSectionResizeMode(
|
||||||
1, QHeaderView.Interactive
|
1, QHeaderView.ResizeMode.Interactive
|
||||||
)
|
)
|
||||||
self.tttable.horizontalHeader().setSectionResizeMode(
|
self.tttable.horizontalHeader().setSectionResizeMode(
|
||||||
2, QHeaderView.Interactive
|
2, QHeaderView.ResizeMode.Interactive
|
||||||
)
|
)
|
||||||
|
|
||||||
self.tttable.horizontalHeader().setSectionResizeMode(
|
self.tttable.horizontalHeader().setSectionResizeMode(
|
||||||
0, QHeaderView.ResizeToContents
|
0, QHeaderView.ResizeMode.ResizeToContents
|
||||||
)
|
)
|
||||||
|
|
||||||
if hc[0] == "E":
|
if hc[0] == "E":
|
||||||
@ -544,7 +518,9 @@ class hookselect(closeashidewindow):
|
|||||||
hlay.addWidget(label)
|
hlay.addWidget(label)
|
||||||
label.setStyleSheet("background-color: rgba(255, 255, 255, 0)")
|
label.setStyleSheet("background-color: rgba(255, 255, 255, 0)")
|
||||||
checkbtn = QPushButton()
|
checkbtn = QPushButton()
|
||||||
checkbtn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
|
checkbtn.setSizePolicy(
|
||||||
|
QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Preferred
|
||||||
|
)
|
||||||
|
|
||||||
def _t(tp):
|
def _t(tp):
|
||||||
_isusing = gobject.baseobject.textsource.checkisusingembed(
|
_isusing = gobject.baseobject.textsource.checkisusingembed(
|
||||||
@ -610,20 +586,22 @@ class hookselect(closeashidewindow):
|
|||||||
|
|
||||||
self.tttable = QTableView()
|
self.tttable = QTableView()
|
||||||
self.tttable.setModel(self.ttCombomodelmodel)
|
self.tttable.setModel(self.ttCombomodelmodel)
|
||||||
# self.tttable .horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
# self.tttable .horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
|
||||||
self.tttable.horizontalHeader().setStretchLastSection(True)
|
self.tttable.horizontalHeader().setStretchLastSection(True)
|
||||||
self.tttable.setSelectionBehavior(QAbstractItemView.SelectRows)
|
self.tttable.setSelectionBehavior(
|
||||||
self.tttable.setSelectionMode(QAbstractItemView.SingleSelection)
|
QAbstractItemView.SelectionBehavior.SelectRows
|
||||||
self.tttable.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
)
|
||||||
|
self.tttable.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection)
|
||||||
|
self.tttable.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
|
||||||
|
|
||||||
self.tttable.doubleClicked.connect(self.table1doubleclicked)
|
self.tttable.doubleClicked.connect(self.table1doubleclicked)
|
||||||
self.tttable.clicked.connect(self.ViewThread)
|
self.tttable.clicked.connect(self.ViewThread)
|
||||||
# self.tttable.setFont(font)
|
# self.tttable.setFont(font)
|
||||||
self.vboxlayout.addWidget(self.tttable)
|
self.vboxlayout.addWidget(self.tttable)
|
||||||
# table.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
# table.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
|
||||||
# table.clicked.connect(self.show_info)
|
# table.clicked.connect(self.show_info)
|
||||||
|
|
||||||
self.tttable.setContextMenuPolicy(Qt.CustomContextMenu)
|
self.tttable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
||||||
self.tttable.customContextMenuRequested.connect(self.showmenu)
|
self.tttable.customContextMenuRequested.connect(self.showmenu)
|
||||||
|
|
||||||
# self.ttCombo.setMaxVisibleItems(50)
|
# self.ttCombo.setMaxVisibleItems(50)
|
||||||
@ -671,11 +649,13 @@ class hookselect(closeashidewindow):
|
|||||||
|
|
||||||
self.tttable2 = QTableView(self)
|
self.tttable2 = QTableView(self)
|
||||||
self.tttable2.setModel(self.ttCombomodelmodel2)
|
self.tttable2.setModel(self.ttCombomodelmodel2)
|
||||||
# self.tttable2 .horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
|
# self.tttable2 .horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)
|
||||||
self.tttable2.horizontalHeader().setStretchLastSection(True)
|
self.tttable2.horizontalHeader().setStretchLastSection(True)
|
||||||
self.tttable2.setSelectionBehavior(QAbstractItemView.SelectRows)
|
self.tttable2.setSelectionBehavior(
|
||||||
self.tttable2.setSelectionMode(QAbstractItemView.SingleSelection)
|
QAbstractItemView.SelectionBehavior.SelectRows
|
||||||
self.tttable2.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
)
|
||||||
|
self.tttable2.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection)
|
||||||
|
self.tttable2.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
|
||||||
self.tttable2.clicked.connect(self.ViewThread2)
|
self.tttable2.clicked.connect(self.ViewThread2)
|
||||||
|
|
||||||
self.vboxlayout.addWidget(self.tttable2)
|
self.vboxlayout.addWidget(self.tttable2)
|
||||||
@ -705,7 +685,7 @@ class hookselect(closeashidewindow):
|
|||||||
self.sysOutput.setReadOnly(True)
|
self.sysOutput.setReadOnly(True)
|
||||||
|
|
||||||
self.tabwidget = QTabWidget()
|
self.tabwidget = QTabWidget()
|
||||||
self.tabwidget.setTabPosition(QTabWidget.East)
|
self.tabwidget.setTabPosition(QTabWidget.TabPosition.East)
|
||||||
self.tabwidget.addTab(self.textOutput, _TR("文本"))
|
self.tabwidget.addTab(self.textOutput, _TR("文本"))
|
||||||
self.tabwidget.addTab(self.sysOutput, _TR("系统"))
|
self.tabwidget.addTab(self.sysOutput, _TR("系统"))
|
||||||
|
|
||||||
@ -962,7 +942,7 @@ class hookselect(closeashidewindow):
|
|||||||
self.textOutput.setPlainText(
|
self.textOutput.setPlainText(
|
||||||
gobject.baseobject.textsource.QueryThreadHistory(tp)
|
gobject.baseobject.textsource.QueryThreadHistory(tp)
|
||||||
)
|
)
|
||||||
self.textOutput.moveCursor(QTextCursor.End)
|
self.textOutput.moveCursor(QTextCursor.MoveOperation.End)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
print_exc()
|
print_exc()
|
||||||
|
@ -1,14 +1,4 @@
|
|||||||
from PyQt5.QtCore import pyqtSignal, Qt, QSize
|
from qtsymbols import *
|
||||||
from PyQt5.QtWidgets import (
|
|
||||||
QWidget,
|
|
||||||
QListWidget,
|
|
||||||
QHBoxLayout,
|
|
||||||
QListWidgetItem,
|
|
||||||
QMenu,
|
|
||||||
QAction,
|
|
||||||
)
|
|
||||||
from PyQt5.QtGui import QFont, QFontMetrics
|
|
||||||
from PyQt5.QtWidgets import QTabWidget
|
|
||||||
import qtawesome, gobject
|
import qtawesome, gobject
|
||||||
import threading, windows, winsharedutils
|
import threading, windows, winsharedutils
|
||||||
from myutils.config import globalconfig, _TR
|
from myutils.config import globalconfig, _TR
|
||||||
@ -55,7 +45,7 @@ class TabWidget(QWidget):
|
|||||||
self.titles.append(title)
|
self.titles.append(title)
|
||||||
self.tab_widget.addTab(widget, title)
|
self.tab_widget.addTab(widget, title)
|
||||||
item = QListWidgetItem(title)
|
item = QListWidgetItem(title)
|
||||||
item.setTextAlignment(Qt.AlignCenter)
|
item.setTextAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||||
item.setSizeHint(QSize(self.tab_widget.width(), 50))
|
item.setSizeHint(QSize(self.tab_widget.width(), 50))
|
||||||
self.list_widget.addItem(item)
|
self.list_widget.addItem(item)
|
||||||
if self.idx == 0:
|
if self.idx == 0:
|
||||||
@ -135,7 +125,7 @@ class Settin(closeashidewindow):
|
|||||||
fn.setFamily(globalconfig["settingfonttype"])
|
fn.setFamily(globalconfig["settingfonttype"])
|
||||||
fm = QFontMetrics(fn)
|
fm = QFontMetrics(fn)
|
||||||
for title in self.tab_widget.titles:
|
for title in self.tab_widget.titles:
|
||||||
width = max(fm.width(title), width)
|
width = max(fm.size(0, title).width(), width)
|
||||||
width += 100
|
width += 100
|
||||||
self.tab_widget.list_widget.setFixedWidth(width)
|
self.tab_widget.list_widget.setFixedWidth(width)
|
||||||
self.list_width = width
|
self.list_width = width
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from PyQt5.QtWidgets import QLineEdit, QPushButton
|
from qtsymbols import *
|
||||||
from myutils.config import _TR
|
from myutils.config import _TR
|
||||||
from myutils.config import globalconfig
|
from myutils.config import globalconfig
|
||||||
from myutils.utils import splittranslatortypes
|
from myutils.utils import splittranslatortypes
|
||||||
@ -13,7 +13,7 @@ from gui.usefulwidget import (
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
def getall(self, l, item="fanyi", name=""):
|
def getall(l, item="fanyi", name=""):
|
||||||
grids = []
|
grids = []
|
||||||
i = 0
|
i = 0
|
||||||
line = []
|
line = []
|
||||||
@ -29,6 +29,7 @@ def getall(self, l, item="fanyi", name=""):
|
|||||||
line += [
|
line += [
|
||||||
(globalconfig[item][fanyi]["name"], 6),
|
(globalconfig[item][fanyi]["name"], 6),
|
||||||
getsimpleswitch(globalconfig[item][fanyi], "useproxy", default=True),
|
getsimpleswitch(globalconfig[item][fanyi], "useproxy", default=True),
|
||||||
|
"",
|
||||||
]
|
]
|
||||||
if i % 3 == 0:
|
if i % 3 == 0:
|
||||||
grids.append(line)
|
grids.append(line)
|
||||||
@ -72,14 +73,9 @@ def setTab_proxy_lazy(self):
|
|||||||
]
|
]
|
||||||
lixians, pre, mianfei, develop, shoufei = splittranslatortypes()
|
lixians, pre, mianfei, develop, shoufei = splittranslatortypes()
|
||||||
|
|
||||||
mianfei = getall(
|
mianfei = getall(l=mianfei, item="fanyi", name="./Lunatranslator/translator/%s.py")
|
||||||
self, l=mianfei, item="fanyi", name="./Lunatranslator/translator/%s.py"
|
shoufei = getall(l=shoufei, item="fanyi", name="./Lunatranslator/translator/%s.py")
|
||||||
)
|
|
||||||
shoufei = getall(
|
|
||||||
self, l=shoufei, item="fanyi", name="./Lunatranslator/translator/%s.py"
|
|
||||||
)
|
|
||||||
ocrs = getall(
|
ocrs = getall(
|
||||||
self,
|
|
||||||
l=set(globalconfig["ocr"].keys()) - set(["local", "windowsocr"]),
|
l=set(globalconfig["ocr"].keys()) - set(["local", "windowsocr"]),
|
||||||
item="ocr",
|
item="ocr",
|
||||||
name="./Lunatranslator/ocrengines/%s.py",
|
name="./Lunatranslator/ocrengines/%s.py",
|
||||||
|
@ -1,15 +1,5 @@
|
|||||||
import functools, os, windows, json
|
import functools, os, windows, json
|
||||||
from PyQt5.QtGui import QFont
|
from qtsymbols import *
|
||||||
from PyQt5.QtCore import Qt, QSize
|
|
||||||
from PyQt5.QtWidgets import (
|
|
||||||
QFontComboBox,
|
|
||||||
QDialog,
|
|
||||||
QLabel,
|
|
||||||
QComboBox,
|
|
||||||
QFileDialog,
|
|
||||||
QFormLayout,
|
|
||||||
QDialogButtonBox,
|
|
||||||
)
|
|
||||||
from gui.pretransfile import sqlite2json2
|
from gui.pretransfile import sqlite2json2
|
||||||
from gui.settingpage_ocr import getocrgrid
|
from gui.settingpage_ocr import getocrgrid
|
||||||
from myutils.config import globalconfig, _TR, _TRL, savehook_new_data, savehook_new_list
|
from myutils.config import globalconfig, _TR, _TRL, savehook_new_data, savehook_new_list
|
||||||
@ -172,7 +162,7 @@ def doexportchspatch(exe, realgame):
|
|||||||
|
|
||||||
def getunknowgameexe(self):
|
def getunknowgameexe(self):
|
||||||
|
|
||||||
dialog = QDialog(self, Qt.WindowCloseButtonHint) # 自定义一个dialog
|
dialog = QDialog(self, Qt.WindowType.WindowCloseButtonHint) # 自定义一个dialog
|
||||||
dialog.setWindowTitle(_TR("选择游戏"))
|
dialog.setWindowTitle(_TR("选择游戏"))
|
||||||
dialog.resize(QSize(800, 10))
|
dialog.resize(QSize(800, 10))
|
||||||
formLayout = QFormLayout(dialog)
|
formLayout = QFormLayout(dialog)
|
||||||
@ -183,12 +173,14 @@ def getunknowgameexe(self):
|
|||||||
|
|
||||||
formLayout.addRow(_TR("选择游戏"), combo)
|
formLayout.addRow(_TR("选择游戏"), combo)
|
||||||
|
|
||||||
button = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
button = QDialogButtonBox(
|
||||||
|
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
|
||||||
|
)
|
||||||
formLayout.addRow(button)
|
formLayout.addRow(button)
|
||||||
button.rejected.connect(dialog.close)
|
button.rejected.connect(dialog.close)
|
||||||
button.accepted.connect(dialog.accept)
|
button.accepted.connect(dialog.accept)
|
||||||
button.button(QDialogButtonBox.Ok).setText(_TR("确定"))
|
button.button(QDialogButtonBox.StandardButton.Ok).setText(_TR("确定"))
|
||||||
button.button(QDialogButtonBox.Cancel).setText(_TR("取消"))
|
button.button(QDialogButtonBox.StandardButton.Cancel).setText(_TR("取消"))
|
||||||
if dialog.exec():
|
if dialog.exec():
|
||||||
return savehook_new_list[combo.currentIndex()]
|
return savehook_new_list[combo.currentIndex()]
|
||||||
|
|
||||||
@ -241,7 +233,7 @@ def gethookembedgrid(self):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.gamefont_comboBox.activated[str].connect(callback)
|
self.gamefont_comboBox.currentTextChanged.connect(callback)
|
||||||
self.gamefont_comboBox.setCurrentFont(
|
self.gamefont_comboBox.setCurrentFont(
|
||||||
QFont(globalconfig["embedded"]["changefont_font"])
|
QFont(globalconfig["embedded"]["changefont_font"])
|
||||||
)
|
)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from PyQt5.QtWidgets import QPushButton, QLabel
|
from qtsymbols import *
|
||||||
import functools, gobject
|
import functools, gobject
|
||||||
from myutils.config import globalconfig, translatorsetting
|
from myutils.config import globalconfig, translatorsetting
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ def setTabTwo_lazy(self):
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
("端口号", 8),
|
("端口号", 8),
|
||||||
(getspinbox(0, 65535, globalconfig, "debugport"), 3),
|
(getspinbox(0, 65535, globalconfig, "debugport"), 4),
|
||||||
],
|
],
|
||||||
[(self.statuslabel, 16)],
|
[(self.statuslabel, 16)],
|
||||||
[],
|
[],
|
||||||
|
@ -1,14 +1,5 @@
|
|||||||
import functools
|
import functools
|
||||||
|
from qtsymbols import *
|
||||||
from PyQt5.QtWidgets import (
|
|
||||||
QHBoxLayout,
|
|
||||||
QPlainTextEdit,
|
|
||||||
QHBoxLayout,
|
|
||||||
QWidget,
|
|
||||||
QMenu,
|
|
||||||
QAction,
|
|
||||||
)
|
|
||||||
from PyQt5.QtCore import Qt, QPoint
|
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from myutils.config import (
|
from myutils.config import (
|
||||||
globalconfig,
|
globalconfig,
|
||||||
@ -241,7 +232,7 @@ def setTab7_lazy(self):
|
|||||||
|
|
||||||
def __():
|
def __():
|
||||||
_w = makescroll(makegrid(grids, True, savelist, savelay))
|
_w = makescroll(makegrid(grids, True, savelist, savelay))
|
||||||
_w.setContextMenuPolicy(Qt.CustomContextMenu)
|
_w.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
||||||
|
|
||||||
def showmenu(p: QPoint):
|
def showmenu(p: QPoint):
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
from PyQt5.QtCore import Qt
|
from qtsymbols import *
|
||||||
from PyQt5.QtGui import QPixmap, QImage
|
|
||||||
from PyQt5.QtWidgets import QLabel, QProgressBar
|
|
||||||
from gui.usefulwidget import (
|
from gui.usefulwidget import (
|
||||||
getsimpleswitch,
|
getsimpleswitch,
|
||||||
getsimplecombobox,
|
getsimplecombobox,
|
||||||
@ -59,13 +57,17 @@ def setTab_about_dicrect(self):
|
|||||||
|
|
||||||
self.versionlabel = QLabel()
|
self.versionlabel = QLabel()
|
||||||
self.versionlabel.setOpenExternalLinks(True)
|
self.versionlabel.setOpenExternalLinks(True)
|
||||||
self.versionlabel.setTextInteractionFlags(Qt.LinksAccessibleByMouse)
|
self.versionlabel.setTextInteractionFlags(
|
||||||
|
Qt.TextInteractionFlag.LinksAccessibleByMouse
|
||||||
|
)
|
||||||
self.versiontextsignal.connect(lambda x: self.versionlabel.setText(x))
|
self.versiontextsignal.connect(lambda x: self.versionlabel.setText(x))
|
||||||
self.downloadprogress = QProgressBar()
|
self.downloadprogress = QProgressBar()
|
||||||
|
|
||||||
self.downloadprogress.setRange(0, 10000)
|
self.downloadprogress.setRange(0, 10000)
|
||||||
|
|
||||||
self.downloadprogress.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
|
self.downloadprogress.setAlignment(
|
||||||
|
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter
|
||||||
|
)
|
||||||
self.progresssignal.connect(lambda text, val: updateprogress(self, text, val))
|
self.progresssignal.connect(lambda text, val: updateprogress(self, text, val))
|
||||||
getversion(self)
|
getversion(self)
|
||||||
|
|
||||||
@ -164,8 +166,8 @@ def setTab_aboutlazy(self):
|
|||||||
img = img.scaled(
|
img = img.scaled(
|
||||||
600,
|
600,
|
||||||
600,
|
600,
|
||||||
Qt.KeepAspectRatio,
|
Qt.AspectRatioMode.KeepAspectRatio,
|
||||||
Qt.SmoothTransformation,
|
Qt.TransformationMode.SmoothTransformation,
|
||||||
)
|
)
|
||||||
lb.setPixmap(img)
|
lb.setPixmap(img)
|
||||||
shuominggrid += [[(lb, 0)]]
|
shuominggrid += [[(lb, 0)]]
|
||||||
|
@ -3,7 +3,7 @@ from myutils.config import globalconfig, _TR
|
|||||||
from myutils.winsyshotkey import SystemHotkey, registerException
|
from myutils.winsyshotkey import SystemHotkey, registerException
|
||||||
import winsharedutils
|
import winsharedutils
|
||||||
import gobject, windows
|
import gobject, windows
|
||||||
from PyQt5.QtWidgets import QLabel
|
from qtsymbols import *
|
||||||
from gui.usefulwidget import (
|
from gui.usefulwidget import (
|
||||||
getsimpleswitch,
|
getsimpleswitch,
|
||||||
getsimplekeyseq,
|
getsimplekeyseq,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import functools
|
import functools
|
||||||
|
from qtsymbols import *
|
||||||
from PyQt5.QtWidgets import QComboBox
|
|
||||||
from gui.inputdialog import autoinitdialog_items, noundictconfigdialog1, autoinitdialog
|
from gui.inputdialog import autoinitdialog_items, noundictconfigdialog1, autoinitdialog
|
||||||
from myutils.config import globalconfig, _TRL
|
from myutils.config import globalconfig, _TRL
|
||||||
import os, functools
|
import os, functools
|
||||||
|
@ -1,17 +1,9 @@
|
|||||||
import functools
|
import functools
|
||||||
from PyQt5.QtGui import QFont
|
from qtsymbols import *
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QTableView, QAbstractItemView
|
|
||||||
from PyQt5.QtWidgets import QHeaderView
|
|
||||||
from PyQt5.QtCore import Qt
|
|
||||||
|
|
||||||
from PyQt5.QtGui import QStandardItem, QStandardItemModel
|
|
||||||
from PyQt5.QtWidgets import QLabel, QSlider, QFontComboBox, QDialog, QGridLayout
|
|
||||||
from gui.inputdialog import multicolorset
|
from gui.inputdialog import multicolorset
|
||||||
from myutils.config import globalconfig, _TR, _TRL, magpie_config, static_data
|
from myutils.config import globalconfig, _TR, _TRL, magpie_config, static_data
|
||||||
from myutils.wrapper import Singleton
|
from myutils.wrapper import Singleton
|
||||||
import qtawesome, gobject, json
|
import qtawesome, gobject, json
|
||||||
from winsharedutils import showintab
|
|
||||||
from gui.inputdialog import getsomepath1
|
from gui.inputdialog import getsomepath1
|
||||||
from gui.usefulwidget import (
|
from gui.usefulwidget import (
|
||||||
getsimplecombobox,
|
getsimplecombobox,
|
||||||
@ -179,7 +171,7 @@ def createbuttonwidget(self):
|
|||||||
class dialog_selecticon(QDialog):
|
class dialog_selecticon(QDialog):
|
||||||
def __init__(self, parent, dict, key, _nouse_for_click_arg) -> None:
|
def __init__(self, parent, dict, key, _nouse_for_click_arg) -> None:
|
||||||
|
|
||||||
super().__init__(parent, Qt.WindowCloseButtonHint)
|
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||||
self.dict = dict
|
self.dict = dict
|
||||||
self.key = key
|
self.key = key
|
||||||
self.setWindowTitle(_TR("选择图标"))
|
self.setWindowTitle(_TR("选择图标"))
|
||||||
@ -216,7 +208,7 @@ def setTabThree_lazy(self):
|
|||||||
self.horizontal_slider = QSlider()
|
self.horizontal_slider = QSlider()
|
||||||
self.horizontal_slider.setMaximum(100)
|
self.horizontal_slider.setMaximum(100)
|
||||||
self.horizontal_slider.setMinimum(1)
|
self.horizontal_slider.setMinimum(1)
|
||||||
self.horizontal_slider.setOrientation(Qt.Horizontal)
|
self.horizontal_slider.setOrientation(Qt.Orientation.Horizontal)
|
||||||
self.horizontal_slider.setValue(0)
|
self.horizontal_slider.setValue(0)
|
||||||
self.horizontal_slider.setValue(globalconfig["transparent"])
|
self.horizontal_slider.setValue(globalconfig["transparent"])
|
||||||
self.horizontal_slider.valueChanged.connect(
|
self.horizontal_slider.valueChanged.connect(
|
||||||
@ -228,7 +220,7 @@ def setTabThree_lazy(self):
|
|||||||
self.horizontal_slider_tool = QSlider()
|
self.horizontal_slider_tool = QSlider()
|
||||||
self.horizontal_slider_tool.setMaximum(100)
|
self.horizontal_slider_tool.setMaximum(100)
|
||||||
self.horizontal_slider_tool.setMinimum(1)
|
self.horizontal_slider_tool.setMinimum(1)
|
||||||
self.horizontal_slider_tool.setOrientation(Qt.Horizontal)
|
self.horizontal_slider_tool.setOrientation(Qt.Orientation.Horizontal)
|
||||||
self.horizontal_slider_tool.setValue(0)
|
self.horizontal_slider_tool.setValue(0)
|
||||||
self.horizontal_slider_tool.setValue(globalconfig["transparent_tool"])
|
self.horizontal_slider_tool.setValue(globalconfig["transparent_tool"])
|
||||||
self.horizontal_slider_tool.valueChanged.connect(
|
self.horizontal_slider_tool.valueChanged.connect(
|
||||||
@ -240,12 +232,12 @@ def setTabThree_lazy(self):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.font_comboBox = QFontComboBox()
|
self.font_comboBox = QFontComboBox()
|
||||||
self.font_comboBox.activated[str].connect(
|
self.font_comboBox.currentTextChanged.connect(
|
||||||
lambda x: globalconfig.__setitem__("fonttype", x)
|
lambda x: globalconfig.__setitem__("fonttype", x)
|
||||||
)
|
)
|
||||||
self.font_comboBox.setCurrentFont(QFont(globalconfig["fonttype"]))
|
self.font_comboBox.setCurrentFont(QFont(globalconfig["fonttype"]))
|
||||||
self.font_comboBox2 = QFontComboBox()
|
self.font_comboBox2 = QFontComboBox()
|
||||||
self.font_comboBox2.activated[str].connect(
|
self.font_comboBox2.currentTextChanged.connect(
|
||||||
lambda x: globalconfig.__setitem__("fonttype2", x)
|
lambda x: globalconfig.__setitem__("fonttype2", x)
|
||||||
)
|
)
|
||||||
self.font_comboBox2.setCurrentFont(QFont(globalconfig["fonttype2"]))
|
self.font_comboBox2.setCurrentFont(QFont(globalconfig["fonttype2"]))
|
||||||
@ -256,29 +248,27 @@ def setTabThree_lazy(self):
|
|||||||
globalconfig.__setitem__("settingfonttype", x)
|
globalconfig.__setitem__("settingfonttype", x)
|
||||||
gobject.baseobject.setcommonstylesheet()
|
gobject.baseobject.setcommonstylesheet()
|
||||||
|
|
||||||
self.sfont_comboBox.activated[str].connect(callback)
|
self.sfont_comboBox.currentTextChanged.connect(callback)
|
||||||
self.sfont_comboBox.setCurrentFont(QFont(globalconfig["settingfonttype"]))
|
self.sfont_comboBox.setCurrentFont(QFont(globalconfig["settingfonttype"]))
|
||||||
|
|
||||||
textgrid = [
|
textgrid = [
|
||||||
|
[("原文字体", 3), (self.font_comboBox, 6), ("", 5)],
|
||||||
[
|
[
|
||||||
("原文字体", 3),
|
|
||||||
(self.font_comboBox, 5),
|
|
||||||
"",
|
|
||||||
("译文字体", 3),
|
("译文字体", 3),
|
||||||
(self.font_comboBox2, 5),
|
(self.font_comboBox2, 6),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
("字体大小", 3),
|
("字体大小", 3),
|
||||||
(self.fontSize_spinBox, 2),
|
(self.fontSize_spinBox, 3),
|
||||||
"",
|
"",
|
||||||
("额外的行间距", 3),
|
("额外的行间距", 3),
|
||||||
(getspinbox(-100, 100, globalconfig, "extra_space"), 2),
|
(getspinbox(-100, 100, globalconfig, "extra_space"), 3),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
("居中显示", 4),
|
("居中显示", 5),
|
||||||
getsimpleswitch(globalconfig, "showatcenter"),
|
getsimpleswitch(globalconfig, "showatcenter"),
|
||||||
"",
|
"",
|
||||||
("加粗字体", 4),
|
("加粗字体", 5),
|
||||||
getsimpleswitch(globalconfig, "showbold"),
|
getsimpleswitch(globalconfig, "showbold"),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -301,11 +291,11 @@ def setTabThree_lazy(self):
|
|||||||
globalconfig,
|
globalconfig,
|
||||||
"zitiyangshi2",
|
"zitiyangshi2",
|
||||||
),
|
),
|
||||||
5,
|
6,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
("特殊字体样式填充颜色", 4),
|
("特殊字体样式填充颜色", 5),
|
||||||
getcolorbutton(
|
getcolorbutton(
|
||||||
globalconfig,
|
globalconfig,
|
||||||
"miaobiancolor",
|
"miaobiancolor",
|
||||||
@ -323,7 +313,7 @@ def setTabThree_lazy(self):
|
|||||||
getspinbox(
|
getspinbox(
|
||||||
0.1, 100, globalconfig, "miaobianwidth", double=True, step=0.1
|
0.1, 100, globalconfig, "miaobianwidth", double=True, step=0.1
|
||||||
),
|
),
|
||||||
2,
|
3,
|
||||||
),
|
),
|
||||||
"",
|
"",
|
||||||
("描边宽度", 3),
|
("描边宽度", 3),
|
||||||
@ -331,27 +321,31 @@ def setTabThree_lazy(self):
|
|||||||
getspinbox(
|
getspinbox(
|
||||||
0.1, 100, globalconfig, "miaobianwidth2", double=True, step=0.1
|
0.1, 100, globalconfig, "miaobianwidth2", double=True, step=0.1
|
||||||
),
|
),
|
||||||
2,
|
3,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
("发光亮度", 3),
|
("发光亮度", 3),
|
||||||
(getspinbox(1, 100, globalconfig, "shadowforce"), 2),
|
(getspinbox(1, 100, globalconfig, "shadowforce"), 3),
|
||||||
"",
|
"",
|
||||||
("投影距离", 3),
|
("投影距离", 3),
|
||||||
(
|
(
|
||||||
getspinbox(
|
getspinbox(
|
||||||
0.1, 100, globalconfig, "traceoffset", double=True, step=0.1
|
0.1, 100, globalconfig, "traceoffset", double=True, step=0.1
|
||||||
),
|
),
|
||||||
2,
|
3,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
("显示原文", 4),
|
("显示原文", 5),
|
||||||
self.show_original_switch,
|
self.show_original_switch,
|
||||||
"",
|
"",
|
||||||
("原文颜色", 4),
|
("显示翻译", 5),
|
||||||
|
(getsimpleswitch(globalconfig, "showfanyi"), 1),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
("原文颜色", 5),
|
||||||
getcolorbutton(
|
getcolorbutton(
|
||||||
globalconfig,
|
globalconfig,
|
||||||
"rawtextcolor",
|
"rawtextcolor",
|
||||||
@ -361,12 +355,21 @@ def setTabThree_lazy(self):
|
|||||||
name="original_color_button",
|
name="original_color_button",
|
||||||
parent=self,
|
parent=self,
|
||||||
),
|
),
|
||||||
|
"",
|
||||||
|
("显示翻译器名称", 5),
|
||||||
|
(getsimpleswitch(globalconfig, "showfanyisource"), 1),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
("显示日语注音", 4),
|
("最长显示字数", 3),
|
||||||
|
(getspinbox(0, 1000000, globalconfig, "maxoriginlength"), 3),
|
||||||
|
],
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
("显示日语注音", 5),
|
||||||
self.show_hira_switch,
|
self.show_hira_switch,
|
||||||
"",
|
],
|
||||||
("注音颜色", 4),
|
[
|
||||||
|
("注音颜色", 5),
|
||||||
getcolorbutton(
|
getcolorbutton(
|
||||||
globalconfig,
|
globalconfig,
|
||||||
"jiamingcolor",
|
"jiamingcolor",
|
||||||
@ -382,14 +385,14 @@ def setTabThree_lazy(self):
|
|||||||
getspinbox(
|
getspinbox(
|
||||||
0.05, 1, globalconfig, "kanarate", double=True, step=0.05, dec=2
|
0.05, 1, globalconfig, "kanarate", double=True, step=0.05, dec=2
|
||||||
),
|
),
|
||||||
2,
|
3,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
("语法加亮", 4),
|
("语法加亮", 5),
|
||||||
self.show_fenciswitch,
|
self.show_fenciswitch,
|
||||||
"",
|
"",
|
||||||
("词性颜色(需要Mecab)", 4),
|
("词性颜色(需要Mecab)", 5),
|
||||||
getcolorbutton(
|
getcolorbutton(
|
||||||
globalconfig,
|
globalconfig,
|
||||||
"",
|
"",
|
||||||
@ -398,28 +401,10 @@ def setTabThree_lazy(self):
|
|||||||
constcolor="#FF69B4",
|
constcolor="#FF69B4",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
[
|
|
||||||
("显示翻译器名称", 4),
|
|
||||||
(getsimpleswitch(globalconfig, "showfanyisource"), 1),
|
|
||||||
"",
|
|
||||||
("显示翻译", 4),
|
|
||||||
(getsimpleswitch(globalconfig, "showfanyi"), 1),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
("最长显示字数", 4),
|
|
||||||
(getspinbox(0, 1000000, globalconfig, "maxoriginlength"), 2),
|
|
||||||
],
|
|
||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
("收到翻译结果时才刷新", 4),
|
("收到翻译结果时才刷新", 5),
|
||||||
getsimpleswitch(globalconfig, "refresh_on_get_trans"),
|
getsimpleswitch(globalconfig, "refresh_on_get_trans"),
|
||||||
"",
|
|
||||||
("可选取模式", 4),
|
|
||||||
getsimpleswitch(
|
|
||||||
globalconfig,
|
|
||||||
"selectable",
|
|
||||||
callback=lambda x: gobject.baseobject.translation_ui.translate_text.setselectable(),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -477,6 +462,14 @@ def setTabThree_lazy(self):
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
("可选取模式", 6),
|
||||||
|
getsimpleswitch(
|
||||||
|
globalconfig,
|
||||||
|
"selectable",
|
||||||
|
callback=lambda x: gobject.baseobject.translation_ui.translate_text.setselectable(),
|
||||||
|
),
|
||||||
|
],
|
||||||
]
|
]
|
||||||
uigrid = [
|
uigrid = [
|
||||||
[("设置界面字体", 4), (self.sfont_comboBox, 5)],
|
[("设置界面字体", 4), (self.sfont_comboBox, 5)],
|
||||||
@ -586,7 +579,7 @@ def setTabThree_lazy(self):
|
|||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
("明暗", 6),
|
("明暗", 4),
|
||||||
(
|
(
|
||||||
getsimplecombobox(
|
getsimplecombobox(
|
||||||
_TRL(["明亮", "黑暗", "跟随系统"]),
|
_TRL(["明亮", "黑暗", "跟随系统"]),
|
||||||
@ -598,7 +591,7 @@ def setTabThree_lazy(self):
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
("明亮主题", 6),
|
("明亮主题", 4),
|
||||||
(
|
(
|
||||||
getsimplecombobox(
|
getsimplecombobox(
|
||||||
_TRL(["默认"]) + themelist("light"),
|
_TRL(["默认"]) + themelist("light"),
|
||||||
@ -610,7 +603,7 @@ def setTabThree_lazy(self):
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
("黑暗主题", 6),
|
("黑暗主题", 4),
|
||||||
(
|
(
|
||||||
getsimplecombobox(
|
getsimplecombobox(
|
||||||
themelist("dark"),
|
themelist("dark"),
|
||||||
@ -623,7 +616,7 @@ def setTabThree_lazy(self):
|
|||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
("窗口特效_翻译窗口", 6),
|
("窗口特效_翻译窗口", 4),
|
||||||
(
|
(
|
||||||
getsimplecombobox(
|
getsimplecombobox(
|
||||||
["Disable", "Acrylic", "Aero"],
|
["Disable", "Acrylic", "Aero"],
|
||||||
@ -638,7 +631,7 @@ def setTabThree_lazy(self):
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
("窗口特效_其他", 6),
|
("窗口特效_其他", 4),
|
||||||
(
|
(
|
||||||
getsimplecombobox(
|
getsimplecombobox(
|
||||||
["Solid", "Acrylic", "Mica", "MicaAlt"],
|
["Solid", "Acrylic", "Mica", "MicaAlt"],
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
from PyQt5.QtCore import Qt
|
from qtsymbols import *
|
||||||
from PyQt5.QtWidgets import QWidget, QPushButton, QHBoxLayout, QVBoxLayout, QLabel
|
|
||||||
from PyQt5.QtGui import QPixmap
|
|
||||||
from PyQt5.QtCore import Qt, pyqtSignal
|
|
||||||
import qtawesome
|
import qtawesome
|
||||||
from myutils.ocrutil import imagesolve
|
from myutils.ocrutil import imagesolve
|
||||||
from gui.usefulwidget import closeashidewindow
|
from gui.usefulwidget import closeashidewindow
|
||||||
@ -46,12 +43,16 @@ class showocrimage(closeashidewindow):
|
|||||||
|
|
||||||
self.originlabel.setPixmap(
|
self.originlabel.setPixmap(
|
||||||
self.img1.scaled(
|
self.img1.scaled(
|
||||||
self.originlabel.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation
|
self.originlabel.size(),
|
||||||
|
Qt.AspectRatioMode.KeepAspectRatio,
|
||||||
|
Qt.TransformationMode.SmoothTransformation,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.solvedlabel.setPixmap(
|
self.solvedlabel.setPixmap(
|
||||||
self.img2.scaled(
|
self.img2.scaled(
|
||||||
self.solvedlabel.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation
|
self.solvedlabel.size(),
|
||||||
|
Qt.AspectRatioMode.KeepAspectRatio,
|
||||||
|
Qt.TransformationMode.SmoothTransformation,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,26 +1,9 @@
|
|||||||
from PyQt5.QtWidgets import (
|
from qtsymbols import *
|
||||||
QWidget,
|
|
||||||
QHBoxLayout,
|
|
||||||
QVBoxLayout,
|
|
||||||
QTextBrowser,
|
|
||||||
QLineEdit,
|
|
||||||
QPlainTextEdit,
|
|
||||||
QFormLayout,
|
|
||||||
QSizePolicy,
|
|
||||||
QPushButton,
|
|
||||||
QTabWidget,
|
|
||||||
QFileDialog,
|
|
||||||
QTabBar,
|
|
||||||
QSplitter,
|
|
||||||
QLabel,
|
|
||||||
)
|
|
||||||
from myutils.hwnd import grabwindow
|
from myutils.hwnd import grabwindow
|
||||||
|
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
from PyQt5.QtGui import QPixmap, QImage
|
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
import requests, json, time
|
import requests, json, time
|
||||||
from PyQt5.QtCore import pyqtSignal, Qt
|
|
||||||
import qtawesome, functools, os, base64
|
import qtawesome, functools, os, base64
|
||||||
import gobject, uuid, windows
|
import gobject, uuid, windows
|
||||||
from myutils.utils import getimageformat, parsekeystringtomodvkcode, unsupportkey
|
from myutils.utils import getimageformat, parsekeystringtomodvkcode, unsupportkey
|
||||||
@ -156,7 +139,7 @@ class AnkiWindow(QWidget):
|
|||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
||||||
self.setWindowTitle("Anki Connect")
|
self.setWindowTitle("Anki Connect")
|
||||||
self.currentword = ""
|
self.currentword = ""
|
||||||
self.tabs = QTabWidget()
|
self.tabs = QTabWidget()
|
||||||
@ -241,7 +224,9 @@ class AnkiWindow(QWidget):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.htmlbrowser = auto_select_webview(self)
|
self.htmlbrowser = auto_select_webview(self)
|
||||||
self.htmlbrowser.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
self.htmlbrowser.setSizePolicy(
|
||||||
|
QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding
|
||||||
|
)
|
||||||
layout.addLayout(
|
layout.addLayout(
|
||||||
getboxlayout(
|
getboxlayout(
|
||||||
[self.previewtab, self.htmlbrowser],
|
[self.previewtab, self.htmlbrowser],
|
||||||
@ -596,7 +581,9 @@ class AnkiWindow(QWidget):
|
|||||||
pix.width() > self.viewimagelabel.width()
|
pix.width() > self.viewimagelabel.width()
|
||||||
or pix.height() > self.viewimagelabel.height()
|
or pix.height() > self.viewimagelabel.height()
|
||||||
):
|
):
|
||||||
pix = pix.scaled(self.viewimagelabel.size() * rate, Qt.KeepAspectRatio)
|
pix = pix.scaled(
|
||||||
|
self.viewimagelabel.size() * rate, Qt.AspectRatioMode.KeepAspectRatio
|
||||||
|
)
|
||||||
self.viewimagelabel.setPixmap(pix)
|
self.viewimagelabel.setPixmap(pix)
|
||||||
|
|
||||||
def selecfile(self, item):
|
def selecfile(self, item):
|
||||||
@ -837,7 +824,7 @@ class searchwordW(closeashidewindow):
|
|||||||
w.setLayout(tablayout)
|
w.setLayout(tablayout)
|
||||||
self.vboxlayout.addWidget(self.spliter)
|
self.vboxlayout.addWidget(self.spliter)
|
||||||
self.isfirstshowanki = True
|
self.isfirstshowanki = True
|
||||||
self.spliter.setOrientation(Qt.Vertical)
|
self.spliter.setOrientation(Qt.Orientation.Vertical)
|
||||||
|
|
||||||
self.spliter.addWidget(w)
|
self.spliter.addWidget(w)
|
||||||
|
|
||||||
|
@ -1,20 +1,4 @@
|
|||||||
from PyQt5.QtWidgets import QWidget, QSizePolicy, QLabel, QScrollArea, QApplication
|
from qtsymbols import *
|
||||||
from PyQt5.QtGui import (
|
|
||||||
QMouseEvent,
|
|
||||||
QPainter,
|
|
||||||
QPen,
|
|
||||||
QFont,
|
|
||||||
QFontMetrics,
|
|
||||||
QRegion,
|
|
||||||
QResizeEvent,
|
|
||||||
)
|
|
||||||
from PyQt5.QtCore import Qt, QEvent
|
|
||||||
from PyQt5.QtWidgets import (
|
|
||||||
QSpacerItem,
|
|
||||||
QWidgetItem,
|
|
||||||
)
|
|
||||||
from PyQt5.QtCore import QPoint, QRect, QSize, Qt, pyqtSignal
|
|
||||||
from PyQt5.QtWidgets import QLayout
|
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from myutils.wrapper import trypass
|
from myutils.wrapper import trypass
|
||||||
import threading
|
import threading
|
||||||
@ -48,9 +32,9 @@ class chartwidget(QWidget):
|
|||||||
if len(self.data) == 1:
|
if len(self.data) == 1:
|
||||||
self.data.insert(0, (0, 0))
|
self.data.insert(0, (0, 0))
|
||||||
painter = QPainter(self)
|
painter = QPainter(self)
|
||||||
painter.setRenderHint(QPainter.Antialiasing)
|
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||||
|
|
||||||
pen = QPen(Qt.blue)
|
pen = QPen(Qt.GlobalColor.blue)
|
||||||
pen.setWidth(2)
|
pen.setWidth(2)
|
||||||
painter.setPen(pen)
|
painter.setPen(pen)
|
||||||
|
|
||||||
@ -65,7 +49,7 @@ class chartwidget(QWidget):
|
|||||||
|
|
||||||
x_labels = [self.xtext(x) for x, _ in self.data]
|
x_labels = [self.xtext(x) for x, _ in self.data]
|
||||||
for l in y_labels:
|
for l in y_labels:
|
||||||
xmargin = max(xmargin, self.fmetrics.width(l))
|
xmargin = max(xmargin, self.fmetrics.size(0, l).width())
|
||||||
|
|
||||||
xmargin = xmargin + self.scalelinelen
|
xmargin = xmargin + self.scalelinelen
|
||||||
|
|
||||||
@ -73,8 +57,8 @@ class chartwidget(QWidget):
|
|||||||
self.width()
|
self.width()
|
||||||
- xmargin
|
- xmargin
|
||||||
- max(
|
- max(
|
||||||
self.fmetrics.width(x_labels[-1]) // 2,
|
self.fmetrics.size(0, x_labels[-1]).width() // 2,
|
||||||
self.fmetrics.width(self.ytext(self.data[-1][1])) // 2,
|
self.fmetrics.size(0, self.ytext(self.data[-1][1])).width() // 2,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -85,7 +69,7 @@ class chartwidget(QWidget):
|
|||||||
y = int(ymargin + height - i * (height / 5))
|
y = int(ymargin + height - i * (height / 5))
|
||||||
painter.drawLine(xmargin - self.scalelinelen, y, xmargin, y)
|
painter.drawLine(xmargin - self.scalelinelen, y, xmargin, y)
|
||||||
painter.drawText(
|
painter.drawText(
|
||||||
xmargin - self.scalelinelen - self.fmetrics.width(label),
|
xmargin - self.scalelinelen - self.fmetrics.size(0, label).width(),
|
||||||
y + 5,
|
y + 5,
|
||||||
label,
|
label,
|
||||||
)
|
)
|
||||||
@ -115,7 +99,7 @@ class chartwidget(QWidget):
|
|||||||
|
|
||||||
if self.data[i + 1][1]: #!=0
|
if self.data[i + 1][1]: #!=0
|
||||||
text = self.ytext(self.data[i + 1][1])
|
text = self.ytext(self.data[i + 1][1])
|
||||||
W = self.fmetrics.width(text)
|
W = self.fmetrics.size(0, text).width()
|
||||||
newrect = QRect(x2 - W // 2, y2 - 10, W, texth)
|
newrect = QRect(x2 - W // 2, y2 - 10, W, texth)
|
||||||
if any(_.intersected(newrect) for _ in rects):
|
if any(_.intersected(newrect) for _ in rects):
|
||||||
continue
|
continue
|
||||||
@ -126,7 +110,7 @@ class chartwidget(QWidget):
|
|||||||
for i, (x, y) in enumerate(points):
|
for i, (x, y) in enumerate(points):
|
||||||
painter.drawLine(x, ymargin + height, x, ymargin + height + 5) # 刻度线
|
painter.drawLine(x, ymargin + height, x, ymargin + height + 5) # 刻度线
|
||||||
|
|
||||||
thisw = self.fmetrics.width(x_labels[i])
|
thisw = self.fmetrics.size(0, x_labels[i]).width()
|
||||||
thisx = x - thisw // 2
|
thisx = x - thisw // 2
|
||||||
|
|
||||||
if thisx > lastx2:
|
if thisx > lastx2:
|
||||||
@ -242,7 +226,9 @@ class FlowLayout(QLayout):
|
|||||||
self._item_list.append(item)
|
self._item_list.append(item)
|
||||||
|
|
||||||
def addSpacing(self, size): # pylint: disable=invalid-name
|
def addSpacing(self, size): # pylint: disable=invalid-name
|
||||||
self.addItem(QSpacerItem(size, 0, QSizePolicy.Fixed, QSizePolicy.Minimum))
|
self.addItem(
|
||||||
|
QSpacerItem(size, 0, QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Minimum)
|
||||||
|
)
|
||||||
|
|
||||||
def count(self):
|
def count(self):
|
||||||
return len(self._item_list)
|
return len(self._item_list)
|
||||||
@ -257,9 +243,6 @@ class FlowLayout(QLayout):
|
|||||||
return self._item_list.pop(index)
|
return self._item_list.pop(index)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def expandingDirections(self): # pylint: disable=invalid-name,no-self-use
|
|
||||||
return Qt.Orientations(Qt.Orientation(0))
|
|
||||||
|
|
||||||
def setGeometry(self, rect): # pylint: disable=invalid-name
|
def setGeometry(self, rect): # pylint: disable=invalid-name
|
||||||
super().setGeometry(rect)
|
super().setGeometry(rect)
|
||||||
self._do_layout(rect, False)
|
self._do_layout(rect, False)
|
||||||
@ -292,10 +275,14 @@ class FlowLayout(QLayout):
|
|||||||
space_y = self.spacing()
|
space_y = self.spacing()
|
||||||
if wid is not None:
|
if wid is not None:
|
||||||
space_x += wid.style().layoutSpacing(
|
space_x += wid.style().layoutSpacing(
|
||||||
QSizePolicy.PushButton, QSizePolicy.PushButton, Qt.Horizontal
|
QSizePolicy.ControlType.PushButton,
|
||||||
|
QSizePolicy.ControlType.PushButton,
|
||||||
|
Qt.Orientation.Horizontal,
|
||||||
)
|
)
|
||||||
space_y += wid.style().layoutSpacing(
|
space_y += wid.style().layoutSpacing(
|
||||||
QSizePolicy.PushButton, QSizePolicy.PushButton, Qt.Vertical
|
QSizePolicy.ControlType.PushButton,
|
||||||
|
QSizePolicy.ControlType.PushButton,
|
||||||
|
Qt.Orientation.Vertical,
|
||||||
)
|
)
|
||||||
|
|
||||||
next_x = x + item.sizeHint().width() + space_x
|
next_x = x + item.sizeHint().width() + space_x
|
||||||
|
@ -1,30 +1,7 @@
|
|||||||
from PyQt5.QtCore import Qt, QPoint, QPointF, pyqtSignal
|
from qtsymbols import *
|
||||||
from PyQt5.QtGui import (
|
|
||||||
QTextCharFormat,
|
|
||||||
QTextBlockFormat,
|
|
||||||
QResizeEvent,
|
|
||||||
QTextCursor,
|
|
||||||
QPixmap,
|
|
||||||
QFontMetricsF,
|
|
||||||
QMouseEvent,
|
|
||||||
)
|
|
||||||
from PyQt5.QtWidgets import (
|
|
||||||
QTextBrowser,
|
|
||||||
QLabel,
|
|
||||||
QGraphicsDropShadowEffect,
|
|
||||||
)
|
|
||||||
import functools
|
import functools
|
||||||
from myutils.config import globalconfig
|
from myutils.config import globalconfig
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from PyQt5.QtGui import (
|
|
||||||
QPainter,
|
|
||||||
QColor,
|
|
||||||
QFont,
|
|
||||||
QPen,
|
|
||||||
QPainterPath,
|
|
||||||
QBrush,
|
|
||||||
QFontMetrics,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Qlabel_c(QLabel):
|
class Qlabel_c(QLabel):
|
||||||
@ -42,7 +19,7 @@ class Qlabel_c(QLabel):
|
|||||||
if self.underMouse():
|
if self.underMouse():
|
||||||
try:
|
try:
|
||||||
if self.pr:
|
if self.pr:
|
||||||
if event.button() == Qt.RightButton:
|
if event.button() == Qt.MouseButton.RightButton:
|
||||||
self.callback(True)
|
self.callback(True)
|
||||||
else:
|
else:
|
||||||
self.callback(False)
|
self.callback(False)
|
||||||
@ -141,13 +118,17 @@ class BorderedLabel(QLabel):
|
|||||||
text = self.text()
|
text = self.text()
|
||||||
font_m = QFontMetrics(font)
|
font_m = QFontMetrics(font)
|
||||||
self.resize(
|
self.resize(
|
||||||
int(font_m.width(text) + 2 * self.m_fontOutLineWidth),
|
int(font_m.size(0, text).width() + 2 * self.m_fontOutLineWidth),
|
||||||
int(font_m.height() + 2 * self.m_fontOutLineWidth),
|
int(font_m.height() + 2 * self.m_fontOutLineWidth),
|
||||||
)
|
)
|
||||||
|
|
||||||
def labelresetcolor(self, color, rate=1):
|
def labelresetcolor(self, color, rate=1):
|
||||||
c1 = color
|
c1 = color
|
||||||
c2 = globalconfig["miaobiancolor"]
|
c2 = globalconfig["miaobiancolor"]
|
||||||
|
if c1 is None:
|
||||||
|
c1 = ""
|
||||||
|
if c2 is None:
|
||||||
|
c2 = ""
|
||||||
if globalconfig["zitiyangshi2"] == 2:
|
if globalconfig["zitiyangshi2"] == 2:
|
||||||
self.setColorWidth(c1, c2, rate * globalconfig["miaobianwidth2"])
|
self.setColorWidth(c1, c2, rate * globalconfig["miaobianwidth2"])
|
||||||
self.clearShadow()
|
self.clearShadow()
|
||||||
@ -161,10 +142,10 @@ class BorderedLabel(QLabel):
|
|||||||
self.setColorWidth(c2, c1, rate * globalconfig["miaobianwidth2"])
|
self.setColorWidth(c2, c1, rate * globalconfig["miaobianwidth2"])
|
||||||
self.setShadow(c2, rate * globalconfig["traceoffset"], 1, True)
|
self.setShadow(c2, rate * globalconfig["traceoffset"], 1, True)
|
||||||
elif globalconfig["zitiyangshi2"] == 0:
|
elif globalconfig["zitiyangshi2"] == 0:
|
||||||
self.setColorWidth(None, c1, 0, 2)
|
self.setColorWidth("", c1, 0, 2)
|
||||||
self.clearShadow()
|
self.clearShadow()
|
||||||
elif globalconfig["zitiyangshi2"] == 5:
|
elif globalconfig["zitiyangshi2"] == 5:
|
||||||
self.setColorWidth(None, c2, 0, 2)
|
self.setColorWidth("", c2, 0, 2)
|
||||||
self.setShadow(
|
self.setShadow(
|
||||||
c1, rate * globalconfig["fontsize"], globalconfig["shadowforce"]
|
c1, rate * globalconfig["fontsize"], globalconfig["shadowforce"]
|
||||||
)
|
)
|
||||||
@ -174,13 +155,13 @@ class BorderedLabel(QLabel):
|
|||||||
rate = self.devicePixelRatioF()
|
rate = self.devicePixelRatioF()
|
||||||
self._pix = QPixmap(self.size() * rate)
|
self._pix = QPixmap(self.size() * rate)
|
||||||
self._pix.setDevicePixelRatio(rate)
|
self._pix.setDevicePixelRatio(rate)
|
||||||
self._pix.fill(Qt.transparent)
|
self._pix.fill(Qt.GlobalColor.transparent)
|
||||||
text = self.text()
|
text = self.text()
|
||||||
font = self.font()
|
font = self.font()
|
||||||
font_m = QFontMetrics(font)
|
font_m = QFontMetrics(font)
|
||||||
painter = QPainter(self._pix)
|
painter = QPainter(self._pix)
|
||||||
|
|
||||||
painter.setRenderHint(QPainter.Antialiasing)
|
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||||
path = QPainterPath()
|
path = QPainterPath()
|
||||||
if self._type == 2:
|
if self._type == 2:
|
||||||
|
|
||||||
@ -202,9 +183,9 @@ class BorderedLabel(QLabel):
|
|||||||
pen = QPen(
|
pen = QPen(
|
||||||
self.m_outLineColor,
|
self.m_outLineColor,
|
||||||
self.m_fontOutLineWidth,
|
self.m_fontOutLineWidth,
|
||||||
Qt.SolidLine,
|
Qt.PenStyle.SolidLine,
|
||||||
Qt.RoundCap,
|
Qt.PenCapStyle.RoundCap,
|
||||||
Qt.RoundJoin,
|
Qt.PenJoinStyle.RoundJoin,
|
||||||
)
|
)
|
||||||
|
|
||||||
if self._type == 0:
|
if self._type == 0:
|
||||||
@ -262,8 +243,12 @@ class Textbrowser(QLabel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.textcursor = self.textbrowser.textCursor()
|
self.textcursor = self.textbrowser.textCursor()
|
||||||
self.textbrowser.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
self.textbrowser.setVerticalScrollBarPolicy(
|
||||||
self.textbrowser.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
Qt.ScrollBarPolicy.ScrollBarAlwaysOff
|
||||||
|
)
|
||||||
|
self.textbrowser.setHorizontalScrollBarPolicy(
|
||||||
|
Qt.ScrollBarPolicy.ScrollBarAlwaysOff
|
||||||
|
)
|
||||||
self.masklabel = QLabel(self.textbrowser)
|
self.masklabel = QLabel(self.textbrowser)
|
||||||
self.masklabel.setGeometry(0, 0, 9999, 9999)
|
self.masklabel.setGeometry(0, 0, 9999, 9999)
|
||||||
self.masklabel.setMouseTracking(True)
|
self.masklabel.setMouseTracking(True)
|
||||||
@ -294,7 +279,7 @@ class Textbrowser(QLabel):
|
|||||||
self.font.setPointSizeF(globalconfig["fontsize"])
|
self.font.setPointSizeF(globalconfig["fontsize"])
|
||||||
self.font.setBold(globalconfig["showbold"])
|
self.font.setBold(globalconfig["showbold"])
|
||||||
|
|
||||||
self.textbrowser.moveCursor(QTextCursor.End)
|
self.textbrowser.moveCursor(QTextCursor.MoveOperation.End)
|
||||||
f = QTextCharFormat()
|
f = QTextCharFormat()
|
||||||
f.setFont(self.font)
|
f.setFont(self.font)
|
||||||
f.setForeground(self.tranparentcolor)
|
f.setForeground(self.tranparentcolor)
|
||||||
@ -322,7 +307,11 @@ class Textbrowser(QLabel):
|
|||||||
for i in range(self.blockcount, self.textbrowser.document().blockCount()):
|
for i in range(self.blockcount, self.textbrowser.document().blockCount()):
|
||||||
b = self.textbrowser.document().findBlockByNumber(i)
|
b = self.textbrowser.document().findBlockByNumber(i)
|
||||||
tf = b.blockFormat()
|
tf = b.blockFormat()
|
||||||
tf.setLineHeight(fh, QTextBlockFormat.LineDistanceHeight)
|
if isqt5:
|
||||||
|
lht = QTextBlockFormat.LineHeightTypes.LineDistanceHeight
|
||||||
|
else:
|
||||||
|
lht = 4
|
||||||
|
tf.setLineHeight(fh, lht)
|
||||||
self.textcursor.setPosition(b.position())
|
self.textcursor.setPosition(b.position())
|
||||||
self.textcursor.setBlockFormat(tf)
|
self.textcursor.setBlockFormat(tf)
|
||||||
self.textbrowser.setTextCursor(self.textcursor)
|
self.textbrowser.setTextCursor(self.textcursor)
|
||||||
@ -342,8 +331,8 @@ class Textbrowser(QLabel):
|
|||||||
self.textbrowser.insertPlainText(text)
|
self.textbrowser.insertPlainText(text)
|
||||||
|
|
||||||
def deletebetween(self, p1, p2):
|
def deletebetween(self, p1, p2):
|
||||||
self.textcursor.setPosition(p1, QTextCursor.MoveAnchor)
|
self.textcursor.setPosition(p1, QTextCursor.MoveMode.MoveAnchor)
|
||||||
self.textcursor.setPosition(p2, QTextCursor.KeepAnchor)
|
self.textcursor.setPosition(p2, QTextCursor.MoveMode.KeepAnchor)
|
||||||
self.textcursor.removeSelectedText()
|
self.textcursor.removeSelectedText()
|
||||||
|
|
||||||
def showyinyingtext2(self, color, iter_context_class, pos, text):
|
def showyinyingtext2(self, color, iter_context_class, pos, text):
|
||||||
@ -626,7 +615,11 @@ class Textbrowser(QLabel):
|
|||||||
b = self.textbrowser.document().findBlockByNumber(i)
|
b = self.textbrowser.document().findBlockByNumber(i)
|
||||||
|
|
||||||
tf = b.blockFormat()
|
tf = b.blockFormat()
|
||||||
tf.setLineHeight(fasall + fha, QTextBlockFormat.FixedHeight)
|
if isqt5:
|
||||||
|
lht = QTextBlockFormat.LineHeightTypes.FixedHeight
|
||||||
|
else:
|
||||||
|
lht = 2
|
||||||
|
tf.setLineHeight(fasall + fha, lht)
|
||||||
self.textcursor.setPosition(b.position())
|
self.textcursor.setPosition(b.position())
|
||||||
self.textcursor.setBlockFormat(tf)
|
self.textcursor.setBlockFormat(tf)
|
||||||
self.textbrowser.setTextCursor(self.textcursor)
|
self.textbrowser.setTextCursor(self.textcursor)
|
||||||
@ -666,8 +659,8 @@ class Textbrowser(QLabel):
|
|||||||
_metrichira = QFontMetricsF(fonthira)
|
_metrichira = QFontMetricsF(fonthira)
|
||||||
_metricorig = QFontMetricsF(fontorig)
|
_metricorig = QFontMetricsF(fontorig)
|
||||||
for i, word in enumerate(x):
|
for i, word in enumerate(x):
|
||||||
word["orig_w"] = _metricorig.width(word["orig"])
|
word["orig_w"] = _metricorig.size(0, word["orig"]).width()
|
||||||
word["hira_w"] = _metrichira.width(word["hira"])
|
word["hira_w"] = _metrichira.size(0, word["hira"]).width()
|
||||||
# print(word['hira'],word['hira_w'])
|
# print(word['hira'],word['hira_w'])
|
||||||
newline.append(word)
|
newline.append(word)
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
from PyQt5.QtWidgets import QPlainTextEdit, QAction, QMenu, QFileDialog
|
from qtsymbols import *
|
||||||
from PyQt5.QtCore import Qt, pyqtSignal
|
|
||||||
from PyQt5.QtGui import QCursor
|
|
||||||
import qtawesome, functools, winsharedutils
|
import qtawesome, functools, winsharedutils
|
||||||
from gui.usefulwidget import closeashidewindow
|
from gui.usefulwidget import closeashidewindow
|
||||||
from myutils.config import globalconfig, _TR
|
from myutils.config import globalconfig, _TR
|
||||||
@ -27,7 +25,7 @@ class transhist(closeashidewindow):
|
|||||||
|
|
||||||
def gettb(_type):
|
def gettb(_type):
|
||||||
textOutput = QPlainTextEdit()
|
textOutput = QPlainTextEdit()
|
||||||
textOutput.setContextMenuPolicy(Qt.CustomContextMenu)
|
textOutput.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
||||||
textOutput.customContextMenuRequested.connect(
|
textOutput.customContextMenuRequested.connect(
|
||||||
functools.partial(self.showmenu, textOutput, _type)
|
functools.partial(self.showmenu, textOutput, _type)
|
||||||
)
|
)
|
||||||
|
@ -4,11 +4,8 @@ import threading
|
|||||||
import os, sys
|
import os, sys
|
||||||
import windows, importlib
|
import windows, importlib
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from PyQt5.QtCore import Qt, pyqtSignal
|
|
||||||
import qtawesome
|
import qtawesome
|
||||||
from PyQt5.QtCore import pyqtSignal, Qt, QSize
|
from qtsymbols import *
|
||||||
from PyQt5.QtGui import QCursor
|
|
||||||
from PyQt5.QtWidgets import QLabel, QPushButton, QSystemTrayIcon
|
|
||||||
import gobject
|
import gobject
|
||||||
from myutils.wrapper import threader, trypass
|
from myutils.wrapper import threader, trypass
|
||||||
import winsharedutils
|
import winsharedutils
|
||||||
@ -183,9 +180,9 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
self.translate_text.setnextfont(origin)
|
self.translate_text.setnextfont(origin)
|
||||||
|
|
||||||
if globalconfig["showatcenter"]:
|
if globalconfig["showatcenter"]:
|
||||||
self.translate_text.setAlignment(Qt.AlignCenter)
|
self.translate_text.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||||
else:
|
else:
|
||||||
self.translate_text.setAlignment(Qt.AlignLeft)
|
self.translate_text.setAlignment(Qt.AlignmentFlag.AlignLeft)
|
||||||
|
|
||||||
if iter_context:
|
if iter_context:
|
||||||
iter_res_status, iter_context_class = iter_context
|
iter_res_status, iter_context_class = iter_context
|
||||||
@ -590,7 +587,7 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
|
|
||||||
super(QUnFrameWindow, self).__init__(
|
super(QUnFrameWindow, self).__init__(
|
||||||
None,
|
None,
|
||||||
flags=Qt.FramelessWindowHint | Qt.Tool,
|
flags=Qt.WindowType.FramelessWindowHint | Qt.WindowType.Tool,
|
||||||
dic=globalconfig,
|
dic=globalconfig,
|
||||||
key="transuigeo",
|
key="transuigeo",
|
||||||
) # 设置为顶级窗口,无边框
|
) # 设置为顶级窗口,无边框
|
||||||
@ -600,8 +597,8 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
self.tray = QSystemTrayIcon()
|
self.tray = QSystemTrayIcon()
|
||||||
self.tray.setIcon(icon)
|
self.tray.setIcon(icon)
|
||||||
self.isfirstshow = True
|
self.isfirstshow = True
|
||||||
self.setAttribute(Qt.WA_TranslucentBackground)
|
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||||
self.setAttribute(Qt.WA_ShowWithoutActivating, True)
|
self.setAttribute(Qt.WidgetAttribute.WA_ShowWithoutActivating, True)
|
||||||
self.setWindowTitle("LunaTranslator")
|
self.setWindowTitle("LunaTranslator")
|
||||||
self.hidesignal.connect(self.hide_)
|
self.hidesignal.connect(self.hide_)
|
||||||
self.lastrefreshtime = time.time()
|
self.lastrefreshtime = time.time()
|
||||||
|
@ -1,44 +1,11 @@
|
|||||||
from PyQt5.QtWidgets import (
|
from qtsymbols import *
|
||||||
QLineEdit,
|
|
||||||
QMainWindow,
|
|
||||||
QApplication,
|
|
||||||
QPushButton,
|
|
||||||
QMessageBox,
|
|
||||||
QTabWidget,
|
|
||||||
QScrollArea,
|
|
||||||
QDialog,
|
|
||||||
QLabel,
|
|
||||||
QGridLayout,
|
|
||||||
QSizePolicy,
|
|
||||||
QHBoxLayout,
|
|
||||||
QWidget,
|
|
||||||
QLayout,
|
|
||||||
)
|
|
||||||
from PyQt5.QtCore import pyqtSignal
|
|
||||||
from PyQt5.QtWidgets import QKeySequenceEdit, QLabel
|
|
||||||
from PyQt5.QtGui import QFontDatabase
|
|
||||||
from PyQt5.QtGui import QKeySequence
|
|
||||||
|
|
||||||
from webviewpy import (
|
from webviewpy import (
|
||||||
webview_native_handle_kind_t,
|
webview_native_handle_kind_t,
|
||||||
Webview,
|
Webview,
|
||||||
declare_library_path,
|
declare_library_path,
|
||||||
)
|
)
|
||||||
from PyQt5.QtGui import QCloseEvent, QColor, QTextCursor, QResizeEvent
|
|
||||||
from PyQt5.QtCore import Qt, pyqtSignal, QSize
|
|
||||||
from myutils.config import _TR, globalconfig
|
from myutils.config import _TR, globalconfig
|
||||||
from PyQt5.QtWidgets import (
|
|
||||||
QColorDialog,
|
|
||||||
QSpinBox,
|
|
||||||
QDoubleSpinBox,
|
|
||||||
QPushButton,
|
|
||||||
QComboBox,
|
|
||||||
QLabel,
|
|
||||||
QDialogButtonBox,
|
|
||||||
QLineEdit,
|
|
||||||
QApplication,
|
|
||||||
QVBoxLayout,
|
|
||||||
)
|
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
import qtawesome, functools, threading, time
|
import qtawesome, functools, threading, time
|
||||||
from myutils.wrapper import Singleton
|
from myutils.wrapper import Singleton
|
||||||
@ -50,7 +17,7 @@ import windows, os, platform
|
|||||||
class dialog_showinfo(QDialog):
|
class dialog_showinfo(QDialog):
|
||||||
|
|
||||||
def __init__(self, parent, title, info) -> None:
|
def __init__(self, parent, title, info) -> None:
|
||||||
super().__init__(parent, Qt.WindowCloseButtonHint)
|
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||||
self.setWindowTitle(title)
|
self.setWindowTitle(title)
|
||||||
l = QLabel(info)
|
l = QLabel(info)
|
||||||
layout = QHBoxLayout()
|
layout = QHBoxLayout()
|
||||||
@ -251,94 +218,100 @@ class resizableframeless(saveposwindow):
|
|||||||
self.height() + 1,
|
self.height() + 1,
|
||||||
]
|
]
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event: QMouseEvent):
|
||||||
# 重写鼠标点击的事件
|
# 重写鼠标点击的事件
|
||||||
|
if isqt5:
|
||||||
if (event.button() == Qt.LeftButton) and (
|
gpos = event.globalPos()
|
||||||
|
else:
|
||||||
|
gpos = event.globalPosition().toPoint()
|
||||||
|
if (event.button() == Qt.MouseButton.LeftButton) and (
|
||||||
isinrect(event.pos(), self._corner_rect)
|
isinrect(event.pos(), self._corner_rect)
|
||||||
):
|
):
|
||||||
# 鼠标左键点击右下角边界区域
|
# 鼠标左键点击右下角边界区域
|
||||||
self._corner_drag = True
|
self._corner_drag = True
|
||||||
elif (event.button() == Qt.LeftButton) and (
|
elif (event.button() == Qt.MouseButton.LeftButton) and (
|
||||||
isinrect(event.pos(), self._right_rect)
|
isinrect(event.pos(), self._right_rect)
|
||||||
):
|
):
|
||||||
# 鼠标左键点击右侧边界区域
|
# 鼠标左键点击右侧边界区域
|
||||||
self._right_drag = True
|
self._right_drag = True
|
||||||
elif (event.button() == Qt.LeftButton) and (
|
elif (event.button() == Qt.MouseButton.LeftButton) and (
|
||||||
isinrect(event.pos(), self._left_rect)
|
isinrect(event.pos(), self._left_rect)
|
||||||
):
|
):
|
||||||
# 鼠标左键点击右侧边界区域
|
# 鼠标左键点击右侧边界区域
|
||||||
self._left_drag = True
|
self._left_drag = True
|
||||||
self.startxp = event.globalPos() - self.pos()
|
self.startxp = gpos - self.pos()
|
||||||
self.startx = event.globalPos().x()
|
self.startx = gpos.x()
|
||||||
self.startw = self.width()
|
self.startw = self.width()
|
||||||
elif (event.button() == Qt.LeftButton) and (
|
elif (event.button() == Qt.MouseButton.LeftButton) and (
|
||||||
isinrect(event.pos(), self._bottom_rect)
|
isinrect(event.pos(), self._bottom_rect)
|
||||||
):
|
):
|
||||||
# 鼠标左键点击下侧边界区域
|
# 鼠标左键点击下侧边界区域
|
||||||
self._bottom_drag = True
|
self._bottom_drag = True
|
||||||
elif (event.button() == Qt.LeftButton) and (
|
elif (event.button() == Qt.MouseButton.LeftButton) and (
|
||||||
isinrect(event.pos(), self._lcorner_rect)
|
isinrect(event.pos(), self._lcorner_rect)
|
||||||
):
|
):
|
||||||
# 鼠标左键点击下侧边界区域
|
# 鼠标左键点击下侧边界区域
|
||||||
self._lcorner_drag = True
|
self._lcorner_drag = True
|
||||||
self.startxp = event.globalPos() - self.pos()
|
self.startxp = gpos - self.pos()
|
||||||
self.startx = event.globalPos().x()
|
self.startx = gpos.x()
|
||||||
self.startw = self.width()
|
self.startw = self.width()
|
||||||
# and (event.y() < self._TitleLabel.height()):
|
# and (event.y() < self._TitleLabel.height()):
|
||||||
elif event.button() == Qt.LeftButton:
|
elif event.button() == Qt.MouseButton.LeftButton:
|
||||||
# 鼠标左键点击标题栏区域
|
# 鼠标左键点击标题栏区域
|
||||||
self._move_drag = True
|
self._move_drag = True
|
||||||
self.move_DragPosition = event.globalPos() - self.pos()
|
self.move_DragPosition = gpos - self.pos()
|
||||||
|
|
||||||
def mouseMoveEvent(self, QMouseEvent):
|
def mouseMoveEvent(self, event):
|
||||||
# 判断鼠标位置切换鼠标手势
|
# 判断鼠标位置切换鼠标手势
|
||||||
|
|
||||||
pos = QMouseEvent.pos()
|
pos = event.pos()
|
||||||
|
if isqt5:
|
||||||
|
gpos = event.globalPos()
|
||||||
|
else:
|
||||||
|
gpos = event.globalPosition().toPoint()
|
||||||
if self._move_drag == False:
|
if self._move_drag == False:
|
||||||
if isinrect(pos, self._corner_rect):
|
if isinrect(pos, self._corner_rect):
|
||||||
self.setCursor(Qt.SizeFDiagCursor)
|
self.setCursor(Qt.CursorShape.SizeFDiagCursor)
|
||||||
elif isinrect(pos, self._lcorner_rect):
|
elif isinrect(pos, self._lcorner_rect):
|
||||||
self.setCursor(Qt.SizeBDiagCursor)
|
self.setCursor(Qt.CursorShape.SizeBDiagCursor)
|
||||||
elif isinrect(pos, self._bottom_rect):
|
elif isinrect(pos, self._bottom_rect):
|
||||||
self.setCursor(Qt.SizeVerCursor)
|
self.setCursor(Qt.CursorShape.SizeVerCursor)
|
||||||
elif isinrect(pos, self._right_rect):
|
elif isinrect(pos, self._right_rect):
|
||||||
self.setCursor(Qt.SizeHorCursor)
|
self.setCursor(Qt.CursorShape.SizeHorCursor)
|
||||||
elif isinrect(pos, self._left_rect):
|
elif isinrect(pos, self._left_rect):
|
||||||
self.setCursor(Qt.SizeHorCursor)
|
self.setCursor(Qt.CursorShape.SizeHorCursor)
|
||||||
else:
|
else:
|
||||||
self.setCursor(Qt.ArrowCursor)
|
self.setCursor(Qt.CursorShape.ArrowCursor)
|
||||||
if Qt.LeftButton and self._right_drag:
|
if Qt.MouseButton.LeftButton and self._right_drag:
|
||||||
|
|
||||||
# 右侧调整窗口宽度
|
# 右侧调整窗口宽度
|
||||||
self.resize(pos.x(), self.height())
|
self.resize(pos.x(), self.height())
|
||||||
elif Qt.LeftButton and self._left_drag:
|
elif Qt.MouseButton.LeftButton and self._left_drag:
|
||||||
# 右侧调整窗口宽度
|
# 右侧调整窗口宽度
|
||||||
self.setGeometry(
|
self.setGeometry(
|
||||||
(QMouseEvent.globalPos() - self.startxp).x(),
|
(gpos - self.startxp).x(),
|
||||||
self.y(),
|
self.y(),
|
||||||
self.startw - (QMouseEvent.globalPos().x() - self.startx),
|
self.startw - (gpos.x() - self.startx),
|
||||||
self.height(),
|
self.height(),
|
||||||
)
|
)
|
||||||
# self.resize(pos.x(), self.height())
|
# self.resize(pos.x(), self.height())
|
||||||
elif Qt.LeftButton and self._bottom_drag:
|
elif Qt.MouseButton.LeftButton and self._bottom_drag:
|
||||||
# 下侧调整窗口高度
|
# 下侧调整窗口高度
|
||||||
self.resize(self.width(), QMouseEvent.pos().y())
|
self.resize(self.width(), event.pos().y())
|
||||||
elif Qt.LeftButton and self._lcorner_drag:
|
elif Qt.MouseButton.LeftButton and self._lcorner_drag:
|
||||||
# 下侧调整窗口高度
|
# 下侧调整窗口高度
|
||||||
self.setGeometry(
|
self.setGeometry(
|
||||||
(QMouseEvent.globalPos() - self.startxp).x(),
|
(gpos - self.startxp).x(),
|
||||||
self.y(),
|
self.y(),
|
||||||
self.startw - (QMouseEvent.globalPos().x() - self.startx),
|
self.startw - (gpos.x() - self.startx),
|
||||||
QMouseEvent.pos().y(),
|
event.pos().y(),
|
||||||
)
|
)
|
||||||
elif Qt.LeftButton and self._corner_drag:
|
elif Qt.MouseButton.LeftButton and self._corner_drag:
|
||||||
# 右下角同时调整高度和宽度
|
# 右下角同时调整高度和宽度
|
||||||
self.resize(pos.x(), pos.y())
|
self.resize(pos.x(), pos.y())
|
||||||
elif Qt.LeftButton and self._move_drag:
|
elif Qt.MouseButton.LeftButton and self._move_drag:
|
||||||
# 标题栏拖放窗口位置
|
# 标题栏拖放窗口位置
|
||||||
self.move(QMouseEvent.globalPos() - self.move_DragPosition)
|
self.move(gpos - self.move_DragPosition)
|
||||||
|
|
||||||
def mouseReleaseEvent(self, QMouseEvent):
|
def mouseReleaseEvent(self, QMouseEvent):
|
||||||
# 鼠标释放后,各扳机复位
|
# 鼠标释放后,各扳机复位
|
||||||
@ -356,7 +329,7 @@ class Prompt_dialog(QDialog):
|
|||||||
self.setWindowFlags(
|
self.setWindowFlags(
|
||||||
self.windowFlags()
|
self.windowFlags()
|
||||||
& ~Qt.WindowContextHelpButtonHint
|
& ~Qt.WindowContextHelpButtonHint
|
||||||
& ~Qt.WindowCloseButtonHint
|
& ~Qt.WindowType.WindowCloseButtonHint
|
||||||
| Qt.WindowStaysOnTopHint
|
| Qt.WindowStaysOnTopHint
|
||||||
)
|
)
|
||||||
self.setWindowTitle(title)
|
self.setWindowTitle(title)
|
||||||
@ -376,7 +349,9 @@ class Prompt_dialog(QDialog):
|
|||||||
hl.addWidget(QLabel(_[0]))
|
hl.addWidget(QLabel(_[0]))
|
||||||
hl.addWidget(le)
|
hl.addWidget(le)
|
||||||
_layout.addLayout(hl)
|
_layout.addLayout(hl)
|
||||||
button = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
button = QDialogButtonBox(
|
||||||
|
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
|
||||||
|
)
|
||||||
button.accepted.connect(self.accept)
|
button.accepted.connect(self.accept)
|
||||||
button.rejected.connect(self.reject)
|
button.rejected.connect(self.reject)
|
||||||
_layout.addWidget(button)
|
_layout.addWidget(button)
|
||||||
@ -401,7 +376,7 @@ def getsimplecombobox(lst, d, k, callback=None, fixedsize=False):
|
|||||||
s.setCurrentIndex(d[k])
|
s.setCurrentIndex(d[k])
|
||||||
s.currentIndexChanged.connect(functools.partial(callbackwrap, d, k, callback))
|
s.currentIndexChanged.connect(functools.partial(callbackwrap, d, k, callback))
|
||||||
if fixedsize:
|
if fixedsize:
|
||||||
s.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
s.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
@ -457,7 +432,7 @@ def getcolorbutton(
|
|||||||
font: 100 10pt;"""
|
font: 100 10pt;"""
|
||||||
)
|
)
|
||||||
b.clicked.connect(callback)
|
b.clicked.connect(callback)
|
||||||
b.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
b.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
|
||||||
if name:
|
if name:
|
||||||
setattr(parent, name, b)
|
setattr(parent, name, b)
|
||||||
return b
|
return b
|
||||||
@ -483,7 +458,7 @@ def getsimpleswitch(
|
|||||||
|
|
||||||
b = MySwitch(sign=d[key], enable=enable)
|
b = MySwitch(sign=d[key], enable=enable)
|
||||||
b.clicked.connect(functools.partial(callbackwrap, d, key, callback))
|
b.clicked.connect(functools.partial(callbackwrap, d, key, callback))
|
||||||
b.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
b.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
|
||||||
if pair:
|
if pair:
|
||||||
if pair not in dir(parent):
|
if pair not in dir(parent):
|
||||||
setattr(parent, pair, {})
|
setattr(parent, pair, {})
|
||||||
@ -539,7 +514,7 @@ def textbrowappendandmovetoend(textOutput, sentence, addspace=True):
|
|||||||
or scrollbar.value() / scrollbar.maximum() > 0.975
|
or scrollbar.value() / scrollbar.maximum() > 0.975
|
||||||
)
|
)
|
||||||
cursor = QTextCursor(textOutput.document())
|
cursor = QTextCursor(textOutput.document())
|
||||||
cursor.movePosition(QTextCursor.End)
|
cursor.movePosition(QTextCursor.MoveOperation.End)
|
||||||
cursor.insertText(
|
cursor.insertText(
|
||||||
(("" if textOutput.document().isEmpty() else "\n") if addspace else "")
|
(("" if textOutput.document().isEmpty() else "\n") if addspace else "")
|
||||||
+ sentence
|
+ sentence
|
||||||
@ -700,7 +675,7 @@ class auto_select_webview(QWidget):
|
|||||||
|
|
||||||
def __init__(self, parent) -> None:
|
def __init__(self, parent) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
||||||
self.cantusewebview2 = False
|
self.cantusewebview2 = False
|
||||||
self.internal = None
|
self.internal = None
|
||||||
self.contex = -1
|
self.contex = -1
|
||||||
@ -817,7 +792,7 @@ def automakegrid(grid: QGridLayout, lis, save=False, savelist=None):
|
|||||||
nowc += cols
|
nowc += cols
|
||||||
if save:
|
if save:
|
||||||
savelist.append(ll)
|
savelist.append(ll)
|
||||||
grid.setRowMinimumHeight(nowr, 30)
|
grid.setRowMinimumHeight(nowr, 25)
|
||||||
|
|
||||||
|
|
||||||
def makegrid(grid, save=False, savelist=None, savelay=None):
|
def makegrid(grid, save=False, savelist=None, savelay=None):
|
||||||
@ -827,7 +802,7 @@ def makegrid(grid, save=False, savelist=None, savelay=None):
|
|||||||
|
|
||||||
gridlayoutwidget = gridwidget()
|
gridlayoutwidget = gridwidget()
|
||||||
gridlay = QGridLayout()
|
gridlay = QGridLayout()
|
||||||
gridlay.setAlignment(Qt.AlignTop)
|
gridlay.setAlignment(Qt.AlignmentFlag.AlignTop)
|
||||||
gridlayoutwidget.setLayout(gridlay)
|
gridlayoutwidget.setLayout(gridlay)
|
||||||
gridlayoutwidget.setStyleSheet("gridwidget{background-color:transparent;}")
|
gridlayoutwidget.setStyleSheet("gridwidget{background-color:transparent;}")
|
||||||
|
|
||||||
|
@ -9,5 +9,4 @@ from html.parser import HTMLParser
|
|||||||
from importlib import resources
|
from importlib import resources
|
||||||
from distutils.version import StrictVersion
|
from distutils.version import StrictVersion
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import colorsys
|
import colorsys
|
||||||
from PyQt5 import QtSvg
|
|
@ -1,7 +1,6 @@
|
|||||||
import windows
|
import windows
|
||||||
import threading
|
import threading
|
||||||
from PyQt5.QtGui import QPixmap, QColor, QIcon
|
from qtsymbols import *
|
||||||
from PyQt5.QtWidgets import QApplication
|
|
||||||
import gobject
|
import gobject
|
||||||
import os, subprocess
|
import os, subprocess
|
||||||
import time, winrtutils, winsharedutils, hashlib
|
import time, winrtutils, winsharedutils, hashlib
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import windows
|
import windows
|
||||||
import os, importlib
|
import os, importlib
|
||||||
from myutils.config import globalconfig, _TR
|
from myutils.config import globalconfig, _TR
|
||||||
from PyQt5.QtGui import QImage
|
from qtsymbols import *
|
||||||
from PyQt5.QtCore import QByteArray, QBuffer
|
|
||||||
from myutils.commonbase import ArgsEmptyExc
|
from myutils.commonbase import ArgsEmptyExc
|
||||||
from myutils.hwnd import screenshot
|
from myutils.hwnd import screenshot
|
||||||
from myutils.utils import stringfyerror
|
from myutils.utils import stringfyerror
|
||||||
|
@ -8,10 +8,7 @@ import ctypes, importlib
|
|||||||
import time
|
import time
|
||||||
import ctypes.wintypes
|
import ctypes.wintypes
|
||||||
import time
|
import time
|
||||||
from PyQt5.QtWidgets import (
|
from qtsymbols import *
|
||||||
QApplication,
|
|
||||||
)
|
|
||||||
from PyQt5.QtGui import QImageWriter
|
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from myutils.config import (
|
from myutils.config import (
|
||||||
globalconfig,
|
globalconfig,
|
||||||
|
@ -1,15 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from PyQt5.QtCore import QByteArray, QObject, QPoint, QRect, Qt
|
from qtsymbols import *
|
||||||
from PyQt5.QtGui import (
|
|
||||||
QColor,
|
|
||||||
QFont,
|
|
||||||
QFontDatabase,
|
|
||||||
QIcon,
|
|
||||||
QIconEngine,
|
|
||||||
QPainter,
|
|
||||||
QPixmap,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class CharIconPainter:
|
class CharIconPainter:
|
||||||
@ -20,7 +11,11 @@ class CharIconPainter:
|
|||||||
painter.setPen(qcolor)
|
painter.setPen(qcolor)
|
||||||
draw_size = round(0.875 * rect.height())
|
draw_size = round(0.875 * rect.height())
|
||||||
painter.setFont(iconic.font(draw_size))
|
painter.setFont(iconic.font(draw_size))
|
||||||
painter.drawText(rect, int(Qt.AlignCenter | Qt.AlignVCenter), char)
|
painter.drawText(
|
||||||
|
rect,
|
||||||
|
int(Qt.AlignmentFlag.AlignCenter | Qt.AlignmentFlag.AlignVCenter),
|
||||||
|
char,
|
||||||
|
)
|
||||||
painter.restore()
|
painter.restore()
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +33,7 @@ class CharIconEngine(QIconEngine):
|
|||||||
|
|
||||||
def pixmap(self, size, mode, state):
|
def pixmap(self, size, mode, state):
|
||||||
pm = QPixmap(size)
|
pm = QPixmap(size)
|
||||||
pm.fill(Qt.transparent)
|
pm.fill(Qt.GlobalColor.transparent)
|
||||||
self.paint(QPainter(pm), QRect(QPoint(0, 0), size))
|
self.paint(QPainter(pm), QRect(QPoint(0, 0), size))
|
||||||
return pm
|
return pm
|
||||||
|
|
||||||
|
14
LunaTranslator/LunaTranslator/qtsymbols.py
Normal file
14
LunaTranslator/LunaTranslator/qtsymbols.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
try:
|
||||||
|
from PyQt5 import QtSvg
|
||||||
|
from PyQt5.QtWidgets import QFrame,QListView,QCheckBox,QAbstractItemView,QTextEdit,QTableView,QHeaderView,QColorDialog,QSpinBox,QDoubleSpinBox,QComboBox,QDialogButtonBox,QMainWindow,QMessageBox,QDialog,QGridLayout,QTextBrowser,QGraphicsDropShadowEffect,QWidget,QSizePolicy,QScrollArea,QApplication,QPushButton,QSystemTrayIcon,QPlainTextEdit,QAction,QMenu,QFileDialog,QKeySequenceEdit,QLabel,QSpacerItem,QWidgetItem,QLayout,QTextBrowser,QLineEdit,QFormLayout,QSizePolicy,QTabWidget,QTabBar,QSplitter,QListWidget,QListWidgetItem,QHBoxLayout,QVBoxLayout,QSizeGrip,QFontComboBox,QProgressBar,QRadioButton,QButtonGroup,QSlider
|
||||||
|
from PyQt5.QtGui import QIconEngine,QIntValidator,QStandardItem,QStandardItemModel,QImageWriter,QIcon,QTextCharFormat,QTextBlockFormat,QResizeEvent,QTextCursor,QFontMetricsF,QMouseEvent,QImage,QPainter,QRegion,QCloseEvent,QFontDatabase,QKeySequence,QPixmap,QCursor,QColor,QFont,QPen,QPainterPath,QBrush,QFontMetrics
|
||||||
|
from PyQt5.QtCore import QObject,pyqtSignal,Qt,QSize,QByteArray,QBuffer,QPointF,QPoint,QRect,QEvent,QModelIndex
|
||||||
|
isqt5 = True
|
||||||
|
except:
|
||||||
|
#from traceback import print_exc
|
||||||
|
#print_exc()
|
||||||
|
from PyQt6 import QtSvg
|
||||||
|
from PyQt6.QtWidgets import QFrame,QListView,QCheckBox,QAbstractItemView,QTextEdit,QTableView,QHeaderView,QColorDialog,QSpinBox,QDoubleSpinBox,QComboBox,QDialogButtonBox,QMainWindow,QMessageBox,QDialog,QGridLayout,QTextBrowser,QGraphicsDropShadowEffect,QWidget,QSizePolicy,QScrollArea,QApplication,QPushButton,QSystemTrayIcon,QPlainTextEdit,QMenu,QFileDialog,QKeySequenceEdit,QLabel,QSpacerItem,QWidgetItem,QLayout,QTextBrowser,QLineEdit,QFormLayout,QSizePolicy,QTabWidget,QTabBar,QSplitter,QListWidget,QListWidgetItem,QHBoxLayout,QVBoxLayout,QSizeGrip,QFontComboBox,QProgressBar,QRadioButton,QButtonGroup,QSlider
|
||||||
|
from PyQt6.QtGui import QIconEngine,QIntValidator,QAction,QStandardItem,QStandardItemModel,QImageWriter,QIcon,QTextCharFormat,QTextBlockFormat,QResizeEvent,QTextCursor,QFontMetricsF,QMouseEvent,QImage,QPainter,QRegion,QCloseEvent,QFontDatabase,QKeySequence,QPixmap,QCursor,QColor,QFont,QPen,QPainterPath,QBrush,QFontMetrics
|
||||||
|
from PyQt6.QtCore import QObject,pyqtSignal,Qt,QSize,QByteArray,QBuffer,QPointF,QPoint,QRect,QEvent,QModelIndex
|
||||||
|
isqt5 = False
|
@ -2,10 +2,9 @@ import time
|
|||||||
from myutils.config import globalconfig
|
from myutils.config import globalconfig
|
||||||
import winsharedutils
|
import winsharedutils
|
||||||
from gui.rangeselect import rangeadjust
|
from gui.rangeselect import rangeadjust
|
||||||
from myutils.ocrutil import imageCut, ocr_run, ocr_end, qimage2binary
|
from myutils.ocrutil import imageCut, ocr_run, ocr_end
|
||||||
import time, gobject, os
|
import time, gobject
|
||||||
from PyQt5.QtWidgets import QApplication
|
from qtsymbols import *
|
||||||
from PyQt5.QtGui import QImage
|
|
||||||
from textsource.textsourcebase import basetext
|
from textsource.textsourcebase import basetext
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,19 +1,6 @@
|
|||||||
from myutils.config import noundictconfig
|
from myutils.config import noundictconfig
|
||||||
import gobject, re
|
import gobject, re
|
||||||
|
from qtsymbols import *
|
||||||
from PyQt5.QtWidgets import (
|
|
||||||
QDialog,
|
|
||||||
QLabel,
|
|
||||||
QLineEdit,
|
|
||||||
QPushButton,
|
|
||||||
QTableView,
|
|
||||||
QVBoxLayout,
|
|
||||||
QHBoxLayout,
|
|
||||||
QHeaderView,
|
|
||||||
QHBoxLayout,
|
|
||||||
)
|
|
||||||
from PyQt5.QtCore import QSize, Qt
|
|
||||||
from PyQt5.QtGui import QCloseEvent, QStandardItem, QStandardItemModel
|
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from myutils.config import (
|
from myutils.config import (
|
||||||
noundictconfig,
|
noundictconfig,
|
||||||
@ -52,7 +39,7 @@ class noundictconfigdialog(QDialog):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self, parent, configdict, title, label=["游戏ID MD5", "原文", "翻译"], _=None
|
self, parent, configdict, title, label=["游戏ID MD5", "原文", "翻译"], _=None
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(parent, Qt.WindowCloseButtonHint)
|
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||||
|
|
||||||
self.setWindowTitle(_TR(title))
|
self.setWindowTitle(_TR(title))
|
||||||
# self.setWindowModality(Qt.ApplicationModal)
|
# self.setWindowModality(Qt.ApplicationModal)
|
||||||
@ -76,8 +63,8 @@ class noundictconfigdialog(QDialog):
|
|||||||
model.setHorizontalHeaderLabels(_TRL(label))
|
model.setHorizontalHeaderLabels(_TRL(label))
|
||||||
table = QTableView(self)
|
table = QTableView(self)
|
||||||
table.setModel(model)
|
table.setModel(model)
|
||||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
|
||||||
# table.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
# table.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
|
||||||
# table.clicked.connect(self.show_info)
|
# table.clicked.connect(self.show_info)
|
||||||
button = threebuttons()
|
button = threebuttons()
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
PyQt5==5.15.10
|
PyQt5==5.15.10
|
||||||
PyQt5-Qt5==5.15.2
|
PyQt5-Qt5==5.15.2
|
||||||
webviewpy==1.2.0
|
webviewpy==1.2.0
|
||||||
pefile
|
pefile
|
||||||
|
#python3.7.9
|
5
LunaTranslator/requirements_qt6.txt
Normal file
5
LunaTranslator/requirements_qt6.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
PyQt6==6.7.0
|
||||||
|
PyQt6-Qt6==6.7.0
|
||||||
|
webviewpy==1.2.0
|
||||||
|
pefile
|
||||||
|
#python3.11.8
|
2
LunaTranslator/run.bat
Normal file
2
LunaTranslator/run.bat
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
python.exe -B LunaTranslator\LunaTranslator_main.py
|
||||||
|
pause
|
Loading…
x
Reference in New Issue
Block a user