mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
Removed wrong visibility initialisation of titlebar close button, added hideEmptyParentSplitters() function to properly hide tree of empty parent splitters if DockArea or DockWidget is removed,
This commit is contained in:
parent
87e3777e37
commit
653f475e72
@ -158,9 +158,6 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
TopLayout->addWidget(CloseButton, 0);
|
||||
_this->connect(CloseButton, SIGNAL(clicked()), SLOT(onCloseButtonClicked()));
|
||||
|
||||
CloseButton->setEnabled(testConfigFlag(CDockManager::DockAreaHasCloseButton));
|
||||
CloseButton->setVisible(CloseButton->isEnabled());
|
||||
}
|
||||
|
||||
|
||||
|
@ -458,16 +458,9 @@ void CDockAreaWidget::hideAreaWithNoVisibleContent()
|
||||
{
|
||||
this->toggleView(false);
|
||||
|
||||
// Hide empty parent splitter
|
||||
// Hide empty parent splitters
|
||||
auto Splitter = internal::findParent<CDockSplitter*>(this);
|
||||
while (Splitter && Splitter->isVisible())
|
||||
{
|
||||
if (!Splitter->hasVisibleContent())
|
||||
{
|
||||
Splitter->hide();
|
||||
}
|
||||
Splitter = internal::findParent<CDockSplitter*>(Splitter);
|
||||
}
|
||||
internal::hideEmptyParentSplitters(Splitter);
|
||||
|
||||
//Hide empty floating widget
|
||||
CDockContainerWidget* Container = this->dockContainer();
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include "ads_globals.h"
|
||||
#include "DockSplitter.h"
|
||||
|
||||
#include <QElapsedTimer>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace ads
|
||||
@ -755,9 +755,13 @@ void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget)
|
||||
{
|
||||
qDebug("%sSplitter %s v: %s c: %s",
|
||||
(const char*)buf,
|
||||
(Splitter->orientation() == Qt::Vertical) ? "-" : "|",
|
||||
Splitter->isVisibleTo(Splitter->parentWidget()) ? "1" : "0",
|
||||
(Splitter->orientation() == Qt::Vertical) ? "--" : "|",
|
||||
Splitter->isHidden() ? " " : "v",
|
||||
QString::number(Splitter->count()).toStdString().c_str());
|
||||
std::cout << (const char*)buf << "Splitter "
|
||||
<< ((Splitter->orientation() == Qt::Vertical) ? "--" : "|") << " "
|
||||
<< (Splitter->isHidden() ? " " : "v") << " "
|
||||
<< QString::number(Splitter->count()).toStdString() << std::endl;
|
||||
for (int i = 0; i < Splitter->count(); ++i)
|
||||
{
|
||||
dumpRecursive(level + 1, Splitter->widget(i));
|
||||
@ -771,6 +775,19 @@ void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget)
|
||||
return;
|
||||
}
|
||||
qDebug("%sDockArea", (const char*)buf);
|
||||
std::cout << (const char*)buf
|
||||
<< (DockArea->isHidden() ? " " : "v")
|
||||
<< (DockArea->openDockWidgetsCount() > 0 ? " " : "c")
|
||||
<< " DockArea" << std::endl;
|
||||
buf.fill(' ', (level + 1) * 4);
|
||||
for (int i = 0; i < DockArea->dockWidgetsCount(); ++i)
|
||||
{
|
||||
std::cout << (const char*)buf << (i == DockArea->currentIndex() ? "*" : " ");
|
||||
CDockWidget* DockWidget = DockArea->dockWidget(i);
|
||||
std::cout << (DockWidget->isHidden() ? " " : "v");
|
||||
std::cout << (DockWidget->isClosed() ? "c" : " ") << " ";
|
||||
std::cout << DockWidget->windowTitle().toStdString() << std::endl;
|
||||
}
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(level);
|
||||
@ -922,10 +939,10 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
||||
d->DockAreas.removeAll(area);
|
||||
CDockSplitter* Splitter = internal::findParent<CDockSplitter*>(area);
|
||||
|
||||
// Remove are from parent splitter and hide splitter if it has no visible
|
||||
// content
|
||||
// Remove are from parent splitter and recursively hide tree of parent
|
||||
// splitters if it has no visible content
|
||||
area->setParent(0);
|
||||
Splitter->setVisible(Splitter->hasVisibleContent());
|
||||
internal::hideEmptyParentSplitters(Splitter);
|
||||
|
||||
// If splitter has more than 1 widgets, we are finished and can leave
|
||||
if (Splitter->count() > 1)
|
||||
@ -1040,9 +1057,6 @@ int CDockContainerWidget::visibleDockAreaCount() const
|
||||
void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWidget,
|
||||
const QPoint& TargetPos)
|
||||
{
|
||||
QElapsedTimer Timer;
|
||||
Timer.start();
|
||||
|
||||
qDebug() << "CDockContainerWidget::dropFloatingWidget";
|
||||
CDockAreaWidget* DockArea = dockAreaAt(TargetPos);
|
||||
auto dropArea = InvalidDockWidgetArea;
|
||||
@ -1203,8 +1217,10 @@ void CDockContainerWidget::dumpLayout()
|
||||
{
|
||||
#if (ADS_DEBUG_LEVEL > 0)
|
||||
qDebug("\n\nDumping layout --------------------------");
|
||||
std::cout << "\n\nDumping layout --------------------------" << std::endl;
|
||||
d->dumpRecursive(0, d->RootSplitter);
|
||||
qDebug("--------------------------\n\n");
|
||||
std::cout << "--------------------------\n\n" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "DockManager.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QList>
|
||||
@ -53,8 +54,6 @@
|
||||
#include "DockStateSerialization.h"
|
||||
#include "DockAreaWidget.h"
|
||||
|
||||
#include <QElapsedTimer>
|
||||
#include <iostream>
|
||||
|
||||
namespace ads
|
||||
{
|
||||
@ -515,10 +514,6 @@ QByteArray CDockManager::saveState(eXmlMode XmlMode, int version) const
|
||||
//============================================================================
|
||||
bool CDockManager::restoreState(const QByteArray &state, int version)
|
||||
{
|
||||
std::cout << "CDockManager::restoreState-----------------------" << std::endl;
|
||||
QElapsedTimer Timer;
|
||||
Timer.start();
|
||||
|
||||
// Prevent multiple calls as long as state is not restore. This may
|
||||
// happen, if QApplication::processEvents() is called somewhere
|
||||
if (d->RestoringState)
|
||||
|
@ -78,7 +78,7 @@ bool CDockSplitter::hasVisibleContent() const
|
||||
// TODO Cache or precalculate this to speed up
|
||||
for (int i = 0; i < count(); ++i)
|
||||
{
|
||||
if (widget(i)->isVisibleTo(this))
|
||||
if (!widget(i)->isHidden())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -224,7 +224,6 @@ bool DockWidgetTabPrivate::startFloating()
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "DockWidgetTabPrivate::startFloating DockArea";
|
||||
// If section widget has only one content widget, we can move the complete
|
||||
// dock area into floating widget
|
||||
FloatingWidget = new CFloatingDockContainer(DockArea);
|
||||
|
@ -150,10 +150,6 @@ void FloatingDockContainerPrivate::titleMouseReleaseEvent()
|
||||
//============================================================================
|
||||
void FloatingDockContainerPrivate::updateDropOverlays(const QPoint& GlobalPos)
|
||||
{
|
||||
static QElapsedTimer MsSinceLastCallTimer;
|
||||
QElapsedTimer PerformanceTimer;
|
||||
PerformanceTimer.start();
|
||||
|
||||
if (!_this->isVisible() || !DockManager)
|
||||
{
|
||||
return;
|
||||
@ -225,8 +221,6 @@ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint& GlobalPos)
|
||||
{
|
||||
DockAreaOverlay->hideOverlay();
|
||||
}
|
||||
|
||||
std::cout << "updateDropOverlays us: " << PerformanceTimer.nsecsElapsed() / 1000 << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,6 +87,20 @@ QPixmap createTransparentPixmap(const QPixmap& Source, qreal Opacity)
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void hideEmptyParentSplitters(CDockSplitter* Splitter)
|
||||
{
|
||||
while (Splitter && Splitter->isVisible())
|
||||
{
|
||||
if (!Splitter->hasVisibleContent())
|
||||
{
|
||||
Splitter->hide();
|
||||
}
|
||||
Splitter = internal::findParent<CDockSplitter*>(Splitter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ads
|
||||
|
||||
|
@ -46,6 +46,8 @@ class QSplitter;
|
||||
|
||||
namespace ads
|
||||
{
|
||||
class CDockSplitter;
|
||||
|
||||
enum DockWidgetArea
|
||||
{
|
||||
NoDockWidgetArea = 0x00,
|
||||
@ -83,6 +85,12 @@ QSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent = 0);
|
||||
*/
|
||||
void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To);
|
||||
|
||||
/**
|
||||
* This function walks the splitter tree upwards to hides all splitters
|
||||
* that do not have visible content
|
||||
*/
|
||||
void hideEmptyParentSplitters(CDockSplitter* FirstParentSplitter);
|
||||
|
||||
/**
|
||||
* Convenience class for QPair to provide better naming than first and
|
||||
* second
|
||||
|
Loading…
Reference in New Issue
Block a user