provide a (rather hidden, unfortunately) slot for applets and containments to attach custom widgets to to enable/disable a Apply button with. welcome the settingsModified() slot

svn path=/trunk/KDE/kdelibs/; revision=1129003
This commit is contained in:
Aaron J. Seigo 2010-05-21 00:26:23 +00:00
parent 530c3fe70a
commit aa5e85e3fa
2 changed files with 31 additions and 3 deletions

View File

@ -53,7 +53,6 @@
#include <kactioncollection.h>
#include <kauthorized.h>
#include <kcolorscheme.h>
#include <kconfigdialog.h>
#include <kdialog.h>
#include <kicon.h>
#include <kiconloader.h>
@ -1805,7 +1804,7 @@ void Applet::showConfigurationInterface()
QUiLoader loader;
QWidget *w = loader.load(&f);
if (w) {
dialog = new KConfigDialog(0, d->configDialogId(), d->configLoader);
dialog = new AppletConfigDialog(0, d->configDialogId(), d->configLoader);
dialog->setWindowTitle(d->configWindowTitle());
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
dialog->addPage(w, i18n("Settings"), icon(), i18n("%1 Settings", name()));
@ -1881,7 +1880,7 @@ QSet<QString> AppletPrivate::knownCategories()
KConfigDialog *AppletPrivate::generateGenericConfigDialog()
{
KConfigSkeleton *nullManager = new KConfigSkeleton(0);
KConfigDialog *dialog = new KConfigDialog(0, configDialogId(), nullManager);
KConfigDialog *dialog = new AppletConfigDialog(0, configDialogId(), nullManager);
dialog->setFaceType(KPageDialog::Auto);
dialog->setWindowTitle(configWindowTitle());
dialog->setAttribute(Qt::WA_DeleteOnClose, true);

View File

@ -26,6 +26,7 @@
#include <QGraphicsProxyWidget>
#include <kactioncollection.h>
#include <kconfigdialog.h>
#include "plasma/animator.h"
#include "plasma/private/dataengineconsumer_p.h"
@ -47,6 +48,34 @@ class AppletScript;
class Wallpaper;
class BusyWidget;
class AppletConfigDialog : public KConfigDialog
{
Q_OBJECT
public:
AppletConfigDialog(QWidget* parent, const QString &id, KConfigSkeleton *s)
: KConfigDialog(parent, id, s),
m_changed(false)
{
}
public Q_SLOTS:
void settingsModified(bool modified = true)
{
m_changed = modified;
updateButtons();
}
protected:
bool hasChanged()
{
return m_changed || KConfigDialog::hasChanged();
}
private:
bool m_changed;
};
class AppletOverlayWidget : public QGraphicsWidget
{
Q_OBJECT