@@ -132,6 +132,11 @@ static std::set<QWidget*> setFixedPitchFontUpdates;
132132// Contains all widgets where a non-default fontsize has been seet with GUIUtil::setFont
133133static std::map<QWidget*, int > mapFontSizeUpdates;
134134
135+ #ifdef Q_OS_MAC
136+ // Contains all widgets where the macOS focus rect has been disabled.
137+ static std::set<QWidget*> setRectsDisabled;
138+ #endif
139+
135140static const std::map<ThemedColor, QColor> themedColors = {
136141 { ThemedColor::DEFAULT, QColor (85 , 85 , 85 ) },
137142 { ThemedColor::UNCONFIRMED, QColor (128 , 128 , 128 ) },
@@ -1025,7 +1030,12 @@ const std::vector<QString> listThemes()
10251030 return vecThemes;
10261031}
10271032
1028- void loadStyleSheet (QWidget* widget, bool fDebugWidget )
1033+ const QString getDefaultTheme ()
1034+ {
1035+ return defaultTheme;
1036+ }
1037+
1038+ void loadStyleSheet (QWidget* widget, bool fForceUpdate )
10291039{
10301040 AssertLockNotHeld (cs_css);
10311041 LOCK (cs_css);
@@ -1036,7 +1046,7 @@ void loadStyleSheet(QWidget* widget, bool fDebugWidget)
10361046 bool fDebugCustomStyleSheets = gArgs .GetBoolArg (" -debug-ui" , false ) && isStyleSheetDirectoryCustom ();
10371047 bool fStyleSheetChanged = false ;
10381048
1039- if (stylesheet == nullptr || fDebugCustomStyleSheets ) {
1049+ if (stylesheet == nullptr || fForceUpdate || fDebugCustomStyleSheets ) {
10401050 auto hasModified = [](const std::vector<QString>& vecFiles) -> bool {
10411051 static std::map<const QString, QDateTime> mapLastModified;
10421052
@@ -1053,7 +1063,7 @@ void loadStyleSheet(QWidget* widget, bool fDebugWidget)
10531063 };
10541064
10551065 auto loadFiles = [&](const std::vector<QString>& vecFiles) -> bool {
1056- if (fDebugCustomStyleSheets && !hasModified (vecFiles)) {
1066+ if (! fForceUpdate && fDebugCustomStyleSheets && !hasModified (vecFiles)) {
10571067 return false ;
10581068 }
10591069
@@ -1086,29 +1096,27 @@ void loadStyleSheet(QWidget* widget, bool fDebugWidget)
10861096 fStyleSheetChanged = loadFiles (vecFiles);
10871097 }
10881098
1089- bool fUpdateStyleSheet = fDebugCustomStyleSheets && fStyleSheetChanged ;
1099+ bool fUpdateStyleSheet = fForceUpdate || ( fDebugCustomStyleSheets && fStyleSheetChanged ) ;
10901100
1091- if (fDebugWidget ) {
1101+ if (widget ) {
10921102 setWidgets.insert (widget);
1093- QWidgetList allWidgets = QApplication::allWidgets ();
1094- auto it = setWidgets.begin ();
1095- while (it != setWidgets.end ()) {
1096- if (!allWidgets.contains (*it)) {
1097- it = setWidgets.erase (it);
1098- continue ;
1099- }
1100- if (fUpdateStyleSheet && *it != widget) {
1101- (*it)->setStyleSheet (*stylesheet);
1102- }
1103- ++it;
1104- }
1103+ widget->setStyleSheet (*stylesheet);
11051104 }
11061105
1107- if (widget) {
1108- widget->setStyleSheet (*stylesheet);
1106+ QWidgetList allWidgets = QApplication::allWidgets ();
1107+ auto it = setWidgets.begin ();
1108+ while (it != setWidgets.end ()) {
1109+ if (!allWidgets.contains (*it)) {
1110+ it = setWidgets.erase (it);
1111+ continue ;
1112+ }
1113+ if (fUpdateStyleSheet && *it != widget) {
1114+ (*it)->setStyleSheet (*stylesheet);
1115+ }
1116+ ++it;
11091117 }
11101118
1111- if (!ShutdownRequested () && fDebugCustomStyleSheets ) {
1119+ if (!ShutdownRequested () && fDebugCustomStyleSheets && ! fForceUpdate ) {
11121120 QTimer::singleShot (200 , [] { loadStyleSheet (); });
11131121 }
11141122}
@@ -1517,12 +1525,36 @@ bool dashThemeActive()
15171525 return theme != traditionalTheme;
15181526}
15191527
1528+ void loadTheme (QWidget* widget, bool fForce )
1529+ {
1530+ loadStyleSheet (widget, fForce );
1531+ updateFonts ();
1532+ updateMacFocusRects ();
1533+ }
1534+
15201535void disableMacFocusRect (const QWidget* w)
15211536{
15221537#ifdef Q_OS_MAC
15231538 for (const auto & c : w->findChildren <QWidget*>()) {
15241539 if (c->testAttribute (Qt::WA_MacShowFocusRect)) {
15251540 c->setAttribute (Qt::WA_MacShowFocusRect, !dashThemeActive ());
1541+ setRectsDisabled.emplace (c);
1542+ }
1543+ }
1544+ #endif
1545+ }
1546+
1547+ void updateMacFocusRects ()
1548+ {
1549+ #ifdef Q_OS_MAC
1550+ QWidgetList allWidgets = QApplication::allWidgets ();
1551+ auto it = setRectsDisabled.begin ();
1552+ while (it != setRectsDisabled.end ()) {
1553+ if (allWidgets.contains (*it)) {
1554+ (*it)->setAttribute (Qt::WA_MacShowFocusRect, !dashThemeActive ());
1555+ ++it;
1556+ } else {
1557+ it = setRectsDisabled.erase (it);
15261558 }
15271559 }
15281560#endif
0 commit comments