diff --git a/src/plasma/applet.cpp b/src/plasma/applet.cpp index f240789c0..d3025c364 100644 --- a/src/plasma/applet.cpp +++ b/src/plasma/applet.cpp @@ -116,8 +116,6 @@ Applet::~Applet() //let people know that i will die emit appletDeleted(this); - // clean up our config dialog, if any - delete KConfigDialog::exists(d->configDialogId()); delete d; } @@ -459,11 +457,6 @@ void Applet::flushPendingConstraintsEvents() QAction *configAction = d->actions->action("configure"); if (configAction) { - /*if (d->isContainment) { - connect(configAction, SIGNAL(triggered(bool)), this, SLOT(requestConfiguration()), Qt::UniqueConnection); - } else { - connect(configAction, SIGNAL(triggered(bool)), this, SLOT(showConfigurationInterface()), Qt::UniqueConnection); - }*/ if (d->hasConfigurationInterface) { bool canConfig = unlocked || KAuthorized::authorize("plasma/allow_configure_when_locked"); @@ -650,130 +643,6 @@ void Applet::setHasConfigurationInterface(bool hasInterface) d->hasConfigurationInterface = hasInterface; } -bool Applet::isUserConfiguring() const -{ - return KConfigDialog::exists(d->configDialogId()); -} - -void Applet::showConfigurationInterface() -{ - if (!hasConfigurationInterface()) { - return; - } - - if (immutability() != Mutable && !KAuthorized::authorize("plasma/allow_configure_when_locked")) { - return; - } - - KConfigDialog *dlg = KConfigDialog::exists(d->configDialogId()); - - if (dlg) { - KWindowSystem::setOnDesktop(dlg->winId(), KWindowSystem::currentDesktop()); - dlg->show(); - KWindowSystem::activateWindow(dlg->winId()); - return; - } - - if (d->package) { - KConfigDialog *dialog = 0; - - const QString uiFile = d->package->filePath("mainconfigui"); - KDesktopFile df(d->package->path() + "/metadata.desktop"); - const QStringList kcmPlugins = df.desktopGroup().readEntry("X-Plasma-ConfigPlugins", QStringList()); - if (!uiFile.isEmpty() || !kcmPlugins.isEmpty()) { - KConfigSkeleton *configLoader = configScheme() ? d->configLoader : new KConfigSkeleton(0); - dialog = new AppletConfigDialog(0, d->configDialogId(), configLoader); - - if (!d->configLoader) { - // delete the temporary when this dialog is done - configLoader->setParent(dialog); - } - - dialog->setWindowTitle(d->configWindowTitle()); - dialog->setAttribute(Qt::WA_DeleteOnClose, true); - bool hasPages = false; - - QFile f(uiFile); - QUiLoader loader; - QWidget *w = loader.load(&f); - if (w) { - dialog->addPage(w, i18n("Settings"), icon(), i18n("%1 Settings", title())); - hasPages = true; - } - - foreach (const QString &kcm, kcmPlugins) { -#if !PLASMA_NO_KUTILS - KCModuleProxy *module = new KCModuleProxy(kcm); - if (module->realModule()) { - //preemptively load modules to prevent save() crashing on some kcms, like powerdevil ones - module->load(); - connect(module, SIGNAL(changed(bool)), dialog, SLOT(settingsModified(bool))); - connect(dialog, SIGNAL(okClicked()), - module->realModule(), SLOT(save())); - connect(dialog, SIGNAL(applyClicked()), - module->realModule(), SLOT(save())); - dialog->addPage(module, module->moduleInfo().moduleName(), module->moduleInfo().icon()); - hasPages = true; - } else { - delete module; - } -#else - KService::Ptr service = KService::serviceByStorageId(kcm); - if (service) { - QString error; - KCModule *module = service->createInstance(dialog, QVariantList(), &error); - if (module) { - module->load(); - connect(module, SIGNAL(changed(bool)), dialog, SLOT(settingsModified(bool))); - connect(dialog, SIGNAL(okClicked()), - module, SLOT(save())); - connect(dialog, SIGNAL(applyClicked()), - module, SLOT(save())); - dialog->addPage(module, service->name(), service->icon()); - hasPages = true; - } else { -#ifndef NDEBUG - kDebug() << "failed to load kcm" << kcm << "for" << title(); -#endif - } - } -#endif - } - - if (hasPages) { - d->addGlobalShortcutsPage(dialog); - dialog->show(); - } else { - delete dialog; - dialog = 0; - } - } - - if (!dialog && d->script) { - d->script->showConfigurationInterface(); - } - } else if (d->script) { - d->script->showConfigurationInterface(); - } else { - KConfigDialog *dialog = d->generateGenericConfigDialog(); - d->addStandardConfigurationPages(dialog); - showConfigurationInterface(dialog); - } - - emit releaseVisualFocus(); -} - -void Applet::showConfigurationInterface(QWidget *widget) -{ - if (!containment() || !containment()->corona() || - !containment()->corona()->dialogManager()) { - widget->show(); - return; - } - - QMetaObject::invokeMethod(containment()->corona()->dialogManager(), "showDialog", Q_ARG(QWidget *, widget), Q_ARG(Plasma::Applet *, this)); -} - void Applet::configChanged() { if (d->script) { @@ -784,13 +653,6 @@ void Applet::configChanged() } } -void Applet::createConfigurationInterface(KConfigDialog *parent) -{ - Q_UNUSED(parent) - // virtual method reimplemented by subclasses. - // do not put anything here ... -} - void Applet::setAssociatedApplication(const QString &string) { AssociatedApplicationManager::self()->setApplication(this, string); diff --git a/src/plasma/applet.h b/src/plasma/applet.h index 3f577b5a7..10e0219e1 100644 --- a/src/plasma/applet.h +++ b/src/plasma/applet.h @@ -352,31 +352,6 @@ class PLASMA_EXPORT Applet : public QObject **/ bool hasConfigurationInterface() const; - /** - * Reimplement this method so provide a configuration interface, - * parented to the supplied widget. Ownership of the widgets is passed - * to the parent widget. - * - * Typically one would add custom pages to the config dialog @p parent - * and then connect to the applyClicked() and okClicked() signals - * or @p parent to react on config changes: - * - * @code - * connect(parent, SIGNAL(applyClicked()), this, SLOT(myConfigAccepted())); - * connect(parent, SIGNAL(okClicked()), this, SLOT(myConfigAccepted())); - * @endcode - * - * With this approach it makes sense to store the custom pages in member - * variables to make their fields accessible from the myConfigAccepted() - * slot. - * - * Use config() to store your configuration. - * - * @param parent the dialog which is the parent of the configuration - * widgets - */ - virtual void createConfigurationInterface(KConfigDialog *parent); - Q_SIGNALS: //BOOKEEPING /** @@ -402,7 +377,6 @@ class PLASMA_EXPORT Applet : public QObject * applets. */ void configNeedsSaving(); - //ACTIONS @@ -451,37 +425,6 @@ class PLASMA_EXPORT Applet : public QObject void setStatus(const ItemStatus stat); //CONFIGURATION - /** - * Lets the user interact with the plasmoid options. - * Called when the user selects the configure entry - * from the context menu. - * - * Unless there is good reason for overriding this method, - * Applet subclasses should actually override createConfigurationInterface - * instead. A good example of when this isn't plausible is - * when using a dialog prepared by another library, such - * as KPropertiesDialog from libkfile. - * You probably want to call showConfigurationInterface(QWidget*) - * with the custom widget you created to actually show your interface - */ - virtual void showConfigurationInterface(); - - /** - * Actually show your custom configuration interface - * Use this only if you reimplemented showConfigurationInterface() - * - * @param widget the widget representing your configuration interface - * - * @since 4.5 - */ - void showConfigurationInterface(QWidget *widget); - - /** - * @return true when the configuration interface is being shown - * @since 4.5 - */ - bool isUserConfiguring() const; - /** * Called when applet configuration values have changed. */ @@ -626,7 +569,6 @@ class PLASMA_EXPORT Applet : public QObject Applet(const QString &packagePath, uint appletId); Q_PRIVATE_SLOT(d, void cleanUpAndDelete()) - Q_PRIVATE_SLOT(d, void configDialogFinished()) Q_PRIVATE_SLOT(d, void updateShortcuts()) Q_PRIVATE_SLOT(d, void globalShortcutChanged()) Q_PRIVATE_SLOT(d, void propagateConfigChanged()) diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index 1e707b0e6..37990b5be 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -507,11 +507,6 @@ QString Containment::activity() const return d->activityId; } -void Containment::showConfigurationInterface() -{ - Applet::showConfigurationInterface(); -} - } // Plasma namespace diff --git a/src/plasma/containment.h b/src/plasma/containment.h index 4c5e46c70..bbeda8b29 100644 --- a/src/plasma/containment.h +++ b/src/plasma/containment.h @@ -279,12 +279,6 @@ Q_SIGNALS: */ void setFormFactor(Plasma::FormFactor formFactor); - /** - * @reimp - * @sa Applet::showConfigurationInterface() - */ - void showConfigurationInterface(); - /** * Sets the type of this containment. */ diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp index 9ca037ec1..6db639a69 100644 --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -223,80 +223,6 @@ KActionCollection* AppletPrivate::defaultActions(QObject *parent) return actions; } -QString AppletPrivate::configDialogId() const -{ - return QString("%1settings%2").arg(appletId).arg(q->title()); -} - -QString AppletPrivate::configWindowTitle() const -{ - return i18nc("@title:window", "%1 Settings", q->title()); -} - -KConfigDialog *AppletPrivate::generateGenericConfigDialog() -{ - KConfigSkeleton *nullManager = new KConfigSkeleton(0); - KConfigDialog *dialog = new AppletConfigDialog(0, configDialogId(), nullManager); - nullManager->setParent(dialog); - dialog->setFaceType(KPageDialog::Auto); - dialog->setWindowTitle(configWindowTitle()); - dialog->setAttribute(Qt::WA_DeleteOnClose, true); - q->createConfigurationInterface(dialog); - dialog->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel); - QObject::connect(dialog->button(QDialogButtonBox::Apply), SIGNAL(clicked()), q, SLOT(configDialogFinished())); - QObject::connect(dialog->button(QDialogButtonBox::Ok), SIGNAL(clicked()), q, SLOT(configDialogFinished())); - return dialog; -} - -void AppletPrivate::addStandardConfigurationPages(KConfigDialog *dialog) -{ - addGlobalShortcutsPage(dialog); -} - -void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog) -{ -#if !PLASMA_NO_GLOBAL_SHORTCUTS - if (isContainment) { - return; - } - - QWidget *page = new QWidget; - QVBoxLayout *layout = new QVBoxLayout(page); - - if (!shortcutEditor) { - shortcutEditor = new KKeySequenceWidget(page); - QObject::connect(shortcutEditor.data(), SIGNAL(keySequenceChanged(QKeySequence)), dialog, SLOT(settingsModified())); - } - - shortcutEditor.data()->setKeySequence(q->globalShortcut().primary()); - layout->addWidget(shortcutEditor.data()); - layout->addStretch(); - dialog->addPage(page, i18n("Keyboard Shortcut"), "preferences-desktop-keyboard"); - - QObject::connect(dialog, SIGNAL(applyClicked()), q, SLOT(configDialogFinished()), Qt::UniqueConnection); - QObject::connect(dialog, SIGNAL(okClicked()), q, SLOT(configDialogFinished()), Qt::UniqueConnection); -#endif -} - -void AppletPrivate::configDialogFinished() -{ - if (shortcutEditor) { - QKeySequence sequence = shortcutEditor.data()->keySequence(); - if (sequence != q->globalShortcut().primary()) { - q->setGlobalShortcut(KShortcut(sequence)); - emit q->configNeedsSaving(); - } - } - - if (!configLoader) { - // the config loader will trigger this for us, so we don't need to. - propagateConfigChanged(); - if (KConfigDialog *dialog = qobject_cast(q->sender())) { - dialog->button(QDialogButtonBox::Apply)->setEnabled(false); - } - } -} - void AppletPrivate::updateShortcuts() { if (isContainment) { diff --git a/src/plasma/private/applet_p.h b/src/plasma/private/applet_p.h index 022476b6e..9c4660469 100644 --- a/src/plasma/private/applet_p.h +++ b/src/plasma/private/applet_p.h @@ -94,12 +94,6 @@ public: void scheduleModificationNotification(); KConfigGroup *mainConfigGroup(); void resetConfigurationObject(); - void addGlobalShortcutsPage(KConfigDialog *dialog); - void configDialogFinished(); - KConfigDialog *generateGenericConfigDialog(); - void addStandardConfigurationPages(KConfigDialog *dialog); - QString configDialogId() const; - QString configWindowTitle() const; void updateShortcuts(); void globalShortcutChanged(); void propagateConfigChanged(); @@ -134,9 +128,6 @@ public: KActionCollection *actions; KAction *activationAction; - // configuration - QWeakPointer shortcutEditor; //TODO: subclass KConfigDialog and encapsulate this in there - ItemStatus itemStatus; // timerEvent bookkeeping diff --git a/src/plasma/scripting/appletscript.cpp b/src/plasma/scripting/appletscript.cpp index 5019e90f1..cd21644cd 100644 --- a/src/plasma/scripting/appletscript.cpp +++ b/src/plasma/scripting/appletscript.cpp @@ -105,31 +105,6 @@ void AppletScript::configNeedsSaving() const } } -void AppletScript::showConfigurationInterface() -{ - if (applet()) { - KConfigDialog *dialog = applet()->d->generateGenericConfigDialog(); - applet()->d->addStandardConfigurationPages(dialog); - dialog->show(); - } -} - -KConfigDialog *AppletScript::standardConfigurationDialog() -{ - if (applet()) { - return applet()->d->generateGenericConfigDialog(); - } - - return 0; -} - -void AppletScript::addStandardConfigurationPages(KConfigDialog *dialog) -{ - if (applet()) { - applet()->d->addStandardConfigurationPages(dialog); - } -} - void AppletScript::configChanged() { } diff --git a/src/plasma/scripting/appletscript.h b/src/plasma/scripting/appletscript.h index b5d2d9dcf..6f3b917ef 100644 --- a/src/plasma/scripting/appletscript.h +++ b/src/plasma/scripting/appletscript.h @@ -160,11 +160,6 @@ Q_SIGNALS: public Q_SLOTS: - /** - * Show a configuration dialog. - */ - virtual void showConfigurationInterface(); - /** * Configure was changed. */ @@ -188,22 +183,6 @@ protected: */ KPluginInfo description() const; - /** - * @return a standard Plasma applet configuration dialog, ready - * to have pages added to it. - * - * Note that the dialog returned is set to delete on close. - */ - KConfigDialog *standardConfigurationDialog(); - - /** - * This method should be called after a scripting applet has added - * its own pages to a configuration dialog - * - * @since 4.3.1 - */ - void addStandardConfigurationPages(KConfigDialog *dialog); - private: friend class Applet; diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index 3140e6e47..57ebe97e1 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -438,7 +438,7 @@ bool AppletInterface::immutable() const bool AppletInterface::userConfiguring() const { - return applet()->isUserConfiguring(); + return m_configView.data()->isVisible(); } int AppletInterface::apiVersion() const