22 #include "tdeconfigdialogmanager.h"
24 #include <tqbuttongroup.h>
25 #include <tqcombobox.h>
27 #include <tqmetaobject.h>
28 #include <tqobjectlist.h>
29 #include <tqsqlpropertymap.h>
31 #include <tqwhatsthis.h>
33 #include <tdeapplication.h>
34 #include <tdeconfigskeleton.h>
36 #include <tdeglobal.h>
40 class TDEConfigDialogManager::Private {
43 Private() : insideGroupBox(false) { }
46 TQDict<TQWidget> knownWidget;
47 TQDict<TQWidget> buddyWidget;
52 : TQObject(parent, name), m_conf(conf), m_dialog(parent)
56 kapp->installKDEPropertyMap();
72 changedMap.insert(TQBUTTON_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(
int)));
73 changedMap.insert(TQCHECKBOX_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(
int)));
74 changedMap.insert(TQPUSHBUTTON_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(
int)));
75 changedMap.insert(TQRADIOBUTTON_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(
int)));
78 changedMap.insert(TQBUTTONGROUP_OBJECT_NAME_STRING, TQT_SIGNAL(clicked(
int)));
79 changedMap.insert(TQGROUPBOX_OBJECT_NAME_STRING, TQT_SIGNAL(toggled(
bool)));
80 changedMap.insert(TQCOMBOBOX_OBJECT_NAME_STRING, TQT_SIGNAL(activated (
int)));
83 changedMap.insert(TQDATEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(
const TQDate &)));
84 changedMap.insert(TQDATETIMEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(
const TQDateTime &)));
85 changedMap.insert(TQDIAL_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged (
int)));
86 changedMap.insert(TQLINEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged(
const TQString &)));
87 changedMap.insert(TQSLIDER_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(
int)));
88 changedMap.insert(TQSPINBOX_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(
int)));
89 changedMap.insert(TQTIMEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(
const TQTime &)));
90 changedMap.insert(TQTEXTEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged()));
91 changedMap.insert(TQTEXTBROWSER_OBJECT_NAME_STRING, TQT_SIGNAL(sourceChanged(
const TQString &)));
92 changedMap.insert(TQMULTILINEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged()));
93 changedMap.insert(TQLISTBOX_OBJECT_NAME_STRING, TQT_SIGNAL(selectionChanged()));
94 changedMap.insert(TQTABWIDGET_OBJECT_NAME_STRING, TQT_SIGNAL(currentChanged(TQWidget *)));
97 changedMap.insert(
"KComboBox", TQT_SIGNAL(activated (
int)));
98 changedMap.insert(
"TDEFontCombo", TQT_SIGNAL(activated (
int)));
99 changedMap.insert(
"TDEFontRequester", TQT_SIGNAL(fontSelected(
const TQFont &)));
100 changedMap.insert(
"TDEFontChooser", TQT_SIGNAL(fontSelected(
const TQFont &)));
101 changedMap.insert(
"KHistoryCombo", TQT_SIGNAL(activated (
int)));
103 changedMap.insert(
"KColorButton", TQT_SIGNAL(changed(
const TQColor &)));
104 changedMap.insert(
"KDatePicker", TQT_SIGNAL(dateSelected (TQDate)));
105 changedMap.insert(
"KDateWidget", TQT_SIGNAL(changed (TQDate)));
106 changedMap.insert(
"KDateTimeWidget", TQT_SIGNAL(valueChanged (
const TQDateTime &)));
107 changedMap.insert(
"KEditListBox", TQT_SIGNAL(changed()));
108 changedMap.insert(
"TDEListBox", TQT_SIGNAL(selectionChanged()));
109 changedMap.insert(
"KLineEdit", TQT_SIGNAL(textChanged(
const TQString &)));
110 changedMap.insert(
"KPasswordEdit", TQT_SIGNAL(textChanged(
const TQString &)));
111 changedMap.insert(
"KRestrictedLine", TQT_SIGNAL(textChanged(
const TQString &)));
112 changedMap.insert(
"KTextBrowser", TQT_SIGNAL(sourceChanged(
const TQString &)));
113 changedMap.insert(
"KTextEdit", TQT_SIGNAL(textChanged()));
114 changedMap.insert(
"KURLRequester", TQT_SIGNAL(textChanged (
const TQString& )));
115 changedMap.insert(
"KIntNumInput", TQT_SIGNAL(valueChanged (
int)));
116 changedMap.insert(
"KIntSpinBox", TQT_SIGNAL(valueChanged (
int)));
117 changedMap.insert(
"KDoubleNumInput", TQT_SIGNAL(valueChanged (
double)));
131 TQVariant minValue = item->
minValue();
132 if (minValue.isValid())
134 if (widget->metaObject()->findProperty(
"minValue",
true) != -1)
135 widget->setProperty(
"minValue", minValue);
137 TQVariant maxValue = item->
maxValue();
138 if (maxValue.isValid())
140 if (widget->metaObject()->findProperty(
"maxValue",
true) != -1)
141 widget->setProperty(
"maxValue", maxValue);
143 if (TQWhatsThis::textFor( widget ).isEmpty())
146 if ( !whatsThis.isEmpty() )
148 TQWhatsThis::add( widget, whatsThis );
155 bool valueChanged =
false;
156 const TQObjectList listOfChildren = widget->childrenListObject();
157 if(listOfChildren.isEmpty())
161 for( TQObjectListIterator it( listOfChildren );
162 (
object = it.current()); ++it )
164 if(!object->isWidgetType())
167 TQWidget *childWidget = (TQWidget *)
object;
169 const char *widgetName = childWidget->name(0);
170 bool bParseChildren =
true;
171 bool bSaveInsideGroupBox = d->insideGroupBox;
173 if (widgetName && (strncmp(widgetName,
"kcfg_", 5) == 0))
176 TQString configId = widgetName+5;
180 d->knownWidget.insert(configId, childWidget);
184 TQMap<TQString, TQCString>::const_iterator changedIt =
changedMap.find(childWidget->className());
192 changedIt =
changedMap.find(childWidget->metaObject()->superClassName());
197 kdWarning(178) <<
"Don't know how to monitor widget '" << childWidget->className() <<
"' for changes!" <<
endl;
201 connect(childWidget, *changedIt,
204 TQGroupBox *gb =
dynamic_cast<TQGroupBox *
>(childWidget);
206 bParseChildren =
false;
208 d->insideGroupBox =
true;
210 TQComboBox *cb =
dynamic_cast<TQComboBox *
>(childWidget);
211 if (cb && cb->editable())
212 connect(cb, TQT_SIGNAL(textChanged(
const TQString &)),
218 kdWarning(178) <<
"A widget named '" << widgetName <<
"' was found but there is no setting named '" << configId <<
"'" <<
endl;
221 else if (childWidget->inherits(TQLABEL_OBJECT_NAME_STRING))
223 TQLabel *label =
static_cast<TQLabel *
>(childWidget);
224 TQWidget *buddy = label->buddy();
227 const char *buddyName = buddy->name(0);
228 if (buddyName && (strncmp(buddyName,
"kcfg_", 5) == 0))
231 TQString configId = buddyName+5;
232 d->buddyWidget.insert(configId, childWidget);
238 TQMap<TQString, TQCString>::const_iterator changedIt =
changedMap.find(childWidget->className());
241 if ((!d->insideGroupBox || !childWidget->inherits(TQRADIOBUTTON_OBJECT_NAME_STRING)) &&
242 !childWidget->inherits(TQGROUPBOX_OBJECT_NAME_STRING))
243 kdDebug(178) <<
"Widget '" << widgetName <<
"' (" << childWidget->className() <<
") remains unmanaged." <<
endl;
254 d->insideGroupBox = bSaveInsideGroupBox;
261 bool changed =
false;
262 bool bSignalsBlocked = signalsBlocked();
266 for( TQDictIterator<TQWidget> it( d->knownWidget );
267 (widget = it.current()); ++it )
272 kdWarning(178) <<
"The setting '" << it.currentKey() <<
"' has disappeared!" <<
endl;
285 widget->setEnabled(
false);
286 TQWidget *buddy = d->buddyWidget.find(it.currentKey());
288 buddy->setEnabled(
false);
291 blockSignals(bSignalsBlocked);
306 bool changed =
false;
309 for( TQDictIterator<TQWidget> it( d->knownWidget );
310 (widget = it.current()); ++it )
315 kdWarning(178) <<
"The setting '" << it.currentKey() <<
"' has disappeared!" <<
endl;
335 TQButtonGroup *bg =
dynamic_cast<TQButtonGroup *
>(w);
338 bg->setButton(v.toInt());
342 TQComboBox *cb =
dynamic_cast<TQComboBox *
>(w);
343 if (cb && cb->editable())
345 cb->setCurrentText(v.toString());
354 TQButtonGroup *bg =
dynamic_cast<TQButtonGroup *
>(w);
356 return TQVariant(bg->selectedId());
358 TQComboBox *cb =
dynamic_cast<TQComboBox *
>(w);
359 if (cb && cb->editable())
360 return TQVariant(cb->currentText());
369 for( TQDictIterator<TQWidget> it( d->knownWidget );
370 (widget = it.current()); ++it )
375 kdWarning(178) <<
"The setting '" << it.currentKey() <<
"' has disappeared!" <<
endl;
397 #include "tdeconfigdialogmanager.moc"
void setupWidget(TQWidget *widget, TDEConfigSkeletonItem *item)
Setup secondary widget properties.
TQString whatsThis() const
Return WhatsThis description of item.
TQMap< TQString, TQCString > changedMap
Map of the classes and the signals that they emit when changed.
TQVariant property(TQWidget *w)
Retrieve a property.
void settingsChanged()
One or more of the settings have been saved (such as when the user clicks on the Apply button)...
bool isDefault()
Returns whether the current state of the known widgets are the same as the default state in the confi...
virtual TQVariant maxValue() const
Return maximum value of item or invalid if not specified.
virtual TQVariant property() const =0
Return item as property.
Class for handling preferences settings for an application.
void widgetModified()
If retrieveSettings() was told to track changes then if any known setting was changed this signal wil...
Class for storing a preferences setting.
bool hasChanged()
Returns whether the current state of the known widgets are different from the state in the config obj...
void init(bool trackChanges)
TDEConfigSkeletonItem * findItem(const TQString &name)
Lookup item by name.
void setProperty(TQWidget *w, const TQVariant &v)
Set a property.
void writeConfig()
Write preferences to config file.
TDEConfigSkeleton * m_conf
TDEConfigSkeleton object used to store settings.
virtual TQVariant minValue() const
Return minimum value of item or invalid if not specified.
bool parseChildren(const TQWidget *widget, bool trackChanges)
Recursive function that finds all known children.
void updateWidgetsDefault()
Traverse the specified widgets, sets the state of all known widgets according to the default state in...
bool useDefaults(bool b)
Indicate whether this object should reflect the actual values or the default values.
virtual void setProperty(const TQVariant &p)=0
Set item to p.
void addWidget(TQWidget *widget)
Add additional widgets to manage.
TDEConfigDialogManager(TQWidget *parent, TDEConfigSkeleton *conf, const char *name=0)
Constructor.
kndbgstream & endl(kndbgstream &s)
Does nothing.
void updateSettings()
Traverse the specified widgets, saving the settings of all known widgets in the settings object...
~TDEConfigDialogManager()
Destructor.
bool isImmutable() const
Return if the entry can be modified.
void updateWidgets()
Traverse the specified widgets, sets the state of all known widgets according to the state in the set...
TQSqlPropertyMap * propertyMap
Pointer to the property map for easy access.
TQWidget * m_dialog
Dialog being managed.