[Gui] Add ability for stylesheet to override prefs

This commit is contained in:
Chris Hennes
2021-10-06 11:43:06 -05:00
parent 75ee123794
commit 3c463d8b78
2 changed files with 29 additions and 1 deletions

View File

@@ -893,6 +893,7 @@ void UrlLabel::setUrl(const QString& u)
StatefulLabel::StatefulLabel(QWidget* parent)
: QLabel(parent)
, _overridePreference(false)
{
// Always attach to the parameter group that stores the main FreeCAD stylesheet
_stylesheetGroup = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General");
@@ -957,10 +958,20 @@ void StatefulLabel::OnChange(Base::Subject<const char*>& rCaller, const char* rc
}
}
void StatefulLabel::setOverridePreference(bool overridePreference)
{
_overridePreference = overridePreference;
}
void StatefulLabel::setState(QString state)
{
_state = state;
std::string stateIn = state.toStdString();
this->ensurePolished();
// If the stylesheet insists, ignore all other logic and let it do its thing. This
// property is *only* set by the stylesheet.
if (_overridePreference)
return;
// Check the cache first:
if (auto style = _styleCache.find(_state); style != _styleCache.end()) {