From a35e284312d640c779fb48ad28f72fb84f40b083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Tue, 4 Jun 2024 22:27:25 +0800 Subject: [PATCH] tag --- LunaTranslator/LunaTranslator/gui/showword.py | 18 ++++++++++++------ LunaTranslator/files/defaultconfig/config.json | 3 ++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/showword.py b/LunaTranslator/LunaTranslator/gui/showword.py index b60f87c8..0b2be62e 100644 --- a/LunaTranslator/LunaTranslator/gui/showword.py +++ b/LunaTranslator/LunaTranslator/gui/showword.py @@ -18,6 +18,7 @@ from gui.usefulwidget import ( getboxlayout, getspinbox, getlineedit, + listediterline, getsimpleswitch, getsimplekeyseq, getcolorbutton, @@ -549,8 +550,16 @@ class AnkiWindow(QWidget): ) ) - self.tagsedit = QLineEdit() - layout.addLayout(getboxlayout([QLabel(_TR("Tags(split by |)")), self.tagsedit])) + layout.addLayout( + getboxlayout( + [ + QLabel(_TR("标签")), + listediterline( + _TR("标签"), _TR("标签"), globalconfig["ankiconnect"]["tags"] + ), + ] + ) + ) btn = QPushButton(_TR("添加")) btn.clicked.connect(self.errorwrap) @@ -633,10 +642,7 @@ class AnkiWindow(QWidget): ModelName = globalconfig["ankiconnect"]["ModelName5"] DeckName = globalconfig["ankiconnect"]["DeckName"] model_htmlfront, model_htmlback, model_css = self.tryloadankitemplates() - try: - tags = self.tagsedit.text().split("|") - except: - tags = [] + tags = globalconfig["ankiconnect"]["tags"] anki.Deck.create(DeckName) try: model = anki.Model.create( diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index a8fa0b85..092715e1 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -206,7 +206,8 @@ } }, "autocrop": false, - "boldword": false + "boldword": false, + "tags": [] }, "imageformat": -1, "ankiwindow": [