增加字体粗细选项

This commit is contained in:
JackLee_CN 2024-10-13 23:18:54 +08:00
parent 73b255ae96
commit f69f4fb27d
5 changed files with 34 additions and 6 deletions

View File

@ -110,12 +110,12 @@ SET(PROJECT_SOURCES
${src}
)
# qFatalqDebug
LIST(APPEND CMAKE_CXX_FLAGS "-DQT_NO_DEBUG_OUTPUT")
#LIST(APPEND CMAKE_CXX_FLAGS "-DQT_NO_DEBUG_OUTPUT")
#
QT6_ADD_RESOURCES(RCFILES res.qrc)
#WIN32
add_executable(${PROJECT_NAME} WIN32 ${PROJECT_SOURCES} ${RCFILES} xsteam.rc)
add_executable(${PROJECT_NAME} ${PROJECT_SOURCES} ${RCFILES} xsteam.rc)
#
#RPATH

View File

@ -113,6 +113,18 @@ void sui_title::slots_ico_menu()
connect(f_Action,SIGNAL(triggered (bool)),this,SLOT(slots_set_font_change()));
f_menu->addAction(f_Action);
}
QAction *separator = new QAction(nullptr);
separator->setSeparator(true);
f_menu->addAction(separator);
QActionGroup* b_QGroup = new QActionGroup(this);
QAction* b_Action=new QAction("字体加粗",b_QGroup);
b_Action->setObjectName("font_bold");
b_Action->setCheckable(true);
if(_data.x_config.font_bold){
b_Action->setChecked(true);
}
connect(b_Action,SIGNAL(triggered (bool)),this,SLOT(slots_set_font_change()));
f_menu->addAction(b_Action);
}
m_menu->addMenu(s_menu);
m_menu->addMenu(f_menu);
@ -129,14 +141,26 @@ void sui_title::slots_set_style_change()
}
void sui_title::slots_set_font_change()
{
if(sender()!=nullptr){
_data.x_config.font=sender()->objectName().toInt();
if(sender()!=nullptr){
if(sender()->objectName()=="font_bold"){
if(_data.x_config.font_bold){
_data.x_config.font_bold=0;
}else{
_data.x_config.font_bold=1;
}
}else{
_data.x_config.font=sender()->objectName().toInt();
}
}
QFont font;
if(!font_table[_data.x_config.font].isEmpty()){
font.setFamily(font_table[_data.x_config.font]);
font.setPointSize(10);
font.setBold(true);
if( _data.x_config.font_bold){
font.setBold(true);
}else{
font.setBold(false);
}
QApplication::setFont(font);
}else {
qDebug()<<"Failed to load font.";

View File

@ -45,7 +45,7 @@ private:
QPushButton *m_max_button; //最大化/还原按钮
QPushButton *m_close_button; //关闭按钮
QSpacerItem *sparcer_item = new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Fixed);
QMenu *m_menu;
QMenu* m_menu;
QMenu* s_menu;
QMenu* f_menu;
QStringList style_table;

View File

@ -56,6 +56,7 @@ typedef struct
{
int style = 0;
int font = 0;
int font_bold=0;
std::string steam_dir={};
std::string steamtools_dir={};
std::string steamtools_st_dir={};

View File

@ -348,6 +348,7 @@ void xsteam_save_data_read()
}
_data.x_config.style = j3.at("xsteam_sets").at("style");
_data.x_config.font = j3.at("xsteam_sets").at("font");
_data.x_config.font_bold = j3.at("xsteam_sets").at("font_bold");
_data.x_config.steam_dir = j3.at("xsteam_sets").at("steam_dir");
_data.x_config.steamtools_dir = j3.at("xsteam_sets").at("steamtools_dir");
_data.x_config.steamtools_st_dir = j3.at("xsteam_sets").at("steamtools_st_dir");
@ -365,6 +366,7 @@ void xsteam_save_data_read()
_data.s_data.push_back(_src_data);
// 默认配置
_data.x_config.font = 0;
_data.x_config.font_bold=0;
_data.x_config.style = 1;
QSettings settings("HKEY_CURRENT_USER\\Software\\Valve\\Steam", QSettings::NativeFormat);
_data.x_config.steam_dir = (settings.value("SteamPath", "").toString()).toStdString();
@ -425,6 +427,7 @@ json xsteam_data_serialize(json jsonData)
}
jsonData[toStr(xsteam_sets)][toStr(style)] = _data.x_config.style;
jsonData[toStr(xsteam_sets)][toStr(font)] = _data.x_config.font;
jsonData[toStr(xsteam_sets)][toStr(font_bold)] = _data.x_config.font_bold;
jsonData[toStr(xsteam_sets)][toStr(steam_dir)] = _data.x_config.steam_dir;
jsonData[toStr(xsteam_sets)][toStr(steamtools_dir)] = _data.x_config.steamtools_dir;
jsonData[toStr(xsteam_sets)][toStr(steamtools_st_dir)] = _data.x_config.steamtools_st_dir;