Bug 375498 - KXmlGui forcefully shows menu bar even though a native menu exists
Summary: KXmlGui forcefully shows menu bar even though a native menu exists
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kxmlgui
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-24 13:03 UTC by Kai Uwe Broulik
Modified: 2017-01-25 12:17 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kai Uwe Broulik 2017-01-24 13:03:55 UTC
With Plasma 5.9 we support global menu which will create a native menu bar for the application. When using 3rd party applications like VLC player their menus are properly hidden.

However, KXmlGui apps like Kate and Kwrite always show their menu bars regardless of this. Qt hides the menu bar when a native one is shown but then KXmlGui probably reads the ShowMenuBar setting and sets the menu visible again.

Now that the "show menu bar" option is disabled in this case, there's no way for the user to hide the menu now, other than editing the ~/.config/kwriterc file
Comment 1 Albert Astals Cid 2017-01-24 21:54:44 UTC
I don't think the problem lies in kxmlgui, unity 7 shows no menubar at all in kate, just the native menu, so the problem must be somewhere else?
Comment 2 David Edmundson 2017-01-25 12:17:37 UTC
Git commit bac5a39f01a88edd1a1165d3f3d08507742367fe by David Edmundson.
Committed on 25/01/2017 at 12:17.
Pushed by davidedmundson into branch 'Plasma/5.9'.

Add workaround for QMenuBar::setVisible bug in 5.7.0

Summary:
QMenuBar::setVisible() only checks isNativeMenuBar on OS X
leading to both the normal in-appmenu and the platform menu both being
visible - especially as KXmlGui explicitly has a setVisible call.

This only affects Qt 5.7.0.
For Qt < 5.7.0 we don't have any DBusMenu support.
For Qt >= 5.7.1 the problem is fixed.

This patch adds a (horrible) event filter on any QMenuBar's and blocks
any setVisible calls.

Qt 5.7.0
void QMenuBar::setVisible(bool visible)
{
    if (isNativeMenuBar()) {
        if (!visible)
            QWidget::setVisible(false);
        return;
    }
    QWidget::setVisible(visible);
}

Qt 5.7.1
void QMenuBar::setVisible(bool visible)
{
    if (isNativeMenuBar()) {
        if (!visible)
            QWidget::setVisible(false);
        return;
    }
    QWidget::setVisible(visible);
}

Test Plan:
Ran on a system with Qt 5.7.0
No longer get double menus

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D4276

M  +42   -0    src/platformtheme/qdbusmenubar.cpp
M  +2    -0    src/platformtheme/qdbusmenubar_p.h

https://commits.kde.org/plasma-integration/bac5a39f01a88edd1a1165d3f3d08507742367fe