diff --git a/UI_main.py b/UI_main.py index a2679831..9b652238 100644 --- a/UI_main.py +++ b/UI_main.py @@ -86,7 +86,7 @@ def setupUi(self, MainWindow): self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents = QtWidgets.QWidget() - self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -64, 991, 10925)) + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -8360, 991, 11145)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout.setContentsMargins(35, 20, 35, 20) @@ -1415,6 +1415,34 @@ def setupUi(self, MainWindow): self.gridLayout_61.setColumnStretch(0, 9) self.gridLayout_61.setColumnStretch(1, 1) self.verticalLayout.addWidget(self.groupBox_schedule) + self.groupBox_idle_time_task = QtWidgets.QGroupBox(self.scrollAreaWidgetContents) + self.groupBox_idle_time_task.setObjectName("groupBox_idle_time_task") + self.gridLayout_87 = QtWidgets.QGridLayout(self.groupBox_idle_time_task) + self.gridLayout_87.setObjectName("gridLayout_87") + spacerItem30 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_87.addItem(spacerItem30, 0, 1, 1, 1) + self.gridLayout_idle_time_task = QtWidgets.QGridLayout() + self.gridLayout_idle_time_task.setObjectName("gridLayout_idle_time_task") + self.gridLayout_87.addLayout(self.gridLayout_idle_time_task, 0, 0, 1, 1) + self.groupBox_idle_time_task_comment = QtWidgets.QGroupBox(self.groupBox_idle_time_task) + self.groupBox_idle_time_task_comment.setObjectName("groupBox_idle_time_task_comment") + self.gridLayout_94 = QtWidgets.QGridLayout(self.groupBox_idle_time_task_comment) + self.gridLayout_94.setObjectName("gridLayout_94") + self.gridLayout_idle_time_task_comment = QtWidgets.QGridLayout() + self.gridLayout_idle_time_task_comment.setObjectName("gridLayout_idle_time_task_comment") + self.gridLayout_94.addLayout(self.gridLayout_idle_time_task_comment, 0, 0, 1, 1) + self.gridLayout_87.addWidget(self.groupBox_idle_time_task_comment, 1, 0, 1, 1) + self.groupBox_idle_time_task_local_audio = QtWidgets.QGroupBox(self.groupBox_idle_time_task) + self.groupBox_idle_time_task_local_audio.setObjectName("groupBox_idle_time_task_local_audio") + self.gridLayout_96 = QtWidgets.QGridLayout(self.groupBox_idle_time_task_local_audio) + self.gridLayout_96.setObjectName("gridLayout_96") + self.gridLayout_idle_time_task_local_audio = QtWidgets.QGridLayout() + self.gridLayout_idle_time_task_local_audio.setObjectName("gridLayout_idle_time_task_local_audio") + self.gridLayout_96.addLayout(self.gridLayout_idle_time_task_local_audio, 0, 0, 1, 1) + self.gridLayout_87.addWidget(self.groupBox_idle_time_task_local_audio, 2, 0, 1, 1) + self.gridLayout_87.setColumnStretch(0, 9) + self.gridLayout_87.setColumnStretch(1, 1) + self.verticalLayout.addWidget(self.groupBox_idle_time_task) self.groupBox_ddsp_svc = QtWidgets.QGroupBox(self.scrollAreaWidgetContents) self.groupBox_ddsp_svc.setObjectName("groupBox_ddsp_svc") self.gridLayout_49 = QtWidgets.QGridLayout(self.groupBox_ddsp_svc) @@ -1464,8 +1492,8 @@ def setupUi(self, MainWindow): self.lineEdit_ddsp_svc_sampleRate.setObjectName("lineEdit_ddsp_svc_sampleRate") self.gridLayout_48.addWidget(self.lineEdit_ddsp_svc_sampleRate, 6, 1, 1, 1) self.gridLayout_49.addLayout(self.gridLayout_48, 0, 0, 1, 1) - spacerItem30 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.gridLayout_49.addItem(spacerItem30, 0, 1, 1, 1) + spacerItem31 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_49.addItem(spacerItem31, 0, 1, 1, 1) self.gridLayout_49.setColumnStretch(0, 9) self.gridLayout_49.setColumnStretch(1, 1) self.verticalLayout.addWidget(self.groupBox_ddsp_svc) @@ -1512,8 +1540,8 @@ def setupUi(self, MainWindow): self.lineEdit_so_vits_svc_wav_format.setObjectName("lineEdit_so_vits_svc_wav_format") self.gridLayout_35.addWidget(self.lineEdit_so_vits_svc_wav_format, 5, 1, 1, 1) self.gridLayout_36.addLayout(self.gridLayout_35, 0, 0, 1, 1) - spacerItem31 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.gridLayout_36.addItem(spacerItem31, 0, 1, 1, 1) + spacerItem32 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_36.addItem(spacerItem32, 0, 1, 1, 1) self.gridLayout_36.setColumnStretch(0, 9) self.gridLayout_36.setColumnStretch(1, 1) self.verticalLayout.addWidget(self.groupBox_so_vits_svc) @@ -1632,8 +1660,8 @@ def setupUi(self, MainWindow): self.lineEdit_prompt_llm_after_prompt.setObjectName("lineEdit_prompt_llm_after_prompt") self.gridLayout_31.addWidget(self.lineEdit_prompt_llm_after_prompt, 3, 1, 1, 1) self.gridLayout_32.addLayout(self.gridLayout_31, 0, 0, 1, 1) - spacerItem32 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.gridLayout_32.addItem(spacerItem32, 0, 1, 1, 1) + spacerItem33 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_32.addItem(spacerItem33, 0, 1, 1, 1) self.gridLayout_32.setColumnStretch(0, 9) self.gridLayout_32.setColumnStretch(1, 1) self.verticalLayout.addWidget(self.groupBox_sd) @@ -1665,8 +1693,8 @@ def setupUi(self, MainWindow): self.checkBox_trends_copywriting_enable.setObjectName("checkBox_trends_copywriting_enable") self.gridLayout_trends_copywriting.addWidget(self.checkBox_trends_copywriting_enable, 1, 1, 1, 1) self.gridLayout_66.addLayout(self.gridLayout_trends_copywriting, 0, 0, 1, 1) - spacerItem33 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.gridLayout_66.addItem(spacerItem33, 0, 1, 1, 1) + spacerItem34 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_66.addItem(spacerItem34, 0, 1, 1, 1) self.gridLayout_66.setColumnStretch(0, 9) self.gridLayout_66.setColumnStretch(1, 1) self.verticalLayout.addWidget(self.groupBox_trends_copywriting) @@ -1683,8 +1711,8 @@ def setupUi(self, MainWindow): self.lineEdit_header_useragent.setObjectName("lineEdit_header_useragent") self.gridLayout_19.addWidget(self.lineEdit_header_useragent, 0, 1, 1, 1) self.gridLayout_18.addLayout(self.gridLayout_19, 0, 1, 1, 1) - spacerItem34 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.gridLayout_18.addItem(spacerItem34, 0, 2, 1, 1) + spacerItem35 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_18.addItem(spacerItem35, 0, 2, 1, 1) self.gridLayout_18.setColumnStretch(1, 9) self.gridLayout_18.setColumnStretch(2, 1) self.verticalLayout.addWidget(self.groupBox_header) @@ -1695,8 +1723,8 @@ def setupUi(self, MainWindow): self.gridLayout_web_captions_printer = QtWidgets.QGridLayout() self.gridLayout_web_captions_printer.setObjectName("gridLayout_web_captions_printer") self.gridLayout_69.addLayout(self.gridLayout_web_captions_printer, 0, 0, 1, 1) - spacerItem35 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.gridLayout_69.addItem(spacerItem35, 0, 1, 1, 1) + spacerItem36 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_69.addItem(spacerItem36, 0, 1, 1, 1) self.gridLayout_69.setColumnStretch(0, 9) self.gridLayout_69.setColumnStretch(1, 1) self.verticalLayout.addWidget(self.groupBox_web_captions_printer) @@ -1707,8 +1735,8 @@ def setupUi(self, MainWindow): self.gridLayout_database = QtWidgets.QGridLayout() self.gridLayout_database.setObjectName("gridLayout_database") self.gridLayout_67.addLayout(self.gridLayout_database, 0, 0, 1, 1) - spacerItem36 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.gridLayout_67.addItem(spacerItem36, 0, 1, 1, 1) + spacerItem37 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_67.addItem(spacerItem37, 0, 1, 1, 1) self.gridLayout_67.setColumnStretch(0, 9) self.gridLayout_67.setColumnStretch(1, 1) self.verticalLayout.addWidget(self.groupBox_database) @@ -1716,8 +1744,8 @@ def setupUi(self, MainWindow): self.groupBox_key_mapping.setObjectName("groupBox_key_mapping") self.gridLayout_90 = QtWidgets.QGridLayout(self.groupBox_key_mapping) self.gridLayout_90.setObjectName("gridLayout_90") - spacerItem37 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.gridLayout_90.addItem(spacerItem37, 0, 1, 1, 1) + spacerItem38 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_90.addItem(spacerItem38, 0, 1, 1, 1) self.gridLayout_key_mapping = QtWidgets.QGridLayout() self.gridLayout_key_mapping.setObjectName("gridLayout_key_mapping") self.checkBox_key_mapping_enable = QtWidgets.QCheckBox(self.groupBox_key_mapping) @@ -1778,8 +1806,8 @@ def setupUi(self, MainWindow): self.widget.setObjectName("widget") self.gridLayout_37 = QtWidgets.QGridLayout(self.widget) self.gridLayout_37.setObjectName("gridLayout_37") - spacerItem38 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.gridLayout_37.addItem(spacerItem38, 6, 0, 1, 1) + spacerItem39 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_37.addItem(spacerItem39, 6, 0, 1, 1) self.textEdit_copywriting_edit = QtWidgets.QTextEdit(self.widget) self.textEdit_copywriting_edit.setStyleSheet("min-height:300px;") self.textEdit_copywriting_edit.setObjectName("textEdit_copywriting_edit") @@ -1819,8 +1847,8 @@ def setupUi(self, MainWindow): "border-radius: 3px;") self.pushButton_copywriting_pause_play.setObjectName("pushButton_copywriting_pause_play") self.gridLayout_37.addWidget(self.pushButton_copywriting_pause_play, 6, 5, 1, 1) - spacerItem39 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.gridLayout_37.addItem(spacerItem39, 6, 1, 1, 1) + spacerItem40 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_37.addItem(spacerItem40, 6, 1, 1, 1) self.label_copywriting_audio_interval = QtWidgets.QLabel(self.widget) self.label_copywriting_audio_interval.setStyleSheet("") self.label_copywriting_audio_interval.setObjectName("label_copywriting_audio_interval") @@ -2061,8 +2089,8 @@ def setupUi(self, MainWindow): self.lineEdit_talk_baidu_secret_key.setObjectName("lineEdit_talk_baidu_secret_key") self.gridLayout_45.addWidget(self.lineEdit_talk_baidu_secret_key, 2, 1, 1, 1) self.gridLayout_40.addWidget(self.groupBox_talk_baidu, 7, 0, 1, 5) - spacerItem40 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.gridLayout_40.addItem(spacerItem40, 0, 5, 1, 1) + spacerItem41 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_40.addItem(spacerItem41, 0, 5, 1, 1) self.gridLayout_40.setRowMinimumHeight(0, 1) self.gridLayout_40.setRowMinimumHeight(1, 1) self.gridLayout_40.setRowMinimumHeight(2, 1) @@ -2188,8 +2216,8 @@ def setupUi(self, MainWindow): self.gridLayout_integral_common.setColumnStretch(1, 6) self.gridLayout_79.addLayout(self.gridLayout_integral_common, 0, 0, 1, 1) self.gridLayout_78.addWidget(self.groupBox_integral_common, 0, 0, 1, 1) - spacerItem41 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.gridLayout_78.addItem(spacerItem41, 0, 1, 1, 1) + spacerItem42 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout_78.addItem(spacerItem42, 0, 1, 1, 1) self.gridLayout_78.setColumnStretch(0, 12) self.gridLayout_78.setColumnStretch(1, 1) self.verticalLayout_6.addWidget(self.widget_3) @@ -2518,6 +2546,9 @@ def retranslateUi(self, MainWindow): self.label_choose_song_match_fail_copy.setText(_translate("MainWindow", "匹配失败文案")) self.label_choose_song_random_cmd.setText(_translate("MainWindow", "随机点歌命令")) self.groupBox_schedule.setTitle(_translate("MainWindow", "定时任务")) + self.groupBox_idle_time_task.setTitle(_translate("MainWindow", "闲时任务")) + self.groupBox_idle_time_task_comment.setTitle(_translate("MainWindow", "LLM模式")) + self.groupBox_idle_time_task_local_audio.setTitle(_translate("MainWindow", "本地音频模式")) self.groupBox_ddsp_svc.setTitle(_translate("MainWindow", "DDSP_SVC")) self.label_ddsp_svc_enable.setText(_translate("MainWindow", "启用")) self.label_ddsp_svc_fSafePrefixPadLength.setText(_translate("MainWindow", "安全前缀填充长度")) diff --git a/config.json b/config.json index b815563f..d893aa47 100644 --- a/config.json +++ b/config.json @@ -37,6 +37,7 @@ "sd": true, "log": true, "schedule": true, + "idle_time_task": true, "database": true, "play_audio": true, "web_captions_printer": true, diff --git a/config.json.bak b/config.json.bak index b815563f..d893aa47 100644 --- a/config.json.bak +++ b/config.json.bak @@ -37,6 +37,7 @@ "sd": true, "log": true, "schedule": true, + "idle_time_task": true, "database": true, "play_audio": true, "web_captions_printer": true, diff --git a/data/badwords.txt b/data/badwords.txt index f0382350..fb5e0192 100644 --- a/data/badwords.txt +++ b/data/badwords.txt @@ -3508,7 +3508,6 @@ 毛肛 毒龙钻 米青 -武器 馬英九 杨建亭 無毛穴 diff --git "a/docs/\346\212\225\350\265\204\344\272\272/index.html" "b/docs/\346\212\225\350\265\204\344\272\272/index.html" index 6c52102d..682f410a 100644 --- "a/docs/\346\212\225\350\265\204\344\272\272/index.html" +++ "b/docs/\346\212\225\350\265\204\344\272\272/index.html" @@ -59,7 +59,7 @@ { name: "存在感患者", avatar: "https://images.cnblogs.com/cnblogs_com/ikaros-521/2328032/o_230722160559_QQ%E5%9B%BE%E7%89%8720230722234802.jpg", - amount: "¥410.8" + amount: "¥548.8" }, { name: "月零宫白", diff --git "a/docs/\346\212\225\350\265\204\344\272\272/invest.png" "b/docs/\346\212\225\350\265\204\344\272\272/invest.png" index ed396aa0..46232cd7 100644 Binary files "a/docs/\346\212\225\350\265\204\344\272\272/invest.png" and "b/docs/\346\212\225\350\265\204\344\272\272/invest.png" differ diff --git a/main.py b/main.py index f5ac27c6..498f5e95 100644 --- a/main.py +++ b/main.py @@ -1239,46 +1239,6 @@ def init_config(self): GUI部分 动态生成的widget 推荐使用这种形式进行UI加载,更具动态,不过目前封装实现还是垃圾了些,不是很好用,待优化 """ - # 定时任务动态加载 - data_json = [] - for index, tmp in enumerate(config.get("schedule")): - tmp_json = { - "label_text": "任务" + str(index), - "label_tip": "是否启用此定时任务", - "data": tmp["enable"], - "widget_text": "", - "click_func": "", - "main_obj_name": "schedule", - "index": index - } - data_json.append(tmp_json) - - tmp_json = { - "label_text": "循环周期", - "label_tip": "定时任务循环的周期时长(秒),即每间隔这个周期就会执行一次", - "data": tmp["time"], - "main_obj_name": "schedule", - "index": index - } - data_json.append(tmp_json) - - tmp_json = { - "label_text": "文案列表", - "label_tip": "存放文案的列表,通过空格或换行分割,通过{变量}来替换关键数据,可修改源码自定义功能", - "data": tmp["copy"], - "main_obj_name": "schedule", - "index": index - } - data_json.append(tmp_json) - widgets = self.create_widgets_from_json(data_json) - - # 动态添加widget到对应的gridLayout - row = 0 - for i in range(0, len(widgets), 2): - self.ui.gridLayout_schedule.addWidget(widgets[i], row, 0) - self.ui.gridLayout_schedule.addWidget(widgets[i + 1], row, 1) - row += 1 - # 自定义显隐各板块 def get_box_name_by_key(key): # 定义键和值的映射关系,请和配置文件中的键保持一致 @@ -1297,6 +1257,7 @@ def get_box_name_by_key(key): "sd": "Stable Diffusion", "log": "日志", "schedule": "定时任务", + "idle_time_task": "闲时任务", "database": "数据库", "play_audio": "播放音频", "web_captions_printer": "web字幕打印机", @@ -1333,6 +1294,194 @@ def get_box_name_by_key(key): row += 1 + # 定时任务动态加载 + data_json = [] + for index, tmp in enumerate(config.get("schedule")): + tmp_json = { + "label_text": "任务" + str(index), + "label_tip": "是否启用此定时任务", + "data": tmp["enable"], + "widget_text": "", + "click_func": "", + "main_obj_name": "schedule", + "index": index + } + data_json.append(tmp_json) + + tmp_json = { + "label_text": "循环周期", + "label_tip": "定时任务循环的周期时长(秒),即每间隔这个周期就会执行一次", + "data": tmp["time"], + "main_obj_name": "schedule", + "index": index + } + data_json.append(tmp_json) + + tmp_json = { + "label_text": "文案列表", + "label_tip": "存放文案的列表,通过空格或换行分割,通过{变量}来替换关键数据,可修改源码自定义功能", + "data": tmp["copy"], + "main_obj_name": "schedule", + "index": index + } + data_json.append(tmp_json) + widgets = self.create_widgets_from_json(data_json) + + # 动态添加widget到对应的gridLayout + row = 0 + for i in range(0, len(widgets), 2): + self.ui.gridLayout_schedule.addWidget(widgets[i], row, 0) + self.ui.gridLayout_schedule.addWidget(widgets[i + 1], row, 1) + row += 1 + + # 闲时任务动态加载 + def idle_time_task_gui_create(): + data_json = [] + idle_time_task_config = config.get("idle_time_task") + + tmp_json = { + "label_text": "闲时任务", + "label_tip": "是否启用闲时任务", + "data": idle_time_task_config["enable"], + "widget_text": "启用", + "click_func": "", + "main_obj_name": "idle_time_task", + "index": 0 + } + data_json.append(tmp_json) + + tmp_json = { + "label_text": "闲时时间", + "label_tip": "闲时间隔时间(正整数),就是在没有弹幕情况下经过的时间", + "data": idle_time_task_config["idle_time"], + "main_obj_name": "zhipu", + "index": 1 + } + data_json.append(tmp_json) + + tmp_json = { + "label_text": "随机闲时时间", + "label_tip": "是否启用随机闲时时间,从0到闲时时间随机一个数", + "data": idle_time_task_config["random_time"], + "widget_text": "启用", + "click_func": "", + "main_obj_name": "idle_time_task", + "index": 2 + } + data_json.append(tmp_json) + + # logging.info(data_json) + + widgets = self.create_widgets_from_json(data_json) + + # 动态添加widget到对应的gridLayout + row = 0 + # 分2列,左边就是label说明,右边就是输入框等 + for i in range(0, len(widgets), 2): + self.ui.gridLayout_idle_time_task.addWidget(widgets[i], row, 0) + self.ui.gridLayout_idle_time_task.addWidget(widgets[i + 1], row, 1) + row += 1 + + idle_time_task_gui_create() + + def idle_time_task_comment_gui_create(): + data_json = [] + idle_time_task_config = config.get("idle_time_task") + + tmp_json = { + "label_text": "LLM模式", + "label_tip": "是否启用LLM模式", + "data": idle_time_task_config["comment"]["enable"], + "widget_text": "启用", + "click_func": "", + "main_obj_name": "idle_time_task", + "index": 3 + } + data_json.append(tmp_json) + + tmp_json = { + "label_text": "随机文案", + "label_tip": "是否启用随机文案,打乱文案触发顺序", + "data": idle_time_task_config["comment"]["random"], + "widget_text": "启用", + "click_func": "", + "main_obj_name": "idle_time_task", + "index": 4 + } + data_json.append(tmp_json) + + tmp_json = { + "label_text": "文案列表", + "label_tip": "文案列表,文案之间用换行分隔,文案会丢LLM进行处理后直接合成返回的结果", + "data": idle_time_task_config["comment"]["copy"], + "main_obj_name": "idle_time_task", + "index": 5 + } + data_json.append(tmp_json) + + # logging.info(data_json) + + widgets = self.create_widgets_from_json(data_json) + + # 动态添加widget到对应的gridLayout + row = 0 + # 分2列,左边就是label说明,右边就是输入框等 + for i in range(0, len(widgets), 2): + self.ui.gridLayout_idle_time_task_comment.addWidget(widgets[i], row, 0) + self.ui.gridLayout_idle_time_task_comment.addWidget(widgets[i + 1], row, 1) + row += 1 + + idle_time_task_comment_gui_create() + + def idle_time_task_local_audio_gui_create(): + data_json = [] + idle_time_task_config = config.get("idle_time_task") + + tmp_json = { + "label_text": "本地音频模式", + "label_tip": "是否启用本地音频模式", + "data": idle_time_task_config["local_audio"]["enable"], + "widget_text": "启用", + "click_func": "", + "main_obj_name": "idle_time_task", + "index": 6 + } + data_json.append(tmp_json) + + tmp_json = { + "label_text": "随机本地音频", + "label_tip": "是否启用随机本地音频,打乱本地音频触发顺序", + "data": idle_time_task_config["local_audio"]["random"], + "widget_text": "启用", + "click_func": "", + "main_obj_name": "idle_time_task", + "index": 7 + } + data_json.append(tmp_json) + + tmp_json = { + "label_text": "本地音频路径列表", + "label_tip": "本地音频路径列表,相对/绝对路径之间用换行分隔,音频文件会直接丢进音频播放队列", + "data": idle_time_task_config["local_audio"]["path"], + "main_obj_name": "idle_time_task", + "index": 8 + } + data_json.append(tmp_json) + + # logging.info(data_json) + + widgets = self.create_widgets_from_json(data_json) + + # 动态添加widget到对应的gridLayout + row = 0 + # 分2列,左边就是label说明,右边就是输入框等 + for i in range(0, len(widgets), 2): + self.ui.gridLayout_idle_time_task_local_audio.addWidget(widgets[i], row, 0) + self.ui.gridLayout_idle_time_task_local_audio.addWidget(widgets[i + 1], row, 1) + row += 1 + + idle_time_task_local_audio_gui_create() + # 文案配置动态加载 self.ui.lineEdit_copywriting_audio_interval.setText(str(self.copywriting_config['audio_interval'])) self.ui.lineEdit_copywriting_switching_interval.setText(str(self.copywriting_config['switching_interval'])) @@ -3265,17 +3414,7 @@ def reorganize_copywriting_config_data(copywriting_config_data): config_data["copywriting"]["switching_interval"] = round(float(self.ui.lineEdit_copywriting_switching_interval.text()), 1) config_data["copywriting"]["random_play"] = self.ui.checkBox_copywriting_switching_random_play.isChecked() - # 动态文案 - config_data["trends_copywriting"]["enable"] = self.ui.checkBox_trends_copywriting_enable.isChecked() - config_data["trends_copywriting"]["random_play"] = self.ui.checkBox_trends_copywriting_random_play.isChecked() - config_data["trends_copywriting"]["play_interval"] = int(self.ui.lineEdit_trends_copywriting_play_interval.text()) - - # 定义trends_copywriting GridLayout的键映射 - trends_copywriting_keys_per_item = ["folder_path", "prompt_change_enable", "prompt_change_content"] - # 重组trends_copywriting数据并写回json - trends_copywriting_data = self.update_data_from_gridLayout(self.ui.gridLayout_trends_copywriting_2) - config_data["trends_copywriting"]["copywriting"] = reorganize_grid_data_list(trends_copywriting_data, trends_copywriting_keys_per_item) - + # 定义每个GridLayout的键映射 zhipu_keys_mapping = { "api_key": 0, @@ -3295,6 +3434,48 @@ def reorganize_copywriting_config_data(copywriting_config_data): zhipu_data = self.update_data_from_gridLayout(self.ui.gridLayout_zhipu) config_data["zhipu"] = reorganize_grid_data(zhipu_data, zhipu_keys_mapping) + # 动态文案 + config_data["trends_copywriting"]["enable"] = self.ui.checkBox_trends_copywriting_enable.isChecked() + config_data["trends_copywriting"]["random_play"] = self.ui.checkBox_trends_copywriting_random_play.isChecked() + config_data["trends_copywriting"]["play_interval"] = int(self.ui.lineEdit_trends_copywriting_play_interval.text()) + + # 定义trends_copywriting GridLayout的键映射 + trends_copywriting_keys_per_item = ["folder_path", "prompt_change_enable", "prompt_change_content"] + # 重组trends_copywriting数据并写回json + trends_copywriting_data = self.update_data_from_gridLayout(self.ui.gridLayout_trends_copywriting_2) + config_data["trends_copywriting"]["copywriting"] = reorganize_grid_data_list(trends_copywriting_data, trends_copywriting_keys_per_item) + + # 闲时文案 + idle_time_task_keys_mapping = { + "enable": 0, + "idle_time": 1, + "random_time": 2 + } + + # 重组idle_time_task数据并写回json + idle_time_task_data = self.update_data_from_gridLayout(self.ui.gridLayout_idle_time_task) + config_data["idle_time_task"] = reorganize_grid_data(idle_time_task_data, idle_time_task_keys_mapping) + + idle_time_task_comment_keys_mapping = { + "enable": 0, + "random": 1, + "copy": 2 + } + + # 重组idle_time_task_comment数据并写回json + idle_time_task_comment_data = self.update_data_from_gridLayout(self.ui.gridLayout_idle_time_task_comment) + config_data["idle_time_task"]["comment"] = reorganize_grid_data(idle_time_task_comment_data, idle_time_task_comment_keys_mapping) + + idle_time_task_local_audio_keys_mapping = { + "enable": 0, + "random": 1, + "path": 2 + } + + # 重组idle_time_task_local_audio数据并写回json + idle_time_task_local_audio_data = self.update_data_from_gridLayout(self.ui.gridLayout_idle_time_task_local_audio) + config_data["idle_time_task"]["local_audio"] = reorganize_grid_data(idle_time_task_local_audio_data, idle_time_task_local_audio_keys_mapping) + vits_keys_mapping = { "type": 0, "config_path": 1, diff --git a/ui/main.ui b/ui/main.ui index 614f3aea..57d554d5 100644 --- a/ui/main.ui +++ b/ui/main.ui @@ -136,9 +136,9 @@ background-color: rgba(255, 255, 255, 50); 0 - -64 + -8360 991 - 10925 + 11145 @@ -2778,6 +2778,55 @@ background-color: rgba(255, 255, 255, 50); + + + + 闲时任务 + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + LLM模式 + + + + + + + + + + + + 本地音频模式 + + + + + + + + + + + diff --git a/webui.py b/webui.py index b4ab0e85..c950a113 100644 --- a/webui.py +++ b/webui.py @@ -319,6 +319,17 @@ def common_textarea_handle(content): # logging.info(tmp_arr) config_data["schedule"] = tmp_arr + # 闲时任务 + config_data["idle_time_task"]["enable"] = switch_idle_time_task_enable.value + config_data["idle_time_task"]["idle_time"] = input_idle_time_task_idle_time.value + config_data["idle_time_task"]["random_time"] = switch_idle_time_task_random_time.value + config_data["idle_time_task"]["comment"]["enable"] = switch_idle_time_task_comment_enable.value + config_data["idle_time_task"]["comment"]["random"] = switch_idle_time_task_comment_random.value + config_data["idle_time_task"]["comment"]["copy"] = common_textarea_handle(textarea_idle_time_task_comment_copy.value) + config_data["idle_time_task"]["local_audio"]["enable"] = switch_idle_time_task_local_audio_enable.value + config_data["idle_time_task"]["local_audio"]["random"] = switch_idle_time_task_local_audio_random.value + config_data["idle_time_task"]["local_audio"]["path"] = common_textarea_handle(textarea_idle_time_task_local_audio_path.value) + # SD config_data["sd"]["enable"] = switch_sd_enable.value config_data["sd"]["prompt_llm"]["type"] = select_sd_prompt_llm_type.value @@ -360,6 +371,10 @@ def common_textarea_handle(content): # logging.info(tmp_arr) config_data["trends_copywriting"]["copywriting"] = tmp_arr + # web字幕打印机 + config_data["web_captions_printer"]["enable"] = switch_web_captions_printer_enable.value + config_data["web_captions_printer"]["api_ip_port"] = input_web_captions_printer_api_ip_port.value + # 数据库 config_data["database"]["path"] = input_database_path.value config_data["database"]["comment_enable"] = switch_database_comment_enable.value @@ -884,7 +899,21 @@ def common_textarea_handle(content): schedule_var[str(3 * index)] = ui.switch(text=f"启用任务{index}", value=schedule["enable"]) schedule_var[str(3 * index + 1)] = ui.input(label="循环周期", value=schedule["time"], placeholder='定时任务循环的周期时长(秒),即每间隔这个周期就会执行一次').style("width:200px;") schedule_var[str(3 * index + 2)] = ui.textarea(label="文案列表", value=textarea_data_change(schedule["copy"]), placeholder='存放文案的列表,通过空格或换行分割,通过{变量}来替换关键数据,可修改源码自定义功能').style("width:500px;") - + with ui.card().style("margin:10px 0px;background: linear-gradient(45deg, #3494E6, #EC6EAD);"): + ui.label('闲时任务') + with ui.row(): + switch_idle_time_task_enable = ui.switch('启用', value=config.get("idle_time_task", "enable")) + input_idle_time_task_idle_time = ui.input(label='闲时时间', value=config.get("idle_time_task", "idle_time"), placeholder='闲时间隔时间(正整数),就是在没有弹幕情况下经过的时间').style("width:200px;") + switch_idle_time_task_random_time = ui.switch('随机闲时时间', value=config.get("idle_time_task", "random_time")) + with ui.row(): + switch_idle_time_task_comment_enable = ui.switch('LLM模式', value=config.get("idle_time_task", "comment", "enable")) + switch_idle_time_task_comment_random = ui.switch('随机文案', value=config.get("idle_time_task", "comment", "random")) + textarea_idle_time_task_comment_copy = ui.textarea(label='文案列表', value=textarea_data_change(config.get("idle_time_task", "comment", "copy")), placeholder='文案列表,文案之间用换行分隔,文案会丢LLM进行处理后直接合成返回的结果').style("width:800px;") + with ui.row(): + switch_idle_time_task_local_audio_enable = ui.switch('本地音频模式', value=config.get("idle_time_task", "local_audio", "enable")) + switch_idle_time_task_local_audio_random = ui.switch('随机本地音频', value=config.get("idle_time_task", "local_audio", "random")) + textarea_idle_time_task_local_audio_path = ui.textarea(label='本地音频路径列表', value=textarea_data_change(config.get("idle_time_task", "local_audio", "path")), placeholder='本地音频路径列表,相对/绝对路径之间用换行分隔,音频文件会直接丢进音频播放队列').style("width:800px;") + with ui.card().style("margin:10px 0px;background: linear-gradient(45deg, #3494E6, #EC6EAD);"): ui.label('Stable Diffusion') with ui.grid(columns=2):