KDE 4.5 PyKDE API Reference

- KDE's Python API

# KConfigDialog Class Reference

`from PyKDE4.kdeui import *`

Inherits: KPageDialog → KDialog → QDialog → QWidget → QObject

## Detailed Description

Standard KDE configuration dialog class

The KConfigDialog class provides an easy and uniform means of displaying a settings dialog using KPageDialog, 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());
       dialog->setFaceType(KPageDialog.List);
       dialog->addPage(new General(0, "General"), i18n("General") );
       dialog->addPage(new Appearance(0, "Style"), i18n("Appearance") );
       connect(dialog, SIGNAL(settingsChanged(const QString&)), mainWidget, SLOT(loadSettings()));
       connect(dialog, SIGNAL(settingsChanged(const QString&)), 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.

For dialog appearance options (like buttons, default button, ...) please see

See also:
  KPageDialog

See also:
  KConfigSkeleton

Author:
  Waldo Bastian <bastian@kde.org>

## Signals
| settingsChanged (QString dialogName)
| widgetModified ()
## Methods
| __init__ (self, QWidget parent, QString name, KConfigSkeleton config)
| __init__ (self, KConfigDialog a0)
KPageWidgetItem | addPage (self, QWidget page, QString itemName, QString pixmapName=QString(), QString header=QString(), bool manage=1)
KPageWidgetItem | addPage (self, QWidget page, KConfigSkeleton config, QString itemName, QString pixmapName=QString(), QString header=QString())
bool | hasChanged (self)
bool | isDefault (self)
| settingsChangedSlot (self)
| showEvent (self, QShowEvent e)
| updateButtons (self)
| updateSettings (self)
| updateWidgets (self)
| updateWidgetsDefault (self)
## Static Methods
KConfigDialog | exists (QString name)
bool | showDialog (QString name)

## Signal Documentation

settingsChanged | ( | QString | dialogName
| ) |  |  |

One or more of the settings have been permanently changed such as if the user clicked on the Apply or Ok button.

Parameters:

  | dialogName | the name of the dialog.

Signal syntax:
  `QObject.connect(source, SIGNAL("settingsChanged(const QString&)"), target_slot)`

widgetModified | ( |  | ) |

A widget in the dialog was modified.

Signal syntax:
  `QObject.connect(source, SIGNAL("widgetModified()"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QWidget | parent,
|  | QString | name,
|  | KConfigSkeleton | config
| ) |  |  |

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.
  | config | - Config object containing settings.

__init__ | ( | self, |
|  | KConfigDialog | a0
| ) |  |  |

KPageWidgetItem addPage | ( | self, |
|  | QWidget | page,
|  | QString | itemName,
|  | QString | pixmapName=QString(),
|  | QString | header=QString(),
|  | bool | manage=1
| ) |  |  |

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.

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.

Returns:
  The KPageWidgetItem associated with the page.

KPageWidgetItem addPage | ( | self, |
|  | QWidget | page,
|  | KConfigSkeleton | config,
|  | QString | itemName,
|  | QString | pixmapName=QString(),
|  | QString | header=QString()
| ) |  |  |

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.

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.

Returns:
  The KPageWidgetItem associated with the page.

bool hasChanged | ( |  | self ) |

Returns whether the current state of the dialog is different from the current configuration. Virtual function for custom additions.

bool isDefault | ( |  | self ) |

Returns whether the current state of the dialog is the same as the default configuration.

settingsChangedSlot | ( |  | self ) |

Some setting was changed. Emit the signal with the dialogs name. Connect to this slot if there are widgets not managed by KConfig.

Since:
  4.3

showEvent | ( | self, |
|  | QShowEvent | e
| ) |  |  |

Internal:

updateButtons | ( |  | self ) |

Updates the Apply and Default buttons. Connect to this slot if you implement you own hasChanged() or isDefault() methods for widgets not managed by KConfig.

Since:
  4.3

updateSettings | ( |  | self ) |

Update the settings from the dialog. Virtual function for custom additions.

Example use: User clicks Ok or Apply button in a configure dialog.

updateWidgets | ( |  | self ) |

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.

updateWidgetsDefault | ( |  | self ) |

Update the dialog based on the default settings. Virtual function for custom additions.

Example use: User clicks Defaults button in a configure dialog.

## Static Method Documentation

KConfigDialog exists | ( | QString | name
| ) |  |  |

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.

bool showDialog | ( | QString | name
| ) |  |  |

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.