Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move QT_X11_NO_NATIVE_MENUBAR to code #4818

Merged
merged 5 commits into from
Feb 11, 2019
Merged

Move QT_X11_NO_NATIVE_MENUBAR to code #4818

merged 5 commits into from
Feb 11, 2019

Conversation

jasp00
Copy link
Member

@jasp00 jasp00 commented Feb 9, 2019

Enable QT_X11_NO_NATIVE_MENUBAR by default. Clean up the desktop entry.

@PhysSong
Copy link
Member

PhysSong commented Feb 9, 2019

@jasp00
Copy link
Member Author

jasp00 commented Feb 9, 2019

  • I don't think the error message is descriptive enough.

Make a proposal.

@tresf
Copy link
Member

tresf commented Feb 9, 2019

@jasp00 thanks for the trick, this will come in useful. For this particular setting, I recommend we remove the env and use code instead, thanks to @PhysSong's findings here: #488 (comment)

@tresf
Copy link
Member

tresf commented Feb 9, 2019

@jasp00 Qt::AA_DontUseNativeMenuBar is part of the Qt4 documentation. Is there a reason why you did not use it?

@jasp00
Copy link
Member Author

jasp00 commented Feb 10, 2019

I do not see a way to override Qt::AA_DontUseNativeMenuBar.

@PhysSong
Copy link
Member

PhysSong commented Feb 10, 2019

I do not see a way to override Qt::AA_DontUseNativeMenuBar.

I think @tresf meant QCoreApplication::setAttribute. Both ways work the same to me, though they internally work slightly different.
Quoting part of the source code of appmenu-qt5:

void AppMenuPlatformMenuBar::createMenuBar()
{
    static bool firstCall = true;
    static bool envSaysNo = !qgetenv("QT_X11_NO_NATIVE_MENUBAR").isEmpty();
    static bool envSaysBoth = qgetenv("APPMENU_DISPLAY_BOTH") == "1";

    if (!m_menuBar->parentWidget()) {
        return;
    }

    m_adapter = 0;

    if (!firstCall && !envSaysBoth && QApplication::testAttribute(Qt::AA_DontUseNativeMenuBar)) {
        return;
    }

    if (envSaysNo) {
        if (firstCall) {
            firstCall = false;
            m_nativeMenuBar = NMB_DisabledByEnv;
            QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true);
        }
        return;
    }
bool AppMenuPlatformMenuBar::isNativeMenuBar() const
{
    if (m_nativeMenuBar == NMB_DisabledByEnv) {
        return false;
    }
    if (m_nativeMenuBar == NMB_Auto) {
        return !QApplication::instance()->testAttribute(Qt::AA_DontUseNativeMenuBar);
    }
    return m_nativeMenuBar == NMB_Enabled;
}
  • I don't think the error message is descriptive enough.

Make a proposal.

Something like this?

Failed to set QT_X11_NO_NATIVE_MENUBAR environment variable. MDI interface might be buggy.

@tresf
Copy link
Member

tresf commented Feb 10, 2019

... but the error message is irrelevant because we should be using the API, or remove it entirely since it does nothing for Qt5.

@PhysSong
Copy link
Member

... but the error message is irrelevant because we should be using the API, or remove it entirely since it does nothing for Qt5.

Okay. Now I'm fine with keeping the error message as-is.

@tresf
Copy link
Member

tresf commented Feb 10, 2019

I'm confused. The error message wouldn't be needed if using QCoreApplication::setAttribute which is more consistent with the hidpi PR. Can we just use that and settle this? How does an error message fit into that?

@PhysSong
Copy link
Member

@tresf I was talking about the error message we should use if we stick to setenv.

@jasp00
Copy link
Member Author

jasp00 commented Feb 10, 2019

Ready.

src/core/main.cpp Outdated Show resolved Hide resolved
@tresf
Copy link
Member

tresf commented Feb 11, 2019

Testing with Qt4:

Before:
image

After:
image

Just incase Qt5 eventually honors this
@tresf tresf added this to the 1.2.0 milestone Feb 11, 2019
@tresf
Copy link
Member

tresf commented Feb 11, 2019

Travis-CI shows failed, but that's just the Debian jobs. Appears to be failing, not related to the codebase at all. Merging.

@tresf tresf merged commit e94d1c9 into stable-1.2 Feb 11, 2019
@PhysSong PhysSong deleted the setenv branch February 20, 2019 23:11
sdasda7777 pushed a commit to sdasda7777/lmms that referenced this pull request Jun 28, 2022
Set Qt::AA_DontUseNativeMenuBar
Remove QT_X11_NO_NATIVE_MENUBAR from desktop launcher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants