kdeui
KConfigDialog Class Reference
Standard KDE configuration dialog class. More...
#include <kconfigdialog.h>
Signals | |
void | settingsChanged (const char *dialogName) |
void | settingsChanged () |
void | widgetModified () |
Public Member Functions | |
void | addPage (QWidget *page, KConfigSkeleton *config, const QString &itemName, const QString &pixmapName, const QString &header=QString::null) |
void | addPage (QWidget *page, const QString &itemName, const QString &pixmapName, const QString &header=QString::null, bool manage=true) |
KConfigDialog (QWidget *parent, const char *name, KConfigSkeleton *config, DialogType dialogType=IconList, int dialogButtons=Default|Ok|Apply|Cancel|Help, ButtonCode defaultButton=Ok, bool modal=false) | |
virtual void | show () |
~KConfigDialog () | |
Static Public Member Functions | |
static KConfigDialog * | exists (const char *name) |
static bool | showDialog (const char *name) |
Protected Slots | |
void | settingsChangedSlot () |
void | updateButtons () |
virtual void | updateSettings () |
virtual void | updateWidgets () |
virtual void | updateWidgetsDefault () |
Protected Member Functions | |
virtual bool | hasChanged () |
virtual bool | isDefault () |
Detailed Description
Standard KDE configuration dialog class.The KConfigDialog class provides an easy and uniform means of displaying a settings dialog using KDialogBase, KConfigDialogManager and a KConfigSkeleton derived settings class.
KConfigDialog handles the enabling and disabling of buttons, creation of the dialog, and deletion of the widgets. Because of KConfigDialogManager, this class also manages: restoring the settings, reseting them to the default values, and saving them. This requires that the names of the widgets corresponding to configuration entries have to have the same name plus an additional "kcfg_" prefix. For example the widget named "kcfg_MyOption" would be associated with the configuration entry "MyOption".
Here is an example usage of KConfigDialog:
void KCoolApp::showSettings(){ if(KConfigDialog::showDialog("settings")) return; KConfigDialog *dialog = new KConfigDialog(this, "settings", MySettings::self(), KDialogBase::IconList); dialog->addPage(new General(0, "General"), i18n("General") ); dialog->addPage(new Appearance(0, "Style"), i18n("Appearance") ); connect(dialog, SIGNAL(settingsChanged()), mainWidget, SLOT(loadSettings())); connect(dialog, SIGNAL(settingsChanged()), this, SLOT(loadSettings())); dialog->show(); }
Other than the above code, each class that has settings in the dialog should have a loadSettings() type slot to read settings and perform any necessary changes.
Please note that using the setMainWidget method inherited from KDialogBase currently yields broken behaviour at runtime; use addPage() instead.
- See also:
- KConfigSkeleton
- Since:
- 3.2
Definition at line 72 of file kconfigdialog.h.
Constructor & Destructor Documentation
KConfigDialog::KConfigDialog | ( | QWidget * | parent, | |
const char * | name, | |||
KConfigSkeleton * | config, | |||
DialogType | dialogType = IconList , |
|||
int | dialogButtons = Default|Ok|Apply|Cancel|Help , |
|||
ButtonCode | defaultButton = Ok , |
|||
bool | modal = false | |||
) |
- Parameters:
-
parent - The parent of this object. Even though the class deletes itself the parent should be set so the dialog can be centered with the application on the screen. name - The name of this object. The name is used in determining if there can be more than one dialog at a time. Use names such as: "Font Settings" or "Color Settings" and not just "Settings" in applications where there is more than one dialog. dialogType - Type used in creating the dialog. See KDialogBase config - Config object containing settings. dialogButtons - Buttons that should show up on the dialog. defaultButton default button that is choosen by hitting the enter key. modal - Whether the dialog should be modal. To prevent more than one non-modal settings dialog from showing the static function showDialog() can be used in determining if the settings dialog already exists before creating a new KConfigDialog object.
Definition at line 49 of file kconfigdialog.cpp.
KConfigDialog::~KConfigDialog | ( | ) |
Deconstructor, removes name from the list of open dialogs.
Deletes private class.
- See also:
- exists()
Definition at line 80 of file kconfigdialog.cpp.
Member Function Documentation
void KConfigDialog::addPage | ( | QWidget * | page, | |
KConfigSkeleton * | config, | |||
const QString & | itemName, | |||
const QString & | pixmapName, | |||
const QString & | header = QString::null | |||
) |
Adds page to the dialog that is managed by a custom KConfigDialogManager.
This is useful for dialogs that contain settings spread over more than one configuration file and thus have/need more than one KConfigSkeleton. When an application is done adding pages show() should be called to display the dialog. Note that after you call show() you can not add any more pages to the dialog.
- Parameters:
-
page - Pointer to the page that is to be added to the dialog. This object is reparented. config - Config object containing corresponding settings. itemName - Name of the page. pixmapName - Name of the pixmap that should be used if needed. header - Header text use in the list modes. Ignored in Tabbed mode. If empty, the itemName text is used when needed.
Definition at line 97 of file kconfigdialog.cpp.
void KConfigDialog::addPage | ( | QWidget * | page, | |
const QString & | itemName, | |||
const QString & | pixmapName, | |||
const QString & | header = QString::null , |
|||
bool | manage = true | |||
) |
Adds page to the dialog and to KConfigDialogManager.
When an application is done adding pages show() should be called to display the dialog. Note that after you call show() you can not add any more pages to the dialog.
- Parameters:
-
page - Pointer to the page that is to be added to the dialog. This object is reparented. itemName - Name of the page. pixmapName - Name of the pixmap that should be used if needed. header - Header text use in the list modes. Ignored in Tabbed mode. If empty, the itemName text is used when needed. manage - Whether KConfigDialogManager should manage the page or not.
Definition at line 86 of file kconfigdialog.cpp.
KConfigDialog * KConfigDialog::exists | ( | const char * | name | ) | [static] |
See if a dialog with the name 'name' already exists.
- See also:
- showDialog()
- Parameters:
-
name - Dialog name to look for.
- Returns:
- Pointer to widget or NULL if it does not exist.
Definition at line 161 of file kconfigdialog.cpp.
virtual bool KConfigDialog::hasChanged | ( | ) | [inline, protected, virtual] |
Returns whether the current state of the dialog is different from the current configutation.
Virtual function for custom additions.
Definition at line 233 of file kconfigdialog.h.
virtual bool KConfigDialog::isDefault | ( | ) | [inline, protected, virtual] |
Returns whether the current state of the dialog is the same as the default configuration.
Definition at line 239 of file kconfigdialog.h.
void KConfigDialog::settingsChanged | ( | const char * | dialogName | ) | [signal] |
One or more of the settings have been permanently changed such as if the user clicked on the Apply or Ok button.
This signal is useful when using KConfigDialog to configure items in a list. When emitted the main class would then know what item in the list was actually changed.
- Parameters:
-
dialogName the name of the dialog.
void KConfigDialog::settingsChanged | ( | ) | [signal] |
One or more of the settings have been permanently changed such as if the user clicked on the Apply or Ok button.
void KConfigDialog::settingsChangedSlot | ( | ) | [protected, slot] |
Some setting was changed.
Emit the signal with the dialogs name
Definition at line 206 of file kconfigdialog.cpp.
void KConfigDialog::show | ( | void | ) | [virtual] |
bool KConfigDialog::showDialog | ( | const char * | name | ) | [static] |
Attempts to show the dialog with the name 'name'.
- See also:
- exists()
- Parameters:
-
name - The name of the dialog to show.
- Returns:
- True if the dialog 'name' exists and was shown.
Definition at line 166 of file kconfigdialog.cpp.
void KConfigDialog::updateButtons | ( | ) | [protected, slot] |
void KConfigDialog::updateSettings | ( | ) | [protected, virtual, slot] |
Update the settings from the dialog.
Virtual function for custom additions.
Example use: User clicks Ok or Apply button in a configure dialog.
Definition at line 246 of file kconfigdialog.cpp.
void KConfigDialog::updateWidgets | ( | ) | [protected, virtual, slot] |
Update the dialog based on the settings.
Virtual function for custom additions.
Example use: Initialisation of dialog. Example use: User clicks Reset button in a configure dialog.
Definition at line 250 of file kconfigdialog.cpp.
void KConfigDialog::updateWidgetsDefault | ( | ) | [protected, virtual, slot] |
Update the dialog based on the default settings.
Virtual function for custom additions.
Example use: User clicks Defaults button in a configure dialog.
Definition at line 254 of file kconfigdialog.cpp.
void KConfigDialog::widgetModified | ( | ) | [signal] |
A widget in the dialog was modified.
The documentation for this class was generated from the following files: