Skip to content

Commit 32b96fc

Browse files
laanwjPastaPastaPasta
authored andcommitted
Merge bitcoin-core/gui#623: Getting ready to Qt 6 (9/n). Apply Qt 6 specific changes
d8d99d0 qt6: Do not use deprecated high DPI attributes in Qt 6 (Hennadii Stepanov) 8927bb8 refactor: Fix style in `initTranslations()` function (Hennadii Stepanov) ad73447 qt6: Do not use deprecated `QLibraryInfo::path` in Qt 6 (Hennadii Stepanov) 3f51d0b qt6: Fix type registration (Hennadii Stepanov) Pull request description: One more step in migration to Qt 6. Could be tested with hebasto#3 or bitcoin#24798. No behavior change when compiling with Qt 5. ACKs for top commit: laanwj: Code review ACK d8d99d0 jarolrod: ACK d8d99d0 Tree-SHA512: e5f92a80f8622e5f95dd98a90783956a26d3c8382b9ca8e479fb6c152cfdc85a2f6084e78d463ceea1e0f0b3ac72d2b086c8ca24967b2b6070553317e9e3252e
1 parent 9f11216 commit 32b96fc

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/qt/bitcoin.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ static void RegisterMetaTypes()
9898
qRegisterMetaType<QMessageBox::Icon>("QMessageBox::Icon");
9999
qRegisterMetaType<interfaces::BlockAndHeaderTipInfo>("interfaces::BlockAndHeaderTipInfo");
100100

101+
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
101102
qRegisterMetaTypeStreamOperators<BitcoinUnit>("BitcoinUnit");
103+
#else
104+
qRegisterMetaType<BitcoinUnit>("BitcoinUnit");
105+
#endif
102106
}
103107

104108
static QString GetLangTerritory()
@@ -137,21 +141,30 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans
137141
// - First load the translator for the base language, without territory
138142
// - Then load the more specific locale translator
139143

144+
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
145+
const QString translation_path{QLibraryInfo::location(QLibraryInfo::TranslationsPath)};
146+
#else
147+
const QString translation_path{QLibraryInfo::path(QLibraryInfo::TranslationsPath)};
148+
#endif
140149
// Load e.g. qt_de.qm
141-
if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
150+
if (qtTranslatorBase.load("qt_" + lang, translation_path)) {
142151
QApplication::installTranslator(&qtTranslatorBase);
152+
}
143153

144154
// Load e.g. qt_de_DE.qm
145-
if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
155+
if (qtTranslator.load("qt_" + lang_territory, translation_path)) {
146156
QApplication::installTranslator(&qtTranslator);
157+
}
147158

148159
// Load e.g. bitcoin_de.qm (shortcut "de" needs to be defined in dash.qrc)
149-
if (translatorBase.load(lang, ":/translations/"))
160+
if (translatorBase.load(lang, ":/translations/")) {
150161
QApplication::installTranslator(&translatorBase);
162+
}
151163

152164
// Load e.g. bitcoin_de_DE.qm (shortcut "de_DE" needs to be defined in dash.qrc)
153-
if (translator.load(lang_territory, ":/translations/"))
165+
if (translator.load(lang_territory, ":/translations/")) {
154166
QApplication::installTranslator(&translator);
167+
}
155168
}
156169

157170
static bool InitSettings()
@@ -513,9 +526,11 @@ int GuiMain(int argc, char* argv[])
513526
Q_INIT_RESOURCE(dash);
514527
Q_INIT_RESOURCE(dash_locale);
515528

529+
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
516530
// Generate high-dpi pixmaps
517531
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
518532
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
533+
#endif
519534

520535
BitcoinApplication app;
521536
GUIUtil::LoadFont(QStringLiteral(":/fonts/monospace"));

0 commit comments

Comments
 (0)