make the notify signals actually be emitted

This commit is contained in:
Marco Martin 2011-06-07 16:40:33 +02:00
parent 90ecc73536
commit f000f07b08
2 changed files with 39 additions and 5 deletions

View File

@ -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<QMoveEvent *>(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<QResizeEvent *>(event);
if (re->oldSize().width() != re->size().width()) {
emit widthChanged();
}
if (re->oldSize().height() != re->size().height()) {
emit heightChanged();
}
}
return false;
}

View File

@ -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();