删除软件本地字体资源功能,直接读取系统字体
This commit is contained in:
parent
380b7cd512
commit
63ab540c26
@ -110,12 +110,12 @@ SET(PROJECT_SOURCES
|
|||||||
${src}
|
${src}
|
||||||
)
|
)
|
||||||
# 设置消息策略为qFatal来禁用qDebug信息
|
# 设置消息策略为qFatal来禁用qDebug信息
|
||||||
LIST(APPEND CMAKE_CXX_FLAGS "-DQT_NO_DEBUG_OUTPUT")
|
#LIST(APPEND CMAKE_CXX_FLAGS "-DQT_NO_DEBUG_OUTPUT")
|
||||||
|
|
||||||
#资源文件
|
#资源文件
|
||||||
QT6_ADD_RESOURCES(RCFILES res.qrc)
|
QT6_ADD_RESOURCES(RCFILES res.qrc)
|
||||||
#WIN32
|
#WIN32
|
||||||
add_executable(${PROJECT_NAME} WIN32 ${PROJECT_SOURCES} ${RCFILES} xsteam.rc)
|
add_executable(${PROJECT_NAME} ${PROJECT_SOURCES} ${RCFILES} xsteam.rc)
|
||||||
|
|
||||||
#安全编译
|
#安全编译
|
||||||
#关闭RPATH特性
|
#关闭RPATH特性
|
||||||
|
7
main.cpp
7
main.cpp
@ -7,11 +7,6 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
/*
|
|
||||||
QTranslator qtTranslator;
|
|
||||||
qtTranslator.load(":/res/translator//qt_zh_CN.qm");
|
|
||||||
a.installTranslator(&qtTranslator);
|
|
||||||
*/
|
|
||||||
QTranslator qtBaseTranslator;
|
QTranslator qtBaseTranslator;
|
||||||
if (!qtBaseTranslator.load(QStringLiteral(":/res/translator/qtbase_zh_CN.qm")))
|
if (!qtBaseTranslator.load(QStringLiteral(":/res/translator/qtbase_zh_CN.qm")))
|
||||||
{
|
{
|
||||||
@ -19,7 +14,7 @@ int main(int argc, char *argv[])
|
|||||||
qDebug() << "Failed to load translation file.";
|
qDebug() << "Failed to load translation file.";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
a.installTranslator(&qtBaseTranslator);
|
a.installTranslator(&qtBaseTranslator);
|
||||||
sui x;
|
sui x;
|
||||||
x.show();
|
x.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
1
res.qrc
1
res.qrc
@ -15,6 +15,5 @@
|
|||||||
<file>res/qss/light_style.qss</file>
|
<file>res/qss/light_style.qss</file>
|
||||||
|
|
||||||
<file>res/txt/about.txt</file>
|
<file>res/txt/about.txt</file>
|
||||||
<file>res/font/HarmonyOS_Sans_SC_Black.ttf</file>
|
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Binary file not shown.
@ -58,10 +58,12 @@ sui_title::sui_title(QWidget *parent)
|
|||||||
m_layout->setSpacing(5);
|
m_layout->setSpacing(5);
|
||||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||||
setFixedHeight(40);
|
setFixedHeight(40);
|
||||||
setLayout(m_layout);
|
setLayout(m_layout);
|
||||||
QDir *fontDir = new QDir(tr(":/res/font/"));
|
QFontDatabase database;
|
||||||
font_table = fontDir->entryList(QDir::Files);
|
foreach(const QString & family, database.families(QFontDatabase::SimplifiedChinese))
|
||||||
font_table.append(QFontDatabase::applicationFontFamilies(QFontDatabase::SimplifiedChinese));
|
{
|
||||||
|
font_table.append(family);
|
||||||
|
}
|
||||||
QDir *styleDir = new QDir(tr(":/res/qss/"));
|
QDir *styleDir = new QDir(tr(":/res/qss/"));
|
||||||
style_table = styleDir->entryList(QDir::Files);
|
style_table = styleDir->entryList(QDir::Files);
|
||||||
slots_set_style_change();
|
slots_set_style_change();
|
||||||
@ -127,20 +129,19 @@ void sui_title::slots_set_style_change()
|
|||||||
}
|
}
|
||||||
void sui_title::slots_set_font_change()
|
void sui_title::slots_set_font_change()
|
||||||
{
|
{
|
||||||
if(sender()!=nullptr){
|
if(sender()!=nullptr){
|
||||||
_data.x_config.font=sender()->objectName().toInt();
|
_data.x_config.font=sender()->objectName().toInt();
|
||||||
}
|
}
|
||||||
QString font=tr(":/res/font/")+font_table[_data.x_config.font];
|
QFont font;
|
||||||
int fontId = QFontDatabase::addApplicationFont(font);
|
if(!font_table[_data.x_config.font].isEmpty()){
|
||||||
QStringList fontIDs = QFontDatabase::applicationFontFamilies(fontId);
|
font.setFamily(font_table[_data.x_config.font]);
|
||||||
if (!fontIDs.isEmpty()) {
|
|
||||||
QFont font(fontIDs.first());
|
|
||||||
font.setPointSize(10);
|
font.setPointSize(10);
|
||||||
|
font.setBold(true);
|
||||||
QApplication::setFont(font);
|
QApplication::setFont(font);
|
||||||
}
|
}else {
|
||||||
else {
|
|
||||||
qDebug()<<"Failed to load font.";
|
qDebug()<<"Failed to load font.";
|
||||||
}
|
}
|
||||||
|
|
||||||
change_style(_data.x_config.style);
|
change_style(_data.x_config.style);
|
||||||
}
|
}
|
||||||
void sui_title::change_style(int index){
|
void sui_title::change_style(int index){
|
||||||
|
Loading…
Reference in New Issue
Block a user