From a7417294760de836a6b4e0312cdd6aa65441ca2d Mon Sep 17 00:00:00 2001 From: trnkava1 Date: Sat, 19 Mar 2016 14:07:48 +0100 Subject: [PATCH] Deleted unused MacMenuReceiver --- src/lib/other/macmenureceiver.cpp | 520 ------------------------------ src/lib/other/macmenureceiver.h | 144 --------- 2 files changed, 664 deletions(-) delete mode 100644 src/lib/other/macmenureceiver.cpp delete mode 100644 src/lib/other/macmenureceiver.h diff --git a/src/lib/other/macmenureceiver.cpp b/src/lib/other/macmenureceiver.cpp deleted file mode 100644 index aca09f6cd..000000000 --- a/src/lib/other/macmenureceiver.cpp +++ /dev/null @@ -1,520 +0,0 @@ -/* ============================================================ -* QupZilla - WebKit based browser -* Copyright (C) 2010-2014 David Rosca -* Copyright (C) 2013-2014 S. Razi Alavizadeh -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* ============================================================ */ -#include "macmenureceiver.h" -#include "mainapplication.h" -#include "browserwindow.h" -#include "settings.h" - -#include -#include - -MacMenuReceiver::MacMenuReceiver(QObject* parent) - : QObject(parent) - , m_macMenuBar(0) - , m_bookmarksMenuChanged(true) - , m_menuBookmarksAction(0) -{ -} - -void MacMenuReceiver::setEnabledSelectedMenuActions(QMenu* menu, const QList indexList) -{ - if (!menu || mApp->windowCount() == 0) { - return; - } - - // we mean all actions by empty list - if (indexList.isEmpty()) { - foreach (QAction* act, menu->actions()) { - act->setEnabled(true); - } - return; - } - - foreach (int index, indexList) { - Q_ASSERT(index >= 0 && index < menu->actions().size()); - menu->actions().at(index)->setEnabled(true); - } -} - -void MacMenuReceiver::setDisabledSelectedMenuActions(QMenu* menu, const QList indexList) -{ - if (!menu) { - return; - } - - // we mean all actions by empty list - if (indexList.isEmpty()) { - foreach (QAction* act, menu->actions()) { - act->setDisabled(true); - } - return; - } - - foreach (int index, indexList) { - Q_ASSERT(index >= 0 && index < menu->actions().size()); - menu->actions().at(index)->setDisabled(true); - } -} - -bool MacMenuReceiver::callSlot(const char* member, bool makeIfNoWindow, QGenericArgument val0, QGenericArgument val1) -{ - BrowserWindow* qzWindow = mApp->getWindow(); - if (!qzWindow) { - if (!makeIfNoWindow) { - return false; - } - else { - qzWindow = mApp->createWindow(Qz::BW_MacFirstWindow); - mApp->processEvents(); - } - } - - bool success = QMetaObject::invokeMethod(qzWindow, member, val0, val1); - - if (!success) { - qCritical("Warning: try to invoke \'BrowserWindow::%s()\' with incorrect parameter(s) or no such slot.", member); - // this should never happen, for now: - // we just ignore it! - } - - return true; -} - -void MacMenuReceiver::goNext() -{ - callSlot("goNext"); -} - - -void MacMenuReceiver::goBack() -{ - callSlot("goBack"); -} - -void MacMenuReceiver::goHome() -{ - callSlot("goHome", true); -} - -void MacMenuReceiver::stop() -{ - callSlot("stop"); -} - -void MacMenuReceiver::reload() -{ - callSlot("reload"); -} - -void MacMenuReceiver::reloadByPassCache() -{ - callSlot("reloadByPassCache"); -} - -void MacMenuReceiver::aboutQupZilla() -{ - callSlot("aboutQupZilla", true); -} - -void MacMenuReceiver::addTab() -{ - if (!callSlot("addTab")) { - mApp->createWindow(Qz::BW_MacFirstWindow); - } -} - -void MacMenuReceiver::savePageScreen() -{ - callSlot("savePageScreen"); -} - -void MacMenuReceiver::searchOnPage() -{ - callSlot("searchOnPage"); -} - -void MacMenuReceiver::showCookieManager() -{ - callSlot("showCookieManager"); -} - -void MacMenuReceiver::showHistoryManager() -{ - callSlot("showHistoryManager"); -} - -void MacMenuReceiver::showBookmarksManager() -{ - callSlot("showBookmarksManager"); -} - -void MacMenuReceiver::showDownloadManager() -{ - callSlot("showDownloadManager"); -} - -void MacMenuReceiver::showMenubar() -{ - callSlot("showMenubar"); -} - -void MacMenuReceiver::showNavigationToolbar() -{ - callSlot("showNavigationToolbar"); -} - -void MacMenuReceiver::showStatusbar() -{ - callSlot("showStatusbar"); -} - -void MacMenuReceiver::showClearPrivateData() -{ - callSlot("showClearPrivateData"); -} - -void MacMenuReceiver::showPreferences() -{ - callSlot("showPreferences", true); -} - -void MacMenuReceiver::showBookmarkImport() -{ - callSlot("showBookmarkImport"); -} - - -void MacMenuReceiver::refreshHistory() -{ - callSlot("refreshHistory"); -} - -void MacMenuReceiver::bookmarkAllTabs() -{ - callSlot("bookmarkAllTabs"); -} - -void MacMenuReceiver::newWindow() -{ - if (!callSlot("newWindow")) { - mApp->createWindow(Qz::BW_MacFirstWindow); - } -} - - -void MacMenuReceiver::openLocation() -{ - callSlot("openLocation", true); -} - -void MacMenuReceiver::openFile() -{ - callSlot("openFile", true); -} - -void MacMenuReceiver::savePage() -{ - callSlot("savePage"); -} - -void MacMenuReceiver::sendLink() -{ - callSlot("sendLink"); -} - -void MacMenuReceiver::webSearch() -{ - callSlot("webSearch"); -} - - -void MacMenuReceiver::editUndo() -{ - callSlot("editUndo"); -} - -void MacMenuReceiver::editRedo() -{ - callSlot("editRedo"); -} - -void MacMenuReceiver::editCut() -{ - callSlot("editCut"); -} - -void MacMenuReceiver::editCopy() -{ - callSlot("editCopy"); -} - -void MacMenuReceiver::editPaste() -{ - callSlot("editPaste"); -} - -void MacMenuReceiver::editSelectAll() -{ - callSlot("editSelectAll"); -} - - -void MacMenuReceiver::zoomIn() -{ - callSlot("zoomIn"); -} - -void MacMenuReceiver::zoomOut() -{ - callSlot("zoomOut"); -} - -void MacMenuReceiver::zoomReset() -{ - callSlot("zoomReset"); -} - -void MacMenuReceiver::toggleFullScreen() -{ - callSlot("toggleFullScreen"); -} - -void MacMenuReceiver::changeEncoding(QObject* obj) -{ - if (!obj) { - obj = sender(); - } - - callSlot("changeEncoding", false, Q_ARG(QObject*, obj)); -} - -void MacMenuReceiver::triggerTabsOnTop(bool enable) -{ - callSlot("triggerTabsOnTop", false, Q_ARG(bool, enable)); -} - -void MacMenuReceiver::closeWindow() -{ - callSlot("closeWindow"); -} - -void MacMenuReceiver::quitApp() -{ - if (!callSlot("quitApp")) { - mApp->quitApplication(); - } -} - -void MacMenuReceiver::printPage(QWebEngineFrame* frame) -{ - callSlot("printPage", false, Q_ARG(QWebEngineFrame*, frame)); -} - -void MacMenuReceiver::showBookmarksToolbar() -{ - callSlot("showBookmarksToolbar"); -} - -void MacMenuReceiver::showSource(QWebEngineFrame* frame, const QString &selectedHtml) -{ - callSlot("showSource", false, Q_ARG(QWebEngineFrame*, frame), Q_ARG(const QString &, selectedHtml)); -} - -void MacMenuReceiver::bookmarkPage() -{ - callSlot("bookmarkPage"); -} - -void MacMenuReceiver::closeTab() -{ - callSlot("closeTab"); -} - -void MacMenuReceiver::restoreClosedTab(QObject* obj) -{ - if (!obj) { - obj = sender(); - } - - callSlot("restoreClosedTab", false, Q_ARG(QObject*, obj)); -} - -void MacMenuReceiver::restoreAllClosedTabs() -{ - callSlot("restoreAllClosedTabs"); -} - -void MacMenuReceiver::clearClosedTabsList() -{ - callSlot("clearClosedTabsList"); -} - -void MacMenuReceiver::showPageInfo() -{ - callSlot("showPageInfo"); -} - -void MacMenuReceiver::showWebInspector(bool toggle) -{ - callSlot("showWebInspector", false, Q_ARG(bool, toggle)); -} - -void MacMenuReceiver::loadActionUrl(QObject* obj) -{ - if (!obj) { - obj = sender(); - } - - callSlot("loadActionUrl", true, Q_ARG(QObject*, obj)); -} - -void MacMenuReceiver::loadActionUrlInNewTab(QObject* obj) -{ - if (!obj) { - obj = sender(); - } - - if (!callSlot("loadActionUrlInNewTab", false, Q_ARG(QObject*, obj))) { - callSlot("loadActionUrl", true, Q_ARG(QObject*, obj)); - } -} - -void MacMenuReceiver::loadActionUrlInNewNotSelectedTab(QObject* obj) -{ - if (!obj) { - obj = sender(); - } - - if (!callSlot("loadActionUrlInNewNotSelectedTab", false, Q_ARG(QObject*, obj))) { - callSlot("loadActionUrl", true, Q_ARG(QObject*, obj)); - } -} - -// about to show/hide slots -void MacMenuReceiver::aboutToShowFileMenu(QMenu* menu) -{ - menu = menu ? menu : qobject_cast(sender()); - setEnabledSelectedMenuActions(menu); - if (!callSlot("aboutToShowFileMenu")) { - setDisabledSelectedMenuActions(menu, QList() - << 4 << 5 << 7 << 8 << 9 << 10 << 12); - } -} - -void MacMenuReceiver::aboutToHideFileMenu() -{ - callSlot("aboutToHideFileMenu"); -} - -void MacMenuReceiver::aboutToShowHistoryMenu(QMenu* menu) -{ - menu = menu ? menu : qobject_cast(sender()); - // 2=Home, 3=Show all History, 7=Closed Tabs - setEnabledSelectedMenuActions(menu, QList() << 2 << 3 << 7); - if (!callSlot("aboutToShowHistoryMenu")) { - setDisabledSelectedMenuActions(menu, QList() - << 0 << 1 << 2 << 3 << 7); - } -} - -void MacMenuReceiver::aboutToHideHistoryMenu() -{ - callSlot("aboutToHideHistoryMenu"); -} - -void MacMenuReceiver::aboutToShowClosedTabsMenu() -{ - callSlot("aboutToShowClosedTabsMenu"); -} - -void MacMenuReceiver::aboutToShowBookmarksMenu(QMenu* menu) -{ - menu = menu ? menu : qobject_cast(sender()); - setEnabledSelectedMenuActions(menu, QList() << 0 << 1 << 2); - if (!callSlot("aboutToShowBookmarksMenu")) { - setDisabledSelectedMenuActions(menu, QList() << 0 << 1 << 2); - } -} - -void MacMenuReceiver::aboutToShowViewMenu(QMenu* menu) -{ - 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); - // for updating reload and stop actions - if (mApp->getWindow()) { - mApp->getWindow()->updateLoadingActions(); - } - - if (!callSlot("aboutToShowViewMenu")) { - setDisabledSelectedMenuActions(menu); - } -} - -void MacMenuReceiver::aboutToHideViewMenu() -{ - callSlot("aboutToHideViewMenu"); -} - -void MacMenuReceiver::aboutToShowEditMenu(QMenu* menu) -{ - menu = menu ? menu : qobject_cast(sender()); - // 8=Find - setEnabledSelectedMenuActions(menu, QList() << 8); - if (!callSlot("aboutToShowEditMenu")) { - setDisabledSelectedMenuActions(menu); - } -} - -void MacMenuReceiver::aboutToHideEditMenu() -{ - callSlot("aboutToHideEditMenu"); -} - -void MacMenuReceiver::aboutToShowToolsMenu(QMenu* menu) -{ - menu = menu ? menu : qobject_cast(sender()); - // enable all - setEnabledSelectedMenuActions(menu); - if (!callSlot("aboutToShowToolsMenu")) { - setDisabledSelectedMenuActions(menu, QList() - << 0 << 1 << 3 << 4 << 6 << 7 << 8); - } -} - -void MacMenuReceiver::aboutToHideToolsMenu() -{ - callSlot("aboutToHideToolsMenu"); -} - -void MacMenuReceiver::aboutToShowEncodingMenu() -{ - callSlot("aboutToShowEncodingMenu"); -} - -void MacMenuReceiver::aboutToShowHistoryRecentMenu() -{ - callSlot("aboutToShowHistoryRecentMenu"); -} - -void MacMenuReceiver::aboutToShowHistoryMostMenu() -{ - callSlot("aboutToShowHistoryMostMenu"); -} diff --git a/src/lib/other/macmenureceiver.h b/src/lib/other/macmenureceiver.h deleted file mode 100644 index 286f4d5b2..000000000 --- a/src/lib/other/macmenureceiver.h +++ /dev/null @@ -1,144 +0,0 @@ -/* ============================================================ -* QupZilla - WebKit based browser -* Copyright (C) 2010-2014 David Rosca -* Copyright (C) 2013-2014 S. Razi Alavizadeh -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* ============================================================ */ -#ifndef MACMENURECEIVER_H -#define MACMENURECEIVER_H - -#include - -#include "qzcommon.h" - -class QWebEngineFrame; -class Menu; -class QMenu; -class QAction; -class QMenuBar; - -class QUPZILLA_EXPORT MacMenuReceiver : public QObject -{ - Q_OBJECT -public: - MacMenuReceiver(QObject* parent = 0); - - inline QMenuBar* menuBar() { return m_macMenuBar; } - inline void setMenuBar(QMenuBar* menuBar) { m_macMenuBar = menuBar; } - - inline bool bookmarksMenuChanged() { return m_bookmarksMenuChanged; } - inline void setBookmarksMenuChanged(bool changed) { m_bookmarksMenuChanged = changed; } - - 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()); - bool callSlot(const char* member, bool makeIfNoWindow = false, - QGenericArgument val0 = QGenericArgument(0), - QGenericArgument val1 = QGenericArgument()); - - QMenuBar* m_macMenuBar; - bool m_bookmarksMenuChanged; - QAction* m_menuBookmarksAction; - -private slots: - void goNext(); - void goBack(); - void goHome(); - void stop(); - void reload(); - void reloadByPassCache(); - void aboutQupZilla(); - void addTab(); - void savePageScreen(); - - void aboutToHideFileMenu(); - void aboutToHideHistoryMenu(); - void aboutToShowClosedTabsMenu(); - void aboutToHideViewMenu(); - void aboutToHideEditMenu(); - void aboutToHideToolsMenu(); - void aboutToShowEncodingMenu(); - - void searchOnPage(); - void showCookieManager(); - void showHistoryManager(); - void showBookmarksManager(); - void showDownloadManager(); - void showMenubar(); - void showNavigationToolbar(); - void showStatusbar(); - void showClearPrivateData(); - void aboutToShowHistoryRecentMenu(); - void aboutToShowHistoryMostMenu(); - void showPreferences(); - void showBookmarkImport(); - - void refreshHistory(); - void bookmarkAllTabs(); - void newWindow(); - - void openLocation(); - void openFile(); - void savePage(); - void sendLink(); - void webSearch(); - - // Edit menu actions - void editUndo(); - void editRedo(); - void editCut(); - void editCopy(); - void editPaste(); - void editSelectAll(); - - void zoomIn(); - void zoomOut(); - void zoomReset(); - void toggleFullScreen(); - void changeEncoding(QObject* obj = 0); - - void triggerTabsOnTop(bool enable); - - void closeWindow(); - void quitApp(); - - void printPage(QWebEngineFrame* frame = 0); - void showBookmarksToolbar(); - void showSource(QWebEngineFrame* frame = 0, const QString &selectedHtml = QString()); - void bookmarkPage(); - void showPageInfo(); - void showWebInspector(bool toggle = true); - - void loadActionUrl(QObject* obj = 0); - void loadActionUrlInNewTab(QObject* obj = 0); - void loadActionUrlInNewNotSelectedTab(QObject* obj = 0); - - void closeTab(); - void restoreClosedTab(QObject* obj = 0); - void restoreAllClosedTabs(); - void clearClosedTabsList(); -}; -#endif // MACMENURECEIVER_H