Make sure QDBusMenuBar is restored when the window is hidden and shown
Task-number: QTBUG-58723 Change-Id: Ib4c3dac8a8cce717f4d47ab619c05b9e1719f311 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
38550c562d
commit
41750492db
@ -120,7 +120,7 @@ void QDBusMenuBar::syncMenu(QPlatformMenu *menu)
|
||||
|
||||
void QDBusMenuBar::handleReparent(QWindow *newParentWindow)
|
||||
{
|
||||
if (newParentWindow && newParentWindow->winId() != m_windowId) {
|
||||
if (newParentWindow) {
|
||||
unregisterMenuBar();
|
||||
m_windowId = newParentWindow->winId();
|
||||
registerMenuBar();
|
||||
|
@ -1474,6 +1474,17 @@ bool QMenuBar::eventFilter(QObject *object, QEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
if (isNativeMenuBar() && event->type() == QEvent::ShowToParent) {
|
||||
// On some desktops like Unity, the D-Bus menu bar is unregistered
|
||||
// when the window is hidden. So when the window is shown, we need
|
||||
// to forcefully re-register it. The only way to force re-registering
|
||||
// with D-Bus menu is the handleReparent method.
|
||||
QWidget *widget = qobject_cast<QWidget *>(object);
|
||||
QWindow *handle = widget ? widget->windowHandle() : nullptr;
|
||||
if (handle != nullptr)
|
||||
d->platformMenuBar->handleReparent(handle);
|
||||
}
|
||||
|
||||
if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)) {
|
||||
if (d->altPressed) {
|
||||
switch (event->type()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user