format code

This commit is contained in:
dranik
2026-05-29 22:57:54 +03:00
parent 446e7b6a8e
commit 7eecc3667f
+19 -18
View File
@@ -12,30 +12,29 @@
#include "logger.h" #include "logger.h"
namespace namespace {
Logger logger("WindowsUtils");
constexpr const wchar_t kThemeWatcherClassName[] = L"AmneziaVpnThemeWatcher";
struct ThemeObserverState
{ {
Logger logger("WindowsUtils");
constexpr const wchar_t kThemeWatcherClassName[] = L"AmneziaVpnThemeWatcher";
struct ThemeObserverState
{
std::function<void()> callback; std::function<void()> callback;
HWND hwnd = nullptr; HWND hwnd = nullptr;
}; };
ThemeObserverState g_themeObserver; ThemeObserverState g_themeObserver;
bool registryUsesDarkTheme(const QSettings &settings, const QString &lightThemeKey) bool registryUsesDarkTheme(const QSettings &settings, const QString &lightThemeKey)
{ {
if (settings.contains(lightThemeKey)) { if (settings.contains(lightThemeKey)) {
return settings.value(lightThemeKey).toInt() != 1; return settings.value(lightThemeKey).toInt() != 1;
} }
return false; return false;
} }
LRESULT CALLBACK themeWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK themeWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
Q_UNUSED(wParam); Q_UNUSED(wParam);
if (msg == WM_SETTINGCHANGE && lParam != 0) { if (msg == WM_SETTINGCHANGE && lParam != 0) {
@@ -48,7 +47,7 @@ namespace
} }
return DefWindowProcW(hwnd, msg, wParam, lParam); return DefWindowProcW(hwnd, msg, wParam, lParam);
} }
} // namespace } // namespace
constexpr const int WINDOWS_11_BUILD = constexpr const int WINDOWS_11_BUILD =
@@ -56,9 +55,11 @@ constexpr const int WINDOWS_11_BUILD =
QString WindowsUtils::getErrorMessage(quint32 code) { QString WindowsUtils::getErrorMessage(quint32 code) {
LPSTR messageBuffer = nullptr; LPSTR messageBuffer = nullptr;
size_t size = size_t size = FormatMessageA(
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
nullptr, code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, nullptr); FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr, code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&messageBuffer, 0, nullptr);
std::string message(messageBuffer, size); std::string message(messageBuffer, size);
QString result(message.c_str()); QString result(message.c_str());