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/>.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
/// \file DockWidgetTab.h
|
|
|
|
/// \author Syarif Fakhri
|
|
|
|
/// \date 05.09.2022
|
|
|
|
/// \brief Implementation of CSideTabBar class
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
// INCLUDES
|
|
|
|
//============================================================================
|
|
|
|
#include "SideTabBar.h"
|
|
|
|
#include "DockContainerWidget.h"
|
|
|
|
#include "DockWidgetSideTab.h"
|
|
|
|
#include "DockWidgetTab.h"
|
|
|
|
|
|
|
|
#include <QBoxLayout>
|
2022-09-14 14:17:28 +08:00
|
|
|
#include <QStyleOption>
|
|
|
|
#include <QPainter>
|
2022-09-05 17:29:42 +08:00
|
|
|
|
|
|
|
namespace ads
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Private data class of CSideTabBar class (pimpl)
|
|
|
|
*/
|
|
|
|
struct SideTabBarPrivate
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Private data constructor
|
|
|
|
*/
|
|
|
|
SideTabBarPrivate(CSideTabBar* _public);
|
|
|
|
|
|
|
|
CSideTabBar* _this;
|
|
|
|
CDockContainerWidget* ContainerWidget;
|
|
|
|
QBoxLayout* TabsLayout;
|
2022-09-13 10:42:58 +08:00
|
|
|
Qt::Orientation Orientation;
|
2022-09-05 17:29:42 +08:00
|
|
|
}; // struct SideTabBarPrivate
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
SideTabBarPrivate::SideTabBarPrivate(CSideTabBar* _public) :
|
|
|
|
_this(_public)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2022-09-13 10:42:58 +08:00
|
|
|
CSideTabBar::CSideTabBar(CDockContainerWidget* parent, Qt::Orientation orientation) :
|
2022-09-05 17:29:42 +08:00
|
|
|
QWidget(parent),
|
|
|
|
d(new SideTabBarPrivate(this))
|
|
|
|
{
|
|
|
|
d->ContainerWidget = parent;
|
2022-09-13 10:42:58 +08:00
|
|
|
d->Orientation = orientation;
|
2022-09-05 17:29:42 +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);
|
|
|
|
d->TabsLayout->setSpacing(0);
|
|
|
|
d->TabsLayout->addStretch(1);
|
|
|
|
setLayout(d->TabsLayout);
|
|
|
|
|
|
|
|
setFocusPolicy(Qt::NoFocus);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
CSideTabBar::~CSideTabBar()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CSideTabBar::insertSideTab(int Index, CDockWidgetSideTab* SideTab)
|
|
|
|
{
|
|
|
|
d->TabsLayout->insertWidget(Index, SideTab);
|
|
|
|
SideTab->setSideTabBar(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CSideTabBar::removeSideTab(CDockWidgetSideTab* SideTab)
|
|
|
|
{
|
|
|
|
d->TabsLayout->removeWidget(SideTab);
|
|
|
|
}
|
2022-09-14 14:17:28 +08:00
|
|
|
|
2022-09-14 14:25:11 +08:00
|
|
|
|
2022-09-14 14:17:28 +08:00
|
|
|
//============================================================================
|
|
|
|
void CSideTabBar::paintEvent(QPaintEvent* event)
|
|
|
|
{
|
|
|
|
QStyleOption option;
|
|
|
|
option.initFrom(this);
|
|
|
|
QPainter painter(this);
|
|
|
|
style()->drawPrimitive(QStyle::PE_Widget, &option, &painter, this);
|
|
|
|
}
|
2022-09-14 14:25:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
Qt::Orientation CSideTabBar::orientation() const
|
|
|
|
{
|
|
|
|
return d->Orientation;
|
|
|
|
}
|
2022-09-05 17:29:42 +08:00
|
|
|
}
|