mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-04-20 20:34:45 +08:00
Fix formatting#2 (#663)
This commit is contained in:
parent
2878559ee6
commit
8cfa5c8e0e
@ -16,6 +16,7 @@
|
|||||||
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
/// \file AutoHideDockContainer.cpp
|
/// \file AutoHideDockContainer.cpp
|
||||||
/// \author Syarif Fakhri
|
/// \author Syarif Fakhri
|
||||||
@ -28,23 +29,23 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
#include "AutoHideDockContainer.h"
|
#include "AutoHideDockContainer.h"
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QBoxLayout>
|
|
||||||
#include <QCursor>
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QPointer>
|
|
||||||
#include <QSplitter>
|
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
|
#include <QBoxLayout>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QSplitter>
|
||||||
|
#include <QPointer>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QCursor>
|
||||||
|
|
||||||
#include <iostream>
|
#include "DockManager.h"
|
||||||
|
#include "DockAreaWidget.h"
|
||||||
|
#include "ResizeHandle.h"
|
||||||
|
#include "DockComponentsFactory.h"
|
||||||
#include "AutoHideSideBar.h"
|
#include "AutoHideSideBar.h"
|
||||||
#include "AutoHideTab.h"
|
#include "AutoHideTab.h"
|
||||||
#include "DockAreaWidget.h"
|
|
||||||
#include "DockComponentsFactory.h"
|
|
||||||
#include "DockManager.h"
|
#include <iostream>
|
||||||
#include "ResizeHandle.h"
|
|
||||||
#include "ads_globals.h"
|
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
@ -59,12 +60,14 @@ bool static isHorizontalArea(SideBarLocation Area)
|
|||||||
case SideBarLocation::SideBarBottom: return true;
|
case SideBarLocation::SideBarBottom: return true;
|
||||||
case SideBarLocation::SideBarLeft:
|
case SideBarLocation::SideBarLeft:
|
||||||
case SideBarLocation::SideBarRight: return false;
|
case SideBarLocation::SideBarRight: return false;
|
||||||
default: return true;
|
default:
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
Qt::Edge static edgeFromSideTabBarArea(SideBarLocation Area)
|
Qt::Edge static edgeFromSideTabBarArea(SideBarLocation Area)
|
||||||
{
|
{
|
||||||
@ -74,12 +77,14 @@ Qt::Edge static edgeFromSideTabBarArea(SideBarLocation Area)
|
|||||||
case SideBarLocation::SideBarBottom: return Qt::TopEdge;
|
case SideBarLocation::SideBarBottom: return Qt::TopEdge;
|
||||||
case SideBarLocation::SideBarLeft: return Qt::RightEdge;
|
case SideBarLocation::SideBarLeft: return Qt::RightEdge;
|
||||||
case SideBarLocation::SideBarRight: return Qt::LeftEdge;
|
case SideBarLocation::SideBarRight: return Qt::LeftEdge;
|
||||||
default: return Qt::LeftEdge;
|
default:
|
||||||
|
return Qt::LeftEdge;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Qt::LeftEdge;
|
return Qt::LeftEdge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
int resizeHandleLayoutPosition(SideBarLocation Area)
|
int resizeHandleLayoutPosition(SideBarLocation Area)
|
||||||
{
|
{
|
||||||
@ -91,12 +96,14 @@ int resizeHandleLayoutPosition(SideBarLocation Area)
|
|||||||
case SideBarLocation::SideBarTop:
|
case SideBarLocation::SideBarTop:
|
||||||
case SideBarLocation::SideBarLeft: return 1;
|
case SideBarLocation::SideBarLeft: return 1;
|
||||||
|
|
||||||
default: return 0;
|
default:
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data of CAutoHideDockContainer - pimpl
|
* Private data of CAutoHideDockContainer - pimpl
|
||||||
*/
|
*/
|
||||||
@ -115,7 +122,7 @@ struct AutoHideDockContainerPrivate
|
|||||||
/**
|
/**
|
||||||
* Private data constructor
|
* Private data constructor
|
||||||
*/
|
*/
|
||||||
AutoHideDockContainerPrivate(CAutoHideDockContainer* _public);
|
AutoHideDockContainerPrivate(CAutoHideDockContainer *_public);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience function to get a dock widget area
|
* Convenience function to get a dock widget area
|
||||||
@ -128,7 +135,8 @@ struct AutoHideDockContainerPrivate
|
|||||||
case SideBarLocation::SideBarRight: return RightDockWidgetArea;
|
case SideBarLocation::SideBarRight: return RightDockWidgetArea;
|
||||||
case SideBarLocation::SideBarBottom: return BottomDockWidgetArea;
|
case SideBarLocation::SideBarBottom: return BottomDockWidgetArea;
|
||||||
case SideBarLocation::SideBarTop: return TopDockWidgetArea;
|
case SideBarLocation::SideBarTop: return TopDockWidgetArea;
|
||||||
default: return LeftDockWidgetArea;
|
default:
|
||||||
|
return LeftDockWidgetArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
return LeftDockWidgetArea;
|
return LeftDockWidgetArea;
|
||||||
@ -140,16 +148,18 @@ struct AutoHideDockContainerPrivate
|
|||||||
void updateResizeHandleSizeLimitMax()
|
void updateResizeHandleSizeLimitMax()
|
||||||
{
|
{
|
||||||
auto Rect = _this->dockContainer()->contentRect();
|
auto Rect = _this->dockContainer()->contentRect();
|
||||||
const auto maxResizeHandleSize =
|
const auto maxResizeHandleSize = ResizeHandle->orientation() == Qt::Horizontal
|
||||||
ResizeHandle->orientation() == Qt::Horizontal ? Rect.width() :
|
? Rect.width() : Rect.height();
|
||||||
Rect.height();
|
|
||||||
ResizeHandle->setMaxResizeSize(maxResizeHandleSize - ResizeMargin);
|
ResizeHandle->setMaxResizeSize(maxResizeHandleSize - ResizeMargin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience function to check, if this is an horizontal area
|
* Convenience function to check, if this is an horizontal area
|
||||||
*/
|
*/
|
||||||
bool isHorizontal() const { return isHorizontalArea(SideTabBarArea); }
|
bool isHorizontal() const
|
||||||
|
{
|
||||||
|
return isHorizontalArea(SideTabBarArea);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forward this event to the dock container
|
* Forward this event to the dock container
|
||||||
@ -165,11 +175,15 @@ struct AutoHideDockContainerPrivate
|
|||||||
|
|
||||||
}; // struct AutoHideDockContainerPrivate
|
}; // struct AutoHideDockContainerPrivate
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
AutoHideDockContainerPrivate::AutoHideDockContainerPrivate(
|
AutoHideDockContainerPrivate::AutoHideDockContainerPrivate(
|
||||||
CAutoHideDockContainer* _public)
|
CAutoHideDockContainer *_public) :
|
||||||
: _this(_public)
|
_this(_public)
|
||||||
{}
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockContainerWidget* CAutoHideDockContainer::dockContainer() const
|
CDockContainerWidget* CAutoHideDockContainer::dockContainer() const
|
||||||
@ -177,32 +191,29 @@ CDockContainerWidget* CAutoHideDockContainer::dockContainer() const
|
|||||||
return internal::findParent<CDockContainerWidget*>(this);
|
return internal::findParent<CDockContainerWidget*>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget,
|
CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget, SideBarLocation area, CDockContainerWidget* parent) :
|
||||||
SideBarLocation area,
|
Super(parent),
|
||||||
CDockContainerWidget* parent)
|
d(new AutoHideDockContainerPrivate(this))
|
||||||
: Super(parent), d(new AutoHideDockContainerPrivate(this))
|
|
||||||
{
|
{
|
||||||
hide(); // auto hide dock container is initially always hidden
|
hide(); // auto hide dock container is initially always hidden
|
||||||
d->SideTabBarArea = area;
|
d->SideTabBarArea = area;
|
||||||
d->SideTab = componentsFactory()->createDockWidgetSideTab(nullptr);
|
d->SideTab = componentsFactory()->createDockWidgetSideTab(nullptr);
|
||||||
connect(d->SideTab, &CAutoHideTab::pressed, this,
|
connect(d->SideTab, &CAutoHideTab::pressed, this, &CAutoHideDockContainer::toggleCollapseState);
|
||||||
&CAutoHideDockContainer::toggleCollapseState);
|
|
||||||
d->DockArea = new CDockAreaWidget(DockWidget->dockManager(), parent);
|
d->DockArea = new CDockAreaWidget(DockWidget->dockManager(), parent);
|
||||||
d->DockArea->setObjectName("autoHideDockArea");
|
d->DockArea->setObjectName("autoHideDockArea");
|
||||||
d->DockArea->setAutoHideDockContainer(this);
|
d->DockArea->setAutoHideDockContainer(this);
|
||||||
|
|
||||||
setObjectName("autoHideDockContainer");
|
setObjectName("autoHideDockContainer");
|
||||||
|
|
||||||
d->Layout = new QBoxLayout(isHorizontalArea(area) ? QBoxLayout::TopToBottom :
|
d->Layout = new QBoxLayout(isHorizontalArea(area) ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight);
|
||||||
QBoxLayout::LeftToRight);
|
|
||||||
d->Layout->setContentsMargins(0, 0, 0, 0);
|
d->Layout->setContentsMargins(0, 0, 0, 0);
|
||||||
d->Layout->setSpacing(0);
|
d->Layout->setSpacing(0);
|
||||||
setLayout(d->Layout);
|
setLayout(d->Layout);
|
||||||
d->ResizeHandle = new CResizeHandle(edgeFromSideTabBarArea(area), this);
|
d->ResizeHandle = new CResizeHandle(edgeFromSideTabBarArea(area), this);
|
||||||
d->ResizeHandle->setMinResizeSize(64);
|
d->ResizeHandle->setMinResizeSize(64);
|
||||||
bool OpaqueResize =
|
bool OpaqueResize = CDockManager::testConfigFlag(CDockManager::OpaqueSplitterResize);
|
||||||
CDockManager::testConfigFlag(CDockManager::OpaqueSplitterResize);
|
|
||||||
d->ResizeHandle->setOpaqueResize(OpaqueResize);
|
d->ResizeHandle->setOpaqueResize(OpaqueResize);
|
||||||
d->Size = d->DockArea->size();
|
d->Size = d->DockArea->size();
|
||||||
d->SizeCache = DockWidget->size();
|
d->SizeCache = DockWidget->size();
|
||||||
@ -212,12 +223,12 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget,
|
|||||||
// The dock area should not be added to the layout before it contains the
|
// The dock area should not be added to the layout before it contains the
|
||||||
// dock widget. If you add it to the layout before it contains the dock widget
|
// dock widget. If you add it to the layout before it contains the dock widget
|
||||||
// then you will likely see this warning for OpenGL widgets or QAxWidgets:
|
// then you will likely see this warning for OpenGL widgets or QAxWidgets:
|
||||||
// setGeometry: Unable to set geometry XxY+Width+Height on
|
// setGeometry: Unable to set geometry XxY+Width+Height on QWidgetWindow/'WidgetClassWindow
|
||||||
// QWidgetWindow/'WidgetClassWindow
|
|
||||||
d->Layout->addWidget(d->DockArea);
|
d->Layout->addWidget(d->DockArea);
|
||||||
d->Layout->insertWidget(resizeHandleLayoutPosition(area), d->ResizeHandle);
|
d->Layout->insertWidget(resizeHandleLayoutPosition(area), d->ResizeHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideDockContainer::updateSize()
|
void CAutoHideDockContainer::updateSize()
|
||||||
{
|
{
|
||||||
@ -231,8 +242,7 @@ void CAutoHideDockContainer::updateSize()
|
|||||||
switch (sideBarLocation())
|
switch (sideBarLocation())
|
||||||
{
|
{
|
||||||
case SideBarLocation::SideBarTop:
|
case SideBarLocation::SideBarTop:
|
||||||
resize(rect.width(),
|
resize(rect.width(), qMin(rect.height() - ResizeMargin, d->Size.height()));
|
||||||
qMin(rect.height() - ResizeMargin, d->Size.height()));
|
|
||||||
move(rect.topLeft());
|
move(rect.topLeft());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -252,15 +262,15 @@ void CAutoHideDockContainer::updateSize()
|
|||||||
|
|
||||||
case SideBarLocation::SideBarBottom:
|
case SideBarLocation::SideBarBottom:
|
||||||
{
|
{
|
||||||
resize(rect.width(),
|
resize(rect.width(), qMin(rect.height() - ResizeMargin, d->Size.height()));
|
||||||
qMin(rect.height() - ResizeMargin, d->Size.height()));
|
|
||||||
QPoint p = rect.bottomLeft();
|
QPoint p = rect.bottomLeft();
|
||||||
p.ry() -= (height() - 1);
|
p.ry() -= (height() - 1);
|
||||||
move(p);
|
move(p);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orientation() == Qt::Horizontal)
|
if (orientation() == Qt::Horizontal)
|
||||||
@ -303,17 +313,18 @@ CAutoHideSideBar* CAutoHideDockContainer::autoHideSideBar() const
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto DockContainer = dockContainer();
|
auto DockContainer = dockContainer();
|
||||||
return DockContainer ? DockContainer->autoHideSideBar(d->SideTabBarArea) :
|
return DockContainer ? DockContainer->autoHideSideBar(d->SideTabBarArea) : nullptr;
|
||||||
nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CAutoHideTab* CAutoHideDockContainer::autoHideTab() const
|
CAutoHideTab* CAutoHideDockContainer::autoHideTab() const
|
||||||
{
|
{
|
||||||
return d->SideTab;
|
return d->SideTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidget* CAutoHideDockContainer::dockWidget() const
|
CDockWidget* CAutoHideDockContainer::dockWidget() const
|
||||||
{
|
{
|
||||||
@ -349,12 +360,14 @@ void CAutoHideDockContainer::addDockWidget(CDockWidget* DockWidget)
|
|||||||
d->DockArea->resize(size());
|
d->DockArea->resize(size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
SideBarLocation CAutoHideDockContainer::sideBarLocation() const
|
SideBarLocation CAutoHideDockContainer::sideBarLocation() const
|
||||||
{
|
{
|
||||||
return d->SideTabBarArea;
|
return d->SideTabBarArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideDockContainer::setSideBarLocation(SideBarLocation SideBarLocation)
|
void CAutoHideDockContainer::setSideBarLocation(SideBarLocation SideBarLocation)
|
||||||
{
|
{
|
||||||
@ -365,15 +378,13 @@ void CAutoHideDockContainer::setSideBarLocation(SideBarLocation SideBarLocation)
|
|||||||
|
|
||||||
d->SideTabBarArea = SideBarLocation;
|
d->SideTabBarArea = SideBarLocation;
|
||||||
d->Layout->removeWidget(d->ResizeHandle);
|
d->Layout->removeWidget(d->ResizeHandle);
|
||||||
d->Layout->setDirection(isHorizontalArea(SideBarLocation) ?
|
d->Layout->setDirection(isHorizontalArea(SideBarLocation) ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight);
|
||||||
QBoxLayout::TopToBottom :
|
d->Layout->insertWidget(resizeHandleLayoutPosition(SideBarLocation), d->ResizeHandle);
|
||||||
QBoxLayout::LeftToRight);
|
|
||||||
d->Layout->insertWidget(resizeHandleLayoutPosition(SideBarLocation),
|
|
||||||
d->ResizeHandle);
|
|
||||||
d->ResizeHandle->setHandlePosition(edgeFromSideTabBarArea(SideBarLocation));
|
d->ResizeHandle->setHandlePosition(edgeFromSideTabBarArea(SideBarLocation));
|
||||||
internal::repolishStyle(this, internal::RepolishDirectChildren);
|
internal::repolishStyle(this, internal::RepolishDirectChildren);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockAreaWidget* CAutoHideDockContainer::dockAreaWidget() const
|
CDockAreaWidget* CAutoHideDockContainer::dockAreaWidget() const
|
||||||
{
|
{
|
||||||
@ -389,16 +400,17 @@ void CAutoHideDockContainer::moveContentsToParent()
|
|||||||
// to the user and he does not have to search where the widget was inserted.
|
// to the user and he does not have to search where the widget was inserted.
|
||||||
d->DockWidget->setDockArea(nullptr);
|
d->DockWidget->setDockArea(nullptr);
|
||||||
auto DockContainer = dockContainer();
|
auto DockContainer = dockContainer();
|
||||||
DockContainer->addDockWidget(d->getDockWidgetArea(d->SideTabBarArea),
|
DockContainer->addDockWidget(d->getDockWidgetArea(d->SideTabBarArea), d->DockWidget);
|
||||||
d->DockWidget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideDockContainer::cleanupAndDelete()
|
void CAutoHideDockContainer::cleanupAndDelete()
|
||||||
{
|
{
|
||||||
const auto dockWidget = d->DockWidget;
|
const auto dockWidget = d->DockWidget;
|
||||||
if (dockWidget)
|
if (dockWidget)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto SideTab = d->SideTab;
|
auto SideTab = d->SideTab;
|
||||||
SideTab->removeFromSideBar();
|
SideTab->removeFromSideBar();
|
||||||
SideTab->setParent(nullptr);
|
SideTab->setParent(nullptr);
|
||||||
@ -409,19 +421,18 @@ void CAutoHideDockContainer::cleanupAndDelete()
|
|||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideDockContainer::saveState(QXmlStreamWriter& s)
|
void CAutoHideDockContainer::saveState(QXmlStreamWriter& s)
|
||||||
{
|
{
|
||||||
s.writeStartElement("Widget");
|
s.writeStartElement("Widget");
|
||||||
s.writeAttribute("Name", d->DockWidget->objectName());
|
s.writeAttribute("Name", d->DockWidget->objectName());
|
||||||
s.writeAttribute("Closed",
|
s.writeAttribute("Closed", QString::number(d->DockWidget->isClosed() ? 1 : 0));
|
||||||
QString::number(d->DockWidget->isClosed() ? 1 : 0));
|
s.writeAttribute("Size", QString::number(d->isHorizontal() ? d->Size.height() : d->Size.width()));
|
||||||
s.writeAttribute(
|
|
||||||
"Size",
|
|
||||||
QString::number(d->isHorizontal() ? d->Size.height() : d->Size.width()));
|
|
||||||
s.writeEndElement();
|
s.writeEndElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideDockContainer::toggleView(bool Enable)
|
void CAutoHideDockContainer::toggleView(bool Enable)
|
||||||
{
|
{
|
||||||
@ -443,6 +454,7 @@ void CAutoHideDockContainer::toggleView(bool Enable)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideDockContainer::collapseView(bool Enable)
|
void CAutoHideDockContainer::collapseView(bool Enable)
|
||||||
{
|
{
|
||||||
@ -465,12 +477,14 @@ void CAutoHideDockContainer::collapseView(bool Enable)
|
|||||||
d->SideTab->updateStyle();
|
d->SideTab->updateStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideDockContainer::toggleCollapseState()
|
void CAutoHideDockContainer::toggleCollapseState()
|
||||||
{
|
{
|
||||||
collapseView(isVisible());
|
collapseView(isVisible());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideDockContainer::setSize(int Size)
|
void CAutoHideDockContainer::setSize(int Size)
|
||||||
{
|
{
|
||||||
@ -486,6 +500,7 @@ void CAutoHideDockContainer::setSize(int Size)
|
|||||||
updateSize();
|
updateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
/**
|
/**
|
||||||
* Returns true if the object given in ancestor is an ancestor of the object
|
* Returns true if the object given in ancestor is an ancestor of the object
|
||||||
@ -508,12 +523,13 @@ static bool objectIsAncestorOf(const QObject* descendant, const QObject* ancesto
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
/**
|
/**
|
||||||
* Returns true if the object given in ancestor is the object given in descendant
|
* Returns true if the object given in ancestor is the object given in descendant
|
||||||
* or if it is an ancestor of the object given in descendant
|
* or if it is an ancestor of the object given in descendant
|
||||||
*/
|
*/
|
||||||
static bool isObjectOrAncestor(const QObject* descendant, const QObject* ancestor)
|
static bool isObjectOrAncestor(const QObject *descendant, const QObject *ancestor)
|
||||||
{
|
{
|
||||||
if (ancestor && (descendant == ancestor))
|
if (ancestor && (descendant == ancestor))
|
||||||
{
|
{
|
||||||
@ -525,6 +541,7 @@ static bool isObjectOrAncestor(const QObject* descendant, const QObject* ancesto
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
|
bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
|
||||||
{
|
{
|
||||||
@ -548,8 +565,8 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
|
|||||||
|
|
||||||
// Now check, if the user clicked into the side tab and ignore this 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
|
// because the side tab click handler will call collapseView(). If we
|
||||||
// do not ignore this here, then we will collapse the container and the
|
// do not ignore this here, then we will collapse the container and the side tab
|
||||||
// side tab click handler will uncollapse it
|
// click handler will uncollapse it
|
||||||
if (widget == d->SideTab.data())
|
if (widget == d->SideTab.data())
|
||||||
{
|
{
|
||||||
return Super::eventFilter(watched, event);
|
return Super::eventFilter(watched, event);
|
||||||
@ -557,8 +574,8 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
|
|||||||
|
|
||||||
// Now we check, if the user clicked inside of this auto hide container.
|
// 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
|
// If the click is inside of this auto hide container, then we can
|
||||||
// ignore the event, because the auto hide overlay should not get
|
// ignore the event, because the auto hide overlay should not get collapsed if
|
||||||
// collapsed if user works in it
|
// user works in it
|
||||||
if (isObjectOrAncestor(widget, this))
|
if (isObjectOrAncestor(widget, this))
|
||||||
{
|
{
|
||||||
return Super::eventFilter(watched, event);
|
return Super::eventFilter(watched, event);
|
||||||
@ -591,6 +608,7 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
|
|||||||
return Super::eventFilter(watched, event);
|
return Super::eventFilter(watched, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideDockContainer::resizeEvent(QResizeEvent* event)
|
void CAutoHideDockContainer::resizeEvent(QResizeEvent* event)
|
||||||
{
|
{
|
||||||
@ -602,8 +620,9 @@ void CAutoHideDockContainer::resizeEvent(QResizeEvent* event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideDockContainer::leaveEvent(QEvent* event)
|
void CAutoHideDockContainer::leaveEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
// Resizing of the dock container via the resize handle in non opaque mode
|
// Resizing of the dock container via the resize handle in non opaque mode
|
||||||
// mays cause a leave event that is not really a leave event. Therefore
|
// mays cause a leave event that is not really a leave event. Therefore
|
||||||
@ -616,17 +635,23 @@ void CAutoHideDockContainer::leaveEvent(QEvent* event)
|
|||||||
Super::leaveEvent(event);
|
Super::leaveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CAutoHideDockContainer::event(QEvent* event)
|
bool CAutoHideDockContainer::event(QEvent* event)
|
||||||
{
|
{
|
||||||
switch (event->type())
|
switch (event->type())
|
||||||
{
|
{
|
||||||
case QEvent::Enter:
|
case QEvent::Enter:
|
||||||
case QEvent::Hide: d->forwardEventToDockContainer(event); break;
|
case QEvent::Hide:
|
||||||
|
d->forwardEventToDockContainer(event);
|
||||||
|
break;
|
||||||
|
|
||||||
case QEvent::MouseButtonPress: return true; break;
|
case QEvent::MouseButtonPress:
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
|
||||||
default: break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Super::event(event);
|
return Super::event(event);
|
||||||
@ -645,11 +670,11 @@ void CAutoHideDockContainer::dragLeaveEvent(QDragLeaveEvent*)
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
Qt::Orientation CAutoHideDockContainer::orientation() const
|
Qt::Orientation CAutoHideDockContainer::orientation() const
|
||||||
{
|
{
|
||||||
return ads::internal::isHorizontalSideBarLocation(d->SideTabBarArea) ?
|
return ads::internal::isHorizontalSideBarLocation(d->SideTabBarArea)
|
||||||
Qt::Horizontal :
|
? Qt::Horizontal : Qt::Vertical;
|
||||||
Qt::Vertical;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideDockContainer::resetToInitialDockWidgetSize()
|
void CAutoHideDockContainer::resetToInitialDockWidgetSize()
|
||||||
{
|
{
|
||||||
@ -663,9 +688,10 @@ void CAutoHideDockContainer::resetToInitialDockWidgetSize()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideDockContainer::moveToNewSideBarLocation(
|
void CAutoHideDockContainer::moveToNewSideBarLocation(SideBarLocation NewSideBarLocation,
|
||||||
SideBarLocation NewSideBarLocation, int TabIndex)
|
int TabIndex)
|
||||||
{
|
{
|
||||||
if (NewSideBarLocation == sideBarLocation() && TabIndex == this->tabIndex())
|
if (NewSideBarLocation == sideBarLocation() && TabIndex == this->tabIndex())
|
||||||
{
|
{
|
||||||
@ -684,10 +710,11 @@ void CAutoHideDockContainer::moveToNewSideBarLocation(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
int CAutoHideDockContainer::tabIndex() const
|
int CAutoHideDockContainer::tabIndex() const
|
||||||
{
|
{
|
||||||
return d->SideTab->tabIndex();
|
return d->SideTab->tabIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ads
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user