A text label whose appearance can change based on a specified state. More...
#include <Widgets.h>
Public Slots | |
void | setOverridePreference (bool overridePreference) |
void | setState (QString state) |
Public Member Functions | |
void | OnChange (Base::Subject< const char * > &rCaller, const char *rcReason) |
Observes the parameter group and clears the cache if it changes. More... | |
void | registerState (const QString &state, const QColor &color, const std::string &preferenceName=std::string()) |
For convenience, allow simple color-only states via QColor (optionally attached to a user preference) More... | |
void | registerState (const QString &state, const QColor &foregroundColor, const QColor &backgroundColor, const std::string &preferenceName=std::string()) |
For convenience, allow simple color-only states via QColor (optionally attached to a user preference) More... | |
void | registerState (const QString &state, const QString &styleCSS, const std::string &preferenceName=std::string()) |
Register a state and its corresponding style (optionally attached to a user preference) More... | |
void | setDefaultStyle (const QString &defaultStyle) |
If an unrecognized state is set, use this style. More... | |
void | setParameterGroup (const std::string &groupName) |
If any of the states have user preferences associated with them, this sets the parameter group that stores those preferences. More... | |
StatefulLabel (QWidget *parent=nullptr) | |
virtual | ~StatefulLabel () |
Public Member Functions inherited from Base::Observer< const char * > | |
virtual const char * | Name () |
This method can be reimplemented from the concrete Observer and returns the name of the observer. More... | |
Observer () | |
A constructor. More... | |
virtual void | OnChange (Subject< const char * > &rCaller, const char * rcReason)=0 |
This method need to be reimplemented from the concrete Observer and get called by the observed class. More... | |
virtual void | OnDestroy (Subject< const char * > &rCaller) |
This method need to be reimplemented from the concrete Observer and get called by the observed class. More... | |
virtual | ~Observer () |
A destructor. More... | |
Properties | |
bool | overridePreference |
QString | state |
A text label whose appearance can change based on a specified state.
The state is an arbitrary string exposed as a Qt Property (and thus available for selection via a stylesheet). This is intended for things like messages to the user, where a message that is an "error" might be colored differently than one that is a "warning" or a "message".
In order of style precedence for a given state: User preference > Stylesheet > Default unless the stylesheet sets the overridePreference, in which case the stylesheet will take precedence. If a stylesheet sets styles for this widgets states, it should also set the "handledByStyle" property to ensure the style values are used, rather than the defaults.
For example, the .qss might contain: Gui–StatefulLabel { qproperty-overridePreference: true; } Gui–StatefulLabel[state="special_state"] { color: red; } In this case, StatefulLabels with state "special_state" will be colored red, regardless of any entry in preferences. Use the "overridePreference" stylesheet option with care!
StatefulLabel::StatefulLabel | ( | QWidget * | parent = nullptr | ) |
|
virtual |
|
virtual |
Observes the parameter group and clears the cache if it changes.
Implements Base::Observer< const char * >.
References state.
void StatefulLabel::registerState | ( | const QString & | state, |
const QColor & | color, | ||
const std::string & | preferenceName = std::string() |
||
) |
For convenience, allow simple color-only states via QColor (optionally attached to a user preference)
References state.
void StatefulLabel::registerState | ( | const QString & | state, |
const QColor & | foregroundColor, | ||
const QColor & | backgroundColor, | ||
const std::string & | preferenceName = std::string() |
||
) |
For convenience, allow simple color-only states via QColor (optionally attached to a user preference)
References state.
void StatefulLabel::registerState | ( | const QString & | state, |
const QString & | styleCSS, | ||
const std::string & | preferenceName = std::string() |
||
) |
Register a state and its corresponding style (optionally attached to a user preference)
References state.
void StatefulLabel::setDefaultStyle | ( | const QString & | defaultStyle | ) |
If an unrecognized state is set, use this style.
|
slot |
References overridePreference.
void StatefulLabel::setParameterGroup | ( | const std::string & | groupName | ) |
If any of the states have user preferences associated with them, this sets the parameter group that stores those preferences.
All states must be in the same parameter group, but the group does not have to have entries for all of them.
References Base::Subject< _MessageType >::Attach(), App::GetApplication(), and App::Application::GetParameterGroupByPath().
|
slot |
References state.
|
write |
Referenced by setOverridePreference().
|
write |
Referenced by Mod.Show.mTempoVis.TempoVis::activateWorkbench(), Mod.Show.mTempoVis.TempoVis::forget(), Mod.Show.mTempoVis.TempoVis::modifyVPProperty(), OnChange(), registerState(), femsolver.run.Machine::reset(), Mod.Show.mTempoVis.TempoVis::restore(), femsolver.run.Machine::run(), setState(), and DraftGui.DraftToolBar::switchUi().