XSteam/src/xsteam_set_ui.cpp

97 lines
4.0 KiB
C++

#include "xsteam_set_ui.h"
xsteam_set_ui::xsteam_set_ui()
{
init_set();
load_data_set();
}
xsteam_set_ui::~xsteam_set_ui()
{
}
void xsteam_set_ui::init_set()
{
setWindowTitle(tr("XSteam设置"));
main_layout = new QVBoxLayout;
foot_layout = new QHBoxLayout;
body_layout = new QVBoxLayout;
src_group=new QGroupBox(tr("设置参数"));
steam_layout=new QHBoxLayout;
steam_path_str=new QLabel(tr("Steam路径设置:"));
steam_path_edit=new QLineEdit();
steam_path_btn=new QPushButton(tr("浏览"));
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->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->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->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->addWidget(steaminfo_head_path_str);
steam_head_api_layout->addWidget(steaminfo_head_path_edit);
body_layout->addLayout(steam_layout);
body_layout->addLayout(steamtools_layout);
body_layout->addLayout(steamtools_st_layout);
body_layout->addLayout(steam_api_layout);
body_layout->addLayout(steam_head_api_layout);
body_layout->addWidget(new QWidget());
src_group->setLayout(body_layout);
_pSaveData = new QPushButton(tr("保存"));
foot_layout->addSpacerItem(sparcer_item);
foot_layout->addWidget(_pSaveData);
foot_layout->addSpacerItem(sparcer_item);
main_layout->addWidget(src_group);
main_layout->addLayout(foot_layout);
main_layout->setStretch(0, 8);
main_layout->setStretch(1, 2);
main_layout->setContentsMargins(5, 5, 5, 5);
setLayout(main_layout);
connect_slots();
}
void xsteam_set_ui::connect_slots(){
connect(_pSaveData, SIGNAL(clicked()), this, SLOT(slotsSaveDone()));
}
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();
}