From 345d03105f9f2f646558a7597c2c246574d22236 Mon Sep 17 00:00:00 2001 From: srazi Date: Mon, 20 Mar 2017 11:37:33 +0330 Subject: [PATCH] macOS: Fix global menu with multiple windows. - Closes #2261 --- src/lib/app/browserwindow.cpp | 4 ++-- src/lib/app/mainapplication.cpp | 2 ++ src/lib/app/mainapplication.h | 1 + src/lib/app/mainmenu.h | 4 +++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp index 026bbb791..ccea6a543 100644 --- a/src/lib/app/browserwindow.cpp +++ b/src/lib/app/browserwindow.cpp @@ -346,20 +346,20 @@ void BrowserWindow::setupMenu() if (!macMainMenu) { macMainMenu = new MainMenu(this, 0); macMainMenu->initMenuBar(new QMenuBar(0)); + connect(mApp, SIGNAL(activeWindowChanged(BrowserWindow*)), macMainMenu, SLOT(setWindow(BrowserWindow*))); } else { macMainMenu->setWindow(this); } m_mainMenu = macMainMenu; - m_mainMenu->initSuperMenu(m_superMenu); #else setMenuBar(new MenuBar(this)); m_mainMenu = new MainMenu(this, this); m_mainMenu->initMenuBar(menuBar()); - m_mainMenu->initSuperMenu(m_superMenu); #endif + m_mainMenu->initSuperMenu(m_superMenu); // Setup other shortcuts QShortcut* reloadBypassCacheAction = new QShortcut(QKeySequence(QSL("Ctrl+F5")), this); diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index f6881ff73..eaa46d55c 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -845,6 +845,8 @@ void MainApplication::onFocusChanged() if (activeBrowserWindow) { m_lastActiveWindow = activeBrowserWindow; + + emit activeWindowChanged(m_lastActiveWindow); } } diff --git a/src/lib/app/mainapplication.h b/src/lib/app/mainapplication.h index 73a02be53..ee66cb4ac 100644 --- a/src/lib/app/mainapplication.h +++ b/src/lib/app/mainapplication.h @@ -121,6 +121,7 @@ public slots: signals: void settingsReloaded(); + void activeWindowChanged(BrowserWindow* window); private slots: void postLaunch(); diff --git a/src/lib/app/mainmenu.h b/src/lib/app/mainmenu.h index f46bc6cda..32e2301eb 100644 --- a/src/lib/app/mainmenu.h +++ b/src/lib/app/mainmenu.h @@ -38,13 +38,15 @@ class QUPZILLA_EXPORT MainMenu : public QMenu public: explicit MainMenu(BrowserWindow* window, QWidget* parent = 0); - void setWindow(BrowserWindow* window); void initMenuBar(QMenuBar* menuBar) const; void initSuperMenu(QMenu* superMenu) const; QAction* action(const QString &name) const; +public slots: + void setWindow(BrowserWindow* window); + private slots: // Standard actions void showAboutDialog();