20 #include "TabBarWidget_p.h"
23 #include <QMouseEvent>
24 #include <QApplication>
25 #include <QProxyStyle>
50 return baseStyle()->styleHint(hint, option, widget, returnData);
60 static auto *proxy =
new MyProxy;
64 TabBarWidget::TabBarWidget(TabWidget *parent)
66 , TabBar(this, parent)
69 setMovable(Config::self().flags() & Config::Flag_AllowReorderTabs);
73 int TabBarWidget::tabAt(
QPoint localPos)
const
80 const int index = currentIndex();
81 return index == -1 ? nullptr
82 : dockWidgetAt(index);
87 onMousePress(e->
pos());
99 void TabBarWidget::mouseDoubleClickEvent(
QMouseEvent *e)
101 TabBar::onMouseDoubleClick(e->
pos());
104 bool TabBarWidget::dragCanStart(
QPoint pressPos,
QPoint pos)
const
109 const bool defaultResult = Draggable::dragCanStart(pressPos, pos);
111 if (!defaultResult || !isMovable()) {
115 return defaultResult;
118 const int index = tabAt(mapFromGlobal(pos));
120 return defaultResult;
122 const int deltaX = qAbs(pos.
x() - pressPos.
x());
123 const int deltaY = qAbs(pos.
y() - pressPos.
y());
137 bool TabBarWidget::event(
QEvent *ev)
143 auto parent = parentWidget();
150 parent->setFocusProxy(
this);
152 parent->setFocusProxy(
nullptr);
158 QString TabBarWidget::text(
int index)
const
160 return tabText(index);
163 QRect TabBarWidget::rectForTab(
int index)
const
168 void TabBarWidget::moveTabTo(
int from,
int to)