add a transientParent property

if this contextmenu is done from a Dialog, add this as transientParent
This commit is contained in:
Marco Martin 2014-02-24 14:01:05 +01:00
parent ef879a7c7b
commit 9976c47ad9
2 changed files with 24 additions and 0 deletions

View File

@ -91,6 +91,21 @@ void QMenuProxy::setVisualParent(QObject *parent)
emit visualParentChanged();
}
QWindow *QMenuProxy::transientParent()
{
return m_menu->windowHandle()->transientParent();
}
void QMenuProxy::setTransientParent(QWindow *parent)
{
if (parent == m_menu->windowHandle()->transientParent()) {
return;
}
m_menu->windowHandle()->setTransientParent(parent);
emit transientParentChanged();
}
bool QMenuProxy::event(QEvent *event)
{
switch (event->type()) {

View File

@ -35,6 +35,11 @@ class QMenuProxy : public QObject
Q_PROPERTY(QQmlListProperty<QMenuItem> content READ content CONSTANT)
Q_CLASSINFO("DefaultProperty", "content")
/**
* This is a hint to the window manager that this window is a dialog or pop-up on behalf of the given window.
*/
Q_PROPERTY(QWindow *transientParent READ transientParent WRITE setTransientParent NOTIFY transientParentChanged)
/**
* the visualParent is used to position the menu. it can be an item on the scene, like a button (that will open the menu on clicked) or another menuitem (in this case this will be a submenu)
*/
@ -53,6 +58,9 @@ public:
QObject *visualParent() const;
void setVisualParent(QObject *parent);
QWindow *transientParent();
void setTransientParent(QWindow *parent);
Q_INVOKABLE void open(int x = 0, int y = 0);
//Q_INVOKABLE void open();
Q_INVOKABLE void close();
@ -66,6 +74,7 @@ protected:
Q_SIGNALS:
void statusChanged();
void visualParentChanged();
void transientParentChanged();
void triggered(QMenuItem *item);
void triggeredIndex(int index);