mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +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 <QDebug>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QMenu>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
@ -162,6 +163,15 @@ bool SearchWidget::eventFilter(QObject *object, QEvent *event)
|
|||||||
closeTab(tabIndex);
|
closeTab(tabIndex);
|
||||||
return true;
|
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 false;
|
||||||
}
|
}
|
||||||
return QWidget::eventFilter(object, event);
|
return QWidget::eventFilter(object, event);
|
||||||
@ -381,3 +391,9 @@ void SearchWidget::closeTab(int index)
|
|||||||
|
|
||||||
delete tab;
|
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;
|
bool eventFilter(QObject *object, QEvent *event) override;
|
||||||
void tabChanged(int index);
|
void tabChanged(int index);
|
||||||
void closeTab(int index);
|
void closeTab(int index);
|
||||||
|
void closeAllTabs();
|
||||||
void tabStatusChanged(QWidget *tab);
|
void tabStatusChanged(QWidget *tab);
|
||||||
void selectMultipleBox(int index);
|
void selectMultipleBox(int index);
|
||||||
void toggleFocusBetweenLineEdits();
|
void toggleFocusBetweenLineEdits();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user