diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 90d3d0cdb..9ae3b03b7 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -348,7 +348,7 @@ void QupZilla::setupMenu() m_menuFile->addAction(QIcon(":/icons/menu/new-tab.png"), tr("New Tab"), MENU_RECEIVER, SLOT(addTab()))->setShortcut(QKeySequence("Ctrl+T")); m_menuFile->addAction(QIcon::fromTheme("document-open-remote"), tr("Open Location"), MENU_RECEIVER, SLOT(openLocation()))->setShortcut(QKeySequence("Ctrl+L")); m_menuFile->addAction(QIcon::fromTheme("document-open"), tr("Open &File"), MENU_RECEIVER, SLOT(openFile()))->setShortcut(QKeySequence("Ctrl+O")); - m_menuFile->addAction(tr("Close Tab"), m_tabWidget, SLOT(closeTab()))->setShortcut(QKeySequence("Ctrl+W")); + m_menuFile->addAction(tr("Close Tab"), MENU_RECEIVER, SLOT(closeTab()))->setShortcut(QKeySequence("Ctrl+W")); m_actionCloseWindow = m_menuFile->addAction(QIcon::fromTheme("window-close"), tr("Close Window"), MENU_RECEIVER, SLOT(closeWindow())); m_actionCloseWindow->setShortcut(QKeySequence("Ctrl+Shift+W")); m_menuFile->addSeparator(); @@ -558,7 +558,7 @@ void QupZilla::setupMenu() *****************/ m_actionRestoreTab = new QAction(QIcon::fromTheme("user-trash"), tr("Restore &Closed Tab"), this); m_actionRestoreTab->setShortcut(QKeySequence("Ctrl+Shift+T")); - connect(m_actionRestoreTab, SIGNAL(triggered()), m_tabWidget, SLOT(restoreClosedTab())); + connect(m_actionRestoreTab, SIGNAL(triggered()), MENU_RECEIVER, SLOT(restoreClosedTab())); addAction(m_actionRestoreTab); QShortcut* reloadByPassCacheAction = new QShortcut(QKeySequence("Ctrl+F5"), this); @@ -579,7 +579,7 @@ void QupZilla::setupMenu() connect(openLocationAction, SIGNAL(activated()), MENU_RECEIVER, SLOT(openLocation())); QShortcut* closeTabAction = new QShortcut(QKeySequence("Ctrl+F4"), this); - connect(closeTabAction, SIGNAL(activated()), m_tabWidget, SLOT(closeTab())); + connect(closeTabAction, SIGNAL(activated()), MENU_RECEIVER, SLOT(closeTab())); // Make shortcuts available even in fullscreen (menu hidden) QList actions = menuBar()->actions(); @@ -830,7 +830,7 @@ void QupZilla::aboutToShowBookmarksMenu() { setEnabledSelectedMenuActions(m_menuBookmarks, QList() << 0 << 1 << 2); - if (!m_bookmarksMenuChanged) { + if (!MENU_RECEIVER->bookmarksMenuChanged()) { if (m_menuBookmarksAction) { m_menuBookmarksAction->setVisible(m_bookmarksToolbar->isVisible()); } @@ -971,7 +971,7 @@ void QupZilla::aboutToShowClosedTabsMenu() title.truncate(40); title += ".."; } - m_menuClosedTabs->addAction(_iconForUrl(tab.url), title, m_tabWidget, SLOT(restoreClosedTab()))->setData(i); + m_menuClosedTabs->addAction(_iconForUrl(tab.url), title, MENU_RECEIVER, SLOT(restoreClosedTab()))->setData(i); i++; } m_menuClosedTabs->addSeparator(); @@ -979,8 +979,8 @@ void QupZilla::aboutToShowClosedTabsMenu() m_menuClosedTabs->addAction(tr("Empty"))->setEnabled(false); } else { - m_menuClosedTabs->addAction(tr("Restore All Closed Tabs"), m_tabWidget, SLOT(restoreAllClosedTabs())); - m_menuClosedTabs->addAction(tr("Clear list"), m_tabWidget, SLOT(clearClosedTabsList())); + m_menuClosedTabs->addAction(tr("Restore All Closed Tabs"), MENU_RECEIVER, SLOT(restoreAllClosedTabs())); + m_menuClosedTabs->addAction(tr("Clear list"), MENU_RECEIVER, SLOT(clearClosedTabsList())); } } @@ -2051,6 +2051,29 @@ bool QupZilla::quitApp() return true; } +void QupZilla::closeTab() +{ + m_tabWidget->closeTab(); +} + +void QupZilla::restoreClosedTab(QObject* obj) +{ + if (!obj) { + obj = sender(); + } + m_tabWidget->restoreClosedTab(obj); +} + +void QupZilla::restoreAllClosedTabs() +{ + m_tabWidget->restoreAllClosedTabs(); +} + +void QupZilla::clearClosedTabsList() +{ + m_tabWidget->clearClosedTabsList(); +} + QByteArray QupZilla::saveState(int version) const { #ifdef QZ_WS_X11 diff --git a/src/lib/app/qupzilla.h b/src/lib/app/qupzilla.h index 5684708a2..86c72ef52 100644 --- a/src/lib/app/qupzilla.h +++ b/src/lib/app/qupzilla.h @@ -103,6 +103,8 @@ public: inline bool isClosing() { return m_isClosing; } inline QUrl homepageUrl() { return m_homepage; } + inline bool bookmarksMenuChanged() { return m_bookmarksMenuChanged; } + signals: void startingCompleted(); void message(Qz::AppMessageType mes, bool state); @@ -195,6 +197,10 @@ private slots: void closeWindow(); bool quitApp(); + void closeTab(); + void restoreClosedTab(QObject* obj = 0); + void restoreAllClosedTabs(); + void clearClosedTabsList(); #ifdef Q_OS_WIN void applyBlurToMainWindow(bool force = false); #endif diff --git a/src/lib/other/macmenureceiver.cpp b/src/lib/other/macmenureceiver.cpp index 74f6dd61a..3427178cc 100644 --- a/src/lib/other/macmenureceiver.cpp +++ b/src/lib/other/macmenureceiver.cpp @@ -31,6 +31,11 @@ MacMenuReceiver::MacMenuReceiver(QObject* parent) { } +bool MacMenuReceiver::bookmarksMenuChanged() +{ + return mApp->getWindow() && mApp->getWindow()->bookmarksMenuChanged(); +} + void MacMenuReceiver::setDisabledSelectedMenuActions(QMenu* menu, const QList indexList) { if (!menu) { @@ -335,6 +340,30 @@ void MacMenuReceiver::loadFolderBookmarks(Menu* menu) callSlot("loadFolderBookmarks", false, Q_ARG(Menu*, menu)); } +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"); diff --git a/src/lib/other/macmenureceiver.h b/src/lib/other/macmenureceiver.h index ec9d6e237..b3dafb833 100644 --- a/src/lib/other/macmenureceiver.h +++ b/src/lib/other/macmenureceiver.h @@ -33,6 +33,8 @@ class QT_QUPZILLA_EXPORT MacMenuReceiver : public QObject public: MacMenuReceiver(QObject* parent = 0); + bool bookmarksMenuChanged(); + private: void setDisabledSelectedMenuActions(QMenu* menu, const QList indexList = QList()); bool callSlot(const char *member, bool makeIfNoWindow = false, @@ -119,5 +121,10 @@ private slots: void loadActionUrlInNewTab(QObject* obj = 0); void loadActionUrlInNewNotSelectedTab(QObject* obj = 0); void loadFolderBookmarks(Menu* menu); + + void closeTab(); + void restoreClosedTab(QObject* obj = 0); + void restoreAllClosedTabs(); + void clearClosedTabsList(); }; #endif // MACMENURECEIVER_H diff --git a/src/lib/webview/tabwidget.cpp b/src/lib/webview/tabwidget.cpp index 5a76bba54..3feba84d9 100644 --- a/src/lib/webview/tabwidget.cpp +++ b/src/lib/webview/tabwidget.cpp @@ -641,15 +641,18 @@ int TabWidget::duplicateTab(int index) return id; } -void TabWidget::restoreClosedTab() +void TabWidget::restoreClosedTab(QObject* obj) { + if (!obj) { + obj = sender(); + } if (!m_closedTabsManager->isClosedTabAvailable()) { return; } ClosedTabsManager::Tab tab; - QAction* action = qobject_cast(sender()); + QAction* action = qobject_cast(obj); if (action && action->data().toInt() != 0) { tab = m_closedTabsManager->getTabAt(action->data().toInt()); } diff --git a/src/lib/webview/tabwidget.h b/src/lib/webview/tabwidget.h index 540d31596..83301e54c 100644 --- a/src/lib/webview/tabwidget.h +++ b/src/lib/webview/tabwidget.h @@ -110,7 +110,7 @@ public slots: void reloadAllTabs(); void stopTab(int index); void closeAllButCurrent(int index); - void restoreClosedTab(); + void restoreClosedTab(QObject* obj = 0); void restoreAllClosedTabs(); void clearClosedTabsList(); void aboutToShowClosedTabsMenu();