summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/CMakeLists.txt7
-rw-r--r--src/corelib/text/qlocale_win.cpp27
2 files changed, 32 insertions, 2 deletions
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index 83d26833fe..0320636c29 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -791,11 +791,16 @@ qt_internal_extend_target(Core CONDITION UNIX AND (NACL OR NOT APPLE)
text/qlocale_unix.cpp
)
-qt_internal_extend_target(Core CONDITION WIN32 AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION WIN32
SOURCES
text/qlocale_win.cpp
)
+qt_internal_extend_target(Core CONDITION WIN32 AND MSVC
+ LIBRARIES
+ runtimeobject
+)
+
qt_internal_extend_target(Core CONDITION QT_FEATURE_icu
SOURCES
text/qcollator_icu.cpp
diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp
index ef41eb6bd2..d2dd07e549 100644
--- a/src/corelib/text/qlocale_win.cpp
+++ b/src/corelib/text/qlocale_win.cpp
@@ -51,6 +51,20 @@
# include <time.h>
#endif
+#if defined(Q_CC_MSVC)
+# include <winrt/base.h>
+// Workaround for Windows SDK bug.
+// See https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47
+namespace winrt::impl
+{
+ template <typename Async>
+ auto wait_for(Async const& async, Windows::Foundation::TimeSpan const& timeout);
+}
+# include <winrt/Windows.Foundation.h>
+# include <winrt/Windows.Foundation.Collections.h>
+# include <winrt/Windows.System.UserProfile.h>
+#endif // defined(Q_CC_MSVC)
+
QT_BEGIN_NAMESPACE
static QByteArray getWinLocaleName(LCID id = LOCALE_USER_DEFAULT);
@@ -615,6 +629,18 @@ QVariant QSystemLocalePrivate::toCurrencyString(const QSystemLocale::CurrencyToS
QVariant QSystemLocalePrivate::uiLanguages()
{
+ QStringList result;
+#if defined(Q_CC_MSVC) // msvc supports WinRT calls
+ using namespace winrt;
+ using namespace Windows::Foundation;
+ using namespace Windows::System::UserProfile;
+ auto languages = GlobalizationPreferences::Languages();
+ for (const auto &lang : languages)
+ result << QString::fromStdString(winrt::to_string(lang));
+ if (!result.isEmpty())
+ return result; // else just fall back to WIN32 API implementation
+#endif // defined(Q_CC_MSVC)
+ // mingw and clang still have to use Win32 API
unsigned long cnt = 0;
QVarLengthArray<wchar_t, 64> buf(64);
# if !defined(QT_BOOTSTRAPPED) // Not present in MinGW 4.9/bootstrap builds.
@@ -629,7 +655,6 @@ QVariant QSystemLocalePrivate::uiLanguages()
}
}
# endif // !QT_BOOTSTRAPPED
- QStringList result;
result.reserve(cnt);
const wchar_t *str = buf.constData();
for (; cnt > 0; --cnt) {