From 342146b2fc0d2f1a0b56b8dc507d0b717fee0741 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 25 Feb 2013 15:47:16 +0100 Subject: [PATCH] get rid of ContainmentActionsPluginConfig expose directly the hash of default plugins from Corona for the default plugins to use as containmentActions, getting rid of this class that is in the end just a wrapper --- src/plasma/CMakeLists.txt | 2 - src/plasma/containment.cpp | 5 +- .../containmentactionspluginsconfig.cpp | 93 ------------------- src/plasma/containmentactionspluginsconfig.h | 90 ------------------ src/plasma/corona.cpp | 12 ++- src/plasma/corona.h | 14 ++- src/plasma/includes/Plasma/ContainmentActions | 1 - .../containmentactionspluginsconfig_p.h | 47 ---------- src/plasma/private/corona_p.h | 2 +- 9 files changed, 20 insertions(+), 246 deletions(-) delete mode 100644 src/plasma/containmentactionspluginsconfig.cpp delete mode 100644 src/plasma/containmentactionspluginsconfig.h delete mode 100644 src/plasma/private/containmentactionspluginsconfig_p.h diff --git a/src/plasma/CMakeLists.txt b/src/plasma/CMakeLists.txt index 9dd85104e..a1bbdcfdc 100644 --- a/src/plasma/CMakeLists.txt +++ b/src/plasma/CMakeLists.txt @@ -72,7 +72,6 @@ set(plasma_LIB_SRCS abstractdialogmanager.cpp configloader.cpp containmentactions.cpp - containmentactionspluginsconfig.cpp datacontainer.cpp dataengine.cpp dataengineconsumer.cpp @@ -167,7 +166,6 @@ set(plasma_LIB_INCLUDES configloader.h containment.h containmentactions.h - containmentactionspluginsconfig.h corona.h datacontainer.h dataengine.h diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index 9d05ce81d..9ac3ceff5 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -47,12 +47,10 @@ #endif #include "containmentactions.h" -#include "containmentactionspluginsconfig.h" #include "corona.h" #include "pluginloader.h" #include "private/applet_p.h" -#include "private/containmentactionspluginsconfig_p.h" #include "plasma/plasma.h" @@ -240,9 +238,8 @@ void Containment::restore(KConfigGroup &group) addContainmentActions(key, cfg.readEntry(key, QString())); } } else { //shell defaults - ContainmentActionsPluginsConfig conf = corona()->containmentActionsDefaults(d->type); //steal the data directly, for efficiency - QHash defaults = conf.d->plugins; + QHash defaults = corona()->containmentActionsDefaults(d->type); for (QHash::const_iterator it = defaults.constBegin(), end = defaults.constEnd(); it != end; ++it) { addContainmentActions(it.key(), it.value()); diff --git a/src/plasma/containmentactionspluginsconfig.cpp b/src/plasma/containmentactionspluginsconfig.cpp deleted file mode 100644 index c0a014a0a..000000000 --- a/src/plasma/containmentactionspluginsconfig.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2009 Chani Armitage - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "containmentactionspluginsconfig.h" -#include "private/containmentactionspluginsconfig_p.h" - -#include -#include -#include -#include -#include - -#include - -#include "containmentactions.h" - -using namespace Plasma; - -namespace Plasma -{ - -ContainmentActionsPluginsConfig::ContainmentActionsPluginsConfig() - : d(new ContainmentActionsPluginsConfigPrivate(this)) -{ -} - -ContainmentActionsPluginsConfig::ContainmentActionsPluginsConfig(const ContainmentActionsPluginsConfig &other) - : d(new ContainmentActionsPluginsConfigPrivate(this)) -{ - d->plugins = other.d->plugins; -} - -ContainmentActionsPluginsConfig& ContainmentActionsPluginsConfig::operator=(const ContainmentActionsPluginsConfig &other) -{ - d->plugins = other.d->plugins; - return *this; -} - -ContainmentActionsPluginsConfig::~ContainmentActionsPluginsConfig() -{ - delete d; -} - -void ContainmentActionsPluginsConfig::clear() -{ - d->plugins.clear(); -} - -void ContainmentActionsPluginsConfig::remove(QEvent *trigger) -{ - QString s = ContainmentActions::eventToString(trigger); - d->plugins.remove(s); -} - -void ContainmentActionsPluginsConfig::addPlugin(QEvent *trigger, const QString &name) -{ - QString s = ContainmentActions::eventToString(trigger); - d->plugins.insert(s, name); -} - -void ContainmentActionsPluginsConfig::addPlugin(Qt::KeyboardModifiers modifiers, Qt::MouseButton button, const QString &name) -{ - QMouseEvent event(QEvent::MouseButtonPress, QPoint(), button, button, modifiers); - QString s = ContainmentActions::eventToString(&event); - d->plugins.insert(s, name); -} - -void ContainmentActionsPluginsConfig::addPlugin(Qt::KeyboardModifiers modifiers, Qt::Orientation wheelDirection, const QString &name) -{ - //most of those parameters are just fillers - QWheelEvent event(QPoint(0,0), 0, Qt::NoButton, modifiers, wheelDirection); - QString s = ContainmentActions::eventToString(&event); - d->plugins.insert(s, name); -} - -} // namespace Plasma - diff --git a/src/plasma/containmentactionspluginsconfig.h b/src/plasma/containmentactionspluginsconfig.h deleted file mode 100644 index 1877d194d..000000000 --- a/src/plasma/containmentactionspluginsconfig.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2009 Chani Armitage - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef PLASMA_CONTAINMENTACTIONSPLUGINSCONFIG_H -#define PLASMA_CONTAINMENTACTIONSPLUGINSCONFIG_H - -#include - -#include - -class QString; -class QEvent; - -namespace Plasma -{ - -class ContainmentActionsPluginsConfigPrivate; - -/** - * @class ContainmentActionsPluginsConfig plasma/containmentactionspluginsconfig.h - * - * @short A class that holds a map of triggers to plugin names - * @since 4.4 - */ -class PLASMA_EXPORT ContainmentActionsPluginsConfig -{ - -public: - ContainmentActionsPluginsConfig(); - ContainmentActionsPluginsConfig(const ContainmentActionsPluginsConfig &other); - ~ContainmentActionsPluginsConfig(); - ContainmentActionsPluginsConfig& operator=(const ContainmentActionsPluginsConfig &other); - - /** - * clears everything - */ - void clear(); - - /** - * removes @p trigger - * @see addPlugin for an explanation of the @p trigger - */ - void remove(QEvent *trigger); - - /** - * Sets @p trigger to plugin @p name - * if you're passing the trigger as an event, the following events are currently understood: - * -mouse press and release events: button and modifiers - * -mouse wheel events: direction and modifiers - * both traditional and graphicsscene events are supported. - */ - void addPlugin(QEvent *trigger, const QString &name); - - /** - * Sets trigger described by @p modifiers and @p button to plugin @p name - */ - void addPlugin(Qt::KeyboardModifiers modifiers, Qt::MouseButton button, const QString &name); - - /** - * Sets trigger described by @p modifiers and @p wheelDirection to plugin @p name - */ - void addPlugin(Qt::KeyboardModifiers modifiers, Qt::Orientation wheelDirection, const QString &name); - -private: - ContainmentActionsPluginsConfigPrivate *const d; - - friend class ContainmentActionsPluginsConfigPrivate; - friend class Containment; -}; - -} // namespace Plasma - -#endif - diff --git a/src/plasma/corona.cpp b/src/plasma/corona.cpp index d62f0989d..9c2de276e 100644 --- a/src/plasma/corona.cpp +++ b/src/plasma/corona.cpp @@ -41,7 +41,6 @@ #include "abstractdialogmanager.h" #include "containment.h" -#include "containmentactionspluginsconfig.h" #include "pluginloader.h" #include "private/applet_p.h" #include "private/containment_p.h" @@ -413,12 +412,17 @@ void Corona::addShortcuts(KActionCollection *newShortcuts) } } -void Corona::setContainmentActionsDefaults(Plasma::ContainmentType containmentType, const ContainmentActionsPluginsConfig &config) +void Corona::setContainmentActionsDefault(Plasma::ContainmentType containmentType, QEvent *trigger, const QString &name) { - d->containmentActionsDefaults.insert(containmentType, config); + d->containmentActionsDefaults[containmentType].insert(ContainmentActions::eventToString(trigger), name); } -ContainmentActionsPluginsConfig Corona::containmentActionsDefaults(Plasma::ContainmentType containmentType) +QString Corona::containmentActionsDefault(Plasma::ContainmentType containmentType, QEvent *trigger) const +{ + return d->containmentActionsDefaults.value(containmentType).value(ContainmentActions::eventToString(trigger)); +} + +QHash Corona::containmentActionsDefaults(ContainmentType containmentType) const { return d->containmentActionsDefaults.value(containmentType); } diff --git a/src/plasma/corona.h b/src/plasma/corona.h index 8bcdded43..db2f92544 100644 --- a/src/plasma/corona.h +++ b/src/plasma/corona.h @@ -213,16 +213,22 @@ public: KAction* addAction(QString name); /** - * @since 4.4 + * @since 5.0 * Sets the default containmentactions plugins for the given containment type */ - void setContainmentActionsDefaults(ContainmentType containmentType, const ContainmentActionsPluginsConfig &config); + void setContainmentActionsDefault(Plasma::ContainmentType containmentType, QEvent *trigger, const QString &name); /** - * @since 4.4 + * @since 5.0 * Returns the default containmentactions plugins for the given containment type */ - ContainmentActionsPluginsConfig containmentActionsDefaults(ContainmentType containmentType); + QString containmentActionsDefault(ContainmentType containmentType, QEvent *trigger) const; + + /** + * @since 5.0 + * Returns the default containmentactions plugins for the given containment type + */ + QHash containmentActionsDefaults(ContainmentType containmentType) const; /** * @param the AbstractDialogManager implementaion diff --git a/src/plasma/includes/Plasma/ContainmentActions b/src/plasma/includes/Plasma/ContainmentActions index d62585105..d957523e7 100644 --- a/src/plasma/includes/Plasma/ContainmentActions +++ b/src/plasma/includes/Plasma/ContainmentActions @@ -1,3 +1,2 @@ #include "../../plasma/containmentactions.h" -#include "../../plasma/containmentactionspluginsconfig.h" diff --git a/src/plasma/private/containmentactionspluginsconfig_p.h b/src/plasma/private/containmentactionspluginsconfig_p.h deleted file mode 100644 index 21c01b141..000000000 --- a/src/plasma/private/containmentactionspluginsconfig_p.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2009 Chani Armitage - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef PLASMA_CONTAINMENTACTIONSPLUGINSCONFIGPRIVATE_H -#define PLASMA_CONTAINMENTACTIONSPLUGINSCONFIGPRIVATE_H - -#include - -namespace Plasma -{ - -class ContainmentActionsPluginsConfigPrivate -{ -public: - ContainmentActionsPluginsConfigPrivate(ContainmentActionsPluginsConfig *config) - : q(config) - { - } - - ~ContainmentActionsPluginsConfigPrivate() - { - } - - ContainmentActionsPluginsConfig *q; - //map trigger -> pluginname - QHash plugins; -}; - -} // namespace Plasma -#endif - diff --git a/src/plasma/private/corona_p.h b/src/plasma/private/corona_p.h index 47723b49a..3c39fb782 100644 --- a/src/plasma/private/corona_p.h +++ b/src/plasma/private/corona_p.h @@ -64,7 +64,7 @@ public: QList containments; QHash offscreenWidgets; KActionCollection actions; - QMap containmentActionsDefaults; + QMap > containmentActionsDefaults; QWeakPointer shortcutsDlg; QWeakPointer dialogManager; QHash toolBoxPlugins;