You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
237 lines
7.1 KiB
237 lines
7.1 KiB
15 years ago
|
/*
|
||
|
* This file is part of the KDE libraries
|
||
13 years ago
|
* Copyright (C) 2003 Benjamin C Meyer (ben+tdelibs at meyerhome dot net)
|
||
15 years ago
|
* Copyright (C) 2003 Waldo Bastian <bastian@kde.org>
|
||
|
*
|
||
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU Library General Public
|
||
|
* License as published by the Free Software Foundation; either
|
||
|
* version 2 of the License, or (at your option) any later version.
|
||
|
*
|
||
|
* This library is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* Library General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Library General Public License
|
||
|
* along with this library; see the file COPYING.LIB. If not, write to
|
||
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
#ifndef KCONFIGDIALOGMANAGER_H
|
||
|
#define KCONFIGDIALOGMANAGER_H
|
||
|
|
||
15 years ago
|
#include <tqobject.h>
|
||
|
#include <tqptrlist.h>
|
||
13 years ago
|
#include "tdelibs_export.h"
|
||
15 years ago
|
|
||
12 years ago
|
class TDEConfigSkeleton;
|
||
|
class TDEConfigSkeletonItem;
|
||
14 years ago
|
class TQWidget;
|
||
|
class TQSqlPropertyMap;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @short Provides a means of automatically retrieving,
|
||
12 years ago
|
* saving and resetting TDEConfigSkeleton based settings in a dialog.
|
||
15 years ago
|
*
|
||
12 years ago
|
* The TDEConfigDialogManager class provides a means of automatically
|
||
15 years ago
|
* 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
|
||
12 years ago
|
* configuration entries in the TDEConfigSkeleton object plus an additional
|
||
15 years ago
|
* "kcfg_" prefix. For example a widget named "kcfg_MyOption" would be
|
||
|
* associated to the configuration entry "MyOption".
|
||
|
*
|
||
12 years ago
|
* TDEConfigDialogManager uses the TQSqlPropertyMap class to determine if it can do
|
||
|
* anything to a widget. Note that TDEConfigDialogManager doesn't require a
|
||
15 years ago
|
* database, it simply uses the functionality that is built into the
|
||
15 years ago
|
* TQSqlPropertyMap class. New widgets can be added to the map using
|
||
|
* TQSqlPropertyMap::installDefaultMap(). Note that you can't just add any
|
||
12 years ago
|
* class. The class must have a matching TQ_PROPERTY(...) macro defined.
|
||
15 years ago
|
*
|
||
|
* For example (note that KColorButton is already added and it doesn't need to
|
||
|
* manually added):
|
||
|
*
|
||
|
* kcolorbutton.h defines the following property:
|
||
|
* \code
|
||
12 years ago
|
* TQ_PROPERTY( TQColor color READ color WRITE setColor )
|
||
15 years ago
|
* \endcode
|
||
|
*
|
||
|
* To add KColorButton the following code would be inserted in the main.
|
||
|
*
|
||
|
* \code
|
||
|
* kapp->installKDEPropertyMap();
|
||
15 years ago
|
* TQSqlPropertyMap *map = TQSqlPropertyMap::defaultMap();
|
||
15 years ago
|
* map->insert("KColorButton", "color");
|
||
|
* \endcode
|
||
|
*
|
||
15 years ago
|
* If you add a new widget to the TQSqlPropertyMap and wish to be notified when
|
||
15 years ago
|
* it is modified you should add its signal using addWidgetChangedSignal().
|
||
|
|
||
|
* @since 3.2
|
||
13 years ago
|
* @author Benjamin C Meyer <ben+tdelibs at meyerhome dot net>
|
||
15 years ago
|
* @author Waldo Bastian <bastian@kde.org>
|
||
|
*/
|
||
12 years ago
|
class TDECORE_EXPORT TDEConfigDialogManager : public TQObject {
|
||
15 years ago
|
|
||
|
Q_OBJECT
|
||
|
|
||
|
signals:
|
||
|
/**
|
||
|
* 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.
|
||
|
*/
|
||
|
void settingsChanged();
|
||
|
|
||
|
/**
|
||
|
* TODO: Verify
|
||
|
* One or more of the settings have been changed.
|
||
|
* @param widget - The widget group (pass in via addWidget()) that
|
||
14 years ago
|
* contains the one or more modified setting.
|
||
15 years ago
|
* @see settingsChanged()
|
||
|
*/
|
||
15 years ago
|
void settingsChanged( TQWidget *widget );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* 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.
|
||
|
*/
|
||
|
void widgetModified();
|
||
|
|
||
|
|
||
|
public:
|
||
|
|
||
|
/**
|
||
|
* Constructor.
|
||
|
* @param parent Dialog widget to manage
|
||
14 years ago
|
* @param conf Object that contains settings
|
||
15 years ago
|
* @param name - Object name.
|
||
|
*/
|
||
12 years ago
|
TDEConfigDialogManager(TQWidget *parent, TDEConfigSkeleton *conf, const char *name=0);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Destructor.
|
||
|
*/
|
||
12 years ago
|
~TDEConfigDialogManager();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Add additional widgets to manage
|
||
|
* @param widget Additional widget to manage, inlcuding all its children
|
||
|
*/
|
||
15 years ago
|
void addWidget(TQWidget *widget);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns whether the current state of the known widgets are
|
||
|
* different from the state in the config object.
|
||
|
*/
|
||
|
bool hasChanged();
|
||
|
|
||
|
/**
|
||
|
* Returns whether the current state of the known widgets are
|
||
|
* the same as the default state in the config object.
|
||
|
*/
|
||
|
bool isDefault();
|
||
|
|
||
|
public slots:
|
||
|
/**
|
||
|
* 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.
|
||
|
*/
|
||
|
void updateSettings();
|
||
|
|
||
|
/**
|
||
|
* 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.
|
||
|
*/
|
||
|
void updateWidgets();
|
||
|
|
||
|
/**
|
||
|
* 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.
|
||
|
*/
|
||
|
void updateWidgetsDefault();
|
||
|
|
||
|
protected:
|
||
|
|
||
|
/**
|
||
|
* @param trackChanges - If any changes by the widgets should be tracked
|
||
|
* set true. This causes the emitting the modified() signal when
|
||
|
* something changes.
|
||
|
* TODO: @return bool - True if any setting was changed from the default.
|
||
|
*/
|
||
|
void init(bool trackChanges);
|
||
|
|
||
|
/**
|
||
14 years ago
|
* Recursive function that finds all known children.
|
||
15 years ago
|
* 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.
|
||
|
* @param widget - Parent of the children to look at.
|
||
|
* @param trackChanges - If true then tracks any changes to the children of
|
||
|
* widget that are known.
|
||
|
* @return bool - If a widget was set to something other then its default.
|
||
|
*/
|
||
15 years ago
|
bool parseChildren(const TQWidget *widget, bool trackChanges);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Set a property
|
||
|
*/
|
||
15 years ago
|
void setProperty(TQWidget *w, const TQVariant &v);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Retrieve a property
|
||
|
*/
|
||
15 years ago
|
TQVariant property(TQWidget *w);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Setup secondary widget properties
|
||
|
*/
|
||
12 years ago
|
void setupWidget(TQWidget *widget, TDEConfigSkeletonItem *item);
|
||
15 years ago
|
|
||
|
protected:
|
||
|
/**
|
||
12 years ago
|
* TDEConfigSkeleton object used to store settings
|
||
15 years ago
|
*/
|
||
12 years ago
|
TDEConfigSkeleton *m_conf;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Dialog being managed
|
||
|
*/
|
||
15 years ago
|
TQWidget *m_dialog;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Pointer to the property map for easy access.
|
||
|
*/
|
||
15 years ago
|
TQSqlPropertyMap *propertyMap;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Map of the classes and the signals that they emit when changed.
|
||
|
*/
|
||
15 years ago
|
TQMap<TQString, TQCString> changedMap;
|
||
15 years ago
|
|
||
|
private:
|
||
|
class Private;
|
||
|
/**
|
||
12 years ago
|
* TDEConfigDialogManager Private class.
|
||
15 years ago
|
*/
|
||
|
Private *d;
|
||
|
|
||
|
};
|
||
|
|
||
|
#endif // KCONFIGDIALOGMANAGER_H
|
||
|
|