summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-05-27 10:51:24 -0400
committerBrad King <brad.king@kitware.com>2022-05-27 11:52:51 -0400
commitae13524e3bc116d38fb54770a40e89ae7274540f (patch)
treee0354bdae0d9b206ad8ad46527b103a91d33a259
parentd6bfce26ad59086282c27b090cefa00ccdeed7e7 (diff)
downloadcmake-ae13524e3bc116d38fb54770a40e89ae7274540f.tar.gz
cmake-gui: Restore support for internationalization with Qt5 on Windows
Restore the logic removed by commit 035078d847 (cmake-gui: Remove explicit locale setup, 2020-12-17, v3.20.0-rc1~205^2~6), but only with Qt5 on Windows. Leave a FIXME comment to support Qt6 later. Fixes: #23562 Issue: #23565
-rw-r--r--Source/QtDialog/CMakeSetup.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index 5debdb89b5..b041de928e 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -10,6 +10,15 @@
#include <QTranslator>
#include <QtPlugin>
+// FIXME(#23565): Qt6 has QTextCodec in Core5Compat, but using its
+// `setCodecForLocale` does not make cmake-gui support non-ASCII chars
+// on Windows. For now we only support them with Qt5. How do we support
+// them with Qt6, preferably without Core5Compat?
+#if defined(Q_OS_WIN) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
+# include <QTextCodec>
+# define CMAKE_HAVE_QTEXTCODEC
+#endif
+
#include "cmsys/CommandLineArguments.hxx"
#include "cmsys/Encoding.hxx"
#include "cmsys/SystemTools.hxx"
@@ -121,6 +130,11 @@ int main(int argc, char** argv)
setlocale(LC_NUMERIC, "C");
+#ifdef CMAKE_HAVE_QTEXTCODEC
+ QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8");
+ QTextCodec::setCodecForLocale(utf8_codec);
+#endif
+
// tell the cmake library where cmake is
QDir cmExecDir(QApplication::applicationDirPath());
#if defined(Q_OS_MAC)