mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Close tab on mouse release rather than on mouse press
Differential Revision: https://phabricator.kde.org/D4501
This commit is contained in:
parent
d75b1de7bf
commit
f7770c60b1
|
@ -29,7 +29,8 @@
|
|||
|
||||
DolphinTabBar::DolphinTabBar(QWidget* parent) :
|
||||
QTabBar(parent),
|
||||
m_autoActivationIndex(-1)
|
||||
m_autoActivationIndex(-1),
|
||||
m_tabToBeClosedOnMiddleMouseButtonRelease(-1)
|
||||
{
|
||||
setAcceptDrops(true);
|
||||
setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
|
||||
|
@ -95,12 +96,25 @@ void DolphinTabBar::mousePressEvent(QMouseEvent* event)
|
|||
const int index = tabAt(event->pos());
|
||||
|
||||
if (index >= 0 && event->button() == Qt::MiddleButton) {
|
||||
m_tabToBeClosedOnMiddleMouseButtonRelease = index;
|
||||
return;
|
||||
}
|
||||
|
||||
QTabBar::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void DolphinTabBar::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
const int index = tabAt(event->pos());
|
||||
|
||||
if (index >= 0 && index == m_tabToBeClosedOnMiddleMouseButtonRelease
|
||||
&& event->button() == Qt::MiddleButton) {
|
||||
// Mouse middle click on a tab closes this tab.
|
||||
emit tabCloseRequested(index);
|
||||
return;
|
||||
}
|
||||
|
||||
QTabBar::mousePressEvent(event);
|
||||
QTabBar::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void DolphinTabBar::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
|
|
|
@ -40,6 +40,7 @@ protected:
|
|||
virtual void dragMoveEvent(QDragMoveEvent* event) Q_DECL_OVERRIDE;
|
||||
virtual void dropEvent(QDropEvent* event) Q_DECL_OVERRIDE;
|
||||
virtual void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
||||
virtual void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
||||
|
||||
/**
|
||||
|
@ -60,6 +61,7 @@ private:
|
|||
private:
|
||||
QTimer* m_autoActivationTimer;
|
||||
int m_autoActivationIndex;
|
||||
int m_tabToBeClosedOnMiddleMouseButtonRelease;
|
||||
};
|
||||
|
||||
#endif // DOLPHIN_TAB_BAR_H
|
||||
|
|
Loading…
Reference in a new issue