@@ -139,6 +139,11 @@ static std::set<QWidget*> setFixedPitchFontUpdates;
139139// Contains all widgets where a non-default fontsize has been seet with GUIUtil::setFont
140140static std::map<QWidget*, int > mapFontSizeUpdates;
141141
142+ #ifdef Q_OS_MAC
143+ // Contains all widgets where the macOS focus rect has been disabled.
144+ static std::set<QWidget*> setRectsDisabled;
145+ #endif
146+
142147static const std::map<ThemedColor, QColor> themedColors = {
143148 { ThemedColor::DEFAULT, QColor (85 , 85 , 85 ) },
144149 { ThemedColor::UNCONFIRMED, QColor (128 , 128 , 128 ) },
@@ -1064,7 +1069,12 @@ const std::vector<QString> listThemes()
10641069 return vecThemes;
10651070}
10661071
1067- void loadStyleSheet (QWidget* widget, bool fDebugWidget )
1072+ const QString getDefaultTheme ()
1073+ {
1074+ return defaultTheme;
1075+ }
1076+
1077+ void loadStyleSheet (QWidget* widget, bool fForceUpdate )
10681078{
10691079 AssertLockNotHeld (cs_css);
10701080 LOCK (cs_css);
@@ -1075,7 +1085,7 @@ void loadStyleSheet(QWidget* widget, bool fDebugWidget)
10751085 bool fDebugCustomStyleSheets = gArgs .GetBoolArg (" -debug-ui" , false ) && isStyleSheetDirectoryCustom ();
10761086 bool fStyleSheetChanged = false ;
10771087
1078- if (stylesheet == nullptr || fDebugCustomStyleSheets ) {
1088+ if (stylesheet == nullptr || fForceUpdate || fDebugCustomStyleSheets ) {
10791089 auto hasModified = [](const std::vector<QString>& vecFiles) -> bool {
10801090 static std::map<const QString, QDateTime> mapLastModified;
10811091
@@ -1092,7 +1102,7 @@ void loadStyleSheet(QWidget* widget, bool fDebugWidget)
10921102 };
10931103
10941104 auto loadFiles = [&](const std::vector<QString>& vecFiles) -> bool {
1095- if (fDebugCustomStyleSheets && !hasModified (vecFiles)) {
1105+ if (! fForceUpdate && fDebugCustomStyleSheets && !hasModified (vecFiles)) {
10961106 return false ;
10971107 }
10981108
@@ -1125,29 +1135,27 @@ void loadStyleSheet(QWidget* widget, bool fDebugWidget)
11251135 fStyleSheetChanged = loadFiles (vecFiles);
11261136 }
11271137
1128- bool fUpdateStyleSheet = fDebugCustomStyleSheets && fStyleSheetChanged ;
1138+ bool fUpdateStyleSheet = fForceUpdate || ( fDebugCustomStyleSheets && fStyleSheetChanged ) ;
11291139
1130- if (fDebugWidget ) {
1140+ if (widget ) {
11311141 setWidgets.insert (widget);
1132- QWidgetList allWidgets = QApplication::allWidgets ();
1133- auto it = setWidgets.begin ();
1134- while (it != setWidgets.end ()) {
1135- if (!allWidgets.contains (*it)) {
1136- it = setWidgets.erase (it);
1137- continue ;
1138- }
1139- if (fUpdateStyleSheet && *it != widget) {
1140- (*it)->setStyleSheet (*stylesheet);
1141- }
1142- ++it;
1143- }
1142+ widget->setStyleSheet (*stylesheet);
11441143 }
11451144
1146- if (widget) {
1147- widget->setStyleSheet (*stylesheet);
1145+ QWidgetList allWidgets = QApplication::allWidgets ();
1146+ auto it = setWidgets.begin ();
1147+ while (it != setWidgets.end ()) {
1148+ if (!allWidgets.contains (*it)) {
1149+ it = setWidgets.erase (it);
1150+ continue ;
1151+ }
1152+ if (fUpdateStyleSheet && *it != widget) {
1153+ (*it)->setStyleSheet (*stylesheet);
1154+ }
1155+ ++it;
11481156 }
11491157
1150- if (!ShutdownRequested () && fDebugCustomStyleSheets ) {
1158+ if (!ShutdownRequested () && fDebugCustomStyleSheets && ! fForceUpdate ) {
11511159 QTimer::singleShot (200 , [] { loadStyleSheet (); });
11521160 }
11531161}
@@ -1556,12 +1564,36 @@ bool dashThemeActive()
15561564 return theme != traditionalTheme;
15571565}
15581566
1567+ void loadTheme (QWidget* widget, bool fForce )
1568+ {
1569+ loadStyleSheet (widget, fForce );
1570+ updateFonts ();
1571+ updateMacFocusRects ();
1572+ }
1573+
15591574void disableMacFocusRect (const QWidget* w)
15601575{
15611576#ifdef Q_OS_MAC
15621577 for (const auto & c : w->findChildren <QWidget*>()) {
15631578 if (c->testAttribute (Qt::WA_MacShowFocusRect)) {
15641579 c->setAttribute (Qt::WA_MacShowFocusRect, !dashThemeActive ());
1580+ setRectsDisabled.emplace (c);
1581+ }
1582+ }
1583+ #endif
1584+ }
1585+
1586+ void updateMacFocusRects ()
1587+ {
1588+ #ifdef Q_OS_MAC
1589+ QWidgetList allWidgets = QApplication::allWidgets ();
1590+ auto it = setRectsDisabled.begin ();
1591+ while (it != setRectsDisabled.end ()) {
1592+ if (allWidgets.contains (*it)) {
1593+ (*it)->setAttribute (Qt::WA_MacShowFocusRect, !dashThemeActive ());
1594+ ++it;
1595+ } else {
1596+ it = setRectsDisabled.erase (it);
15651597 }
15661598 }
15671599#endif
0 commit comments