22 #include "kconfigdialog.h" 24 #include <kconfigskeleton.h> 25 #include <kconfigdialogmanager.h> 27 #include <kiconloader.h> 34 TQAsciiDict<KConfigDialog> KConfigDialog::openDialogs;
37 class KConfigDialog::KConfigDialogPrivate
41 : shown(false), type(t), manager(0) { }
46 TQMap<TQWidget *, KConfigDialogManager *> managerForPage;
55 KDialogBase( dialogType, (WFlags)TQt::WStyle_DialogBorder,
56 parent, name, modal, i18n(
"Configure"), dialogButtons, defaultButton ),
57 d(new KConfigDialogPrivate(dialogType))
60 openDialogs.insert(name,
this);
62 TQCString genericName;
63 genericName.sprintf(
"SettingsDialog-%p",
this);
64 openDialogs.insert(genericName,
this);
75 setupManagerConnections(d->manager);
82 openDialogs.remove(name());
87 const TQString &itemName,
88 const TQString &pixmapName,
89 const TQString &header,
92 addPageInternal(page, itemName, pixmapName, header);
94 d->manager->addWidget(page);
99 const TQString &itemName,
100 const TQString &pixmapName,
101 const TQString &header)
103 addPageInternal(page, itemName, pixmapName, header);
105 setupManagerConnections(d->managerForPage[page]);
108 void KConfigDialog::addPageInternal(TQWidget *page,
109 const TQString &itemName,
110 const TQString &pixmapName,
111 const TQString &header)
115 kdDebug(240) <<
"KConfigDialog::addPage: can not add a page after the dialog has been shown.";
123 TQVBox *frame =
addVBoxPage(itemName, header, SmallIcon(pixmapName, 32));
124 frame->setSpacing( 0 );
125 frame->setMargin( 0 );
126 page->reparent(((TQWidget*)frame), 0, TQPoint());
132 page->reparent(
this, 0, TQPoint());
140 TQVBoxLayout *topLayout =
new TQVBoxLayout( main, 0, 0 );
141 page->reparent(((TQWidget*)main), 0, TQPoint());
142 topLayout->addWidget( page );
147 kdDebug(240) <<
"KConfigDialog::addpage: unknown type.";
163 return openDialogs.find(name);
171 return (dialog != NULL);
176 static bool only_once =
false;
177 if (only_once)
return;
180 TQMap<TQWidget *, KConfigDialogManager *>::iterator it;
182 bool has_changed = d->manager->hasChanged() ||
hasChanged();
183 for (it = d->managerForPage.begin();
184 it != d->managerForPage.end() && !has_changed;
187 has_changed |= (*it)->hasChanged();
192 bool is_default = d->manager->isDefault() &&
isDefault();
193 for (it = d->managerForPage.begin();
194 it != d->managerForPage.end() && is_default;
197 is_default &= (*it)->isDefault();
216 TQMap<TQWidget *, KConfigDialogManager *>::iterator it;
219 d->manager->updateWidgets();
220 for (it = d->managerForPage.begin(); it != d->managerForPage.end(); ++it)
221 (*it)->updateWidgets();
223 bool has_changed = d->manager->hasChanged() ||
hasChanged();
224 for (it = d->managerForPage.begin();
225 it != d->managerForPage.end() && !has_changed;
228 has_changed |= (*it)->hasChanged();
233 bool is_default = d->manager->isDefault() &&
isDefault();
234 for (it = d->managerForPage.begin();
235 it != d->managerForPage.end() && is_default;
238 is_default &= (*it)->isDefault();
259 #include "kconfigdialog.moc" virtual void updateWidgets()
Update the dialog based on the settings.
void defaultClicked()
The Default button was pressed.
void widgetModified()
A widget in the dialog was modified.
void applyClicked()
The Apply button was pressed.
void settingsChangedSlot()
Some setting was changed.
TQVBox * addVBoxPage(const TQString &itemName, const TQString &header=TQString::null, const TQPixmap &pixmap=TQPixmap())
Add a page to the dialog when the class is used in TreeList, IconList or Tabbed mode.
virtual void updateSettings()
Update the settings from the dialog.
static KConfigDialog * exists(const char *name)
See if a dialog with the name 'name' already exists.
KConfigDialog(TQWidget *parent, const char *name, KConfigSkeleton *config, DialogType dialogType=IconList, int dialogButtons=Default|Ok|Apply|Cancel|Help, ButtonCode defaultButton=Ok, bool modal=false)
void enableButton(ButtonCode id, bool state)
Enable or disable (gray out) a general action button.
kdbgstream kdDebug(int area=0)
virtual void updateWidgetsDefault()
Update the dialog based on the default settings.
A dialog base class with standard buttons and predefined layouts.
Standard KDE configuration dialog class.
virtual bool hasChanged()
Returns whether the current state of the dialog is different from the current configutation.
virtual bool isDefault()
Returns whether the current state of the dialog is the same as the default configuration.
void setMainWidget(TQWidget *widget)
Sets the main user definable widget.
TQFrame * plainPage()
Retrieve the empty page when the predefined layout is used in Plain mode.
void updateButtons()
Updates the Apply and Default buttons.
virtual void show()
Show the dialog.
void okClicked()
The OK button was pressed.
void addPage(TQWidget *page, const TQString &itemName, const TQString &pixmapName, const TQString &header=TQString::null, bool manage=true)
Adds page to the dialog and to KConfigDialogManager.
~KConfigDialog()
Deconstructor, removes name from the list of open dialogs.
static bool showDialog(const char *name)
Attempts to show the dialog with the name 'name'.
void settingsChanged()
One or more of the settings have been permanently changed such as if the user clicked on the Apply or...