diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 03140be11..a6a5d9fe6 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -192,7 +192,10 @@ void QupZilla::postLaunch() } break; +#ifdef Q_OS_MAC case Qz::BW_MacFirstWindow: + QTimer::singleShot(0, this, SLOT(refreshStateOfAllActions())); +#endif case Qz::BW_NewWindow: addTab = true; break; @@ -247,6 +250,8 @@ void QupZilla::postLaunch() QMainWindow::setWindowTitle(m_lastWindowTitle); setUpdatesEnabled(true); + raise(); + activateWindow(); } void QupZilla::setupUi() @@ -701,6 +706,16 @@ void QupZilla::setupMacMenu() m_actionPageInfo = m_menuTools->actions().at(1); m_actionPrivateBrowsing = m_menuTools->actions().at(9); } + +void QupZilla::refreshStateOfAllActions() +{ + mApp->macMenuReceiver()->aboutToShowFileMenu(m_menuFile); + mApp->macMenuReceiver()->aboutToShowHistoryMenu(m_menuHistory); + mApp->macMenuReceiver()->aboutToShowBookmarksMenu(m_menuBookmarks); + mApp->macMenuReceiver()->aboutToShowViewMenu(m_menuView); + mApp->macMenuReceiver()->aboutToShowEditMenu(m_menuEdit); + mApp->macMenuReceiver()->aboutToShowToolsMenu(m_menuTools); +} #endif void QupZilla::loadSettings() @@ -2122,6 +2137,8 @@ void QupZilla::closeEvent(QCloseEvent* event) return; } +#else + QTimer::singleShot(0, this, SLOT(refreshStateOfAllActions())); #endif mApp->aboutToCloseWindow(this); diff --git a/src/lib/app/qupzilla.h b/src/lib/app/qupzilla.h index 93360f895..f6fbf00d1 100644 --- a/src/lib/app/qupzilla.h +++ b/src/lib/app/qupzilla.h @@ -209,6 +209,9 @@ private slots: void restoreAllClosedTabs(); void clearClosedTabsList(); void hideNavigationSlot(); +#ifdef Q_OS_MAC + void refreshStateOfAllActions(); +#endif private: bool event(QEvent* event); diff --git a/src/lib/other/macmenureceiver.cpp b/src/lib/other/macmenureceiver.cpp index 75b1749e7..848c498c8 100644 --- a/src/lib/other/macmenureceiver.cpp +++ b/src/lib/other/macmenureceiver.cpp @@ -426,9 +426,9 @@ void MacMenuReceiver::loadActionUrlInNewNotSelectedTab(QObject* obj) } // about to show/hide slots -void MacMenuReceiver::aboutToShowFileMenu() +void MacMenuReceiver::aboutToShowFileMenu(QMenu* menu) { - QMenu* menu = qobject_cast(sender()); + menu = menu ? menu : qobject_cast(sender()); setEnabledSelectedMenuActions(menu); if (!callSlot("aboutToShowFileMenu")) { setDisabledSelectedMenuActions(menu, QList() @@ -441,9 +441,9 @@ void MacMenuReceiver::aboutToHideFileMenu() callSlot("aboutToHideFileMenu"); } -void MacMenuReceiver::aboutToShowHistoryMenu() +void MacMenuReceiver::aboutToShowHistoryMenu(QMenu* menu) { - QMenu* menu = qobject_cast(sender()); + menu = menu ? menu : qobject_cast(sender()); // 2=Home, 3=Show all History, 7=Closed Tabs setEnabledSelectedMenuActions(menu, QList() << 2 << 3 << 7); if (!callSlot("aboutToShowHistoryMenu")) { @@ -462,18 +462,18 @@ void MacMenuReceiver::aboutToShowClosedTabsMenu() callSlot("aboutToShowClosedTabsMenu"); } -void MacMenuReceiver::aboutToShowBookmarksMenu() +void MacMenuReceiver::aboutToShowBookmarksMenu(QMenu* menu) { - QMenu* menu = qobject_cast(sender()); + menu = menu ? menu : qobject_cast(sender()); setEnabledSelectedMenuActions(menu, QList() << 0 << 1 << 2); if (!callSlot("aboutToShowBookmarksMenu")) { setDisabledSelectedMenuActions(menu, QList() << 0 << 1 << 2); } } -void MacMenuReceiver::aboutToShowViewMenu() +void MacMenuReceiver::aboutToShowViewMenu(QMenu* menu) { - QMenu* menu = qobject_cast(sender()); + menu = menu ? menu : qobject_cast(sender()); // 7,8,9=Zoom actions, 12=Character Encoding, 15=Fullscreen setEnabledSelectedMenuActions(menu, QList() << 0 << 1 << 2 << 7 << 8 << 9 << 11 << 12 << 15); @@ -492,9 +492,9 @@ void MacMenuReceiver::aboutToHideViewMenu() callSlot("aboutToHideViewMenu"); } -void MacMenuReceiver::aboutToShowEditMenu() +void MacMenuReceiver::aboutToShowEditMenu(QMenu* menu) { - QMenu* menu = qobject_cast(sender()); + menu = menu ? menu : qobject_cast(sender()); // 8=Find setEnabledSelectedMenuActions(menu, QList() << 8); if (!callSlot("aboutToShowEditMenu")) { @@ -507,9 +507,9 @@ void MacMenuReceiver::aboutToHideEditMenu() callSlot("aboutToHideEditMenu"); } -void MacMenuReceiver::aboutToShowToolsMenu() +void MacMenuReceiver::aboutToShowToolsMenu(QMenu* menu) { - QMenu* menu = qobject_cast(sender()); + menu = menu ? menu : qobject_cast(sender()); // enable all setEnabledSelectedMenuActions(menu); if (!callSlot("aboutToShowToolsMenu")) { diff --git a/src/lib/other/macmenureceiver.h b/src/lib/other/macmenureceiver.h index bf90417a5..092642247 100644 --- a/src/lib/other/macmenureceiver.h +++ b/src/lib/other/macmenureceiver.h @@ -44,6 +44,14 @@ public: inline QAction* menuBookmarksAction() { return m_menuBookmarksAction; } inline void setMenuBookmarksAction(QAction* action) { m_menuBookmarksAction = action; } +public slots: + void aboutToShowFileMenu(QMenu* menu = 0); + void aboutToShowEditMenu(QMenu* menu = 0); + void aboutToShowViewMenu(QMenu* menu = 0); + void aboutToShowHistoryMenu(QMenu* menu = 0); + void aboutToShowBookmarksMenu(QMenu* menu = 0); + void aboutToShowToolsMenu(QMenu* menu = 0); + private: void setEnabledSelectedMenuActions(QMenu* menu, const QList indexList = QList()); void setDisabledSelectedMenuActions(QMenu* menu, const QList indexList = QList()); @@ -66,17 +74,11 @@ private slots: void addTab(); void savePageScreen(); - void aboutToShowFileMenu(); void aboutToHideFileMenu(); - void aboutToShowHistoryMenu(); void aboutToHideHistoryMenu(); void aboutToShowClosedTabsMenu(); - void aboutToShowBookmarksMenu(); - void aboutToShowViewMenu(); void aboutToHideViewMenu(); - void aboutToShowEditMenu(); void aboutToHideEditMenu(); - void aboutToShowToolsMenu(); void aboutToHideToolsMenu(); void aboutToShowEncodingMenu();