Merge pull request #2299 from okrc/okrc-patch-1
Add dark title bar support for Windows 11.
This commit is contained in:
commit
b1a03a6dd1
|
@ -83,6 +83,12 @@ public:
|
||||||
if (theGUI && theConf->GetInt("Options/UseDarkTheme", 2) == 2)
|
if (theGUI && theConf->GetInt("Options/UseDarkTheme", 2) == 2)
|
||||||
theGUI->UpdateTheme();
|
theGUI->UpdateTheme();
|
||||||
}
|
}
|
||||||
|
else if (msg->message == WM_SHOWWINDOW && msg->wParam)
|
||||||
|
{
|
||||||
|
QWidget* pWidget = QWidget::find((WId)msg->hwnd);
|
||||||
|
if (theGUI && pWidget && (pWidget->windowType() | Qt::Dialog) == Qt::Dialog)
|
||||||
|
theGUI->UpdateTitleTheme(msg->hwnd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2919,6 +2925,37 @@ void CSandMan::SetUITheme()
|
||||||
font.setPointSizeF(newFontSize);
|
font.setPointSizeF(newFontSize);
|
||||||
QApplication::setFont(font);
|
QApplication::setFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
foreach(QWidget * pWidget, QApplication::topLevelWidgets())
|
||||||
|
{
|
||||||
|
if (pWidget->isVisible())
|
||||||
|
SetTitleTheme((HWND)pWidget->winId());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSandMan::SetTitleTheme(const HWND& hwnd)
|
||||||
|
{
|
||||||
|
static const int CurrentVersion = QSettings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
|
||||||
|
QSettings::NativeFormat).value("CurrentBuild").toInt();
|
||||||
|
if (CurrentVersion < 22000) // Windows 11-
|
||||||
|
return;
|
||||||
|
|
||||||
|
HMODULE dwmapi = GetModuleHandle(L"dwmapi.dll");
|
||||||
|
if (dwmapi)
|
||||||
|
{
|
||||||
|
typedef HRESULT(WINAPI* P_DwmSetWindowAttribute)(HWND, DWORD, LPCVOID, DWORD);
|
||||||
|
P_DwmSetWindowAttribute pDwmSetWindowAttribute = reinterpret_cast<P_DwmSetWindowAttribute>(GetProcAddress(dwmapi, "DwmSetWindowAttribute"));
|
||||||
|
if (pDwmSetWindowAttribute)
|
||||||
|
{
|
||||||
|
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
||||||
|
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
||||||
|
#endif
|
||||||
|
BOOL value = m_DarkTheme;
|
||||||
|
pDwmSetWindowAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSandMan::UpdateTheme()
|
void CSandMan::UpdateTheme()
|
||||||
|
@ -2930,6 +2967,11 @@ void CSandMan::UpdateTheme()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSandMan::UpdateTitleTheme(const HWND& hwnd)
|
||||||
|
{
|
||||||
|
SetTitleTheme(hwnd);
|
||||||
|
}
|
||||||
|
|
||||||
void CSandMan::LoadLanguage()
|
void CSandMan::LoadLanguage()
|
||||||
{
|
{
|
||||||
QString Lang = theConf->GetString("Options/UiLanguage");
|
QString Lang = theConf->GetString("Options/UiLanguage");
|
||||||
|
|
|
@ -72,6 +72,7 @@ public:
|
||||||
bool CheckCertificate(QWidget* pWidget);
|
bool CheckCertificate(QWidget* pWidget);
|
||||||
|
|
||||||
void UpdateTheme();
|
void UpdateTheme();
|
||||||
|
void UpdateTitleTheme(const HWND& hwnd);
|
||||||
|
|
||||||
void UpdateCertState();
|
void UpdateCertState();
|
||||||
|
|
||||||
|
@ -221,6 +222,7 @@ private slots:
|
||||||
void OnSysTray(QSystemTrayIcon::ActivationReason Reason);
|
void OnSysTray(QSystemTrayIcon::ActivationReason Reason);
|
||||||
|
|
||||||
void SetUITheme();
|
void SetUITheme();
|
||||||
|
void SetTitleTheme(const HWND& hwnd);
|
||||||
|
|
||||||
void AddLogMessage(const QString& Message);
|
void AddLogMessage(const QString& Message);
|
||||||
void AddFileRecovered(const QString& BoxName, const QString& FilePath);
|
void AddFileRecovered(const QString& BoxName, const QString& FilePath);
|
||||||
|
|
Loading…
Reference in New Issue