digiKam
Digikam::DConfigDlgMngr Class Reference
+ Inheritance diagram for Digikam::DConfigDlgMngr:

Public Slots

void updateSettings ()
 
void updateWidgets ()
 
void updateWidgetsDefault ()
 

Signals

void settingsChanged ()
 
void settingsChanged (QWidget *widget)
 
void widgetModified ()
 

Public Member Functions

void addWidget (QWidget *const widget)
 
 DConfigDlgMngr (QWidget *const parent, KConfigSkeleton *const conf)
 
bool hasChanged () const
 
bool isDefault () const
 
 ~DConfigDlgMngr () override
 

Static Public Member Functions

static QHash< QString, QByteArray > * changedMap ()
 
static QHash< QString, QByteArray > * propertyMap ()
 

Protected Member Functions

QByteArray getCustomProperty (const QWidget *widget) const
 
QByteArray getCustomPropertyChangedSignal (const QWidget *widget) const
 
QByteArray getUserProperty (const QWidget *widget) const
 
QByteArray getUserPropertyChangedSignal (const QWidget *widget) const
 
void init (bool trackChanges)
 
bool parseChildren (const QWidget *widget, bool trackChanges)
 
QVariant property (QWidget *w) const
 
void setProperty (QWidget *w, const QVariant &v)
 
void setupWidget (QWidget *widget, KConfigSkeletonItem *item)
 

Static Protected Member Functions

static void initMaps ()
 

Detailed Description

The DConfigDlgMngr 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 object 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 with the object name "kcfg_MyOption" would be associated to the configuration entry "MyOption".

The widget classes of Qt are supported out of the box.

Custom widget classes are supported if they have a Q_PROPERTY defined for the property representing the value edited by the widget. By default the property is used for which "USER true" is set. For using another property, see below.

Constructor & Destructor Documentation

◆ DConfigDlgMngr()

Digikam::DConfigDlgMngr::DConfigDlgMngr ( QWidget *const  parent,
KConfigSkeleton *const  conf 
)

Constructor.

Parameters
parentDialog widget to manage
confObject that contains settings

References init().

◆ ~DConfigDlgMngr()

Digikam::DConfigDlgMngr::~DConfigDlgMngr ( )
override

Destructor.

Member Function Documentation

◆ addWidget()

void Digikam::DConfigDlgMngr::addWidget ( QWidget *const  widget)

Add additional widgets to manage

Parameters
widgetAdditional widget to manage, including all its children

References parseChildren().

◆ changedMap()

QHash< QString, QByteArray > * Digikam::DConfigDlgMngr::changedMap ( )
static

Retrieve the map between widgets class names and signals that are listened to detect changes in the configuration values.

References initMaps().

◆ getCustomProperty()

QByteArray Digikam::DConfigDlgMngr::getCustomProperty ( const QWidget *  widget) const
protected

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.

Referenced by parseChildren(), property(), setProperty(), and setupWidget().

◆ getCustomPropertyChangedSignal()

QByteArray Digikam::DConfigDlgMngr::getCustomPropertyChangedSignal ( const QWidget *  widget) const
protected

Find the changed signal of the property to use for a widget by querying the "kcfg_propertyNotify" property of the widget. Like a widget can use a property change signal other than the one for USER property, if there even is one.

Referenced by parseChildren().

◆ getUserProperty()

QByteArray Digikam::DConfigDlgMngr::getUserProperty ( const QWidget *  widget) const
protected

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

Referenced by parseChildren(), property(), and setProperty().

◆ getUserPropertyChangedSignal()

QByteArray Digikam::DConfigDlgMngr::getUserPropertyChangedSignal ( const QWidget *  widget) const
protected

Finds the changed signal of the USER property using Qt's MetaProperty system.

Referenced by parseChildren().

◆ hasChanged()

bool Digikam::DConfigDlgMngr::hasChanged ( ) const

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

References property().

Referenced by isDefault().

◆ init()

void Digikam::DConfigDlgMngr::init ( bool  trackChanges)
protected
Parameters
trackChanges- If any changes by the widgets should be tracked set true. This causes the emitting the modified() signal when something changes.

References initMaps(), and parseChildren().

Referenced by DConfigDlgMngr().

◆ initMaps()

void Digikam::DConfigDlgMngr::initMaps ( )
staticprotected

Initializes the property maps

Referenced by changedMap(), init(), and propertyMap().

◆ isDefault()

bool Digikam::DConfigDlgMngr::isDefault ( ) const

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

References hasChanged().

◆ parseChildren()

bool Digikam::DConfigDlgMngr::parseChildren ( const QWidget *  widget,
bool  trackChanges 
)
protected

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.

References getCustomProperty(), getCustomPropertyChangedSignal(), getUserProperty(), getUserPropertyChangedSignal(), setupWidget(), and widgetModified().

Referenced by addWidget(), and init().

◆ property()

QVariant Digikam::DConfigDlgMngr::property ( QWidget *  w) const
protected

Retrieve a property

References getCustomProperty(), and getUserProperty().

Referenced by hasChanged(), setupWidget(), updateSettings(), and updateWidgets().

◆ propertyMap()

QHash< QString, QByteArray > * Digikam::DConfigDlgMngr::propertyMap ( )
static

Retrieve the map between widgets class names and the USER properties used for the configuration values.

References initMaps().

◆ setProperty()

void Digikam::DConfigDlgMngr::setProperty ( QWidget *  w,
const QVariant &  v 
)
protected

Set a property

References getCustomProperty(), and getUserProperty().

Referenced by setupWidget(), and updateWidgets().

◆ settingsChanged [1/2]

void Digikam::DConfigDlgMngr::settingsChanged ( )
signal

One or more of the settings have been saved (such as when the user clicks on the Apply button). This is only emitted by updateSettings() whenever one or more setting were changed and consequently saved.

Referenced by updateSettings().

◆ settingsChanged [2/2]

void Digikam::DConfigDlgMngr::settingsChanged ( QWidget *  widget)
signal

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()

◆ setupWidget()

void Digikam::DConfigDlgMngr::setupWidget ( QWidget *  widget,
KConfigSkeletonItem *  item 
)
protected

Setup secondary widget properties

References getCustomProperty(), property(), and setProperty().

Referenced by parseChildren().

◆ updateSettings

void Digikam::DConfigDlgMngr::updateSettings ( )
slot

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.

References property(), and settingsChanged().

◆ updateWidgets

void Digikam::DConfigDlgMngr::updateWidgets ( )
slot

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.

References property(), setProperty(), and widgetModified().

Referenced by updateWidgetsDefault().

◆ updateWidgetsDefault

void Digikam::DConfigDlgMngr::updateWidgetsDefault ( )
slot

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.

References updateWidgets().

◆ widgetModified

void Digikam::DConfigDlgMngr::widgetModified ( )
signal

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.

Referenced by parseChildren(), and updateWidgets().


The documentation for this class was generated from the following files: