Manager: Fix style not reacting to Windows light/dark mode change

Add a native event filter for dark mode update, move the function
that queries the current theme to qt_util.cpp and make widgets
with custom stylesheets update their style on update
This commit is contained in:
Alexander Babikov
2025-08-05 20:16:09 +05:00
parent 7bf7d341d4
commit 5de3af3df7
17 changed files with 337 additions and 64 deletions

View File

@@ -18,13 +18,10 @@
#include <QApplication>
#include "qt_util.hpp"
#include "qt_vmmanager_listviewdelegate.hpp"
#include "qt_vmmanager_model.hpp"
#ifdef Q_OS_WINDOWS
extern bool windows_is_light_theme();
#endif
// Thanks to scopchanov https://github.com/scopchanov/SO-MessageLog
// from https://stackoverflow.com/questions/53105343/is-it-possible-to-add-a-custom-widget-into-a-qlistview
@@ -52,7 +49,7 @@ void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewI
const QModelIndex &index) const {
bool windows_light_mode = true;
#ifdef Q_OS_WINDOWS
windows_light_mode = windows_is_light_theme();
windows_light_mode = util::isWindowsLightTheme();
#endif
QStyleOptionViewItem opt(option);
initStyleOption(&opt, index);