And finally we can drag even the last ExtenderItem from PopupApplet without stuff

breaking all around, and some random crashes are avoided too, all by making the
Dialog in PopupApplet no longer of the type Qt::Popup and installing an event filter
to still hide the dialog when you click somewhere else on your screen.


svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=857095
This commit is contained in:
Rob Scheepmaker 2008-09-04 17:09:34 +00:00
parent 04d513894b
commit dcaf4a4b8a
6 changed files with 28 additions and 8 deletions

View File

@ -373,8 +373,7 @@ void Corona::addOffscreenWidget(QGraphicsWidget *widget)
d->offscreenLayout->addItem(widget, d->offscreenLayout->rowCount() + 1,
d->offscreenLayout->columnCount() + 1);
kDebug() << "current scenerect = " << widget->sceneBoundingRect();
widget->update();
}
void Corona::removeOffscreenWidget(QGraphicsWidget *widget)

View File

@ -88,11 +88,12 @@ void DialogPrivate::themeUpdated()
void DialogPrivate::adjustView()
{
if (view && widget) {
kDebug() << "resize the view.";
QSize prevSize = q->size();
//reposition and resize the view.
view->setSceneRect(widget->mapToScene(widget->boundingRect()).boundingRect());
view->resize(widget->preferredSize().toSize());
view->resize(widget->size().toSize());
view->centerOn(widget);
//set the sizehints correctly:

View File

@ -81,7 +81,6 @@ class PLASMA_EXPORT Dialog : public QWidget
bool eventFilter(QObject *watched, QEvent *event);
void hideEvent (QHideEvent * event);
void showEvent (QShowEvent * event);
private:
DialogPrivate * const d;

View File

@ -377,8 +377,6 @@ void ExtenderPrivate::loadExtenderItems()
adjustSizeHints();
}
QGraphicsGridLayout *ExtenderPrivate::s_popupLayout = 0;
} // Plasma namespace
#include "extender.moc"

View File

@ -712,8 +712,11 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
corona->addOffscreenWidget(this);
update();
d->toplevel->setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint
| Qt::WindowStaysOnTopHint);
d->toplevel->setFrameShape(QFrame::NoFrame);
d->toplevel->resize(screenRect.size());
d->toplevel->setSceneRect(sceneBoundingRect());
d->toplevel->centerOn(this);

View File

@ -26,6 +26,7 @@
#include <KIcon>
#include <KIconLoader>
#include <KWindowSystem>
#include <plasma/dialog.h>
#include <plasma/corona.h>
@ -209,7 +210,15 @@ void PopupApplet::constraintsEvent(Plasma::Constraints constraints)
if (!d->dialog) {
d->dialog = new Plasma::Dialog();
d->dialog->setWindowFlags(Qt::Popup);
//no longer use Qt::Popup since that seems to cause a lot of problem when you drag
//stuff out of your Dialog (extenders). Monitor WindowDeactivate events so we can
//emulate the same kind of behavior as Qt::Popup (close when you click somewhere
//else.
d->dialog->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
KWindowSystem::setState(d->dialog->winId(), NET::SkipTaskbar | NET::SkipPager);
d->dialog->installEventFilter(this);
connect(d->dialog, SIGNAL(dialogResized()), this, SLOT(dialogSizeChanged()));
connect(d->dialog, SIGNAL(dialogVisible(bool)), this , SLOT(dialogStatusChanged(bool)));
if (graphicsWidget()) {
@ -244,6 +253,10 @@ void PopupApplet::constraintsEvent(Plasma::Constraints constraints)
bool PopupApplet::eventFilter(QObject *watched, QEvent *event)
{
if (watched == d->dialog && (event->type() == QEvent::WindowDeactivate)) {
hidePopup();
}
if (watched == graphicsWidget() && (event->type() == QEvent::GraphicsSceneResize)) {
//sizes are recalculated in the constraintsevent so let's just call that.
constraintsEvent(Plasma::FormFactorConstraint);
@ -262,6 +275,7 @@ void PopupApplet::showPopup(uint popupDuration)
if (d->dialog && (formFactor() == Horizontal || formFactor() == Vertical)) {
d->dialog->move(popupPosition(d->dialog->size()));
d->dialog->show();
KWindowSystem::setState(d->dialog->winId(), NET::SkipTaskbar | NET::SkipPager);
if (d->timer) {
d->timer->stop();
@ -298,7 +312,13 @@ void PopupAppletPrivate::togglePopup()
}
dialog->move(q->popupPosition(dialog->size()));
dialog->show();
if (dialog->isVisible()) {
dialog->hide();
} else {
dialog->show();
KWindowSystem::setState(dialog->winId(), NET::SkipTaskbar | NET::SkipPager);
}
dialog->clearFocus();
}