correctly build applet and containment
This commit is contained in:
parent
cc21f6fcfe
commit
64fde089f2
@ -190,17 +190,17 @@ set(plasma_LIB_SRCS
|
|||||||
#FIXME: all these must move into the qgv library
|
#FIXME: all these must move into the qgv library
|
||||||
private/themedwidgetinterface.cpp
|
private/themedwidgetinterface.cpp
|
||||||
widgets/iconwidget.cpp
|
widgets/iconwidget.cpp
|
||||||
abstracttoolbox.cpp
|
#view.cpp
|
||||||
view.cpp
|
|
||||||
applet.cpp
|
applet.cpp
|
||||||
containment.cpp
|
containment.cpp
|
||||||
corona.cpp
|
corona.cpp
|
||||||
dialog.cpp
|
#dialog.cpp
|
||||||
popupapplet.cpp
|
popupapplet.cpp
|
||||||
private/applethandle.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set (plasmaqgv_LIB_SRCS
|
set (plasmaqgv_LIB_SRCS
|
||||||
|
private/applethandle.cpp
|
||||||
|
abstracttoolbox.cpp
|
||||||
delegate.cpp
|
delegate.cpp
|
||||||
#FIXME: this is duplicated with libplasma because iconwidget requires it!
|
#FIXME: this is duplicated with libplasma because iconwidget requires it!
|
||||||
private/themedwidgetinterface.cpp
|
private/themedwidgetinterface.cpp
|
||||||
|
273
applet.cpp
273
applet.cpp
@ -205,7 +205,6 @@ Applet::~Applet()
|
|||||||
|
|
||||||
void Applet::init()
|
void Applet::init()
|
||||||
{
|
{
|
||||||
setFlag(ItemIsMovable, true);
|
|
||||||
if (d->script) {
|
if (d->script) {
|
||||||
d->setupScriptSupport();
|
d->setupScriptSupport();
|
||||||
|
|
||||||
@ -360,7 +359,11 @@ KConfigGroup Applet::globalConfig() const
|
|||||||
KConfigGroup globalAppletConfig;
|
KConfigGroup globalAppletConfig;
|
||||||
QString group = isContainment() ? "ContainmentGlobals" : "AppletGlobals";
|
QString group = isContainment() ? "ContainmentGlobals" : "AppletGlobals";
|
||||||
|
|
||||||
Corona *corona = qobject_cast<Corona*>(scene());
|
Containment *cont = containment();
|
||||||
|
Corona *corona = 0;
|
||||||
|
if (cont) {
|
||||||
|
corona = cont->corona();
|
||||||
|
}
|
||||||
if (corona) {
|
if (corona) {
|
||||||
KSharedConfig::Ptr coronaConfig = corona->config();
|
KSharedConfig::Ptr coronaConfig = corona->config();
|
||||||
globalAppletConfig = KConfigGroup(coronaConfig, group);
|
globalAppletConfig = KConfigGroup(coronaConfig, group);
|
||||||
@ -402,45 +405,20 @@ Package Applet::package() const
|
|||||||
return d->package ? *d->package : Package();
|
return d->package ? *d->package : Package();
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsView *Applet::view() const
|
|
||||||
{
|
|
||||||
// It's assumed that we won't be visible on more than one view here.
|
|
||||||
// Anything that actually needs view() should only really care about
|
|
||||||
// one of them anyway though.
|
|
||||||
if (!scene()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QGraphicsView *found = 0;
|
|
||||||
QGraphicsView *possibleFind = 0;
|
|
||||||
//kDebug() << "looking through" << scene()->views().count() << "views";
|
|
||||||
foreach (QGraphicsView *view, scene()->views()) {
|
|
||||||
//kDebug() << " checking" << view << view->sceneRect()
|
|
||||||
// << "against" << sceneBoundingRect() << scenePos();
|
|
||||||
if (view->sceneRect().intersects(sceneBoundingRect()) ||
|
|
||||||
view->sceneRect().contains(scenePos())) {
|
|
||||||
//kDebug() << " found something!" << view->isActiveWindow();
|
|
||||||
if (view->isActiveWindow()) {
|
|
||||||
found = view;
|
|
||||||
} else {
|
|
||||||
possibleFind = view;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return found ? found : possibleFind;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF Applet::mapFromView(const QGraphicsView *view, const QRect &rect) const
|
QRectF Applet::mapFromView(const QGraphicsView *view, const QRect &rect) const
|
||||||
{
|
{
|
||||||
|
return QRect();
|
||||||
|
/*TODO: port away qgv
|
||||||
// Why is this adjustment needed? Qt calculation error?
|
// Why is this adjustment needed? Qt calculation error?
|
||||||
return mapFromScene(view->mapToScene(rect)).boundingRect().adjusted(0, 0, 1, 1);
|
return mapFromScene(view->mapToScene(rect)).boundingRect().adjusted(0, 0, 1, 1);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect Applet::mapToView(const QGraphicsView *view, const QRectF &rect) const
|
QRect Applet::mapToView(const QGraphicsView *view, const QRectF &rect) const
|
||||||
{
|
{
|
||||||
|
return QRect();
|
||||||
|
/*TODO: port away qgv
|
||||||
// Why is this adjustment needed? Qt calculation error?
|
// Why is this adjustment needed? Qt calculation error?
|
||||||
return view->mapFromScene(mapToScene(rect)).boundingRect().adjusted(0, 0, -1, -1);
|
return view->mapFromScene(mapToScene(rect)).boundingRect().adjusted(0, 0, -1, -1);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint Applet::popupPosition(const QSize &s) const
|
QPoint Applet::popupPosition(const QSize &s) const
|
||||||
@ -450,7 +428,11 @@ QPoint Applet::popupPosition(const QSize &s) const
|
|||||||
|
|
||||||
QPoint Applet::popupPosition(const QSize &s, Qt::AlignmentFlag alignment) const
|
QPoint Applet::popupPosition(const QSize &s, Qt::AlignmentFlag alignment) const
|
||||||
{
|
{
|
||||||
Corona * corona = qobject_cast<Corona*>(scene());
|
Containment *cont = containment();
|
||||||
|
Corona *corona = 0;
|
||||||
|
if (cont) {
|
||||||
|
corona = cont->corona();
|
||||||
|
}
|
||||||
Q_ASSERT(corona);
|
Q_ASSERT(corona);
|
||||||
|
|
||||||
return corona->popupPosition(this, s, alignment);
|
return corona->popupPosition(this, s, alignment);
|
||||||
@ -580,8 +562,6 @@ ImmutabilityType Applet::immutability() const
|
|||||||
|
|
||||||
if (cont) {
|
if (cont) {
|
||||||
upperImmutability = cont->immutability();
|
upperImmutability = cont->immutability();
|
||||||
} else if (Corona *corona = qobject_cast<Corona*>(scene())) {
|
|
||||||
upperImmutability = corona->immutability();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (upperImmutability != Mutable) {
|
if (upperImmutability != Mutable) {
|
||||||
@ -637,7 +617,6 @@ void Applet::setBackgroundHints(const Plasma::BackgroundHints hints)
|
|||||||
d->background->setEnabledBorders(Plasma::FrameSvg::AllBorders);
|
d->background->setEnabledBorders(Plasma::FrameSvg::AllBorders);
|
||||||
qreal left, top, right, bottom;
|
qreal left, top, right, bottom;
|
||||||
d->background->getMargins(left, top, right, bottom);
|
d->background->getMargins(left, top, right, bottom);
|
||||||
setContentsMargins(left, right, top, bottom);
|
|
||||||
QSizeF fitSize(left + right, top + bottom);
|
QSizeF fitSize(left + right, top + bottom);
|
||||||
d->background->resizeFrame(boundingRect().size());
|
d->background->resizeFrame(boundingRect().size());
|
||||||
|
|
||||||
@ -656,10 +635,7 @@ void Applet::setBackgroundHints(const Plasma::BackgroundHints hints)
|
|||||||
|
|
||||||
delete d->background;
|
delete d->background;
|
||||||
d->background = 0;
|
d->background = 0;
|
||||||
setContentsMargins(0, 0, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Applet::hasFailedToLaunch() const
|
bool Applet::hasFailedToLaunch() const
|
||||||
@ -748,7 +724,11 @@ void Applet::flushPendingConstraintsEvents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
d->updateShortcuts();
|
d->updateShortcuts();
|
||||||
Corona * corona = qobject_cast<Corona*>(scene());
|
Containment *cont = containment();
|
||||||
|
Corona *corona = 0;
|
||||||
|
if (cont) {
|
||||||
|
corona = cont->corona();
|
||||||
|
}
|
||||||
if (corona) {
|
if (corona) {
|
||||||
connect(corona, SIGNAL(shortcutsChanged()), this, SLOT(updateShortcuts()), Qt::UniqueConnection);
|
connect(corona, SIGNAL(shortcutsChanged()), this, SLOT(updateShortcuts()), Qt::UniqueConnection);
|
||||||
}
|
}
|
||||||
@ -773,11 +753,6 @@ void Applet::flushPendingConstraintsEvents()
|
|||||||
AppletHandle *h = d->handle.data();
|
AppletHandle *h = d->handle.data();
|
||||||
disconnect(this);
|
disconnect(this);
|
||||||
|
|
||||||
QGraphicsScene *s = scene();
|
|
||||||
if (s && h->scene() == s) {
|
|
||||||
s->removeItem(h);
|
|
||||||
}
|
|
||||||
|
|
||||||
h->deleteLater();
|
h->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,10 +761,6 @@ void Applet::flushPendingConstraintsEvents()
|
|||||||
|
|
||||||
if (c & Plasma::SizeConstraint) {
|
if (c & Plasma::SizeConstraint) {
|
||||||
d->positionMessageOverlay();
|
d->positionMessageOverlay();
|
||||||
|
|
||||||
if (d->started && layout()) {
|
|
||||||
layout()->updateGeometry();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c & Plasma::FormFactorConstraint) {
|
if (c & Plasma::FormFactorConstraint) {
|
||||||
@ -802,14 +773,6 @@ void Applet::flushPendingConstraintsEvents()
|
|||||||
d->preferredBackgroundHints = hints;
|
d->preferredBackgroundHints = hints;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->failed) {
|
|
||||||
if (f == Vertical || f == Horizontal) {
|
|
||||||
QGraphicsLayoutItem *item = layout()->itemAt(1);
|
|
||||||
layout()->removeAt(1);
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// avoid putting rotated applets in panels
|
// avoid putting rotated applets in panels
|
||||||
if (f == Vertical || f == Horizontal) {
|
if (f == Vertical || f == Horizontal) {
|
||||||
QTransform at;
|
QTransform at;
|
||||||
@ -843,7 +806,6 @@ void Applet::flushPendingConstraintsEvents()
|
|||||||
setSizePolicy(d->preferredSizePolicy);
|
setSizePolicy(d->preferredSizePolicy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateGeometry();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now take care of constraints in special subclasses: Contaiment and PopupApplet
|
// now take care of constraints in special subclasses: Contaiment and PopupApplet
|
||||||
@ -917,11 +879,6 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal left, top, right, bottom;
|
|
||||||
getContentsMargins(&left, &top, &right, &bottom);
|
|
||||||
QRect contentsRect = QRectF(QPointF(0, 0),
|
|
||||||
boundingRect().size()).adjusted(left, top, -right, -bottom).toRect();
|
|
||||||
|
|
||||||
if (widget && d->isContainment) {
|
if (widget && d->isContainment) {
|
||||||
// note that the widget we get is actually the viewport of the view, not the view itself
|
// note that the widget we get is actually the viewport of the view, not the view itself
|
||||||
View* v = qobject_cast<Plasma::View*>(widget->parent());
|
View* v = qobject_cast<Plasma::View*>(widget->parent());
|
||||||
@ -938,37 +895,13 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
|
|||||||
wallpaperConfig = KConfigGroup(&wallpaperConfig, "Wallpaper");
|
wallpaperConfig = KConfigGroup(&wallpaperConfig, "Wallpaper");
|
||||||
wallpaperConfig = KConfigGroup(&wallpaperConfig, w->pluginName());
|
wallpaperConfig = KConfigGroup(&wallpaperConfig, w->pluginName());
|
||||||
w->restore(wallpaperConfig);
|
w->restore(wallpaperConfig);
|
||||||
disconnect(w, SIGNAL(update(QRectF)), this, SLOT(updateRect(QRectF)));
|
|
||||||
connect(w, SIGNAL(update(QRectF)), this, SLOT(updateRect(QRectF)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
c->wallpaper()->paint(painter, option->exposedRect);
|
c->wallpaper()->paint(painter, option->exposedRect);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
// .. and now paint the actual containment interface, but with
|
|
||||||
// a Containment style option based on the one we get
|
|
||||||
// the view must be assigned only if its containment is actually our own
|
|
||||||
Containment::StyleOption coption(*option);
|
|
||||||
if (v && v->containment() == containment()) {
|
|
||||||
coption.view = v;
|
|
||||||
}
|
|
||||||
paintInterface(painter, &coption, contentsRect);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//kDebug() << "paint interface of" << (QObject*) this;
|
|
||||||
// paint the applet's interface
|
|
||||||
paintInterface(painter, option, contentsRect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Applet::paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect)
|
|
||||||
{
|
|
||||||
if (d->script) {
|
|
||||||
d->script->paintInterface(painter, option, contentsRect);
|
|
||||||
} else {
|
|
||||||
//kDebug() << "Applet::paintInterface() default impl";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -976,17 +909,10 @@ FormFactor Applet::formFactor() const
|
|||||||
{
|
{
|
||||||
Containment *c = containment();
|
Containment *c = containment();
|
||||||
QObject *pw = qobject_cast<QObject *>(parent());
|
QObject *pw = qobject_cast<QObject *>(parent());
|
||||||
if (!pw) {
|
|
||||||
pw = dynamic_cast<QObject *>(parentItem());
|
|
||||||
}
|
|
||||||
Plasma::Applet *parentApplet = qobject_cast<Plasma::Applet *>(pw);
|
Plasma::Applet *parentApplet = qobject_cast<Plasma::Applet *>(pw);
|
||||||
//assumption: this loop is usually is -really- short or doesn't run at all
|
//assumption: this loop is usually is -really- short or doesn't run at all
|
||||||
while (!parentApplet && pw && pw->parentWidget()) {
|
while (!parentApplet && pw && pw->parent()) {
|
||||||
QObject *parentWidget = qobject_cast<QObject *>(pw->parent());
|
pw = pw->parent();
|
||||||
if (!parentWidget) {
|
|
||||||
parentWidget = dynamic_cast<QObject *>(pw->parentItem());
|
|
||||||
}
|
|
||||||
pw = parentWidget;
|
|
||||||
parentApplet = qobject_cast<Plasma::Applet *>(pw);
|
parentApplet = qobject_cast<Plasma::Applet *>(pw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -999,10 +925,10 @@ FormFactor Applet::formFactor() const
|
|||||||
// a popupapplet can always be constrained.
|
// a popupapplet can always be constrained.
|
||||||
// a normal applet should to but
|
// a normal applet should to but
|
||||||
//FIXME: not always constrained to not break systemmonitor
|
//FIXME: not always constrained to not break systemmonitor
|
||||||
if (parentApplet && parentApplet != c && c != this && (pa || layout())) {
|
if (parentApplet && parentApplet != c && c != this) {
|
||||||
if (pa || (parentApplet->size().height() < layout()->effectiveSizeHint(Qt::MinimumSize).height())) {
|
if (pa || (parentApplet->size().height() < sizeHint(Qt::MinimumSize).height())) {
|
||||||
return Plasma::Horizontal;
|
return Plasma::Horizontal;
|
||||||
} else if (pa || (parentApplet->size().width() < layout()->effectiveSizeHint(Qt::MinimumSize).width())) {
|
} else if (pa || (parentApplet->size().width() < sizeHint(Qt::MinimumSize).width())) {
|
||||||
return Plasma::Vertical;
|
return Plasma::Vertical;
|
||||||
}
|
}
|
||||||
return parentApplet->formFactor();
|
return parentApplet->formFactor();
|
||||||
@ -1020,7 +946,7 @@ Containment *Applet::containment() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject *parent = parentItem();
|
QObject *parent = this->parent();
|
||||||
Containment *c = 0;
|
Containment *c = 0;
|
||||||
|
|
||||||
while (parent) {
|
while (parent) {
|
||||||
@ -1029,7 +955,7 @@ Containment *Applet::containment() const
|
|||||||
c = possibleC;
|
c = possibleC;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
parent = parent->parentItem();
|
parent = parent->parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!c) {
|
if (!c) {
|
||||||
@ -1121,34 +1047,6 @@ void Applet::setAspectRatioMode(Plasma::AspectRatioMode mode)
|
|||||||
d->aspectRatioMode = mode;
|
d->aspectRatioMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Applet::registerAsDragHandle(QObject *item)
|
|
||||||
{
|
|
||||||
if (!item || d->registeredAsDragHandle.contains(item)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
d->registeredAsDragHandle.insert(item);
|
|
||||||
item->installSceneEventFilter(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Applet::unregisterAsDragHandle(QObject *item)
|
|
||||||
{
|
|
||||||
if (!item) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (d->registeredAsDragHandle.remove(item)) {
|
|
||||||
if (item != this) {
|
|
||||||
item->removeSceneEventFilter(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Applet::isRegisteredAsDragHandle(QObject *item)
|
|
||||||
{
|
|
||||||
return d->registeredAsDragHandle.contains(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Applet::hasConfigurationInterface() const
|
bool Applet::hasConfigurationInterface() const
|
||||||
{
|
{
|
||||||
return d->hasConfigurationInterface;
|
return d->hasConfigurationInterface;
|
||||||
@ -1210,106 +1108,6 @@ void Applet::setHasConfigurationInterface(bool hasInterface)
|
|||||||
d->hasConfigurationInterface = hasInterface;
|
d->hasConfigurationInterface = hasInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Applet::sceneEventFilter(QObject *watched, QEvent *event)
|
|
||||||
{
|
|
||||||
if (watched == this) {
|
|
||||||
switch (event->type()) {
|
|
||||||
case QEvent::GraphicsSceneHoverEnter:
|
|
||||||
//kDebug() << "got hoverenterEvent" << immutability() << " " << immutability();
|
|
||||||
if (immutability() == Mutable) {
|
|
||||||
QObject *pw = this;
|
|
||||||
//This is for the rare case of applet in applet (systray)
|
|
||||||
//if the applet is in an applet that is not a containment, don't create the handle BUG:301648
|
|
||||||
while (pw = pw->parentWidget()) {
|
|
||||||
if (qobject_cast<Containment *>(pw)) {
|
|
||||||
break;
|
|
||||||
} else if (qobject_cast<Applet *>(pw)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QGraphicsSceneHoverEvent *he = static_cast<QGraphicsSceneHoverEvent*>(event);
|
|
||||||
if (d->handle) {
|
|
||||||
d->handle.data()->setHoverPos(he->pos());
|
|
||||||
} else {
|
|
||||||
//kDebug() << "generated applet handle";
|
|
||||||
AppletHandle *handle = new AppletHandle(containment(), this, he->pos());
|
|
||||||
|
|
||||||
connect(this, SIGNAL(geometryChanged()),
|
|
||||||
handle, SLOT(appletResized()));
|
|
||||||
d->handle = handle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case QEvent::GraphicsSceneHoverMove:
|
|
||||||
if (d->handle && !d->handle.data()->shown() && immutability() == Mutable) {
|
|
||||||
QGraphicsSceneHoverEvent *he = static_cast<QGraphicsSceneHoverEvent*>(event);
|
|
||||||
d->handle.data()->setHoverPos(he->pos());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (event->type()) {
|
|
||||||
case QEvent::GraphicsSceneMouseMove:
|
|
||||||
case QEvent::GraphicsSceneMousePress:
|
|
||||||
case QEvent::GraphicsSceneMouseRelease:
|
|
||||||
{
|
|
||||||
// don't move when the containment is not mutable,
|
|
||||||
// in the rare case the containment doesn't exists consider it as mutable
|
|
||||||
if ((flags() & ItemIsMovable) && d->registeredAsDragHandle.contains(watched)) {
|
|
||||||
Containment *c = containment();
|
|
||||||
if (!c || c->immutability() == Mutable) {
|
|
||||||
scene()->sendEvent(this, event);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QObject::sceneEventFilter(watched, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Applet::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|
||||||
{
|
|
||||||
if (immutability() == Mutable && formFactor() == Plasma::Planar && (flags() & ItemIsMovable)) {
|
|
||||||
QObject::mouseMoveEvent(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Applet::focusInEvent(QFocusEvent *event)
|
|
||||||
{
|
|
||||||
if (!isContainment() && containment()) {
|
|
||||||
//focusing an applet may trigger this event again, but we won't be here more than twice
|
|
||||||
containment()->d->focusApplet(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
QObject::focusInEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Applet::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|
||||||
{
|
|
||||||
QObject::resizeEvent(event);
|
|
||||||
|
|
||||||
if (d->background) {
|
|
||||||
d->background->resizeFrame(boundingRect().size());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateConstraints(Plasma::SizeConstraint);
|
|
||||||
|
|
||||||
d->scheduleModificationNotification();
|
|
||||||
emit geometryChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Applet::isUserConfiguring() const
|
bool Applet::isUserConfiguring() const
|
||||||
{
|
{
|
||||||
return KConfigDialog::exists(d->configDialogId());
|
return KConfigDialog::exists(d->configDialogId());
|
||||||
@ -1621,18 +1419,9 @@ Applet *Applet::loadPlasmoid(const QString &path, uint appletId, const QVariantL
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainterPath Applet::shape() const
|
|
||||||
{
|
|
||||||
if (d->script) {
|
|
||||||
return d->script->shape();
|
|
||||||
}
|
|
||||||
|
|
||||||
return QObject::shape();
|
|
||||||
}
|
|
||||||
|
|
||||||
QSizeF Applet::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
|
QSizeF Applet::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
|
||||||
{
|
{
|
||||||
QSizeF hint = QObject::sizeHint(which, constraint);
|
QSizeF hint(-1, -1);
|
||||||
const FormFactor ff = formFactor();
|
const FormFactor ff = formFactor();
|
||||||
|
|
||||||
// in panels make sure that the contents won't exit from the panel
|
// in panels make sure that the contents won't exit from the panel
|
||||||
@ -1704,6 +1493,8 @@ void Applet::timerEvent(QTimerEvent *event)
|
|||||||
|
|
||||||
QRect Applet::screenRect() const
|
QRect Applet::screenRect() const
|
||||||
{
|
{
|
||||||
|
//TODO: port away QGV
|
||||||
|
/*
|
||||||
QGraphicsView *v = view();
|
QGraphicsView *v = view();
|
||||||
|
|
||||||
if (v) {
|
if (v) {
|
||||||
@ -1714,7 +1505,7 @@ QRect Applet::screenRect() const
|
|||||||
QPoint tL = v->mapToGlobal(v->mapFromScene(pos()));
|
QPoint tL = v->mapToGlobal(v->mapFromScene(pos()));
|
||||||
QPoint bR = v->mapToGlobal(v->mapFromScene(bottomRight));
|
QPoint bR = v->mapToGlobal(v->mapFromScene(bottomRight));
|
||||||
return QRect(QPoint(tL.x(), tL.y()), QSize(bR.x() - tL.x(), bR.y() - tL.y()));
|
return QRect(QPoint(tL.x(), tL.y()), QSize(bR.x() - tL.x(), bR.y() - tL.y()));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//The applet doesn't have a view on it.
|
//The applet doesn't have a view on it.
|
||||||
//So a screenRect isn't relevant.
|
//So a screenRect isn't relevant.
|
||||||
|
105
applet.h
105
applet.h
@ -22,7 +22,7 @@
|
|||||||
#ifndef PLASMA_APPLET_H
|
#ifndef PLASMA_APPLET_H
|
||||||
#define PLASMA_APPLET_H
|
#define PLASMA_APPLET_H
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QObject>
|
||||||
#include <QGraphicsWidget>
|
#include <QGraphicsWidget>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
@ -173,14 +173,6 @@ class PLASMA_EXPORT Applet : public QObject
|
|||||||
**/
|
**/
|
||||||
Package package() const;
|
Package package() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the view this widget is visible on, or 0 if none can be found.
|
|
||||||
* @warning do NOT assume this will always return a view!
|
|
||||||
* a null view probably means that either plasma isn't finished loading, or your applet is
|
|
||||||
* on an activity that's not being shown anywhere.
|
|
||||||
*/
|
|
||||||
QGraphicsView *view() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps a QRect from a view's coordinates to local coordinates.
|
* Maps a QRect from a view's coordinates to local coordinates.
|
||||||
* @param view the view from which rect should be mapped
|
* @param view the view from which rect should be mapped
|
||||||
@ -340,18 +332,6 @@ class PLASMA_EXPORT Applet : public QObject
|
|||||||
*/
|
*/
|
||||||
static QString category(const QString &appletName);
|
static QString category(const QString &appletName);
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called when the interface should be painted.
|
|
||||||
*
|
|
||||||
* @param painter the QPainter to use to do the paintiner
|
|
||||||
* @param option the style options object
|
|
||||||
* @param contentsRect the rect to paint within; automatically adjusted for
|
|
||||||
* the background, if any
|
|
||||||
**/
|
|
||||||
virtual void paintInterface(QPainter *painter,
|
|
||||||
const QStyleOptionGraphicsItem *option,
|
|
||||||
const QRect &contentsRect);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the user-visible name for the applet, as specified in the
|
* Returns the user-visible name for the applet, as specified in the
|
||||||
* .desktop file.
|
* .desktop file.
|
||||||
@ -468,7 +448,7 @@ class PLASMA_EXPORT Applet : public QObject
|
|||||||
QRect screenRect() const;
|
QRect screenRect() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reimplemented from QGraphicsItem
|
* Reimplemented from QObject
|
||||||
**/
|
**/
|
||||||
int type() const;
|
int type() const;
|
||||||
enum {
|
enum {
|
||||||
@ -511,25 +491,25 @@ class PLASMA_EXPORT Applet : public QObject
|
|||||||
virtual void removeAssociatedWidget(QWidget *widget);
|
virtual void removeAssociatedWidget(QWidget *widget);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parent the QGraphicsItem this applet is parented to
|
* @param parent the QObject this applet is parented to
|
||||||
* @param serviceId the name of the .desktop file containing the
|
* @param serviceId the name of the .desktop file containing the
|
||||||
* information about the widget
|
* information about the widget
|
||||||
* @param appletId a unique id used to differentiate between multiple
|
* @param appletId a unique id used to differentiate between multiple
|
||||||
* instances of the same Applet type
|
* instances of the same Applet type
|
||||||
*/
|
*/
|
||||||
explicit Applet(QGraphicsItem *parent = 0, const QString &serviceId = QString(), uint appletId = 0);
|
explicit Applet(QObject *parent = 0, const QString &serviceId = QString(), uint appletId = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parent the QGraphicsItem this applet is parented to
|
* @param parent the QObject this applet is parented to
|
||||||
* @param info the plugin information object for this Applet
|
* @param info the plugin information object for this Applet
|
||||||
* @param appletId a unique id used to differentiate between multiple
|
* @param appletId a unique id used to differentiate between multiple
|
||||||
* instances of the same Applet type
|
* instances of the same Applet type
|
||||||
* @since 4.6
|
* @since 4.6
|
||||||
*/
|
*/
|
||||||
explicit Applet(const KPluginInfo &info, QGraphicsItem *parent = 0, uint appletId = 0);
|
explicit Applet(const KPluginInfo &info, QObject *parent = 0, uint appletId = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parent the QGraphicsItem this applet is parented to
|
* @param parent the QObject this applet is parented to
|
||||||
* @param serviceId the name of the .desktop file containing the
|
* @param serviceId the name of the .desktop file containing the
|
||||||
* information about the widget
|
* information about the widget
|
||||||
* @param appletId a unique id used to differentiate between multiple
|
* @param appletId a unique id used to differentiate between multiple
|
||||||
@ -538,7 +518,7 @@ class PLASMA_EXPORT Applet : public QObject
|
|||||||
* and the applet id
|
* and the applet id
|
||||||
* @since 4.3
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
explicit Applet(QGraphicsItem *parent, const QString &serviceId, uint appletId, const QVariantList &args);
|
explicit Applet(QObject *parent, const QString &serviceId, uint appletId, const QVariantList &args);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -685,6 +665,8 @@ class PLASMA_EXPORT Applet : public QObject
|
|||||||
*/
|
*/
|
||||||
void immutabilityChanged(Plasma::ImmutabilityType immutable);
|
void immutabilityChanged(Plasma::ImmutabilityType immutable);
|
||||||
|
|
||||||
|
void geometryChanged();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Sets the immutability type for this applet (not immutable,
|
* Sets the immutability type for this applet (not immutable,
|
||||||
@ -812,10 +794,21 @@ class PLASMA_EXPORT Applet : public QObject
|
|||||||
bool hasFocus() const;
|
bool hasFocus() const;
|
||||||
void setFocus(Qt::FocusReason);
|
void setFocus(Qt::FocusReason);
|
||||||
|
|
||||||
void resize(const QSizeF &size);
|
//Geometry functions: FIXME: to remove?
|
||||||
QSizeF size() const;
|
QSizeF size() const;
|
||||||
QRectF geometry() const;
|
QRectF geometry() const;
|
||||||
void setGeometry(const QRect &geom);
|
void setGeometry(const QRectF &rect);
|
||||||
|
QRectF boundingRect() const;
|
||||||
|
void resize(const QSizeF &size);
|
||||||
|
int zValue() const;
|
||||||
|
void setZValue(int val);
|
||||||
|
QTransform transform() const;
|
||||||
|
void setTransform(const QTransform &transform);
|
||||||
|
QPointF pos() const;
|
||||||
|
void setPos(const QPointF &pos);
|
||||||
|
void setPos(int x, int y);
|
||||||
|
QSizePolicy sizePolicy() const;
|
||||||
|
void setSizePolicy(const QSizePolicy &policy);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
@ -915,55 +908,6 @@ class PLASMA_EXPORT Applet : public QObject
|
|||||||
*/
|
*/
|
||||||
virtual void constraintsEvent(Plasma::Constraints constraints);
|
virtual void constraintsEvent(Plasma::Constraints constraints);
|
||||||
|
|
||||||
/**
|
|
||||||
* Register the widgets that manage mouse clicks but you still want
|
|
||||||
* to be able to drag the applet around when holding the mouse pointer
|
|
||||||
* on that widget.
|
|
||||||
*
|
|
||||||
* Calling this results in an eventFilter being places on the widget.
|
|
||||||
*
|
|
||||||
* @param item the item to watch for mouse move
|
|
||||||
*/
|
|
||||||
void registerAsDragHandle(QGraphicsItem *item);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregister a widget registered with registerAsDragHandle.
|
|
||||||
*
|
|
||||||
* @param item the item to unregister
|
|
||||||
*/
|
|
||||||
void unregisterAsDragHandle(QGraphicsItem *item);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param item the item to look for if it is registered or not
|
|
||||||
* @return true if it is registered, false otherwise
|
|
||||||
*/
|
|
||||||
bool isRegisteredAsDragHandle(QGraphicsItem *item);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal scene event filter; used to manage applet dragging
|
|
||||||
*/
|
|
||||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal manage the mouse movement to drag the applet around
|
|
||||||
*/
|
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reimplemented from QGraphicsItem
|
|
||||||
*/
|
|
||||||
void focusInEvent(QFocusEvent *event);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reimplemented from QGraphicsItem
|
|
||||||
*/
|
|
||||||
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reimplemented from QGraphicsItem
|
|
||||||
*/
|
|
||||||
QPainterPath shape() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reimplemented from QGraphicsLayoutItem
|
* Reimplemented from QGraphicsLayoutItem
|
||||||
*/
|
*/
|
||||||
@ -998,7 +942,6 @@ class PLASMA_EXPORT Applet : public QObject
|
|||||||
|
|
||||||
Q_PRIVATE_SLOT(d, void cleanUpAndDelete())
|
Q_PRIVATE_SLOT(d, void cleanUpAndDelete())
|
||||||
Q_PRIVATE_SLOT(d, void selectItemToDestroy())
|
Q_PRIVATE_SLOT(d, void selectItemToDestroy())
|
||||||
Q_PRIVATE_SLOT(d, void updateRect(const QRectF& rect))
|
|
||||||
Q_PRIVATE_SLOT(d, void configDialogFinished())
|
Q_PRIVATE_SLOT(d, void configDialogFinished())
|
||||||
Q_PRIVATE_SLOT(d, void updateShortcuts())
|
Q_PRIVATE_SLOT(d, void updateShortcuts())
|
||||||
Q_PRIVATE_SLOT(d, void publishCheckboxStateChanged(int state))
|
Q_PRIVATE_SLOT(d, void publishCheckboxStateChanged(int state))
|
||||||
@ -1006,7 +949,7 @@ class PLASMA_EXPORT Applet : public QObject
|
|||||||
Q_PRIVATE_SLOT(d, void propagateConfigChanged())
|
Q_PRIVATE_SLOT(d, void propagateConfigChanged())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reimplemented from QGraphicsItem
|
* Reimplemented from QObject
|
||||||
**/
|
**/
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||||
|
|
||||||
|
267
containment.cpp
267
containment.cpp
@ -52,7 +52,6 @@
|
|||||||
#include "kio/scheduler.h"
|
#include "kio/scheduler.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "abstracttoolbox.h"
|
|
||||||
#include "animator.h"
|
#include "animator.h"
|
||||||
#include "containmentactions.h"
|
#include "containmentactions.h"
|
||||||
#include "containmentactionspluginsconfig.h"
|
#include "containmentactionspluginsconfig.h"
|
||||||
@ -97,7 +96,7 @@ Containment::StyleOption::StyleOption(const QStyleOptionGraphicsItem &other)
|
|||||||
type = Type;
|
type = Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
Containment::Containment(QGraphicsItem *parent,
|
Containment::Containment(QObject *parent,
|
||||||
const QString &serviceId,
|
const QString &serviceId,
|
||||||
uint containmentId)
|
uint containmentId)
|
||||||
: Applet(parent, serviceId, containmentId),
|
: Applet(parent, serviceId, containmentId),
|
||||||
@ -148,11 +147,7 @@ void Containment::init()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setCacheMode(NoCache);
|
|
||||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
|
||||||
setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
setAcceptsHoverEvents(true);
|
|
||||||
|
|
||||||
if (d->type == NoContainmentType) {
|
if (d->type == NoContainmentType) {
|
||||||
setContainmentType(DesktopContainment);
|
setContainmentType(DesktopContainment);
|
||||||
@ -273,10 +268,7 @@ void Containment::restore(KConfigGroup &group)
|
|||||||
|
|
||||||
|
|
||||||
resize(geo.size());
|
resize(geo.size());
|
||||||
//are we an offscreen containment?
|
//FIXME: unbreak containments just for dashboard
|
||||||
if (containmentType() != PanelContainment && containmentType() != CustomPanelContainment && geo.right() < 0) {
|
|
||||||
corona()->addOffscreenWidget(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
setLocation((Plasma::Location)group.readEntry("location", (int)d->location));
|
setLocation((Plasma::Location)group.readEntry("location", (int)d->location));
|
||||||
setFormFactor((Plasma::FormFactor)group.readEntry("formfactor", (int)d->formFactor));
|
setFormFactor((Plasma::FormFactor)group.readEntry("formfactor", (int)d->formFactor));
|
||||||
@ -293,10 +285,6 @@ void Containment::restore(KConfigGroup &group)
|
|||||||
setWallpaper(group.readEntry("wallpaperplugin", ContainmentPrivate::defaultWallpaper),
|
setWallpaper(group.readEntry("wallpaperplugin", ContainmentPrivate::defaultWallpaper),
|
||||||
group.readEntry("wallpaperpluginmode", ContainmentPrivate::defaultWallpaperMode));
|
group.readEntry("wallpaperpluginmode", ContainmentPrivate::defaultWallpaperMode));
|
||||||
|
|
||||||
if (d->toolBox) {
|
|
||||||
d->toolBox.data()->restore(group);
|
|
||||||
}
|
|
||||||
|
|
||||||
KConfigGroup cfg;
|
KConfigGroup cfg;
|
||||||
if (containmentType() == PanelContainment || containmentType() == CustomPanelContainment) {
|
if (containmentType() == PanelContainment || containmentType() == CustomPanelContainment) {
|
||||||
//don't let global desktop actions conflict with panels
|
//don't let global desktop actions conflict with panels
|
||||||
@ -383,10 +371,6 @@ void Containment::save(KConfigGroup &g) const
|
|||||||
group.writeEntry("location", (int)d->location);
|
group.writeEntry("location", (int)d->location);
|
||||||
group.writeEntry("activityId", d->activityId);
|
group.writeEntry("activityId", d->activityId);
|
||||||
|
|
||||||
if (d->toolBox) {
|
|
||||||
d->toolBox.data()->save(group);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (d->wallpaper) {
|
if (d->wallpaper) {
|
||||||
group.writeEntry("wallpaperplugin", d->wallpaper->pluginName());
|
group.writeEntry("wallpaperplugin", d->wallpaper->pluginName());
|
||||||
@ -450,86 +434,13 @@ void Containment::setContainmentType(Containment::Type type)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete d->toolBox.data();
|
|
||||||
d->type = type;
|
d->type = type;
|
||||||
d->checkContainmentFurniture();
|
d->checkContainmentFurniture();
|
||||||
}
|
}
|
||||||
|
|
||||||
Corona *Containment::corona() const
|
Corona *Containment::corona() const
|
||||||
{
|
{
|
||||||
return qobject_cast<Corona*>(scene());
|
return qobject_cast<Corona*>(parent());
|
||||||
}
|
|
||||||
|
|
||||||
void Containment::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|
||||||
{
|
|
||||||
event->ignore();
|
|
||||||
if (d->wallpaper && d->wallpaper->isInitialized()) {
|
|
||||||
QGraphicsItem *item = scene()->itemAt(event->scenePos());
|
|
||||||
if (item == this) {
|
|
||||||
d->wallpaper->mouseMoveEvent(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!event->isAccepted()) {
|
|
||||||
event->accept();
|
|
||||||
Applet::mouseMoveEvent(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Containment::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|
||||||
{
|
|
||||||
//close a toolbox if exists, to emulate qmenu behavior
|
|
||||||
if (d->toolBox) {
|
|
||||||
d->toolBox.data()->setShowing(false);
|
|
||||||
}
|
|
||||||
event->ignore();
|
|
||||||
if (d->appletAt(event->scenePos())) {
|
|
||||||
return; //no unexpected click-throughs
|
|
||||||
}
|
|
||||||
|
|
||||||
if (d->wallpaper && d->wallpaper->isInitialized() && !event->isAccepted()) {
|
|
||||||
d->wallpaper->mousePressEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event->isAccepted()) {
|
|
||||||
setFocus(Qt::MouseFocusReason);
|
|
||||||
} else if (event->button() == Qt::RightButton && event->modifiers() == Qt::NoModifier) {
|
|
||||||
// we'll catch this in the context menu even
|
|
||||||
Applet::mousePressEvent(event);
|
|
||||||
} else {
|
|
||||||
QString trigger = ContainmentActions::eventToString(event);
|
|
||||||
if (d->prepareContainmentActions(trigger, event->screenPos())) {
|
|
||||||
d->actionPlugins()->value(trigger)->contextEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!event->isAccepted()) {
|
|
||||||
Applet::mousePressEvent(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Containment::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|
||||||
{
|
|
||||||
event->ignore();
|
|
||||||
|
|
||||||
if (d->appletAt(event->scenePos())) {
|
|
||||||
return; //no unexpected click-throughs
|
|
||||||
}
|
|
||||||
|
|
||||||
QString trigger = ContainmentActions::eventToString(event);
|
|
||||||
|
|
||||||
if (d->wallpaper && d->wallpaper->isInitialized()) {
|
|
||||||
d->wallpaper->mouseReleaseEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!event->isAccepted() && isContainment()) {
|
|
||||||
if (d->prepareContainmentActions(trigger, event->screenPos())) {
|
|
||||||
d->actionPlugins()->value(trigger)->contextEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
event->accept();
|
|
||||||
Applet::mouseReleaseEvent(event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Containment::showDropZone(const QPoint pos)
|
void Containment::showDropZone(const QPoint pos)
|
||||||
@ -543,17 +454,16 @@ void Containment::showContextMenu(const QPointF &containmentPos, const QPoint &s
|
|||||||
//kDebug() << containmentPos << screenPos;
|
//kDebug() << containmentPos << screenPos;
|
||||||
QGraphicsSceneContextMenuEvent gvevent;
|
QGraphicsSceneContextMenuEvent gvevent;
|
||||||
gvevent.setScreenPos(screenPos);
|
gvevent.setScreenPos(screenPos);
|
||||||
gvevent.setScenePos(mapToScene(containmentPos));
|
|
||||||
gvevent.setPos(containmentPos);
|
gvevent.setPos(containmentPos);
|
||||||
gvevent.setReason(QGraphicsSceneContextMenuEvent::Mouse);
|
gvevent.setReason(QGraphicsSceneContextMenuEvent::Mouse);
|
||||||
gvevent.setWidget(view());
|
//FIXME: do we need views here?
|
||||||
|
//gvevent.setWidget(view());
|
||||||
contextMenuEvent(&gvevent);
|
contextMenuEvent(&gvevent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Containment::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
void Containment::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
if (!isContainment() || !KAuthorized::authorizeKAction("plasma/containment_context_menu")) {
|
if (!isContainment() || !KAuthorized::authorizeKAction("plasma/containment_context_menu")) {
|
||||||
Applet::contextMenuEvent(event);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,8 +507,6 @@ void Containment::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||||||
|
|
||||||
menu->exec(pos);
|
menu->exec(pos);
|
||||||
event->accept();
|
event->accept();
|
||||||
} else {
|
|
||||||
Applet::contextMenuEvent(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,10 +519,6 @@ void Containment::setFormFactor(FormFactor formFactor)
|
|||||||
//kDebug() << "switching FF to " << formFactor;
|
//kDebug() << "switching FF to " << formFactor;
|
||||||
d->formFactor = formFactor;
|
d->formFactor = formFactor;
|
||||||
|
|
||||||
if (d->toolBox) {
|
|
||||||
d->toolBox.data()->reposition();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateConstraints(Plasma::FormFactorConstraint);
|
updateConstraints(Plasma::FormFactorConstraint);
|
||||||
|
|
||||||
KConfigGroup c = config();
|
KConfigGroup c = config();
|
||||||
@ -714,7 +618,6 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit)
|
|||||||
disconnect(applet, 0, currentContainment, 0);
|
disconnect(applet, 0, currentContainment, 0);
|
||||||
KConfigGroup oldConfig = applet->config();
|
KConfigGroup oldConfig = applet->config();
|
||||||
currentContainment->d->applets.removeAll(applet);
|
currentContainment->d->applets.removeAll(applet);
|
||||||
applet->setParentItem(this);
|
|
||||||
applet->setParent(this);
|
applet->setParent(this);
|
||||||
|
|
||||||
// now move the old config to the new location
|
// now move the old config to the new location
|
||||||
@ -725,7 +628,6 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit)
|
|||||||
|
|
||||||
disconnect(applet, SIGNAL(activate()), currentContainment, SIGNAL(activate()));
|
disconnect(applet, SIGNAL(activate()), currentContainment, SIGNAL(activate()));
|
||||||
} else {
|
} else {
|
||||||
applet->setParentItem(this);
|
|
||||||
applet->setParent(this);
|
applet->setParent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -748,7 +650,6 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit)
|
|||||||
d->appletAppeared(applet);
|
d->appletAppeared(applet);
|
||||||
}
|
}
|
||||||
|
|
||||||
applet->setFlag(QGraphicsItem::ItemIsMovable, true);
|
|
||||||
applet->updateConstraints(Plasma::AllConstraints);
|
applet->updateConstraints(Plasma::AllConstraints);
|
||||||
if (!delayInit) {
|
if (!delayInit) {
|
||||||
applet->flushPendingConstraintsEvents();
|
applet->flushPendingConstraintsEvents();
|
||||||
@ -863,112 +764,16 @@ QStringList Containment::listContainmentTypes()
|
|||||||
return types.toList();
|
return types.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Containment::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
|
|
||||||
{
|
|
||||||
//kDebug() << immutability() << Mutable << (immutability() == Mutable);
|
|
||||||
event->setAccepted(immutability() == Mutable &&
|
|
||||||
(event->mimeData()->hasFormat(static_cast<Corona*>(scene())->appletMimeType()) ||
|
|
||||||
event->mimeData()->hasUrls()));
|
|
||||||
|
|
||||||
if (!event->isAccepted()) {
|
|
||||||
// check to see if we have an applet that accepts the format.
|
|
||||||
QStringList formats = event->mimeData()->formats();
|
|
||||||
|
|
||||||
foreach (const QString &format, formats) {
|
|
||||||
KPluginInfo::List appletList = Applet::listAppletInfoForMimeType(format);
|
|
||||||
if (!appletList.isEmpty()) {
|
|
||||||
event->setAccepted(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!event->isAccepted()) {
|
|
||||||
foreach (const QString &format, formats) {
|
|
||||||
KPluginInfo::List wallpaperList = Wallpaper::listWallpaperInfoForMimeType(format);
|
|
||||||
if (!wallpaperList.isEmpty()) {
|
|
||||||
event->setAccepted(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event->isAccepted()) {
|
|
||||||
if (d->dropZoneStarted) {
|
|
||||||
showDropZone(event->pos().toPoint());
|
|
||||||
} else {
|
|
||||||
if (!d->showDropZoneDelayTimer) {
|
|
||||||
d->showDropZoneDelayTimer = new QTimer(this);
|
|
||||||
d->showDropZoneDelayTimer->setInterval(300);
|
|
||||||
d->showDropZoneDelayTimer->setSingleShot(true);
|
|
||||||
connect(d->showDropZoneDelayTimer, SIGNAL(timeout()), this, SLOT(showDropZoneDelayed()));
|
|
||||||
}
|
|
||||||
|
|
||||||
d->dropPoints.insert(0, event->pos());
|
|
||||||
d->showDropZoneDelayTimer->start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Containment::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
|
|
||||||
{
|
|
||||||
//kDebug() << event->pos() << size().height() << size().width();
|
|
||||||
if (d->showDropZoneDelayTimer) {
|
|
||||||
d->showDropZoneDelayTimer->stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event->pos().y() < 1 || event->pos().y() > size().height() ||
|
|
||||||
event->pos().x() < 1 || event->pos().x() > size().width()) {
|
|
||||||
showDropZone(QPoint());
|
|
||||||
d->dropZoneStarted = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Containment::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
|
|
||||||
{
|
|
||||||
QGraphicsItem *item = scene()->itemAt(event->scenePos());
|
|
||||||
event->setAccepted(item == this || item == d->toolBox.data() || !item);
|
|
||||||
//kDebug() << event->isAccepted() << d->showDropZoneDelayTimer->isActive();
|
|
||||||
if (!event->isAccepted()) {
|
|
||||||
if (d->showDropZoneDelayTimer) {
|
|
||||||
d->showDropZoneDelayTimer->stop();
|
|
||||||
}
|
|
||||||
} else if (!d->showDropZoneDelayTimer->isActive() && immutability() == Plasma::Mutable) {
|
|
||||||
showDropZone(event->pos().toPoint());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
|
void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
|
||||||
{
|
{
|
||||||
if (isContainment()) {
|
if (isContainment()) {
|
||||||
d->dropData(event->scenePos(), event->screenPos(), event);
|
d->dropData(event->scenePos(), event->screenPos(), event);
|
||||||
} else {
|
|
||||||
Applet::dropEvent(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Containment::setToolBox(AbstractToolBox *toolBox)
|
|
||||||
{
|
|
||||||
if (d->toolBox.data()) {
|
|
||||||
d->toolBox.data()->deleteLater();
|
|
||||||
}
|
|
||||||
d->toolBox = toolBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractToolBox *Containment::toolBox() const
|
|
||||||
{
|
|
||||||
return d->toolBox.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Containment::resizeEvent(QGraphicsSceneResizeEvent *event)
|
void Containment::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
{
|
{
|
||||||
Applet::resizeEvent(event);
|
|
||||||
|
|
||||||
if (isContainment()) {
|
if (isContainment()) {
|
||||||
if (corona()) {
|
|
||||||
corona()->layoutContainments();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (d->wallpaper) {
|
if (d->wallpaper) {
|
||||||
d->wallpaper->setBoundingRect(QRectF(QPointF(0, 0), size()));
|
d->wallpaper->setBoundingRect(QRectF(QPointF(0, 0), size()));
|
||||||
}
|
}
|
||||||
@ -997,14 +802,11 @@ void Containment::wheelEvent(QGraphicsSceneWheelEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (d->wallpaper && d->wallpaper->isInitialized()) {
|
if (d->wallpaper && d->wallpaper->isInitialized()) {
|
||||||
QGraphicsItem *item = scene()->itemAt(event->scenePos());
|
event->ignore();
|
||||||
if (item == this) {
|
d->wallpaper->wheelEvent(event);
|
||||||
event->ignore();
|
|
||||||
d->wallpaper->wheelEvent(event);
|
|
||||||
|
|
||||||
if (event->isAccepted()) {
|
if (event->isAccepted()) {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1013,9 +815,6 @@ void Containment::wheelEvent(QGraphicsSceneWheelEvent *event)
|
|||||||
if (d->prepareContainmentActions(trigger, event->screenPos())) {
|
if (d->prepareContainmentActions(trigger, event->screenPos())) {
|
||||||
d->actionPlugins()->value(trigger)->contextEvent(event);
|
d->actionPlugins()->value(trigger)->contextEvent(event);
|
||||||
event->accept();
|
event->accept();
|
||||||
} else {
|
|
||||||
event->ignore();
|
|
||||||
Applet::wheelEvent(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1030,47 +829,12 @@ void Containment::enableAction(const QString &name, bool enable)
|
|||||||
|
|
||||||
void Containment::addToolBoxAction(QAction *action)
|
void Containment::addToolBoxAction(QAction *action)
|
||||||
{
|
{
|
||||||
d->createToolBox();
|
d->toolBoxActions << action;
|
||||||
if (d->toolBox) {
|
|
||||||
d->toolBox.data()->addTool(action);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Containment::removeToolBoxAction(QAction *action)
|
void Containment::removeToolBoxAction(QAction *action)
|
||||||
{
|
{
|
||||||
if (d->toolBox) {
|
d->toolBoxActions.removeAll(action);
|
||||||
d->toolBox.data()->removeTool(action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Containment::setToolBoxOpen(bool open)
|
|
||||||
{
|
|
||||||
if (open) {
|
|
||||||
openToolBox();
|
|
||||||
} else {
|
|
||||||
closeToolBox();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Containment::isToolBoxOpen() const
|
|
||||||
{
|
|
||||||
return (d->toolBox && d->toolBox.data()->isShowing());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Containment::openToolBox()
|
|
||||||
{
|
|
||||||
if (d->toolBox && !d->toolBox.data()->isShowing()) {
|
|
||||||
d->toolBox.data()->setShowing(true);
|
|
||||||
emit toolBoxVisibilityChanged(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Containment::closeToolBox()
|
|
||||||
{
|
|
||||||
if (d->toolBox && d->toolBox.data()->isShowing()) {
|
|
||||||
d->toolBox.data()->setShowing(false);
|
|
||||||
emit toolBoxVisibilityChanged(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Containment::addAssociatedWidget(QWidget *widget)
|
void Containment::addAssociatedWidget(QWidget *widget)
|
||||||
@ -1163,8 +927,6 @@ void Containment::setWallpaper(const QString &pluginName, const QString &mode)
|
|||||||
cfg.writeEntry("wallpaperpluginmode", mode);
|
cfg.writeEntry("wallpaperpluginmode", mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!d->wallpaper) {
|
if (!d->wallpaper) {
|
||||||
@ -1253,10 +1015,6 @@ void Containment::setActivity(const QString &activityId)
|
|||||||
KConfigGroup c = config();
|
KConfigGroup c = config();
|
||||||
c.writeEntry("activityId", activityId);
|
c.writeEntry("activityId", activityId);
|
||||||
|
|
||||||
if (d->toolBox) {
|
|
||||||
d->toolBox.data()->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit configNeedsSaving();
|
emit configNeedsSaving();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1316,7 +1074,8 @@ void Containment::destroy(bool confirm)
|
|||||||
const QString title = i18nc("@title:window %1 is the name of the containment", "Remove %1", name());
|
const QString title = i18nc("@title:window %1 is the name of the containment", "Remove %1", name());
|
||||||
KGuiItem remove = KStandardGuiItem::remove();
|
KGuiItem remove = KStandardGuiItem::remove();
|
||||||
remove.setText(title);
|
remove.setText(title);
|
||||||
if (KMessageBox::warningContinueCancel(view(),
|
//FIXME: make the view accessible?
|
||||||
|
if (KMessageBox::warningContinueCancel(0/*view()*/,
|
||||||
i18nc("%1 is the name of the containment", "Do you really want to remove this %1?", name()),
|
i18nc("%1 is the name of the containment", "Do you really want to remove this %1?", name()),
|
||||||
title, remove) != KMessageBox::Continue) {
|
title, remove) != KMessageBox::Continue) {
|
||||||
return;
|
return;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#ifndef PLASMA_CONTAINMENT_H
|
#ifndef PLASMA_CONTAINMENT_H
|
||||||
#define PLASMA_CONTAINMENT_H
|
#define PLASMA_CONTAINMENT_H
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QObject>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QStyleOptionGraphicsItem>
|
#include <QStyleOptionGraphicsItem>
|
||||||
|
|
||||||
@ -104,14 +104,24 @@ class PLASMA_EXPORT Containment : public Applet
|
|||||||
CustomPanelContainment = 128 /**< A customized desktop panel */
|
CustomPanelContainment = 128 /**< A customized desktop panel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ToolType {
|
||||||
|
AddTool = 0,
|
||||||
|
ConfigureTool = 100,
|
||||||
|
ControlTool = 200,
|
||||||
|
MiscTool = 300,
|
||||||
|
DestructiveTool = 400,
|
||||||
|
UserToolType = DestructiveTool + 1000
|
||||||
|
};
|
||||||
|
Q_ENUMS(ToolType)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parent the QGraphicsItem this applet is parented to
|
* @param parent the QObject this applet is parented to
|
||||||
* @param serviceId the name of the .desktop file containing the
|
* @param serviceId the name of the .desktop file containing the
|
||||||
* information about the widget
|
* information about the widget
|
||||||
* @param containmentId a unique id used to differentiate between multiple
|
* @param containmentId a unique id used to differentiate between multiple
|
||||||
* instances of the same Applet type
|
* instances of the same Applet type
|
||||||
*/
|
*/
|
||||||
explicit Containment(QGraphicsItem *parent = 0,
|
explicit Containment(QObject *parent = 0,
|
||||||
const QString &serviceId = QString(),
|
const QString &serviceId = QString(),
|
||||||
uint containmentId = 0);
|
uint containmentId = 0);
|
||||||
|
|
||||||
@ -299,29 +309,6 @@ class PLASMA_EXPORT Containment : public Applet
|
|||||||
*/
|
*/
|
||||||
void removeToolBoxAction(QAction *action);
|
void removeToolBoxAction(QAction *action);
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the open or closed state of the Containment's toolbox
|
|
||||||
*
|
|
||||||
* @param open true to open the ToolBox, false to close it
|
|
||||||
*/
|
|
||||||
void setToolBoxOpen(bool open);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true if the toolbox is open
|
|
||||||
* @since 4.5
|
|
||||||
*/
|
|
||||||
bool isToolBoxOpen() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Open the Containment's toolbox
|
|
||||||
*/
|
|
||||||
void openToolBox();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Closes Containment's toolbox
|
|
||||||
*/
|
|
||||||
void closeToolBox();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* associate actions with this widget, including ones added after this call.
|
* associate actions with this widget, including ones added after this call.
|
||||||
* needed to make keyboard shortcuts work.
|
* needed to make keyboard shortcuts work.
|
||||||
@ -545,31 +532,10 @@ Q_SIGNALS:
|
|||||||
*/
|
*/
|
||||||
virtual void restoreContents(KConfigGroup &group);
|
virtual void restoreContents(KConfigGroup &group);
|
||||||
|
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
|
||||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
void wheelEvent(QGraphicsSceneWheelEvent *event);
|
void wheelEvent(QGraphicsSceneWheelEvent *event);
|
||||||
|
|
||||||
/**
|
|
||||||
* @reimp
|
|
||||||
* @sa QGraphicsItem::dragEnterEvent()
|
|
||||||
*/
|
|
||||||
void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @reimp
|
|
||||||
* @sa QGraphicsItem::dragLeaveEvent()
|
|
||||||
*/
|
|
||||||
void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @reimp
|
|
||||||
* @sa QGraphicsItem::dragMoveEvent()
|
|
||||||
*/
|
|
||||||
void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @reimp
|
* @reimp
|
||||||
* @sa QGraphicsItem::dropEvent()
|
* @sa QGraphicsItem::dropEvent()
|
||||||
@ -578,25 +544,15 @@ Q_SIGNALS:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @reimp
|
* @reimp
|
||||||
* @sa QGraphicsItem::resizeEvent()
|
* @sa QObject::resizeEvent()
|
||||||
*/
|
*/
|
||||||
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
|
||||||
/**
|
//FIXME: kill those
|
||||||
* Sets a custom ToolBox
|
QSizeF maximumSize() const;
|
||||||
* if there was an old one it will be deleted
|
void setMaximumSize(QSizeF size);
|
||||||
* and the new one won't have any actions in it
|
QSizeF minimumSize() const;
|
||||||
*
|
void setMinimumSize(QSizeF size);
|
||||||
* @param item the new toolbox item
|
|
||||||
* @since 4.4
|
|
||||||
*/
|
|
||||||
void setToolBox(AbstractToolBox *toolBox);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the ToolBox
|
|
||||||
* @since 4.4
|
|
||||||
*/
|
|
||||||
AbstractToolBox *toolBox() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
@ -611,9 +567,7 @@ Q_SIGNALS:
|
|||||||
|
|
||||||
Q_PRIVATE_SLOT(d, void appletDeleted(Plasma::Applet*))
|
Q_PRIVATE_SLOT(d, void appletDeleted(Plasma::Applet*))
|
||||||
Q_PRIVATE_SLOT(d, void triggerShowAddWidgets())
|
Q_PRIVATE_SLOT(d, void triggerShowAddWidgets())
|
||||||
Q_PRIVATE_SLOT(d, void positionToolBox())
|
|
||||||
Q_PRIVATE_SLOT(d, void requestConfiguration())
|
Q_PRIVATE_SLOT(d, void requestConfiguration())
|
||||||
Q_PRIVATE_SLOT(d, void updateToolBoxVisibility())
|
|
||||||
Q_PRIVATE_SLOT(d, void showDropZoneDelayed())
|
Q_PRIVATE_SLOT(d, void showDropZoneDelayed())
|
||||||
Q_PRIVATE_SLOT(d, void checkStatus(Plasma::ItemStatus))
|
Q_PRIVATE_SLOT(d, void checkStatus(Plasma::ItemStatus))
|
||||||
Q_PRIVATE_SLOT(d, void remoteAppletReady(Plasma::AccessAppletJob *))
|
Q_PRIVATE_SLOT(d, void remoteAppletReady(Plasma::AccessAppletJob *))
|
||||||
|
@ -329,9 +329,10 @@ QRegion Corona::availableScreenRegion(int id) const
|
|||||||
return QRegion(screenGeometry(id));
|
return QRegion(screenGeometry(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint Corona::popupPosition(const QGraphicsItem *item, const QSize &s, Qt::AlignmentFlag alignment)
|
QPoint Corona::popupPosition(const QObject *item, const QSize &s, Qt::AlignmentFlag alignment)
|
||||||
{
|
{
|
||||||
const QGraphicsItem *actualItem = item;
|
//FIXME: this is a stub
|
||||||
|
const QGraphicsItem *actualItem = static_cast<QGraphicsItem>(item);
|
||||||
const QGraphicsView *v = viewFor(item);
|
const QGraphicsView *v = viewFor(item);
|
||||||
|
|
||||||
if (!v) {
|
if (!v) {
|
||||||
|
2
corona.h
2
corona.h
@ -202,7 +202,7 @@ public:
|
|||||||
* @param alignment alignment of the popup, valid flags are Qt::AlignLeft, Qt::AlignRight and Qt::AlignCenter
|
* @param alignment alignment of the popup, valid flags are Qt::AlignLeft, Qt::AlignRight and Qt::AlignCenter
|
||||||
* @returns reccomended position
|
* @returns reccomended position
|
||||||
*/
|
*/
|
||||||
QPoint popupPosition(const QGraphicsItem *item, const QSize &size, Qt::AlignmentFlag alignment = Qt::AlignCenter);
|
QPoint popupPosition(const QObject *item, const QSize &size, Qt::AlignmentFlag alignment = Qt::AlignCenter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is useful in order to retrieve the list of available
|
* This method is useful in order to retrieve the list of available
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
#include "kio/scheduler.h"
|
#include "kio/scheduler.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "abstracttoolbox.h"
|
|
||||||
#include "containmentactions.h"
|
#include "containmentactions.h"
|
||||||
#include "containmentactionspluginsconfig.h"
|
#include "containmentactionspluginsconfig.h"
|
||||||
#include "corona.h"
|
#include "corona.h"
|
||||||
@ -94,19 +93,19 @@ void ContainmentPrivate::addDefaultActions(KActionCollection *actions, Containme
|
|||||||
appletBrowserAction->setText(i18n("Add Widgets..."));
|
appletBrowserAction->setText(i18n("Add Widgets..."));
|
||||||
appletBrowserAction->setIcon(KDE::icon("list-add"));
|
appletBrowserAction->setIcon(KDE::icon("list-add"));
|
||||||
appletBrowserAction->setShortcut(KShortcut("alt+d, a"));
|
appletBrowserAction->setShortcut(KShortcut("alt+d, a"));
|
||||||
appletBrowserAction->setData(AbstractToolBox::AddTool);
|
appletBrowserAction->setData(Containment::AddTool);
|
||||||
|
|
||||||
KAction *action = actions->addAction("next applet");
|
KAction *action = actions->addAction("next applet");
|
||||||
action->setText(i18n("Next Widget"));
|
action->setText(i18n("Next Widget"));
|
||||||
//no icon
|
//no icon
|
||||||
action->setShortcut(KShortcut("alt+d, n"));
|
action->setShortcut(KShortcut("alt+d, n"));
|
||||||
action->setData(AbstractToolBox::ControlTool);
|
action->setData(Containment::ControlTool);
|
||||||
|
|
||||||
action = actions->addAction("previous applet");
|
action = actions->addAction("previous applet");
|
||||||
action->setText(i18n("Previous Widget"));
|
action->setText(i18n("Previous Widget"));
|
||||||
//no icon
|
//no icon
|
||||||
action->setShortcut(KShortcut("alt+d, p"));
|
action->setShortcut(KShortcut("alt+d, p"));
|
||||||
action->setData(AbstractToolBox::ControlTool);
|
action->setData(Containment::ControlTool);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainmentPrivate::initApplets()
|
void ContainmentPrivate::initApplets()
|
||||||
@ -134,7 +133,6 @@ void ContainmentPrivate::checkContainmentFurniture()
|
|||||||
{
|
{
|
||||||
if (q->isContainment() &&
|
if (q->isContainment() &&
|
||||||
(type == Containment::DesktopContainment || type == Containment::PanelContainment)) {
|
(type == Containment::DesktopContainment || type == Containment::PanelContainment)) {
|
||||||
createToolBox();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,15 +280,6 @@ void ContainmentPrivate::setScreen(int newScreen, int newDesktop, bool preventIn
|
|||||||
const bool isDesktopContainment = type == Containment::DesktopContainment ||
|
const bool isDesktopContainment = type == Containment::DesktopContainment ||
|
||||||
type == Containment::CustomContainment;
|
type == Containment::CustomContainment;
|
||||||
if (isDesktopContainment) {
|
if (isDesktopContainment) {
|
||||||
// we want to listen to changes in work area if our screen changes
|
|
||||||
if (toolBox) {
|
|
||||||
if (screen < 0 && newScreen > -1) {
|
|
||||||
QObject::connect(KWindowSystem::self(), SIGNAL(workAreaChanged()), toolBox.data(), SLOT(reposition()), Qt::UniqueConnection);
|
|
||||||
} else if (newScreen < 0) {
|
|
||||||
QObject::disconnect(KWindowSystem::self(), SIGNAL(workAreaChanged()), toolBox.data(), SLOT(reposition()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newScreen > -1) {
|
if (newScreen > -1) {
|
||||||
// sanity check to make sure someone else doesn't have this screen already!
|
// sanity check to make sure someone else doesn't have this screen already!
|
||||||
Containment *currently = corona->containmentForScreen(newScreen, newDesktop);
|
Containment *currently = corona->containmentForScreen(newScreen, newDesktop);
|
||||||
@ -801,32 +790,6 @@ void ContainmentPrivate::checkStatus(Plasma::ItemStatus appletStatus)
|
|||||||
q->setStatus(appletStatus);
|
q->setStatus(appletStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainmentPrivate::createToolBox()
|
|
||||||
{
|
|
||||||
if (!toolBox && KAuthorized::authorizeKAction("plasma/containment_context_menu")) {
|
|
||||||
toolBox = Plasma::AbstractToolBox::load(q->corona()->preferredToolBoxPlugin(type), QVariantList(), q);
|
|
||||||
|
|
||||||
if (toolBox) {
|
|
||||||
QObject::connect(toolBox.data(), SIGNAL(toggled()), q, SIGNAL(toolBoxToggled()));
|
|
||||||
QObject::connect(toolBox.data(), SIGNAL(toggled()), q, SLOT(updateToolBoxVisibility()));
|
|
||||||
|
|
||||||
positionToolBox();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainmentPrivate::positionToolBox()
|
|
||||||
{
|
|
||||||
if (toolBox) {
|
|
||||||
toolBox.data()->reposition();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainmentPrivate::updateToolBoxVisibility()
|
|
||||||
{
|
|
||||||
emit q->toolBoxVisibilityChanged(toolBox.data()->isShowing());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainmentPrivate::triggerShowAddWidgets()
|
void ContainmentPrivate::triggerShowAddWidgets()
|
||||||
{
|
{
|
||||||
emit q->showAddWidgetsInterface(QPointF());
|
emit q->showAddWidgetsInterface(QPointF());
|
||||||
@ -869,14 +832,6 @@ void ContainmentPrivate::containmentConstraintsEvent(Plasma::Constraints constra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolBox && (constraints & Plasma::SizeConstraint ||
|
|
||||||
constraints & Plasma::FormFactorConstraint ||
|
|
||||||
constraints & Plasma::ScreenConstraint ||
|
|
||||||
constraints & Plasma::StartupCompletedConstraint)) {
|
|
||||||
//kDebug() << "Positioning toolbox";
|
|
||||||
positionToolBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (constraints & Plasma::StartupCompletedConstraint && type < Containment::CustomContainment) {
|
if (constraints & Plasma::StartupCompletedConstraint && type < Containment::CustomContainment) {
|
||||||
q->addToolBoxAction(q->action("remove"));
|
q->addToolBoxAction(q->action("remove"));
|
||||||
checkRemoveAction();
|
checkRemoveAction();
|
||||||
@ -897,15 +852,7 @@ Applet *ContainmentPrivate::addApplet(const QString &name, const QVariantList &a
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsView *v = q->view();
|
|
||||||
if (v) {
|
|
||||||
v->setCursor(Qt::BusyCursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
Applet *applet = PluginLoader::self()->loadApplet(name, id, args);
|
Applet *applet = PluginLoader::self()->loadApplet(name, id, args);
|
||||||
if (v) {
|
|
||||||
v->unsetCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!applet) {
|
if (!applet) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#ifndef CONTAINMENT_P_H
|
#ifndef CONTAINMENT_P_H
|
||||||
#define CONTAINMENT_P_H
|
#define CONTAINMENT_P_H
|
||||||
|
|
||||||
|
#include <kactioncollection.h>
|
||||||
#include <kmenu.h>
|
#include <kmenu.h>
|
||||||
|
|
||||||
#include "plasma.h"
|
#include "plasma.h"
|
||||||
@ -28,7 +29,6 @@
|
|||||||
#include "corona.h"
|
#include "corona.h"
|
||||||
|
|
||||||
static const int INTER_CONTAINMENT_MARGIN = 6;
|
static const int INTER_CONTAINMENT_MARGIN = 6;
|
||||||
static const int TOOLBOX_MARGIN = 150;
|
|
||||||
static const int CONTAINMENT_COLUMNS = 2;
|
static const int CONTAINMENT_COLUMNS = 2;
|
||||||
static const int VERTICAL_STACKING_OFFSET = 10000;
|
static const int VERTICAL_STACKING_OFFSET = 10000;
|
||||||
|
|
||||||
@ -44,7 +44,6 @@ namespace Plasma
|
|||||||
|
|
||||||
class AccessAppletJob;
|
class AccessAppletJob;
|
||||||
class Containment;
|
class Containment;
|
||||||
class AbstractToolBox;
|
|
||||||
|
|
||||||
class ContainmentPrivate
|
class ContainmentPrivate
|
||||||
{
|
{
|
||||||
@ -79,9 +78,6 @@ public:
|
|||||||
dropMenus.clear();
|
dropMenus.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void createToolBox();
|
|
||||||
void positionToolBox();
|
|
||||||
void updateToolBoxVisibility();
|
|
||||||
void triggerShowAddWidgets();
|
void triggerShowAddWidgets();
|
||||||
void requestConfiguration();
|
void requestConfiguration();
|
||||||
void checkStatus(Plasma::ItemStatus status);
|
void checkStatus(Plasma::ItemStatus status);
|
||||||
@ -168,7 +164,7 @@ public:
|
|||||||
int lastScreen;
|
int lastScreen;
|
||||||
int desktop;
|
int desktop;
|
||||||
int lastDesktop;
|
int lastDesktop;
|
||||||
QWeakPointer<AbstractToolBox> toolBox;
|
QList<QAction *> toolBoxActions;
|
||||||
QString activityId;
|
QString activityId;
|
||||||
Containment::Type type;
|
Containment::Type type;
|
||||||
QHash<KJob*, QPointF> dropPoints;
|
QHash<KJob*, QPointF> dropPoints;
|
||||||
|
@ -146,28 +146,6 @@ void AppletScript::showMessage(const QIcon &icon, const QString &message, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletScript::registerAsDragHandle(QGraphicsItem *item)
|
|
||||||
{
|
|
||||||
if (applet()) {
|
|
||||||
applet()->registerAsDragHandle(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppletScript::unregisterAsDragHandle(QGraphicsItem *item)
|
|
||||||
{
|
|
||||||
if (applet()) {
|
|
||||||
applet()->unregisterAsDragHandle(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AppletScript::isRegisteredAsDragHandle(QGraphicsItem *item)
|
|
||||||
{
|
|
||||||
if (applet()) {
|
|
||||||
return applet()->isRegisteredAsDragHandle(item);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppletScript::configChanged()
|
void AppletScript::configChanged()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -225,21 +225,6 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void showMessage(const QIcon &icon, const QString &message, const MessageButtons buttons);
|
void showMessage(const QIcon &icon, const QString &message, const MessageButtons buttons);
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Applet
|
|
||||||
*/
|
|
||||||
void registerAsDragHandle(QGraphicsItem *item);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Applet
|
|
||||||
*/
|
|
||||||
void unregisterAsDragHandle(QGraphicsItem *item);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Applet
|
|
||||||
*/
|
|
||||||
bool isRegisteredAsDragHandle(QGraphicsItem *item);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Applet;
|
friend class Applet;
|
||||||
friend class PopupApplet;
|
friend class PopupApplet;
|
||||||
|
Loading…
Reference in New Issue
Block a user