summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuhang Zhao <yuhangzhao@deepin.org>2023-06-24 13:46:48 +0800
committerYuhang Zhao <yuhangzhao@deepin.org>2023-06-28 05:13:57 +0000
commit27c4e4c4f58fbb1d01cd152b154d4ed21e2c5264 (patch)
treef080886b396519f823b96f2bdf3c1e53ccdd196a
parent779e4cc0b0ed5c3f6958dc4a856277e6c908f8f9 (diff)
Windows QPA: minor code simplification
Simplify the code a little bit. Change-Id: I7fdb14e676c5b0aa8752b6ee17f0644056ddfcea Reviewed-by: Timothée Keller <timothee.keller@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
-rw-r--r--src/plugins/styles/windowsvista/qwindowsvistastyle.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
index 0d5e0837be..fd099d642d 100644
--- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
+++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
@@ -20,6 +20,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static const int windowsItemFrame = 2; // menu item frame width
static const int windowsItemHMargin = 3; // menu item hor text margin
static const int windowsItemVMargin = 4; // menu item ver text margin
@@ -225,23 +227,15 @@ HTHEME QWindowsVistaStylePrivate::openThemeForPrimaryScreenDpi(HWND hwnd, const
{
// We want to call OpenThemeDataForDpi, but it won't link with MinGW (11.2.0), so we
// dynamically load this.
- using FuncThemeDpi = decltype(&::OpenThemeDataForDpi);
-
- // Only try to initialize openThemeForDpiFunc once. If it fails, it will likely keep failing.
- const FuncThemeDpi uninitializedFunction = reinterpret_cast<FuncThemeDpi>(1);
- static FuncThemeDpi openThemeForDpiFunc = uninitializedFunction;
- if (openThemeForDpiFunc == uninitializedFunction) {
- QSystemLibrary uxthemeLib(L"uxtheme.dll");
- openThemeForDpiFunc = reinterpret_cast<FuncThemeDpi>(uxthemeLib.resolve("OpenThemeDataForDpi"));
- if (!openThemeForDpiFunc) {
- qWarning() << "QWindowsVistaStylePrivate: Load OpenThemeDataForDpi in uxtheme.dll failed";
- }
- }
+ // Only try to initialize pOpenThemeDataForDpi once. If it fails, it will likely keep failing.
+ static const auto pOpenThemeDataForDpi =
+ reinterpret_cast<decltype(&::OpenThemeDataForDpi)>(
+ QSystemLibrary::resolve(u"uxtheme"_s, "OpenThemeDataForDpi"));
- // If we have screens and the openThemeDataForDpi function then use it :).
- if (openThemeForDpiFunc && QGuiApplication::primaryScreen()) {
+ // If we have screens and the OpenThemeDataForDpi function then use it :).
+ if (pOpenThemeDataForDpi && QGuiApplication::primaryScreen()) {
const int dpi = qRound(QGuiApplication::primaryScreen()->handle()->logicalDpi().first);
- return openThemeForDpiFunc(hwnd, name, dpi);
+ return pOpenThemeDataForDpi(hwnd, name, dpi);
}
// In case of any issues we fall back to use the plain/old OpenThemeData.