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 CDockWidgetSideTab class
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
// INCLUDES
|
|
|
|
//============================================================================
|
2022-10-12 17:17:54 +08:00
|
|
|
#include <AutoHideDockContainer.h>
|
2022-09-05 17:29:42 +08:00
|
|
|
#include "DockWidgetSideTab.h"
|
|
|
|
#include "SideTabBar.h"
|
|
|
|
|
|
|
|
#include <QBoxLayout>
|
|
|
|
|
2022-09-08 11:30:56 +08:00
|
|
|
#include "DockAreaWidget.h"
|
2022-09-12 15:55:45 +08:00
|
|
|
#include "DockManager.h"
|
2022-09-05 17:29:42 +08:00
|
|
|
|
|
|
|
#include "DockWidget.h"
|
|
|
|
|
|
|
|
namespace ads
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Private data class of CDockWidgetTab class (pimpl)
|
|
|
|
*/
|
|
|
|
struct DockWidgetSideTabPrivate
|
|
|
|
{
|
|
|
|
CDockWidgetSideTab* _this;
|
|
|
|
CDockWidget* DockWidget;
|
2022-10-28 21:20:56 +08:00
|
|
|
CSideTabBar* SideTabBar = nullptr;
|
2022-09-13 10:42:58 +08:00
|
|
|
Qt::Orientation Orientation{Qt::Vertical};
|
2022-09-05 17:29:42 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Private data constructor
|
|
|
|
*/
|
|
|
|
DockWidgetSideTabPrivate(CDockWidgetSideTab* _public);
|
2022-09-12 15:55:45 +08:00
|
|
|
}; // struct DockWidgetTabPrivate
|
2022-09-05 17:29:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
DockWidgetSideTabPrivate::DockWidgetSideTabPrivate(CDockWidgetSideTab* _public) :
|
|
|
|
_this(_public)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CDockWidgetSideTab::setSideTabBar(CSideTabBar* SideTabBar)
|
|
|
|
{
|
|
|
|
d->SideTabBar = SideTabBar;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CDockWidgetSideTab::removeFromSideTabBar()
|
|
|
|
{
|
|
|
|
if (d->SideTabBar == nullptr)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
d->SideTabBar->removeSideTab(this);
|
|
|
|
setSideTabBar(nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
CDockWidgetSideTab::CDockWidgetSideTab(CDockWidget* DockWidget, QWidget* parent) :
|
2022-10-18 22:43:39 +08:00
|
|
|
Super(parent),
|
2022-09-05 17:29:42 +08:00
|
|
|
d(new DockWidgetSideTabPrivate(this))
|
|
|
|
{
|
|
|
|
setAttribute(Qt::WA_NoMousePropagation);
|
|
|
|
d->DockWidget = DockWidget;
|
2022-10-18 22:43:39 +08:00
|
|
|
setText(DockWidget->windowTitle());
|
2022-09-05 17:29:42 +08:00
|
|
|
setFocusPolicy(Qt::NoFocus);
|
|
|
|
}
|
|
|
|
|
2022-09-12 15:55:45 +08:00
|
|
|
|
2022-09-05 17:29:42 +08:00
|
|
|
//============================================================================
|
|
|
|
CDockWidgetSideTab::~CDockWidgetSideTab()
|
|
|
|
{
|
2022-10-27 16:22:28 +08:00
|
|
|
qDebug() << "~CDockWidgetSideTab()";
|
2022-09-05 17:29:42 +08:00
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
2022-09-12 15:55:45 +08:00
|
|
|
|
2022-09-05 17:29:42 +08:00
|
|
|
//============================================================================
|
|
|
|
void CDockWidgetSideTab::updateStyle()
|
|
|
|
{
|
2022-10-28 21:20:56 +08:00
|
|
|
internal::repolishStyle(this, internal::RepolishDirectChildren);
|
2022-10-25 21:51:38 +08:00
|
|
|
update();
|
2022-09-05 17:29:42 +08:00
|
|
|
}
|
2022-09-08 11:30:56 +08:00
|
|
|
|
2022-09-12 15:55:45 +08:00
|
|
|
|
|
|
|
//============================================================================
|
2022-10-27 16:22:28 +08:00
|
|
|
SideBarLocation CDockWidgetSideTab::sideTabBarArea() const
|
2022-09-08 11:30:56 +08:00
|
|
|
{
|
2022-10-28 21:20:56 +08:00
|
|
|
if (d->SideTabBar)
|
2022-09-08 11:30:56 +08:00
|
|
|
{
|
2022-10-28 21:20:56 +08:00
|
|
|
qDebug() << "CDockWidgetSideTab::sideTabBarArea() " << d->SideTabBar->sideTabBarArea();
|
|
|
|
return d->SideTabBar->sideTabBarArea();
|
2022-09-08 11:30:56 +08:00
|
|
|
}
|
|
|
|
|
2022-10-17 17:34:59 +08:00
|
|
|
return Left;
|
2022-09-08 11:30:56 +08:00
|
|
|
}
|
2022-09-12 15:55:45 +08:00
|
|
|
|
2022-10-26 15:51:37 +08:00
|
|
|
|
2022-09-12 15:55:45 +08:00
|
|
|
//============================================================================
|
2022-09-13 10:42:58 +08:00
|
|
|
void CDockWidgetSideTab::setOrientation(Qt::Orientation Orientation)
|
|
|
|
{
|
|
|
|
d->Orientation = Orientation;
|
2022-10-26 15:51:37 +08:00
|
|
|
CPushButton::setButtonOrientation((Qt::Horizontal == Orientation)
|
2022-10-18 22:43:39 +08:00
|
|
|
? CPushButton::Horizontal : CPushButton::VerticalTopToBottom);
|
2022-09-13 14:21:01 +08:00
|
|
|
updateStyle();
|
2022-09-13 10:42:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-26 15:51:37 +08:00
|
|
|
//============================================================================
|
|
|
|
Qt::Orientation CDockWidgetSideTab::orientation() const
|
|
|
|
{
|
|
|
|
return d->Orientation;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-13 10:42:58 +08:00
|
|
|
//============================================================================
|
2022-10-28 19:19:38 +08:00
|
|
|
void CDockWidgetSideTab::updateOrientationForArea(SideBarLocation area)
|
2022-09-12 15:55:45 +08:00
|
|
|
{
|
2022-10-14 21:13:32 +08:00
|
|
|
setOrientation((area == Bottom || area == Top) ? Qt::Horizontal : Qt::Vertical);
|
2022-09-13 10:42:58 +08:00
|
|
|
|
2022-10-19 17:35:36 +08:00
|
|
|
if (icon().isNull())
|
2022-09-12 15:55:45 +08:00
|
|
|
{
|
2022-10-19 17:35:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-10-28 21:52:52 +08:00
|
|
|
bool IconOnly = false;
|
|
|
|
switch (area)
|
2022-10-19 17:35:36 +08:00
|
|
|
{
|
2022-10-28 21:52:52 +08:00
|
|
|
case SideBarLocation::Left:
|
|
|
|
IconOnly = CDockManager::testConfigFlag(CDockManager::LeftSideBarIconOnly);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SideBarLocation::Right:
|
|
|
|
IconOnly = CDockManager::testConfigFlag(CDockManager::RightSideBarIconOnly);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SideBarLocation::Top:
|
|
|
|
IconOnly = CDockManager::testConfigFlag(CDockManager::BottomSideBarIconOnly);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SideBarLocation::Bottom:
|
|
|
|
IconOnly = CDockManager::testConfigFlag(CDockManager::TopSideBarIconOnly);
|
|
|
|
break;
|
2022-10-14 21:13:32 +08:00
|
|
|
}
|
2022-10-28 21:52:52 +08:00
|
|
|
|
|
|
|
if (IconOnly)
|
2022-09-13 14:16:12 +08:00
|
|
|
{
|
2022-10-19 17:35:36 +08:00
|
|
|
setText("");
|
|
|
|
setOrientation(Qt::Horizontal);
|
|
|
|
}
|
2022-09-12 15:55:45 +08:00
|
|
|
}
|
|
|
|
|
2022-09-14 17:39:57 +08:00
|
|
|
|
2022-10-14 21:32:05 +08:00
|
|
|
//============================================================================
|
|
|
|
bool CDockWidgetSideTab::isActiveTab() const
|
|
|
|
{
|
|
|
|
if (d->DockWidget->autoHideDockContainer())
|
|
|
|
{
|
|
|
|
return d->DockWidget->autoHideDockContainer()->isVisible();
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-14 17:39:57 +08:00
|
|
|
//============================================================================
|
|
|
|
CDockWidget* CDockWidgetSideTab::dockWidget() const
|
|
|
|
{
|
|
|
|
return d->DockWidget;
|
|
|
|
}
|
|
|
|
|
2022-09-05 17:29:42 +08:00
|
|
|
}
|