update messagebox

This commit is contained in:
jiegeaiai 2025-01-05 19:39:24 +08:00
parent 302694578c
commit 3bad2cc7cd
3 changed files with 16 additions and 4 deletions

View File

@ -11,6 +11,7 @@
#include <QAction> #include <QAction>
#include "config.h" #include "config.h"
#include "common/SpdLogger.h"
template<> RecourceHelper* Singleton<RecourceHelper>::instance_ = nullptr; template<> RecourceHelper* Singleton<RecourceHelper>::instance_ = nullptr;
RecourceHelper::RecourceHelper(QObject* parent) RecourceHelper::RecourceHelper(QObject* parent)
@ -72,7 +73,7 @@ void RecourceHelper::Init() {
if (fontName.count() > 0) { if (fontName.count() > 0) {
iconFont_ = QFont(fontName.at(0)); iconFont_ = QFont(fontName.at(0));
} else { } else {
qDebug() << "fontName count <= 0 error"; LOG_WARN("fontName count <= 0 error");
} }
const QString appName = QApplication::applicationDisplayName(); const QString appName = QApplication::applicationDisplayName();
@ -83,8 +84,18 @@ void RecourceHelper::Init() {
#endif #endif
qDebug() << transName; qDebug() << transName;
bool success = trans_.load(transName); bool success = trans_.load(transName);
if (!success) { if (success) {
qDebug() << "load translations error"; QApplication::installTranslator(&trans_);
} else {
LOG_WARN("load translations error: {}", transName.toStdString());
} }
QApplication::installTranslator(&trans_);
const QString systemTransName = QString("./translations/qt_%1.qm").arg( QLocale::system().name());
success = systemTrans_.load(systemTransName);
if (success) {
QApplication::installTranslator(&systemTrans_);
} else {
LOG_WARN("load translations error: {}", systemTransName.toStdString());
}
} }

View File

@ -33,4 +33,5 @@ private:
private: private:
QFont iconFont_; QFont iconFont_;
QTranslator trans_; QTranslator trans_;
QTranslator systemTrans_;
}; };

Binary file not shown.