* Add a Plasma::AppletScript::addStandardConfigurationPages() method that adds

standard pages to a configuration dialog such as the shortcuts one. In
conjunction with standardConfigurationDialog() this will allow script engines
to use the same dialogs as C++ applets


svn path=/branches/KDE/4.3/kdelibs/; revision=1013766
This commit is contained in:
Richard Dale 2009-08-20 18:20:31 +00:00
parent cc3a2992fc
commit fca66bfd9e
3 changed files with 24 additions and 9 deletions

View File

@ -1584,13 +1584,14 @@ void Applet::showConfigurationInterface()
}
d->addGlobalShortcutsPage(dialog);
connect(dialog, SIGNAL(applyClicked()), this, SLOT(configDialogFinished()));
connect(dialog, SIGNAL(okClicked()), this, SLOT(configDialogFinished()));
dialog->show();
} else if (d->script) {
d->script->showConfigurationInterface();
} else {
d->generateGenericConfigDialog()->show();
KConfigDialog *dialog = d->generateGenericConfigDialog();
createConfigurationInterface(dialog);
d->addGlobalShortcutsPage(dialog);
dialog->show();
}
emit releaseVisualFocus();
@ -1640,12 +1641,6 @@ KConfigDialog *AppletPrivate::generateGenericConfigDialog()
dialog->setFaceType(KPageDialog::Auto);
dialog->setWindowTitle(configWindowTitle());
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
q->createConfigurationInterface(dialog);
addGlobalShortcutsPage(dialog);
//TODO: Apply button does not correctly work for now, so do not show it
dialog->showButton(KDialog::Apply, false);
QObject::connect(dialog, SIGNAL(applyClicked()), q, SLOT(configDialogFinished()));
QObject::connect(dialog, SIGNAL(okClicked()), q, SLOT(configDialogFinished()));
QObject::connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater()));
return dialog;
}
@ -1668,6 +1663,11 @@ void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog)
layout->addWidget(shortcutEditor);
layout->addStretch();
dialog->addPage(page, i18n("Keyboard Shortcut"), "preferences-desktop-keyboard");
//TODO: Apply button does not correctly work for now, so do not show it
dialog->showButton(KDialog::Apply, false);
QObject::connect(dialog, SIGNAL(applyClicked()), q, SLOT(configDialogFinished()));
QObject::connect(dialog, SIGNAL(okClicked()), q, SLOT(configDialogFinished()));
}
void AppletPrivate::clearShortcutEditorPtr()

View File

@ -140,6 +140,15 @@ KConfigDialog *AppletScript::standardConfigurationDialog()
return 0;
}
void AppletScript::addStandardConfigurationPages(KConfigDialog *dialog)
{
if (applet()) {
return applet()->d->addGlobalShortcutsPage(dialog);
}
return;
}
void AppletScript::configChanged()
{
}

View File

@ -180,6 +180,12 @@ protected:
*/
KConfigDialog *standardConfigurationDialog();
/**
* This method should be called after a scripting applet has added
* its own pages to a configuration dialog
*/
void addStandardConfigurationPages(KConfigDialog *dialog);
private:
AppletScriptPrivate *const d;
};