34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
#include "sui_sys_style.h"
|
|
|
|
sui_sys_style::sui_sys_style(QObject *parent) : QObject(parent)
|
|
{
|
|
}
|
|
sui_sys_style::~sui_sys_style()
|
|
{
|
|
}
|
|
void sui_sys_style::slots_sys_style_thread()
|
|
{
|
|
//当前系统主题状态,默认0-深色主题,1-浅色主题
|
|
Qt::ColorScheme cDark=QGuiApplication::styleHints()->colorScheme();
|
|
while (true)
|
|
{
|
|
//跟随功能是否开启,0-关闭,1-开启 采用bool类型
|
|
if (state==1)
|
|
{
|
|
//判断当前临时isDark状态是否和系统主题一致&不一致则更新当前软件主题
|
|
if (cDark != QGuiApplication::styleHints()->colorScheme())
|
|
{
|
|
bool style;
|
|
if(QGuiApplication::styleHints()->colorScheme()==Qt::ColorScheme::Light){
|
|
style=true;
|
|
}else if(QGuiApplication::styleHints()->colorScheme()==Qt::ColorScheme::Dark){
|
|
style=false;
|
|
}
|
|
emit signals_sys_style_change(style);
|
|
cDark = QGuiApplication::styleHints()->colorScheme();
|
|
}
|
|
}
|
|
//刷新间隔5秒
|
|
QThread::sleep(2);
|
|
}
|
|
} |