* @internal: introduce a containmentConstraintsUpdated so that we can manage some containment specific things
* introduce CustomContainment types which will be more 'hands off' svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=738503
This commit is contained in:
parent
8d29e6f5e8
commit
4b8f4092a0
@ -39,10 +39,12 @@
|
||||
#include "applethandle_p.h"
|
||||
#include "corona.h"
|
||||
#include "phase.h"
|
||||
#include "toolbox_p.h"
|
||||
#include "svg.h"
|
||||
|
||||
#include "widgets/freelayout.h"
|
||||
#include "widgets/boxlayout.h"
|
||||
#include "widgets/pushbutton.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
@ -56,7 +58,8 @@ public:
|
||||
: formFactor(Planar),
|
||||
location(Floating),
|
||||
screen(0),
|
||||
immutable(false)
|
||||
immutable(false),
|
||||
toolbox(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -72,6 +75,7 @@ public:
|
||||
QMap<Applet*, AppletHandle*> handles;
|
||||
int screen;
|
||||
bool immutable;
|
||||
DesktopToolbox *toolbox;
|
||||
};
|
||||
|
||||
Containment::Containment(QGraphicsItem* parent,
|
||||
@ -105,6 +109,23 @@ void Containment::init()
|
||||
//TODO: would be nice to not do this on init, as it causes Phase to init
|
||||
connect(Phase::self(), SIGNAL(animationComplete(QGraphicsItem*,Plasma::Phase::Animation)),
|
||||
this, SLOT(appletAnimationComplete(QGraphicsItem*,Plasma::Phase::Animation)));
|
||||
|
||||
if (type() == DesktopContainment) {
|
||||
Plasma::PushButton *tool = new Plasma::PushButton(i18n("Add Widgets"));
|
||||
tool->resize(tool->sizeHint());
|
||||
addToolBoxTool(tool);
|
||||
connect(tool, SIGNAL(clicked()), this, SIGNAL(showAddWidgets()));
|
||||
|
||||
tool = new Plasma::PushButton(i18n("Zoom In"));
|
||||
connect(tool, SIGNAL(clicked()), this, SIGNAL(zoomIn()));
|
||||
tool->resize(tool->sizeHint());
|
||||
addToolBoxTool(tool);
|
||||
|
||||
tool = new Plasma::PushButton(i18n("Zoom Out"));
|
||||
connect(tool, SIGNAL(clicked()), this, SIGNAL(zoomOut()));
|
||||
tool->resize(tool->sizeHint());
|
||||
addToolBoxTool(tool);
|
||||
}
|
||||
}
|
||||
|
||||
void Containment::loadConstraints(KConfigGroup* group)
|
||||
@ -127,6 +148,13 @@ void Containment::saveConstraints(KConfigGroup* group) const
|
||||
group->writeEntry("location", (int)d->location);
|
||||
}
|
||||
|
||||
void Containment::containmentConstraintsUpdated(Plasma::Constraints constraints)
|
||||
{
|
||||
if (d->toolbox && constraints & Plasma::ScreenConstraint) {
|
||||
d->toolbox->setPos(geometry().width() - d->toolbox->boundingRect().width(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
Containment::Type Containment::type()
|
||||
{
|
||||
return DesktopContainment;
|
||||
@ -586,6 +614,17 @@ void Containment::emitLaunchActivated()
|
||||
emit launchActivated();
|
||||
}
|
||||
|
||||
void Containment::addToolBoxTool(QGraphicsItem *tool)
|
||||
{
|
||||
if (!d->toolbox) {
|
||||
d->toolbox = new DesktopToolbox(this);
|
||||
d->toolbox->setPos(geometry().width() - d->toolbox->boundingRect().width(), 0);
|
||||
}
|
||||
|
||||
d->toolbox->addTool(tool);
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#include "containment.moc"
|
||||
|
||||
|
@ -65,7 +65,9 @@ class PLASMA_EXPORT Containment : public Applet
|
||||
typedef QHash<QString, Applet*> Dict;
|
||||
|
||||
enum Type { DesktopContainment = 0 /**< A desktop containment */,
|
||||
PanelContainment /**< A desktop panel */
|
||||
PanelContainment /**< A desktop panel */,
|
||||
CustomContainment /**< A containment that is neither a desktop nor a panel,
|
||||
but something application specific */
|
||||
};
|
||||
|
||||
/**
|
||||
@ -200,6 +202,20 @@ class PLASMA_EXPORT Containment : public Applet
|
||||
*/
|
||||
void emitLaunchActivated();
|
||||
|
||||
/**
|
||||
* Adds an item to the toolbox. The toolbox takes over ownership of the item.
|
||||
* TODO: add remove and accessor methods
|
||||
*/
|
||||
void addToolBoxTool(QGraphicsItem *tool);
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Called when constraints have been updated on this containment to provide
|
||||
* constraint services common to all containments. Containments should still
|
||||
* implement their own constraintsUpdated method
|
||||
*/
|
||||
void containmentConstraintsUpdated(Plasma::Constraints constraints);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted when a new applet is created by the containment
|
||||
@ -211,6 +227,24 @@ class PLASMA_EXPORT Containment : public Applet
|
||||
*/
|
||||
void launchActivated();
|
||||
|
||||
/**
|
||||
* Emitted when the containment requests zooming out one step.
|
||||
* Usually only used for desktop containments.
|
||||
*/
|
||||
void zoomIn();
|
||||
|
||||
/**
|
||||
* Emitted when the containment requests zooming out one step.
|
||||
* Usually only used for desktop containments.
|
||||
*/
|
||||
void zoomOut();
|
||||
|
||||
/**
|
||||
* Emitted when the containment requests an add widgets dialog is shown.
|
||||
* Usually only used for desktop containments.
|
||||
*/
|
||||
void showAddWidgets();
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Informs the Corona as to what position it is in. This is informational
|
||||
|
Loading…
Reference in New Issue
Block a user