This commit is contained in:
恍兮惚兮 2024-09-16 12:12:09 +08:00
parent 91c875ba45
commit 7321a74d95
34 changed files with 140 additions and 137 deletions

View File

@ -38,6 +38,6 @@ class edict(cishubase):
x = self.sql.execute(
"select word, content from entry where id =?", (_id,)
).fetchone()
saveres.append(x[0] + "<br>" + re.sub("/EntL.*/", "", x[1][1:]))
saveres.append(x[0] + "<hr>" + re.sub("/EntL.*/", "", x[1][1:]))
return "<hr>".join(saveres)

View File

@ -40,6 +40,6 @@ class edict2(cishubase):
srt = argsort(dis)
for ii in srt[: self.config["max_num"]]:
saveres.append(
savew[ii] + "<br>" + re.sub("/EntL.*/", "", self.save[savew[ii]][1:])
savew[ii] + "<hr>" + re.sub("/EntL.*/", "", self.save[savew[ii]][1:])
)
return "<hr>".join(saveres)

View File

@ -99,9 +99,4 @@ class jisho(cishubase):
ss = re.search('href="https://assets.jisho.org/assets/application(.*)"', html)
stl = requests.get(ss.group()[6:-1], proxies=self.proxy).text
return (
'<div style="text-align: center;"><a href="{}">link</a></div><br>'.format(
url
)
+ f"<style>{stl}</style>{res}"
)
return f"<style>{stl}</style>{res}"

View File

@ -46,5 +46,5 @@ class linggesi(cishubase):
mp[w] = [xx, d]
x = sorted(list(mp.keys()), key=lambda x: mp[x][1])[: self.config["max_num"]]
save = [w + "<br>" + mp[w][0] for w in x]
save = [w + "<hr>" + mp[w][0] for w in x]
return "<hr>".join(save)

View File

@ -628,7 +628,7 @@ class mojidict(cishubase):
result = ""
try:
result += mojiclicksearch(self, word)
result += "<br>"
result += "<hr>"
except:
pass
try:

View File

@ -23,11 +23,5 @@ class weblio(cishubase):
xx = re.sub('class="(.*?)"', "", xx)
_all.append(xx)
join = "<br>".join(_all)
if len(join):
return (
'<div style="text-align: center;"><a href="{}">link</a></div>'.format(
url
)
+ join
)
join = "<hr>".join(_all)
return join

View File

@ -443,8 +443,7 @@ def filetranslate(self):
[(functools.partial(createdownloadprogress, self), 0)],
[],
[
"使用最快翻译而非指定翻译器",
D_getsimpleswitch(globalconfig["embedded"], "as_fast_as_posible"),
"指定翻译器",
(
D_getsimplecombobox(
alltransvis,
@ -452,9 +451,13 @@ def filetranslate(self):
"translator_2",
internal=alltrans,
),
2,
3,
),
],
[
"使用最快翻译而非指定翻译器",
D_getsimpleswitch(globalconfig["embedded"], "as_fast_as_posible"),
],
]
return grids

View File

@ -155,19 +155,16 @@ class AnkiWindow(QWidget):
def creattemplatetab(self, baselay):
layout = QHBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
wid = QWidget()
wid.setLayout(layout)
baselay.addWidget(wid)
spliter = QSplitter()
baselay.addWidget(spliter)
edittemptab = LTabWidget()
self.previewtab = LTabBar()
revertbtn = LPushButton("恢复")
revertbtn.clicked.connect(self.loadedits)
savebtn = LPushButton("保存")
savebtn.clicked.connect(self.saveedits)
layout.addLayout(
spliter.addWidget(
getboxlayout(
[
edittemptab,
@ -175,6 +172,7 @@ class AnkiWindow(QWidget):
],
lc=QVBoxLayout,
margin0=True,
makewidget=True,
)
)
@ -182,11 +180,12 @@ class AnkiWindow(QWidget):
self.htmlbrowser.setSizePolicy(
QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding
)
layout.addLayout(
spliter.addWidget(
getboxlayout(
[self.previewtab, self.htmlbrowser],
lc=QVBoxLayout,
margin0=True,
makewidget=True,
)
)
self.fronttext = FQPlainTextEdit()
@ -209,10 +208,17 @@ class AnkiWindow(QWidget):
):
object.setPlainText(text)
def makedictionaryHTML(self, dictionarys):
if not dictionarys:
return ""
htmlcontents = ""
for iiii in range(len(dictionarys)):
htmlcontents += f'<div id="luna_dict_tab_{dictionarys[iiii]["dict"]}" class="tab-pane">{dictionarys[iiii]["content"]}</div>'
return htmlcontents
def loadfileds(self):
word = self.currentword
explain = quote(json.dumps(self.refsearchw.generate_explains()))
dictionarys = self.refsearchw.generate_dictionarys()
remarks = self.remarks.toPlainText()
example = self.example.toPlainText()
if globalconfig["ankiconnect"]["boldword"]:
@ -226,10 +232,18 @@ class AnkiWindow(QWidget):
collect.append(hira["orig"])
example = "".join(collect)
ruby = self.ruby
dictionaryInfo = []
dictionaryJson = {}
for _ in dictionarys:
dictionaryInfo.append(
{"dict": _["dict"], "name": globalconfig["cishu"][_["dict"]]["name"]}
)
dictionaryJson[_["dict"]] = _["content"]
fields = {
"word": word,
"rubytext": ruby,
"explain": explain,
"rubytextHtml": ruby,
"dictionaryJson": quote(json.dumps(dictionaryJson)),
"dictionaryInfo": json.dumps(dictionaryInfo, ensure_ascii=False),
"example_sentence": example.replace("\n", "<br>"),
"remarks": remarks.replace("\n", "<br>"),
}
@ -275,9 +289,9 @@ class AnkiWindow(QWidget):
else:
encoded_string3 = ""
fields = {
"audio": encoded_string2,
"audio_sentence": encoded_string3,
"image": encoded_string,
"audio_for_word": encoded_string2,
"audio_for_example_sentence": encoded_string3,
"screenshot": encoded_string,
}
return fields
@ -584,15 +598,23 @@ class AnkiWindow(QWidget):
if res != "":
item.setText(res)
def makerubyhtml(self, ruby):
if not ruby:
return ""
html = ""
for i in range(len(ruby)):
html += ruby[i]["orig"]
if ruby[i]["orig"] != ruby[i]["hira"]:
html += "<rt>" + ruby[i]["hira"] + "</rt>"
else:
html += "<rt></rt>"
html = "<ruby>" + html + "</ruby>"
return html
def reset(self, text):
self.currentword = text
if text and len(text):
self.ruby = quote(
json.dumps(
gobject.baseobject.parsehira(text),
ensure_ascii=False,
)
)
self.ruby = self.makerubyhtml(gobject.baseobject.parsehira(text))
else:
self.ruby = ""
self.editpath.clear()
@ -905,7 +927,7 @@ class searchwordW(closeashidewindow):
self.searchtext.text(), True, gobject.baseobject.audioplayer.timestamp
)
def generate_explains(self):
def generate_dictionarys(self):
res = []
tabks = []
for k, v in self.cache_results.items():
@ -919,9 +941,8 @@ class searchwordW(closeashidewindow):
for i in tabks:
if i >= thisp:
idx += 1
k = _TR(globalconfig["cishu"][k]["name"])
tabks.append(thisp)
res.insert(idx, {"source": k, "content": v})
res.insert(idx, {"dict": k, "content": v})
return res
def __click_word_search_function(self, word, append):

View File

@ -1,25 +1,14 @@
<div class="hide-style">
<div id="audio">{{audio}}</div>
<div id="audio_sentence">{{audio_sentence}}</div>
<div id="audio">{{audio_for_word}}</div>
<div id="audio_sentence">{{audio_for_example_sentence}}</div>
</div>
<div class="centerdiv" onclick='playAudio("audio")'>
<div class="ruby-div" id="word">{{ word }}</div>
<div id="rubyword" class="ruby-div"></div>
<div id="rubyword" class="ruby-div">{{ rubytextHtml }}</div>
</div>
<script>
var ruby = JSON.parse(decodeURIComponent("{{ rubytext }}"))
var html = ''
if (ruby.length) {
for (var i = 0; i < ruby.length; i++) {
html += ruby[i]['orig'];
if (ruby[i]['orig'] != ruby[i]['hira'])
html += '<rt>' + ruby[i]['hira'] + '</rt>';
else
html += '<rt></rt>';
}
html = '<ruby>' + html + '</ruby>'
document.getElementById('rubyword').innerHTML = html
if (document.getElementById('rubyword').innerHTML.trim().length > 0) {
document.getElementById('word').classList.add("hide-style");
}
else {
@ -32,7 +21,7 @@
{{example_sentence}}
</div>
<div id="image" class="centerdiv">
{{image}}
{{screenshot}}
</div>
<div id="remarks" class="centerdiv remark-div">
@ -47,23 +36,7 @@
</div>
</div>
</div>
<script>
var explains = JSON.parse(decodeURIComponent("{{ explain }}"))
function safehtml(html) {
html = decodeURIComponent(html)
var tempParent = document.createElement('div');
tempParent.innerHTML = html;
var fragment = document.createElement('div');
while (tempParent.firstChild) {
fragment.appendChild(tempParent.firstChild);
}
return fragment, fragment.innerHTML
}
var htmltabbuttons = ''
var htmlcontents = ''
function onclickbtn(_id) {
var tabButtons = document.querySelectorAll('.tab-widget .tab-button');
@ -73,41 +46,43 @@
for (var i = 0; i < tabPanes.length; i++)
tabPanes[i].classList.remove('active');
document.getElementById(_id).classList.add('active');
var tabId = document.getElementById(_id).getAttribute('data-tab');
var tabPane = document.getElementById(tabId);
tabPane.classList.add('active');
document.getElementById('luna_dict_btn_' + _id).classList.add('active');
document.getElementById('luna_dict_tab_' + _id).classList.add('active');
}
</script>
<script>
var dictionaryInfo = {{ dictionaryInfo }};
var dictionaryJson = JSON.parse(decodeURIComponent("{{ dictionaryJson }}"))
var htmltabbuttons = ''
var htmlcontents = ''
var scriptElementss = []
for (var iiii = 0; iiii < explains.length; iiii++) {
htmltabbuttons += '<button type="button" onclick="onclickbtn(\'buttonid' + (iiii).toString() + '\')" id="buttonid' + (iiii).toString() + '" class="tab-button" data-tab="tab' + (iiii).toString() + '">' + explains[iiii]['source'] + '</button>'
for (var iiii = 0; iiii < dictionaryInfo.length; iiii++) {
htmltabbuttons += '<button type="button" onclick="onclickbtn(\'' + dictionaryInfo[iiii]['dict'] + '\')" id="luna_dict_btn_' + dictionaryInfo[iiii]['dict'] + '" class="tab-button">' + dictionaryInfo[iiii]['name'] + '</button>'
var tempParent = document.createElement('div');
tempParent.innerHTML = explains[iiii]['content'];
tempParent.innerHTML = dictionaryJson[dictionaryInfo[iiii]['dict']];
var fragment = document.createElement('div');
while (tempParent.firstChild) {
fragment.appendChild(tempParent.firstChild);
}
htmlcontents += '<div id="tab' + (iiii).toString() + '" class="tab-pane">' + fragment.innerHTML + '</div>'
htmlcontents += '<div id="luna_dict_tab_' + dictionaryInfo[iiii]['dict'] + '" class="tab-pane">' + fragment.innerHTML + '</div>'
var scriptElements = fragment.getElementsByTagName('script');
for (var jjjj = 0; jjjj < scriptElements.length; jjjj++) {
scriptElementss.push(scriptElements[jjjj].textContent)
}
}
document.getElementById('tab_contents').innerHTML = htmlcontents;
document.getElementById('tab_buttons').innerHTML = htmltabbuttons;
if (document.querySelectorAll('.tab-widget .tab-button').length) {
document.querySelectorAll('.tab-widget .tab-button')[0].click()
}
document.getElementById('tab_buttons').innerHTML = htmltabbuttons
document.getElementById('tab_contents').innerHTML = htmlcontents
for (var iiii = 0; iiii < scriptElementss.length; iiii++) {
eval(scriptElementss[iiii])
}
if (dictionaryInfo.length > 0) {
onclickbtn(dictionaryInfo[0]['dict'])
}
</script>
<script>
function playAudio(audioId) {
var audioDiv = document.getElementById(audioId);

View File

@ -1,25 +1,14 @@
<div class="hide-style">
<div id="audio">{{audio}}</div>
<div id="audio_sentence">{{audio_sentence}}</div>
<div id="audio">{{audio_for_word}}</div>
<div id="audio_sentence">{{audio_for_example_sentence}}</div>
</div>
<div class="centerdiv" onclick='playAudio("audio")'>
<div class="ruby-div" id="word">{{ word }}</div>
<div id="rubyword" class="ruby-div"></div>
<div id="rubyword" class="ruby-div">{{ rubytextHtml }}</div>
</div>
<script>
var ruby = JSON.parse(decodeURIComponent("{{ rubytext }}"))
var html = ''
if (ruby.length) {
for (var i = 0; i < ruby.length; i++) {
html += ruby[i]['orig'];
if (ruby[i]['orig'] != ruby[i]['hira'])
html += '<rt>' + ruby[i]['hira'] + '</rt>';
else
html += '<rt></rt>';
}
html = '<ruby>' + html + '</ruby>'
document.getElementById('rubyword').innerHTML = html
if (document.getElementById('rubyword').innerHTML.trim().length > 0) {
document.getElementById('word').classList.add("hide-style");
}
else {
@ -32,7 +21,7 @@
{{example_sentence}}
</div>
<div id="image" class="centerdiv">
{{image}}
{{screenshot}}
</div>

View File

@ -11,7 +11,6 @@
.centerdiv img {
flex: 1;
max-width: 100%;
height: auto;
}

View File

@ -473,7 +473,7 @@
"DeckNameS": [
"lunadeck"
],
"ModelName5": "lunamodel5",
"ModelName6": "modelofluna",
"allowDuplicate": true,
"autoUpdateModel": true,
"ocrcroped": false,

View File

@ -1996,13 +1996,20 @@
],
"model_fileds": [
"word",
"remarks",
"rubytextHtml",
"example_sentence",
"image",
"audio",
"audio_sentence",
"rubytext",
"explain"
"audio_for_word",
"audio_for_example_sentence",
"screenshot",
"remarks",
"dictionaryInfo",
"dictionaryJson",
"luna_reserved_1",
"luna_reserved_2",
"luna_reserved_3",
"user_custom_1",
"user_custom_2",
"user_custom_3"
],
"textrender": {
"textbrowser": [

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "لا يتم عرض اسم المترجم",
"华为云": "هوا وي يون",
"逐行匹配": "خط مطابقة",
"游戏适配": "لعبة مباراة"
"游戏适配": "لعبة مباراة",
"指定翻译器": "تعيين مترجم"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "不顯示翻譯器名稱",
"华为云": "華為雲",
"逐行匹配": "逐行匹配",
"游戏适配": "遊戲適配"
"游戏适配": "遊戲適配",
"指定翻译器": "指定翻譯器"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "Nezobrazovat jméno překladatele",
"华为云": "Hua Weiyun.",
"逐行匹配": "Shoda řádku po řádku",
"游戏适配": "Úprava hry"
"游戏适配": "Úprava hry",
"指定翻译器": "Upřesnit překladatele"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "Übersetzername nicht anzeigen",
"华为云": "Hua Weiyun",
"逐行匹配": "Zeile für Zeile übereinstimmen",
"游戏适配": "Anpassung des Spiels"
"游戏适配": "Anpassung des Spiels",
"指定翻译器": "Übersetzer angeben"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "Do not display translator name",
"华为云": "Hua Weiyun",
"逐行匹配": "Match line by line",
"游戏适配": "Game adaptation"
"游戏适配": "Game adaptation",
"指定翻译器": "Specify translator"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "No se muestra el nombre del traductor",
"华为云": "Hua weiyun",
"逐行匹配": "Coincidencia línea a línea",
"游戏适配": "Adaptación del juego"
"游戏适配": "Adaptación del juego",
"指定翻译器": "Especificar traductor"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "Ne pas afficher le nom du traducteur",
"华为云": "Huawei Cloud",
"逐行匹配": "Correspondance ligne par ligne",
"游戏适配": "Adaptation du jeu"
"游戏适配": "Adaptation du jeu",
"指定翻译器": "Spécifier le traducteur"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "Non visualizzare il nome del traduttore",
"华为云": "Hua Weiyun",
"逐行匹配": "Corrisponda linea per linea",
"游戏适配": "Adattamento del gioco"
"游戏适配": "Adattamento del gioco",
"指定翻译器": "Specifica traduttore"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "翻訳者名を表示しない",
"华为云": "華を雲と為す",
"逐行匹配": "プログレッシブマッチング",
"游戏适配": "ゲームアダプタ"
"游戏适配": "ゲームアダプタ",
"指定翻译器": "翻訳機の指定"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "번역기 이름이 표시되지 않음",
"华为云": "화위운",
"逐行匹配": "행별 일치",
"游戏适配": "게임 적합성"
"游戏适配": "게임 적합성",
"指定翻译器": "번역기 지정"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "Toon de naam van de vertaler niet",
"华为云": "Hua Weiyun.",
"逐行匹配": "Lijn voor regel overeenkomen",
"游戏适配": "Game aanpassing"
"游戏适配": "Game aanpassing",
"指定翻译器": "Vertaler opgeven"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "Nie wyświetlaj nazwy tłumacza",
"华为云": "Hua Weiyun.",
"逐行匹配": "Dopasuj linię po linii",
"游戏适配": "Adaptacja gry"
"游戏适配": "Adaptacja gry",
"指定翻译器": "Określ tłumacza"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "Não mostrar o nome do tradutor",
"华为云": "Hua Weiyun",
"逐行匹配": "Corresponder linha por linha",
"游戏适配": "Adaptação do jogo"
"游戏适配": "Adaptação do jogo",
"指定翻译器": "Especificar o tradutor"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "Не показывать имя переводчика",
"华为云": "Хуа как облако",
"逐行匹配": "Постепенное согласование",
"游戏适配": "Игра подходит"
"游戏适配": "Игра подходит",
"指定翻译器": "Назначить переводчика"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "Visa inte översättarens namn",
"华为云": "Hua Weiyun",
"逐行匹配": "Matcha rad för rad",
"游戏适配": "Spelanpassning"
"游戏适配": "Spelanpassning",
"指定翻译器": "Ange översättare"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "ไม่แสดงชื่อแปล",
"华为云": "Huawei เมฆ",
"逐行匹配": "จับคู่ตามบรรทัด",
"游戏适配": "การปรับเกม"
"游戏适配": "การปรับเกม",
"指定翻译器": "ระบุนักแปล"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "Tercüme ismini gösterme",
"华为云": "Hua Weiyun",
"逐行匹配": "Satırla eşleştir",
"游戏适配": "Oyun uygulaması"
"游戏适配": "Oyun uygulaması",
"指定翻译器": "Çevirmeyi belirtin"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "Не показувати назву перекладача",
"华为云": "Hua Weiyun",
"逐行匹配": "Порівнювати рядок за рядком",
"游戏适配": "Адаптація гри"
"游戏适配": "Адаптація гри",
"指定翻译器": "Вкажіть перекладач"
}

View File

@ -856,5 +856,6 @@
"不显示翻译器名称": "Name",
"华为云": "Hoa Vi Vân",
"逐行匹配": "Khớp từng dòng",
"游戏适配": "Trò chơi phù hợp"
"游戏适配": "Trò chơi phù hợp",
"指定翻译器": "Chỉ định trình dịch"
}

View File

@ -856,5 +856,6 @@
"还原图标": "",
"拉丁语": "",
"华为云": "",
"逐行匹配": ""
"逐行匹配": "",
"指定翻译器": ""
}

View File

@ -29,7 +29,7 @@ include(generate_product_version)
set(VERSION_MAJOR 5)
set(VERSION_MINOR 35)
set(VERSION_PATCH 9)
set(VERSION_PATCH 10)
add_library(pch pch.cpp)
target_precompile_headers(pch PUBLIC pch.h)