From 7a893fbe9f68130d68305f6e79eccf5e3baa8a5d 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: Fri, 21 Jun 2024 20:23:58 +0800 Subject: [PATCH] color --- .../LunaTranslator/gui/setting_display_ui.py | 14 +++++++++++++- LunaTranslator/LunaTranslator/gui/translatorUI.py | 12 ++---------- LunaTranslator/files/defaultconfig/config.json | 3 ++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/setting_display_ui.py b/LunaTranslator/LunaTranslator/gui/setting_display_ui.py index ecee9ba1..a73c485f 100644 --- a/LunaTranslator/LunaTranslator/gui/setting_display_ui.py +++ b/LunaTranslator/LunaTranslator/gui/setting_display_ui.py @@ -318,7 +318,19 @@ def uisetting(self): name="buttoncolorbutton", parent=self, ), - "", + D_getcolorbutton( + globalconfig, + "buttoncolor_1", + callback=lambda: selectcolor( + self, + globalconfig, + "buttoncolor_1", + self.buttoncolorbutton_1, + callback=lambda: gobject.baseobject.translation_ui.refreshtooliconsignal.emit(), + ), + name="buttoncolorbutton_1", + parent=self, + ), "", ("工具按钮大小", 4), ( diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index afc126e3..1c357abe 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -16,14 +16,6 @@ from gui.edittext import edittrans from gui.dialog_savedgame import browserdialog, dialog_savedgame_integrated -def contrastcolor(color): - color = QColor(globalconfig["buttoncolor"]) - r, g, b, a = color.getRgb() - - r, g, b = [hex((_ + 128) % 256)[2:] for _ in (r, g, b)] - return f"#{r}{g}{b}" - - class QUnFrameWindow(resizableframeless): displayglobaltooltip = pyqtSignal(str) displayres = pyqtSignal(dict) @@ -261,7 +253,7 @@ class QUnFrameWindow(resizableframeless): for name in self.buttons: if name in colorstate: color = ( - contrastcolor(globalconfig["buttoncolor"]) + globalconfig["buttoncolor_1"] if colorstate[name] else globalconfig["buttoncolor"] ) @@ -579,7 +571,7 @@ class QUnFrameWindow(resizableframeless): None, flags=Qt.WindowType.FramelessWindowHint | Qt.WindowType.WindowMinimizeButtonHint, - poslist=globalconfig["transuigeo"] + poslist=globalconfig["transuigeo"], ) # 设置为顶级窗口,无边框 icon = getExeIcon(sys.argv[0]) #'./LunaTranslator.exe')# QIcon() # icon.addPixmap(QPixmap('./files/luna.png'), QIcon.Normal, QIcon.On) diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index 698f845e..79c43dc9 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -475,9 +475,10 @@ "accept_use_unicode_start": 0, "accept_use_unicode_end": 65535, "premtsimiuse": false, - "buttoncolor": "#001f9f", + "buttoncolor": "#FF69B4", "buttoncolor2": "#FF69B4", "buttoncolor3": "#afafaf", + "buttoncolor_1": "#afafaf", "premtsimi2": 100, "ocrrangecolor": "#000000", "ocrrangewidth": 2,