void TabBar::contextMenuEvent(QContextMenuEvent* event) { int index = tabAt(event->pos()); m_clickedTab = index; QMenu menu; menu.addAction(IconProvider::newTabIcon(), tr("&New tab"), m_window, SLOT(addTab())); menu.addSeparator(); if (index != -1) { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_clickedTab)); if (!webTab) { return; } if (m_window->weView(m_clickedTab)->isLoading()) { menu.addAction(QIcon::fromTheme(QSL("process-stop")), tr("&Stop Tab"), this, SLOT(stopTab())); } else { menu.addAction(QIcon::fromTheme(QSL("view-refresh")), tr("&Reload Tab"), this, SLOT(reloadTab())); } menu.addAction(QIcon::fromTheme("tab-duplicate"), tr("&Duplicate Tab"), this, SLOT(duplicateTab())); if (count() > 1 && !webTab->isPinned()) { menu.addAction(QIcon::fromTheme("tab-detach"), tr("D&etach Tab"), this, SLOT(detachTab())); } menu.addAction(webTab->isPinned() ? tr("Un&pin Tab") : tr("&Pin Tab"), this, SLOT(pinTab())); #if QT_VERSION >= QT_VERSION_CHECK(5,7,0) menu.addAction(webTab->isMuted() ? tr("Un&mute Tab") : tr("&Mute Tab"), this, SLOT(muteTab())); #endif menu.addSeparator(); menu.addAction(tr("Re&load All Tabs"), m_tabWidget, SLOT(reloadAllTabs())); menu.addAction(tr("&Bookmark This Tab"), this, SLOT(bookmarkTab())); menu.addAction(tr("Bookmark &All Tabs"), m_window, SLOT(bookmarkAllTabs())); menu.addSeparator(); menu.addAction(m_window->action(QSL("Other/RestoreClosedTab"))); menu.addSeparator(); menu.addAction(tr("Close Ot&her Tabs"), this, SLOT(closeAllButCurrent())); menu.addAction(QIcon::fromTheme("window-close"), tr("Cl&ose"), this, SLOT(closeTab())); menu.addSeparator(); } else { menu.addAction(tr("Reloa&d All Tabs"), m_tabWidget, SLOT(reloadAllTabs())); menu.addAction(tr("Bookmark &All Tabs"), m_window, SLOT(bookmarkAllTabs())); menu.addSeparator(); menu.addAction(m_window->action(QSL("Other/RestoreClosedTab"))); } m_window->action(QSL("Other/RestoreClosedTab"))->setEnabled(m_tabWidget->canRestoreTab()); // Prevent choosing first option with double rightclick const QPoint pos = event->globalPos(); QPoint p(pos.x(), pos.y() + 1); menu.exec(p); m_window->action(QSL("Other/RestoreClosedTab"))->setEnabled(true); }
void TabBar::contextMenuRequested(const QPoint &position) { int index = tabAt(position); m_clickedTab = index; QMenu menu; menu.addAction(QIcon(":/icons/menu/new-tab.png"), tr("&New tab"), p_QupZilla, SLOT(addTab())); menu.addSeparator(); if (index != -1) { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_clickedTab)); if (!webTab) { return; } if (p_QupZilla->weView(m_clickedTab)->isLoading()) { menu.addAction(qIconProvider->standardIcon(QStyle::SP_BrowserStop), tr("&Stop Tab"), this, SLOT(stopTab())); } else { menu.addAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("&Reload Tab"), this, SLOT(reloadTab())); } menu.addAction(tr("&Duplicate Tab"), this, SLOT(duplicateTab())); menu.addAction(webTab->isPinned() ? tr("Un&pin Tab") : tr("&Pin Tab"), this, SLOT(pinTab())); menu.addSeparator(); menu.addAction(tr("Re&load All Tabs"), m_tabWidget, SLOT(reloadAllTabs())); menu.addAction(tr("&Bookmark This Tab"), this, SLOT(bookmarkTab())); menu.addAction(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs())); menu.addSeparator(); QAction* action = p_QupZilla->actionRestoreTab(); action->setEnabled(m_tabWidget->canRestoreTab()); menu.addAction(action); menu.addSeparator(); menu.addAction(tr("Close Ot&her Tabs"), this, SLOT(closeAllButCurrent())); menu.addAction(QIcon::fromTheme("window-close"), tr("Cl&ose"), this, SLOT(closeTab())); menu.addSeparator(); } else { menu.addAction(tr("Reloa&d All Tabs"), m_tabWidget, SLOT(reloadAllTabs())); menu.addAction(tr("Bookmark &All Ta&bs"), p_QupZilla, SLOT(bookmarkAllTabs())); menu.addSeparator(); QAction* action = menu.addAction(QIcon::fromTheme("user-trash"), tr("Restore &Closed Tab"), m_tabWidget, SLOT(restoreClosedTab())); action->setEnabled(m_tabWidget->canRestoreTab()); } // Prevent choosing first option with double rightclick const QPoint &pos = mapToGlobal(position); QPoint p(pos.x(), pos.y() + 1); menu.exec(p); p_QupZilla->actionRestoreTab()->setEnabled(true); }
void BookmarksToolbar::customContextMenuRequested(const QPoint &pos) { Q_UNUSED(pos) QMenu menu; menu.addAction(tr("&Bookmark Current Page"), p_QupZilla, SLOT(bookmarkPage())); menu.addAction(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs())); menu.addAction(qIconProvider->fromTheme("user-bookmarks"), tr("&Organize Bookmarks"), p_QupZilla, SLOT(showBookmarksManager())); menu.addSeparator(); QAction act(tr("Show Most &Visited"), this); act.setCheckable(true); act.setChecked(m_bookmarksModel->isShowingMostVisited()); connect(&act, SIGNAL(triggered()), this, SLOT(showMostVisited())); menu.addAction(&act); QAction act2(tr("Show Only Icons"), this); act2.setCheckable(true); act2.setChecked(m_bookmarksModel->isShowingOnlyIconsInToolbar()); connect(&act2, SIGNAL(triggered()), this, SLOT(toggleShowOnlyIcons())); menu.addAction(&act2); menu.addSeparator(); menu.addAction(tr("&Hide Toolbar"), this, SLOT(hidePanel())); //Prevent choosing first option with double rightclick QPoint position = mapToGlobal(pos); QPoint p(position.x(), position.y() + 1); menu.exec(p); }
void BookmarksToolbar::customContextMenuRequested(const QPoint &pos) { Q_UNUSED(pos) QMenu menu; menu.addAction(tr("&Bookmark Current Page"), p_QupZilla, SLOT(bookmarkPage())); menu.addAction(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs())); menu.addAction(IconProvider::fromTheme("user-bookmarks"), tr("&Organize Bookmarks"), p_QupZilla, SLOT(showBookmarksManager())); menu.addSeparator(); menu.addAction(m_bookmarksModel->isShowingMostVisited() ? tr("Hide Most &Visited") : tr("Show Most &Visited"), this, SLOT(showMostVisited())); menu.addAction(tr("&Hide Toolbar"), this, SLOT(hidePanel())); //Prevent choosing first option with double rightclick QPoint position = QCursor::pos(); QPoint p(position.x(), position.y() + 1); menu.exec(p); }