2022-09-05 17:29:42 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
** Qt Advanced Docking System
|
|
|
|
** Copyright (C) 2017 Uwe Kindler
|
|
|
|
**
|
|
|
|
** This library is free software; you can redistribute it and/or
|
|
|
|
** modify it under the terms of the GNU Lesser General Public
|
|
|
|
** License as published by the Free Software Foundation; either
|
|
|
|
** version 2.1 of the License, or (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This library is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
** Lesser General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU Lesser General Public
|
|
|
|
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2022-11-01 20:41:36 +08:00
|
|
|
/// \file AutoHideSideBar.cpp
|
2022-09-05 17:29:42 +08:00
|
|
|
/// \author Syarif Fakhri
|
|
|
|
/// \date 05.09.2022
|
2022-11-01 20:41:36 +08:00
|
|
|
/// \brief Implementation of CAutoHideSideBar class
|
2022-09-05 17:29:42 +08:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
// INCLUDES
|
|
|
|
//============================================================================
|
2022-11-01 20:41:36 +08:00
|
|
|
#include "AutoHideSideBar.h"
|
|
|
|
|
2022-09-05 17:29:42 +08:00
|
|
|
#include <QBoxLayout>
|
2022-09-14 14:17:28 +08:00
|
|
|
#include <QStyleOption>
|
|
|
|
#include <QPainter>
|
2022-10-31 02:44:33 +08:00
|
|
|
#include <QXmlStreamWriter>
|
2022-09-05 17:29:42 +08:00
|
|
|
|
2022-10-27 19:25:40 +08:00
|
|
|
#include "DockContainerWidget.h"
|
|
|
|
#include "DockWidgetTab.h"
|
|
|
|
#include "DockFocusController.h"
|
|
|
|
#include "AutoHideDockContainer.h"
|
2022-10-31 02:44:33 +08:00
|
|
|
#include "DockAreaWidget.h"
|
2022-11-01 18:02:01 +08:00
|
|
|
#include "DockingStateReader.h"
|
2022-11-01 20:41:36 +08:00
|
|
|
#include "AutoHideTab.h"
|
2022-10-27 19:25:40 +08:00
|
|
|
|
2022-09-05 17:29:42 +08:00
|
|
|
namespace ads
|
|
|
|
{
|
2022-11-03 18:34:04 +08:00
|
|
|
class CTabsWidget;
|
|
|
|
|
2022-09-05 17:29:42 +08:00
|
|
|
/**
|
|
|
|
* Private data class of CSideTabBar class (pimpl)
|
|
|
|
*/
|
2022-11-01 19:06:59 +08:00
|
|
|
struct AutoHideSideBarPrivate
|
2022-09-05 17:29:42 +08:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Private data constructor
|
|
|
|
*/
|
2022-11-01 19:06:59 +08:00
|
|
|
AutoHideSideBarPrivate(CAutoHideSideBar* _public);
|
2022-09-05 17:29:42 +08:00
|
|
|
|
2022-11-01 19:06:59 +08:00
|
|
|
CAutoHideSideBar* _this;
|
2022-09-05 17:29:42 +08:00
|
|
|
CDockContainerWidget* ContainerWidget;
|
2022-11-03 18:34:04 +08:00
|
|
|
CTabsWidget* TabsContainerWidget;
|
2022-09-05 17:29:42 +08:00
|
|
|
QBoxLayout* TabsLayout;
|
2022-09-13 10:42:58 +08:00
|
|
|
Qt::Orientation Orientation;
|
2022-11-03 22:28:01 +08:00
|
|
|
SideBarLocation SideTabArea = SideBarLocation::SideBarLeft;
|
2022-10-26 15:50:16 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience function to check if this is a horizontal side bar
|
|
|
|
*/
|
|
|
|
bool isHorizontal() const
|
|
|
|
{
|
|
|
|
return Qt::Horizontal == Orientation;
|
|
|
|
}
|
2022-11-03 18:34:04 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called from viewport to forward event handling to this
|
|
|
|
*/
|
|
|
|
void handleViewportEvent(QEvent* e);
|
2022-11-01 19:06:59 +08:00
|
|
|
}; // struct AutoHideSideBarPrivate
|
2022-09-05 17:29:42 +08:00
|
|
|
|
2022-11-03 18:34:04 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This widget stores the tab buttons
|
|
|
|
*/
|
|
|
|
class CTabsWidget : public QWidget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using QWidget::QWidget;
|
|
|
|
using Super = QWidget;
|
|
|
|
AutoHideSideBarPrivate* EventHandler;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the size hint as minimum size hint
|
|
|
|
*/
|
|
|
|
virtual QSize minimumSizeHint() const override
|
|
|
|
{
|
|
|
|
return Super::sizeHint();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Forward event handling to EventHandler
|
|
|
|
*/
|
2022-11-04 20:43:59 +08:00
|
|
|
virtual bool event(QEvent* e) override
|
2022-11-03 18:34:04 +08:00
|
|
|
{
|
|
|
|
EventHandler->handleViewportEvent(e);
|
|
|
|
return Super::event(e);
|
2022-11-04 20:43:59 +08:00
|
|
|
}
|
2022-11-03 18:34:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-09-05 17:29:42 +08:00
|
|
|
//============================================================================
|
2022-11-01 19:06:59 +08:00
|
|
|
AutoHideSideBarPrivate::AutoHideSideBarPrivate(CAutoHideSideBar* _public) :
|
2022-09-05 17:29:42 +08:00
|
|
|
_this(_public)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-03 18:34:04 +08:00
|
|
|
//============================================================================
|
|
|
|
void AutoHideSideBarPrivate::handleViewportEvent(QEvent* e)
|
|
|
|
{
|
|
|
|
switch (e->type())
|
|
|
|
{
|
|
|
|
case QEvent::ChildRemoved:
|
|
|
|
if (TabsLayout->isEmpty())
|
|
|
|
{
|
|
|
|
_this->hide();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-05 17:29:42 +08:00
|
|
|
//============================================================================
|
2022-11-01 19:06:59 +08:00
|
|
|
CAutoHideSideBar::CAutoHideSideBar(CDockContainerWidget* parent, SideBarLocation area) :
|
2022-10-26 15:50:16 +08:00
|
|
|
Super(parent),
|
2022-11-01 19:06:59 +08:00
|
|
|
d(new AutoHideSideBarPrivate(this))
|
2022-09-05 17:29:42 +08:00
|
|
|
{
|
2022-10-26 15:50:16 +08:00
|
|
|
d->SideTabArea = area;
|
2022-09-05 17:29:42 +08:00
|
|
|
d->ContainerWidget = parent;
|
2022-11-03 22:28:01 +08:00
|
|
|
d->Orientation = (area == SideBarLocation::SideBarBottom || area == SideBarLocation::SideBarTop)
|
2022-10-26 15:50:16 +08:00
|
|
|
? Qt::Horizontal : Qt::Vertical;
|
2022-09-05 17:29:42 +08:00
|
|
|
|
2022-11-03 18:34:04 +08:00
|
|
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
setFrameStyle(QFrame::NoFrame);
|
|
|
|
setWidgetResizable(true);
|
|
|
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
|
|
|
|
d->TabsContainerWidget = new CTabsWidget();
|
|
|
|
d->TabsContainerWidget->EventHandler = d;
|
|
|
|
d->TabsContainerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
d->TabsContainerWidget->setObjectName("sideTabsContainerWidget");
|
|
|
|
|
2022-09-14 15:52:34 +08:00
|
|
|
|
2022-09-13 10:42:58 +08:00
|
|
|
d->TabsLayout = new QBoxLayout(d->Orientation == Qt::Vertical ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight);
|
2022-09-05 17:29:42 +08:00
|
|
|
d->TabsLayout->setContentsMargins(0, 0, 0, 0);
|
2022-11-03 18:34:04 +08:00
|
|
|
d->TabsLayout->setSpacing(12);
|
|
|
|
d->TabsLayout->addStretch(1);
|
|
|
|
d->TabsContainerWidget->setLayout(d->TabsLayout);
|
|
|
|
setWidget(d->TabsContainerWidget);
|
2022-10-26 15:50:16 +08:00
|
|
|
|
2022-09-05 17:29:42 +08:00
|
|
|
setFocusPolicy(Qt::NoFocus);
|
2022-10-26 15:50:16 +08:00
|
|
|
if (d->isHorizontal())
|
|
|
|
{
|
|
|
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
|
|
|
}
|
|
|
|
|
|
|
|
hide();
|
2022-09-05 17:29:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2022-11-01 19:06:59 +08:00
|
|
|
CAutoHideSideBar::~CAutoHideSideBar()
|
2022-09-05 17:29:42 +08:00
|
|
|
{
|
2022-11-03 23:49:20 +08:00
|
|
|
ADS_PRINT("~CSideTabBar()");
|
2022-10-27 16:23:11 +08:00
|
|
|
// The SideTabeBar is not the owner of the tabs and to prevent deletion
|
|
|
|
// we set the parent here to nullptr to remove it from the children
|
2022-11-01 19:06:59 +08:00
|
|
|
auto Tabs = findChildren<CAutoHideTab*>(QString(), Qt::FindDirectChildrenOnly);
|
2022-10-27 16:23:11 +08:00
|
|
|
for (auto Tab : Tabs)
|
|
|
|
{
|
|
|
|
Tab->setParent(nullptr);
|
|
|
|
}
|
2022-09-05 17:29:42 +08:00
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2022-11-01 20:34:08 +08:00
|
|
|
void CAutoHideSideBar::insertTab(int Index, CAutoHideTab* SideTab)
|
2022-09-05 17:29:42 +08:00
|
|
|
{
|
2022-11-01 19:06:59 +08:00
|
|
|
SideTab->setSideBar(this);
|
2022-11-03 18:34:04 +08:00
|
|
|
SideTab->installEventFilter(this);
|
|
|
|
if (Index < 0)
|
|
|
|
{
|
|
|
|
d->TabsLayout->insertWidget(d->TabsLayout->count() - 1, SideTab);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
d->TabsLayout->insertWidget(Index, SideTab);
|
|
|
|
}
|
2022-10-26 15:50:16 +08:00
|
|
|
show();
|
2022-09-05 17:29:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-27 19:25:40 +08:00
|
|
|
//============================================================================
|
2022-11-01 19:06:59 +08:00
|
|
|
CAutoHideDockContainer* CAutoHideSideBar::insertDockWidget(int Index, CDockWidget* DockWidget)
|
2022-10-27 19:25:40 +08:00
|
|
|
{
|
2022-10-28 22:28:23 +08:00
|
|
|
auto AutoHideContainer = new CAutoHideDockContainer(DockWidget, d->SideTabArea, d->ContainerWidget);
|
|
|
|
DockWidget->dockManager()->dockFocusController()->clearDockWidgetFocus(DockWidget);
|
2022-11-01 20:34:08 +08:00
|
|
|
auto Tab = AutoHideContainer->autoHideTab();
|
2022-11-02 21:29:23 +08:00
|
|
|
DockWidget->setSideTabWidget(Tab);
|
2022-11-01 20:34:08 +08:00
|
|
|
insertTab(Index, Tab);
|
2022-10-27 19:25:40 +08:00
|
|
|
return AutoHideContainer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-15 21:16:01 +08:00
|
|
|
//============================================================================
|
|
|
|
void CAutoHideSideBar::removeAutoHideWidget(CAutoHideDockContainer* AutoHideWidget)
|
|
|
|
{
|
|
|
|
AutoHideWidget->autoHideTab()->removeFromSideBar();
|
|
|
|
auto DockContainer = AutoHideWidget->dockContainer();
|
|
|
|
if (DockContainer)
|
|
|
|
{
|
|
|
|
DockContainer->removeAutoHideWidget(AutoHideWidget);
|
|
|
|
}
|
|
|
|
AutoHideWidget->setParent(nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
2023-07-12 16:42:24 +08:00
|
|
|
void CAutoHideSideBar::addAutoHideWidget(CAutoHideDockContainer* AutoHideWidget,
|
|
|
|
int Index)
|
2022-11-15 21:16:01 +08:00
|
|
|
{
|
|
|
|
auto SideBar = AutoHideWidget->autoHideTab()->sideBar();
|
2022-11-15 22:08:52 +08:00
|
|
|
if (SideBar == this)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-11-15 21:16:01 +08:00
|
|
|
if (SideBar)
|
|
|
|
{
|
|
|
|
SideBar->removeAutoHideWidget(AutoHideWidget);
|
|
|
|
}
|
|
|
|
AutoHideWidget->setParent(d->ContainerWidget);
|
2022-11-15 22:08:52 +08:00
|
|
|
AutoHideWidget->setSideBarLocation(d->SideTabArea);
|
2022-11-15 21:16:01 +08:00
|
|
|
d->ContainerWidget->registerAutoHideWidget(AutoHideWidget);
|
2023-07-12 16:42:24 +08:00
|
|
|
insertTab(Index, AutoHideWidget->autoHideTab());
|
2022-11-15 21:16:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-27 19:25:40 +08:00
|
|
|
//============================================================================
|
2022-11-01 20:34:08 +08:00
|
|
|
void CAutoHideSideBar::removeTab(CAutoHideTab* SideTab)
|
2022-09-05 17:29:42 +08:00
|
|
|
{
|
2022-10-28 17:11:35 +08:00
|
|
|
SideTab->removeEventFilter(this);
|
2022-09-05 17:29:42 +08:00
|
|
|
d->TabsLayout->removeWidget(SideTab);
|
2022-10-26 15:50:16 +08:00
|
|
|
if (d->TabsLayout->isEmpty())
|
|
|
|
{
|
|
|
|
hide();
|
|
|
|
}
|
2022-09-05 17:29:42 +08:00
|
|
|
}
|
2022-09-14 14:17:28 +08:00
|
|
|
|
2022-09-14 14:25:11 +08:00
|
|
|
|
2022-10-28 17:11:35 +08:00
|
|
|
//============================================================================
|
2022-11-01 19:06:59 +08:00
|
|
|
bool CAutoHideSideBar::eventFilter(QObject *watched, QEvent *event)
|
2022-10-28 17:11:35 +08:00
|
|
|
{
|
2023-06-22 20:45:29 +08:00
|
|
|
auto Tab = qobject_cast<CAutoHideTab*>(watched);
|
|
|
|
if (!Tab)
|
2022-10-28 17:11:35 +08:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-06-22 20:45:29 +08:00
|
|
|
switch (event->type())
|
2022-10-28 17:11:35 +08:00
|
|
|
{
|
2023-06-22 20:45:29 +08:00
|
|
|
case QEvent::ShowToParent:
|
|
|
|
show();
|
|
|
|
break;
|
|
|
|
|
2023-06-23 15:15:24 +08:00
|
|
|
case QEvent::HideToParent:
|
2023-06-22 20:45:29 +08:00
|
|
|
if (!hasVisibleTabs())
|
|
|
|
{
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2022-10-28 17:11:35 +08:00
|
|
|
}
|
2023-06-22 20:45:29 +08:00
|
|
|
|
2022-10-28 17:11:35 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-06-22 20:45:29 +08:00
|
|
|
|
2022-09-14 14:25:11 +08:00
|
|
|
//============================================================================
|
2022-11-01 19:06:59 +08:00
|
|
|
Qt::Orientation CAutoHideSideBar::orientation() const
|
2022-09-14 14:25:11 +08:00
|
|
|
{
|
|
|
|
return d->Orientation;
|
|
|
|
}
|
2022-09-14 17:39:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2023-07-12 16:42:24 +08:00
|
|
|
CAutoHideTab* CAutoHideSideBar::tab(int index) const
|
2022-09-14 17:39:57 +08:00
|
|
|
{
|
2022-11-01 19:06:59 +08:00
|
|
|
return qobject_cast<CAutoHideTab*>(d->TabsLayout->itemAt(index)->widget());
|
2022-09-14 17:39:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2023-07-12 16:42:24 +08:00
|
|
|
int CAutoHideSideBar::count() const
|
2022-09-14 17:39:57 +08:00
|
|
|
{
|
2022-11-03 18:34:04 +08:00
|
|
|
return d->TabsLayout->count() - 1;
|
2022-09-14 17:39:57 +08:00
|
|
|
}
|
2022-10-26 15:50:16 +08:00
|
|
|
|
|
|
|
|
2023-06-22 20:45:29 +08:00
|
|
|
//============================================================================
|
|
|
|
int CAutoHideSideBar::visibleTabCount() const
|
|
|
|
{
|
2023-07-12 16:42:24 +08:00
|
|
|
int VisibleTabCount = 0;
|
2023-06-23 16:21:08 +08:00
|
|
|
auto ParentWidget = parentWidget();
|
2023-07-12 16:42:24 +08:00
|
|
|
for (auto i = 0; i < count(); i++)
|
2023-06-22 20:45:29 +08:00
|
|
|
{
|
2023-07-12 16:42:24 +08:00
|
|
|
if (tab(i)->isVisibleTo(ParentWidget))
|
2023-06-22 20:45:29 +08:00
|
|
|
{
|
2023-07-12 16:42:24 +08:00
|
|
|
VisibleTabCount++;
|
2023-06-22 20:45:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-12 16:42:24 +08:00
|
|
|
return VisibleTabCount;
|
2023-06-22 20:45:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
bool CAutoHideSideBar::hasVisibleTabs() const
|
|
|
|
{
|
2023-06-23 16:21:08 +08:00
|
|
|
auto ParentWidget = parentWidget();
|
2023-07-12 16:42:24 +08:00
|
|
|
for (auto i = 0; i < count(); i++)
|
2023-06-22 20:45:29 +08:00
|
|
|
{
|
2023-07-12 16:42:24 +08:00
|
|
|
if (tab(i)->isVisibleTo(ParentWidget))
|
2023-06-22 20:45:29 +08:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-26 15:50:16 +08:00
|
|
|
//============================================================================
|
2022-11-01 20:34:08 +08:00
|
|
|
SideBarLocation CAutoHideSideBar::sideBarLocation() const
|
2022-10-26 15:50:16 +08:00
|
|
|
{
|
|
|
|
return d->SideTabArea;
|
|
|
|
}
|
2022-10-28 17:11:35 +08:00
|
|
|
|
2022-10-31 02:44:33 +08:00
|
|
|
|
|
|
|
//============================================================================
|
2022-11-01 19:06:59 +08:00
|
|
|
void CAutoHideSideBar::saveState(QXmlStreamWriter& s) const
|
2022-10-31 02:44:33 +08:00
|
|
|
{
|
2023-07-12 16:42:24 +08:00
|
|
|
if (!count())
|
2022-10-31 02:44:33 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
s.writeStartElement("SideBar");
|
2022-11-01 20:34:08 +08:00
|
|
|
s.writeAttribute("Area", QString::number(sideBarLocation()));
|
2023-07-12 16:42:24 +08:00
|
|
|
s.writeAttribute("Tabs", QString::number(count()));
|
2022-10-31 02:44:33 +08:00
|
|
|
|
2023-07-12 16:42:24 +08:00
|
|
|
for (auto i = 0; i < count(); ++i)
|
2022-10-31 02:44:33 +08:00
|
|
|
{
|
2023-07-12 16:42:24 +08:00
|
|
|
auto Tab = tab(i);
|
2022-10-31 02:44:33 +08:00
|
|
|
if (!Tab)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-11-01 18:02:01 +08:00
|
|
|
Tab->dockWidget()->autoHideDockContainer()->saveState(s);
|
2022-10-31 02:44:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
s.writeEndElement();
|
|
|
|
}
|
2022-11-01 18:02:01 +08:00
|
|
|
|
2022-11-03 18:34:04 +08:00
|
|
|
//===========================================================================
|
|
|
|
QSize CAutoHideSideBar::minimumSizeHint() const
|
|
|
|
{
|
|
|
|
QSize Size = sizeHint();
|
|
|
|
Size.setWidth(10);
|
|
|
|
return Size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
QSize CAutoHideSideBar::sizeHint() const
|
|
|
|
{
|
|
|
|
return d->TabsContainerWidget->sizeHint();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
int CAutoHideSideBar::spacing() const
|
|
|
|
{
|
|
|
|
return d->TabsLayout->spacing();
|
|
|
|
}
|
|
|
|
|
2022-12-09 15:50:41 +08:00
|
|
|
|
2022-11-03 18:34:04 +08:00
|
|
|
//===========================================================================
|
|
|
|
void CAutoHideSideBar::setSpacing(int Spacing)
|
|
|
|
{
|
|
|
|
d->TabsLayout->setSpacing(Spacing);
|
|
|
|
}
|
2022-11-01 18:02:01 +08:00
|
|
|
|
2022-12-09 15:50:41 +08:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
CDockContainerWidget* CAutoHideSideBar::dockContainer() const
|
|
|
|
{
|
|
|
|
return d->ContainerWidget;
|
|
|
|
}
|
|
|
|
|
2023-07-12 16:42:24 +08:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
int CAutoHideSideBar::tabAt(const QPoint& Pos) const
|
|
|
|
{
|
|
|
|
if (!isVisible())
|
|
|
|
{
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Pos.x() < tab(0)->geometry().x())
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < count(); ++i)
|
|
|
|
{
|
|
|
|
if (tab(i)->geometry().contains(Pos))
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
int CAutoHideSideBar::tabInsertIndexAt(const QPoint& Pos) const
|
|
|
|
{
|
|
|
|
int Index = tabAt(Pos);
|
|
|
|
return (Index < 0) ? -1 : Index;
|
|
|
|
}
|
|
|
|
|
2022-11-01 18:02:01 +08:00
|
|
|
} // namespace ads
|
2022-11-03 18:34:04 +08:00
|
|
|
|