mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +08:00
Moved dock area restore code into CDockAreaWidget
This commit is contained in:
parent
8d670577a9
commit
d1d801cf16
@ -27,14 +27,7 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
#include <AutoHideDockContainer.h>
|
#include "AutoHideDockContainer.h"
|
||||||
#include "DockManager.h"
|
|
||||||
#include "DockWidgetSideTab.h"
|
|
||||||
#include "DockWidgetTab.h"
|
|
||||||
#include "SideTabBar.h"
|
|
||||||
#include "DockAreaWidget.h"
|
|
||||||
#include "DockingStateReader.h"
|
|
||||||
#include "ResizeHandle.h"
|
|
||||||
|
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
@ -43,6 +36,16 @@
|
|||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
#include "DockManager.h"
|
||||||
|
#include "DockWidgetSideTab.h"
|
||||||
|
#include "DockWidgetTab.h"
|
||||||
|
#include "SideTabBar.h"
|
||||||
|
#include "DockAreaWidget.h"
|
||||||
|
#include "DockingStateReader.h"
|
||||||
|
#include "ResizeHandle.h"
|
||||||
|
#include "DockComponentsFactory.h"
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
@ -174,7 +177,7 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, SideBa
|
|||||||
d(new AutoHideDockContainerPrivate(this))
|
d(new AutoHideDockContainerPrivate(this))
|
||||||
{
|
{
|
||||||
d->SideTabBarArea = area;
|
d->SideTabBarArea = area;
|
||||||
d->SideTab = new CDockWidgetSideTab();
|
d->SideTab = componentsFactory()->createDockWidgetSideTab(nullptr);
|
||||||
connect(d->SideTab, &CDockWidgetSideTab::pressed, this, &CAutoHideDockContainer::toggleCollapseState);
|
connect(d->SideTab, &CDockWidgetSideTab::pressed, this, &CAutoHideDockContainer::toggleCollapseState);
|
||||||
d->DockArea = new CDockAreaWidget(DockManager, parent);
|
d->DockArea = new CDockAreaWidget(DockManager, parent);
|
||||||
d->DockArea->setObjectName("autoHideDockArea");
|
d->DockArea->setObjectName("autoHideDockArea");
|
||||||
@ -294,14 +297,7 @@ void CAutoHideDockContainer::addDockWidget(CDockWidget* DockWidget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
d->DockWidget = DockWidget;
|
d->DockWidget = DockWidget;
|
||||||
if (!d->SideTab)
|
d->SideTab->setDockWidget(DockWidget);
|
||||||
{
|
|
||||||
d->SideTab = DockWidget->sideTabWidget();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
d->SideTab->setDockWidget(DockWidget);
|
|
||||||
}
|
|
||||||
CDockAreaWidget* OldDockArea = DockWidget->dockAreaWidget();
|
CDockAreaWidget* OldDockArea = DockWidget->dockAreaWidget();
|
||||||
if (OldDockArea)
|
if (OldDockArea)
|
||||||
{
|
{
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
#include "DockComponentsFactory.h"
|
#include "DockComponentsFactory.h"
|
||||||
#include "DockWidgetTab.h"
|
#include "DockWidgetTab.h"
|
||||||
#include "DockWidgetSideTab.h"
|
#include "DockWidgetSideTab.h"
|
||||||
|
#include "DockingStateReader.h"
|
||||||
|
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
@ -895,6 +896,98 @@ void CDockAreaWidget::saveState(QXmlStreamWriter& s) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
bool CDockAreaWidget::restoreDockArea(CDockingStateReader& s, CDockAreaWidget*& CreatedWidget,
|
||||||
|
bool Testing, CDockContainerWidget* Container)
|
||||||
|
{
|
||||||
|
bool Ok;
|
||||||
|
#ifdef ADS_DEBUG_PRINT
|
||||||
|
int Tabs = s.attributes().value("Tabs").toInt(&Ok);
|
||||||
|
if (!Ok)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QString CurrentDockWidget = s.attributes().value("Current").toString();
|
||||||
|
ADS_PRINT("Restore NodeDockArea Tabs: " << Tabs << " Current: "
|
||||||
|
<< CurrentDockWidget);
|
||||||
|
|
||||||
|
auto DockManager = Container->dockManager();
|
||||||
|
CDockAreaWidget* DockArea = nullptr;
|
||||||
|
if (!Testing)
|
||||||
|
{
|
||||||
|
DockArea = new CDockAreaWidget(DockManager, Container);
|
||||||
|
const auto AllowedAreasAttribute = s.attributes().value("AllowedAreas");
|
||||||
|
if (!AllowedAreasAttribute.isEmpty())
|
||||||
|
{
|
||||||
|
DockArea->setAllowedAreas((DockWidgetArea)AllowedAreasAttribute.toInt(nullptr, 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto FlagsAttribute = s.attributes().value("Flags");
|
||||||
|
if (!FlagsAttribute.isEmpty())
|
||||||
|
{
|
||||||
|
DockArea->setDockAreaFlags((CDockAreaWidget::DockAreaFlags)FlagsAttribute.toInt(nullptr, 16));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (s.readNextStartElement())
|
||||||
|
{
|
||||||
|
if (s.name() != QLatin1String("Widget"))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto ObjectName = s.attributes().value("Name");
|
||||||
|
if (ObjectName.isEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Closed = s.attributes().value("Closed").toInt(&Ok);
|
||||||
|
if (!Ok)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
s.skipCurrentElement();
|
||||||
|
CDockWidget* DockWidget = DockManager->findDockWidget(ObjectName.toString());
|
||||||
|
if (!DockWidget || Testing)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ADS_PRINT("Dock Widget found - parent " << DockWidget->parent());
|
||||||
|
// We hide the DockArea here to prevent the short display (the flashing)
|
||||||
|
// of the dock areas during application startup
|
||||||
|
DockArea->hide();
|
||||||
|
DockArea->addDockWidget(DockWidget);
|
||||||
|
DockWidget->setToggleViewActionChecked(!Closed);
|
||||||
|
DockWidget->setClosedState(Closed);
|
||||||
|
DockWidget->setProperty(internal::ClosedProperty, Closed);
|
||||||
|
DockWidget->setProperty(internal::DirtyProperty, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Testing)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!DockArea->dockWidgetsCount())
|
||||||
|
{
|
||||||
|
delete DockArea;
|
||||||
|
DockArea = nullptr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DockArea->setProperty("currentDockWidget", CurrentDockWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
CreatedWidget = DockArea;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidget* CDockAreaWidget::nextOpenDockWidget(CDockWidget* DockWidget) const
|
CDockWidget* CDockAreaWidget::nextOpenDockWidget(CDockWidget* DockWidget) const
|
||||||
{
|
{
|
||||||
|
@ -46,6 +46,7 @@ class CDockManager;
|
|||||||
class CDockContainerWidget;
|
class CDockContainerWidget;
|
||||||
class DockContainerWidgetPrivate;
|
class DockContainerWidgetPrivate;
|
||||||
class CDockAreaTitleBar;
|
class CDockAreaTitleBar;
|
||||||
|
class CDockingStateReader;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -296,6 +297,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
void saveState(QXmlStreamWriter& Stream) const;
|
void saveState(QXmlStreamWriter& Stream) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restores a dock area.
|
||||||
|
* \see restoreChildNodes() for details
|
||||||
|
*/
|
||||||
|
static bool restoreDockArea(CDockingStateReader& Stream, CDockAreaWidget*& CreatedWidget,
|
||||||
|
bool Testing, CDockContainerWidget* Container);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This functions returns the dock widget features of all dock widget in
|
* This functions returns the dock widget features of all dock widget in
|
||||||
* this area.
|
* this area.
|
||||||
@ -362,6 +370,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool containsCentralWidget() const;
|
bool containsCentralWidget() const;
|
||||||
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* This activates the tab for the given tab index.
|
* This activates the tab for the given tab index.
|
||||||
|
@ -910,23 +910,7 @@ void DockContainerWidgetPrivate::saveAutoHideWidgetsState(QXmlStreamWriter& s)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
s.writeStartElement("SideBar");
|
sideTabBar->saveState(s);
|
||||||
s.writeAttribute("Area", QString::number(sideTabBar->sideTabBarArea()));
|
|
||||||
s.writeAttribute("Tabs", QString::number(sideTabBar->tabCount()));
|
|
||||||
|
|
||||||
for (auto i = 0; i < sideTabBar->tabCount(); ++i)
|
|
||||||
{
|
|
||||||
auto Tab = sideTabBar->tabAt(i);
|
|
||||||
if (!Tab)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto DockArea = Tab->dockWidget()->dockAreaWidget();
|
|
||||||
DockArea->saveState(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
s.writeEndElement();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1049,6 +1033,11 @@ bool DockContainerWidgetPrivate::restoreSplitter(CDockingStateReader& s,
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
bool DockContainerWidgetPrivate::restoreAutoHideDockArea(CDockingStateReader& s, SideBarLocation area, bool Testing)
|
bool DockContainerWidgetPrivate::restoreAutoHideDockArea(CDockingStateReader& s, SideBarLocation area, bool Testing)
|
||||||
{
|
{
|
||||||
|
if (!CDockManager::testConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Ok;
|
bool Ok;
|
||||||
#ifdef ADS_DEBUG_PRINT
|
#ifdef ADS_DEBUG_PRINT
|
||||||
int Tabs = s.attributes().value("Tabs").toInt(&Ok);
|
int Tabs = s.attributes().value("Tabs").toInt(&Ok);
|
||||||
@ -1062,11 +1051,6 @@ bool DockContainerWidgetPrivate::restoreAutoHideDockArea(CDockingStateReader& s,
|
|||||||
ADS_PRINT("Restore NodeDockArea Tabs: " << Tabs << " Current: "
|
ADS_PRINT("Restore NodeDockArea Tabs: " << Tabs << " Current: "
|
||||||
<< CurrentDockWidget);
|
<< CurrentDockWidget);
|
||||||
|
|
||||||
if (!CDockManager::testConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CDockAreaWidget* DockArea = nullptr;
|
CDockAreaWidget* DockArea = nullptr;
|
||||||
CAutoHideDockContainer* AutoHideContainer = nullptr;
|
CAutoHideDockContainer* AutoHideContainer = nullptr;
|
||||||
if (!Testing)
|
if (!Testing)
|
||||||
@ -1136,91 +1120,14 @@ bool DockContainerWidgetPrivate::restoreAutoHideDockArea(CDockingStateReader& s,
|
|||||||
bool DockContainerWidgetPrivate::restoreDockArea(CDockingStateReader& s,
|
bool DockContainerWidgetPrivate::restoreDockArea(CDockingStateReader& s,
|
||||||
QWidget*& CreatedWidget, bool Testing)
|
QWidget*& CreatedWidget, bool Testing)
|
||||||
{
|
{
|
||||||
bool Ok;
|
|
||||||
#ifdef ADS_DEBUG_PRINT
|
|
||||||
int Tabs = s.attributes().value("Tabs").toInt(&Ok);
|
|
||||||
if (!Ok)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QString CurrentDockWidget = s.attributes().value("Current").toString();
|
|
||||||
ADS_PRINT("Restore NodeDockArea Tabs: " << Tabs << " Current: "
|
|
||||||
<< CurrentDockWidget);
|
|
||||||
|
|
||||||
CDockAreaWidget* DockArea = nullptr;
|
CDockAreaWidget* DockArea = nullptr;
|
||||||
if (!Testing)
|
auto Result = CDockAreaWidget::restoreDockArea(s, DockArea, Testing, _this);
|
||||||
|
if (Result && DockArea)
|
||||||
{
|
{
|
||||||
DockArea = new CDockAreaWidget(DockManager, _this);
|
|
||||||
const auto AllowedAreasAttribute = s.attributes().value("AllowedAreas");
|
|
||||||
if (!AllowedAreasAttribute.isEmpty())
|
|
||||||
{
|
|
||||||
DockArea->setAllowedAreas((DockWidgetArea)AllowedAreasAttribute.toInt(nullptr, 16));
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto FlagsAttribute = s.attributes().value("Flags");
|
|
||||||
if (!FlagsAttribute.isEmpty())
|
|
||||||
{
|
|
||||||
DockArea->setDockAreaFlags((CDockAreaWidget::DockAreaFlags)FlagsAttribute.toInt(nullptr, 16));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (s.readNextStartElement())
|
|
||||||
{
|
|
||||||
if (s.name() != QLatin1String("Widget"))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ObjectName = s.attributes().value("Name");
|
|
||||||
if (ObjectName.isEmpty())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Closed = s.attributes().value("Closed").toInt(&Ok);
|
|
||||||
if (!Ok)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
s.skipCurrentElement();
|
|
||||||
CDockWidget* DockWidget = DockManager->findDockWidget(ObjectName.toString());
|
|
||||||
if (!DockWidget || Testing)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ADS_PRINT("Dock Widget found - parent " << DockWidget->parent());
|
|
||||||
// We hide the DockArea here to prevent the short display (the flashing)
|
|
||||||
// of the dock areas during application startup
|
|
||||||
DockArea->hide();
|
|
||||||
DockArea->addDockWidget(DockWidget);
|
|
||||||
DockWidget->setToggleViewActionChecked(!Closed);
|
|
||||||
DockWidget->setClosedState(Closed);
|
|
||||||
DockWidget->setProperty(internal::ClosedProperty, Closed);
|
|
||||||
DockWidget->setProperty(internal::DirtyProperty, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Testing)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DockArea->dockWidgetsCount())
|
|
||||||
{
|
|
||||||
delete DockArea;
|
|
||||||
DockArea = nullptr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DockArea->setProperty("currentDockWidget", CurrentDockWidget);
|
|
||||||
appendDockAreas({DockArea});
|
appendDockAreas({DockArea});
|
||||||
}
|
}
|
||||||
|
|
||||||
CreatedWidget = DockArea;
|
CreatedWidget = DockArea;
|
||||||
return true;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2319,6 +2226,13 @@ QRect CDockContainerWidget::contentRectGlobal() const
|
|||||||
}
|
}
|
||||||
return internal::globalGeometry(d->RootSplitter);
|
return internal::globalGeometry(d->RootSplitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
CDockManager* CDockContainerWidget::dockManager() const
|
||||||
|
{
|
||||||
|
return d->DockManager;
|
||||||
|
}
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -342,6 +342,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
QRect contentRectGlobal() const;
|
QRect contentRectGlobal() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the dock manager that owns this container
|
||||||
|
*/
|
||||||
|
CDockManager* dockManager() const;
|
||||||
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
|
@ -325,10 +325,6 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
|
|||||||
setObjectName(title);
|
setObjectName(title);
|
||||||
|
|
||||||
d->TabWidget = componentsFactory()->createDockWidgetTab(this);
|
d->TabWidget = componentsFactory()->createDockWidgetTab(this);
|
||||||
d->SideTabWidget = componentsFactory()->createDockWidgetSideTab(nullptr);
|
|
||||||
d->SideTabWidget->hide();
|
|
||||||
|
|
||||||
connect(d->SideTabWidget, &CDockWidgetSideTab::pressed, this, &CDockWidget::onDockWidgetSideTabClicked);
|
|
||||||
|
|
||||||
d->ToggleViewAction = new QAction(title, this);
|
d->ToggleViewAction = new QAction(title, this);
|
||||||
d->ToggleViewAction->setCheckable(true);
|
d->ToggleViewAction->setCheckable(true);
|
||||||
@ -346,10 +342,6 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
|
|||||||
CDockWidget::~CDockWidget()
|
CDockWidget::~CDockWidget()
|
||||||
{
|
{
|
||||||
ADS_PRINT("~CDockWidget()");
|
ADS_PRINT("~CDockWidget()");
|
||||||
if (d->SideTabWidget)
|
|
||||||
{
|
|
||||||
delete d->SideTabWidget;
|
|
||||||
}
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,6 +435,8 @@ CDockWidgetTab* CDockWidget::tabWidget() const
|
|||||||
return d->TabWidget;
|
return d->TabWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
CAutoHideDockContainer* CDockWidget::autoHideDockContainer() const
|
CAutoHideDockContainer* CDockWidget::autoHideDockContainer() const
|
||||||
{
|
{
|
||||||
if (!d->DockArea)
|
if (!d->DockArea)
|
||||||
@ -534,6 +528,20 @@ CDockWidgetSideTab* CDockWidget::sideTabWidget() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockWidget::setSideTabWidget(CDockWidgetSideTab* SideTab) const
|
||||||
|
{
|
||||||
|
d->SideTabWidget = SideTab;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
bool CDockWidget::isAutoHide() const
|
||||||
|
{
|
||||||
|
return !d->SideTabWidget.isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CDockWidget::isFloating() const
|
bool CDockWidget::isFloating() const
|
||||||
{
|
{
|
||||||
@ -741,6 +749,10 @@ bool CDockWidget::event(QEvent *e)
|
|||||||
{
|
{
|
||||||
d->TabWidget->setText(title);
|
d->TabWidget->setText(title);
|
||||||
}
|
}
|
||||||
|
if (d->SideTabWidget)
|
||||||
|
{
|
||||||
|
d->SideTabWidget->setText(title);
|
||||||
|
}
|
||||||
if (d->ToggleViewAction)
|
if (d->ToggleViewAction)
|
||||||
{
|
{
|
||||||
d->ToggleViewAction->setText(title);
|
d->ToggleViewAction->setText(title);
|
||||||
@ -791,7 +803,12 @@ void CDockWidget::setTabToolTip(const QString &text)
|
|||||||
void CDockWidget::setIcon(const QIcon& Icon)
|
void CDockWidget::setIcon(const QIcon& Icon)
|
||||||
{
|
{
|
||||||
d->TabWidget->setIcon(Icon);
|
d->TabWidget->setIcon(Icon);
|
||||||
d->SideTabWidget->setIcon(Icon);
|
|
||||||
|
if (d->SideTabWidget)
|
||||||
|
{
|
||||||
|
d->SideTabWidget->setIcon(Icon);
|
||||||
|
}
|
||||||
|
|
||||||
if (!d->ToggleViewAction->isCheckable())
|
if (!d->ToggleViewAction->isCheckable())
|
||||||
{
|
{
|
||||||
d->ToggleViewAction->setIcon(Icon);
|
d->ToggleViewAction->setIcon(Icon);
|
||||||
@ -1082,17 +1099,6 @@ void CDockWidget::showNormal()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
|
||||||
void CDockWidget::onDockWidgetSideTabClicked()
|
|
||||||
{
|
|
||||||
const auto autoHideContainer = autoHideDockContainer();
|
|
||||||
if (!autoHideContainer)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
autoHideContainer->toggleCollapseState();
|
|
||||||
}
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CDockWidget::isFullScreen() const
|
bool CDockWidget::isFullScreen() const
|
||||||
|
@ -315,12 +315,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
CDockWidgetTab* tabWidget() const;
|
CDockWidgetTab* tabWidget() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the auto hide dock container of this dock widget
|
|
||||||
* or 0 if there is none
|
|
||||||
*/
|
|
||||||
CAutoHideDockContainer* autoHideDockContainer() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets, whether the dock widget is movable, closable, and floatable.
|
* Sets, whether the dock widget is movable, closable, and floatable.
|
||||||
*/
|
*/
|
||||||
@ -371,6 +365,22 @@ public:
|
|||||||
*/
|
*/
|
||||||
CDockWidgetSideTab* sideTabWidget() const;
|
CDockWidgetSideTab* sideTabWidget() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign a side tab widget if this dock widget is an auto hide container
|
||||||
|
*/
|
||||||
|
void setSideTabWidget(CDockWidgetSideTab* SideTab) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true, if this dock widget is in an auto hide container
|
||||||
|
*/
|
||||||
|
bool isAutoHide() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the auto hide dock container of this dock widget
|
||||||
|
* or 0 if there is none
|
||||||
|
*/
|
||||||
|
CAutoHideDockContainer* autoHideDockContainer() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This property holds whether the dock widget is floating.
|
* This property holds whether the dock widget is floating.
|
||||||
* A dock widget is only floating, if it is the one and only widget inside
|
* A dock widget is only floating, if it is the one and only widget inside
|
||||||
@ -613,10 +623,6 @@ public Q_SLOTS:
|
|||||||
*/
|
*/
|
||||||
void showNormal();
|
void showNormal();
|
||||||
|
|
||||||
/**
|
|
||||||
* Toggles the dock auto hide container when the side tab is clicked
|
|
||||||
*/
|
|
||||||
void onDockWidgetSideTabClicked();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
|
@ -205,6 +205,7 @@ void CDockWidgetSideTab::setDockWidget(CDockWidget* DockWidget)
|
|||||||
}
|
}
|
||||||
d->DockWidget = DockWidget;
|
d->DockWidget = DockWidget;
|
||||||
setText(DockWidget->windowTitle());
|
setText(DockWidget->windowTitle());
|
||||||
|
setIcon(d->DockWidget->icon());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,14 @@
|
|||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QStyleOption>
|
#include <QStyleOption>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
#include "DockContainerWidget.h"
|
#include "DockContainerWidget.h"
|
||||||
#include "DockWidgetSideTab.h"
|
#include "DockWidgetSideTab.h"
|
||||||
#include "DockWidgetTab.h"
|
#include "DockWidgetTab.h"
|
||||||
#include "DockFocusController.h"
|
#include "DockFocusController.h"
|
||||||
#include "AutoHideDockContainer.h"
|
#include "AutoHideDockContainer.h"
|
||||||
|
#include "DockAreaWidget.h"
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
@ -274,4 +276,31 @@ SideBarLocation CSideTabBar::sideTabBarArea() const
|
|||||||
return d->SideTabArea;
|
return d->SideTabArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CSideTabBar::saveState(QXmlStreamWriter& s) const
|
||||||
|
{
|
||||||
|
if (!tabCount())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
s.writeStartElement("SideBar");
|
||||||
|
s.writeAttribute("Area", QString::number(sideTabBarArea()));
|
||||||
|
s.writeAttribute("Tabs", QString::number(tabCount()));
|
||||||
|
|
||||||
|
for (auto i = 0; i < tabCount(); ++i)
|
||||||
|
{
|
||||||
|
auto Tab = tabAt(i);
|
||||||
|
if (!Tab)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto DockArea = Tab->dockWidget()->dockAreaWidget();
|
||||||
|
DockArea->saveState(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
s.writeEndElement();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,12 @@
|
|||||||
#include "DockWidgetSideTab.h"
|
#include "DockWidgetSideTab.h"
|
||||||
#include "ads_globals.h"
|
#include "ads_globals.h"
|
||||||
|
|
||||||
|
class QXmlStreamWriter;
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
struct SideTabBarPrivate;
|
struct SideTabBarPrivate;
|
||||||
|
class DockContainerWidgetPrivate;
|
||||||
class CDockContainerWidget;
|
class CDockContainerWidget;
|
||||||
class CDockWidgetSideTab;
|
class CDockWidgetSideTab;
|
||||||
class CAutoHideDockContainer;
|
class CAutoHideDockContainer;
|
||||||
@ -57,12 +60,18 @@ private:
|
|||||||
SideTabBarPrivate* d; ///< private data (pimpl)
|
SideTabBarPrivate* d; ///< private data (pimpl)
|
||||||
friend struct SideTabBarPrivate;
|
friend struct SideTabBarPrivate;
|
||||||
friend class DockWidgetSideTab;
|
friend class DockWidgetSideTab;
|
||||||
|
friend DockContainerWidgetPrivate;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paintEvent(QPaintEvent* event) override;
|
virtual void paintEvent(QPaintEvent* event) override;
|
||||||
virtual bool event(QEvent* e) override;
|
virtual bool event(QEvent* e) override;
|
||||||
virtual bool eventFilter(QObject *watched, QEvent *event) override;
|
virtual bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the state into the given stream
|
||||||
|
*/
|
||||||
|
void saveState(QXmlStreamWriter& Stream) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Super = QFrame;
|
using Super = QFrame;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user