properties for dialog move

This commit is contained in:
Marco Martin 2011-02-25 20:37:56 +01:00
parent fcfafcbc6e
commit d8457ecd8d
2 changed files with 41 additions and 0 deletions

View File

@ -159,6 +159,35 @@ void DialogProxy::showPopup(QGraphicsObject *item)
emit visibleChanged();
}
int DialogProxy::x() const
{
return m_dialog->pos().x();
}
void DialogProxy::setX(int x)
{
m_dialog->move(x, m_dialog->pos().y());
}
int DialogProxy::y() const
{
return m_dialog->pos().y();
}
void DialogProxy::setY(int y)
{
m_dialog->move(m_dialog->pos().x(), y);
}
bool DialogProxy::eventFilter(QObject *watched, QEvent *event)
{
if (watched == m_dialog && event->type() == QEvent::Move) {
emit positionChanged();
}
return false;
}
void DialogProxy::setAttribute(int attribute, bool on)
{
m_dialog->setAttribute((Qt::WidgetAttribute)attribute, on);

View File

@ -37,6 +37,8 @@ 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)
public:
enum WidgetAttribute {
@ -52,6 +54,12 @@ public:
bool isVisible() const;
void setVisible(const bool visible);
int x() const;
void setX(int x);
int y() const;
void setY(int y);
Q_INVOKABLE void showPopup(QGraphicsObject *item);
//FIXME:: Qt::WidgetAttribute should be already
Q_INVOKABLE void setAttribute(int attribute, bool on);
@ -59,10 +67,14 @@ public:
Q_SIGNALS:
void mainItemChanged();
void visibleChanged();
void positionChanged();
protected Q_SLOTS:
void syncMainItem();
protected:
bool eventFilter(QObject *watched, QEvent *event);
private:
Plasma::Dialog *m_dialog;
DeclarativeItemContainer *m_declarativeItemContainer;