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