revert last commit

popups are done correctly now
(is necessary so show, set the flags and show again)
This commit is contained in:
Marco Martin 2011-06-07 19:12:04 +02:00
parent 230a15d475
commit d3868a8b65
2 changed files with 4 additions and 32 deletions

View File

@ -24,14 +24,14 @@
#include <QGraphicsObject>
#include <QGraphicsWidget>
#include <QTimer>
#include <QLayout>
#include <Plasma/Corona>
#include <Plasma/Dialog>
DialogProxy::DialogProxy(QObject *parent)
: QObject(parent),
m_isPopupMenu(false)
: QObject(parent)
{
m_dialog = new Plasma::Dialog();
m_dialog->installEventFilter(this);
@ -117,22 +117,13 @@ void DialogProxy::setVisible(const bool visible)
m_dialog->setVisible(visible);
if (visible) {
m_dialog->setWindowFlags(m_flags);
m_dialog->setVisible(visible);
m_dialog->raise();
if (m_isPopupMenu && QWidget::mouseGrabber() != m_dialog) {
QTimer::singleShot(200, this, SLOT(syncGrab()));
}
}
emit visibleChanged();
}
}
void DialogProxy::syncGrab()
{
if (m_isPopupMenu) {
m_dialog->grabMouse();
}
}
QPoint DialogProxy::popupPosition(QGraphicsObject *item) const
{
Plasma::Corona *corona = qobject_cast<Plasma::Corona *>(item->scene());
@ -203,30 +194,13 @@ bool DialogProxy::eventFilter(QObject *watched, QEvent *event)
if (re->oldSize().height() != re->size().height()) {
emit heightChanged();
}
} else if (watched == m_dialog && event->type() == QEvent::Hide) {
m_dialog->releaseMouse();
} else if (watched == m_dialog && event->type() == QEvent::MouseButtonPress) {
if (m_isPopupMenu) {
QMouseEvent *me = static_cast<QMouseEvent *>(event);
if (!m_dialog->geometry().contains(me->globalPos())) {
m_dialog->releaseMouse();
setVisible(false);
}
}
}
return false;
}
void DialogProxy::setAttribute(int attribute, bool on)
{
Qt::WidgetAttribute attr = (Qt::WidgetAttribute)attribute;
if (attr == Qt::WA_X11NetWmWindowTypePopupMenu) {
m_isPopupMenu = on;
if (m_isPopupMenu && QWidget::mouseGrabber() != m_dialog) {
QTimer::singleShot(200, this, SLOT(syncGrab()));
}
}
m_dialog->setAttribute(attr, on);
m_dialog->setAttribute((Qt::WidgetAttribute)attribute, on);
}
#include "dialog.moc"

View File

@ -86,7 +86,6 @@ Q_SIGNALS:
protected Q_SLOTS:
void syncMainItem();
void syncGrab();
protected:
bool eventFilter(QObject *watched, QEvent *event);
@ -96,7 +95,6 @@ private:
Qt::WindowFlags m_flags;
DeclarativeItemContainer *m_declarativeItemContainer;
QWeakPointer<QGraphicsObject> m_mainItem;
bool m_isPopupMenu;
};
#endif