Double clicking on a tab will make it float

Also really required for Wayland, where we don't another way to
float a single tab, as the float button affects all of them.
This commit is contained in:
Sergio Martins
2020-10-17 12:09:47 +01:00
parent d7de0ebd20
commit 424453ab57
4 changed files with 13 additions and 0 deletions

View File

@@ -111,6 +111,11 @@ void TabBarWidget::mouseMoveEvent(QMouseEvent *e)
}
}
void TabBarWidget::mouseDoubleClickEvent(QMouseEvent *e)
{
TabBar::onMouseDoubleClick(e->pos());
}
bool TabBarWidget::dragCanStart(QPoint pressPos, QPoint pos) const
{
// Here we allow the user to re-order tabs instead of dragging them off.

View File

@@ -47,6 +47,7 @@ protected:
bool dragCanStart(QPoint pressPos, QPoint pos) const override;
void mousePressEvent(QMouseEvent *) override;
void mouseMoveEvent(QMouseEvent *e) override;
void mouseDoubleClickEvent(QMouseEvent *e) override;
private:
TabWidget *const m_tabWidget;
};

View File

@@ -115,6 +115,12 @@ void TabBar::onMousePress(QPoint localPos)
m_lastPressedDockWidget = dockWidgetAt(localPos);
}
void TabBar::onMouseDoubleClick(QPoint localPos)
{
if (DockWidgetBase *dw = dockWidgetAt(localPos))
dw->setFloating(true);
}
bool TabBar::hasSingleDockWidget() const
{
return numDockWidgets() == 1;

View File

@@ -67,6 +67,7 @@ public:
FloatingWindow *detachTab(DockWidgetBase *dockWidget);
void onMousePress(QPoint localPos);
void onMouseDoubleClick(QPoint localPos);
///@brief returns whether there's only 1 tab
bool hasSingleDockWidget() const;