14#include "core/Draggable_p.h"
16#include "core/ScopedValueRollback_p.h"
19#include "core/DockWidget_p.h"
20#include "core/Logging_p.h"
24#include "core/DragController_p.h"
25#include "core/Utils_p.h"
37 , d(new Private(stack))
41 tvi->setTabsAreMovable(tabsAreMovable());
60 const bool defaultResult = Draggable::dragCanStart(pressPos, pos);
62 if (!defaultResult || !tabsAreMovable()) {
74 const int deltaX = std::abs(pos.x() - pressPos.x());
75 const int deltaY = std::abs(pos.y() - pressPos.y());
79 if (deltaY > 5 * startDragDistance) {
82 }
else if (deltaY > startDragDistance && deltaX < startDragDistance) {
93 if (index < 0 || index >= numDockWidgets())
96 return const_cast<DockWidget *
>(d->m_dockWidgets.value(index));
102 return dockWidgetAt(tvi->tabAt(localPos));
109 return d->m_dockWidgets.indexOf(dw);
117 auto it = d->aboutToDeleteConnections.find(dw);
118 if (it != d->aboutToDeleteConnections.end())
119 d->aboutToDeleteConnections.erase(it);
121 const bool wasCurrent = dw == d->m_currentDockWidget;
122 const int index = d->m_dockWidgets.indexOf(dw);
125 const bool isLast = index == d->m_dockWidgets.count() - 1;
126 const int newCurrentIndex = isLast ? index - 1 : index + 1;
130 d->m_removeGuard =
true;
134 tvi->removeDockWidget(dw);
135 d->m_removeGuard =
false;
137 d->m_dockWidgets.removeOne(dw);
144 if (
auto oldGroup = dw->
dptr()->group()) {
145 if (
auto oldTabBar = oldGroup->tabBar()) {
146 if (oldTabBar !=
this) {
147 oldTabBar->removeDockWidget(dw);
152 d->m_dockWidgets.insert(index, dw);
156 d->aboutToDeleteConnections[dw] = std::move(conn);
159 if (!d->m_currentDockWidget)
167 auto dock = d->m_lastPressedDockWidget;
168 d->m_lastPressedDockWidget =
nullptr;
170 const bool hideTitleBarWhenTabsVisible =
174 if (hideTitleBarWhenTabsVisible) {
176 if (alwaysShowTabs && hasSingleDockWidget()) {
179 return d->m_stack->makeWindow();
185 return d->m_stack->makeWindow();
188 if (dock && hasSingleDockWidget() && alwaysShowTabs) {
202 auto draggable = KDDockWidgets::usesNativeTitleBar() ?
static_cast<Draggable *
>(floatingWindow)
203 :
static_cast<Draggable *
>(
this);
204 return std::make_unique<WindowBeingDragged>(floatingWindow, draggable);
210 return d->m_stack->isWindow();
215 d->m_lastPressedDockWidget = dockWidgetAt(localPos);
216 Group *group = this->group();
227 dw->setFloating(
true);
232 return numDockWidgets() == 1;
237 return d->m_dockWidgets.
size();
242 return d->m_stack->singleDockWidget();
248 return f && f->
isMDI();
262void Core::TabBar::Private::moveTabTo(
int from,
int to)
264 auto fromDw = m_dockWidgets.takeAt(from);
265 m_dockWidgets.insert(to, fromDw);
270 ScopedValueRollback guard(d->m_isMovingTab,
true);
272 d->moveTabTo(from, to);
276 tvi->moveTabTo(from, to);
282 return tvi->text(index);
290 return tvi->rectForTab(index);
297 return d->m_currentDockWidget;
302 if (d->m_removeGuard)
305 if (dw == d->m_currentDockWidget)
313 if (!d->m_currentDockWidget)
316 return d->m_dockWidgets.indexOf(d->m_currentDockWidget);
321 if (d->m_removeGuard)
325 if (newCurrentDw == d->m_currentDockWidget)
328 if (d->m_currentDockWidget) {
329 d->m_currentDockWidget->d->isCurrentTabChanged.emit(
false);
332 d->m_currentDockWidget = newCurrentDw;
333 d->currentDockWidgetChanged.emit(newCurrentDw);
335 tvi->setCurrentIndex(index);
338 newCurrentDw->d->isCurrentTabChanged.emit(
true);
344 tvi->renameTab(index,
text);
350 tvi->changeTabIcon(index, icon);
355 return d->m_isMovingTab;
Application-wide config to tune certain behaviours of the framework.
A ScopedConnection is a RAII-style way to make sure a Connection is disconnected.