From 98de30b53fbd8ae5ce2bf279b17911223fe848d0 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Thu, 30 May 2024 01:00:06 +0200 Subject: [PATCH] show 'hide menubar?' dialog on Linux only when the menubar will be in the window i.e. only if global menu is not supported or if it is and we're when going fullscreen --- src/mixxxmainwindow.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/mixxxmainwindow.cpp b/src/mixxxmainwindow.cpp index af88465c7f66..aa03adbe44de 100644 --- a/src/mixxxmainwindow.cpp +++ b/src/mixxxmainwindow.cpp @@ -555,6 +555,7 @@ void MixxxMainWindow::initializeWindow() { #ifndef __APPLE__ void MixxxMainWindow::alwaysHideMenuBarDlg() { + // Don't show the dialog if the user unchecked "Ask me again" if (!m_pCoreServices->getSettings()->getValue( kMenuBarHintConfigKey, true)) { return; @@ -956,6 +957,7 @@ void MixxxMainWindow::connectMenuBar() { #endif } +/// Enable/disable listening to Alt key press for toggling the menubar. #ifndef __APPLE__ void MixxxMainWindow::slotUpdateMenuBarAltKeyConnection() { if (!m_pCoreServices->getKeyboardEventFilter() || !m_pMenuBar) { @@ -963,6 +965,7 @@ void MixxxMainWindow::slotUpdateMenuBarAltKeyConnection() { } if (m_pCoreServices->getSettings()->getValue(kHideMenuBarConfigKey, false)) { + // with Qt::UniqueConnection we don't need to check whether we're already connected connect(m_pCoreServices->getKeyboardEventFilter().get(), &KeyboardEventFilter::altPressedWithoutKeys, m_pMenuBar, @@ -1238,7 +1241,7 @@ bool MixxxMainWindow::loadConfiguredSkin() { return m_pCentralWidget != nullptr; } -// Try to load default styles that can be overridden by skins +/// Try to load default styles that can be overridden by skins void MixxxMainWindow::tryParseAndSetDefaultStyleSheet() { const QString resPath = m_pCoreServices->getSettings()->getResourcePath(); QFile file(resPath + "/skins/default.qss"); @@ -1251,6 +1254,7 @@ void MixxxMainWindow::tryParseAndSetDefaultStyleSheet() { } } +/// Catch ToolTip and WindowStateChange events bool MixxxMainWindow::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::ToolTip) { // always show tooltips in the preferences window @@ -1307,12 +1311,21 @@ bool MixxxMainWindow::eventFilter(QObject* obj, QEvent* event) { QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, isFullScreenNow); createMenuBar(); connectMenuBar(); - // With a global menu we didn't show the menubar auto-hide dialog - // during (windowed) startup, so ask now. + } +#endif + +#ifndef __APPLE__ +#ifdef __LINUX__ + // Only show the dialog if we are able to have the menubar in the + // main window, only then we're able to hide it. + if (!m_supportsGlobalMenuBar || isFullScreenNow) +#endif + { alwaysHideMenuBarDlg(); slotUpdateMenuBarAltKeyConnection(); } #endif + // This will toggle the Fullscreen checkbox and hide the menubar if // we go fullscreen. // Skip this during startup or the launchimage will be shifted