From ad4f11b37ee363a8e3ab633c0e818fd311daad48 Mon Sep 17 00:00:00 2001 From: xi-yue-233 <1004514855@qq.com> Date: Wed, 25 Oct 2023 12:21:39 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=8A=A8=E4=BD=9C=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E5=BD=93=E5=8F=91=E7=8E=B0ps=E5=86=85=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E9=9C=80=E8=A6=81=E7=9A=84=E5=8A=A8=E4=BD=9C?= =?UTF-8?q?=E6=97=B6=E4=BC=9A=E8=87=AA=E5=8A=A8=E8=BF=9B=E8=A1=8C=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=202=E3=80=81=E4=BF=AE=E5=A4=8D=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E9=94=AE=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98=203=E3=80=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E9=AB=98=E9=A2=91=E5=B1=82=E3=80=81?= =?UTF-8?q?=E4=BD=8E=E9=A2=91=E5=B1=82=E3=80=81=E9=A5=B1=E5=92=8C=E5=BA=A6?= =?UTF-8?q?=E8=A7=82=E5=AF=9F=E5=B1=82=E3=80=81=E5=BD=B1=E8=B0=83=E8=A7=82?= =?UTF-8?q?=E5=AF=9F=E5=B1=82=E7=9A=84=E5=BF=AB=E9=80=9F=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "PSDLink\345\212\250\344\275\234.atn" | Bin 0 -> 4397 bytes button_mehod.py | 29 +++- config.json | 8 +- main.py | 128 ++++++++++++--- main_window.py | 4 + main_window.ui | 6 + playsound.py | 7 + ps_tools.py | 31 +++- set_key.py | 88 ++++++++++ set_key.ui | 224 ++++++++++++++++++++++++++ set_key_window.py | 79 +++++++++ small_tab.py | 2 +- small_tab.ui | 2 +- small_window.py | 4 + small_window.ui | 6 + tab_window.py | 4 +- tab_window.ui | 4 +- tool_bar_method.py | 14 ++ 18 files changed, 602 insertions(+), 38 deletions(-) create mode 100644 "PSDLink\345\212\250\344\275\234.atn" create mode 100644 set_key.py create mode 100644 set_key.ui create mode 100644 set_key_window.py diff --git "a/PSDLink\345\212\250\344\275\234.atn" "b/PSDLink\345\212\250\344\275\234.atn" new file mode 100644 index 0000000000000000000000000000000000000000..8a70643ca54c44ae7abc67bd35ff81b022197f45 GIT binary patch literal 4397 zcmd5=O>7%Q6dreN=ciF97dSGA8#k^!C2OT2!ar&3x>SLp_3p}cJf3xT*9k^IrAizS zk=ou$gpi;TswyFrD$s_sK*18wDpZxC5+O<|ae+$^f>T8c@6GOX*R%xeSi~z?^LE~w zH}7x1H)BG`9zuvh9AXd>0kRK%9u>pM%x3alBtfba3ZFn7C zJ+pl0(@Tp>A2wGnp8FByBcRI{RvgoXndsL)-T2~9cz{;k_~a-@F+zX|JCj{V^EzWz zVTJ-38RJz{jV8g9Y}gdXjBSW@IlG8DNsdyQDa`0Vwn~b(bd^%yh!`0q6Vrd}zbz!C zAH&?7n`D}98uwiJ_Uy{aH)n5r+5G;awQIlO9^i_Uk5;vc2~)94XD+|H*LNm*`1VUz z$zBvCBvqjl1_kN#9Hnlfh6{Y-5+%-%GwM?MU`M5d98*q(;)(+fFPgkw^=LbVo!eYIeff9atoXuu zcJ=wq%+2~CZ=a_@7$_0jDZ`-$xV!I($rss($L@_9Oc|8Q#Hoy9;&!t#H#Iv6&bmGE zon&gd>jlr&M<)E}$sw9a2dP!sN^Pk8hKgF;oL~a1#divA&6r8zcG#?1yRy#_aye*;J~x*A<;1|L zw~iqqz>{Tq0>>_cqBLuZ!^49OL3amhwh3pHXUg30VSG54L03R#PcW0HJFX?Vbb{H5 zJWFCP8)yv%a$r^j6KF@a2c%)1U@yZ_WqL)z@@Ia}YfsZ5HYYT0U(>kFyQC@6=$0mx zbt_J(A{WQW?Z@e0NgSzKayQaZ?$WL;&Wd51I@6@G%6++$nnIAg1E|*>s7=Us& z%ary+h5Kx)YPEBHd^oHj>uR>kEM9~?AA{dRVdfY&d=>>3 z30*9suQmxKPr+p1U^nV!+c)0U$_R|xv7(3_v*(qmcw+@4NXVq)`fcBPC;i9Q@;{^p r( 2: + deleted.append(item.name) + del keyboard._pressed_events[k] + if is_exit: + return 0 + time.sleep(1) + + if __name__ == '__main__': QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling) sys.excepthook = exceptOutConfig app = QApplication(sys.argv) + threading.Thread(target=clear_keys).start() check_is_sound() check_pswindow() # 查看是否透明 diff --git a/main_window.py b/main_window.py index b757e41..836e3c0 100644 --- a/main_window.py +++ b/main_window.py @@ -94,6 +94,8 @@ def setupUi(self, MainWindow): self.actionopcacity_true.setObjectName("actionopcacity_true") self.actionopcacity_false = QtWidgets.QAction(MainWindow) self.actionopcacity_false.setObjectName("actionopcacity_false") + self.actionset_key = QtWidgets.QAction(MainWindow) + self.actionset_key.setObjectName("actionset_key") self.menu.addAction(self.actionsave) self.menu.addAction(self.actionimport) self.menu.addAction(self.actionexit) @@ -112,6 +114,7 @@ def setupUi(self, MainWindow): self.menu_7.addAction(self.actionopcacity_false) self.menu_6.addAction(self.menuyinpin.menuAction()) self.menu_6.addAction(self.menu_7.menuAction()) + self.menu_6.addAction(self.actionset_key) self.menubar.addAction(self.menu.menuAction()) self.menubar.addAction(self.menu_2.menuAction()) self.menubar.addAction(self.menu_3.menuAction()) @@ -169,3 +172,4 @@ def retranslateUi(self, MainWindow): self.actionsetting.setText(_translate("MainWindow", "Autodl账号密码配置")) self.actionopcacity_true.setText(_translate("MainWindow", "不透明")) self.actionopcacity_false.setText(_translate("MainWindow", "半透明")) + self.actionset_key.setText(_translate("MainWindow", "设置快捷键")) diff --git a/main_window.ui b/main_window.ui index b33c131..da05eb1 100644 --- a/main_window.ui +++ b/main_window.ui @@ -182,6 +182,7 @@ li.checked::marker { content: "\2612"; } + @@ -286,6 +287,11 @@ li.checked::marker { content: "\2612"; } 半透明 + + + 设置快捷键 + + diff --git a/playsound.py b/playsound.py index a33f889..ba0e322 100644 --- a/playsound.py +++ b/playsound.py @@ -10,6 +10,13 @@ def check_is_sound(): BASE_PATH = os.path.dirname(os.path.realpath(sys.argv[0])) with open(os.path.join(BASE_PATH, "config.json"), "r") as f: data = json.load(f) + if "isplaysound" not in data: + data["isplaysound"]=True + with open(os.path.join(BASE_PATH, "config.json"), "w") as f: + # 将 python 字典转换为 json 字符串,并指定缩进为 4 个空格 + formatted_data = json.dumps(data, indent=4) + # 将格式化后的 json 字符串写入新的文件 + f.write(formatted_data) isplaysound=data["isplaysound"] def playsound(): diff --git a/ps_tools.py b/ps_tools.py index 49f37d7..0ffe2be 100644 --- a/ps_tools.py +++ b/ps_tools.py @@ -1,9 +1,12 @@ import os import sys +import time +from _ctypes import COMError from datetime import datetime import photoshop.api as ps +import pythoncom from photoshop import Session from PIL import Image @@ -13,6 +16,28 @@ def start_ps(): app = ps.Application() return app +#执行动作 +def execute_action(action_name,group_name): + pythoncom.CoInitialize() # 初始化com环境 + try: + with Session() as ps: + desc69=ps.ActionDescriptor + ref22=ps.ActionReference + idactn=ps.app.charIDToTypeID('Actn') + ref22.putName(idactn,action_name) + ref22.putName(ps.app.charIDToTypeID("ASet"),group_name) + desc69.putReference(ps.app.charIDToTypeID("null"),ref22) + try: + ps.app.executeAction(ps.app.charIDToTypeID("Ply "),desc69,ps.DialogModes.DisplayNoDialogs) + except COMError: + BASE_PATH = os.path.dirname(os.path.realpath(sys.argv[0])) + os.system('chcp 65001') + os.system(f"cd {BASE_PATH} && start PSDLink动作.atn") + print("发现未导入动作,导入动作") + time.sleep(1.5) + ps.app.executeAction(ps.app.charIDToTypeID("Ply "), desc69, ps.DialogModes.DisplayNoDialogs) + finally: + pythoncom.CoInitialize() # 初始化com环境 # 自动匹配ps文档和tabs文档名 def auto_doc_name(application,small_application=None): @@ -50,7 +75,7 @@ def export_image_from_ps(app, document_name): os.mkdir(EXPORT_PATH) # 循环查找指定的文档名 for document in documents: - if document_name in document.name: + if document_name == document.name[0:len(document_name)]: document.saveAs(os.path.join(EXPORT_PATH, document_name + f"-{now_long}.jpg"), options) return os.path.join(EXPORT_PATH, document_name + f"-{now_long}.jpg"), document_name + f"-{now_long}" # 如果没找到指定文档,则默认以当前文档导出 @@ -84,7 +109,7 @@ def import_image_from_sd(app, img_name, count): document_name = img_name.split("-")[0] # 循环查找指定的文档名 for document in documents: - if document_name in document.name: + if document_name == document.name[0:len(document_name)]: # 获取文档的宽度和高度 doc_width = document.width doc_height = document.height @@ -165,7 +190,7 @@ def export_controlnet_image_from_ps(app, document_name): os.mkdir(EXPORT_PATH) # 循环查找指定的文档名 for document in documents: - if document_name in document.name: + if document_name == document.name[0:len(document_name)]: document.saveAs(os.path.join(EXPORT_PATH, document_name + f"-{now_long}" + "-controlnet.jpg"), options) return os.path.join(EXPORT_PATH, document_name + f"-{now_long}" + "-controlnet.jpg") # 如果没找到指定文档,则默认以当前文档导出 diff --git a/set_key.py b/set_key.py new file mode 100644 index 0000000..cea2e3a --- /dev/null +++ b/set_key.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'set_key.ui' +# +# Created by: PyQt5 UI code generator 5.15.9 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(376, 237) + self.label_20 = QtWidgets.QLabel(Form) + self.label_20.setGeometry(QtCore.QRect(6, 10, 171, 16)) + self.label_20.setObjectName("label_20") + self.gaopin = QtWidgets.QLineEdit(Form) + self.gaopin.setGeometry(QtCore.QRect(190, 10, 141, 21)) + self.gaopin.setText("") + self.gaopin.setPlaceholderText("") + self.gaopin.setObjectName("gaopin") + self.label_21 = QtWidgets.QLabel(Form) + self.label_21.setGeometry(QtCore.QRect(6, 40, 171, 16)) + self.label_21.setObjectName("label_21") + self.dipin = QtWidgets.QLineEdit(Form) + self.dipin.setGeometry(QtCore.QRect(190, 40, 141, 21)) + self.dipin.setText("") + self.dipin.setPlaceholderText("") + self.dipin.setObjectName("dipin") + self.label_22 = QtWidgets.QLabel(Form) + self.label_22.setGeometry(QtCore.QRect(6, 70, 171, 16)) + self.label_22.setObjectName("label_22") + self.lama_export = QtWidgets.QLineEdit(Form) + self.lama_export.setGeometry(QtCore.QRect(190, 70, 141, 21)) + self.lama_export.setText("") + self.lama_export.setPlaceholderText("") + self.lama_export.setObjectName("lama_export") + self.lama_import = QtWidgets.QLineEdit(Form) + self.lama_import.setGeometry(QtCore.QRect(190, 100, 141, 21)) + self.lama_import.setText("") + self.lama_import.setPlaceholderText("") + self.lama_import.setObjectName("lama_import") + self.label_23 = QtWidgets.QLabel(Form) + self.label_23.setGeometry(QtCore.QRect(6, 100, 171, 16)) + self.label_23.setObjectName("label_23") + self.label_24 = QtWidgets.QLabel(Form) + self.label_24.setGeometry(QtCore.QRect(6, 130, 171, 16)) + self.label_24.setObjectName("label_24") + self.yingdiao = QtWidgets.QLineEdit(Form) + self.yingdiao.setGeometry(QtCore.QRect(190, 130, 141, 21)) + self.yingdiao.setText("") + self.yingdiao.setPlaceholderText("") + self.yingdiao.setObjectName("yingdiao") + self.label_25 = QtWidgets.QLabel(Form) + self.label_25.setGeometry(QtCore.QRect(6, 160, 171, 16)) + self.label_25.setObjectName("label_25") + self.baohe = QtWidgets.QLineEdit(Form) + self.baohe.setGeometry(QtCore.QRect(190, 160, 141, 21)) + self.baohe.setText("") + self.baohe.setPlaceholderText("") + self.baohe.setObjectName("baohe") + self.check_btn = QtWidgets.QPushButton(Form) + self.check_btn.setGeometry(QtCore.QRect(140, 200, 91, 23)) + self.check_btn.setObjectName("check_btn") + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.label_20.setText(_translate("Form", "

创建高频层快捷键

")) + self.gaopin.setToolTip(_translate("Form", "不需要多任务流水线的话,自动对ps当前的文档进行执行,可以不用填写。如需一图多修,可将其他任务的文档名改成与这个图片一致的文档名。")) + self.label_21.setText(_translate("Form", "

创建低频层快捷键

")) + self.dipin.setToolTip(_translate("Form", "不需要多任务流水线的话,自动对ps当前的文档进行执行,可以不用填写。如需一图多修,可将其他任务的文档名改成与这个图片一致的文档名。")) + self.label_22.setText(_translate("Form", "

Lama导入快捷键

")) + self.lama_export.setToolTip(_translate("Form", "不需要多任务流水线的话,自动对ps当前的文档进行执行,可以不用填写。如需一图多修,可将其他任务的文档名改成与这个图片一致的文档名。")) + self.lama_import.setToolTip(_translate("Form", "不需要多任务流水线的话,自动对ps当前的文档进行执行,可以不用填写。如需一图多修,可将其他任务的文档名改成与这个图片一致的文档名。")) + self.label_23.setText(_translate("Form", "

Lama传回快捷键

")) + self.label_24.setText(_translate("Form", "

影调观察层快捷键

")) + self.yingdiao.setToolTip(_translate("Form", "不需要多任务流水线的话,自动对ps当前的文档进行执行,可以不用填写。如需一图多修,可将其他任务的文档名改成与这个图片一致的文档名。")) + self.label_25.setText(_translate("Form", "

饱和观察层快捷键

")) + self.baohe.setToolTip(_translate("Form", "不需要多任务流水线的话,自动对ps当前的文档进行执行,可以不用填写。如需一图多修,可将其他任务的文档名改成与这个图片一致的文档名。")) + self.check_btn.setText(_translate("Form", "确认")) diff --git a/set_key.ui b/set_key.ui new file mode 100644 index 0000000..34cdcff --- /dev/null +++ b/set_key.ui @@ -0,0 +1,224 @@ + + + Form + + + + 0 + 0 + 376 + 237 + + + + Form + + + + + 6 + 10 + 171 + 16 + + + + <html><head/><body><p align="center">创建高频层快捷键</p></body></html> + + + + + + 190 + 10 + 141 + 21 + + + + 不需要多任务流水线的话,自动对ps当前的文档进行执行,可以不用填写。如需一图多修,可将其他任务的文档名改成与这个图片一致的文档名。 + + + + + + + + + + + + 6 + 40 + 171 + 16 + + + + <html><head/><body><p align="center">创建低频层快捷键</p></body></html> + + + + + + 190 + 40 + 141 + 21 + + + + 不需要多任务流水线的话,自动对ps当前的文档进行执行,可以不用填写。如需一图多修,可将其他任务的文档名改成与这个图片一致的文档名。 + + + + + + + + + + + + 6 + 70 + 171 + 16 + + + + <html><head/><body><p align="center">Lama导入快捷键</p></body></html> + + + + + + 190 + 70 + 141 + 21 + + + + 不需要多任务流水线的话,自动对ps当前的文档进行执行,可以不用填写。如需一图多修,可将其他任务的文档名改成与这个图片一致的文档名。 + + + + + + + + + + + + 190 + 100 + 141 + 21 + + + + 不需要多任务流水线的话,自动对ps当前的文档进行执行,可以不用填写。如需一图多修,可将其他任务的文档名改成与这个图片一致的文档名。 + + + + + + + + + + + + 6 + 100 + 171 + 16 + + + + <html><head/><body><p align="center">Lama传回快捷键</p></body></html> + + + + + + 6 + 130 + 171 + 16 + + + + <html><head/><body><p align="center">影调观察层快捷键</p></body></html> + + + + + + 190 + 130 + 141 + 21 + + + + 不需要多任务流水线的话,自动对ps当前的文档进行执行,可以不用填写。如需一图多修,可将其他任务的文档名改成与这个图片一致的文档名。 + + + + + + + + + + + + 6 + 160 + 171 + 16 + + + + <html><head/><body><p align="center">饱和观察层快捷键</p></body></html> + + + + + + 190 + 160 + 141 + 21 + + + + 不需要多任务流水线的话,自动对ps当前的文档进行执行,可以不用填写。如需一图多修,可将其他任务的文档名改成与这个图片一致的文档名。 + + + + + + + + + + + + 140 + 200 + 91 + 23 + + + + 确认 + + + + + + diff --git a/set_key_window.py b/set_key_window.py new file mode 100644 index 0000000..b76013b --- /dev/null +++ b/set_key_window.py @@ -0,0 +1,79 @@ +import json +import os +import sys + +from PyQt5 import QtWidgets +from PyQt5.QtWidgets import QMessageBox + +import set_key + + +def open_key_preset(QMainWindow): + QMainWindow.key_w = QtWidgets.QWidget() + QMainWindow.ui_key_w = set_key.Ui_Form() + QMainWindow.ui_key_w.setupUi(QMainWindow.key_w) + QMainWindow.key_w.setWindowTitle("快捷键设置") + QMainWindow.key_w.setWindowFlags(QMainWindow.windowFlags()) + + BASE_PATH = os.path.dirname(os.path.realpath(sys.argv[0])) + with open(os.path.join(BASE_PATH, "config.json"), "r") as f: + data = json.load(f) + if "gaopin_key" not in data: + data["gaopin_key"]="shift+f4" + if "dipin_key" not in data: + data["dipin_key"]="shift+f3" + if "lama_export" not in data: + data["lama_export"] = "ctrl+shift+f3" + if "lama_import" not in data: + data["lama_import"] = "ctrl+shift+f4" + if "yingdiao" not in data: + data["yingdiao"] = "ctrl+shift+d" + if "baohe" not in data: + data["baohe"] = "ctrl+shift+f" + with open(os.path.join(BASE_PATH, "config.json"), "w") as f: + # 将 python 字典转换为 json 字符串,并指定缩进为 4 个空格 + formatted_data = json.dumps(data, indent=4) + # 将格式化后的 json 字符串写入新的文件 + f.write(formatted_data) + + QMainWindow.ui_key_w.gaopin.setText(data["gaopin_key"]) + QMainWindow.ui_key_w.dipin.setText(data["dipin_key"]) + QMainWindow.ui_key_w.lama_export.setText(data["lama_export"]) + QMainWindow.ui_key_w.lama_import.setText(data["lama_import"]) + QMainWindow.ui_key_w.yingdiao.setText(data["yingdiao"]) + QMainWindow.ui_key_w.baohe.setText(data["baohe"]) + + def show_message_box(text): + message_box = QMessageBox(QMainWindow) + message_box.setIcon(QMessageBox.Information) + message_box.setText(text) + message_box.setWindowTitle("提示") + message_box.setStandardButtons(QMessageBox.Ok) + message_box.exec_() + + def check_btn(): + try: + data["gaopin_key"]=QMainWindow.ui_key_w.gaopin.text() + data["dipin_key"]=QMainWindow.ui_key_w.dipin.text() + data["lama_export"]=QMainWindow.ui_key_w.lama_export.text() + data["lama_import"]=QMainWindow.ui_key_w.lama_import.text() + data["yingdiao"]=QMainWindow.ui_key_w.yingdiao.text() + data["baohe"]=QMainWindow.ui_key_w.baohe.text() + + with open(os.path.join(BASE_PATH, "config.json"), "w") as f: + # 将 python 字典转换为 json 字符串,并指定缩进为 4 个空格 + formatted_data = json.dumps(data, indent=4) + # 将格式化后的 json 字符串写入新的文件 + f.write(formatted_data) + + show_message_box("修改完成") + QMainWindow.block_all_short_key() + QMainWindow.key_w.destroy() + except Exception as e: + show_message_box("修改失败") + + QMainWindow.ui_key_w.check_btn.clicked.connect( + lambda: check_btn()) + + + QMainWindow.key_w.show() \ No newline at end of file diff --git a/small_tab.py b/small_tab.py index 389b41d..0cd4fac 100644 --- a/small_tab.py +++ b/small_tab.py @@ -180,7 +180,7 @@ def retranslateUi(self, Form): self.lama_import.setToolTip(_translate("Form", "快捷键ctrl+shift+F4")) self.lama_import.setText(_translate("Form", "Lama导回")) self.import_sd_btn.setToolTip(_translate("Form", "按照任务设定从ps当前的文档导出图片进入sd执行")) - self.import_sd_btn.setText(_translate("Form", "导入SD")) + self.import_sd_btn.setText(_translate("Form", "执行全流程")) self.start_cal_btn.setToolTip(_translate("Form", "直接触发sd的开始按钮并在完成后导回sd")) self.start_cal_btn.setText(_translate("Form", "开始运算")) self.hd_btn.setToolTip(_translate("Form", "用当前的设定对网页上生成好的图片进行sd放大")) diff --git a/small_tab.ui b/small_tab.ui index b2c6fbf..964071d 100644 --- a/small_tab.ui +++ b/small_tab.ui @@ -473,7 +473,7 @@ 按照任务设定从ps当前的文档导出图片进入sd执行 - 导入SD + 执行全流程 diff --git a/small_window.py b/small_window.py index e2d0011..22c8e28 100644 --- a/small_window.py +++ b/small_window.py @@ -89,6 +89,8 @@ def setupUi(self, MainWindow): self.actionopcacity_true.setObjectName("actionopcacity_true") self.actionopcacity_false = QtWidgets.QAction(MainWindow) self.actionopcacity_false.setObjectName("actionopcacity_false") + self.actionset_key = QtWidgets.QAction(MainWindow) + self.actionset_key.setObjectName("actionset_key") self.menu.addAction(self.actionsave) self.menu.addAction(self.actionimport) self.menu.addAction(self.actionexit) @@ -105,6 +107,7 @@ def setupUi(self, MainWindow): self.menu_7.addAction(self.actionopcacity_false) self.menu_5.addAction(self.menub.menuAction()) self.menu_5.addAction(self.menu_7.menuAction()) + self.menu_5.addAction(self.actionset_key) self.menu_6.addAction(self.actionabout) self.menu_6.addAction(self.actionhelp) self.menubar.addAction(self.menu.menuAction()) @@ -161,3 +164,4 @@ def retranslateUi(self, MainWindow): self.actionhelp.setText(_translate("MainWindow", "帮助")) self.actionopcacity_true.setText(_translate("MainWindow", "不透明")) self.actionopcacity_false.setText(_translate("MainWindow", "半透明")) + self.actionset_key.setText(_translate("MainWindow", "设置快捷键")) diff --git a/small_window.ui b/small_window.ui index 6d5ce97..a07cd63 100644 --- a/small_window.ui +++ b/small_window.ui @@ -163,6 +163,7 @@ li.checked::marker { content: "\2612"; } + @@ -263,6 +264,11 @@ li.checked::marker { content: "\2612"; } 半透明 + + + 设置快捷键 + + diff --git a/tab_window.py b/tab_window.py index 0950eb6..4a98c8c 100644 --- a/tab_window.py +++ b/tab_window.py @@ -14,7 +14,7 @@ class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") - Form.resize(491, 524) + Form.resize(491, 528) self.layer_name = QtWidgets.QLineEdit(Form) self.layer_name.setGeometry(QtCore.QRect(190, 35, 141, 21)) self.layer_name.setPlaceholderText("") @@ -296,7 +296,7 @@ def retranslateUi(self, Form): self.only_import_start.setToolTip(_translate("Form", "不改变提示词,导入并生成")) self.only_import_start.setText(_translate("Form", "仅导入并开始")) self.import_sd_btn.setToolTip(_translate("Form", "按照任务设定从ps当前的文档导出图片进入sd执行")) - self.import_sd_btn.setText(_translate("Form", "导入SD")) + self.import_sd_btn.setText(_translate("Form", "执行全流程")) self.start_cal_btn.setToolTip(_translate("Form", "直接触发sd的开始按钮并在完成后导回sd")) self.start_cal_btn.setText(_translate("Form", "开始运算")) self.hd_btn.setToolTip(_translate("Form", "用当前的设定对网页上生成好的图片进行sd放大")) diff --git a/tab_window.ui b/tab_window.ui index dafa2a3..96b494a 100644 --- a/tab_window.ui +++ b/tab_window.ui @@ -7,7 +7,7 @@ 0 0 491 - 524 + 528 @@ -352,7 +352,7 @@ 按照任务设定从ps当前的文档导出图片进入sd执行 - 导入SD + 执行全流程 diff --git a/tool_bar_method.py b/tool_bar_method.py index 41bfc71..3171ac1 100644 --- a/tool_bar_method.py +++ b/tool_bar_method.py @@ -20,6 +20,13 @@ def check_is_night(): BASE_PATH = os.path.dirname(os.path.realpath(sys.argv[0])) with open(os.path.join(BASE_PATH, "config.json"), "r") as f: data = json.load(f) + if "isnight" not in data: + data["isnight"]=False + with open(os.path.join(BASE_PATH, "config.json"), "w") as f: + # 将 python 字典转换为 json 字符串,并指定缩进为 4 个空格 + formatted_data = json.dumps(data, indent=4) + # 将格式化后的 json 字符串写入新的文件 + f.write(formatted_data) isnight=data["isnight"] def night_theme(): @@ -62,6 +69,13 @@ def check_opacity(): BASE_PATH = os.path.dirname(os.path.realpath(sys.argv[0])) with open(os.path.join(BASE_PATH, "config.json"), "r") as f: data = json.load(f) + if "isopacity" not in data: + data["isopacity"]=True + with open(os.path.join(BASE_PATH, "config.json"), "w") as f: + # 将 python 字典转换为 json 字符串,并指定缩进为 4 个空格 + formatted_data = json.dumps(data, indent=4) + # 将格式化后的 json 字符串写入新的文件 + f.write(formatted_data) isopacity=data["isopacity"] def set_opacity(windows):