From f000f07b088259974ecf54ecb2f77412bd053cbf Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 7 Jun 2011 16:40:33 +0200 Subject: [PATCH] make the notify signals actually be emitted --- declarativeimports/core/dialog.cpp | 29 +++++++++++++++++++++++++++-- declarativeimports/core/dialog.h | 15 ++++++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/declarativeimports/core/dialog.cpp b/declarativeimports/core/dialog.cpp index b2daf6447..831c0bdb3 100644 --- a/declarativeimports/core/dialog.cpp +++ b/declarativeimports/core/dialog.cpp @@ -33,6 +33,7 @@ DialogProxy::DialogProxy(QObject *parent) : QObject(parent) { m_dialog = new Plasma::Dialog(); + m_dialog->installEventFilter(this); m_flags = m_dialog->windowFlags(); } @@ -152,6 +153,16 @@ void DialogProxy::setY(int y) m_dialog->move(m_dialog->pos().x(), y); } +int DialogProxy::width() const +{ + return m_dialog->size().width(); +} + +int DialogProxy::height() const +{ + return m_dialog->size().height(); +} + int DialogProxy::windowFlags() const { return (int)m_dialog->windowFlags(); @@ -166,8 +177,22 @@ void DialogProxy::setWindowFlags(const int flags) bool DialogProxy::eventFilter(QObject *watched, QEvent *event) { if (watched == m_dialog && event->type() == QEvent::Move) { - emit positionChanged(); - } + QMoveEvent *me = static_cast(event); + if (me->oldPos().x() != me->pos().x()) { + emit xChanged(); + } + if (me->oldPos().y() != me->pos().y()) { + emit yChanged(); + } + } else if (watched == m_dialog && event->type() == QEvent::Resize) { + QResizeEvent *re = static_cast(event); + if (re->oldSize().width() != re->size().width()) { + emit widthChanged(); + } + if (re->oldSize().height() != re->size().height()) { + emit heightChanged(); + } + } return false; } diff --git a/declarativeimports/core/dialog.h b/declarativeimports/core/dialog.h index fa8ce532f..e86fffc76 100644 --- a/declarativeimports/core/dialog.h +++ b/declarativeimports/core/dialog.h @@ -38,8 +38,11 @@ class DialogProxy : public QObject Q_PROPERTY(QGraphicsObject *mainItem READ mainItem WRITE setMainItem NOTIFY mainItemChanged) Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) - Q_PROPERTY(int x READ x WRITE setX NOTIFY positionChanged) - Q_PROPERTY(int y READ y WRITE setY NOTIFY positionChanged) + Q_PROPERTY(int x READ x WRITE setX NOTIFY xChanged) + Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged) + //to set the size try to force doing so from the inner item + Q_PROPERTY(int width READ width NOTIFY widthChanged) + Q_PROPERTY(int height READ width NOTIFY heightChanged) Q_PROPERTY(int windowFlags READ windowFlags WRITE setWindowFlags) public: @@ -62,6 +65,9 @@ public: int y() const; void setY(int y); + int width() const; + int height() const; + //FIXME: passing an int is ugly int windowFlags() const; void setWindowFlags(const int); @@ -73,7 +79,10 @@ public: Q_SIGNALS: void mainItemChanged(); void visibleChanged(); - void positionChanged(); + void xChanged(); + void yChanged(); + void widthChanged(); + void heightChanged(); protected Q_SLOTS: void syncMainItem();