优化了部分代码结构
This commit is contained in:
@ -366,6 +366,21 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
|
|||||||
path.mkdir(parents=True, exist_ok=True)
|
path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
def set_dark_mode_status(self):
|
def set_dark_mode_status(self):
|
||||||
|
module_list = [
|
||||||
|
self,
|
||||||
|
self.approximately_align,
|
||||||
|
self.preprocess,
|
||||||
|
self.detect_Jpeak,
|
||||||
|
self.detect_Rpeak,
|
||||||
|
self.label_check,
|
||||||
|
self.precisely_align,
|
||||||
|
self.cut_PSG,
|
||||||
|
self.artifact_label,
|
||||||
|
self.bcg_quality_label,
|
||||||
|
self.resp_quality_label,
|
||||||
|
self.SA_label
|
||||||
|
]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self.ui.checkBox_darkmode.isChecked():
|
if self.ui.checkBox_darkmode.isChecked():
|
||||||
QApplication.styleHints().setColorScheme(Qt.ColorScheme.Dark)
|
QApplication.styleHints().setColorScheme(Qt.ColorScheme.Dark)
|
||||||
@ -374,3 +389,22 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
PublicFunc.msgbox_output(self, Constants.MAINWINDOW_DARKMODE_FAILURE + "。" + format_exc(), Constants.MSGBOX_TYPE_ERROR)
|
PublicFunc.msgbox_output(self, Constants.MAINWINDOW_DARKMODE_FAILURE + "。" + format_exc(), Constants.MSGBOX_TYPE_ERROR)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
for module in module_list:
|
||||||
|
try:
|
||||||
|
if module is not None:
|
||||||
|
MainWindow.update_widget_style(module)
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update_widget_style(mainWindow):
|
||||||
|
all_widgets = mainWindow.centralWidget().findChildren(QWidget)
|
||||||
|
# 迭代所有部件
|
||||||
|
for widget in all_widgets:
|
||||||
|
try:
|
||||||
|
widget.style().unpolish(widget)
|
||||||
|
widget.style().polish(widget)
|
||||||
|
widget.update()
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
Reference in New Issue
Block a user