新增了手动切换深浅色模式的功能
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
from pathlib import Path
|
||||
from traceback import format_exc
|
||||
|
||||
from PySide6.QtWidgets import QMainWindow, QMessageBox, QFileDialog
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QMainWindow, QMessageBox, QFileDialog, QApplication, QWidget
|
||||
from PySide6.QtGui import QGuiApplication
|
||||
from matplotlib import use
|
||||
from yaml import dump, load, FullLoader
|
||||
@ -112,7 +114,16 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
|
||||
|
||||
PublicFunc.__styleAllButton__(self, ButtonState)
|
||||
|
||||
try:
|
||||
if QApplication.styleHints().colorScheme() == Qt.ColorScheme.Dark:
|
||||
self.ui.checkBox_darkmode.setChecked(True)
|
||||
else:
|
||||
self.ui.checkBox_darkmode.setChecked(False)
|
||||
except Exception as e:
|
||||
PublicFunc.msgbox_output(self, Constants.MAINWINDOW_GET_DARKMODE_FAILURE + "。" + format_exc(), Constants.TIPS_TYPE_ERROR)
|
||||
|
||||
# 绑定槽函数
|
||||
self.ui.checkBox_darkmode.stateChanged.connect(self.set_dark_mode_status)
|
||||
self.ui.pushButton_open.clicked.connect(self.__slot_btn_open__)
|
||||
self.ui.pushButton_approximately_align.clicked.connect(self.__slot_btn_approximately_align__)
|
||||
self.ui.pushButton_preprocess_BCG.clicked.connect(self.__slot_btn_preprocess__)
|
||||
@ -351,4 +362,86 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
|
||||
|
||||
for path in path_list:
|
||||
if not path.exists():
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
def set_dark_mode_status(self):
|
||||
try:
|
||||
if self.ui.checkBox_darkmode.isChecked():
|
||||
QApplication.styleHints().setColorScheme(Qt.ColorScheme.Dark)
|
||||
else:
|
||||
QApplication.styleHints().setColorScheme(Qt.ColorScheme.Light)
|
||||
except Exception as e:
|
||||
PublicFunc.msgbox_output(self, Constants.MAINWINDOW_DARKMODE_FAILURE + "。" + format_exc(), Constants.MSGBOX_TYPE_ERROR)
|
||||
return
|
||||
|
||||
try:
|
||||
MainWindow.update_widget_style(self)
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
if self.approximately_align is not None:
|
||||
MainWindow.update_widget_style(self.approximately_align)
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
if self.preprocess is not None:
|
||||
MainWindow.update_widget_style(self.preprocess)
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
if self.detect_Jpeak is not None:
|
||||
MainWindow.update_widget_style(self.detect_Jpeak)
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
if self.detect_Rpeak is not None:
|
||||
MainWindow.update_widget_style(self.detect_Rpeak)
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
if self.label_check is not None:
|
||||
MainWindow.update_widget_style(self.label_check)
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
if self.precisely_align is not None:
|
||||
MainWindow.update_widget_style(self.precisely_align)
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
if self.cut_PSG is not None:
|
||||
MainWindow.update_widget_style(self.cut_PSG)
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
if self.artifact_label is not None:
|
||||
MainWindow.update_widget_style(self.artifact_label)
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
if self.bcg_quality_label is not None:
|
||||
MainWindow.update_widget_style(self.bcg_quality_label)
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
if self.resp_quality_label is not None:
|
||||
MainWindow.update_widget_style(self.resp_quality_label)
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
if self.SA_label is not None:
|
||||
MainWindow.update_widget_style(self.SA_label)
|
||||
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
|
||||
@ -14,6 +14,8 @@ class Constants:
|
||||
MAINWINDOW_ROOT_PATH_NOT_EXIST: str = "根目录路径输入错误"
|
||||
MAINWINDOW_SAMPID_EMPTY: str = "样本ID为空"
|
||||
MAINWINDOW_MSGBOX_TITLE: str = "消息"
|
||||
MAINWINDOW_GET_DARKMODE_FAILURE: str = "获取深浅色状态失败,不影响标注工作,可忽略"
|
||||
MAINWINDOW_DARKMODE_FAILURE: str = "切换深浅色模式失败,不影响标注工作,可忽略"
|
||||
|
||||
INPUTTING_DATA: str = "正在导入数据"
|
||||
INPUT_FINISHED: str = "导入完成"
|
||||
|
||||
Reference in New Issue
Block a user