diff --git a/declarativeimports/core/dialog.cpp b/declarativeimports/core/dialog.cpp index 989af03c5..d3951347f 100644 --- a/declarativeimports/core/dialog.cpp +++ b/declarativeimports/core/dialog.cpp @@ -82,7 +82,8 @@ int DialogMargins::bottom() const DialogProxy::DialogProxy(QObject *parent) : QObject(parent), - m_declarativeItemContainer(0) + m_declarativeItemContainer(0), + m_activeWindow(false) { m_dialog = new Plasma::Dialog(); m_margins = new DialogMargins(m_dialog, this); @@ -225,6 +226,11 @@ int DialogProxy::height() const return m_dialog->size().height(); } +bool DialogProxy::isActiveWindow() const +{ + return m_activeWindow; +} + int DialogProxy::windowFlags() const { return (int)m_dialog->windowFlags(); @@ -262,6 +268,12 @@ bool DialogProxy::eventFilter(QObject *watched, QEvent *event) if (re->oldSize().height() != re->size().height()) { emit heightChanged(); } + } else if (watched == m_dialog && event->type() == QEvent::WindowActivate) { + m_activeWindow = true; + emit activeWindowChanged(); + } else if (watched == m_dialog && event->type() == QEvent::WindowDeactivate) { + m_activeWindow = false; + emit activeWindowChanged(); } return false; } diff --git a/declarativeimports/core/dialog.h b/declarativeimports/core/dialog.h index 35500f5ea..5d60d13bc 100644 --- a/declarativeimports/core/dialog.h +++ b/declarativeimports/core/dialog.h @@ -80,6 +80,7 @@ class DialogProxy : public QObject Q_PROPERTY(int height READ height NOTIFY heightChanged) Q_PROPERTY(int windowFlags READ windowFlags WRITE setWindowFlags) Q_PROPERTY(QObject *margins READ margins CONSTANT) + Q_PROPERTY(bool activeWindow READ isActiveWindow NOTIFY activeWindowChanged) public: enum WidgetAttribute { @@ -104,6 +105,8 @@ public: int width() const; int height() const; + bool isActiveWindow() const; + //FIXME: passing an int is ugly int windowFlags() const; void setWindowFlags(const int); @@ -122,6 +125,7 @@ Q_SIGNALS: void yChanged(); void widthChanged(); void heightChanged(); + void activeWindowChanged(); protected Q_SLOTS: void syncMainItem(); @@ -135,6 +139,7 @@ private: DeclarativeItemContainer *m_declarativeItemContainer; QWeakPointer m_mainItem; DialogMargins *m_margins; + bool m_activeWindow; }; #endif