mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 15:41:34 +08:00
Some refactoring to improve code clarity, renamed DockWidgetTitleBar into DockWidgetTab because in the GUI it is a tab, created new class CDockAreaTabBar for the tabbar of a dock area
This commit is contained in:
parent
f5b3c0556d
commit
6b93ae9c39
@ -174,13 +174,15 @@ void MainWindowPrivate::createContent()
|
|||||||
QMenu* ViewMenu = ui.menuView;
|
QMenu* ViewMenu = ui.menuView;
|
||||||
auto DockWidget = createCalendarDockWidget(ViewMenu);
|
auto DockWidget = createCalendarDockWidget(ViewMenu);
|
||||||
DockWidget->setIcon(_this->style()->standardIcon(QStyle::SP_DialogOpenButton));
|
DockWidget->setIcon(_this->style()->standardIcon(QStyle::SP_DialogOpenButton));
|
||||||
DockWidget->setFeatures(DockWidget->features().setFlag(ads::CDockWidget::DockWidgetClosable, false));
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
|
||||||
DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
|
DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
|
||||||
DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu));
|
DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu));
|
||||||
DockManager->addDockWidget(ads::BottomDockWidgetArea, createFileSystemTreeDockWidget(ViewMenu));
|
DockManager->addDockWidget(ads::BottomDockWidgetArea, createFileSystemTreeDockWidget(ViewMenu));
|
||||||
auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, createFileSystemTreeDockWidget(ViewMenu));
|
auto FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu);
|
||||||
|
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetMovable, false);
|
||||||
|
auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget);
|
||||||
DockWidget = createCalendarDockWidget(ViewMenu);
|
DockWidget = createCalendarDockWidget(ViewMenu);
|
||||||
DockWidget->setFeatures(DockWidget->features().setFlag(ads::CDockWidget::DockWidgetClosable, false));
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
|
||||||
DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
|
DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
|
||||||
|
|
||||||
// Test dock area docking
|
// Test dock area docking
|
||||||
|
173
src/DockAreaTabBar.cpp
Normal file
173
src/DockAreaTabBar.cpp
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
//============================================================================
|
||||||
|
/// \file DockAreaTabBar.cpp
|
||||||
|
/// \author Uwe Kindler
|
||||||
|
/// \date 24.08.2018
|
||||||
|
/// \brief Implementation of CDockAreaTabBar class
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// INCLUDES
|
||||||
|
//============================================================================
|
||||||
|
#include "DockAreaTabBar.h"
|
||||||
|
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QScrollBar>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "FloatingDockContainer.h"
|
||||||
|
#include "DockAreaWidget.h"
|
||||||
|
#include "DockOverlay.h"
|
||||||
|
#include "DockManager.h"
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Private data class of CDockAreaTabBar class (pimpl)
|
||||||
|
*/
|
||||||
|
struct DockAreaTabBarPrivate
|
||||||
|
{
|
||||||
|
CDockAreaTabBar* _this;
|
||||||
|
QPoint DragStartMousePos;
|
||||||
|
CDockAreaWidget* DockArea;
|
||||||
|
CFloatingDockContainer* FloatingWidget = nullptr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data constructor
|
||||||
|
*/
|
||||||
|
DockAreaTabBarPrivate(CDockAreaTabBar* _public);
|
||||||
|
};
|
||||||
|
// struct DockAreaTabBarPrivate
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
DockAreaTabBarPrivate::DockAreaTabBarPrivate(CDockAreaTabBar* _public) :
|
||||||
|
_this(_public)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CDockAreaTabBar::CDockAreaTabBar(CDockAreaWidget* parent) :
|
||||||
|
QScrollArea(parent),
|
||||||
|
d(new DockAreaTabBarPrivate(this))
|
||||||
|
{
|
||||||
|
d->DockArea = parent;
|
||||||
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored);
|
||||||
|
setFrameStyle(QFrame::NoFrame);
|
||||||
|
setWidgetResizable(true);
|
||||||
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CDockAreaTabBar::~CDockAreaTabBar()
|
||||||
|
{
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockAreaTabBar::wheelEvent(QWheelEvent* Event)
|
||||||
|
{
|
||||||
|
Event->accept();
|
||||||
|
const int direction = Event->angleDelta().y();
|
||||||
|
if (direction < 0)
|
||||||
|
{
|
||||||
|
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 20);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
horizontalScrollBar()->setValue(horizontalScrollBar()->value() - 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockAreaTabBar::mousePressEvent(QMouseEvent* ev)
|
||||||
|
{
|
||||||
|
if (ev->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
ev->accept();
|
||||||
|
d->DragStartMousePos = ev->pos();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QScrollArea::mousePressEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockAreaTabBar::mouseReleaseEvent(QMouseEvent* ev)
|
||||||
|
{
|
||||||
|
if (ev->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
qDebug() << "CTabsScrollArea::mouseReleaseEvent";
|
||||||
|
ev->accept();
|
||||||
|
d->FloatingWidget = nullptr;
|
||||||
|
d->DragStartMousePos = QPoint();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QScrollArea::mouseReleaseEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
|
||||||
|
{
|
||||||
|
QScrollArea::mouseMoveEvent(ev);
|
||||||
|
if (ev->buttons() != Qt::LeftButton)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d->FloatingWidget)
|
||||||
|
{
|
||||||
|
d->FloatingWidget->moveFloating();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this is the last dock area in a dock container it does not make
|
||||||
|
// sense to move it to a new floating widget and leave this one
|
||||||
|
// empty
|
||||||
|
if (d->DockArea->dockContainer()->isFloating()
|
||||||
|
&& d->DockArea->dockContainer()->visibleDockAreaCount() == 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this->geometry().contains(ev->pos()))
|
||||||
|
{
|
||||||
|
qDebug() << "CTabsScrollArea::startFloating";
|
||||||
|
startFloating(d->DragStartMousePos);
|
||||||
|
auto Overlay = d->DockArea->dockManager()->containerOverlay();
|
||||||
|
Overlay->setAllowedAreas(OuterDockAreas);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockAreaTabBar::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
// If this is the last dock area in a dock container it does not make
|
||||||
|
// sense to move it to a new floating widget and leave this one
|
||||||
|
// empty
|
||||||
|
if (d->DockArea->dockContainer()->isFloating() && d->DockArea->dockContainer()->dockAreaCount() == 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
startFloating(event->pos());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockAreaTabBar::startFloating(const QPoint& Pos)
|
||||||
|
{
|
||||||
|
QSize Size = d->DockArea->size();
|
||||||
|
CFloatingDockContainer* FloatingWidget = new CFloatingDockContainer(d->DockArea);
|
||||||
|
FloatingWidget->startFloating(Pos, Size);
|
||||||
|
d->FloatingWidget = FloatingWidget;
|
||||||
|
}
|
||||||
|
} // namespace ads
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// EOF DockAreaTabBar.cpp
|
74
src/DockAreaTabBar.h
Normal file
74
src/DockAreaTabBar.h
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#ifndef DockAreaTabBarH
|
||||||
|
#define DockAreaTabBarH
|
||||||
|
//============================================================================
|
||||||
|
/// \file DockAreaTabBar.h
|
||||||
|
/// \author Uwe Kindler
|
||||||
|
/// \date 24.08.2018
|
||||||
|
/// \brief Declaration of CDockAreaTabBar class
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// INCLUDES
|
||||||
|
//============================================================================
|
||||||
|
#include <QScrollArea>
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
class CDockAreaWidget;
|
||||||
|
struct DockAreaTabBarPrivate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom scroll bar implementation for dock area tab bar
|
||||||
|
* This scroll area enables floating of a whole dock area including all
|
||||||
|
* dock widgets
|
||||||
|
*/
|
||||||
|
class CDockAreaTabBar : public QScrollArea
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
DockAreaTabBarPrivate* d; ///< private data (pimpl)
|
||||||
|
friend class DockAreaTabBarPrivate;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void wheelEvent(QWheelEvent* Event) override;
|
||||||
|
/**
|
||||||
|
* Stores mouse position to detect dragging
|
||||||
|
*/
|
||||||
|
virtual void mousePressEvent(QMouseEvent* ev) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores mouse position to detect dragging
|
||||||
|
*/
|
||||||
|
virtual void mouseReleaseEvent(QMouseEvent* ev) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts floating the complete docking area including all dock widgets,
|
||||||
|
* if it is not the last dock area in a floating widget
|
||||||
|
*/
|
||||||
|
virtual void mouseMoveEvent(QMouseEvent* ev) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Double clicking the title bar also starts floating of the complete area
|
||||||
|
*/
|
||||||
|
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts floating
|
||||||
|
*/
|
||||||
|
void startFloating(const QPoint& Pos);
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Default Constructor
|
||||||
|
*/
|
||||||
|
CDockAreaTabBar(CDockAreaWidget* parent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtual Destructor
|
||||||
|
*/
|
||||||
|
virtual ~CDockAreaTabBar();
|
||||||
|
}; // class CDockAreaTabBar
|
||||||
|
} // namespace ads
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#endif // DockAreaTabBarH
|
||||||
|
|
@ -28,6 +28,7 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
#include <DockWidgetTab.h>
|
||||||
#include "DockAreaWidget.h"
|
#include "DockAreaWidget.h"
|
||||||
|
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
@ -44,10 +45,10 @@
|
|||||||
|
|
||||||
#include "DockContainerWidget.h"
|
#include "DockContainerWidget.h"
|
||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
#include "DockWidgetTitleBar.h"
|
|
||||||
#include "FloatingDockContainer.h"
|
#include "FloatingDockContainer.h"
|
||||||
#include "DockManager.h"
|
#include "DockManager.h"
|
||||||
#include "DockOverlay.h"
|
#include "DockOverlay.h"
|
||||||
|
#include "DockAreaTabBar.h"
|
||||||
|
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
@ -56,140 +57,6 @@ static const char* const INDEX_PROPERTY = "index";
|
|||||||
static const char* const ACTION_PROPERTY = "action";
|
static const char* const ACTION_PROPERTY = "action";
|
||||||
static const int APPEND = -1;
|
static const int APPEND = -1;
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom scroll bar implementation for dock area tab bar
|
|
||||||
* This scroll area enables floating of a whole dock area including all
|
|
||||||
* dock widgets
|
|
||||||
*/
|
|
||||||
class CTabsScrollArea : public QScrollArea
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
QPoint m_DragStartMousePos;
|
|
||||||
CDockAreaWidget* m_DockArea;
|
|
||||||
CFloatingDockContainer* m_FloatingWidget = nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
CTabsScrollArea(CDockAreaWidget* parent)
|
|
||||||
: QScrollArea(parent),
|
|
||||||
m_DockArea(parent)
|
|
||||||
{
|
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored);
|
|
||||||
setFrameStyle(QFrame::NoFrame);
|
|
||||||
setWidgetResizable(true);
|
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void wheelEvent(QWheelEvent* Event) override
|
|
||||||
{
|
|
||||||
Event->accept();
|
|
||||||
const int direction = Event->angleDelta().y();
|
|
||||||
if (direction < 0)
|
|
||||||
{
|
|
||||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 20);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value() - 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores mouse position to detect dragging
|
|
||||||
*/
|
|
||||||
virtual void mousePressEvent(QMouseEvent* ev) override
|
|
||||||
{
|
|
||||||
if (ev->button() == Qt::LeftButton)
|
|
||||||
{
|
|
||||||
ev->accept();
|
|
||||||
m_DragStartMousePos = ev->pos();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QScrollArea::mousePressEvent(ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores mouse position to detect dragging
|
|
||||||
*/
|
|
||||||
virtual void mouseReleaseEvent(QMouseEvent* ev) override
|
|
||||||
{
|
|
||||||
if (ev->button() == Qt::LeftButton)
|
|
||||||
{
|
|
||||||
qDebug() << "CTabsScrollArea::mouseReleaseEvent";
|
|
||||||
ev->accept();
|
|
||||||
m_FloatingWidget = nullptr;
|
|
||||||
m_DragStartMousePos = QPoint();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QScrollArea::mouseReleaseEvent(ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts floating the complete docking area including all dock widgets,
|
|
||||||
* if it is not the last dock area in a floating widget
|
|
||||||
*/
|
|
||||||
virtual void mouseMoveEvent(QMouseEvent* ev) override
|
|
||||||
{
|
|
||||||
QScrollArea::mouseMoveEvent(ev);
|
|
||||||
if (ev->buttons() != Qt::LeftButton)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_FloatingWidget)
|
|
||||||
{
|
|
||||||
m_FloatingWidget->moveFloating();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this is the last dock area in a dock container it does not make
|
|
||||||
// sense to move it to a new floating widget and leave this one
|
|
||||||
// empty
|
|
||||||
if (m_DockArea->dockContainer()->isFloating()
|
|
||||||
&& m_DockArea->dockContainer()->visibleDockAreaCount() == 1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this->geometry().contains(ev->pos()))
|
|
||||||
{
|
|
||||||
qDebug() << "CTabsScrollArea::startFloating";
|
|
||||||
startFloating(m_DragStartMousePos);
|
|
||||||
auto Overlay = m_DockArea->dockManager()->containerOverlay();
|
|
||||||
Overlay->setAllowedAreas(OuterDockAreas);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Double clicking the title bar also starts floating of the complete area
|
|
||||||
*/
|
|
||||||
virtual void mouseDoubleClickEvent(QMouseEvent *event) override
|
|
||||||
{
|
|
||||||
// If this is the last dock area in a dock container it does not make
|
|
||||||
// sense to move it to a new floating widget and leave this one
|
|
||||||
// empty
|
|
||||||
if (m_DockArea->dockContainer()->isFloating() && m_DockArea->dockContainer()->dockAreaCount() == 1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
startFloating(event->pos());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts floating
|
|
||||||
*/
|
|
||||||
void startFloating(const QPoint& Pos)
|
|
||||||
{
|
|
||||||
QSize Size = m_DockArea->size();
|
|
||||||
CFloatingDockContainer* FloatingWidget = new CFloatingDockContainer(m_DockArea);
|
|
||||||
FloatingWidget->startFloating(Pos, Size);
|
|
||||||
m_FloatingWidget = FloatingWidget;
|
|
||||||
}
|
|
||||||
}; // class CTabsScrollArea
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data class of CDockAreaWidget class (pimpl)
|
* Private data class of CDockAreaWidget class (pimpl)
|
||||||
@ -201,7 +68,7 @@ struct DockAreaWidgetPrivate
|
|||||||
QFrame* TitleBar;
|
QFrame* TitleBar;
|
||||||
QBoxLayout* TopLayout;
|
QBoxLayout* TopLayout;
|
||||||
QStackedLayout* ContentsLayout;
|
QStackedLayout* ContentsLayout;
|
||||||
QScrollArea* TabsScrollArea;
|
CDockAreaTabBar* TabBar;
|
||||||
QWidget* TabsContainerWidget;
|
QWidget* TabsContainerWidget;
|
||||||
QBoxLayout* TabsLayout;
|
QBoxLayout* TabsLayout;
|
||||||
QPushButton* TabsMenuButton;
|
QPushButton* TabsMenuButton;
|
||||||
@ -230,7 +97,7 @@ struct DockAreaWidgetPrivate
|
|||||||
/**
|
/**
|
||||||
* Convenience function to ease title widget access by index
|
* Convenience function to ease title widget access by index
|
||||||
*/
|
*/
|
||||||
CDockWidgetTitleBar* titleWidgetAt(int index)
|
CDockWidgetTab* titleWidgetAt(int index)
|
||||||
{
|
{
|
||||||
return dockWidgetAt(index)->titleBar();
|
return dockWidgetAt(index)->titleBar();
|
||||||
}
|
}
|
||||||
@ -293,12 +160,12 @@ void DockAreaWidgetPrivate::createTabBar()
|
|||||||
TitleBar->setLayout(TopLayout);
|
TitleBar->setLayout(TopLayout);
|
||||||
Layout->addWidget(TitleBar);
|
Layout->addWidget(TitleBar);
|
||||||
|
|
||||||
TabsScrollArea = new CTabsScrollArea(_this);
|
TabBar = new CDockAreaTabBar(_this);
|
||||||
TopLayout->addWidget(TabsScrollArea, 1);
|
TopLayout->addWidget(TabBar, 1);
|
||||||
|
|
||||||
TabsContainerWidget = new QWidget();
|
TabsContainerWidget = new QWidget();
|
||||||
TabsContainerWidget->setObjectName("tabsContainerWidget");
|
TabsContainerWidget->setObjectName("tabsContainerWidget");
|
||||||
TabsScrollArea->setWidget(TabsContainerWidget);
|
TabBar->setWidget(TabsContainerWidget);
|
||||||
|
|
||||||
TabsLayout = new QBoxLayout(QBoxLayout::LeftToRight);
|
TabsLayout = new QBoxLayout(QBoxLayout::LeftToRight);
|
||||||
TabsLayout->setContentsMargins(0, 0, 0, 0);
|
TabsLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
@ -489,7 +356,7 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaWidget::onDockWidgetTitleClicked()
|
void CDockAreaWidget::onDockWidgetTitleClicked()
|
||||||
{
|
{
|
||||||
CDockWidgetTitleBar* TitleWidget = qobject_cast<CDockWidgetTitleBar*>(sender());
|
CDockWidgetTab* TitleWidget = qobject_cast<CDockWidgetTab*>(sender());
|
||||||
if (!TitleWidget)
|
if (!TitleWidget)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -546,7 +413,7 @@ void CDockAreaWidget::setCurrentIndex(int index)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto TitleWidget = dynamic_cast<CDockWidgetTitleBar*>(item->widget());
|
auto TitleWidget = dynamic_cast<CDockWidgetTab*>(item->widget());
|
||||||
if (!TitleWidget)
|
if (!TitleWidget)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@ -556,7 +423,7 @@ void CDockAreaWidget::setCurrentIndex(int index)
|
|||||||
{
|
{
|
||||||
TitleWidget->show();
|
TitleWidget->show();
|
||||||
TitleWidget->setActiveTab(true);
|
TitleWidget->setActiveTab(true);
|
||||||
d->TabsScrollArea->ensureWidgetVisible(TitleWidget);
|
d->TabBar->ensureWidgetVisible(TitleWidget);
|
||||||
auto Features = TitleWidget->dockWidget()->features();
|
auto Features = TitleWidget->dockWidget()->features();
|
||||||
d->CloseButton->setVisible(Features.testFlag(CDockWidget::DockWidgetClosable));
|
d->CloseButton->setVisible(Features.testFlag(CDockWidget::DockWidgetClosable));
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
#include <DockWidgetTab.h>
|
||||||
#include "DockManager.h"
|
#include "DockManager.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -49,7 +50,6 @@
|
|||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
#include "ads_globals.h"
|
#include "ads_globals.h"
|
||||||
#include "DockStateSerialization.h"
|
#include "DockStateSerialization.h"
|
||||||
#include "DockWidgetTitleBar.h"
|
|
||||||
#include "DockAreaWidget.h"
|
#include "DockAreaWidget.h"
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
@ -370,7 +370,6 @@ bool CDockManager::restoreState(const QByteArray &state, int version)
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit stateChanged();
|
emit stateChanged();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,9 @@ signals:
|
|||||||
void perspectiveListChanged();
|
void perspectiveListChanged();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This signal is emitted if the state changed in restoreState
|
* This signal is emitted if the state changed in restoreState.
|
||||||
|
* The signal is emitted if the restoreState() function is called or
|
||||||
|
* if the openPerspective() function is called
|
||||||
*/
|
*/
|
||||||
void stateChanged();
|
void stateChanged();
|
||||||
}; // class DockManager
|
}; // class DockManager
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
#include <DockWidgetTab.h>
|
||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
@ -40,7 +41,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
#include "DockWidgetTitleBar.h"
|
|
||||||
#include "DockContainerWidget.h"
|
#include "DockContainerWidget.h"
|
||||||
#include "DockAreaWidget.h"
|
#include "DockAreaWidget.h"
|
||||||
#include "DockManager.h"
|
#include "DockManager.h"
|
||||||
@ -59,7 +59,7 @@ struct DockWidgetPrivate
|
|||||||
CDockWidget* _this;
|
CDockWidget* _this;
|
||||||
QBoxLayout* Layout;
|
QBoxLayout* Layout;
|
||||||
QWidget* Widget = nullptr;
|
QWidget* Widget = nullptr;
|
||||||
CDockWidgetTitleBar* TitleWidget;
|
CDockWidgetTab* TitleWidget;
|
||||||
CDockWidget::DockWidgetFeatures Features = CDockWidget::AllDockWidgetFeatures;
|
CDockWidget::DockWidgetFeatures Features = CDockWidget::AllDockWidgetFeatures;
|
||||||
CDockManager* DockManager = nullptr;
|
CDockManager* DockManager = nullptr;
|
||||||
CDockAreaWidget* DockArea = nullptr;
|
CDockAreaWidget* DockArea = nullptr;
|
||||||
@ -212,7 +212,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
|
|||||||
setLayout(d->Layout);
|
setLayout(d->Layout);
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
|
|
||||||
d->TitleWidget = new CDockWidgetTitleBar(this);
|
d->TitleWidget = new CDockWidgetTab(this);
|
||||||
d->ToggleViewAction = new QAction(title);
|
d->ToggleViewAction = new QAction(title);
|
||||||
d->ToggleViewAction->setCheckable(true);
|
d->ToggleViewAction->setCheckable(true);
|
||||||
connect(d->ToggleViewAction, SIGNAL(triggered(bool)), this,
|
connect(d->ToggleViewAction, SIGNAL(triggered(bool)), this,
|
||||||
@ -261,7 +261,7 @@ QWidget* CDockWidget::widget() const
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidgetTitleBar* CDockWidget::titleBar() const
|
CDockWidgetTab* CDockWidget::titleBar() const
|
||||||
{
|
{
|
||||||
return d->TitleWidget;
|
return d->TitleWidget;
|
||||||
}
|
}
|
||||||
@ -274,6 +274,13 @@ void CDockWidget::setFeatures(DockWidgetFeatures features)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockWidget::setFeature(DockWidgetFeature flag, bool on)
|
||||||
|
{
|
||||||
|
d->Features.setFlag(flag, on);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidget::DockWidgetFeatures CDockWidget::features() const
|
CDockWidget::DockWidgetFeatures CDockWidget::features() const
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ class QXmlStreamWriter;
|
|||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
struct DockWidgetPrivate;
|
struct DockWidgetPrivate;
|
||||||
class CDockWidgetTitleBar;
|
class CDockWidgetTab;
|
||||||
class CDockManager;
|
class CDockManager;
|
||||||
class CDockContainerWidget;
|
class CDockContainerWidget;
|
||||||
class CDockAreaWidget;
|
class CDockAreaWidget;
|
||||||
@ -155,13 +155,19 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Returns the title bar widget of this dock widget
|
* Returns the title bar widget of this dock widget
|
||||||
*/
|
*/
|
||||||
CDockWidgetTitleBar* titleBar() const;
|
CDockWidgetTab* titleBar() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets, whether the dock widget is movable, closable, and floatable.
|
* Sets, whether the dock widget is movable, closable, and floatable.
|
||||||
*/
|
*/
|
||||||
void setFeatures(DockWidgetFeatures features);
|
void setFeatures(DockWidgetFeatures features);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the feature flag for this dock widget if on is true; otherwise
|
||||||
|
* clears the flag.
|
||||||
|
*/
|
||||||
|
void setFeature(DockWidgetFeature flag, bool on);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This property holds whether the dock widget is movable, closable, and
|
* This property holds whether the dock widget is movable, closable, and
|
||||||
* floatable.
|
* floatable.
|
||||||
|
@ -18,17 +18,17 @@
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
/// \file DockWidgetTitleBar.cpp
|
/// \file DockWidgetTab.cpp
|
||||||
/// \author Uwe Kindler
|
/// \author Uwe Kindler
|
||||||
/// \date 27.02.2017
|
/// \date 27.02.2017
|
||||||
/// \brief Implementation of CDockWidgetTitleBar class
|
/// \brief Implementation of CDockWidgetTab class
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
#include "DockWidgetTitleBar.h"
|
#include "DockWidgetTab.h"
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
@ -60,11 +60,11 @@ enum eDragState
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data class of CDockWidgetTitleBar class (pimpl)
|
* Private data class of CDockWidgetTab class (pimpl)
|
||||||
*/
|
*/
|
||||||
struct DockWidgetTitleBarPrivate
|
struct DockWidgetTabPrivate
|
||||||
{
|
{
|
||||||
CDockWidgetTitleBar* _this;
|
CDockWidgetTab* _this;
|
||||||
CDockWidget* DockWidget;
|
CDockWidget* DockWidget;
|
||||||
QLabel* IconLabel;
|
QLabel* IconLabel;
|
||||||
QLabel* TitleLabel;
|
QLabel* TitleLabel;
|
||||||
@ -78,7 +78,7 @@ struct DockWidgetTitleBarPrivate
|
|||||||
/**
|
/**
|
||||||
* Private data constructor
|
* Private data constructor
|
||||||
*/
|
*/
|
||||||
DockWidgetTitleBarPrivate(CDockWidgetTitleBar* _public);
|
DockWidgetTabPrivate(CDockWidgetTab* _public);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the complete layout including all controls
|
* Creates the complete layout including all controls
|
||||||
@ -115,11 +115,11 @@ struct DockWidgetTitleBarPrivate
|
|||||||
*/
|
*/
|
||||||
bool startFloating();
|
bool startFloating();
|
||||||
};
|
};
|
||||||
// struct DockWidgetTitleBarPrivate
|
// struct DockWidgetTabPrivate
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
DockWidgetTitleBarPrivate::DockWidgetTitleBarPrivate(CDockWidgetTitleBar* _public) :
|
DockWidgetTabPrivate::DockWidgetTabPrivate(CDockWidgetTab* _public) :
|
||||||
_this(_public)
|
_this(_public)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ DockWidgetTitleBarPrivate::DockWidgetTitleBarPrivate(CDockWidgetTitleBar* _publi
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void DockWidgetTitleBarPrivate::createLayout()
|
void DockWidgetTabPrivate::createLayout()
|
||||||
{
|
{
|
||||||
QBoxLayout* l = new QBoxLayout(QBoxLayout::LeftToRight);
|
QBoxLayout* l = new QBoxLayout(QBoxLayout::LeftToRight);
|
||||||
l->setContentsMargins(0, 0, 0, 0);
|
l->setContentsMargins(0, 0, 0, 0);
|
||||||
@ -146,7 +146,7 @@ void DockWidgetTitleBarPrivate::createLayout()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void DockWidgetTitleBarPrivate::moveTab(QMouseEvent* ev)
|
void DockWidgetTabPrivate::moveTab(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
ev->accept();
|
ev->accept();
|
||||||
int left, top, right, bottom;
|
int left, top, right, bottom;
|
||||||
@ -159,7 +159,7 @@ void DockWidgetTitleBarPrivate::moveTab(QMouseEvent* ev)
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool DockWidgetTitleBarPrivate::startFloating()
|
bool DockWidgetTabPrivate::startFloating()
|
||||||
{
|
{
|
||||||
qDebug() << "isFloating " << DockWidget->dockContainer()->isFloating();
|
qDebug() << "isFloating " << DockWidget->dockContainer()->isFloating();
|
||||||
qDebug() << "areaCount " << DockWidget->dockContainer()->dockAreaCount();
|
qDebug() << "areaCount " << DockWidget->dockContainer()->dockAreaCount();
|
||||||
@ -185,7 +185,7 @@ bool DockWidgetTitleBarPrivate::startFloating()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "DockWidgetTitleBarPrivate::startFloating DockArea";
|
qDebug() << "DockWidgetTabPrivate::startFloating DockArea";
|
||||||
// If section widget has only one content widget, we can move the complete
|
// If section widget has only one content widget, we can move the complete
|
||||||
// dock area into floating widget
|
// dock area into floating widget
|
||||||
FloatingWidget = new CFloatingDockContainer(DockArea);
|
FloatingWidget = new CFloatingDockContainer(DockArea);
|
||||||
@ -200,9 +200,9 @@ bool DockWidgetTitleBarPrivate::startFloating()
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidgetTitleBar::CDockWidgetTitleBar(CDockWidget* DockWidget, QWidget *parent) :
|
CDockWidgetTab::CDockWidgetTab(CDockWidget* DockWidget, QWidget *parent) :
|
||||||
QFrame(parent),
|
QFrame(parent),
|
||||||
d(new DockWidgetTitleBarPrivate(this))
|
d(new DockWidgetTabPrivate(this))
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_NoMousePropagation, true);
|
setAttribute(Qt::WA_NoMousePropagation, true);
|
||||||
d->DockWidget = DockWidget;
|
d->DockWidget = DockWidget;
|
||||||
@ -210,19 +210,19 @@ CDockWidgetTitleBar::CDockWidgetTitleBar(CDockWidget* DockWidget, QWidget *paren
|
|||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidgetTitleBar::~CDockWidgetTitleBar()
|
CDockWidgetTab::~CDockWidgetTab()
|
||||||
{
|
{
|
||||||
qDebug() << "~CDockWidgetTitleBar()";
|
qDebug() << "~CDockWidgetTab()";
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidgetTitleBar::mousePressEvent(QMouseEvent* ev)
|
void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
if (ev->button() == Qt::LeftButton)
|
if (ev->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
qDebug() << "CDockWidgetTitleBar::mousePressEvent";
|
qDebug() << "CDockWidgetTab::mousePressEvent";
|
||||||
ev->accept();
|
ev->accept();
|
||||||
d->DragStartMousePosition = ev->pos();
|
d->DragStartMousePosition = ev->pos();
|
||||||
d->DragState = DraggingMousePressed;
|
d->DragState = DraggingMousePressed;
|
||||||
@ -234,9 +234,9 @@ void CDockWidgetTitleBar::mousePressEvent(QMouseEvent* ev)
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidgetTitleBar::mouseReleaseEvent(QMouseEvent* ev)
|
void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
qDebug() << "CDockWidgetTitleBar::mouseReleaseEvent";
|
qDebug() << "CDockWidgetTab::mouseReleaseEvent";
|
||||||
// End of tab moving, change order now
|
// End of tab moving, change order now
|
||||||
if (d->isDraggingState(DraggingTab) && d->DockArea)
|
if (d->isDraggingState(DraggingTab) && d->DockArea)
|
||||||
{
|
{
|
||||||
@ -267,7 +267,7 @@ void CDockWidgetTitleBar::mouseReleaseEvent(QMouseEvent* ev)
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
|
void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
|
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
|
||||||
{
|
{
|
||||||
@ -315,14 +315,14 @@ void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CDockWidgetTitleBar::isActiveTab() const
|
bool CDockWidgetTab::isActiveTab() const
|
||||||
{
|
{
|
||||||
return d->IsActiveTab;
|
return d->IsActiveTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidgetTitleBar::setActiveTab(bool active)
|
void CDockWidgetTab::setActiveTab(bool active)
|
||||||
{
|
{
|
||||||
if (d->IsActiveTab == active)
|
if (d->IsActiveTab == active)
|
||||||
{
|
{
|
||||||
@ -341,28 +341,28 @@ void CDockWidgetTitleBar::setActiveTab(bool active)
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidget* CDockWidgetTitleBar::dockWidget() const
|
CDockWidget* CDockWidgetTab::dockWidget() const
|
||||||
{
|
{
|
||||||
return d->DockWidget;
|
return d->DockWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidgetTitleBar::setDockAreaWidget(CDockAreaWidget* DockArea)
|
void CDockWidgetTab::setDockAreaWidget(CDockAreaWidget* DockArea)
|
||||||
{
|
{
|
||||||
d->DockArea = DockArea;
|
d->DockArea = DockArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockAreaWidget* CDockWidgetTitleBar::dockAreaWidget() const
|
CDockAreaWidget* CDockWidgetTab::dockAreaWidget() const
|
||||||
{
|
{
|
||||||
return d->DockArea;
|
return d->DockArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidgetTitleBar::setIcon(const QIcon& Icon)
|
void CDockWidgetTab::setIcon(const QIcon& Icon)
|
||||||
{
|
{
|
||||||
d->Icon = Icon;
|
d->Icon = Icon;
|
||||||
d->IconLabel->setPixmap(Icon.pixmap(this->windowHandle(), QSize(16, 16)));
|
d->IconLabel->setPixmap(Icon.pixmap(this->windowHandle(), QSize(16, 16)));
|
||||||
@ -371,11 +371,11 @@ void CDockWidgetTitleBar::setIcon(const QIcon& Icon)
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
const QIcon& CDockWidgetTitleBar::icon() const
|
const QIcon& CDockWidgetTab::icon() const
|
||||||
{
|
{
|
||||||
return d->Icon;
|
return d->Icon;
|
||||||
}
|
}
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// EOF DockWidgetTitleBar.cpp
|
// EOF DockWidgetTab.cpp
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef DockWidgetTitleBarH
|
#ifndef DockWidgetTabH
|
||||||
#define DockWidgetTitleBarH
|
#define DockWidgetTabH
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Qt Advanced Docking System
|
** Qt Advanced Docking System
|
||||||
** Copyright (C) 2017 Uwe Kindler
|
** Copyright (C) 2017 Uwe Kindler
|
||||||
@ -20,10 +20,10 @@
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
/// \file DockWidgetTitleBar.h
|
/// \file DockWidgetTab.h
|
||||||
/// \author Uwe Kindler
|
/// \author Uwe Kindler
|
||||||
/// \date 27.02.2017
|
/// \date 27.02.2017
|
||||||
/// \brief Declaration of CDockWidgetTitleBar class
|
/// \brief Declaration of CDockWidgetTab class
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
|
|
||||||
@ -38,19 +38,21 @@ namespace ads
|
|||||||
{
|
{
|
||||||
class CDockWidget;
|
class CDockWidget;
|
||||||
class CDockAreaWidget;
|
class CDockAreaWidget;
|
||||||
struct DockWidgetTitleBarPrivate;
|
struct DockWidgetTabPrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A dock widget title bar that shows a title and an icon
|
* A dock widget tab that shows a title and an icon.
|
||||||
|
* The dock widget tab is shown in the dock area title bar to switch between
|
||||||
|
* tabbed dock widgets
|
||||||
*/
|
*/
|
||||||
class ADS_EXPORT CDockWidgetTitleBar : public QFrame
|
class ADS_EXPORT CDockWidgetTab : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool activeTab READ isActiveTab WRITE setActiveTab NOTIFY activeTabChanged)
|
Q_PROPERTY(bool activeTab READ isActiveTab WRITE setActiveTab NOTIFY activeTabChanged)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DockWidgetTitleBarPrivate* d; ///< private data (pimpl)
|
DockWidgetTabPrivate* d; ///< private data (pimpl)
|
||||||
friend struct DockWidgetTitleBarPrivate;
|
friend struct DockWidgetTabPrivate;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mousePressEvent(QMouseEvent* ev) override;
|
virtual void mousePressEvent(QMouseEvent* ev) override;
|
||||||
@ -63,12 +65,12 @@ public:
|
|||||||
* param[in] DockWidget The dock widget this title bar belongs to
|
* param[in] DockWidget The dock widget this title bar belongs to
|
||||||
* param[in] parent The parent widget of this title bar
|
* param[in] parent The parent widget of this title bar
|
||||||
*/
|
*/
|
||||||
CDockWidgetTitleBar(CDockWidget* DockWidget, QWidget* parent = 0);
|
CDockWidgetTab(CDockWidget* DockWidget, QWidget* parent = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual Destructor
|
* Virtual Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~CDockWidgetTitleBar();
|
virtual ~CDockWidgetTab();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true, if this is the active tab
|
* Returns true, if this is the active tab
|
||||||
@ -111,8 +113,8 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void activeTabChanged();
|
void activeTabChanged();
|
||||||
void clicked();
|
void clicked();
|
||||||
}; // class DockWidgetTitleBar
|
}; // class DockWidgetTab
|
||||||
}
|
}
|
||||||
// namespace ads
|
// namespace ads
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#endif // DockWidgetTitleBarH
|
#endif // DockWidgetTabH
|
@ -210,7 +210,6 @@ CFloatingDockContainer::CFloatingDockContainer(CDockManager* DockManager) :
|
|||||||
QWidget(DockManager, Qt::Window),
|
QWidget(DockManager, Qt::Window),
|
||||||
d(new FloatingDockContainerPrivate(this))
|
d(new FloatingDockContainerPrivate(this))
|
||||||
{
|
{
|
||||||
//setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
d->DockManager = DockManager;
|
d->DockManager = DockManager;
|
||||||
QBoxLayout* l = new QBoxLayout(QBoxLayout::TopToBottom);
|
QBoxLayout* l = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||||
l->setContentsMargins(0, 0, 0, 0);
|
l->setContentsMargins(0, 0, 0, 0);
|
||||||
@ -412,7 +411,7 @@ void CFloatingDockContainer::moveFloating()
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CFloatingDockContainer::isClosable()
|
bool CFloatingDockContainer::isClosable() const
|
||||||
{
|
{
|
||||||
auto OpenDockAreas = d->DockContainer->openedDockAreas();
|
auto OpenDockAreas = d->DockContainer->openedDockAreas();
|
||||||
for (auto DockArea : OpenDockAreas)
|
for (auto DockArea : OpenDockAreas)
|
||||||
@ -420,13 +419,17 @@ bool CFloatingDockContainer::isClosable()
|
|||||||
auto OpenDockWidgets = DockArea->openedDockWidgets();
|
auto OpenDockWidgets = DockArea->openedDockWidgets();
|
||||||
for (auto DockWidget : OpenDockWidgets)
|
for (auto DockWidget : OpenDockWidgets)
|
||||||
{
|
{
|
||||||
if (!(DockWidget->features() & CDockWidget::DockWidgetClosable))
|
if (!DockWidget->features().testFlag(CDockWidget::DockWidgetClosable))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
void CFloatingDockContainer::onDockAreasAddedOrRemoved()
|
void CFloatingDockContainer::onDockAreasAddedOrRemoved()
|
||||||
{
|
{
|
||||||
qDebug() << "CFloatingDockContainer::onDockAreasAddedOrRemoved()";
|
qDebug() << "CFloatingDockContainer::onDockAreasAddedOrRemoved()";
|
||||||
|
@ -55,8 +55,6 @@ private:
|
|||||||
FloatingDockContainerPrivate* d; ///< private data (pimpl)
|
FloatingDockContainerPrivate* d; ///< private data (pimpl)
|
||||||
friend struct FloatingDockContainerPrivate;
|
friend struct FloatingDockContainerPrivate;
|
||||||
|
|
||||||
bool isClosable();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDockAreasAddedOrRemoved();
|
void onDockAreasAddedOrRemoved();
|
||||||
void onDockAreaCurrentChanged(int Index);
|
void onDockAreaCurrentChanged(int Index);
|
||||||
@ -117,6 +115,12 @@ public:
|
|||||||
* faulty files before you start restoring the state
|
* faulty files before you start restoring the state
|
||||||
*/
|
*/
|
||||||
bool restoreState(QXmlStreamReader& Stream, bool Testing);
|
bool restoreState(QXmlStreamReader& Stream, bool Testing);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function returns true, if it can be closed.
|
||||||
|
* It can be closed, if all dock widgets in all dock areas can be closed
|
||||||
|
*/
|
||||||
|
bool isClosable() const;
|
||||||
}; // class FloatingDockContainer
|
}; // class FloatingDockContainer
|
||||||
}
|
}
|
||||||
// namespace ads
|
// namespace ads
|
||||||
|
@ -33,10 +33,11 @@ RESOURCES += ads.qrc
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
ads_globals.h \
|
ads_globals.h \
|
||||||
DockAreaWidget.h \
|
DockAreaWidget.h \
|
||||||
|
DockAreaTabBar.h \
|
||||||
DockContainerWidget.h \
|
DockContainerWidget.h \
|
||||||
DockManager.h \
|
DockManager.h \
|
||||||
DockWidget.h \
|
DockWidget.h \
|
||||||
DockWidgetTitleBar.h \
|
DockWidgetTab.h \
|
||||||
FloatingDockContainer.h \
|
FloatingDockContainer.h \
|
||||||
DockOverlay.h \
|
DockOverlay.h \
|
||||||
DockSplitter.h
|
DockSplitter.h
|
||||||
@ -46,10 +47,11 @@ HEADERS += \
|
|||||||
SOURCES += \
|
SOURCES += \
|
||||||
ads_globals.cpp \
|
ads_globals.cpp \
|
||||||
DockAreaWidget.cpp \
|
DockAreaWidget.cpp \
|
||||||
|
DockAreaTabBar.cpp \
|
||||||
DockContainerWidget.cpp \
|
DockContainerWidget.cpp \
|
||||||
DockManager.cpp \
|
DockManager.cpp \
|
||||||
DockWidget.cpp \
|
DockWidget.cpp \
|
||||||
DockWidgetTitleBar.cpp \
|
DockWidgetTab.cpp \
|
||||||
FloatingDockContainer.cpp \
|
FloatingDockContainer.cpp \
|
||||||
DockOverlay.cpp \
|
DockOverlay.cpp \
|
||||||
DockSplitter.cpp
|
DockSplitter.cpp
|
||||||
|
@ -25,7 +25,7 @@ ads--CDockAreaWidget #tabsMenuButton::menu-indicator
|
|||||||
image: none;
|
image: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
ads--CDockWidgetTitleBar
|
ads--CDockWidgetTab
|
||||||
{
|
{
|
||||||
background: palette(window);
|
background: palette(window);
|
||||||
border-color: palette(light);
|
border-color: palette(light);
|
||||||
@ -34,17 +34,17 @@ ads--CDockWidgetTitleBar
|
|||||||
padding: 0 9px;
|
padding: 0 9px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ads--CDockWidgetTitleBar[activeTab="true"]
|
ads--CDockWidgetTab[activeTab="true"]
|
||||||
{
|
{
|
||||||
background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:0.5, stop:0 palette(window), stop:1 palette(light));
|
background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:0.5, stop:0 palette(window), stop:1 palette(light));
|
||||||
}
|
}
|
||||||
|
|
||||||
ads--CDockWidgetTitleBar QLabel
|
ads--CDockWidgetTab QLabel
|
||||||
{
|
{
|
||||||
color: palette(dark);
|
color: palette(dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
ads--CDockWidgetTitleBar[activeTab="true"] QLabel
|
ads--CDockWidgetTab[activeTab="true"] QLabel
|
||||||
{
|
{
|
||||||
color: palette(foreground);
|
color: palette(foreground);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user