mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 00:24:13 +08:00
edit
This commit is contained in:
parent
a35e284312
commit
3c16f053c5
@ -108,11 +108,6 @@ class edittrans(QMainWindow):
|
|||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super().__init__(parent, Qt.WindowType.FramelessWindowHint)
|
super().__init__(parent, Qt.WindowType.FramelessWindowHint)
|
||||||
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
|
||||||
self.setStyleSheet(
|
|
||||||
"background-color: %s"
|
|
||||||
% str2rgba(globalconfig["backcolor"], globalconfig["transparent"])
|
|
||||||
)
|
|
||||||
self.setupUi()
|
self.setupUi()
|
||||||
|
|
||||||
self.rssignal.connect(self.resize)
|
self.rssignal.connect(self.resize)
|
||||||
@ -142,8 +137,7 @@ class edittrans(QMainWindow):
|
|||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
self.setWindowIcon(qtawesome.icon("fa.edit"))
|
self.setWindowIcon(qtawesome.icon("fa.edit"))
|
||||||
|
|
||||||
self.textOutput = QLineEdit(self)
|
self.textOutput = QPlainTextEdit(self)
|
||||||
|
|
||||||
qv = QHBoxLayout()
|
qv = QHBoxLayout()
|
||||||
w = QWidget()
|
w = QWidget()
|
||||||
self.setCentralWidget(w)
|
self.setCentralWidget(w)
|
||||||
@ -160,11 +154,10 @@ class edittrans(QMainWindow):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
qv.addWidget(submit)
|
qv.addWidget(submit)
|
||||||
|
|
||||||
submit.clicked.connect(self.submitfunction)
|
submit.clicked.connect(self.submitfunction)
|
||||||
|
|
||||||
def submitfunction(self):
|
def submitfunction(self):
|
||||||
text = self.textOutput.text()
|
text = self.textOutput.toPlainText()
|
||||||
if len(text) == 0:
|
if len(text) == 0:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
@ -241,6 +241,8 @@ class basetrans(commonbase):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def cachesetatend(self, contentsolved, res):
|
def cachesetatend(self, contentsolved, res):
|
||||||
|
if self.transtype == "pre":
|
||||||
|
return
|
||||||
if globalconfig["uselongtermcache"]:
|
if globalconfig["uselongtermcache"]:
|
||||||
self.longtermcacheset(contentsolved, res)
|
self.longtermcacheset(contentsolved, res)
|
||||||
self.shorttermcacheset(contentsolved, res)
|
self.shorttermcacheset(contentsolved, res)
|
||||||
@ -290,7 +292,8 @@ class basetrans(commonbase):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
collectiterres.append(_)
|
collectiterres.append(_)
|
||||||
callback("".join(collectiterres), embedcallback, is_iter_res)
|
if all([_ is not None for _ in collectiterres]):
|
||||||
|
callback("".join(collectiterres), embedcallback, is_iter_res)
|
||||||
|
|
||||||
def reinitandtrans(self, contentraw, contentsolved, is_auto_run):
|
def reinitandtrans(self, contentraw, contentsolved, is_auto_run):
|
||||||
if self.needreinit or self.initok == False:
|
if self.needreinit or self.initok == False:
|
||||||
@ -345,7 +348,8 @@ class basetrans(commonbase):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
__callback(res, 0)
|
__callback(res, 0)
|
||||||
self.cachesetatend(contentsolved, "".join(collectiterres))
|
if all([_ is not None for _ in collectiterres]):
|
||||||
|
self.cachesetatend(contentsolved, "".join(collectiterres))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if self.using and globalconfig["showtranexception"]:
|
if self.using and globalconfig["showtranexception"]:
|
||||||
if isinstance(e, ArgsEmptyExc):
|
if isinstance(e, ArgsEmptyExc):
|
||||||
|
19
LunaTranslator/LunaTranslator/translator/realtime_edit.py
Normal file
19
LunaTranslator/LunaTranslator/translator/realtime_edit.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import json, gobject
|
||||||
|
from translator.basetranslator import basetrans
|
||||||
|
|
||||||
|
|
||||||
|
class TS(basetrans):
|
||||||
|
|
||||||
|
def translate(self, content):
|
||||||
|
try:
|
||||||
|
sql = gobject.baseobject.textsource.sqlwrite2
|
||||||
|
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
(ret,) = sql.execute(
|
||||||
|
"SELECT machineTrans FROM artificialtrans WHERE source = ?", (content,)
|
||||||
|
).fetchone()
|
||||||
|
if ret is None:
|
||||||
|
return None
|
||||||
|
ret = json.loads(ret)
|
||||||
|
return ret.get("realtime_edit", None)
|
Loading…
x
Reference in New Issue
Block a user