introduce createConfigurationInterface, it's now the prefered mechanism. showConfigurationInterface remains for the convenience of Applet itself, and remains virtual so as not to break existing applets.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=792927
This commit is contained in:
parent
def626b080
commit
2558d5c305
43
applet.cpp
43
applet.cpp
@ -39,11 +39,12 @@
|
|||||||
#include <KColorScheme>
|
#include <KColorScheme>
|
||||||
#include <KConfigDialog>
|
#include <KConfigDialog>
|
||||||
#include <KDialog>
|
#include <KDialog>
|
||||||
|
#include <KIconLoader>
|
||||||
#include <KPluginInfo>
|
#include <KPluginInfo>
|
||||||
#include <KStandardDirs>
|
#include <KStandardDirs>
|
||||||
#include <KService>
|
#include <KService>
|
||||||
#include <KServiceTypeTrader>
|
#include <KServiceTypeTrader>
|
||||||
#include <KIconLoader>
|
#include <KWindowSystem>
|
||||||
|
|
||||||
#include <Solid/PowerManagement>
|
#include <Solid/PowerManagement>
|
||||||
|
|
||||||
@ -1296,14 +1297,29 @@ void Applet::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
|
|
||||||
void Applet::showConfigurationInterface()
|
void Applet::showConfigurationInterface()
|
||||||
{
|
{
|
||||||
|
if (!hasConfigurationInterface()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString dialogId = QString("%1settings%2").arg(id()).arg(name());
|
||||||
|
KConfigDialog * dlg = KConfigDialog::exists(dialogId);
|
||||||
|
|
||||||
|
if (dlg) {
|
||||||
|
KWindowSystem::setOnDesktop(dlg->winId(), KWindowSystem::currentDesktop());
|
||||||
|
dlg->show();
|
||||||
|
KWindowSystem::activateWindow(dlg->winId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString windowTitle = i18nc("@title:window", "%1 Settings", name());
|
||||||
if (d->package && d->configXml) {
|
if (d->package && d->configXml) {
|
||||||
QString uiFile = d->package->filePath("mainconfigui");
|
QString uiFile = d->package->filePath("mainconfigui");
|
||||||
if (uiFile.isEmpty()) {
|
if (uiFile.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
KConfigDialog *dialog = new KConfigDialog(0, "", d->configXml);
|
KConfigDialog *dialog = new KConfigDialog(0, dialogId, d->configXml);
|
||||||
dialog->setWindowTitle(i18n("%1 Settings", name()));
|
dialog->setWindowTitle(windowTitle);
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
|
||||||
QUiLoader loader;
|
QUiLoader loader;
|
||||||
@ -1318,12 +1334,29 @@ void Applet::showConfigurationInterface()
|
|||||||
|
|
||||||
dialog->addPage(w, i18n("Settings"), icon(), i18n("%1 Settings", name()));
|
dialog->addPage(w, i18n("Settings"), icon(), i18n("%1 Settings", name()));
|
||||||
dialog->show();
|
dialog->show();
|
||||||
}
|
} else if (d->script) {
|
||||||
else if(d->script) {
|
|
||||||
d->script->showConfigurationInterface();
|
d->script->showConfigurationInterface();
|
||||||
|
} else {
|
||||||
|
KConfigSkeleton *nullManager = new KConfigSkeleton(0);
|
||||||
|
KConfigDialog *dialog = new KConfigDialog(0, dialogId, nullManager);
|
||||||
|
dialog->setFaceType(KPageDialog::Auto);
|
||||||
|
dialog->setWindowTitle(windowTitle);
|
||||||
|
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
createConfigurationInterface(dialog);
|
||||||
|
//TODO: would be nice to not show dialog if there are no pages added?
|
||||||
|
connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater()));
|
||||||
|
dialog->show();
|
||||||
|
dialog->enableButtonApply(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Applet::createConfigurationInterface(KConfigDialog *parent)
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent)
|
||||||
|
// virtual method reimplemented by subclasses.
|
||||||
|
// do not put anything here ...
|
||||||
|
}
|
||||||
|
|
||||||
KPluginInfo::List Applet::knownApplets(const QString &category,
|
KPluginInfo::List Applet::knownApplets(const QString &category,
|
||||||
const QString &parentApp)
|
const QString &parentApp)
|
||||||
{
|
{
|
||||||
|
20
applet.h
20
applet.h
@ -25,7 +25,6 @@
|
|||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
#include <KDE/KPluginInfo>
|
#include <KDE/KPluginInfo>
|
||||||
#include <KDE/KSharedConfig>
|
|
||||||
#include <KDE/KGenericFactory>
|
#include <KDE/KGenericFactory>
|
||||||
|
|
||||||
#include <plasma/configxml.h>
|
#include <plasma/configxml.h>
|
||||||
@ -33,6 +32,8 @@
|
|||||||
#include <plasma/plasma.h>
|
#include <plasma/plasma.h>
|
||||||
#include <plasma/widgets/widget.h>
|
#include <plasma/widgets/widget.h>
|
||||||
|
|
||||||
|
class KConfigDialog;
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -673,14 +674,25 @@ class PLASMA_EXPORT Applet : public Widget
|
|||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reimplement this slot to show a configuration dialog.
|
* Lets the user interact with the plasmoid options.
|
||||||
*
|
|
||||||
* Let the user play with the plasmoid options.
|
|
||||||
* Called when the user selects the configure entry
|
* Called when the user selects the configure entry
|
||||||
* from the context menu.
|
* from the context menu.
|
||||||
|
*
|
||||||
|
* Applets should NOT reimplement this method unless there is good
|
||||||
|
* reason to do so, but instead reimplment createConfigurationInterface
|
||||||
*/
|
*/
|
||||||
virtual void showConfigurationInterface();
|
virtual void showConfigurationInterface();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reimplement this method so provide a configuration interface,
|
||||||
|
* parented to the supplied widget. Ownership of the widgets is passed
|
||||||
|
* to the parent widget.
|
||||||
|
*
|
||||||
|
* @param parent the dialog which is the parent of the configuration
|
||||||
|
* widgets
|
||||||
|
*/
|
||||||
|
virtual void createConfigurationInterface(KConfigDialog *parent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends all pending contraints updates to the applet. Will usually
|
* Sends all pending contraints updates to the applet. Will usually
|
||||||
* be called automatically, but can also be called manually if needed.
|
* be called automatically, but can also be called manually if needed.
|
||||||
|
Loading…
Reference in New Issue
Block a user