Merge branch 'auto_hide_feature' of github.com:githubuser0xFFFF/Qt-Advanced-Docking-System into auto_hide_feature

This commit is contained in:
Syarif Fakhri 2022-10-13 11:11:58 +08:00
commit ae55013566
22 changed files with 166 additions and 101 deletions

View File

@ -650,7 +650,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
// uncomment the following line to enable focus highlighting of the dock // uncomment the following line to enable focus highlighting of the dock
// widget that has the focus // widget that has the focus
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true); //CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
// uncomment if you would like to enable dock widget auto hiding // uncomment if you would like to enable dock widget auto hiding
// CDockManager::setConfigFlag(CDockManager::DefaultAutoHideConfig, true); // CDockManager::setConfigFlag(CDockManager::DefaultAutoHideConfig, true);

View File

@ -27,7 +27,7 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include "OverlayDockContainer.h" #include <AutoHideDockContainer.h>
#include "DockManager.h" #include "DockManager.h"
#include "DockWidgetSideTab.h" #include "DockWidgetSideTab.h"
#include "DockWidgetTab.h" #include "DockWidgetTab.h"
@ -40,12 +40,15 @@
#include <QPainter> #include <QPainter>
#include <QSplitter> #include <QSplitter>
#include <QPointer> #include <QPointer>
#include <QApplication>
#include <iostream>
namespace ads namespace ads
{ {
struct OverlayDockContainerPrivate struct AutoHideDockContainerPrivate
{ {
COverlayDockContainer* _this; CAutoHideDockContainer* _this;
CDockAreaWidget* DockArea{nullptr}; CDockAreaWidget* DockArea{nullptr};
CDockWidget* DockWidget{nullptr}; CDockWidget* DockWidget{nullptr};
QPointer<CDockManager> DockManager{nullptr}; QPointer<CDockManager> DockManager{nullptr};
@ -54,7 +57,7 @@ struct OverlayDockContainerPrivate
/** /**
* Private data constructor * Private data constructor
*/ */
OverlayDockContainerPrivate(COverlayDockContainer *_public); AutoHideDockContainerPrivate(CAutoHideDockContainer *_public);
/** /**
* Convenience function to get a dock widget area * Convenience function to get a dock widget area
@ -110,22 +113,22 @@ struct OverlayDockContainerPrivate
}; // struct OverlayDockContainerPrivate }; // struct OverlayDockContainerPrivate
//============================================================================ //============================================================================
OverlayDockContainerPrivate::OverlayDockContainerPrivate( AutoHideDockContainerPrivate::AutoHideDockContainerPrivate(
COverlayDockContainer *_public) : CAutoHideDockContainer *_public) :
_this(_public) _this(_public)
{ {
} }
CDockContainerWidget* COverlayDockContainer::parentContainer() const CDockContainerWidget* CAutoHideDockContainer::parentContainer() const
{ {
return internal::findParent<CDockContainerWidget*>(this); return internal::findParent<CDockContainerWidget*>(this);
} }
//============================================================================ //============================================================================
COverlayDockContainer::COverlayDockContainer(CDockManager* DockManager, CDockWidgetSideTab::SideTabBarArea area, CDockContainerWidget* parent) : CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, CDockWidgetSideTab::SideTabBarArea area, CDockContainerWidget* parent) :
QSplitter(area == CDockWidgetSideTab::Bottom ? Qt::Orientation::Vertical : Qt::Orientation::Horizontal, parent), QSplitter(area == CDockWidgetSideTab::Bottom ? Qt::Orientation::Vertical : Qt::Orientation::Horizontal, parent),
d(new OverlayDockContainerPrivate(this)) d(new AutoHideDockContainerPrivate(this))
{ {
d->DockManager = DockManager; d->DockManager = DockManager;
d->Area = area; d->Area = area;
@ -176,7 +179,7 @@ COverlayDockContainer::COverlayDockContainer(CDockManager* DockManager, CDockWid
} }
//============================================================================ //============================================================================
void COverlayDockContainer::updateMask() void CAutoHideDockContainer::updateMask()
{ {
const auto rect = d->DockArea->frameGeometry(); const auto rect = d->DockArea->frameGeometry();
const auto topLeft = rect.topLeft(); const auto topLeft = rect.topLeft();
@ -197,7 +200,7 @@ void COverlayDockContainer::updateMask()
} }
//============================================================================ //============================================================================
void COverlayDockContainer::updateSize() void CAutoHideDockContainer::updateSize()
{ {
const auto dockContainerParent = parentContainer(); const auto dockContainerParent = parentContainer();
const auto rootSplitter = dockContainerParent->rootSplitter(); const auto rootSplitter = dockContainerParent->rootSplitter();
@ -207,15 +210,15 @@ void COverlayDockContainer::updateSize()
} }
//============================================================================ //============================================================================
COverlayDockContainer::COverlayDockContainer(CDockWidget* DockWidget, CDockWidgetSideTab::SideTabBarArea area, CDockContainerWidget* parent) : CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget, CDockWidgetSideTab::SideTabBarArea area, CDockContainerWidget* parent) :
COverlayDockContainer(DockWidget->dockManager(), area, parent) CAutoHideDockContainer(DockWidget->dockManager(), area, parent)
{ {
addDockWidget(DockWidget); addDockWidget(DockWidget);
setDockSizeProportion(DockWidget->DefaultOverlayDockProportion()); setDockSizeProportion(DockWidget->DefaultOverlayDockProportion());
} }
//============================================================================ //============================================================================
COverlayDockContainer::~COverlayDockContainer() CAutoHideDockContainer::~CAutoHideDockContainer()
{ {
ADS_PRINT("~COverlayDockContainer"); ADS_PRINT("~COverlayDockContainer");
@ -232,19 +235,19 @@ COverlayDockContainer::~COverlayDockContainer()
} }
//============================================================================ //============================================================================
CSideTabBar* COverlayDockContainer::sideTabBar() const CSideTabBar* CAutoHideDockContainer::sideTabBar() const
{ {
return parentContainer()->sideTabBar(d->Area); return parentContainer()->sideTabBar(d->Area);
} }
//============================================================================ //============================================================================
CDockWidget* COverlayDockContainer::dockWidget() const CDockWidget* CAutoHideDockContainer::dockWidget() const
{ {
return d->DockWidget; return d->DockWidget;
} }
//============================================================================ //============================================================================
void COverlayDockContainer::addDockWidget(CDockWidget* DockWidget) void CAutoHideDockContainer::addDockWidget(CDockWidget* DockWidget)
{ {
if (d->DockWidget) if (d->DockWidget)
{ {
@ -267,7 +270,7 @@ void COverlayDockContainer::addDockWidget(CDockWidget* DockWidget)
//============================================================================ //============================================================================
void COverlayDockContainer::setDockSizeProportion(float SplitterProportion) void CAutoHideDockContainer::setDockSizeProportion(float SplitterProportion)
{ {
if (SplitterProportion < 0 || SplitterProportion > 1) if (SplitterProportion < 0 || SplitterProportion > 1)
{ {
@ -298,19 +301,19 @@ void COverlayDockContainer::setDockSizeProportion(float SplitterProportion)
//============================================================================ //============================================================================
CDockWidgetSideTab::SideTabBarArea COverlayDockContainer::sideTabBarArea() const CDockWidgetSideTab::SideTabBarArea CAutoHideDockContainer::sideTabBarArea() const
{ {
return d->Area; return d->Area;
} }
//============================================================================ //============================================================================
CDockAreaWidget* COverlayDockContainer::dockAreaWidget() const CDockAreaWidget* CAutoHideDockContainer::dockAreaWidget() const
{ {
return d->DockArea; return d->DockArea;
} }
//============================================================================ //============================================================================
void COverlayDockContainer::moveContentsToParent() void CAutoHideDockContainer::moveContentsToParent()
{ {
cleanupAndDelete(); cleanupAndDelete();
@ -331,7 +334,7 @@ void COverlayDockContainer::moveContentsToParent()
//============================================================================ //============================================================================
void COverlayDockContainer::cleanupAndDelete() void CAutoHideDockContainer::cleanupAndDelete()
{ {
const auto dockWidget = d->DockWidget; const auto dockWidget = d->DockWidget;
if (dockWidget) if (dockWidget)
@ -347,7 +350,7 @@ void COverlayDockContainer::cleanupAndDelete()
//============================================================================ //============================================================================
void COverlayDockContainer::saveState(QXmlStreamWriter& s) void CAutoHideDockContainer::saveState(QXmlStreamWriter& s)
{ {
s.writeAttribute("SideTabBarArea", QString::number(sideTabBarArea())); s.writeAttribute("SideTabBarArea", QString::number(sideTabBarArea()));
QStringList Sizes; QStringList Sizes;
@ -361,7 +364,7 @@ void COverlayDockContainer::saveState(QXmlStreamWriter& s)
//============================================================================ //============================================================================
bool COverlayDockContainer::restoreState(CDockingStateReader& s, bool Testing) bool CAutoHideDockContainer::restoreState(CDockingStateReader& s, bool Testing)
{ {
auto sSizes = s.attributes().value("Sizes").trimmed().toString(); auto sSizes = s.attributes().value("Sizes").trimmed().toString();
ADS_PRINT("Sizes: " << sSizes); ADS_PRINT("Sizes: " << sSizes);
@ -387,7 +390,9 @@ bool COverlayDockContainer::restoreState(CDockingStateReader& s, bool Testing)
return true; return true;
} }
void COverlayDockContainer::toggleView(bool Enable)
//============================================================================
void CAutoHideDockContainer::toggleView(bool Enable)
{ {
if (Enable) if (Enable)
{ {
@ -405,16 +410,20 @@ void COverlayDockContainer::toggleView(bool Enable)
dockWidget->sideTabWidget()->hide(); dockWidget->sideTabWidget()->hide();
} }
hide(); hide();
qApp->removeEventFilter(this);
} }
} }
void COverlayDockContainer::collapseView(bool Enable)
//============================================================================
void CAutoHideDockContainer::collapseView(bool Enable)
{ {
if (Enable) if (Enable)
{ {
hide(); hide();
d->DockArea->hide(); d->DockArea->hide();
d->DockWidget->hide(); d->DockWidget->hide();
qApp->removeEventFilter(this);
} }
else else
{ {
@ -422,12 +431,20 @@ void COverlayDockContainer::collapseView(bool Enable)
show(); show();
d->DockArea->show(); d->DockArea->show();
d->DockWidget->show(); d->DockWidget->show();
qApp->installEventFilter(this);
} }
} }
//============================================================================ //============================================================================
bool COverlayDockContainer::areaExistsInConfig(CDockWidgetSideTab::SideTabBarArea area) void CAutoHideDockContainer::toggleCollapseState()
{
collapseView(isVisible());
}
//============================================================================
bool CAutoHideDockContainer::areaExistsInConfig(CDockWidgetSideTab::SideTabBarArea area)
{ {
switch (area) switch (area)
{ {
@ -452,27 +469,70 @@ bool COverlayDockContainer::areaExistsInConfig(CDockWidgetSideTab::SideTabBarAre
//============================================================================ //============================================================================
bool COverlayDockContainer::eventFilter(QObject* watched, QEvent* event) bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
{ {
if (event->type() == QEvent::Resize) if (event->type() == QEvent::Resize)
{ {
updateSize(); updateSize();
updateMask(); updateMask();
} }
else if (event->type() == QEvent::MouseButtonPress)
{
// First we check, if the mouse button press is inside the dock manager
// widget. If it is not, i.e. if someone resizes the main window or
// clicks into the application menu or toolbar, then we ignore the
// event
auto widget = qobject_cast<QWidget*>(watched);
bool IsDockManager = false;
while (widget)
{
if (widget == d->DockManager)
{
IsDockManager = true;
}
widget = widget->parentWidget();
}
if (!IsDockManager)
{
return QSplitter::eventFilter(watched, event);
}
// Now we check, if the user clicked inside of this auto hide container.
// If the click is inside of this auto hide container, then we can also
// ignore the event, because the overlay should not get collapsed if
// user works in it
QMouseEvent* me = static_cast<QMouseEvent*>(event);
auto pos = d->DockArea->mapFromGlobal(me->globalPos());
auto rect = d->DockArea->rect().adjusted(-handleWidth(), 0, 0, 0);
if (rect.contains(pos))
{
return QSplitter::eventFilter(watched, event);
}
// Now check, if the user clicked into the side tab and ignore this event,
// because the side tab click handler will call collapseView(). If we
// do not ignore this here, then we will collapse the container and the side tab
// click handler will uncollapse it
auto SideTab = d->DockWidget->sideTabWidget();
pos = SideTab->mapFromGlobal(me->globalPos());
if (SideTab->rect().contains(pos))
{
return QSplitter::eventFilter(watched, event);
}
// If the mouse button down event is in the dock manager but outside
// of the open auto hide container, then the auto hide dock widget
// should get collapsed
collapseView(true);
}
return QSplitter::eventFilter(watched, event); return QSplitter::eventFilter(watched, event);
} }
//============================================================================ //============================================================================
void COverlayDockContainer::mousePressEvent(QMouseEvent* event) void CAutoHideDockContainer::resizeEvent(QResizeEvent* event)
{
QSplitter::mousePressEvent(event);
}
//============================================================================
void COverlayDockContainer::resizeEvent(QResizeEvent* event)
{ {
updateMask(); updateMask();
QSplitter::resizeEvent(event); QSplitter::resizeEvent(event);

View File

@ -39,7 +39,7 @@ class QXmlStreamWriter;
namespace ads namespace ads
{ {
struct OverlayDockContainerPrivate; struct AutoHideDockContainerPrivate;
class CDockManager; class CDockManager;
class CDockWidget; class CDockWidget;
class CDockContainerWidget; class CDockContainerWidget;
@ -49,17 +49,16 @@ class CDockingStateReader;
// Note: This widget must be a QSplitter, inheriting from QWidget and keeping an internal splitter breaks ActiveX widgets // Note: This widget must be a QSplitter, inheriting from QWidget and keeping an internal splitter breaks ActiveX widgets
// likely due to layout issues between this widget and the internal splitter // likely due to layout issues between this widget and the internal splitter
class ADS_EXPORT COverlayDockContainer : public QSplitter class ADS_EXPORT CAutoHideDockContainer : public QSplitter
{ {
Q_OBJECT Q_OBJECT
private: private:
OverlayDockContainerPrivate* d; ///< private data (pimpl) AutoHideDockContainerPrivate* d; ///< private data (pimpl)
friend struct OverlayDockContainerPrivate; friend struct AutoHideDockContainerPrivate;
protected: protected:
bool eventFilter(QObject* watched, QEvent* event) override; bool eventFilter(QObject* watched, QEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void resizeEvent(QResizeEvent* event) override; void resizeEvent(QResizeEvent* event) override;
void updateMask(); void updateMask();
void updateSize(); void updateSize();
@ -70,17 +69,17 @@ public:
/** /**
* Create overlay widget with a dock manager * Create overlay widget with a dock manager
*/ */
COverlayDockContainer(CDockManager* DockManager, CDockWidgetSideTab::SideTabBarArea area, CDockContainerWidget* parent); CAutoHideDockContainer(CDockManager* DockManager, CDockWidgetSideTab::SideTabBarArea area, CDockContainerWidget* parent);
/** /**
* Create overlay widget with the given dock widget * Create overlay widget with the given dock widget
*/ */
COverlayDockContainer(CDockWidget* DockWidget, CDockWidgetSideTab::SideTabBarArea area, CDockContainerWidget* parent); CAutoHideDockContainer(CDockWidget* DockWidget, CDockWidgetSideTab::SideTabBarArea area, CDockContainerWidget* parent);
/** /**
* Virtual Destructor * Virtual Destructor
*/ */
virtual ~COverlayDockContainer(); virtual ~CAutoHideDockContainer();
/** /**
* Get's the side tab bar * Get's the side tab bar
@ -148,6 +147,11 @@ public:
*/ */
void collapseView(bool Enable); void collapseView(bool Enable);
/**
* Toggles the current collapse state
*/
void toggleCollapseState();
/* /*
* Convenience function fr determining if area exists in config * Convenience function fr determining if area exists in config
*/ */

View File

@ -29,7 +29,7 @@ set(ads_SRCS
DockComponentsFactory.cpp DockComponentsFactory.cpp
SideTabBar.cpp SideTabBar.cpp
DockWidgetSideTab.cpp DockWidgetSideTab.cpp
OverlayDockContainer.cpp AutoHideDockContainer.cpp
ads.qrc ads.qrc
) )
set(ads_HEADERS set(ads_HEADERS
@ -53,7 +53,7 @@ set(ads_HEADERS
DockComponentsFactory.h DockComponentsFactory.h
SideTabBar.h SideTabBar.h
DockWidgetSideTab.h DockWidgetSideTab.h
OverlayDockContainer.h AutoHideDockContainer.h
) )
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>") add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE)

View File

@ -27,6 +27,7 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <AutoHideDockContainer.h>
#include "DockAreaTitleBar.h" #include "DockAreaTitleBar.h"
#include <QPushButton> #include <QPushButton>
@ -51,7 +52,6 @@
#include "DockAreaTabBar.h" #include "DockAreaTabBar.h"
#include "DockComponentsFactory.h" #include "DockComponentsFactory.h"
#include "DockFocusController.h" #include "DockFocusController.h"
#include "OverlayDockContainer.h"
#include "ElidingLabel.h" #include "ElidingLabel.h"
#include <iostream> #include <iostream>

View File

@ -28,6 +28,7 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <AutoHideDockContainer.h>
#include "DockAreaWidget.h" #include "DockAreaWidget.h"
#include <QStackedLayout> #include <QStackedLayout>
@ -52,7 +53,6 @@
#include "DockComponentsFactory.h" #include "DockComponentsFactory.h"
#include "DockWidgetTab.h" #include "DockWidgetTab.h"
#include "DockWidgetSideTab.h" #include "DockWidgetSideTab.h"
#include "OverlayDockContainer.h"
namespace ads namespace ads
@ -248,7 +248,7 @@ struct DockAreaWidgetPrivate
DockAreaLayout* ContentsLayout = nullptr; DockAreaLayout* ContentsLayout = nullptr;
CDockAreaTitleBar* TitleBar = nullptr; CDockAreaTitleBar* TitleBar = nullptr;
CDockManager* DockManager = nullptr; CDockManager* DockManager = nullptr;
COverlayDockContainer* OverlayDockContainer = nullptr; CAutoHideDockContainer* OverlayDockContainer = nullptr;
bool UpdateTitleBarButtons = false; bool UpdateTitleBarButtons = false;
DockWidgetAreas AllowedAreas = DefaultAllowedAreas; DockWidgetAreas AllowedAreas = DefaultAllowedAreas;
QSize MinSizeHint; QSize MinSizeHint;
@ -457,7 +457,7 @@ CDockContainerWidget* CDockAreaWidget::dockContainer() const
} }
//============================================================================ //============================================================================
COverlayDockContainer* CDockAreaWidget::overlayDockContainer() const CAutoHideDockContainer* CDockAreaWidget::overlayDockContainer() const
{ {
return d->OverlayDockContainer; return d->OverlayDockContainer;
} }
@ -469,7 +469,7 @@ bool CDockAreaWidget::isOverlayed() const
} }
//============================================================================ //============================================================================
void CDockAreaWidget::setOverlayDockContainer(COverlayDockContainer* OverlayDockContainer) void CDockAreaWidget::setOverlayDockContainer(CAutoHideDockContainer* OverlayDockContainer)
{ {
d->OverlayDockContainer = OverlayDockContainer; d->OverlayDockContainer = OverlayDockContainer;
} }

View File

@ -66,7 +66,7 @@ private:
friend class CDockWidget; friend class CDockWidget;
friend struct DockManagerPrivate; friend struct DockManagerPrivate;
friend class CDockManager; friend class CDockManager;
friend class COverlayDockContainer; friend class CAutoHideDockContainer;
void onDockWidgetFeaturesChanged(); void onDockWidgetFeaturesChanged();
private Q_SLOTS: private Q_SLOTS:
@ -212,7 +212,7 @@ public:
* Returns the overlay dock container widget this dock area widget belongs to or 0 * Returns the overlay dock container widget this dock area widget belongs to or 0
* if there is no * if there is no
*/ */
COverlayDockContainer* overlayDockContainer() const; CAutoHideDockContainer* overlayDockContainer() const;
/** /**
* Returns true if the dock area exists in an overlay dock container * Returns true if the dock area exists in an overlay dock container
@ -223,7 +223,7 @@ public:
/** /**
* Sets the current overlay dock container * Sets the current overlay dock container
*/ */
void setOverlayDockContainer(COverlayDockContainer* OverlayDockContainer); void setOverlayDockContainer(CAutoHideDockContainer* OverlayDockContainer);
/** /**
* Returns the largest minimumSizeHint() of the dock widgets in this * Returns the largest minimumSizeHint() of the dock widgets in this

View File

@ -28,6 +28,7 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <AutoHideDockContainer.h>
#include "DockContainerWidget.h" #include "DockContainerWidget.h"
#include <QEvent> #include <QEvent>
@ -49,7 +50,6 @@
#include "ads_globals.h" #include "ads_globals.h"
#include "DockSplitter.h" #include "DockSplitter.h"
#include "SideTabBar.h" #include "SideTabBar.h"
#include "OverlayDockContainer.h"
#include "DockWidgetTab.h" #include "DockWidgetTab.h"
#include "DockWidgetSideTab.h" #include "DockWidgetSideTab.h"
#include "DockAreaTitleBar.h" #include "DockAreaTitleBar.h"
@ -138,7 +138,7 @@ public:
QPointer<CDockManager> DockManager; QPointer<CDockManager> DockManager;
unsigned int zOrderIndex = 0; unsigned int zOrderIndex = 0;
QList<CDockAreaWidget*> DockAreas; QList<CDockAreaWidget*> DockAreas;
QList<COverlayDockContainer*> OverlayWidgets; QList<CAutoHideDockContainer*> OverlayWidgets;
QMap<CDockWidgetSideTab::SideTabBarArea, CSideTabBar*> SideTabBarWidgets; QMap<CDockWidgetSideTab::SideTabBarArea, CSideTabBar*> SideTabBarWidgets;
QGridLayout* Layout = nullptr; QGridLayout* Layout = nullptr;
QSplitter* RootSplitter = nullptr; QSplitter* RootSplitter = nullptr;
@ -1048,7 +1048,7 @@ bool DockContainerWidgetPrivate::restoreOverlayDockArea(CDockingStateReader& s,
ADS_PRINT("Restore NodeDockArea Tabs: " << Tabs << " Current: " ADS_PRINT("Restore NodeDockArea Tabs: " << Tabs << " Current: "
<< CurrentDockWidget); << CurrentDockWidget);
if (!COverlayDockContainer::areaExistsInConfig(area)) if (!CAutoHideDockContainer::areaExistsInConfig(area))
{ {
return false; return false;
} }
@ -1056,7 +1056,7 @@ bool DockContainerWidgetPrivate::restoreOverlayDockArea(CDockingStateReader& s,
CDockAreaWidget* DockArea = nullptr; CDockAreaWidget* DockArea = nullptr;
if (!Testing) if (!Testing)
{ {
const auto dockContainer = new COverlayDockContainer(DockManager, area, _this); const auto dockContainer = new CAutoHideDockContainer(DockManager, area, _this);
if (!dockContainer->restoreState(s, Testing)) if (!dockContainer->restoreState(s, Testing))
{ {
return false; return false;
@ -1491,13 +1491,13 @@ CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockW
//============================================================================ //============================================================================
COverlayDockContainer* CDockContainerWidget::createAndInitializeDockWidgetOverlayContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* DockWidget, CDockWidget::eOverlayInsertOrder insertOrder) CAutoHideDockContainer* CDockContainerWidget::createAndInitializeDockWidgetOverlayContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* DockWidget, CDockWidget::eOverlayInsertOrder insertOrder)
{ {
if (d->DockManager != DockWidget->dockManager()) if (d->DockManager != DockWidget->dockManager())
{ {
DockWidget->setDockManager(d->DockManager); // Overlay Dock Container needs a valid dock manager DockWidget->setDockManager(d->DockManager); // Overlay Dock Container needs a valid dock manager
} }
if (!COverlayDockContainer::areaExistsInConfig(area)) if (!CAutoHideDockContainer::areaExistsInConfig(area))
{ {
Q_ASSERT_X(false, "CDockContainerWidget::createAndInitializeDockWidgetOverlayContainer", Q_ASSERT_X(false, "CDockContainerWidget::createAndInitializeDockWidgetOverlayContainer",
"Requested area does not exist in config"); "Requested area does not exist in config");
@ -1508,7 +1508,7 @@ COverlayDockContainer* CDockContainerWidget::createAndInitializeDockWidgetOverla
sideTabBar(area)->insertSideTab(insertOrder == CDockWidget::First ? 0 : -1, DockWidget->sideTabWidget()); sideTabBar(area)->insertSideTab(insertOrder == CDockWidget::First ? 0 : -1, DockWidget->sideTabWidget());
DockWidget->sideTabWidget()->show(); DockWidget->sideTabWidget()->show();
const auto dockContainer = new COverlayDockContainer(DockWidget, area, this); const auto dockContainer = new CAutoHideDockContainer(DockWidget, area, this);
dockContainer->hide(); dockContainer->hide();
d->DockManager->dockFocusController()->clearDockWidgetFocus(DockWidget); d->DockManager->dockFocusController()->clearDockWidgetFocus(DockWidget);
return dockContainer; return dockContainer;
@ -1619,7 +1619,7 @@ void CDockContainerWidget::deleteOverlayWidgets()
} }
//============================================================================ //============================================================================
QList<COverlayDockContainer*> CDockContainerWidget::overlayWidgets() const QList<CAutoHideDockContainer*> CDockContainerWidget::overlayWidgets() const
{ {
return d->OverlayWidgets; return d->OverlayWidgets;
} }
@ -2156,7 +2156,7 @@ void CDockContainerWidget::updateSplitterHandles(QSplitter* splitter)
} }
//============================================================================ //============================================================================
void CDockContainerWidget::registerOverlayWidget(COverlayDockContainer* OverlayWidget) void CDockContainerWidget::registerOverlayWidget(CAutoHideDockContainer* OverlayWidget)
{ {
d->OverlayWidgets.append(OverlayWidget); d->OverlayWidgets.append(OverlayWidget);
Q_EMIT overlayWidgetCreated(OverlayWidget); Q_EMIT overlayWidgetCreated(OverlayWidget);
@ -2164,7 +2164,7 @@ void CDockContainerWidget::registerOverlayWidget(COverlayDockContainer* OverlayW
} }
//============================================================================ //============================================================================
void CDockContainerWidget::removeOverlayWidget(COverlayDockContainer* OverlayWidget) void CDockContainerWidget::removeOverlayWidget(CAutoHideDockContainer* OverlayWidget)
{ {
d->OverlayWidgets.removeAll(OverlayWidget); d->OverlayWidgets.removeAll(OverlayWidget);
} }

View File

@ -76,7 +76,7 @@ private:
friend class CDockWidget; friend class CDockWidget;
friend class CFloatingDragPreview; friend class CFloatingDragPreview;
friend struct FloatingDragPreviewPrivate; friend struct FloatingDragPreviewPrivate;
friend class COverlayDockContainer; friend class CAutoHideDockContainer;
protected: protected:
/** /**
@ -100,7 +100,7 @@ protected:
* Initializing inserts the tabs into the side tab widget and hides it * Initializing inserts the tabs into the side tab widget and hides it
* Returns nullptr if you try and insert into an area where the configuration is not enabled * Returns nullptr if you try and insert into an area where the configuration is not enabled
*/ */
COverlayDockContainer* createAndInitializeDockWidgetOverlayContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* DockWidget, CDockWidget::eOverlayInsertOrder insertOrder); CAutoHideDockContainer* createAndInitializeDockWidgetOverlayContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* DockWidget, CDockWidget::eOverlayInsertOrder insertOrder);
/** /**
* Helper function for creation of the root splitter * Helper function for creation of the root splitter
@ -187,13 +187,13 @@ protected:
* Registers the given floating widget in the internal list of * Registers the given floating widget in the internal list of
* overlay widgets * overlay widgets
*/ */
void registerOverlayWidget(COverlayDockContainer* OverlayWidget); void registerOverlayWidget(CAutoHideDockContainer* OverlayWidget);
/** /**
* Remove the given overlay widget from the list of registered overlay * Remove the given overlay widget from the list of registered overlay
* widgets * widgets
*/ */
void removeOverlayWidget(COverlayDockContainer* OverlayWidget); void removeOverlayWidget(CAutoHideDockContainer* OverlayWidget);
public: public:
@ -326,7 +326,7 @@ public:
/** /**
* Access function for overlay widgets * Access function for overlay widgets
*/ */
QList<COverlayDockContainer*> overlayWidgets() const; QList<CAutoHideDockContainer*> overlayWidgets() const;
Q_SIGNALS: Q_SIGNALS:
/** /**
@ -339,7 +339,7 @@ Q_SIGNALS:
/** /**
* This signal is emitted, if a new overlay widget has been created. * This signal is emitted, if a new overlay widget has been created.
*/ */
void overlayWidgetCreated(ads::COverlayDockContainer* OverlayWidget); void overlayWidgetCreated(ads::CAutoHideDockContainer* OverlayWidget);
/** /**
* This signal is emitted if one or multiple dock areas has been removed * This signal is emitted if one or multiple dock areas has been removed

View File

@ -26,7 +26,6 @@
#include "DockManager.h" #include "DockManager.h"
#include "DockAreaTitleBar.h" #include "DockAreaTitleBar.h"
#include "DockWidgetSideTab.h" #include "DockWidgetSideTab.h"
#include "OverlayDockContainer.h"
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
#include "linux/FloatingWidgetTitleBar.h" #include "linux/FloatingWidgetTitleBar.h"
@ -189,12 +188,7 @@ void DockFocusControllerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget)
} }
#endif #endif
if (old && old->overlayDockContainer() && old->overlayDockContainer()->isVisible() && old != FocusedDockWidget) if (old == DockWidget && !ForceFocusChangedSignal)
{
old->overlayDockContainer()->collapseView(true);
}
if (old == DockWidget && !ForceFocusChangedSignal)
{ {
return; return;
} }

View File

@ -28,6 +28,7 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <AutoHideDockContainer.h>
#include "DockWidgetTab.h" #include "DockWidgetTab.h"
#include "DockManager.h" #include "DockManager.h"
@ -57,7 +58,6 @@
#include "DockAreaTitleBar.h" #include "DockAreaTitleBar.h"
#include "DockFocusController.h" #include "DockFocusController.h"
#include "DockSplitter.h" #include "DockSplitter.h"
#include "OverlayDockContainer.h"
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
#include "linux/FloatingWidgetTitleBar.h" #include "linux/FloatingWidgetTitleBar.h"
@ -865,13 +865,13 @@ CDockAreaWidget* CDockManager::addDockWidgetToContainer(DockWidgetArea area,
} }
//============================================================================ //============================================================================
COverlayDockContainer* CDockManager::addOverlayDockWidget(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget, CDockWidget::eOverlayInsertOrder insertOrder) CAutoHideDockContainer* CDockManager::addOverlayDockWidget(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget, CDockWidget::eOverlayInsertOrder insertOrder)
{ {
return addOverlayDockWidgetToContainer(area, Dockwidget, this, insertOrder); return addOverlayDockWidgetToContainer(area, Dockwidget, this, insertOrder);
} }
//============================================================================ //============================================================================
COverlayDockContainer* CDockManager::addOverlayDockWidgetToContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget, CDockContainerWidget* DockContainerWidget, CDockWidget::eOverlayInsertOrder insertOrder) CAutoHideDockContainer* CDockManager::addOverlayDockWidgetToContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget, CDockContainerWidget* DockContainerWidget, CDockWidget::eOverlayInsertOrder insertOrder)
{ {
d->DockWidgetsMap.insert(Dockwidget->objectName(), Dockwidget); d->DockWidgetsMap.insert(Dockwidget->objectName(), Dockwidget);
auto container = DockContainerWidget->createAndInitializeDockWidgetOverlayContainer(area, Dockwidget, insertOrder); auto container = DockContainerWidget->createAndInitializeDockWidgetOverlayContainer(area, Dockwidget, insertOrder);

View File

@ -84,7 +84,7 @@ private:
friend class CFloatingDragPreview; friend class CFloatingDragPreview;
friend struct FloatingDragPreviewPrivate; friend struct FloatingDragPreviewPrivate;
friend class CDockAreaTitleBar; friend class CDockAreaTitleBar;
friend class COverlayDockContainer; friend class CAutoHideDockContainer;
protected: protected:
@ -341,14 +341,14 @@ public:
* An overlay widget is used for auto hide functionality * An overlay widget is used for auto hide functionality
* \return Returns the COverlayDockContainer that contains the new DockWidget * \return Returns the COverlayDockContainer that contains the new DockWidget
*/ */
COverlayDockContainer* addOverlayDockWidget(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget, CDockWidget::eOverlayInsertOrder insertOrder = CDockWidget::Last); CAutoHideDockContainer* addOverlayDockWidget(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget, CDockWidget::eOverlayInsertOrder insertOrder = CDockWidget::Last);
/** /**
* Adds dock widget overlayed into the given container based on the CDockWidgetSideTab::SideTabBarArea. * Adds dock widget overlayed into the given container based on the CDockWidgetSideTab::SideTabBarArea.
* An overlay widget is used for auto hide functionality * An overlay widget is used for auto hide functionality
* \return Returns the COverlayDockContainer that contains the new DockWidget * \return Returns the COverlayDockContainer that contains the new DockWidget
*/ */
COverlayDockContainer* addOverlayDockWidgetToContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget, CDockContainerWidget* DockContainerWidget, CDockWidget::eOverlayInsertOrder = CDockWidget::Last); CAutoHideDockContainer* addOverlayDockWidgetToContainer(CDockWidgetSideTab::SideTabBarArea area, CDockWidget* Dockwidget, CDockContainerWidget* DockContainerWidget, CDockWidget::eOverlayInsertOrder = CDockWidget::Last);
/** /**
* This function will add the given Dockwidget to the given dock area as * This function will add the given Dockwidget to the given dock area as

View File

@ -28,6 +28,7 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <AutoHideDockContainer.h>
#include "DockWidgetTab.h" #include "DockWidgetTab.h"
#include "DockWidget.h" #include "DockWidget.h"
@ -59,7 +60,6 @@
#include "DockSplitter.h" #include "DockSplitter.h"
#include "DockComponentsFactory.h" #include "DockComponentsFactory.h"
#include "ads_globals.h" #include "ads_globals.h"
#include "OverlayDockContainer.h"
namespace ads namespace ads
@ -437,7 +437,7 @@ CDockWidgetTab* CDockWidget::tabWidget() const
return d->TabWidget; return d->TabWidget;
} }
COverlayDockContainer* CDockWidget::overlayDockContainer() const CAutoHideDockContainer* CDockWidget::autoHideDockContainer() const
{ {
if (!d->DockArea) if (!d->DockArea)
{ {
@ -1079,15 +1079,16 @@ void CDockWidget::showNormal()
//============================================================================ //============================================================================
void CDockWidget::onDockWidgetSideTabClicked() void CDockWidget::onDockWidgetSideTabClicked()
{ {
const auto overlayContainer = overlayDockContainer(); const auto overlayContainer = autoHideDockContainer();
if (!overlayContainer) if (!overlayContainer)
{ {
return; return;
} }
overlayContainer->raise(); overlayContainer->raise();
const auto shouldCollapse = overlayContainer->isVisible(); //const auto shouldCollapse = overlayContainer->isVisible();
overlayContainer->collapseView(shouldCollapse); //overlayContainer->collapseView(shouldCollapse);
overlayContainer->toggleCollapseState();
if (overlayContainer->isVisible()) if (overlayContainer->isVisible())
{ {
// d->DockManager->setDockWidgetFocused(this) does not // d->DockManager->setDockWidgetFocused(this) does not

View File

@ -47,7 +47,7 @@ class CDockAreaWidget;
class DockContainerWidgetPrivate; class DockContainerWidgetPrivate;
class CFloatingDockContainer; class CFloatingDockContainer;
class CDockWidgetSideTab; class CDockWidgetSideTab;
class COverlayDockContainer; class CAutoHideDockContainer;
/** /**
* The QDockWidget class provides a widget that can be docked inside a * The QDockWidget class provides a widget that can be docked inside a
@ -77,7 +77,7 @@ protected:
friend class CDockWidgetTab; friend class CDockWidgetTab;
friend struct DockWidgetTabPrivate; friend struct DockWidgetTabPrivate;
friend struct DockAreaTitleBarPrivate; friend struct DockAreaTitleBarPrivate;
friend class COverlayDockContainer; friend class CAutoHideDockContainer;
/** /**
* Assigns the dock manager that manages this dock widget * Assigns the dock manager that manages this dock widget
@ -319,7 +319,7 @@ public:
* Returns the overlay dock container of this dock widget * Returns the overlay dock container of this dock widget
* or 0 if there is none * or 0 if there is none
*/ */
COverlayDockContainer* overlayDockContainer() const; CAutoHideDockContainer* autoHideDockContainer() const;
/** /**
* Sets, whether the dock widget is movable, closable, and floatable. * Sets, whether the dock widget is movable, closable, and floatable.

View File

@ -27,6 +27,7 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <AutoHideDockContainer.h>
#include "DockWidgetSideTab.h" #include "DockWidgetSideTab.h"
#include "SideTabBar.h" #include "SideTabBar.h"
@ -37,7 +38,6 @@
#include "ElidingLabel.h" #include "ElidingLabel.h"
#include "DockWidget.h" #include "DockWidget.h"
#include "OverlayDockContainer.h"
namespace ads namespace ads
{ {

View File

@ -57,7 +57,7 @@ private:
DockWidgetSideTabPrivate* d; ///< private data (pimpl) DockWidgetSideTabPrivate* d; ///< private data (pimpl)
friend struct DockWidgetSideTabPrivate; friend struct DockWidgetSideTabPrivate;
friend class CDockWidget; friend class CDockWidget;
friend class COverlayDockContainer; friend class CAutoHideDockContainer;
protected: protected:
friend class CSideTabBar; friend class CSideTabBar;

View File

@ -28,6 +28,7 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <AutoHideDockContainer.h>
#include "FloatingDragPreview.h" #include "FloatingDragPreview.h"
#include "ElidingLabel.h" #include "ElidingLabel.h"
#include "DockWidgetTab.h" #include "DockWidgetTab.h"
@ -51,7 +52,6 @@
#include "DockManager.h" #include "DockManager.h"
#include "IconProvider.h" #include "IconProvider.h"
#include "DockFocusController.h" #include "DockFocusController.h"
#include "OverlayDockContainer.h"
namespace ads namespace ads

View File

@ -58,7 +58,7 @@ private:
friend struct DockWidgetTabPrivate; friend struct DockWidgetTabPrivate;
friend class CDockWidget; friend class CDockWidget;
friend class CDockManager; friend class CDockManager;
friend class COverlayDockContainer; friend class CAutoHideDockContainer;
void onDockWidgetFeaturesChanged(); void onDockWidgetFeaturesChanged();
private Q_SLOTS: private Q_SLOTS:

View File

@ -241,6 +241,7 @@ QString CElidingLabel::text() const
return d->Text; return d->Text;
} }
/** /**
* Private data of public CVerticalElidingLabel * Private data of public CVerticalElidingLabel
*/ */
@ -255,9 +256,11 @@ struct VerticalElidingLabelPrivate
//============================================================================ //============================================================================
VerticalElidingLabelPrivate::VerticalElidingLabelPrivate(CVerticalElidingLabel* _public) VerticalElidingLabelPrivate::VerticalElidingLabelPrivate(CVerticalElidingLabel* _public)
: _this(_public)
{ {
} }
//============================================================================ //============================================================================
CVerticalElidingLabel::CVerticalElidingLabel(QWidget* parent, Qt::WindowFlags f) : CVerticalElidingLabel::CVerticalElidingLabel(QWidget* parent, Qt::WindowFlags f) :
CElidingLabel(parent, f), CElidingLabel(parent, f),
@ -265,6 +268,7 @@ CVerticalElidingLabel::CVerticalElidingLabel(QWidget* parent, Qt::WindowFlags f)
{ {
} }
//============================================================================ //============================================================================
void CVerticalElidingLabel::setOrientation(Qt::Orientation orientation) void CVerticalElidingLabel::setOrientation(Qt::Orientation orientation)
{ {

View File

@ -8,6 +8,7 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <AutoHideDockContainer.h>
#include "FloatingDragPreview.h" #include "FloatingDragPreview.h"
#include <iostream> #include <iostream>
@ -21,7 +22,6 @@
#include "DockManager.h" #include "DockManager.h"
#include "DockContainerWidget.h" #include "DockContainerWidget.h"
#include "DockOverlay.h" #include "DockOverlay.h"
#include "OverlayDockContainer.h"
namespace ads namespace ads
{ {
@ -369,9 +369,9 @@ void CFloatingDragPreview::cleanupOverlayContainerWidget()
{ {
auto DroppedDockWidget = qobject_cast<CDockWidget*>(d->Content); auto DroppedDockWidget = qobject_cast<CDockWidget*>(d->Content);
auto DroppedArea = qobject_cast<CDockAreaWidget*>(d->Content); auto DroppedArea = qobject_cast<CDockAreaWidget*>(d->Content);
if (DroppedDockWidget && DroppedDockWidget->overlayDockContainer()) if (DroppedDockWidget && DroppedDockWidget->autoHideDockContainer())
{ {
DroppedDockWidget->overlayDockContainer()->cleanupAndDelete(); DroppedDockWidget->autoHideDockContainer()->cleanupAndDelete();
} }
if (DroppedArea && DroppedArea->overlayDockContainer()) if (DroppedArea && DroppedArea->overlayDockContainer())
{ {

View File

@ -111,6 +111,8 @@ void CSideTabBar::removeSideTab(CDockWidgetSideTab* SideTab)
//============================================================================ //============================================================================
void CSideTabBar::paintEvent(QPaintEvent* event) void CSideTabBar::paintEvent(QPaintEvent* event)
{ {
Q_UNUSED(event)
QStyleOption option; QStyleOption option;
option.initFrom(this); option.initFrom(this);
QPainter painter(this); QPainter painter(this);

View File

@ -48,7 +48,7 @@ HEADERS += \
IconProvider.h \ IconProvider.h \
DockComponentsFactory.h \ DockComponentsFactory.h \
DockFocusController.h \ DockFocusController.h \
OverlayDockContainer.h \ AutoHideDockContainer.h \
SideTabBar.h \ SideTabBar.h \
DockWidgetSideTab.h DockWidgetSideTab.h
@ -71,7 +71,7 @@ SOURCES += \
IconProvider.cpp \ IconProvider.cpp \
DockComponentsFactory.cpp \ DockComponentsFactory.cpp \
DockFocusController.cpp \ DockFocusController.cpp \
OverlayDockContainer.cpp \ AutoHideDockContainer.cpp \
SideTabBar.cpp \ SideTabBar.cpp \
DockWidgetSideTab.cpp DockWidgetSideTab.cpp