20#include "TabWidget_p.h"
22#include "DockWidgetBase_p.h"
23#include "DragController_p.h"
24#include "FloatingWindow_p.h"
29#include "WindowBeingDragged_p.h"
40 : Draggable(thisWidget)
41 , m_tabWidget(tabWidget)
42 , m_thisWidget(thisWidget)
48 if (index < 0 || index >= numDockWidgets())
51 return m_tabWidget->dockwidgetAt(index);
56 return dockWidgetAt(tabAt(localPos));
59std::unique_ptr<WindowBeingDragged> TabBar::makeWindow()
61 auto dock = m_lastPressedDockWidget;
62 m_lastPressedDockWidget =
nullptr;
67 if (hideTitleBarWhenTabsVisible) {
69 if (alwaysShowTabs && hasSingleDockWidget()) {
71 return m_tabWidget->makeWindow();
76 return m_tabWidget->makeWindow();
79 if (dock && hasSingleDockWidget() && alwaysShowTabs) {
88 FloatingWindow *floatingWindow = frame()->detachTab(dock);
92 auto draggable = KDDockWidgets::usesNativeTitleBar() ?
static_cast<Draggable *
>(floatingWindow)
93 : static_cast<Draggable *>(this);
94 return std::unique_ptr<WindowBeingDragged>(
new WindowBeingDragged(floatingWindow, draggable));
97bool TabBar::isWindow()
const
100 return m_tabWidget->isWindow();
103void TabBar::onMousePress(
QPoint localPos)
105 m_lastPressedDockWidget = dockWidgetAt(localPos);
106 Frame *frame = this->frame();
114void TabBar::onMouseDoubleClick(
QPoint localPos)
117 dw->setFloating(
true);
120bool TabBar::hasSingleDockWidget()
const
122 return numDockWidgets() == 1;
125int TabBar::numDockWidgets()
const
127 return m_tabWidget->numDockWidgets();
137 return m_tabWidget->singleDockWidget();
140bool TabBar::isMDI()
const
143 return f && f->isMDI();
146Frame *TabBar::frame()
const
148 return m_tabWidget->frame();
152 : Draggable(thisWidget,
Config::self().flags() & (
Config::Flag_HideTitleBarWhenTabsVisible |
Config::Flag_AlwaysShowTabs))
154 , m_thisWidget(thisWidget)
160 setCurrentDockWidget(indexOfDockWidget(dw));
165 return dockwidgetAt(currentIndex());
170 insertDockWidget(dock, numDockWidgets());
176 qCDebug(addwidget) << Q_FUNC_INFO << dock <<
"; count before=" << numDockWidgets();
180 if (index > numDockWidgets())
181 index = numDockWidgets();
183 if (contains(dock)) {
184 qWarning() << Q_FUNC_INFO <<
"Refusing to add already existing widget";
189 insertDockWidget(index, dock, dock->
icon(DockWidgetBase::IconPlace::TabBar), dock->
title());
190 setCurrentDockWidget(index);
192 if (oldFrame && oldFrame->beingDeletedLater()) {
209 return indexOfDockWidget(dw) != -1;
217Frame *TabWidget::frame()
const
222std::unique_ptr<WindowBeingDragged> TabWidget::makeWindow()
226 if (
auto floatingWindow = qobject_cast<FloatingWindow *>(asWidget()->window())) {
227 if (floatingWindow->hasSingleFrame()) {
230 return std::unique_ptr<WindowBeingDragged>(
new WindowBeingDragged(floatingWindow,
this));
234 QRect r = m_frame->QWidgetAdapter::geometry();
236 const QPoint globalPoint = m_thisWidget->mapToGlobal(
QPoint(0, 0));
241 floatingWindow->show();
243 return std::unique_ptr<WindowBeingDragged>(
new WindowBeingDragged(floatingWindow,
this));
246bool TabWidget::isWindow()
const
248 if (
auto floatingWindow = qobject_cast<FloatingWindow *>(asWidget()->window())) {
250 return floatingWindow->hasSingleFrame();
258 if (m_frame->hasSingleDockWidget())
259 return m_frame->dockWidgets().first();
264bool TabWidget::isMDI()
const
266 return m_frame && m_frame->isMDI();
269void TabWidget::onTabInserted()
271 m_frame->onDockWidgetCountChanged();
274void TabWidget::onTabRemoved()
276 m_frame->onDockWidgetCountChanged();
279void TabWidget::onCurrentTabChanged(
int index)
284bool TabWidget::onMouseDoubleClick(
QPoint localPos)
292 Frame *frame = this->frame();
295 if (frame->isCentralFrame())
298 if (FloatingWindow *fw = frame->floatingWindow()) {
299 if (!fw->hasSingleFrame()) {
303 }
else if (frame->isInMainWindow()) {
Application-wide config to tune certain behaviours of the framework.
void moveTopLeft(const QPoint &position)