remove createConfigurationInterface

configuration interface stuff is done right now in the ConfigView class, right now in the qml scriptengine (may be moved to the shell eventually)
This commit is contained in:
Marco Martin 2013-03-01 11:36:37 +01:00
parent 099319a911
commit c3924c75b7
9 changed files with 1 additions and 337 deletions

View File

@ -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<KCModule>(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);

View File

@ -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
/**
@ -404,7 +379,6 @@ class PLASMA_EXPORT Applet : public QObject
void configNeedsSaving();
//ACTIONS
/**
* Emitted when activation is requested due to, for example, a global
@ -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())

View File

@ -507,11 +507,6 @@ QString Containment::activity() const
return d->activityId;
}
void Containment::showConfigurationInterface()
{
Applet::showConfigurationInterface();
}
} // Plasma namespace

View File

@ -279,12 +279,6 @@ Q_SIGNALS:
*/
void setFormFactor(Plasma::FormFactor formFactor);
/**
* @reimp
* @sa Applet::showConfigurationInterface()
*/
void showConfigurationInterface();
/**
* Sets the type of this containment.
*/

View File

@ -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<KConfigDialog *>(q->sender())) {
dialog->button(QDialogButtonBox::Apply)->setEnabled(false);
}
}
}
void AppletPrivate::updateShortcuts()
{
if (isContainment) {

View File

@ -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<KKeySequenceWidget> shortcutEditor; //TODO: subclass KConfigDialog and encapsulate this in there
ItemStatus itemStatus;
// timerEvent bookkeeping

View File

@ -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()
{
}

View File

@ -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;

View File

@ -438,7 +438,7 @@ bool AppletInterface::immutable() const
bool AppletInterface::userConfiguring() const
{
return applet()->isUserConfiguring();
return m_configView.data()->isVisible();
}
int AppletInterface::apiVersion() const