修复样式跟随系统问题

路径选择采用闭包形式
This commit is contained in:
JackLee_CN 2024-11-05 11:11:19 +08:00
parent 04aafbe408
commit dfd46be74e
5 changed files with 45 additions and 35 deletions

View File

@ -21,6 +21,7 @@ int main(int argc, char *argv[])
//仅限于windows平台 //仅限于windows平台
#if defined(__WIN32__) #if defined(__WIN32__)
x.title()->set_type(QD_TYPE::QD_EXIT); x.title()->set_type(QD_TYPE::QD_EXIT);
x.title()->set_font_style();
#endif #endif
x.show(); x.show();
return a.exec(); return a.exec();

View File

@ -11,20 +11,20 @@ void sui_sys_style::slots_sys_style_thread()
//获取系统注册表信息 //获取系统注册表信息
QSettings style_set(QSettings::UserScope, "Microsoft", "Windows\\CurrentVersion\\Themes\\Personalize"); QSettings style_set(QSettings::UserScope, "Microsoft", "Windows\\CurrentVersion\\Themes\\Personalize");
//当前系统主题状态,默认0-深色主题,1-浅色主题 //当前系统主题状态,默认0-深色主题,1-浅色主题
bool isDark=true; bool isDark=style_set.value("AppsUseLightTheme").toBool();
while (true) while (true)
{ {
//跟随功能是否开启,0-关闭,1-开启 采用bool类型 //跟随功能是否开启,0-关闭,1-开启 采用bool类型
if (state) if (state==1)
{ {
//判断当前临时isDark状态是否和系统主题一致&不一致则更新当前软件主题 //判断当前临时isDark状态是否和系统主题一致&不一致则更新当前软件主题
if (isDark != !style_set.value("AppsUseLightTheme").toBool()) if (isDark != style_set.value("AppsUseLightTheme").toBool())
{ {
emit signals_sys_style_change(!style_set.value("AppsUseLightTheme").toInt()); emit signals_sys_style_change(style_set.value("AppsUseLightTheme").toInt());
isDark = !style_set.value("AppsUseLightTheme").toBool(); isDark = style_set.value("AppsUseLightTheme").toBool();
} }
} }
//刷新间隔5秒 //刷新间隔5秒
QThread::sleep(5); QThread::sleep(2);
} }
} }

View File

@ -60,7 +60,6 @@ sui_title::sui_title(QWidget *parent)
m_layout->setContentsMargins(5, 0, 5, 0); m_layout->setContentsMargins(5, 0, 5, 0);
setFixedHeight(40); setFixedHeight(40);
setLayout(m_layout); setLayout(m_layout);
set_font_style();
connect_slots(); connect_slots();
} }
sui_title::~sui_title() sui_title::~sui_title()
@ -166,16 +165,16 @@ void sui_title::slots_style_system()
{ {
if (sender() != nullptr) if (sender() != nullptr)
{ {
if (_data.x_config.style_system) if (_data.x_config.style_system!=0)
{ {
_data.x_config.style_system = 0; _data.x_config.style_system = 0;
m_style->state=0; m_style->state=_data.x_config.style_system;
((QAction *)sender())->setChecked(false); ((QAction *)sender())->setChecked(false);
} }
else else
{ {
_data.x_config.style_system = 1; _data.x_config.style_system = 1;
m_style->state=1; m_style->state=_data.x_config.style_system;
((QAction *)sender())->setChecked(true); ((QAction *)sender())->setChecked(true);
} }
} }
@ -246,7 +245,7 @@ void sui_title::change_style(int index)
QString _styleSheet = QLatin1String(qss.readAll()); QString _styleSheet = QLatin1String(qss.readAll());
m_parent->setStyleSheet(""); m_parent->setStyleSheet("");
m_parent->setStyleSheet(_styleSheet); m_parent->setStyleSheet(_styleSheet);
QApplication::setStyle("Fusion"); //QApplication::setStyle("Fusion");
} }
qss.close(); qss.close();
//m_parent->update(); //m_parent->update();
@ -322,6 +321,7 @@ void sui_title::set_type(QD_TYPE _type)
m_style = new sui_sys_style(); m_style = new sui_sys_style();
m_thread=new QThread(); m_thread=new QThread();
m_style->moveToThread(m_thread); m_style->moveToThread(m_thread);
m_style->state=_data.x_config.style_system;
connect(m_style, SIGNAL(signals_sys_style_change(int)), this, SLOT(change_style(int))); connect(m_style, SIGNAL(signals_sys_style_change(int)), this, SLOT(change_style(int)));
connect(m_thread, SIGNAL(started()), m_style, SLOT(slots_sys_style_thread())); connect(m_thread, SIGNAL(started()), m_style, SLOT(slots_sys_style_thread()));
m_thread->start(); m_thread->start();

View File

@ -106,34 +106,42 @@ void xsteam_set_ui::slotsSaveDone()
} }
void xsteam_set_ui::slots_set_path_change() void xsteam_set_ui::slots_set_path_change()
{ {
QString set_dir; auto select_dir = [=](QString sender_name)
if (sender()->objectName() == "STEAM_PATH_BTN")
{ {
set_dir = QFileDialog::getExistingDirectory(new QWidget(), "选择目录", steam_path_edit->text()); QString default_dir;
} if (sender_name == "STEAM_PATH_BTN")
else if (sender()->objectName() == "STEAMTOOLS_PATH_BTN")
{
set_dir = QFileDialog::getExistingDirectory(new QWidget(), "选择目录", steamtools_path_edit->text());
}
else if (sender()->objectName() == "STEAMTOOLS_ST_PATH_BTN")
{
set_dir = QFileDialog::getExistingDirectory(new QWidget(), "选择目录", steamtools_st_path_edit->text());
}
if (set_dir != nullptr)
{
if (sender()->objectName() == "STEAM_PATH_BTN")
{ {
_data.x_config.steam_dir = set_dir.toStdString(); default_dir = steam_path_edit->text();
} }
else if (sender()->objectName() == "STEAMTOOLS_PATH_BTN") else if (sender_name == "STEAMTOOLS_PATH_BTN")
{ {
_data.x_config.steamtools_dir = set_dir.toStdString(); default_dir = steamtools_path_edit->text();
} }
else if (sender()->objectName() == "STEAMTOOLS_ST_PATH_BTN") else if (sender_name == "STEAMTOOLS_ST_PATH_BTN")
{ {
_data.x_config.steamtools_st_dir = set_dir.toStdString(); default_dir = steamtools_st_path_edit->text();
} }
return QFileDialog::getExistingDirectory(new QWidget(), "选择目录", default_dir);
};
auto set_dir = [=](QString sender_name,QString dir_str)
{
if (sender_name == "STEAM_PATH_BTN")
{
_data.x_config.steam_dir = dir_str.toStdString();
}
else if (sender_name == "STEAMTOOLS_PATH_BTN")
{
_data.x_config.steamtools_dir = dir_str.toStdString();
}
else if (sender_name == "STEAMTOOLS_ST_PATH_BTN")
{
_data.x_config.steamtools_st_dir = dir_str.toStdString();
}
};
QString dir_str=select_dir(sender()->objectName());
if ( dir_str!= nullptr)
{
set_dir(sender()->objectName(),dir_str);
load_data_set(); load_data_set();
} }
} }

View File

@ -42,6 +42,7 @@ void xsteam_ui::xsteam_init_info_layout()
info_layout->addItem(sparcer_item); info_layout->addItem(sparcer_item);
info_layout->addWidget(info_txt_tag); info_layout->addWidget(info_txt_tag);
info_layout->addItem(sparcer_item); info_layout->addItem(sparcer_item);
info_txt_tag->setVisible(false);
} }
void xsteam_ui::xsteam_init_mind_layout() void xsteam_ui::xsteam_init_mind_layout()
{ {
@ -492,7 +493,7 @@ void xsteam_ui::slots_push_manifest()
xs_push_manifest = xsteam_push_manifest::Instance(); xs_push_manifest = xsteam_push_manifest::Instance();
if (!xs_push_manifest->isVisible()) if (!xs_push_manifest->isVisible())
{ {
xs_push_manifest->setMaximumSize(width(), height() - 25); xs_push_manifest->setMaximumSize(width(), height() - 30);
xs_push_manifest->setGeometry(geometry()); xs_push_manifest->setGeometry(geometry());
xs_push_manifest->show(); xs_push_manifest->show();
} }
@ -502,7 +503,7 @@ void xsteam_ui::slots_open_server_edit()
xs_src_edit_ui = xsteam_src_edit_ui::Instance(); xs_src_edit_ui = xsteam_src_edit_ui::Instance();
if (!xs_src_edit_ui->isVisible()) if (!xs_src_edit_ui->isVisible())
{ {
xs_src_edit_ui->setMaximumSize(width(), height()); xs_src_edit_ui->setMaximumSize(width(), height()- 30);
xs_src_edit_ui->setGeometry(geometry()); xs_src_edit_ui->setGeometry(geometry());
connect(xs_src_edit_ui, SIGNAL(signals_update()), this, SLOT(slots_server_combobox_load_data())); connect(xs_src_edit_ui, SIGNAL(signals_update()), this, SLOT(slots_server_combobox_load_data()));
xs_src_edit_ui->title()->set_font_style(); xs_src_edit_ui->title()->set_font_style();
@ -525,7 +526,7 @@ void xsteam_ui::slots_open_setting()
xs_sets_ui = xsteam_set_ui::Instance(); xs_sets_ui = xsteam_set_ui::Instance();
if (!xs_sets_ui->isVisible()) if (!xs_sets_ui->isVisible())
{ {
xs_sets_ui->setMaximumSize(width(), height()); xs_sets_ui->setMaximumSize(width(), height()- 30);
xs_sets_ui->setGeometry(geometry()); xs_sets_ui->setGeometry(geometry());
xs_sets_ui->title()->set_font_style(); xs_sets_ui->title()->set_font_style();
xs_sets_ui->show(); xs_sets_ui->show();