mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Add context menu for tabs in search widget (#14926)
In searchwidget you can close all opened tabs or selected tab using menu. Closes #5628.
This commit is contained in:
parent
ea3b897d5d
commit
a51742b47c
@ -39,6 +39,7 @@
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <QObject>
|
||||
#include <QRegularExpression>
|
||||
@ -162,6 +163,15 @@ bool SearchWidget::eventFilter(QObject *object, QEvent *event)
|
||||
closeTab(tabIndex);
|
||||
return true;
|
||||
}
|
||||
if (mouseEvent->button() == Qt::RightButton)
|
||||
{
|
||||
QMenu *menu = new QMenu(this);
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
menu->addAction(tr("Close tab"), this, [this, tabIndex]() { closeTab(tabIndex); });
|
||||
menu->addAction(tr("Close all tabs"), this, &SearchWidget::closeAllTabs);
|
||||
menu->popup(QCursor::pos());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return QWidget::eventFilter(object, event);
|
||||
@ -381,3 +391,9 @@ void SearchWidget::closeTab(int index)
|
||||
|
||||
delete tab;
|
||||
}
|
||||
|
||||
void SearchWidget::closeAllTabs()
|
||||
{
|
||||
for (int i = (m_allTabs.size() - 1); i >= 0; --i)
|
||||
closeTab(i);
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ private:
|
||||
bool eventFilter(QObject *object, QEvent *event) override;
|
||||
void tabChanged(int index);
|
||||
void closeTab(int index);
|
||||
void closeAllTabs();
|
||||
void tabStatusChanged(QWidget *tab);
|
||||
void selectMultipleBox(int index);
|
||||
void toggleFocusBetweenLineEdits();
|
||||
|
Loading…
Reference in New Issue
Block a user