read only property: activeWindow

This commit is contained in:
Marco Martin 2011-06-19 23:08:15 +02:00
parent 3475f99f96
commit 86d4283ff9
2 changed files with 18 additions and 1 deletions

View File

@ -82,7 +82,8 @@ int DialogMargins::bottom() const
DialogProxy::DialogProxy(QObject *parent) DialogProxy::DialogProxy(QObject *parent)
: QObject(parent), : QObject(parent),
m_declarativeItemContainer(0) m_declarativeItemContainer(0),
m_activeWindow(false)
{ {
m_dialog = new Plasma::Dialog(); m_dialog = new Plasma::Dialog();
m_margins = new DialogMargins(m_dialog, this); m_margins = new DialogMargins(m_dialog, this);
@ -225,6 +226,11 @@ int DialogProxy::height() const
return m_dialog->size().height(); return m_dialog->size().height();
} }
bool DialogProxy::isActiveWindow() const
{
return m_activeWindow;
}
int DialogProxy::windowFlags() const int DialogProxy::windowFlags() const
{ {
return (int)m_dialog->windowFlags(); return (int)m_dialog->windowFlags();
@ -262,6 +268,12 @@ bool DialogProxy::eventFilter(QObject *watched, QEvent *event)
if (re->oldSize().height() != re->size().height()) { if (re->oldSize().height() != re->size().height()) {
emit heightChanged(); 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; return false;
} }

View File

@ -80,6 +80,7 @@ class DialogProxy : public QObject
Q_PROPERTY(int height READ height NOTIFY heightChanged) Q_PROPERTY(int height READ height NOTIFY heightChanged)
Q_PROPERTY(int windowFlags READ windowFlags WRITE setWindowFlags) Q_PROPERTY(int windowFlags READ windowFlags WRITE setWindowFlags)
Q_PROPERTY(QObject *margins READ margins CONSTANT) Q_PROPERTY(QObject *margins READ margins CONSTANT)
Q_PROPERTY(bool activeWindow READ isActiveWindow NOTIFY activeWindowChanged)
public: public:
enum WidgetAttribute { enum WidgetAttribute {
@ -104,6 +105,8 @@ public:
int width() const; int width() const;
int height() const; int height() const;
bool isActiveWindow() const;
//FIXME: passing an int is ugly //FIXME: passing an int is ugly
int windowFlags() const; int windowFlags() const;
void setWindowFlags(const int); void setWindowFlags(const int);
@ -122,6 +125,7 @@ Q_SIGNALS:
void yChanged(); void yChanged();
void widthChanged(); void widthChanged();
void heightChanged(); void heightChanged();
void activeWindowChanged();
protected Q_SLOTS: protected Q_SLOTS:
void syncMainItem(); void syncMainItem();
@ -135,6 +139,7 @@ private:
DeclarativeItemContainer *m_declarativeItemContainer; DeclarativeItemContainer *m_declarativeItemContainer;
QWeakPointer<QGraphicsObject> m_mainItem; QWeakPointer<QGraphicsObject> m_mainItem;
DialogMargins *m_margins; DialogMargins *m_margins;
bool m_activeWindow;
}; };
#endif #endif