From db4e1fd6aaceb33df76f79aeef36b7f13d95f20b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Wed, 6 Nov 2024 09:01:04 +0800 Subject: [PATCH] smooth --- py/LunaTranslator/gui/setting_display_ui.py | 5 ++- py/LunaTranslator/gui/translatorUI.py | 41 ++++++++++++++++++--- py/LunaTranslator/gui/usefulwidget.py | 2 +- py/LunaTranslator/rendertext/textbrowser.py | 14 +++++-- py/files/defaultconfig/config.json | 1 + py/files/lang/ar.json | 5 ++- py/files/lang/cht.json | 5 ++- py/files/lang/cs.json | 5 ++- py/files/lang/de.json | 5 ++- py/files/lang/en.json | 5 ++- py/files/lang/es.json | 5 ++- py/files/lang/fr.json | 5 ++- py/files/lang/it.json | 5 ++- py/files/lang/ja.json | 5 ++- py/files/lang/ko.json | 5 ++- py/files/lang/nl.json | 5 ++- py/files/lang/pl.json | 5 ++- py/files/lang/pt.json | 5 ++- py/files/lang/ru.json | 5 ++- py/files/lang/sv.json | 5 ++- py/files/lang/th.json | 5 ++- py/files/lang/tr.json | 5 ++- py/files/lang/uk.json | 5 ++- py/files/lang/vi.json | 5 ++- py/files/lang/zh.json | 5 ++- 25 files changed, 111 insertions(+), 52 deletions(-) diff --git a/py/LunaTranslator/gui/setting_display_ui.py b/py/LunaTranslator/gui/setting_display_ui.py index dcd1b2c0..8aa2d728 100644 --- a/py/LunaTranslator/gui/setting_display_ui.py +++ b/py/LunaTranslator/gui/setting_display_ui.py @@ -457,6 +457,9 @@ def mainuisetting(self): "", "自动调整高度", D_getsimpleswitch(globalconfig, "adaptive_height"), + D_getsimplecombobox( + ["向上", "向下"], globalconfig, "top_align" + ), "", "任务栏中显示", D_getsimpleswitch( @@ -477,8 +480,6 @@ def mainuisetting(self): "", "自动隐藏窗口", D_getsimpleswitch(globalconfig, "autodisappear"), - "", - "隐藏延迟(s)", D_getspinbox( 1, 100, diff --git a/py/LunaTranslator/gui/translatorUI.py b/py/LunaTranslator/gui/translatorUI.py index 7ce48822..c3773f1f 100644 --- a/py/LunaTranslator/gui/translatorUI.py +++ b/py/LunaTranslator/gui/translatorUI.py @@ -315,7 +315,8 @@ class TranslatorWindow(resizableframeless): if windows.MonitorFromWindow(hwnd) != windows.MonitorFromWindow(self.winid): lastpos = None return - self.move_signal.emit(tracepos - lastpos.topLeft() + rect.topLeft()) + if globalconfig["top_align"] == 0: + self.move_signal.emit(tracepos - lastpos.topLeft() + rect.topLeft()) def showres(self, kwargs): try: @@ -940,6 +941,10 @@ class TranslatorWindow(resizableframeless): self.smooth_resizer = QVariantAnimation(self) self.smooth_resizer.setDuration(500) self.smooth_resizer.valueChanged.connect(self.smooth_resizing) + self.smooth_resizer2 = QVariantAnimation(self) + self.smooth_resizer2.setDuration(500) + self.smooth_resizer2.valueChanged.connect(self.smooth_resizing2) + self.left_bottom_corner = self.geometry().bottomLeft() self.translate_text = Textbrowser(self) self.translate_text.move(0, 0) self.translate_text.contentsChanged.connect(self.textAreaChanged) @@ -1200,9 +1205,23 @@ class TranslatorWindow(resizableframeless): return 0 + def mouseReleaseEvent(self, e: QMouseEvent): + super().mouseReleaseEvent(e) + self.left_bottom_corner = self.geometry().bottomLeft() + + def mousePressEvent(self, e: QMouseEvent): + super().mousePressEvent(e) + self.smooth_resizer.stop() + self.smooth_resizer2.stop() + self.left_bottom_corner = self.geometry().bottomLeft() + def smooth_resizing(self, value): self.resize(QSize(self.width(), value)) + def smooth_resizing2(self, new_size: QSize): + new_pos = self.left_bottom_corner - QPoint(0, new_size.height()) + self.setGeometry(new_pos.x(), new_pos.y(), new_size.width(), new_size.height()) + def textAreaChanged(self, size: QSize): if self.translate_text.cleared: @@ -1213,12 +1232,24 @@ class TranslatorWindow(resizableframeless): newHeight = limit + self.dynamicextraheight() size = QSize(self.width(), newHeight) self.smooth_resizer.stop() - if newHeight > self.height(): + self.smooth_resizer2.stop() + if self.isdoingsomething(): self.resize(size) + return + if globalconfig["top_align"] == 0: + if newHeight > self.height(): + self.resize(size) + else: + self.smooth_resizer.setStartValue(self.height()) + self.smooth_resizer.setEndValue(newHeight) + self.smooth_resizer.start() else: - self.smooth_resizer.setStartValue(self.height()) - self.smooth_resizer.setEndValue(newHeight) - self.smooth_resizer.start() + if newHeight > self.height(): + self.smooth_resizing2(size) + else: + self.smooth_resizer2.setStartValue(self.size()) + self.smooth_resizer2.setEndValue(size) + self.smooth_resizer2.start() def clickRange(self, auto): if globalconfig["sourcestatus2"]["ocr"]["use"] == False: diff --git a/py/LunaTranslator/gui/usefulwidget.py b/py/LunaTranslator/gui/usefulwidget.py index 7cc02913..ca0e852f 100644 --- a/py/LunaTranslator/gui/usefulwidget.py +++ b/py/LunaTranslator/gui/usefulwidget.py @@ -840,7 +840,7 @@ class resizableframeless(saveposwindow): elif self._move_drag: self.move(gpos - self.move_DragPosition) - def mouseReleaseEvent(self, QMouseEvent): + def mouseReleaseEvent(self, e: QMouseEvent): self.resetflags() diff --git a/py/LunaTranslator/rendertext/textbrowser.py b/py/LunaTranslator/rendertext/textbrowser.py index 02199468..de134789 100644 --- a/py/LunaTranslator/rendertext/textbrowser.py +++ b/py/LunaTranslator/rendertext/textbrowser.py @@ -33,14 +33,20 @@ class Qlabel_c(QLabel): return super().mouseReleaseEvent(event) def enterEvent(self, a0) -> None: - if self.company: - self.company.setStyleSheet("background-color: rgba(0,0,0,0.5);") + try: + if self.company: + self.company.setStyleSheet("background-color: rgba(0,0,0,0.5);") + except: + pass self.setStyleSheet("background-color: rgba(0,0,0,0.5);") return super().enterEvent(a0) def leaveEvent(self, a0) -> None: - if self.company: - self.company.setStyleSheet("background-color: rgba(0,0,0,0.01);") + try: + if self.company: + self.company.setStyleSheet("background-color: rgba(0,0,0,0.01);") + except: + pass self.setStyleSheet("background-color: rgba(0,0,0,0.01);") return super().leaveEvent(a0) diff --git a/py/files/defaultconfig/config.json b/py/files/defaultconfig/config.json index 69e9aa65..084f753f 100644 --- a/py/files/defaultconfig/config.json +++ b/py/files/defaultconfig/config.json @@ -846,6 +846,7 @@ "disappear_delay_tool": 1, "mousetransparent": false, "adaptive_height": true, + "bottom_align": false, "backtransparent": false, "showtranexception": true, "refresh_on_get_trans": false, diff --git a/py/files/lang/ar.json b/py/files/lang/ar.json index cae012ef..d36c1061 100644 --- a/py/files/lang/ar.json +++ b/py/files/lang/ar.json @@ -640,7 +640,6 @@ "文本区": "منطقة النص", "收到翻译时才刷新": "تحديث عند تلقي الترجمة", "自动隐藏窗口": "نافذة مخفية تلقائيا", - "隐藏延迟(s)": "إخفاء تأخير ( ق )", "内容": "المحتويات", "显示内容": "عرض المحتوى", "界面设置": "إعدادات واجهة", @@ -811,5 +810,7 @@ "重命名": "إعادة تسمية", "应用ID": "معرف التطبيق", "应用密钥": "مفتاح التطبيق", - "无": "لا" + "无": "لا", + "向上": "صاعد", + "向下": "نزولا" } \ No newline at end of file diff --git a/py/files/lang/cht.json b/py/files/lang/cht.json index 0baedc55..7f5b1041 100644 --- a/py/files/lang/cht.json +++ b/py/files/lang/cht.json @@ -640,7 +640,6 @@ "文本区": "文字區", "收到翻译时才刷新": "收到翻譯時才重新整理", "自动隐藏窗口": "自動隱藏視窗", - "隐藏延迟(s)": "隱藏延遲(s)", "内容": "內容", "显示内容": "顯示內容", "界面设置": "介面設定", @@ -811,5 +810,7 @@ "重命名": "重命名", "应用ID": "應用ID", "应用密钥": "應用金鑰", - "无": "無" + "无": "無", + "向上": "向上", + "向下": "向下" } \ No newline at end of file diff --git a/py/files/lang/cs.json b/py/files/lang/cs.json index 884661d6..209029ac 100644 --- a/py/files/lang/cs.json +++ b/py/files/lang/cs.json @@ -642,7 +642,6 @@ "自动调整高度": "Automaticky nastavit výšku", "文本区": "Textová oblast", "自动隐藏窗口": "Automaticky skrýt okna", - "隐藏延迟(s)": "Skrytá latence (s)", "内容": "obsah", "显示内容": "zobrazit obsah", "界面设置": "Nastavení rozhraní", @@ -811,5 +810,7 @@ "重命名": "přejmenovat", "应用ID": "ID aplikace", "应用密钥": "Klíč aplikace", - "无": "nic" + "无": "nic", + "向上": "Nahoru", + "向下": "dolů" } \ No newline at end of file diff --git a/py/files/lang/de.json b/py/files/lang/de.json index 0f0f82c7..3cea7313 100644 --- a/py/files/lang/de.json +++ b/py/files/lang/de.json @@ -642,7 +642,6 @@ "自动调整高度": "Höhe automatisch anpassen", "文本区": "Textbereich", "自动隐藏窗口": "Fenster automatisch ausblenden", - "隐藏延迟(s)": "Versteckte Latenz (s)", "内容": "Inhalt", "显示内容": "Inhalt anzeigen", "界面设置": "Schnittstelleneinstellungen", @@ -811,5 +810,7 @@ "重命名": "umbenennen", "应用ID": "Anwendungs-ID", "应用密钥": "Anwendungsschlüssel", - "无": "nichts" + "无": "nichts", + "向上": "Nach oben", + "向下": "nach unten" } \ No newline at end of file diff --git a/py/files/lang/en.json b/py/files/lang/en.json index 09778eaf..ffecb74e 100644 --- a/py/files/lang/en.json +++ b/py/files/lang/en.json @@ -639,7 +639,6 @@ "文本区": "Text Area", "收到翻译时才刷新": "Only Refresh Display on New Translation", "自动隐藏窗口": "Auto Hide Window", - "隐藏延迟(s)": "Hide Delay (s)", "内容": "Content", "显示内容": "Show Content", "界面设置": "Interface Settings", @@ -811,5 +810,7 @@ "重命名": "rename", "应用ID": "Application ID", "应用密钥": "Application key", - "无": "nothing" + "无": "nothing", + "向上": "Up", + "向下": "down" } \ No newline at end of file diff --git a/py/files/lang/es.json b/py/files/lang/es.json index 5bcf13e9..be91576a 100644 --- a/py/files/lang/es.json +++ b/py/files/lang/es.json @@ -640,7 +640,6 @@ "文本区": "Área de texto", "收到翻译时才刷新": "Actualización al recibir la traducción", "自动隐藏窗口": "Ocultar automáticamente la ventana", - "隐藏延迟(s)": "Retraso oculto (s)", "内容": "Contenido", "显示内容": "Mostrar contenido", "界面设置": "Configuración de la interfaz", @@ -811,5 +810,7 @@ "重命名": "Cambiar el nombre", "应用ID": "ID de la aplicación", "应用密钥": "Clave de aplicación", - "无": "Ninguno" + "无": "Ninguno", + "向上": "Arriba", + "向下": "Abajo" } \ No newline at end of file diff --git a/py/files/lang/fr.json b/py/files/lang/fr.json index 2f81e7cc..e5cd3f2a 100644 --- a/py/files/lang/fr.json +++ b/py/files/lang/fr.json @@ -640,7 +640,6 @@ "文本区": "Zone de texte", "收到翻译时才刷新": "Rafraîchissez seulement lorsque vous recevez la traduction", "自动隐藏窗口": "Masquer la fenêtre automatiquement", - "隐藏延迟(s)": "Délai caché (s)", "内容": "Contenu", "显示内容": "Afficher le contenu", "界面设置": "Paramètres de l'interface", @@ -811,5 +810,7 @@ "重命名": "Renommer", "应用ID": "Id de l'application", "应用密钥": "Appliquer la clé", - "无": "Aucun" + "无": "Aucun", + "向上": "Vers le Haut", + "向下": "Vers le bas" } \ No newline at end of file diff --git a/py/files/lang/it.json b/py/files/lang/it.json index ab70802f..4ca04412 100644 --- a/py/files/lang/it.json +++ b/py/files/lang/it.json @@ -640,7 +640,6 @@ "文本区": "Area testo", "收到翻译时才刷新": "Aggiorna solo dopo aver ricevuto la traduzione", "自动隐藏窗口": "Nascondi automaticamente la finestra", - "隐藏延迟(s)": "Ritardo nascosto (s)", "内容": "contenuto", "显示内容": "mostra contenuti", "界面设置": "Impostazioni interfaccia", @@ -811,5 +810,7 @@ "重命名": "rinomina", "应用ID": "ID dell'applicazione", "应用密钥": "Chiave dell'applicazione", - "无": "niente" + "无": "niente", + "向上": "Su", + "向下": "giù" } \ No newline at end of file diff --git a/py/files/lang/ja.json b/py/files/lang/ja.json index f8360d9e..3e8d3af0 100644 --- a/py/files/lang/ja.json +++ b/py/files/lang/ja.json @@ -640,7 +640,6 @@ "文本区": "テキスト領域", "收到翻译时才刷新": "翻訳を受信したときに更新される", "自动隐藏窗口": "ウィンドウを自動的に隠す", - "隐藏延迟(s)": "隠蔽遅延(s)", "内容": "内容", "显示内容": "コンテンツの表示", "界面设置": "インタフェースの設定", @@ -811,5 +810,7 @@ "重命名": "名前を変更", "应用ID": "アプリケーションID", "应用密钥": "キーの適用", - "无": "なし" + "无": "なし", + "向上": "上へ", + "向下": "下へ" } \ No newline at end of file diff --git a/py/files/lang/ko.json b/py/files/lang/ko.json index 41b90473..ac1b4ca0 100644 --- a/py/files/lang/ko.json +++ b/py/files/lang/ko.json @@ -640,7 +640,6 @@ "文本区": "텍스트 영역", "收到翻译时才刷新": "번역을 받았을 때만 새로 고침", "自动隐藏窗口": "자동으로 창 숨기기", - "隐藏延迟(s)": "지연 숨기기 (s)", "内容": "내용", "显示内容": "컨텐트 표시", "界面设置": "인터페이스 설정", @@ -811,5 +810,7 @@ "重命名": "이름 바꾸기", "应用ID": "적용 ID", "应用密钥": "키 적용", - "无": "없음" + "无": "없음", + "向上": "상향", + "向下": "아래로" } \ No newline at end of file diff --git a/py/files/lang/nl.json b/py/files/lang/nl.json index 4dccddd3..080ad0a8 100644 --- a/py/files/lang/nl.json +++ b/py/files/lang/nl.json @@ -642,7 +642,6 @@ "自动调整高度": "Hoogte automatisch aanpassen", "文本区": "Tekstgebied", "自动隐藏窗口": "Vensters automatisch verbergen", - "隐藏延迟(s)": "Verborgen latentie (s)", "内容": "inhoud", "显示内容": "inhoud tonen", "界面设置": "Interfaceinstellingen", @@ -811,5 +810,7 @@ "重命名": "hernoemen", "应用ID": "Applicatie-ID", "应用密钥": "Toepassingssleutel", - "无": "niets" + "无": "niets", + "向上": "Naar boven", + "向下": "omlaag" } \ No newline at end of file diff --git a/py/files/lang/pl.json b/py/files/lang/pl.json index d00ec876..0e0b93f1 100644 --- a/py/files/lang/pl.json +++ b/py/files/lang/pl.json @@ -640,7 +640,6 @@ "文本区": "Obszar tekstowy", "收到翻译时才刷新": "Odśwież tylko po otrzymaniu tłumaczenia", "自动隐藏窗口": "Automatyczne ukrywanie okna", - "隐藏延迟(s)": "Ukryte opóźnienie (s)", "内容": "treść", "显示内容": "pokaż zawartość", "界面设置": "Ustawienia interfejsu", @@ -811,5 +810,7 @@ "重命名": "zmień nazwę", "应用ID": "Identyfikator aplikacji", "应用密钥": "Klucz aplikacji", - "无": "nic" + "无": "nic", + "向上": "W górę", + "向下": "w dół" } \ No newline at end of file diff --git a/py/files/lang/pt.json b/py/files/lang/pt.json index f070326f..a74f0130 100644 --- a/py/files/lang/pt.json +++ b/py/files/lang/pt.json @@ -642,7 +642,6 @@ "自动调整高度": "Ajustar automaticamente a altura", "文本区": "Área de texto", "自动隐藏窗口": "Esconder automaticamente as janelas", - "隐藏延迟(s)": "Latência oculta (s)", "内容": "conteúdo", "显示内容": "mostrar o conteúdo", "界面设置": "Configuração da interface", @@ -811,5 +810,7 @@ "重命名": "renomear", "应用ID": "ID da Aplicação", "应用密钥": "Chave da aplicação", - "无": "nada" + "无": "nada", + "向上": "Subir", + "向下": "para baixo" } \ No newline at end of file diff --git a/py/files/lang/ru.json b/py/files/lang/ru.json index 0410e147..5c373bfc 100644 --- a/py/files/lang/ru.json +++ b/py/files/lang/ru.json @@ -640,7 +640,6 @@ "文本区": "Текстовая область", "收到翻译时才刷新": "Обновить при получении перевода.", "自动隐藏窗口": "Автоматически скрыть окно", - "隐藏延迟(s)": "Скрыть задержку (s)", "内容": "Содержание", "显示内容": "Показать содержимое", "界面设置": "Параметры интерфейса", @@ -811,5 +810,7 @@ "重命名": "Переименовать", "应用ID": "Использовать ID", "应用密钥": "Применить ключ", - "无": "Нет" + "无": "Нет", + "向上": "Вверх", + "向下": "Вниз" } \ No newline at end of file diff --git a/py/files/lang/sv.json b/py/files/lang/sv.json index 8f13bd8b..c0e4ef58 100644 --- a/py/files/lang/sv.json +++ b/py/files/lang/sv.json @@ -642,7 +642,6 @@ "自动调整高度": "Justera höjd automatiskt", "文本区": "Textområde", "自动隐藏窗口": "Dölj fönster automatiskt", - "隐藏延迟(s)": "Dold latens (s)", "内容": "innehåll", "显示内容": "visa innehåll", "界面设置": "Gränssnittsinställningar", @@ -811,5 +810,7 @@ "重命名": "Byt namn", "应用ID": "Program- ID", "应用密钥": "Programnyckel", - "无": "ingenting" + "无": "ingenting", + "向上": "Upp", + "向下": "ner" } \ No newline at end of file diff --git a/py/files/lang/th.json b/py/files/lang/th.json index ebc728bb..077c1a9f 100644 --- a/py/files/lang/th.json +++ b/py/files/lang/th.json @@ -640,7 +640,6 @@ "文本区": "พื้นที่ข้อความ", "收到翻译时才刷新": "รีเฟรชเมื่อได้รับการแปล", "自动隐藏窗口": "ซ่อนหน้าต่างอัตโนมัติ", - "隐藏延迟(s)": "ซ่อนเวลาแฝง (s)", "内容": "เนื้อหา", "显示内容": "แสดงเนื้อหา", "界面设置": "การตั้งค่าอินเทอร์เฟซ", @@ -811,5 +810,7 @@ "重命名": "เปลี่ยนชื่อ", "应用ID": "สมัคร ID", "应用密钥": "ใช้คีย์", - "无": "ไม่มี" + "无": "ไม่มี", + "向上": "ขึ้น", + "向下": "ลง" } \ No newline at end of file diff --git a/py/files/lang/tr.json b/py/files/lang/tr.json index c0c813aa..95c00fec 100644 --- a/py/files/lang/tr.json +++ b/py/files/lang/tr.json @@ -640,7 +640,6 @@ "文本区": "Metin alanı", "收到翻译时才刷新": "Sadece çeviri alırken yenilene", "自动隐藏窗口": "Pencereyi otomatik sakla", - "隐藏延迟(s)": "Gizli gecikme (s)", "内容": "İçeri", "显示内容": "İçeri göster", "界面设置": "Arayüz ayarları", @@ -811,5 +810,7 @@ "重命名": "Yeniden Adlandır", "应用ID": "Uygulama Kimliği", "应用密钥": "Uygulama anahtarı", - "无": "Hiçbir şey yok." + "无": "Hiçbir şey yok.", + "向上": "Yukarı", + "向下": "Aşağı" } \ No newline at end of file diff --git a/py/files/lang/uk.json b/py/files/lang/uk.json index d99fa937..61262f0d 100644 --- a/py/files/lang/uk.json +++ b/py/files/lang/uk.json @@ -640,7 +640,6 @@ "文本区": "Текстова область", "收到翻译时才刷新": "Оновити лише після отримання перекладу", "自动隐藏窗口": "Автоматично сховати вікно", - "隐藏延迟(s)": "Схована затримка (с)", "内容": "вміст", "显示内容": "показувати вміст", "界面设置": "Параметри інтерфейсу", @@ -811,5 +810,7 @@ "重命名": "перейменувати", "应用ID": "ІД програми", "应用密钥": "Ключ програми", - "无": "нічого" + "无": "нічого", + "向上": "Вгору", + "向下": "вниз" } \ No newline at end of file diff --git a/py/files/lang/vi.json b/py/files/lang/vi.json index a5c5eeeb..c179f183 100644 --- a/py/files/lang/vi.json +++ b/py/files/lang/vi.json @@ -640,7 +640,6 @@ "文本区": "Vùng văn bản", "收到翻译时才刷新": "Làm mới khi nhận được bản dịch", "自动隐藏窗口": "Tự động ẩn cửa sổ", - "隐藏延迟(s)": "Độ trễ ẩn (s)", "内容": "Nội dung", "显示内容": "Hiển thị nội dung", "界面设置": "Thiết lập giao diện", @@ -811,5 +810,7 @@ "重命名": "Thay tên", "应用ID": "Ứng dụng ID", "应用密钥": "Khóa ứng dụng", - "无": "Không" + "无": "Không", + "向上": "Lên trên", + "向下": "Xuống" } \ No newline at end of file diff --git a/py/files/lang/zh.json b/py/files/lang/zh.json index 91f07d01..9b307550 100644 --- a/py/files/lang/zh.json +++ b/py/files/lang/zh.json @@ -643,7 +643,6 @@ "自动调整高度": "", "文本区": "", "自动隐藏窗口": "", - "隐藏延迟(s)": "", "内容": "", "显示内容": "", "界面设置": "", @@ -811,5 +810,7 @@ "重命名": "", "应用ID": "", "应用密钥": "", - "无": "" + "无": "", + "向上": "", + "向下": "" } \ No newline at end of file