give corona its own action collection.
this is a place for things which shouldn't be duplicated over every single containment, like "lock" and "new activity". for now we still add the lock action to every containment, so that none of the code lower down notices the change - but we only have one action behind it all :) svn path=/trunk/KDE/kdelibs/; revision=937923
This commit is contained in:
parent
324b6f11d4
commit
aa34398a80
@ -160,16 +160,12 @@ void Containment::init()
|
|||||||
action->setShortcut(QKeySequence("alt+d,p"));
|
action->setShortcut(QKeySequence("alt+d,p"));
|
||||||
d->actions().addAction("previous applet", action);
|
d->actions().addAction("previous applet", action);
|
||||||
|
|
||||||
if (immutability() != SystemImmutable) {
|
if (immutability() != SystemImmutable && corona()) {
|
||||||
//FIXME I'm not certain this belongs in Containment
|
QAction *lockDesktopAction = corona()->action("lock widgets");
|
||||||
//but it sure is nice to have the keyboard shortcut in every containment by default
|
//keep a pointer so nobody notices it moved to corona
|
||||||
KAction *lockDesktopAction =
|
if (lockDesktopAction) {
|
||||||
new KAction(unlocked ? i18n("Lock Widgets") : i18n("Unlock Widgets"), this);
|
d->actions().addAction("lock widgets", lockDesktopAction);
|
||||||
lockDesktopAction->setIcon(KIcon(unlocked ? "object-locked" : "object-unlocked"));
|
}
|
||||||
connect(lockDesktopAction, SIGNAL(triggered(bool)),
|
|
||||||
this, SLOT(toggleDesktopImmutability()));
|
|
||||||
lockDesktopAction->setShortcut(QKeySequence("alt+d,l"));
|
|
||||||
d->actions().addAction("lock widgets", lockDesktopAction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->type != PanelContainment &&
|
if (d->type != PanelContainment &&
|
||||||
@ -1513,35 +1509,6 @@ void Containment::destroy(bool confirm)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainmentPrivate::toggleDesktopImmutability()
|
|
||||||
{
|
|
||||||
if (q->corona()) {
|
|
||||||
if (q->corona()->immutability() == Mutable) {
|
|
||||||
q->corona()->setImmutability(UserImmutable);
|
|
||||||
} else if (q->corona()->immutability() == UserImmutable) {
|
|
||||||
q->corona()->setImmutability(Mutable);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (q->immutability() == Mutable) {
|
|
||||||
q->setImmutability(UserImmutable);
|
|
||||||
} else if (q->immutability() == UserImmutable) {
|
|
||||||
q->setImmutability(Mutable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (q->immutability() != Mutable) {
|
|
||||||
QMap<Applet*, AppletHandle*> h = handles;
|
|
||||||
handles.clear();
|
|
||||||
|
|
||||||
foreach (AppletHandle *handle, h) {
|
|
||||||
handle->disconnect(q);
|
|
||||||
handle->deleteLater();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//setLockToolText();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainmentPrivate::zoomIn()
|
void ContainmentPrivate::zoomIn()
|
||||||
{
|
{
|
||||||
emit q->zoomRequested(q, Plasma::ZoomIn);
|
emit q->zoomRequested(q, Plasma::ZoomIn);
|
||||||
@ -1650,6 +1617,17 @@ void ContainmentPrivate::containmentConstraintsEvent(Plasma::Constraints constra
|
|||||||
toolBox->setIsMovable(unlocked);
|
toolBox->setIsMovable(unlocked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//clear handles on lock
|
||||||
|
if (!unlocked) {
|
||||||
|
QMap<Applet*, AppletHandle*> h = handles;
|
||||||
|
handles.clear();
|
||||||
|
|
||||||
|
foreach (AppletHandle *handle, h) {
|
||||||
|
handle->disconnect(q);
|
||||||
|
handle->deleteLater();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constraints & Plasma::FormFactorConstraint) {
|
if (constraints & Plasma::FormFactorConstraint) {
|
||||||
|
@ -515,7 +515,6 @@ class PLASMA_EXPORT Containment : public Applet
|
|||||||
Q_PRIVATE_SLOT(d, void positionToolBox())
|
Q_PRIVATE_SLOT(d, void positionToolBox())
|
||||||
Q_PRIVATE_SLOT(d, void zoomIn())
|
Q_PRIVATE_SLOT(d, void zoomIn())
|
||||||
Q_PRIVATE_SLOT(d, void zoomOut())
|
Q_PRIVATE_SLOT(d, void zoomOut())
|
||||||
Q_PRIVATE_SLOT(d, void toggleDesktopImmutability())
|
|
||||||
Q_PRIVATE_SLOT(d, void requestConfiguration())
|
Q_PRIVATE_SLOT(d, void requestConfiguration())
|
||||||
|
|
||||||
friend class Applet;
|
friend class Applet;
|
||||||
|
39
corona.cpp
39
corona.cpp
@ -35,6 +35,8 @@
|
|||||||
#include <kglobal.h>
|
#include <kglobal.h>
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
#include <kmimetype.h>
|
#include <kmimetype.h>
|
||||||
|
#include <kactioncollection.h>
|
||||||
|
#include <kaction.h>
|
||||||
|
|
||||||
#include "containment.h"
|
#include "containment.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
@ -57,7 +59,8 @@ public:
|
|||||||
: q(corona),
|
: q(corona),
|
||||||
immutability(Mutable),
|
immutability(Mutable),
|
||||||
mimetype("text/x-plasmoidservicename"),
|
mimetype("text/x-plasmoidservicename"),
|
||||||
config(0)
|
config(0),
|
||||||
|
actions(corona)
|
||||||
{
|
{
|
||||||
if (KGlobal::hasMainComponent()) {
|
if (KGlobal::hasMainComponent()) {
|
||||||
configName = KGlobal::mainComponent().componentName() + "-appletsrc";
|
configName = KGlobal::mainComponent().componentName() + "-appletsrc";
|
||||||
@ -75,6 +78,24 @@ public:
|
|||||||
{
|
{
|
||||||
configSyncTimer.setSingleShot(true);
|
configSyncTimer.setSingleShot(true);
|
||||||
QObject::connect(&configSyncTimer, SIGNAL(timeout()), q, SLOT(syncConfig()));
|
QObject::connect(&configSyncTimer, SIGNAL(timeout()), q, SLOT(syncConfig()));
|
||||||
|
|
||||||
|
//some common actions
|
||||||
|
KAction *lockAction = new KAction(i18n("Lock Widgets"), q);
|
||||||
|
lockAction->setIcon(KIcon("object-locked"));
|
||||||
|
QObject::connect(lockAction, SIGNAL(triggered(bool)),
|
||||||
|
q, SLOT(toggleImmutability()));
|
||||||
|
lockAction->setShortcut(QKeySequence("alt+d,l"));
|
||||||
|
lockAction->setShortcutContext(Qt::ApplicationShortcut);
|
||||||
|
actions.addAction("lock widgets", lockAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleImmutability()
|
||||||
|
{
|
||||||
|
if (immutability == Mutable) {
|
||||||
|
q->setImmutability(UserImmutable);
|
||||||
|
} else {
|
||||||
|
q->setImmutability(Mutable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveLayout(KSharedConfigPtr cg) const
|
void saveLayout(KSharedConfigPtr cg) const
|
||||||
@ -192,6 +213,7 @@ public:
|
|||||||
QTimer configSyncTimer;
|
QTimer configSyncTimer;
|
||||||
QList<Containment*> containments;
|
QList<Containment*> containments;
|
||||||
QHash<uint, QGraphicsWidget*> offscreenWidgets;
|
QHash<uint, QGraphicsWidget*> offscreenWidgets;
|
||||||
|
KActionCollection actions;
|
||||||
};
|
};
|
||||||
|
|
||||||
Corona::Corona(QObject *parent)
|
Corona::Corona(QObject *parent)
|
||||||
@ -569,6 +591,21 @@ QList<Plasma::Location> Corona::freeEdges(int screen) const
|
|||||||
return freeEdges;
|
return freeEdges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QAction *Corona::action(QString name) const
|
||||||
|
{
|
||||||
|
return d->actions.action(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Corona::addAction(QString name, QAction *action)
|
||||||
|
{
|
||||||
|
d->actions.addAction(name, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QAction*> Corona::actions() const
|
||||||
|
{
|
||||||
|
return d->actions.actions();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
|
||||||
#include "corona.moc"
|
#include "corona.moc"
|
||||||
|
17
corona.h
17
corona.h
@ -28,6 +28,7 @@
|
|||||||
#include <plasma/plasma_export.h>
|
#include <plasma/plasma_export.h>
|
||||||
|
|
||||||
class QGraphicsGridLayout;
|
class QGraphicsGridLayout;
|
||||||
|
class QAction;
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
@ -155,6 +156,21 @@ public:
|
|||||||
*/
|
*/
|
||||||
QList<Plasma::Location> freeEdges(int screen) const;
|
QList<Plasma::Location> freeEdges(int screen) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the QAction with the given name from our collection
|
||||||
|
*/
|
||||||
|
QAction *action(QString name) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the action to our collection under the given name
|
||||||
|
*/
|
||||||
|
void addAction(QString name, QAction *action);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all the actions in our collection
|
||||||
|
*/
|
||||||
|
QList<QAction*> actions() const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Initializes the layout from a config file. This will first clear any existing
|
* Initializes the layout from a config file. This will first clear any existing
|
||||||
@ -277,6 +293,7 @@ private:
|
|||||||
Q_PRIVATE_SLOT(d, void containmentDestroyed(QObject*))
|
Q_PRIVATE_SLOT(d, void containmentDestroyed(QObject*))
|
||||||
Q_PRIVATE_SLOT(d, void offscreenWidgetDestroyed(QObject *))
|
Q_PRIVATE_SLOT(d, void offscreenWidgetDestroyed(QObject *))
|
||||||
Q_PRIVATE_SLOT(d, void syncConfig())
|
Q_PRIVATE_SLOT(d, void syncConfig())
|
||||||
|
Q_PRIVATE_SLOT(d, void toggleImmutability())
|
||||||
|
|
||||||
friend class CoronaPrivate;
|
friend class CoronaPrivate;
|
||||||
};
|
};
|
||||||
|
@ -84,13 +84,6 @@ public:
|
|||||||
bool showContextMenu(const QPointF &point, const QPoint &screenPos, bool includeApplet);
|
bool showContextMenu(const QPointF &point, const QPoint &screenPos, bool includeApplet);
|
||||||
void checkRemoveAction();
|
void checkRemoveAction();
|
||||||
|
|
||||||
/**
|
|
||||||
* Locks or unlocks plasma's applets.
|
|
||||||
* When plasma is locked, applets cannot be transformed, added or deleted
|
|
||||||
* but they can still be configured.
|
|
||||||
*/
|
|
||||||
void toggleDesktopImmutability();
|
|
||||||
|
|
||||||
Applet *addApplet(const QString &name, const QVariantList &args = QVariantList(),
|
Applet *addApplet(const QString &name, const QVariantList &args = QVariantList(),
|
||||||
const QRectF &geometry = QRectF(-1, -1, -1, -1), uint id = 0,
|
const QRectF &geometry = QRectF(-1, -1, -1, -1), uint id = 0,
|
||||||
bool delayedInit = false);
|
bool delayedInit = false);
|
||||||
|
Loading…
Reference in New Issue
Block a user