The preference widget class. More...
#include <PrefWidgets.h>
Public Member Functions | |
QByteArray entryName () const | |
Returns the widget's preference name. More... | |
virtual void OnChange (Base::Subject< const char * > &rCaller, const char *sReason) | |
This method is called if one or more values in the parameter settings are changed where getParamGrp() points to. More... | |
void onRestore () | |
Restores the preferences of the widget. More... | |
void onSave () | |
Saves the current preferences of the widget. More... | |
QByteArray paramGrpPath () const | |
Returns the widget's preferences path. More... | |
void setEntryName (const QByteArray &name) | |
Sets the preference name to name. More... | |
void setParamGrpPath (const QByteArray &path) | |
Sets the preference path to path. More... | |
![]() | |
ParameterGrp::handle getWindowParameter (void) | |
return the parameter group of this window More... | |
void OnChange (Base::Subject< const char * > &rCaller, const char *sReason) | |
bool setGroupName (const char *name) | |
Sets the group of the window to name. More... | |
WindowParameter (const char *name) | |
virtual ~WindowParameter () | |
Protected Member Functions | |
void failedToRestore (const QString &) const | |
Print warning that restoring failed. More... | |
void failedToSave (const QString &) const | |
Print warning that saving failed. More... | |
PrefWidget () | |
Constructs a preference widget. More... | |
virtual void restorePreferences ()=0 | |
Restores the preferences Must be reimplemented in any subclasses. More... | |
virtual void savePreferences ()=0 | |
Save the preferences Must be reimplemented in any subclasses. More... | |
virtual ~PrefWidget () | |
Destroys the widget and detaches it from its parameter group. More... | |
Friends | |
class Gui::WidgetFactoryInst | |
Additional Inherited Members | |
![]() | |
static ParameterGrp::handle getDefaultParameter (void) | |
get the parameters More... | |
Detailed Description
The preference widget class.
If you want to extend a QWidget class to save/restore its data you just have to derive from this class and implement the methods restorePreferences() and savePreferences().
To restore and save the settings of any widgets in own dialogs you have call onRestore() e.g. in the dialog's constructor and call onSave() e.g. in accept() for each widget you want to enable this mechanism.
For more information of how to use these widgets in normal container widgets which are again in a dialog refer to the description of Gui::Dialog::DlgPreferencesImp.
Constructor & Destructor Documentation
◆ PrefWidget()
|
protected |
Constructs a preference widget.
◆ ~PrefWidget()
|
protectedvirtual |
Destroys the widget and detaches it from its parameter group.
References Base::Subject< _MessageType >::Detach(), Gui::WindowParameter::getWindowParameter(), and femsolver.elmer.sifio::isValid().
Member Function Documentation
◆ entryName()
QByteArray PrefWidget::entryName | ( | ) | const |
Returns the widget's preference name.
Referenced by onSave(), Gui::PrefSpinBox::restorePreferences(), Gui::PrefDoubleSpinBox::restorePreferences(), Gui::PrefLineEdit::restorePreferences(), Gui::PrefFileChooser::restorePreferences(), Gui::PrefComboBox::restorePreferences(), Gui::PrefCheckBox::restorePreferences(), Gui::PrefRadioButton::restorePreferences(), Gui::PrefSlider::restorePreferences(), Gui::PrefColorButton::restorePreferences(), Gui::PrefUnitSpinBox::restorePreferences(), Gui::PrefFontBox::restorePreferences(), Gui::PrefSpinBox::savePreferences(), Gui::PrefDoubleSpinBox::savePreferences(), Gui::PrefLineEdit::savePreferences(), Gui::PrefFileChooser::savePreferences(), Gui::PrefComboBox::savePreferences(), Gui::PrefCheckBox::savePreferences(), Gui::PrefRadioButton::savePreferences(), Gui::PrefSlider::savePreferences(), Gui::PrefColorButton::savePreferences(), Gui::PrefUnitSpinBox::savePreferences(), and Gui::PrefFontBox::savePreferences().
◆ failedToRestore()
|
protected |
Print warning that restoring failed.
References Base::ConsoleSingleton::Warning().
Referenced by Gui::PrefSpinBox::restorePreferences(), Gui::PrefDoubleSpinBox::restorePreferences(), Gui::PrefLineEdit::restorePreferences(), Gui::PrefFileChooser::restorePreferences(), Gui::PrefComboBox::restorePreferences(), Gui::PrefCheckBox::restorePreferences(), Gui::PrefRadioButton::restorePreferences(), Gui::PrefSlider::restorePreferences(), Gui::PrefColorButton::restorePreferences(), Gui::PrefUnitSpinBox::restorePreferences(), and Gui::PrefFontBox::restorePreferences().
◆ failedToSave()
|
protected |
Print warning that saving failed.
References Base::ConsoleSingleton::Warning().
Referenced by Gui::PrefSpinBox::savePreferences(), Gui::PrefDoubleSpinBox::savePreferences(), Gui::PrefLineEdit::savePreferences(), Gui::PrefFileChooser::savePreferences(), Gui::PrefComboBox::savePreferences(), Gui::PrefCheckBox::savePreferences(), Gui::PrefRadioButton::savePreferences(), Gui::PrefSlider::savePreferences(), Gui::PrefColorButton::savePreferences(), Gui::PrefUnitSpinBox::savePreferences(), and Gui::PrefFontBox::savePreferences().
◆ OnChange()
|
virtual |
This method is called if one or more values in the parameter settings are changed where getParamGrp() points to.
Note: This method is called for each parameter inside the parameter group. So you have to filter out the appropriate parameter with the name sReason. rCaller calls this method.
References restorePreferences().
◆ onRestore()
void PrefWidget::onRestore | ( | ) |
Restores the preferences of the widget.
References Gui::WindowParameter::getWindowParameter(), DraftVecUtils::isNull(), and restorePreferences().
◆ onSave()
void PrefWidget::onSave | ( | ) |
Saves the current preferences of the widget.
All preference widget attached to the same parameter group are notified.
References entryName(), Gui::WindowParameter::getWindowParameter(), femsolver.elmer.sifio::isValid(), Base::Subject< _MessageType >::Notify(), and savePreferences().
◆ paramGrpPath()
QByteArray PrefWidget::paramGrpPath | ( | ) | const |
Returns the widget's preferences path.
Referenced by setParamGrpPath().
◆ restorePreferences()
|
protectedpure virtual |
Restores the preferences Must be reimplemented in any subclasses.
Implemented in Gui::PrefFontBox, Gui::PrefUnitSpinBox, Gui::PrefColorButton, Gui::PrefSlider, Gui::PrefRadioButton, Gui::PrefCheckBox, Gui::PrefComboBox, Gui::PrefFileChooser, Gui::PrefLineEdit, Gui::PrefDoubleSpinBox, and Gui::PrefSpinBox.
Referenced by Gui::WidgetFactoryInst::createPrefWidget(), OnChange(), and onRestore().
◆ savePreferences()
|
protectedpure virtual |
Save the preferences Must be reimplemented in any subclasses.
Implemented in Gui::PrefFontBox, Gui::PrefUnitSpinBox, Gui::PrefColorButton, Gui::PrefSlider, Gui::PrefRadioButton, Gui::PrefCheckBox, Gui::PrefComboBox, Gui::PrefFileChooser, Gui::PrefLineEdit, Gui::PrefDoubleSpinBox, and Gui::PrefSpinBox.
Referenced by onSave().
◆ setEntryName()
void PrefWidget::setEntryName | ( | const QByteArray & | name | ) |
Sets the preference name to name.
Referenced by Gui::WidgetFactoryInst::createPrefWidget().
◆ setParamGrpPath()
void PrefWidget::setParamGrpPath | ( | const QByteArray & | path | ) |
Sets the preference path to path.
References Base::Subject< _MessageType >::Attach(), Base::Console(), Gui::WindowParameter::getWindowParameter(), femsolver.elmer.sifio::isValid(), paramGrpPath(), Gui::WindowParameter::setGroupName(), and Base::ConsoleSingleton::Warning().
Friends And Related Function Documentation
◆ Gui::WidgetFactoryInst
|
friend |
The documentation for this class was generated from the following files:
- src/Gui/PrefWidgets.h
- src/Gui/PrefWidgets.cpp