mirror of
https://git.citron-emu.org/citron/emulator
synced 2025-12-19 18:53:32 +00:00
@@ -49,13 +49,27 @@ static QScrollArea* CreateScrollArea(QWidget* widget) {
|
|||||||
return scroll_area;
|
return scroll_area;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to detect if the application is using a dark theme
|
// Helper function to detect if the application should be in a dark theme state
|
||||||
static bool IsDarkMode() {
|
static bool IsDarkMode() {
|
||||||
const QPalette palette = qApp->palette();
|
const std::string& theme_name = UISettings::values.theme;
|
||||||
const QColor text_color = palette.color(QPalette::WindowText);
|
|
||||||
const QColor base_color = palette.color(QPalette::Window);
|
// Priority 1: Check for explicitly chosen dark themes.
|
||||||
// A common heuristic for dark mode is that the text color is brighter than the background
|
if (theme_name == "qdarkstyle" || theme_name == "colorful_dark" ||
|
||||||
return text_color.value() > base_color.value();
|
theme_name == "qdarkstyle_midnight_blue" || theme_name == "colorful_midnight_blue") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Priority 2: Check for adaptive themes ("default" and "colorful").
|
||||||
|
// For these, we fall back to checking the OS palette.
|
||||||
|
if (theme_name == "default" || theme_name == "colorful") {
|
||||||
|
const QPalette palette = qApp->palette();
|
||||||
|
const QColor text_color = palette.color(QPalette::WindowText);
|
||||||
|
const QColor base_color = palette.color(QPalette::Window);
|
||||||
|
return text_color.value() > base_color.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback for any other unknown theme (assumed light).
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_,
|
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_,
|
||||||
@@ -99,6 +113,8 @@ rainbow_timer{new QTimer(this)} {
|
|||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
last_palette_text_color = qApp->palette().color(QPalette::WindowText);
|
||||||
|
|
||||||
if (!UISettings::values.configure_dialog_geometry.isEmpty()) {
|
if (!UISettings::values.configure_dialog_geometry.isEmpty()) {
|
||||||
restoreGeometry(UISettings::values.configure_dialog_geometry);
|
restoreGeometry(UISettings::values.configure_dialog_geometry);
|
||||||
}
|
}
|
||||||
@@ -272,6 +288,14 @@ void ConfigureDialog::changeEvent(QEvent* event) {
|
|||||||
RetranslateUI();
|
RetranslateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event->type() == QEvent::PaletteChange) {
|
||||||
|
const QColor current_color = qApp->palette().color(QPalette::WindowText);
|
||||||
|
if (current_color != last_palette_text_color) {
|
||||||
|
last_palette_text_color = current_color;
|
||||||
|
UpdateTheme();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QDialog::changeEvent(event);
|
QDialog::changeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user