mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
some
This commit is contained in:
parent
7890588710
commit
bb6c0f7efd
@ -32,7 +32,7 @@ from gui.dynalang import (
|
|||||||
|
|
||||||
@Singleton_close
|
@Singleton_close
|
||||||
class noundictconfigdialog1(LDialog):
|
class noundictconfigdialog1(LDialog):
|
||||||
def newline(self, row, item):
|
def newline(self, row, item: dict):
|
||||||
self.model.insertRow(
|
self.model.insertRow(
|
||||||
row,
|
row,
|
||||||
[
|
[
|
||||||
@ -42,15 +42,9 @@ class noundictconfigdialog1(LDialog):
|
|||||||
QStandardItem(item["value"]),
|
QStandardItem(item["value"]),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
if "regex" not in item:
|
self.table.setindexdata(self.model.index(row, 0), item.get("regex", False))
|
||||||
item["regex"] = False
|
self.table.setindexdata(
|
||||||
if "escape" not in item:
|
self.model.index(row, 1), item.get("escape", item.get("regex", False))
|
||||||
item["escape"] = item["regex"]
|
|
||||||
self.table.setIndexWidget(
|
|
||||||
self.model.index(row, 0), getsimpleswitch(item, "regex")
|
|
||||||
)
|
|
||||||
self.table.setIndexWidget(
|
|
||||||
self.model.index(row, 1), getsimpleswitch(item, "escape")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, parent, reflist, title, label) -> None:
|
def __init__(self, parent, reflist, title, label) -> None:
|
||||||
@ -74,8 +68,6 @@ class noundictconfigdialog1(LDialog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.table = table
|
self.table = table
|
||||||
for row, item in enumerate(reflist):
|
|
||||||
self.newline(row, item)
|
|
||||||
|
|
||||||
search = QHBoxLayout()
|
search = QHBoxLayout()
|
||||||
searchcontent = QLineEdit()
|
searchcontent = QLineEdit()
|
||||||
@ -100,6 +92,8 @@ class noundictconfigdialog1(LDialog):
|
|||||||
table.getindexdata = self.__getindexwidgetdata
|
table.getindexdata = self.__getindexwidgetdata
|
||||||
table.setindexdata = self.__setindexwidget
|
table.setindexdata = self.__setindexwidget
|
||||||
self.table = table
|
self.table = table
|
||||||
|
for row, item in enumerate(reflist):
|
||||||
|
self.newline(row, item)
|
||||||
button = threebuttons(texts=["添加行", "删除行", "上移", "下移", "立即应用"])
|
button = threebuttons(texts=["添加行", "删除行", "上移", "下移", "立即应用"])
|
||||||
table.insertplainrow = lambda row: self.newline(
|
table.insertplainrow = lambda row: self.newline(
|
||||||
row, {"key": "", "value": "", "regex": False}
|
row, {"key": "", "value": "", "regex": False}
|
||||||
@ -121,10 +115,10 @@ class noundictconfigdialog1(LDialog):
|
|||||||
|
|
||||||
def __setindexwidget(self, index: QModelIndex, data):
|
def __setindexwidget(self, index: QModelIndex, data):
|
||||||
if index.column() == 0:
|
if index.column() == 0:
|
||||||
data = {"regex": data.lower() == "true"}
|
data = {"regex": self.table.compatiblebool(data)}
|
||||||
self.table.setIndexWidget(index, getsimpleswitch(data, "regex"))
|
self.table.setIndexWidget(index, getsimpleswitch(data, "regex"))
|
||||||
elif index.column() == 1:
|
elif index.column() == 1:
|
||||||
data = {"escape": data.lower() == "true"}
|
data = {"escape": self.table.compatiblebool(data)}
|
||||||
self.table.setIndexWidget(index, getsimpleswitch(data, "escape"))
|
self.table.setIndexWidget(index, getsimpleswitch(data, "escape"))
|
||||||
else:
|
else:
|
||||||
self.table.model().setItem(index.row(), index.column(), QStandardItem(data))
|
self.table.model().setItem(index.row(), index.column(), QStandardItem(data))
|
||||||
@ -261,12 +255,10 @@ class yuyinzhidingsetting(LDialog):
|
|||||||
QStandardItem(),
|
QStandardItem(),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
self.table.setIndexWidget(
|
self.table.setindexdata(self.model.index(row, 0), item['regex'])
|
||||||
self.model.index(row, 0), getsimpleswitch(item, "regex")
|
|
||||||
)
|
self.table.setindexdata(self.model.index(row, 1), item['condition'])
|
||||||
com = getsimplecombobox(["首尾", "包含"], item, "condition")
|
self.table.setindexdata(self.model.index(row, 3), item['target'])
|
||||||
self.table.setIndexWidget(self.model.index(row, 1), com)
|
|
||||||
self.table.setIndexWidget(self.model.index(row, 3), self.createacombox(item))
|
|
||||||
|
|
||||||
def createacombox(self, config):
|
def createacombox(self, config):
|
||||||
com = LFocusCombo()
|
com = LFocusCombo()
|
||||||
@ -384,7 +376,7 @@ class yuyinzhidingsetting(LDialog):
|
|||||||
|
|
||||||
def __setindexwidget(self, index: QModelIndex, data):
|
def __setindexwidget(self, index: QModelIndex, data):
|
||||||
if index.column() == 0:
|
if index.column() == 0:
|
||||||
data = {"regex": data.lower() == "true"}
|
data = {"regex": self.table.compatiblebool(data)}
|
||||||
self.table.setIndexWidget(index, getsimpleswitch(data, "regex"))
|
self.table.setIndexWidget(index, getsimpleswitch(data, "regex"))
|
||||||
elif index.column() == 1:
|
elif index.column() == 1:
|
||||||
try:
|
try:
|
||||||
@ -400,7 +392,7 @@ class yuyinzhidingsetting(LDialog):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
data = json.loads(data)
|
data = self.table.compatiblejson(data)
|
||||||
except:
|
except:
|
||||||
data = "default"
|
data = "default"
|
||||||
self.table.setIndexWidget(index, self.createacombox({"target": data}))
|
self.table.setIndexWidget(index, self.createacombox({"target": data}))
|
||||||
|
@ -120,7 +120,6 @@ def updatemethod(urls, self):
|
|||||||
stream=True,
|
stream=True,
|
||||||
verify=False,
|
verify=False,
|
||||||
proxies=getproxy(("update", __x)),
|
proxies=getproxy(("update", __x)),
|
||||||
timeout=None,
|
|
||||||
)
|
)
|
||||||
file_size = 0
|
file_size = 0
|
||||||
for i in r.iter_content(chunk_size=1024):
|
for i in r.iter_content(chunk_size=1024):
|
||||||
|
@ -97,8 +97,7 @@ class TableViewW(QTableView):
|
|||||||
self.customContextMenuRequested.connect(self.showmenu)
|
self.customContextMenuRequested.connect(self.showmenu)
|
||||||
|
|
||||||
def showmenu(self, pos):
|
def showmenu(self, pos):
|
||||||
r = self.currentIndex().row()
|
if not self.currentIndex().isValid():
|
||||||
if r < 0:
|
|
||||||
return
|
return
|
||||||
menu = QMenu(self)
|
menu = QMenu(self)
|
||||||
up = LAction("上移")
|
up = LAction("上移")
|
||||||
@ -159,8 +158,11 @@ class TableViewW(QTableView):
|
|||||||
self.model().removeRow(row)
|
self.model().removeRow(row)
|
||||||
|
|
||||||
def removeselectedrows(self):
|
def removeselectedrows(self):
|
||||||
row = self.currentIndex().row()
|
curr = self.currentIndex()
|
||||||
col = self.currentIndex().column()
|
if not curr.isValid():
|
||||||
|
return
|
||||||
|
row = curr.row()
|
||||||
|
col = curr.column()
|
||||||
skip = []
|
skip = []
|
||||||
for index in self.selectedIndexes():
|
for index in self.selectedIndexes():
|
||||||
if index.row() in skip:
|
if index.row() in skip:
|
||||||
@ -176,6 +178,8 @@ class TableViewW(QTableView):
|
|||||||
|
|
||||||
def moverank(self, dy):
|
def moverank(self, dy):
|
||||||
curr = self.currentIndex()
|
curr = self.currentIndex()
|
||||||
|
if not curr.isValid():
|
||||||
|
return
|
||||||
row, col = curr.row(), curr.column()
|
row, col = curr.row(), curr.column()
|
||||||
|
|
||||||
model = self.model()
|
model = self.model()
|
||||||
@ -206,6 +210,15 @@ class TableViewW(QTableView):
|
|||||||
l: QHBoxLayout = w.layout()
|
l: QHBoxLayout = w.layout()
|
||||||
return l.itemAt(0).widget()
|
return l.itemAt(0).widget()
|
||||||
|
|
||||||
|
def inputMethodEvent(self, event: QInputMethodEvent):
|
||||||
|
# setindexwidget之后,会导致谜之循环触发,异常;
|
||||||
|
# 没有setindexwidget的,会跳转到第一个输入的字母的行,正常,但我不想要。
|
||||||
|
pres = event.commitString()
|
||||||
|
if not pres:
|
||||||
|
super().inputMethodEvent(event)
|
||||||
|
else:
|
||||||
|
event.accept()
|
||||||
|
|
||||||
def setIndexWidget(self, index: QModelIndex, w: QWidget):
|
def setIndexWidget(self, index: QModelIndex, w: QWidget):
|
||||||
if w is None:
|
if w is None:
|
||||||
return
|
return
|
||||||
@ -229,6 +242,24 @@ class TableViewW(QTableView):
|
|||||||
def setindexdata(self, index, data):
|
def setindexdata(self, index, data):
|
||||||
self.model().setItem(index.row(), index.column(), QStandardItem(data))
|
self.model().setItem(index.row(), index.column(), QStandardItem(data))
|
||||||
|
|
||||||
|
def compatiblebool(self, data):
|
||||||
|
if isinstance(data, str):
|
||||||
|
data = data.lower() == "true"
|
||||||
|
elif isinstance(data, bool):
|
||||||
|
data = data
|
||||||
|
else:
|
||||||
|
raise Exception
|
||||||
|
return data
|
||||||
|
|
||||||
|
def compatiblejson(self, data):
|
||||||
|
if isinstance(data, str):
|
||||||
|
data = json.loads(data)
|
||||||
|
elif isinstance(data, (list, dict, tuple)):
|
||||||
|
data = data
|
||||||
|
else:
|
||||||
|
raise Exception
|
||||||
|
return data
|
||||||
|
|
||||||
def getdata(self, row_or_index, col=None):
|
def getdata(self, row_or_index, col=None):
|
||||||
if col is None:
|
if col is None:
|
||||||
index: QModelIndex = row_or_index
|
index: QModelIndex = row_or_index
|
||||||
@ -260,8 +291,10 @@ class TableViewW(QTableView):
|
|||||||
winsharedutils.clipboard_set(csv_str)
|
winsharedutils.clipboard_set(csv_str)
|
||||||
|
|
||||||
def pastetable(self):
|
def pastetable(self):
|
||||||
string = winsharedutils.clipboard_get()
|
|
||||||
current = self.currentIndex()
|
current = self.currentIndex()
|
||||||
|
if not current.isValid():
|
||||||
|
return
|
||||||
|
string = winsharedutils.clipboard_get()
|
||||||
try:
|
try:
|
||||||
csv_file = io.StringIO(string)
|
csv_file = io.StringIO(string)
|
||||||
csv_reader = csv.reader(csv_file, delimiter="\t")
|
csv_reader = csv.reader(csv_file, delimiter="\t")
|
||||||
@ -1796,8 +1829,7 @@ def makesubtab_lazy(
|
|||||||
class listediter(LDialog):
|
class listediter(LDialog):
|
||||||
def showmenu(self, p: QPoint):
|
def showmenu(self, p: QPoint):
|
||||||
curr = self.hctable.currentIndex()
|
curr = self.hctable.currentIndex()
|
||||||
r = curr.row()
|
if not curr.isValid():
|
||||||
if r < 0:
|
|
||||||
return
|
return
|
||||||
menu = QMenu(self.hctable)
|
menu = QMenu(self.hctable)
|
||||||
remove = LAction("删除")
|
remove = LAction("删除")
|
||||||
|
@ -87,8 +87,10 @@ def ocr_run(qimage: QImage):
|
|||||||
if not image:
|
if not image:
|
||||||
return "", None
|
return "", None
|
||||||
global _nowuseocrx, _ocrengine
|
global _nowuseocrx, _ocrengine
|
||||||
|
thisocrtype = _nowuseocrx
|
||||||
try:
|
try:
|
||||||
ocr_init()
|
ocr_init()
|
||||||
|
thisocrtype = _ocrengine.typename
|
||||||
res = _ocrengine._private_ocr(image)
|
res = _ocrengine._private_ocr(image)
|
||||||
if not res:
|
if not res:
|
||||||
return "", None
|
return "", None
|
||||||
@ -105,7 +107,7 @@ def ocr_run(qimage: QImage):
|
|||||||
print_exc()
|
print_exc()
|
||||||
msg = stringfyerror(e)
|
msg = stringfyerror(e)
|
||||||
text = (
|
text = (
|
||||||
(_TR(globalconfig["ocr"][_nowuseocrx]["name"]) if _nowuseocrx else "")
|
(_TR(globalconfig["ocr"][thisocrtype]["name"]) if thisocrtype else "")
|
||||||
+ " "
|
+ " "
|
||||||
+ msg
|
+ msg
|
||||||
)
|
)
|
||||||
|
@ -158,9 +158,10 @@ class Requester(Requester_common):
|
|||||||
|
|
||||||
curl_easy_reset(curl)
|
curl_easy_reset(curl)
|
||||||
curl_easy_setopt(curl, CURLoption.COOKIEJAR, "")
|
curl_easy_setopt(curl, CURLoption.COOKIEJAR, "")
|
||||||
if timeout:
|
if timeout[0]:
|
||||||
curl_easy_setopt(curl, CURLoption.TIMEOUT_MS, timeout)
|
curl_easy_setopt(curl, CURLoption.CONNECTTIMEOUT_MS, timeout[0])
|
||||||
curl_easy_setopt(curl, CURLoption.CONNECTTIMEOUT_MS, timeout)
|
if timeout[1]:
|
||||||
|
curl_easy_setopt(curl, CURLoption.TIMEOUT_MS, sum(timeout))
|
||||||
curl_easy_setopt(
|
curl_easy_setopt(
|
||||||
curl,
|
curl,
|
||||||
CURLoption.ACCEPT_ENCODING,
|
CURLoption.ACCEPT_ENCODING,
|
||||||
|
@ -160,8 +160,9 @@ class Requester(Requester_common):
|
|||||||
flag,
|
flag,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if timeout:
|
tconnect = timeout[0]
|
||||||
WinHttpSetTimeouts(hRequest, timeout, timeout, timeout, timeout)
|
tsendrecv = timeout[1]
|
||||||
|
WinHttpSetTimeouts(hRequest, tconnect, tconnect, tsendrecv, tsendrecv)
|
||||||
if hRequest == 0:
|
if hRequest == 0:
|
||||||
MaybeRaiseException()
|
MaybeRaiseException()
|
||||||
self._set_verify(hRequest, verify)
|
self._set_verify(hRequest, verify)
|
||||||
|
@ -17,9 +17,7 @@ class OCR(baseocr):
|
|||||||
cookies = {"SOCS": "CAESEwgDEgk0ODE3Nzk3MjQaAmVuIAEaBgiA_LyaBg"}
|
cookies = {"SOCS": "CAESEwgDEgk0ODE3Nzk3MjQaAmVuIAEaBgiA_LyaBg"}
|
||||||
|
|
||||||
files = {"encoded_image": ("screenshot.png", imagebinary, "image/png")}
|
files = {"encoded_image": ("screenshot.png", imagebinary, "image/png")}
|
||||||
res = self.proxysession.post(
|
res = self.proxysession.post(url, files=files, headers=headers, cookies=cookies)
|
||||||
url, files=files, headers=headers, cookies=cookies, timeout=20
|
|
||||||
)
|
|
||||||
match = regex.search(res.text)
|
match = regex.search(res.text)
|
||||||
if match == None:
|
if match == None:
|
||||||
return
|
return
|
||||||
|
@ -433,10 +433,6 @@ class Service(object):
|
|||||||
url,
|
url,
|
||||||
headers=r.headers,
|
headers=r.headers,
|
||||||
data=r.form,
|
data=r.form,
|
||||||
timeout=(
|
|
||||||
self.service_info.connection_timeout,
|
|
||||||
self.service_info.socket_timeout,
|
|
||||||
),
|
|
||||||
proxies=proxy,
|
proxies=proxy,
|
||||||
)
|
)
|
||||||
if resp.status_code == 200:
|
if resp.status_code == 200:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
try:
|
try:
|
||||||
from PyQt5 import QtSvg
|
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,QToolTip,QGroupBox,QGraphicsOpacityEffect,QStackedWidget,QStyledItemDelegate,QStyleOptionViewItem,QFontDialog,QTreeView
|
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,QToolTip,QGroupBox,QGraphicsOpacityEffect,QStackedWidget,QStyledItemDelegate,QStyleOptionViewItem,QFontDialog,QTreeView
|
||||||
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,QShowEvent,QWheelEvent,QPaintEvent,QTextLayout, QTextOption,QDragEnterEvent, QDropEvent,QTransform,QKeyEvent
|
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,QShowEvent,QWheelEvent,QPaintEvent,QTextLayout, QTextOption,QDragEnterEvent, QDropEvent,QTransform,QKeyEvent,QInputMethodEvent
|
||||||
from PyQt5.QtCore import QObject,pyqtSignal,Qt,QSize,QByteArray,QBuffer,QPointF,QPoint,QRect,QEvent,QModelIndex,QTimer,QRectF,QVariantAnimation,QUrl,QPropertyAnimation,QLocale,QSignalBlocker
|
from PyQt5.QtCore import QObject,pyqtSignal,Qt,QSize,QByteArray,QBuffer,QPointF,QPoint,QRect,QEvent,QModelIndex,QTimer,QRectF,QVariantAnimation,QUrl,QPropertyAnimation,QLocale,QSignalBlocker
|
||||||
isqt5 = True
|
isqt5 = True
|
||||||
class LineHeightTypes:
|
class LineHeightTypes:
|
||||||
@ -12,7 +12,7 @@ except:
|
|||||||
#print_exc()
|
#print_exc()
|
||||||
from PyQt6 import QtSvg
|
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,QToolTip,QGroupBox,QGraphicsOpacityEffect,QStackedWidget,QTreeView
|
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,QToolTip,QGroupBox,QGraphicsOpacityEffect,QStackedWidget,QTreeView
|
||||||
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,QShowEvent,QWheelEvent,QPaintEvent,QTextLayout, QTextOption,QKeyEvent
|
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,QShowEvent,QWheelEvent,QPaintEvent,QTextLayout, QTextOption,QKeyEvent,QInputMethodEvent
|
||||||
from PyQt6.QtCore import QObject,pyqtSignal,Qt,QSize,QByteArray,QBuffer,QPointF,QPoint,QRect,QEvent,QModelIndex,QTimer,QRectF,QVariantAnimation,QUrl,QPropertyAnimation,QLocale
|
from PyQt6.QtCore import QObject,pyqtSignal,Qt,QSize,QByteArray,QBuffer,QPointF,QPoint,QRect,QEvent,QModelIndex,QTimer,QRectF,QVariantAnimation,QUrl,QPropertyAnimation,QLocale
|
||||||
isqt5 = False
|
isqt5 = False
|
||||||
|
|
||||||
|
@ -17,13 +17,12 @@ class CachedQGraphicsDropShadowEffect_multi(QGraphicsDropShadowEffect):
|
|||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.shadow_pixmap = QPixmap()
|
self.shadow_pixmap = QPixmap()
|
||||||
self.x = x
|
self.x = x
|
||||||
self.savey = None
|
self.savey = None # iterappend中被移动而不需重绘
|
||||||
|
|
||||||
def draw(self, painter):
|
def draw(self, painter):
|
||||||
r = self.parent().devicePixelRatioF()
|
|
||||||
if self.shadow_pixmap.isNull():
|
if self.shadow_pixmap.isNull():
|
||||||
|
r = self.parent().devicePixelRatioF()
|
||||||
size = QSize(painter.device().width(), painter.device().height()) * r
|
size = self.boundingRect().toRect().united(painter.viewport()).size() * r
|
||||||
self.shadow_pixmap = QPixmap(size)
|
self.shadow_pixmap = QPixmap(size)
|
||||||
self.shadow_pixmap.setDevicePixelRatio(r)
|
self.shadow_pixmap.setDevicePixelRatio(r)
|
||||||
self.shadow_pixmap.fill(Qt.GlobalColor.transparent)
|
self.shadow_pixmap.fill(Qt.GlobalColor.transparent)
|
||||||
|
@ -294,13 +294,17 @@ class Requester_common:
|
|||||||
proxy = None if proxy == "" else proxy
|
proxy = None if proxy == "" else proxy
|
||||||
if timeout:
|
if timeout:
|
||||||
if isinstance(timeout, (float, int)):
|
if isinstance(timeout, (float, int)):
|
||||||
timeout = int(timeout * 1000) # convert to milliseconds
|
timeout = (int(timeout * 1000), 0) # convert to milliseconds
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
timeout = max(int(_ * 1000) for _ in timeout)
|
timeout = [int(_ * 1000) for _ in timeout[:2]]
|
||||||
except:
|
except:
|
||||||
print("Error invalid timeout", timeout)
|
print("Error invalid timeout", timeout)
|
||||||
timeout = None
|
timeout = [0, 0]
|
||||||
|
timeout.append(0)
|
||||||
|
timeout = timeout[:2]
|
||||||
|
else:
|
||||||
|
timeout = (0, 0)
|
||||||
return self.request_impl(
|
return self.request_impl(
|
||||||
method,
|
method,
|
||||||
scheme,
|
scheme,
|
||||||
|
@ -327,10 +327,6 @@ class Service(object):
|
|||||||
url,
|
url,
|
||||||
headers=r.headers,
|
headers=r.headers,
|
||||||
data=r.body.encode("utf8").decode("latin1"),
|
data=r.body.encode("utf8").decode("latin1"),
|
||||||
timeout=(
|
|
||||||
self.service_info.connection_timeout,
|
|
||||||
self.service_info.socket_timeout,
|
|
||||||
),
|
|
||||||
proxies=proxy,
|
proxies=proxy,
|
||||||
)
|
)
|
||||||
if resp.status_code == 200:
|
if resp.status_code == 200:
|
||||||
|
@ -18,7 +18,7 @@ def translate_async(text, to_language, from_language=None, self=None):
|
|||||||
url = "{}/translate?api-version={}&to={}".format(
|
url = "{}/translate?api-version={}&to={}".format(
|
||||||
_apiEndpoint, _apiVersion, to_language
|
_apiEndpoint, _apiVersion, to_language
|
||||||
)
|
)
|
||||||
if from_language is not None:
|
if from_language != "auto":
|
||||||
url += "&from={}".format(from_language)
|
url += "&from={}".format(from_language)
|
||||||
_privateKey = [
|
_privateKey = [
|
||||||
0xA2,
|
0xA2,
|
||||||
|
@ -28,8 +28,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/version)
|
|||||||
include(generate_product_version)
|
include(generate_product_version)
|
||||||
|
|
||||||
set(VERSION_MAJOR 5)
|
set(VERSION_MAJOR 5)
|
||||||
set(VERSION_MINOR 51)
|
set(VERSION_MINOR 52)
|
||||||
set(VERSION_PATCH 2)
|
set(VERSION_PATCH 0)
|
||||||
|
|
||||||
add_library(pch pch.cpp)
|
add_library(pch pch.cpp)
|
||||||
target_precompile_headers(pch PUBLIC pch.h)
|
target_precompile_headers(pch PUBLIC pch.h)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user