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
This commit is contained in:
parent
c3a536a7a4
commit
342146b2fc
@ -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
|
||||
|
@ -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<QString,QString> defaults = conf.d->plugins;
|
||||
QHash<QString,QString> defaults = corona()->containmentActionsDefaults(d->type);
|
||||
for (QHash<QString,QString>::const_iterator it = defaults.constBegin(),
|
||||
end = defaults.constEnd(); it != end; ++it) {
|
||||
addContainmentActions(it.key(), it.value());
|
||||
|
@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Chani Armitage <chani@kde.org>
|
||||
*
|
||||
* 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 <QHash>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QWheelEvent>
|
||||
#include <QString>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#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
|
||||
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Chani Armitage <chani@kde.org>
|
||||
*
|
||||
* 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 <plasma/plasma_export.h>
|
||||
|
||||
#include <Qt>
|
||||
|
||||
class QString;
|
||||
class QEvent;
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class ContainmentActionsPluginsConfigPrivate;
|
||||
|
||||
/**
|
||||
* @class ContainmentActionsPluginsConfig plasma/containmentactionspluginsconfig.h <Plasma/ContainmentActionsPluginsConfig>
|
||||
*
|
||||
* @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
|
||||
|
@ -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<QString, QString> Corona::containmentActionsDefaults(ContainmentType containmentType) const
|
||||
{
|
||||
return d->containmentActionsDefaults.value(containmentType);
|
||||
}
|
||||
|
@ -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<QString, QString> containmentActionsDefaults(ContainmentType containmentType) const;
|
||||
|
||||
/**
|
||||
* @param the AbstractDialogManager implementaion
|
||||
|
@ -1,3 +1,2 @@
|
||||
#include "../../plasma/containmentactions.h"
|
||||
#include "../../plasma/containmentactionspluginsconfig.h"
|
||||
|
||||
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Chani Armitage <chani@kde.org>
|
||||
*
|
||||
* 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 <QHash>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class ContainmentActionsPluginsConfigPrivate
|
||||
{
|
||||
public:
|
||||
ContainmentActionsPluginsConfigPrivate(ContainmentActionsPluginsConfig *config)
|
||||
: q(config)
|
||||
{
|
||||
}
|
||||
|
||||
~ContainmentActionsPluginsConfigPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
ContainmentActionsPluginsConfig *q;
|
||||
//map trigger -> pluginname
|
||||
QHash<QString, QString> plugins;
|
||||
};
|
||||
|
||||
} // namespace Plasma
|
||||
#endif
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
QList<Containment*> containments;
|
||||
QHash<uint, QGraphicsWidget*> offscreenWidgets;
|
||||
KActionCollection actions;
|
||||
QMap<Plasma::ContainmentType, ContainmentActionsPluginsConfig> containmentActionsDefaults;
|
||||
QMap<Plasma::ContainmentType, QHash<QString, QString> > containmentActionsDefaults;
|
||||
QWeakPointer<KShortcutsDialog> shortcutsDlg;
|
||||
QWeakPointer<AbstractDialogManager> dialogManager;
|
||||
QHash<Plasma::ContainmentType, QString> toolBoxPlugins;
|
||||
|
Loading…
Reference in New Issue
Block a user