KDE 4.9 PyKDE API Reference

- KDE's Python API

# KConfigDialogManager Class Reference

`from PyKDE4.kdeui import *`

Inherits: QObject

## Detailed Description

Provides a means of automatically retrieving, saving and resetting KConfigSkeleton based settings in a dialog.

The KConfigDialogManager class provides a means of automatically retrieving, saving and resetting basic settings. It also can emit signals when settings have been changed (settings were saved) or modified (the user changes a checkbox from on to off).

The names of the widgets to be managed have to correspond to the names of the configuration entries in the KConfigSkeleton object plus an additional "kcfg_" prefix. For example a widget named "kcfg_MyOption" would be associated to the configuration entry "MyOption".

New widgets can be added to the map using the static functions propertyMap() and changedMap(). Note that you can't just add any class. The class must have a matching Q_PROPERTY(...) macro defined, and a signal which emitted when the property changed. Note: by default, the property which defined as "USER true" is used.

For example (note that KColorButton is already added and it doesn't need to manually added):

kcolorbutton.h defines the following property:

     Q_PROPERTY( QColor color READ color WRITE setColor USER true )

and signal:

     void changed( const QColor &newColor );

To add KColorButton the following code would be inserted in the main:

     KConfigDialogManager.changedMap()->insert("KColorButton", SIGNAL(changed(const QColor &)));

If you want to use a widget's property that is not the USER property, you can define which property to use in the widget's kcfg_property:

     KUrlRequester *myWidget = new KUrlRequester;
     myWidget->setProperty("kcfg_property", QByteArray("text"));

Alternatively you can set the kcfg_property using designer.

Author:
  Benjamin C Meyer <ben+kdelibs at meyerhome dot net>

Author:
  Waldo Bastian <bastian@kde.org>

## Signals

| settingsChanged ()
| settingsChanged (QWidget widget)
| widgetModified ()

## Methods

| __init__ (self, QWidget parent, KConfigSkeleton conf)
| __init__ (self, KConfigDialogManager a0)
| __init__ (self, QWidget parent, KCoreConfigSkeleton conf)
| addWidget (self, QWidget widget)
QByteArray | getCustomProperty (self, QWidget widget)
QByteArray | getUserProperty (self, QWidget widget)
bool | hasChanged (self)
| init (self, bool trackChanges)
bool | isDefault (self)
bool | parseChildren (self, QWidget widget, bool trackChanges)
QVariant | property (self, QWidget w)
| setProperty (self, QWidget w, QVariant v)
| setupWidget (self, QWidget widget, KConfigSkeletonItem item)
| updateSettings (self)
| updateWidgets (self)
| updateWidgetsDefault (self)

## Static Methods

{QString:QByteArray} | changedMap ()
| initMaps ()
{QString:QByteArray} | propertyMap ()

## Signal Documentation

settingsChanged | ( |  | ) |

TODO: Verify One or more of the settings have been changed.

Parameters:

  | widget | - The widget group (pass in via addWidget()) that contains the one or more modified setting.

See also:
  settingsChanged()

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

settingsChanged | ( | QWidget | widget
| ) |  |  |

TODO: Verify One or more of the settings have been changed.

Parameters:

  | widget | - The widget group (pass in via addWidget()) that contains the one or more modified setting.

See also:
  settingsChanged()

Signal syntax:
  `QObject.connect(source, SIGNAL("settingsChanged(QWidget*)"), target_slot)`

widgetModified | ( |  | ) |

If retrieveSettings() was told to track changes then if any known setting was changed this signal will be emitted. Note that a settings can be modified several times and might go back to the original saved state. hasChanged() will tell you if anything has actually changed from the saved values.

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

## Method Documentation

__init__ | ( | self, |
|  | QWidget | parent,
|  | KConfigSkeleton | conf
| ) |  |  |

Constructor.

Parameters:

  | parent | Dialog widget to manage
  | conf | Object that contains settings

__init__ | ( | self, |
|  | KConfigDialogManager | a0
| ) |  |  |

__init__ | ( | self, |
|  | QWidget | parent,
|  | KCoreConfigSkeleton | conf
| ) |  |  |

Constructor.

Parameters:

  | parent | Dialog widget to manage
  | conf | Object that contains settings

addWidget | ( | self, |
|  | QWidget | widget
| ) |  |  |

Add additional widgets to manage

Parameters:

  | widget | Additional widget to manage, inlcuding all its children

QByteArray getCustomProperty | ( | self, |
|  | QWidget | widget
| ) |  |  |

Find the property to use for a widget by querying the kcfg_property property of the widget. Like a widget can use a property other than the USER property.

Since:
  4.3

QByteArray getUserProperty | ( | self, |
|  | QWidget | widget
| ) |  |  |

Finds the USER property name using Qt's MetaProperty system, and caches it in the property map (the cache could be retrieved by propertyMap() ).

bool hasChanged | ( |  | self ) |

Returns whether the current state of the known widgets are different from the state in the config object.

init | ( | self, |
|  | bool | trackChanges
| ) |  |  |

Parameters:

  trackChanges

  - If any changes by the widgets should be tracked set true. This causes the emitting the modified() signal when something changes. TODO:
  Returns:
    bool - True if any setting was changed from the default.

bool isDefault | ( |  | self ) |

Returns whether the current state of the known widgets are the same as the default state in the config object.

bool parseChildren | ( | self, |
|  | QWidget | widget,
|  | bool | trackChanges
| ) |  |  |

Recursive function that finds all known children. Goes through the children of widget and if any are known and not being ignored, stores them in currentGroup. Also checks if the widget should be disabled because it is set immutable.

Parameters:

  | widget | - Parent of the children to look at.
  | trackChanges | - If true then tracks any changes to the children of widget that are known.

Returns:
  bool - If a widget was set to something other than its default.

QVariant property | ( | self, |
|  | QWidget | w
| ) |  |  |

Retrieve a property

setProperty | ( | self, |
|  | QWidget | w,
|  | QVariant | v
| ) |  |  |

Set a property

setupWidget | ( | self, |
|  | QWidget | widget,
|  | KConfigSkeletonItem | item
| ) |  |  |

Setup secondary widget properties

updateSettings | ( |  | self ) |

Traverse the specified widgets, saving the settings of all known widgets in the settings object.

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

updateWidgets | ( |  | self ) |

Traverse the specified widgets, sets the state of all known widgets according to the state in the settings object.

Example use: Initialisation of dialog. Example use: User clicks Reset button in a configure dialog.

updateWidgetsDefault | ( |  | self ) |

Traverse the specified widgets, sets the state of all known widgets according to the default state in the settings object.

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

## Static Method Documentation

{QString:QByteArray} changedMap | ( |  | ) |

Retrieve the widget change map

initMaps | ( |  | ) |

Initializes the property maps

{QString:QByteArray} propertyMap | ( |  | ) |

Retrieve the property map