27 #include <tqpushbutton.h>
29 #include <tdeaboutdata.h>
30 #include <tdeapplication.h>
32 #include <kiconloader.h>
33 #include <klibloader.h>
35 #include <tdemessagebox.h>
36 #include <tdeprocess.h>
38 #include <kstdguiitem.h>
41 #include "tdecmoduleloader.h"
42 #include "tdecmoduleproxy.h"
43 #include "kcmultidialog.h"
44 #include "kcmultidialog.moc"
46 class KCMultiDialog::KCMultiDialogPrivate
49 KCMultiDialogPrivate()
50 : hasRootKCM( false ), currentModule( 0 )
59 :
KDialogBase(IconList, i18n(
"Configure"), Help | Default |Cancel | Apply |
60 Ok | User1 | User2, Ok, parent, name, modal, true,
62 , dialogface( IconList ), d( new KCMultiDialogPrivate )
68 :
KDialogBase( dialogFace, caption, Help | Default | Cancel | Apply | Ok |
69 User1 | User2, Ok, parent, name, modal, true,
71 , dialogface( dialogFace ), d( new KCMultiDialogPrivate )
77 const KGuiItem &user3,
int buttonMask,
const TQString &caption,
78 TQWidget *parent,
const char *name,
bool modal )
79 :
KDialogBase( dialogFace, caption, buttonMask | Help | Default | Cancel |
80 Apply | Ok | User1, Ok, parent, name, modal, true,
82 , dialogface( dialogFace ), d( new KCMultiDialogPrivate )
84 kdDebug( 710 ) <<
"Root modules will not work with this constructor. See the API documentation." <<
endl;
86 if ( buttonMask &
User2 )
90 inline void KCMultiDialog::init()
92 connect(
this, TQ_SIGNAL(
finished()), TQ_SLOT( dialogClosed()));
96 connect(
this, TQ_SIGNAL(
aboutToShowPage(TQWidget *)),
this, TQ_SLOT(slotAboutToShow(TQWidget *)));
98 moduleParentComponents.setAutoDelete(
true );
104 OrphanMap::Iterator end2 = m_orphanModules.end();
105 for( OrphanMap::Iterator it = m_orphanModules.begin(); it != end2; ++it )
114 ModuleList::Iterator end = m_modules.end();
115 for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it )
116 if(
pageIndex( ( TQWidget * )( *it ).kcm->parent() ) == curPageIndex )
118 ( *it ).kcm->defaults();
119 clientChanged(
true );
128 ModuleList::Iterator end = m_modules.end();
129 for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it )
130 if(
pageIndex( ( TQWidget * )( *it ).kcm->parent() ) == curPageIndex )
133 clientChanged(
false );
138 void KCMultiDialog::apply()
140 TQStringList updatedModules;
141 ModuleList::Iterator end = m_modules.end();
142 for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it )
148 TQStringList * names = moduleParentComponents[ m ];
149 kdDebug(710) << k_funcinfo << *names <<
" saved and added to the list" <<
endl;
150 for( TQStringList::ConstIterator it = names->begin(); it != names->end(); ++it )
151 if( updatedModules.find( *it ) == updatedModules.end() )
152 updatedModules.append( *it );
155 for( TQStringList::const_iterator it = updatedModules.begin(); it != updatedModules.end(); ++it )
157 kdDebug(710) << k_funcinfo << *it <<
" " << ( *it ).latin1() <<
endl;
188 ModuleList::Iterator end = m_modules.end();
189 for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it ) {
190 if(
pageIndex( ( TQWidget * )( *it ).kcm->parent() ) == curPageIndex )
195 if (docPath == TQString::null)
199 if (section != TQString::null) {
200 docPath = TQString(
"%1#%2" ).arg( docPath ).arg( section );
206 KURL url(
KURL(
"help:/"), docPath );
210 process <<
"khelpcenter"
219 void KCMultiDialog::clientChanged(
bool state)
222 ModuleList::Iterator end = m_modules.end();
223 for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it )
224 if( ( *it ).kcm->changed() )
234 TQString complete = path;
236 if( !path.endsWith(
".desktop" ))
237 complete +=
".desktop";
239 KService::Ptr service = KService::serviceByStorageId( complete );
245 TQStringList parentmodulenames,
bool withfallback, TQStringList args)
247 kdDebug(710) <<
"KCMultiDialog::addModule "
253 if ( !kapp->authorizeControlModule( moduleinfo.
service()->menuId() ))
260 if (!moduleinfo.
service()->noDisplay())
266 SmallIcon( moduleinfo.
icon(),
271 moduleinfo.
comment(), DesktopIcon( moduleinfo.
icon(),
276 (
new TQHBoxLayout( page ) )->setAutoAdd(
true );
279 kdError( 710 ) <<
"unsupported dialog face for KCMultiDialog"
288 if( m_orphanModules.contains( moduleinfo.
service() ) )
292 module = m_orphanModules[ moduleinfo.
service() ];
293 m_orphanModules.remove( moduleinfo.
service() );
294 kdDebug( 710 ) <<
"Use TDECModule from the list of orphans for " <<
297 module->reparent( page, 0, TQPoint( 0, 0 ),
true );
300 clientChanged(
true );
307 module =
new TDECModuleProxy( moduleinfo, withfallback, page, 0, args );
308 TQStringList parentComponents = moduleinfo.
service()->property(
309 "X-TDE-ParentComponents" ).toStringList();
310 moduleParentComponents.insert( module,
311 new TQStringList( parentComponents ) );
313 connect(module, TQ_SIGNAL(changed(
bool)),
this, TQ_SLOT(clientChanged(
bool)));
315 if( m_modules.count() == 0 )
320 cm.service = moduleinfo.
service();
321 m_modules.append( cm );
324 !
KUser().isSuperUser() )
326 d->hasRootKCM =
true;
329 slotAboutToShow( page );
336 ModuleList::Iterator end = m_modules.end();
337 for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it )
341 TQObject * page = kcm->parent();
346 kcm->reparent( 0, TQPoint( 0, 0 ),
false );
349 m_orphanModules[ ( *it ).service ] = kcm;
350 kdDebug( 710 ) <<
"added TDECModule to the list of orphans: " <<
355 clientChanged(
false );
358 void KCMultiDialog::show()
363 void KCMultiDialog::slotAboutToShow(TQWidget *page)
367 TQObject * obj = page->child( 0,
"TDECModuleProxy" );
374 d->currentModule = module;
377 d->currentModule->buttons() & TDECModule::Help );
379 d->currentModule->buttons() & TDECModule::Default );
383 if (d->currentModule->moduleInfo().needsRootPrivileges())
385 if ( !d->currentModule->rootMode() )
388 connect(
this, TQ_SIGNAL(
user2Clicked()), d->currentModule, TQ_SLOT( runAsRoot() ));
389 connect(
this, TQ_SIGNAL(
user2Clicked()), TQ_SLOT( disableRModeButton() ));
396 void KCMultiDialog::rootExit()
401 void KCMultiDialog::disableRModeButton()
404 connect ( d->currentModule, TQ_SIGNAL( childClosed() ), TQ_SLOT( rootExit() ));
407 void KCMultiDialog::dialogClosed()
414 ModuleList::Iterator
end = m_modules.end();
415 for( ModuleList::Iterator it = m_modules.begin(); it != end; ++it )
416 ( *it ).kcm->deleteClient();
virtual void slotOk()
This slot is called when the user presses the "OK" Button.
void addModule(const TQString &module, bool withfallback=true, TQStringList args=TQStringList())
Add a module.
virtual ~KCMultiDialog()
Destructor.
KCMultiDialog(TQWidget *parent=0, const char *name=0, bool modal=false)
Constructs a new KCMultiDialog.
virtual void slotDefault()
This slot is called when the user presses the "Default" Button.
virtual void slotHelp()
This slot is called when the user presses the "Help" Button.
void configCommitted()
Emitted after all TDECModules have been told to save their configuration.
virtual void slotUser1()
This slot is called when the user presses the "Reset" Button.
void removeAllModules()
Remove all modules from the dialog.
virtual void slotApply()
This slot is called when the user presses the "Apply" Button.
void enableButton(ButtonCode id, bool state)
void showButton(ButtonCode id, bool state)
TQHBox * addHBoxPage(const TQString &itemName, const TQString &header=TQString::null, const TQPixmap &pixmap=TQPixmap())
TQPushButton * actionButton(ButtonCode id)
int activePageIndex() const
void aboutToShowPage(TQWidget *page)
void setInitialSize(const TQSize &s, bool noResize=false)
int pageIndex(TQWidget *widget) const
TQString protocol() const
TQString url(int _trailing=0, int encoding_hint=0) const
A class that provides information about a TDECModule.
bool needsRootPrivileges() const
KService::Ptr service() const
TQString moduleName() const
static bool testModule(const TQString &module)
Checks whether an TDECModule should be shown by running its test function.
static void unloadModule(const TDECModuleInfo &mod)
Unloads the module's library.
Encapsulates a TDECModule for embedding.
TQString handbookSection() const
TQString handbookDocPath() const
void save()
Calling it will cause the contained module to run its save() routine.
const TDECModuleInfo & moduleInfo() const
virtual bool start(RunMode runmode=NotifyOnExit, Communication comm=NoCommunication)
kndbgstream & endl(kndbgstream &s)
kdbgstream kdError(int area=0)
kdbgstream kdDebug(int area=0)
const TDEShortcut & end()