Merge pull request #8488 from tinyredpanda/simplify-wstring-conversion

Simplify wstring to QString conversion
This commit is contained in:
Léo Lam 2019-11-24 00:17:32 +01:00 committed by GitHub
commit 3a2d3aa9d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 15 deletions

View File

@ -231,15 +231,14 @@ void CompatPatchesInstall(LdrWatcher* watcher)
return; return;
} }
// If we reach here, the version is buggy (afaik) and patching failed // If we reach here, the version is buggy (afaik) and patching failed
const auto msg = const auto msg = fmt::format(
fmt::format("You are running {} version {}.{}.{}.{}.\n" L"You are running {} version {}.{}.{}.{}.\n"
"An important fix affecting Dolphin was introduced in build {}.\n" L"An important fix affecting Dolphin was introduced in build {}.\n"
"You can use Dolphin, but there will be known bugs.\n" L"You can use Dolphin, but there will be known bugs.\n"
"Please update this file by installing the latest Universal C Runtime.\n", L"Please update this file by installing the latest Universal C Runtime.\n",
UTF16ToUTF8(event.name), version.major, version.minor, version.build, event.name, version.major, version.minor, version.build, version.qfe, fixed_build);
version.qfe, fixed_build);
// Use MessageBox for maximal user annoyance // Use MessageBox for maximal user annoyance
MessageBoxA(nullptr, msg.c_str(), "WARNING: BUGGY UCRT VERSION", MB_ICONEXCLAMATION); MessageBoxW(nullptr, msg.c_str(), L"WARNING: BUGGY UCRT VERSION", MB_ICONEXCLAMATION);
}}); }});
} }

View File

@ -5,8 +5,6 @@
#ifdef _WIN32 #ifdef _WIN32
#include <Windows.h> #include <Windows.h>
#include <cstdio> #include <cstdio>
#include "Common/StringUtil.h"
#endif #endif
#include <OptionParser.h> #include <OptionParser.h>
@ -104,16 +102,16 @@ int main(int argc, char* argv[])
#ifdef _WIN32 #ifdef _WIN32
// Get the default system font because Qt's way of obtaining it is outdated // Get the default system font because Qt's way of obtaining it is outdated
NONCLIENTMETRICS metrics = {}; NONCLIENTMETRICSW metrics = {};
LOGFONT& logfont = metrics.lfMenuFont; LOGFONTW& logfont = metrics.lfMenuFont;
metrics.cbSize = sizeof(NONCLIENTMETRICS); metrics.cbSize = sizeof(metrics);
if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(metrics), &metrics, 0)) if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(metrics), &metrics, 0))
{ {
// Sadly Qt 5 doesn't support turning a native font handle into a QFont so this is the next best // Sadly Qt 5 doesn't support turning a native font handle into a QFont so this is the next best
// thing // thing
QFont font = QApplication::font(); QFont font = QApplication::font();
font.setFamily(QString::fromStdString(UTF16ToUTF8(logfont.lfFaceName))); font.setFamily(QString::fromStdWString(logfont.lfFaceName));
font.setItalic(logfont.lfItalic); font.setItalic(logfont.lfItalic);
font.setStrikeOut(logfont.lfStrikeOut); font.setStrikeOut(logfont.lfStrikeOut);