diff --git a/src/lib/tabwidget/tabcontextmenu.cpp b/src/lib/tabwidget/tabcontextmenu.cpp index 0ffb61639..e3dfcb118 100644 --- a/src/lib/tabwidget/tabcontextmenu.cpp +++ b/src/lib/tabwidget/tabcontextmenu.cpp @@ -43,6 +43,7 @@ TabContextMenu::TabContextMenu(int index, BrowserWindow *window, Options options connect(this, SIGNAL(closeToRight(int)), tabWidget, SLOT(closeToRight(int))); connect(this, SIGNAL(closeToLeft(int)), tabWidget, SLOT(closeToLeft(int))); connect(this, SIGNAL(duplicateTab(int)), tabWidget, SLOT(duplicateTab(int))); + connect(this, SIGNAL(detachTab(int)), tabWidget, SLOT(detachTab(int))); connect(this, SIGNAL(loadTab(int)), tabWidget, SLOT(loadTab(int))); connect(this, SIGNAL(unloadTab(int)), tabWidget, SLOT(unloadTab(int))); @@ -121,6 +122,10 @@ void TabContextMenu::init() addAction(QIcon::fromTheme("tab-duplicate"), tr("&Duplicate Tab"), this, SLOT(duplicateTab())); + if (m_options & ShowDetachTabAction && (mApp->windowCount() > 1 || tabWidget->count() > 1)) { + addAction(QIcon::fromTheme("tab-detach"), tr("D&etach Tab"), this, SLOT(detachTab())); + } + addAction(webTab->isPinned() ? tr("Un&pin Tab") : tr("&Pin Tab"), this, SLOT(pinTab())); addAction(webTab->isMuted() ? tr("Un&mute Tab") : tr("&Mute Tab"), this, SLOT(muteTab())); diff --git a/src/lib/tabwidget/tabcontextmenu.h b/src/lib/tabwidget/tabcontextmenu.h index d72a29aab..79683e491 100644 --- a/src/lib/tabwidget/tabcontextmenu.h +++ b/src/lib/tabwidget/tabcontextmenu.h @@ -35,6 +35,7 @@ public: HorizontalTabs = 1 << 0, VerticalTabs = 1 << 1, ShowCloseOtherTabsActions = 1 << 2, + ShowDetachTabAction = 1 << 3, DefaultOptions = HorizontalTabs | ShowCloseOtherTabsActions }; @@ -50,6 +51,7 @@ signals: void closeToRight(int index); void closeToLeft(int index); void duplicateTab(int index); + void detachTab(int index); void loadTab(int index); void unloadTab(int index); @@ -58,6 +60,7 @@ private slots: void stopTab() { emit stopTab(m_clickedTab); } void closeTab() { emit tabCloseRequested(m_clickedTab); } void duplicateTab() { emit duplicateTab(m_clickedTab); } + void detachTab() { emit detachTab(m_clickedTab); } void loadTab() { emit loadTab(m_clickedTab); } void unloadTab() { emit unloadTab(m_clickedTab); } @@ -76,4 +79,6 @@ private: Options m_options = InvalidOption; }; +Q_DECLARE_OPERATORS_FOR_FLAGS(TabContextMenu::Options) + #endif // TABCONTEXTMENU_H diff --git a/src/plugins/VerticalTabs/tablistview.cpp b/src/plugins/VerticalTabs/tablistview.cpp index 67864b711..78caee432 100644 --- a/src/plugins/VerticalTabs/tablistview.cpp +++ b/src/plugins/VerticalTabs/tablistview.cpp @@ -208,7 +208,8 @@ bool TabListView::viewportEvent(QEvent *event) const QModelIndex index = indexAt(ce->pos()); WebTab *tab = index.data(TabModel::WebTabRole).value(); const int tabIndex = tab ? tab->tabIndex() : -1; - TabContextMenu menu(tabIndex, m_window, TabContextMenu::HorizontalTabs); + TabContextMenu::Options options = TabContextMenu::HorizontalTabs | TabContextMenu::ShowDetachTabAction; + TabContextMenu menu(tabIndex, m_window, options); menu.exec(ce->globalPos()); break; } diff --git a/src/plugins/VerticalTabs/tabtreeview.cpp b/src/plugins/VerticalTabs/tabtreeview.cpp index 716cd31ff..7f836e4c4 100644 --- a/src/plugins/VerticalTabs/tabtreeview.cpp +++ b/src/plugins/VerticalTabs/tabtreeview.cpp @@ -304,7 +304,7 @@ bool TabTreeView::viewportEvent(QEvent *event) const QModelIndex index = indexAt(ce->pos()); WebTab *tab = index.data(TabModel::WebTabRole).value(); const int tabIndex = tab ? tab->tabIndex() : -1; - TabContextMenu::Options options = TabContextMenu::VerticalTabs; + TabContextMenu::Options options = TabContextMenu::VerticalTabs | TabContextMenu::ShowDetachTabAction; if (m_tabsInOrder) { options |= TabContextMenu::ShowCloseOtherTabsActions; }