Skip to content

Commit

Permalink
use QPalette Highlight color for focus highlight on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhendricks committed Apr 15, 2024
1 parent 8689b0a commit bca761d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
12 changes: 4 additions & 8 deletions src/MainUI/PreviewWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 3 additions & 8 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit bca761d

Please sign in to comment.