PopupApplet monitors the size of the applet now. And fixed scenePosFromScreenPos so you can now
reorder extenderitems within a Dialog. Stuff still breaks when detaching the last item, I'm still working on that. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=854547
This commit is contained in:
parent
7c817fd06c
commit
c066ea7027
@ -374,8 +374,6 @@ void Corona::addOffscreenWidget(QGraphicsWidget *widget)
|
|||||||
d->offscreenLayout->addItem(widget, d->offscreenLayout->rowCount() + 1,
|
d->offscreenLayout->addItem(widget, d->offscreenLayout->rowCount() + 1,
|
||||||
d->offscreenLayout->columnCount() + 1);
|
d->offscreenLayout->columnCount() + 1);
|
||||||
|
|
||||||
d->offscreenLayout->invalidate();
|
|
||||||
|
|
||||||
kDebug() << "current scenerect = " << widget->sceneBoundingRect();
|
kDebug() << "current scenerect = " << widget->sceneBoundingRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +388,6 @@ void Corona::removeOffscreenWidget(QGraphicsWidget *widget)
|
|||||||
dynamic_cast<QGraphicsWidget*>(d->offscreenLayout->itemAt(i));
|
dynamic_cast<QGraphicsWidget*>(d->offscreenLayout->itemAt(i));
|
||||||
if (foundWidget == widget) {
|
if (foundWidget == widget) {
|
||||||
d->offscreenLayout->removeAt(i);
|
d->offscreenLayout->removeAt(i);
|
||||||
d->offscreenLayout->invalidate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,9 +46,9 @@ Extender::Extender(Applet *applet)
|
|||||||
|
|
||||||
d->emptyExtenderLabel = new Label(this);
|
d->emptyExtenderLabel = new Label(this);
|
||||||
d->emptyExtenderLabel->setText(d->emptyExtenderMessage);
|
d->emptyExtenderLabel->setText(d->emptyExtenderMessage);
|
||||||
d->emptyExtenderLabel->setMinimumSize(QSizeF(150, 24));
|
d->emptyExtenderLabel->setMinimumSize(QSizeF(150, 64));
|
||||||
d->emptyExtenderLabel->setPreferredSize(QSizeF(200, 48));
|
d->emptyExtenderLabel->setPreferredSize(QSizeF(200, 64));
|
||||||
d->emptyExtenderLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
d->emptyExtenderLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||||
d->layout->addItem(d->emptyExtenderLabel);
|
d->layout->addItem(d->emptyExtenderLabel);
|
||||||
|
|
||||||
d->loadExtenderItems();
|
d->loadExtenderItems();
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <QGraphicsSceneResizeEvent>
|
#include <QGraphicsSceneResizeEvent>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QGraphicsLinearLayout>
|
#include <QGraphicsLinearLayout>
|
||||||
|
#include <QLayout>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@ -34,6 +35,7 @@
|
|||||||
#include "applet.h"
|
#include "applet.h"
|
||||||
#include "containment.h"
|
#include "containment.h"
|
||||||
#include "corona.h"
|
#include "corona.h"
|
||||||
|
#include "dialog.h"
|
||||||
#include "extender.h"
|
#include "extender.h"
|
||||||
#include "panelsvg.h"
|
#include "panelsvg.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
@ -177,9 +179,24 @@ class ExtenderItemPrivate
|
|||||||
|
|
||||||
QGraphicsView *found = 0;
|
QGraphicsView *found = 0;
|
||||||
foreach (QWidget *w, QApplication::topLevelWidgets()) {
|
foreach (QWidget *w, QApplication::topLevelWidgets()) {
|
||||||
QGraphicsView *v = qobject_cast<QGraphicsView *>(w);
|
QGraphicsView *v = 0;
|
||||||
if (v && v->isVisible() && v->geometry().contains(pos)) {
|
|
||||||
if (found) {
|
//first check if we're over a Dialog.
|
||||||
|
Dialog *dialog = qobject_cast<Dialog*>(w);
|
||||||
|
if (dialog) {
|
||||||
|
if (dialog->isVisible() && dialog->geometry().contains(pos)) {
|
||||||
|
v = qobject_cast<QGraphicsView*>(dialog->layout()->itemAt(0)->widget());
|
||||||
|
if (v) {
|
||||||
|
return v->mapToScene(v->mapFromGlobal(pos));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
v = qobject_cast<QGraphicsView *>(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
//else check if it is a QGV:
|
||||||
|
if (v && w->isVisible() && w->geometry().contains(pos)) {
|
||||||
|
if (found && order.contains(found->winId())) {
|
||||||
if (order.indexOf(found->winId()) < order.indexOf(v->winId())) {
|
if (order.indexOf(found->winId()) < order.indexOf(v->winId())) {
|
||||||
found = v;
|
found = v;
|
||||||
}
|
}
|
||||||
@ -405,7 +422,6 @@ void ExtenderItem::setExtender(Extender *extender, const QPointF &pos)
|
|||||||
|
|
||||||
//move the configuration.
|
//move the configuration.
|
||||||
if (d->hostApplet() && (extender != d->extender)) {
|
if (d->hostApplet() && (extender != d->extender)) {
|
||||||
kDebug() << "moving configuration";
|
|
||||||
KConfigGroup c = extender->d->applet->config("ExtenderItems");
|
KConfigGroup c = extender->d->applet->config("ExtenderItems");
|
||||||
config().reparent(&c);
|
config().reparent(&c);
|
||||||
}
|
}
|
||||||
@ -636,6 +652,7 @@ void ExtenderItem::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|||||||
|
|
||||||
void ExtenderItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void ExtenderItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
kDebug() << "the mouse pressed yeah yeah yeah!";
|
||||||
if (!(d->dragHandleRect().contains(event->pos()))) {
|
if (!(d->dragHandleRect().contains(event->pos()))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -651,16 +668,17 @@ void ExtenderItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
setZValue(parentApplet->zValue());
|
setZValue(parentApplet->zValue());
|
||||||
|
|
||||||
if (d->extender) {
|
if (d->extender) {
|
||||||
d->extender->itemHoverEnterEvent(this);
|
//d->extender->itemHoverEnterEvent(this);
|
||||||
//d->extender->itemHoverMoveEvent(this, d->extender->mapFromScene(event->scenePos()));
|
//d->extender->itemHoverMoveEvent(this, d->extender->mapFromScene(event->scenePos()));
|
||||||
|
d->extender->itemHoverMoveEvent(this, d->extender->mapFromScene(d->scenePosFromScreenPos(event->screenPos())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d->extender->d->removeExtenderItem(this);
|
||||||
|
|
||||||
//call the move event, since that spawns a toplevel view when this extender item is in a
|
//call the move event, since that spawns a toplevel view when this extender item is in a
|
||||||
//Plasma::Dialog, which is very essential since else the dialog will close before having been
|
//Plasma::Dialog, which is very essential since else the dialog will close before having been
|
||||||
//able to receive any move events.
|
//able to receive any move events.
|
||||||
mouseMoveEvent(event);
|
//mouseMoveEvent(event);
|
||||||
|
|
||||||
d->extender->d->removeExtenderItem(this);
|
|
||||||
|
|
||||||
QApplication::setOverrideCursor(Qt::ClosedHandCursor);
|
QApplication::setOverrideCursor(Qt::ClosedHandCursor);
|
||||||
}
|
}
|
||||||
|
@ -175,6 +175,7 @@ void PopupApplet::constraintsEvent(Plasma::Constraints constraints)
|
|||||||
if (graphicsWidget()) {
|
if (graphicsWidget()) {
|
||||||
d->layout->addItem(graphicsWidget());
|
d->layout->addItem(graphicsWidget());
|
||||||
setMinimumSize(graphicsWidget()->minimumSize() + marginSize);
|
setMinimumSize(graphicsWidget()->minimumSize() + marginSize);
|
||||||
|
graphicsWidget()->installEventFilter(this);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!d->proxy) {
|
if (!d->proxy) {
|
||||||
@ -240,6 +241,21 @@ void PopupApplet::constraintsEvent(Plasma::Constraints constraints)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PopupApplet::eventFilter(QObject *watched, QEvent *event)
|
||||||
|
{
|
||||||
|
if (watched == graphicsWidget() && (event->type() == QEvent::GraphicsSceneResize)) {
|
||||||
|
//sizes are recalculated in the constraintsevent so let's just call that.
|
||||||
|
constraintsEvent(Plasma::FormFactorConstraint);
|
||||||
|
|
||||||
|
//resize vertically if necesarry.
|
||||||
|
if (formFactor() == Plasma::MediaCenter || formFactor() == Plasma::Planar) {
|
||||||
|
resize(QSizeF(size().width(), minimumHeight()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Applet::eventFilter(watched, event);
|
||||||
|
}
|
||||||
|
|
||||||
void PopupApplet::showPopup(uint popupDuration)
|
void PopupApplet::showPopup(uint popupDuration)
|
||||||
{
|
{
|
||||||
if (d->dialog && (formFactor() == Horizontal || formFactor() == Vertical)) {
|
if (d->dialog && (formFactor() == Horizontal || formFactor() == Vertical)) {
|
||||||
@ -275,19 +291,6 @@ void PopupApplet::popupEvent(bool)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupApplet::widgetGeometryChanged()
|
|
||||||
{
|
|
||||||
if (graphicsWidget() && layout()) {
|
|
||||||
//sizes are recalculated in the constraintsevent so let's just call that.
|
|
||||||
constraintsEvent(Plasma::FormFactorConstraint);
|
|
||||||
|
|
||||||
//resize vertically if necesarry.
|
|
||||||
if (formFactor() == Plasma::MediaCenter || formFactor() == Plasma::Planar) {
|
|
||||||
resize(QSizeF(size().width(), minimumHeight()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PopupAppletPrivate::togglePopup()
|
void PopupAppletPrivate::togglePopup()
|
||||||
{
|
{
|
||||||
if (dialog) {
|
if (dialog) {
|
||||||
|
@ -100,14 +100,9 @@ public Q_SLOTS:
|
|||||||
*/
|
*/
|
||||||
void hidePopup();
|
void hidePopup();
|
||||||
|
|
||||||
/**
|
|
||||||
* Notify PopupApplet that the geometry of the graphicsWidget has changed. When you use an
|
|
||||||
* extender you'll want to connect the extender's geometryChanged() signal to this slot.
|
|
||||||
*/
|
|
||||||
void widgetGeometryChanged();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void constraintsEvent(Plasma::Constraints constraints);
|
void constraintsEvent(Plasma::Constraints constraints);
|
||||||
|
bool eventFilter(QObject *watched, QEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_PRIVATE_SLOT(d, void togglePopup())
|
Q_PRIVATE_SLOT(d, void togglePopup())
|
||||||
|
Loading…
Reference in New Issue
Block a user