增加设置界面中路径设置功能

This commit is contained in:
JackLee_CN 2024-11-02 18:07:48 +08:00
parent 807b47b818
commit 8ac8985bd4
8 changed files with 142 additions and 61 deletions

11
.vscode/launch.json vendored
View File

@ -3,5 +3,14 @@
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": []
"configurations": [
{
"type": "cmake",
"request": "launch",
"name": "Debug portfile(s)",
"cmakeDebugType": "external",
"pipeName": "\\\\.\\pipe\\vcpkg_ext_portfile_dbg",
"preLaunchTask": "Debug vcpkg commands"
}
]
}

13
.vscode/settings.json vendored
View File

@ -113,5 +113,16 @@
"*.in": "cpp",
"qactiongroup": "cpp"
},
"Codegeex.RepoIndex": true
"Codegeex.RepoIndex": true,
"editor.gotoLocation.alternativeDeclarationCommand": "editor.action.revealDefinition",
"editor.gotoLocation.alternativeDefinitionCommand": "editor.action.revealDefinition",
"editor.gotoLocation.alternativeTypeDefinitionCommand": "editor.action.revealDefinition",
"editor.selectionHighlight": false,
"files.autoSave": "onFocusChange",
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.quickSuggestions": {
"other": "on",
"comments": "off",
"strings": "on"
}
}

View File

@ -148,6 +148,7 @@ SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -s")
SET(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -s")
#EXE
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-s")
#
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -ftrapv")
#

View File

@ -55,27 +55,25 @@ QPushButton#min_button,QPushButton#max_button,QPushButton#close_button{
margin-right:3px;
margin-bottom:0px;
border-radius:8px;
font-family: "Microsoft YaHei";
font-weight: bold;
font: bold 12px;
}
QPushButton#min_button{
image:url(":/res/img/btn/btn_min.png");
border:none;
width:20px;
height:20px;
width:25px;
height:25px;
}
QPushButton#max_button{
image:url(":/res/img/btn/btn_max.png");
border:none;
width:20px;
height:20px;
width:25px;
height:25px;
}
QPushButton#close_button{
image:url(":/res/img/btn/btn_close.png");
border:none;
width:20px;
height:20px;
width:25px;
height:25px;
}
QPushButton#min_button:hover,QPushButton#max_button:hover,QPushButton#close_button:hover{
@ -87,3 +85,4 @@ QPushButton#min_button:pressed,QPushButton#max_button:pressed,QPushButton#close_
padding-left:1px;
padding-top:1px;
}

View File

@ -6,7 +6,7 @@ sui_title::sui_title(QWidget *parent)
f_menu(nullptr)
{
m_parent = parent;
m_type=QD_TYPE::QD_EXIT;
m_type = QD_TYPE::QD_EXIT;
// 给成员变量申请内存
m_icon_button = new QPushButton(/*this*/);
m_min_button = new QPushButton(this);
@ -66,7 +66,24 @@ sui_title::sui_title(QWidget *parent)
sui_title::~sui_title()
{
}
void sui_title::auto_style()
{
QFuture<void> future = QtConcurrent::run([=]()
{
QSettings style_set(QSettings::UserScope, "Microsoft", "Windows\\CurrentVersion\\Themes\\Personalize");
bool isDark;
while (true)
{
isDark= !style_set.value("AppsUseLightTheme").toBool();
if(isDark){
change_style(0);
}else{
change_style(1);
}
QThread::sleep(5);
}
});
}
void sui_title::connect_slots()
{
// 连接三个按钮的信号槽3
@ -134,7 +151,8 @@ void sui_title::slots_ico_menu()
delete m_menu;
m_menu = nullptr;
}
void sui_title::set_font_style(){
void sui_title::set_font_style()
{
slots_set_style_change();
slots_set_font_change();
}

View File

@ -17,6 +17,7 @@
#include <QActionGroup>
#include <QFontDatabase>
#include <QStyleFactory>
#include <QtConcurrent/QtConcurrent>
#include "xsteam_ex.h"
typedef enum{
@ -44,6 +45,7 @@ private:
void up_maximize();
void change_style(int);
void connect_slots();
void auto_style();
private:
QWidget *m_parent;
QHBoxLayout *m_layout;

View File

@ -10,48 +10,49 @@ xsteam_set_ui::~xsteam_set_ui()
}
void xsteam_set_ui::init_set()
{
main_qwidget=new QWidget;
main_qwidget = new QWidget;
main_layout = new QVBoxLayout;
foot_layout = new QHBoxLayout;
body_layout = new QVBoxLayout;
set_group=new QGroupBox(tr("参数设置"));
set_group = new QGroupBox(tr("参数设置"));
set_group->setObjectName("SET_GROUP");
steam_layout=new QHBoxLayout;
steam_path_str=new QLabel(tr("Steam路径设置:"));
steam_path_edit=new QLineEdit();
steam_path_btn=new QPushButton(tr("浏览"));
steam_layout = new QHBoxLayout;
steam_path_str = new QLabel(tr("Steam路径设置:"));
steam_path_edit = new QLineEdit();
steam_path_btn = new QPushButton(tr("浏览"));
steam_path_btn->setObjectName("STEAM_PATH_BTN");
steam_layout->addWidget(steam_path_str);
steam_layout->addWidget(steam_path_edit);
steam_layout->addWidget(steam_path_btn);
steamtools_layout=new QHBoxLayout;
steamtools_path_str=new QLabel(tr("SteamTools路径设置:"));
steamtools_path_edit=new QLineEdit();
steamtools_path_btn=new QPushButton(tr("浏览"));
steamtools_layout = new QHBoxLayout;
steamtools_path_str = new QLabel(tr("SteamTools路径设置:"));
steamtools_path_edit = new QLineEdit();
steamtools_path_btn = new QPushButton(tr("浏览"));
steamtools_path_btn->setObjectName("STEAMTOOLS_PATH_BTN");
steamtools_layout->addWidget(steamtools_path_str);
steamtools_layout->addWidget(steamtools_path_edit);
steamtools_layout->addWidget(steamtools_path_btn);
steamtools_st_layout=new QHBoxLayout;
steamtools_st_path_str=new QLabel(tr("SteamTools .st路径设置(不建议修改):"));
steamtools_st_path_edit=new QLineEdit();
steamtools_st_path_btn=new QPushButton(tr("浏览"));
steamtools_st_layout = new QHBoxLayout;
steamtools_st_path_str = new QLabel(tr("SteamTools .st路径设置(不建议修改):"));
steamtools_st_path_edit = new QLineEdit();
steamtools_st_path_btn = new QPushButton(tr("浏览"));
steamtools_st_path_btn->setObjectName("STEAMTOOLS_ST_PATH_BTN");
steamtools_st_layout->addWidget(steamtools_st_path_str);
steamtools_st_layout->addWidget(steamtools_st_path_edit);
steamtools_st_layout->addWidget(steamtools_st_path_btn);
steam_api_layout=new QHBoxLayout;
steaminfo_api_path_str=new QLabel(tr("Steam Info Api Url(不建议修改):"));
steaminfo_api_path_edit=new QLineEdit();
steam_api_layout = new QHBoxLayout;
steaminfo_api_path_str = new QLabel(tr("Steam Info Api Url(不建议修改):"));
steaminfo_api_path_edit = new QLineEdit();
steam_api_layout->addWidget(steaminfo_api_path_str);
steam_api_layout->addWidget(steaminfo_api_path_edit);
steam_head_api_layout=new QHBoxLayout;
steaminfo_head_path_str=new QLabel(tr("Steam Logo Api Url(不建议修改):"));
steaminfo_head_path_edit=new QLineEdit();
steam_head_api_layout = new QHBoxLayout;
steaminfo_head_path_str = new QLabel(tr("Steam Logo Api Url(不建议修改):"));
steaminfo_head_path_edit = new QLineEdit();
steam_head_api_layout->addWidget(steaminfo_head_path_str);
steam_head_api_layout->addWidget(steaminfo_head_path_edit);
@ -77,23 +78,62 @@ void xsteam_set_ui::init_set()
layout()->addWidget(main_qwidget);
connect_slots();
}
void xsteam_set_ui::connect_slots(){
void xsteam_set_ui::connect_slots()
{
connect(_pSaveData, SIGNAL(clicked()), this, SLOT(slotsSaveDone()));
connect(steam_path_btn, SIGNAL(clicked()), this, SLOT(slots_set_path_change()));
connect(steamtools_path_btn, SIGNAL(clicked()), this, SLOT(slots_set_path_change()));
connect(steamtools_st_path_btn, SIGNAL(clicked()), this, SLOT(slots_set_path_change()));
}
void xsteam_set_ui::load_data_set(){
void xsteam_set_ui::load_data_set()
{
steam_path_edit->setText(QString::fromStdString(_data.x_config.steam_dir));
steamtools_path_edit->setText(QString::fromStdString(_data.x_config.steamtools_dir));
steamtools_st_path_edit->setText(QString::fromStdString(_data.x_config.steamtools_st_dir));
steaminfo_api_path_edit->setText(QString::fromStdString(_data.x_config.steam_api_url));
steaminfo_head_path_edit->setText(QString::fromStdString(_data.x_config.steam_logo_url));
}
void xsteam_set_ui::slotsSaveDone(){
_data.x_config.steam_dir=steam_path_edit->text().toStdString();
_data.x_config.steamtools_dir=steamtools_path_edit->text().toStdString();
_data.x_config.steamtools_st_dir=steamtools_st_path_edit->text().toStdString();
_data.x_config.steam_api_url=steaminfo_api_path_edit->text().toStdString();
_data.x_config.steam_logo_url=steaminfo_head_path_edit->text().toStdString();
xsteam_save_data_write();
xsteam_msg_tip(nullptr, "保存成功");
this->close();
void xsteam_set_ui::slotsSaveDone()
{
_data.x_config.steam_dir = steam_path_edit->text().toStdString();
_data.x_config.steamtools_dir = steamtools_path_edit->text().toStdString();
_data.x_config.steamtools_st_dir = steamtools_st_path_edit->text().toStdString();
_data.x_config.steam_api_url = steaminfo_api_path_edit->text().toStdString();
_data.x_config.steam_logo_url = steaminfo_head_path_edit->text().toStdString();
xsteam_save_data_write();
xsteam_msg_tip(nullptr, "保存成功");
this->close();
}
void xsteam_set_ui::slots_set_path_change()
{
QString set_dir;
if (sender()->objectName() == "STEAM_PATH_BTN")
{
set_dir = QFileDialog::getExistingDirectory(new QWidget(), "选择目录", steam_path_edit->text());
}
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();
}
else if (sender()->objectName() == "STEAMTOOLS_PATH_BTN")
{
_data.x_config.steamtools_dir = set_dir.toStdString();
}
else if (sender()->objectName() == "STEAMTOOLS_ST_PATH_BTN")
{
_data.x_config.steamtools_st_dir = set_dir.toStdString();
}
load_data_set();
}
}

View File

@ -80,6 +80,7 @@ private:
private slots:
//void clicked_rightMenu(const QPoint &pos); //右键信号槽函数
void slotsSaveDone();
void slots_set_path_change();
};
xsteam_set_ui *xsteam_set_ui::_instance = {};
QMutex xsteam_set_ui::mutex;