add a transientParent property
if this contextmenu is done from a Dialog, add this as transientParent
This commit is contained in:
parent
ef879a7c7b
commit
9976c47ad9
@ -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()) {
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user