diff --git a/src/mumble/LogTabs.cpp b/src/mumble/LogTabs.cpp index 7f3650642f8..4165b26fc6c 100644 --- a/src/mumble/LogTabs.cpp +++ b/src/mumble/LogTabs.cpp @@ -169,6 +169,21 @@ void LogTabWidget::onTabCloseRequested(int index) { updateHashMap(); } +void LogTabWidget::onTabCloseAllRequested() { + for (int i = count() - 1; i >= 0; i--) { + if (i == getGeneralTab()) { + continue; + } + + QString hashKey = dynamic_cast(widget(i))->m_hash; + m_hashMap.remove(hashKey); + widget(i)->deleteLater(); + removeTab(i); + } + + updateHashMap(); +} + void LogTabWidget::onTabBarCustomContextMenuRequested(const QPoint& point) { QSignalMapper *mapper = new QSignalMapper(this); for (int i = 0; i < count(); i++) { @@ -178,11 +193,16 @@ void LogTabWidget::onTabBarCustomContextMenuRequested(const QPoint& point) { if (tabBar()->tabRect(i).contains(point)) { QMenu *menu = new QMenu(); - QAction *action = menu->addAction(tr("Close")); - mapper->setMapping(action, i); - connect(action, SIGNAL(triggered()), mapper, SLOT(map())); + QAction *closeAction = menu->addAction(tr("Close")); + QAction *closeAllAction = menu->addAction(tr("Close all")); + + mapper->setMapping(closeAction, i); + + connect(closeAllAction, SIGNAL(triggered()), this, SLOT(onTabCloseAllRequested())); + connect(closeAction, SIGNAL(triggered()), mapper, SLOT(map())); connect(mapper, SIGNAL(mapped(int)), this, SLOT(onTabCloseRequested(int))); connect(mapper, SIGNAL(mapped(int)), this, SIGNAL(currentChanged(int))); + menu->exec(QCursor::pos()); break; } diff --git a/src/mumble/LogTabs.h b/src/mumble/LogTabs.h index b29c718ae94..48df3a8a7e0 100644 --- a/src/mumble/LogTabs.h +++ b/src/mumble/LogTabs.h @@ -53,6 +53,7 @@ public slots: void onCurrentChanged(int); void onTabMoved(int, int); void onTabCloseRequested(int); + void onTabCloseAllRequested(); void onTabBarCustomContextMenuRequested(const QPoint &); signals: void anchorClick(const QUrl &); diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index 83a2be8a590..18f9c76154f 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -1950,6 +1950,7 @@ void MainWindow::qmChannel_aboutToShow() { qmChannel->addAction(qaChannelUnlinkAll); qmChannel->addSeparator(); qmChannel->addAction(qaChannelCopyURL); + qmChannel->addAction(qaChannelOpenTab); qmChannel->addAction(qaChannelSendMessage); // hiding the root is nonsense @@ -2007,6 +2008,7 @@ void MainWindow::qmChannel_aboutToShow() { qaChannelLink->setEnabled(link); qaChannelUnlink->setEnabled(unlink); qaChannelUnlinkAll->setEnabled(unlinkall); + qaChannelOpenTab->setEnabled(msg); qaChannelSendMessage->setEnabled(msg); updateMenuPermissions(); } @@ -2116,6 +2118,16 @@ void MainWindow::on_qaChannelUnlinkAll_triggered() { g.sh->sendMessage(mpcs); } +void MainWindow::on_qaChannelOpenTab_triggered() { + Channel *c = getContextMenuChannel(); + if (!c) { + return; + } + + qtwLogTabs->createTab(QString::number(c->iId), c->qsName, true); + qtwLogTabs->openTab(QString::number(c->iId)); +} + void MainWindow::on_qaChannelSendMessage_triggered() { Channel *c = getContextMenuChannel(); @@ -2256,6 +2268,7 @@ void MainWindow::updateMenuPermissions() { qaChannelUnlinkAll->setEnabled(p & (ChanACL::Write | ChanACL::LinkChannel)); qaChannelCopyURL->setEnabled(c); + qaChannelOpenTab->setEnabled(p & (ChanACL::Write | ChanACL::TextMessage)); qaChannelSendMessage->setEnabled(p & (ChanACL::Write | ChanACL::TextMessage)); qaChannelFilter->setEnabled(true); } diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index 53868f5281c..55166b2426c 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -218,6 +218,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin void on_qaChannelLink_triggered(); void on_qaChannelUnlink_triggered(); void on_qaChannelUnlinkAll_triggered(); + void on_qaChannelOpenTab_triggered(); void on_qaChannelSendMessage_triggered(); void on_qaChannelFilter_triggered(); void on_qaChannelCopyURL_triggered(); diff --git a/src/mumble/MainWindow.ui b/src/mumble/MainWindow.ui index edd9fe422a3..8e459210fc2 100644 --- a/src/mumble/MainWindow.ui +++ b/src/mumble/MainWindow.ui @@ -48,7 +48,7 @@ 0 0 671 - 21 + 23 @@ -111,8 +111,7 @@ 1 - - + @@ -900,6 +899,11 @@ the channel's context menu. false + + + Open &tab + +