28 #include <QtCore/QStringList>
29 #include <QtCore/QProcess>
49 bool KCMultiDialogPrivate::resolveChanges(
KCModuleProxy *currentProxy)
52 if( !currentProxy || !currentProxy->
changed() ) {
59 i18n(
"The settings of the current module have changed.\n"
60 "Do you want to apply the changes or discard them?"),
61 i18n(
"Apply Settings"),
68 return moduleSave(currentProxy);
88 q->blockSignals(
true);
89 q->setCurrentPage(previous);
92 for (
int i = 0; i <
modules.count(); ++i ) {
93 if (
modules[ i ].item == previous ) {
94 previousModule =
modules[ i ].kcm;
99 if( resolveChanges(previousModule) ) {
100 q->setCurrentPage(current);
102 q->blockSignals(
false);
114 for (
int i = 0; i <
modules.count(); ++i ) {
115 if (
modules[ i ].item == q->currentPage() ) {
116 activeModule =
modules[ i ].kcm;
123 change = activeModule->
changed();
126 q->disconnect(q, SIGNAL(applyClicked()), q, SLOT(slotApplyClicked()));
132 q->disconnect(q, SIGNAL(okClicked()), q, SLOT(slotOkClicked()));
150 q->connect(q, SIGNAL(applyClicked()), SLOT(slotApplyClicked()));
155 q->connect(q, SIGNAL(okClicked()), SLOT(slotOkClicked()));
200 for (
int i = 0; i <
modules.count(); ++i )
201 modules[ i ].kcm->deleteClient();
204 void KCMultiDialogPrivate::init()
208 q->setCaption(
i18n(
"Configure"));
214 q->connect(q, SIGNAL(applyClicked()), SLOT(slotApplyClicked()));
215 q->connect(q, SIGNAL(okClicked()), SLOT(slotOkClicked()));
216 q->connect(q, SIGNAL(defaultClicked()), SLOT(slotDefaultClicked()));
217 q->connect(q, SIGNAL(helpClicked()), SLOT(slotHelpClicked()));
218 q->connect(q, SIGNAL(user1Clicked()), SLOT(slotUser1Clicked()));
219 q->connect(q, SIGNAL(resetClicked()), SLOT(slotUser1Clicked()));
224 q->setInitialSize(
QSize(800, 550));
256 for (
int i = 0; i < d->modules.count(); ++i ) {
257 if ( d->modules[ i ].item == item ) {
258 d->modules[ i ].kcm->defaults();
259 d->_k_clientChanged();
272 for (
int i = 0; i < d->modules.count(); ++i ) {
273 if ( d->modules[ i ].item == item ) {
274 d->modules[ i ].kcm->load();
275 d->_k_clientChanged();
291 void KCMultiDialogPrivate::apply()
296 foreach (
const CreatedModule &module,
modules) {
306 foreach (
const QString &componentName, module.componentNames) {
307 if (!updatedComponents.contains(componentName)) {
308 updatedComponents.append(componentName);
315 foreach (
const QString &name, updatedComponents) {
316 emit q->configCommitted(name.toLatin1());
319 emit q->configCommitted();
346 for (
int i = 0; i < d->modules.count(); ++i ) {
347 if ( d->modules[ i ].item == item ) {
348 docPath = d->modules[ i ].kcm->moduleInfo().docPath();
353 KUrl docUrl(
KUrl(
"help:/" ), docPath );
355 QProcess::startDetached(
"khelpcenter",
QStringList() << docUrl.
url());
366 if ( !path.endsWith( QLatin1String(
".desktop") ) )
367 complete +=
".desktop";
397 item->setProperty(
"_k_weight", moduleInfo.
weight());
399 bool updateCurrentPage =
false;
403 const QModelIndex parentIndex = model->
index(parentItem);
404 const int siblingCount = model->
rowCount(parentIndex);
406 for (; row < siblingCount; ++row) {
408 if (siblingItem->property(
"_k_weight").toInt() > moduleInfo.
weight()) {
410 kDebug(710) <<
"adding KCM " << item->
name() <<
" before " << siblingItem->
name();
415 if (row >= siblingCount) {
417 kDebug(710) <<
"adding KCM " << item->
name() <<
" with parent " << parentItem->
name();
421 const int siblingCount = model->
rowCount();
423 for (; row < siblingCount; ++row) {
425 if (siblingItem->property(
"_k_weight").toInt() > moduleInfo.
weight()) {
427 kDebug(710) <<
"adding KCM " << item->
name() <<
" before " << siblingItem->
name();
430 updateCurrentPage =
true;
435 if (row == siblingCount) {
437 kDebug(710) <<
"adding KCM " << item->
name() <<
" at the top level";
442 connect(kcm, SIGNAL(changed(
bool)),
this, SLOT(_k_clientChanged()));
443 connect(kcm->
realModule(), SIGNAL(rootOnlyMessageChanged(
bool,
QString)),
this, SLOT(_k_updateHeader(
bool,
QString)));
450 d->modules.append( cm );
452 if ( d->modules.count() == 1 || updateCurrentPage )
455 d->_k_clientChanged();
465 for (
int i = 0; i < d->modules.count(); ++i ) {
467 delete d->modules[ i ].kcm;
472 d->_k_clientChanged();
481 button(KDialog::Ok)->setAutoDefault(
true);
484 button(KDialog::Apply)->setAutoDefault(
true);
487 button(KDialog::Default)->setAutoDefault(
true);
490 button(KDialog::Reset)->setAutoDefault(
true);
493 button(KDialog::Cancel)->setAutoDefault(
true);
496 button(KDialog::Help)->setAutoDefault(
true);
506 #include "kcmultidialog.moc"