This class implements a dialog containing several preference pages. More...

#include <DlgPreferencesImp.h>

Public Member Functions

void accept ()
 
void activateGroupPage (const QString &group, int id)
 Activates the page at position index of the group with name group. More...
 
 DlgPreferencesImp (QWidget *parent=0, Qt::WindowFlags fl=Qt::WindowFlags())
 Constructs a DlgPreferencesImp which is a child of 'parent', with widget flags set to 'fl'. More...
 
 ~DlgPreferencesImp ()
 Destroys the object and frees any allocated resources. More...
 

Static Public Member Functions

static void addPage (const std::string &className, const std::string &group)
 Adds a preference page with its class name className and the group group it belongs to. More...
 
static void removePage (const std::string &className, const std::string &group)
 

Protected Slots

void changeGroup (QListWidgetItem *current, QListWidgetItem *previous)
 
void on_buttonBox_clicked (QAbstractButton *)
 
void resizeWindow (int w, int h)
 

Protected Member Functions

void changeEvent (QEvent *e)
 
void resizeEvent (QResizeEvent *)
 
void showEvent (QShowEvent *)
 

Detailed Description

This class implements a dialog containing several preference pages.

To append your own page you just have to take note of these points:

  • Each preference page can be created by the Qt Designer selecting the "Widget" item in the project dialog.
  • To save or load the widgets' settings automatically (e.g. combo boxes, line edits, check boxes, ...) you can make use of the classes inherited from PrefWidget such as: PrefSpinBox, PrefLineEdit, PrefComboBox, PrefListBox, PrefCheckBox, PrefRadioButton and PrefSlider. If you have compiled and installed the library under src/Tools/plugins/widgets to QTDIR/plugins/designer you should see the new category "Preferences". Moreover you have to make sure to have specified the "prefEntry" and "prefPath" properties for each preference widget you have used inside your form in Qt Designer.
  • For each widget inside your page - you want to save or load - you have to call <objectname>->onSave() or <objectname>->onRestore(). The best way to this is either to define the protected slots saveSettings() and loadSettings() in your form and overwrite them in a subclass or define these slots in this subclass directly.

See the example below for more details:

// This class was created by Qt's uic tool
class MyPrefPage : public QWidget
{
public:
MyPrefPage( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 )
{
myLineEdit->setProperty( "prefEntry", "lineedit" );
myLineEdit->setProperty( "prefPath", "GroupName" );
myCheckBox->setProperty( "prefEntry", "checkbox" );
myCheckBox->setProperty( "prefPath", "GroupName" );
...
}
PrefLineEdit* myLineEdit;
PrefCheckBox* myCheckBox;
};

In the derived class you just have to implement the methods saveSettings() and loadSettings() in the following way:.

class MyPrefPageImp : public MyPrefPage
{
public:
MyPrefPageImp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 )
{
}
protected Q_SLOTS:
void saveSettings()
{
myLineEdit->onSave();
myCheckBox->onSave();
}
void loadSettings();
{
myLineEdit->onRestore();
myCheckBox->onRestore();
}
};
  • Now you have to make the widget factory to know your class by adding the line new PrefPageProducer<MyPrefPageImp> (QT_TR_NOOP("My category"));
See also
PrefWidget
Author
Werner Mayer, J├╝rgen Riegel

Constructor & Destructor Documentation

◆ DlgPreferencesImp()

DlgPreferencesImp::DlgPreferencesImp ( QWidget parent = 0,
Qt::WindowFlags  fl = Qt::WindowFlags() 
)

Constructs a DlgPreferencesImp which is a child of 'parent', with widget flags set to 'fl'.

The dialog will by default be modeless, unless you set 'modal' to true to construct a modal dialog.

References changeGroup(), draftgeoutils.intersections::connect(), and Gui::getMainWindow().

◆ ~DlgPreferencesImp()

DlgPreferencesImp::~DlgPreferencesImp ( )

Destroys the object and frees any allocated resources.

Member Function Documentation

◆ accept()

◆ activateGroupPage()

void DlgPreferencesImp::activateGroupPage ( const QString &  group,
int  id 
)

Activates the page at position index of the group with name group.

Referenced by Gui::Application::sShowPreferences().

◆ addPage()

void DlgPreferencesImp::addPage ( const std::string &  className,
const std::string &  group 
)
static

Adds a preference page with its class name className and the group group it belongs to.

To create this page it must be registered in the WidgetFactory.

See also
WidgetFactory
PrefPageProducer

Referenced by Gui::PrefPageProducer< CLASS >::PrefPageProducer(), Gui::PrefPagePyProducer::PrefPagePyProducer(), and Gui::PrefPageUiProducer::PrefPageUiProducer().

◆ changeEvent()

void DlgPreferencesImp::changeEvent ( QEvent e)
protected

◆ changeGroup

void DlgPreferencesImp::changeGroup ( QListWidgetItem current,
QListWidgetItem previous 
)
protectedslot

Referenced by DlgPreferencesImp().

◆ on_buttonBox_clicked

void DlgPreferencesImp::on_buttonBox_clicked ( QAbstractButton *  btn)
protectedslot

◆ removePage()

void DlgPreferencesImp::removePage ( const std::string &  className,
const std::string &  group 
)
static

◆ resizeEvent()

void DlgPreferencesImp::resizeEvent ( QResizeEvent *  ev)
protected

◆ resizeWindow

void DlgPreferencesImp::resizeWindow ( int  w,
int  h 
)
protectedslot

◆ showEvent()

void DlgPreferencesImp::showEvent ( QShowEvent *  ev)
protected

The documentation for this class was generated from the following files:
  • Sources/FreeCAD/src/Gui/DlgPreferencesImp.h
  • Sources/FreeCAD/src/Gui/DlgPreferencesImp.cpp