From bca761d3585741a3860364afd39f6d49e9fb4988 Mon Sep 17 00:00:00 2001 From: Kevin Hendricks Date: Mon, 15 Apr 2024 10:59:39 -0400 Subject: [PATCH] use QPalette Highlight color for focus highlight on all platforms --- src/MainUI/PreviewWindow.cpp | 12 ++++-------- src/main.cpp | 11 +++-------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/MainUI/PreviewWindow.cpp b/src/MainUI/PreviewWindow.cpp index c15e027470..aea5c9dc13 100644 --- a/src/MainUI/PreviewWindow.cpp +++ b/src/MainUI/PreviewWindow.cpp @@ -552,14 +552,10 @@ bool PreviewWindow::eventFilter(QObject *object, QEvent *event) case QEvent::FocusIn: // track focus in change events of m_Preview (or one of its child focus proxies) if (m_use_focus_highlight) { - // a bit hackish as this should match what we do in main.cpp - // so we should probably create a sigil_constant for this value - // and fix both places to use it -#ifdef Q_OS_MAC - m_wrapper->setStyleSheet("border: 1px solid #2B5FFE;"); -#else - m_wrapper->setStyleSheet("border: 1px solid red"); -#endif + QString focus_qss = "border: 1px solid HIGHLIGHT_COLOR;"; + QString hcolor = palette().color(QPalette::Highlight).name(); + focus_qss.replace("HIGHLIGHT_COLOR", hcolor); + m_wrapper->setStyleSheet(focus_qss); } DBG qDebug() << "focus in event: " << object; break; diff --git a/src/main.cpp b/src/main.cpp index cbc345a9f4..53c3e15f57 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -683,16 +683,11 @@ int main(int argc, char *argv[]) app.setStyleSheet(app.styleSheet().append(MAC_DOCK_TITLEBAR_FIX)); #endif - // allow user to highlight focus widget + // allow user to highlight the focus widget if (settings.uiHighlightFocusWidgetEnabled()) { QString focus_qss = FOCUS_HIGHLIGHT_QSS; - // See PreviewWindow.cpp in the eventFilter routine in FocusIn - // where the same platform constant is used - keep in sync -#ifdef Q_OS_MAC - focus_qss.replace("HIGHLIGHT_COLOR", "#2B5FFE"); -#else //Linux and Windows - focus_qss.replace("HIGHLIGHT_COLOR", "red"); -#endif + QString hcolor = app.palette().color(QPalette::Highlight).name(); + focus_qss.replace("HIGHLIGHT_COLOR", hcolor); app.setStyleSheet(app.styleSheet().append(focus_qss)); }