nasty little hack for when PopupApplet is in a focussable window; prior to this, a PopupApplet in plasmoidviewer would show the popup over and over and over

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=862100
This commit is contained in:
Aaron J. Seigo 2008-09-18 04:11:03 +00:00
parent 2a979b4e00
commit f24df9f3ed
2 changed files with 16 additions and 3 deletions

View File

@ -54,7 +54,8 @@ public:
popupPlacement(Plasma::FloatingPopup),
savedAspectRatio(Plasma::InvalidAspectRatioMode),
timer(0),
startupComplete(false)
startupComplete(false),
popupLostFocus(false)
{
}
@ -70,6 +71,7 @@ public:
void togglePopup();
void hideTimedPopup();
void clearPopupLostFocus();
void dialogSizeChanged();
void dialogStatusChanged(bool status);
void updateDialogPosition();
@ -83,7 +85,8 @@ public:
Plasma::AspectRatioMode savedAspectRatio;
QTimer *timer;
QPoint clicked;
bool startupComplete;
bool startupComplete : 1;
bool popupLostFocus : 1;
};
PopupApplet::PopupApplet(QObject *parent, const QVariantList &args)
@ -291,11 +294,12 @@ void PopupApplet::constraintsEvent(Plasma::Constraints constraints)
void PopupApplet::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (!d->icon && event->buttons() == Qt::LeftButton) {
if (!d->icon && !d->popupLostFocus && event->buttons() == Qt::LeftButton) {
d->clicked = scenePos().toPoint();
event->setAccepted(true);
return;
} else {
d->popupLostFocus = false;
Applet::mousePressEvent(event);
}
}
@ -312,7 +316,9 @@ void PopupApplet::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
bool PopupApplet::eventFilter(QObject *watched, QEvent *event)
{
if (watched == d->dialog && (event->type() == QEvent::WindowDeactivate)) {
d->popupLostFocus = true;
hidePopup();
QTimer::singleShot(100, this, SLOT(clearPopupLostFocus()));
}
if (watched == graphicsWidget() && (event->type() == QEvent::GraphicsSceneResize)) {
@ -378,6 +384,7 @@ void PopupApplet::popupEvent(bool)
void PopupAppletPrivate::togglePopup()
{
kDebug();
if (dialog) {
if (timer) {
timer->stop();
@ -401,6 +408,11 @@ void PopupAppletPrivate::hideTimedPopup()
q->hidePopup();
}
void PopupAppletPrivate::clearPopupLostFocus()
{
popupLostFocus = false;
}
void PopupAppletPrivate::dialogSizeChanged()
{
//Reposition the dialog

View File

@ -116,6 +116,7 @@ protected:
private:
Q_PRIVATE_SLOT(d, void togglePopup())
Q_PRIVATE_SLOT(d, void hideTimedPopup())
Q_PRIVATE_SLOT(d, void clearPopupLostFocus())
Q_PRIVATE_SLOT(d, void dialogSizeChanged())
Q_PRIVATE_SLOT(d, void dialogStatusChanged(bool))