Add unit aware preferences widget
This commit is contained in:
@@ -457,6 +457,39 @@ void PrefColorButton::savePreferences()
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
PrefUnitSpinBox::PrefUnitSpinBox ( QWidget * parent )
|
||||
: QuantitySpinBox(parent), PrefWidget()
|
||||
{
|
||||
}
|
||||
|
||||
PrefUnitSpinBox::~PrefUnitSpinBox()
|
||||
{
|
||||
}
|
||||
|
||||
void PrefUnitSpinBox::restorePreferences()
|
||||
{
|
||||
if (getWindowParameter().isNull()) {
|
||||
Console().Warning("Cannot restore!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
double fVal = (double)getWindowParameter()->GetFloat( entryName() ,rawValue() );
|
||||
setValue(fVal);
|
||||
}
|
||||
|
||||
void PrefUnitSpinBox::savePreferences()
|
||||
{
|
||||
if (getWindowParameter().isNull()) {
|
||||
Console().Warning("Cannot save!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
double q = rawValue();
|
||||
getWindowParameter()->SetFloat( entryName(), q );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
namespace Gui {
|
||||
class PrefQuantitySpinBoxPrivate
|
||||
{
|
||||
|
||||
@@ -275,6 +275,28 @@ protected:
|
||||
void savePreferences();
|
||||
};
|
||||
|
||||
/** The PrefUnitSpinBox class.
|
||||
* \author wandererfan
|
||||
* a simple Unit aware spin box.
|
||||
* See also \ref PrefQuantitySpinBox
|
||||
*/
|
||||
class GuiExport PrefUnitSpinBox : public QuantitySpinBox, public PrefWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY( QByteArray prefEntry READ entryName WRITE setEntryName )
|
||||
Q_PROPERTY( QByteArray prefPath READ paramGrpPath WRITE setParamGrpPath )
|
||||
|
||||
public:
|
||||
PrefUnitSpinBox ( QWidget * parent = 0 );
|
||||
virtual ~PrefUnitSpinBox();
|
||||
|
||||
protected:
|
||||
// restore from/save to parameters
|
||||
void restorePreferences();
|
||||
void savePreferences();
|
||||
};
|
||||
|
||||
class PrefQuantitySpinBoxPrivate;
|
||||
|
||||
/**
|
||||
|
||||
@@ -175,6 +175,7 @@ void PreferenceUiForm::loadSettings()
|
||||
loadPrefWidgets<Gui::PrefRadioButton *>();
|
||||
loadPrefWidgets<Gui::PrefSlider *>();
|
||||
loadPrefWidgets<Gui::PrefColorButton *>();
|
||||
loadPrefWidgets<Gui::PrefUnitSpinBox *>();
|
||||
}
|
||||
|
||||
void PreferenceUiForm::saveSettings()
|
||||
@@ -192,6 +193,7 @@ void PreferenceUiForm::saveSettings()
|
||||
savePrefWidgets<Gui::PrefRadioButton *>();
|
||||
savePrefWidgets<Gui::PrefSlider *>();
|
||||
savePrefWidgets<Gui::PrefColorButton *>();
|
||||
savePrefWidgets<Gui::PrefUnitSpinBox *>();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
@@ -96,6 +96,8 @@ WidgetFactorySupplier::WidgetFactorySupplier()
|
||||
new WidgetProducer<Gui::PrefSlider>;
|
||||
new WidgetProducer<Gui::PrefFileChooser>;
|
||||
new WidgetProducer<Gui::PrefColorButton>;
|
||||
new WidgetProducer<Gui::PrefUnitSpinBox>;
|
||||
new WidgetProducer<Gui::PrefQuantitySpinBox>;
|
||||
new WidgetProducer<Gui::CommandIconView>;
|
||||
new WidgetProducer<Gui::AccelLineEdit>;
|
||||
new WidgetProducer<Gui::ActionSelector>;
|
||||
|
||||
Reference in New Issue
Block a user