diff --git a/LunaTranslator/LunaTranslator/gui/setting_cishu.py b/LunaTranslator/LunaTranslator/gui/setting_cishu.py index 0b0dc7c9..9621153c 100644 --- a/LunaTranslator/LunaTranslator/gui/setting_cishu.py +++ b/LunaTranslator/LunaTranslator/gui/setting_cishu.py @@ -100,8 +100,8 @@ def _createseletengeinecombo_1(self): def vistranslate_rank(self): listediter( self, - ("显示顺序"), - ("显示顺序"), + "显示顺序", + "显示顺序", globalconfig["cishuvisrank"], isrankeditor=True, namemapfunction=lambda k: globalconfig["cishu"][k]["name"], diff --git a/LunaTranslator/LunaTranslator/gui/showword.py b/LunaTranslator/LunaTranslator/gui/showword.py index 162c8d91..ba2f5659 100644 --- a/LunaTranslator/LunaTranslator/gui/showword.py +++ b/LunaTranslator/LunaTranslator/gui/showword.py @@ -19,6 +19,7 @@ from gui.usefulwidget import ( getspinbox, getsimplecombobox, getlineedit, + listediter, listediterline, getsimpleswitch, makesubtab_lazy, @@ -329,6 +330,20 @@ class AnkiWindow(QWidget): "例句中加粗单词", getsimpleswitch(globalconfig["ankiconnect"], "boldword"), ) + layout.addRow( + "不添加辞书", + getIconButton(self.vistranslate_rank, "fa.gear"), + ) + + def vistranslate_rank(self): + listediter( + self, + "不添加辞书", + "不添加辞书", + globalconfig["ignoredict"], + candidates=list(globalconfig["cishu"].keys()), + namemapfunction=lambda k: globalconfig["cishu"][k]["name"], + ) def startorendrecord(self, target: QLineEdit, idx): if idx == 1: @@ -706,11 +721,15 @@ class searchwordW(closeashidewindow): self.vboxlayout.addLayout(self.searchlayout) self.searchtext = QLineEdit1() self.searchtext.textChanged.connect(self.ankiwindow.reset) - self.history_last_btn = statusbutton(icons=["fa.arrow-left", "fa.arrow-left"], colors=["", ""]) + self.history_last_btn = statusbutton( + icons=["fa.arrow-left", "fa.arrow-left"], colors=["", ""] + ) self.history_last_btn.clicked.connect( functools.partial(self.__move_history_search, -1) ) - self.history_next_btn = statusbutton(icons=["fa.arrow-right", "fa.arrow-right"], colors=["", ""]) + self.history_next_btn = statusbutton( + icons=["fa.arrow-right", "fa.arrow-right"], colors=["", ""] + ) self.history_next_btn.clicked.connect( functools.partial(self.__move_history_search, 1) ) @@ -783,9 +802,12 @@ class searchwordW(closeashidewindow): res = [] tabks = [] for k, v in self.cache_results.items(): + if k in globalconfig["ignoredict"]: + continue if len(v) == 0: continue thisp = self.thisps.get(k, 0) + idx = 0 for i in tabks: if i >= thisp: diff --git a/LunaTranslator/LunaTranslator/gui/usefulwidget.py b/LunaTranslator/LunaTranslator/gui/usefulwidget.py index 3206e284..208832c6 100644 --- a/LunaTranslator/LunaTranslator/gui/usefulwidget.py +++ b/LunaTranslator/LunaTranslator/gui/usefulwidget.py @@ -97,6 +97,8 @@ class TableViewW(QTableView): def setIndexWidget(self, index: QModelIndex, w: QWidget): super().setIndexWidget(index, w) + if w is None: + return if self.rowHeight(index.row()) < w.height(): self.setRowHeight(index.row(), w.height()) @@ -1668,11 +1670,12 @@ class listediter(LDialog): copy = LAction("复制") up = LAction("上移") down = LAction("下移") - if not self.isrankeditor: + if not (self.isrankeditor): menu.addAction(remove) menu.addAction(copy) - menu.addAction(up) - menu.addAction(down) + if not (self.candidates): + menu.addAction(up) + menu.addAction(down) action = menu.exec(self.hctable.cursor().pos()) if action == remove: @@ -1710,9 +1713,11 @@ class listediter(LDialog): ispathsedit=None, isrankeditor=False, namemapfunction=None, + candidates=None, ) -> None: super().__init__(parent) self.lst = lst + self.candidates = candidates self.closecallback = closecallback self.ispathsedit = ispathsedit self.isrankeditor = isrankeditor @@ -1727,7 +1732,7 @@ class listediter(LDialog): QHeaderView.ResizeMode.ResizeToContents ) table.horizontalHeader().setStretchLastSection(True) - if isrankeditor or (not (ispathsedit is None)): + if isrankeditor or (not (ispathsedit is None)) or self.candidates: table.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers) table.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows) table.setSelectionMode((QAbstractItemView.SelectionMode.SingleSelection)) @@ -1754,6 +1759,10 @@ class listediter(LDialog): self.buttons = threebuttons(texts=["上移", "下移"]) self.buttons.btn1clicked.connect(functools.partial(self.moverank, -1)) self.buttons.btn2clicked.connect(functools.partial(self.moverank, 1)) + elif self.candidates: + self.buttons = threebuttons(texts=["添加行", "删除行"]) + self.buttons.btn1clicked.connect(self.click1) + self.buttons.btn2clicked.connect(self.clicked2) else: self.buttons = threebuttons(texts=["添加行", "删除行", "上移", "下移"]) self.buttons.btn1clicked.connect(self.click1) @@ -1805,9 +1814,27 @@ class listediter(LDialog): self.internalrealname.insert(0, paths) self.hcmodel.insertRow(0, [QStandardItem(path)]) - def click1(self): + def __changed(self, idx): + self.internalrealname[self.hctable.currentIndex().row()] = self.candidates[idx] - if self.ispathsedit is None: + def click1(self): + if self.candidates: + if len(self.internalrealname): + _vis = self.internalrealname[0] + self.hctable.setIndexWidget(self.hcmodel.index(0, 0), None) + if self.namemapfunction: + _vis = self.namemapfunction(_vis) + self.hcmodel.setItem(0, 0, QStandardItem(_vis)) + self.internalrealname.insert(0, self.candidates[0]) + self.hcmodel.insertRow(0, [QStandardItem("")]) + combo = LFocusCombo() + _vis = self.candidates + if self.namemapfunction: + _vis = [self.namemapfunction(_) for _ in _vis] + combo.addItems(_vis) + combo.currentIndexChanged.connect(self.__changed) + self.hctable.setIndexWidget(self.hcmodel.index(0, 0), combo) + elif self.ispathsedit is None: self.internalrealname.insert(0, "") self.hcmodel.insertRow(0, [QStandardItem("")]) else: diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index a722afef..fe95f532 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -332,6 +332,7 @@ "fix_translate_rank": false, "fix_translate_rank_rank": [], "cishuvisrank": [], + "ignoredict": [], "transoptimi": { "noundict": false, "gptpromptdict": false, diff --git a/LunaTranslator/files/lang/ar.json b/LunaTranslator/files/lang/ar.json index 852413ba..0c0181cc 100644 --- a/LunaTranslator/files/lang/ar.json +++ b/LunaTranslator/files/lang/ar.json @@ -842,5 +842,6 @@ "启动方式": "طريقة البدء", "直接启动": "بدء التشغيل مباشرة", "优先使用": "الأولوية في استخدام", - "外部": "خارجي ." + "外部": "خارجي .", + "不添加辞书": "لا إضافة القاموس" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/cht.json b/LunaTranslator/files/lang/cht.json index 08741147..03e0fc88 100644 --- a/LunaTranslator/files/lang/cht.json +++ b/LunaTranslator/files/lang/cht.json @@ -842,5 +842,6 @@ "启动方式": "啟動管道", "直接启动": "直接啟動", "优先使用": "優先使用", - "外部": "外部" + "外部": "外部", + "不添加辞书": "不添加辭書" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/cs.json b/LunaTranslator/files/lang/cs.json index 0174bc05..e936efa9 100644 --- a/LunaTranslator/files/lang/cs.json +++ b/LunaTranslator/files/lang/cs.json @@ -842,5 +842,6 @@ "启动方式": "Metoda spuštění", "直接启动": "Přímo spustit", "优先使用": "priorita použití", - "外部": "externí" + "外部": "externí", + "不添加辞书": "Nepřidávat slovník" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/de.json b/LunaTranslator/files/lang/de.json index b88d9ce6..38b4a2e0 100644 --- a/LunaTranslator/files/lang/de.json +++ b/LunaTranslator/files/lang/de.json @@ -842,5 +842,6 @@ "启动方式": "Startmethode", "直接启动": "Direkt starten", "优先使用": "Priorität der Verwendung", - "外部": "extern" + "外部": "extern", + "不添加辞书": "Kein Wörterbuch hinzufügen" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/en.json b/LunaTranslator/files/lang/en.json index 9268a72d..1d2b3155 100644 --- a/LunaTranslator/files/lang/en.json +++ b/LunaTranslator/files/lang/en.json @@ -842,5 +842,6 @@ "启动方式": "Startup method", "直接启动": "Directly start", "优先使用": "priority of use", - "外部": "external" + "外部": "external", + "不添加辞书": "Do not add a dictionary" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/es.json b/LunaTranslator/files/lang/es.json index 25249808..10c4ab1f 100644 --- a/LunaTranslator/files/lang/es.json +++ b/LunaTranslator/files/lang/es.json @@ -842,5 +842,6 @@ "启动方式": "Modo de arranque", "直接启动": "Arranque directo", "优先使用": "Uso prioritario", - "外部": "Exterior" + "外部": "Exterior", + "不添加辞书": "Sin agregar diccionarios" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/fr.json b/LunaTranslator/files/lang/fr.json index e685280d..4741f8ef 100644 --- a/LunaTranslator/files/lang/fr.json +++ b/LunaTranslator/files/lang/fr.json @@ -842,5 +842,6 @@ "启动方式": "Mode de démarrage", "直接启动": "Démarrage direct", "优先使用": "Utilisation prioritaire", - "外部": "Extérieur" + "外部": "Extérieur", + "不添加辞书": "Pas d'ajout de discours" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/it.json b/LunaTranslator/files/lang/it.json index 54c58f25..d8a5d325 100644 --- a/LunaTranslator/files/lang/it.json +++ b/LunaTranslator/files/lang/it.json @@ -842,5 +842,6 @@ "启动方式": "Metodo di avvio", "直接启动": "Avvia direttamente", "优先使用": "priorità d'uso", - "外部": "esterno" + "外部": "esterno", + "不添加辞书": "Non aggiungere un dizionario" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ja.json b/LunaTranslator/files/lang/ja.json index 06329a53..205f1542 100644 --- a/LunaTranslator/files/lang/ja.json +++ b/LunaTranslator/files/lang/ja.json @@ -842,5 +842,6 @@ "启动方式": "起動モード", "直接启动": "ダイレクトスタート", "优先使用": "優先的に使用", - "外部": "外部" + "外部": "外部", + "不添加辞书": "辞書を追加しない" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ko.json b/LunaTranslator/files/lang/ko.json index 8b24143a..b96f39df 100644 --- a/LunaTranslator/files/lang/ko.json +++ b/LunaTranslator/files/lang/ko.json @@ -842,5 +842,6 @@ "启动方式": "시작 방법", "直接启动": "직접 시작", "优先使用": "우선 사용", - "外部": "외부" + "外部": "외부", + "不添加辞书": "사서 를 넣지 않다" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/nl.json b/LunaTranslator/files/lang/nl.json index 79ee24e4..15619799 100644 --- a/LunaTranslator/files/lang/nl.json +++ b/LunaTranslator/files/lang/nl.json @@ -842,5 +842,6 @@ "启动方式": "Opstartmethode", "直接启动": "Direct starten", "优先使用": "prioriteit van het gebruik", - "外部": "extern" + "外部": "extern", + "不添加辞书": "Geen woordenboek toevoegen" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/pl.json b/LunaTranslator/files/lang/pl.json index 27cda875..1fb6424a 100644 --- a/LunaTranslator/files/lang/pl.json +++ b/LunaTranslator/files/lang/pl.json @@ -842,5 +842,6 @@ "启动方式": "Metoda uruchomienia", "直接启动": "Bezpośredni start", "优先使用": "priorytet stosowania", - "外部": "zewnętrzne" + "外部": "zewnętrzne", + "不添加辞书": "Nie dodawaj słownika" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/pt.json b/LunaTranslator/files/lang/pt.json index 3bb38f73..3373fbac 100644 --- a/LunaTranslator/files/lang/pt.json +++ b/LunaTranslator/files/lang/pt.json @@ -842,5 +842,6 @@ "启动方式": "Método de arranque", "直接启动": "Iniciar directamente", "优先使用": "prioridade de utilização", - "外部": "externo" + "外部": "externo", + "不添加辞书": "Não adicionar um dicionário" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ru.json b/LunaTranslator/files/lang/ru.json index 44c96339..f038a087 100644 --- a/LunaTranslator/files/lang/ru.json +++ b/LunaTranslator/files/lang/ru.json @@ -842,5 +842,6 @@ "启动方式": "Режим запуска", "直接启动": "Прямой запуск", "优先使用": "Приоритетное использование", - "外部": "Внешний" + "外部": "Внешний", + "不添加辞书": "Не добавлять слова" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/sv.json b/LunaTranslator/files/lang/sv.json index 7ad80dcb..96479842 100644 --- a/LunaTranslator/files/lang/sv.json +++ b/LunaTranslator/files/lang/sv.json @@ -842,5 +842,6 @@ "启动方式": "Startmetod", "直接启动": "Starta direkt", "优先使用": "prioritet för användning", - "外部": "extern" + "外部": "extern", + "不添加辞书": "Lägg inte till en ordlista" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/th.json b/LunaTranslator/files/lang/th.json index 5cd09679..927ff1b2 100644 --- a/LunaTranslator/files/lang/th.json +++ b/LunaTranslator/files/lang/th.json @@ -842,5 +842,6 @@ "启动方式": "วิธีการเริ่มต้น", "直接启动": "เริ่มต้นโดยตรง", "优先使用": "ใช้ลำดับความสำคัญ", - "外部": "ภายนอก" + "外部": "ภายนอก", + "不添加辞书": "ไม่เพิ่มสำนวน" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/tr.json b/LunaTranslator/files/lang/tr.json index a61eac3b..4e8f0640 100644 --- a/LunaTranslator/files/lang/tr.json +++ b/LunaTranslator/files/lang/tr.json @@ -842,5 +842,6 @@ "启动方式": "Başlangıç yöntemi", "直接启动": "Direkten başla", "优先使用": "kullanımın önceliği", - "外部": "dış" + "外部": "dış", + "不添加辞书": "Sözlük eklemeyin" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/uk.json b/LunaTranslator/files/lang/uk.json index d0050bba..8211c4f4 100644 --- a/LunaTranslator/files/lang/uk.json +++ b/LunaTranslator/files/lang/uk.json @@ -842,5 +842,6 @@ "启动方式": "Метод запуску", "直接启动": "Прямо запустити", "优先使用": "пріоритет використання", - "外部": "зовнішній" + "外部": "зовнішній", + "不添加辞书": "Не додавати словник" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/vi.json b/LunaTranslator/files/lang/vi.json index 1eaa36df..57b2c104 100644 --- a/LunaTranslator/files/lang/vi.json +++ b/LunaTranslator/files/lang/vi.json @@ -842,5 +842,6 @@ "启动方式": "Cách bắt đầu", "直接启动": "Khởi động trực tiếp", "优先使用": "Ưu tiên sử dụng", - "外部": "Bên ngoài" + "外部": "Bên ngoài", + "不添加辞书": "Không thêm từ điển" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/zh.json b/LunaTranslator/files/lang/zh.json index facb2b36..db3d8766 100644 --- a/LunaTranslator/files/lang/zh.json +++ b/LunaTranslator/files/lang/zh.json @@ -842,5 +842,6 @@ "启动方式": "", "直接启动": "", "优先使用": "", - "外部": "" + "外部": "", + "不添加辞书": "" } \ No newline at end of file