diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 7c353bf..336355c 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -475,15 +475,17 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget) setCurrentIndex(d->ContentsLayout->currentIndex()); d->updateTabsMenu(); + CDockContainerWidget* DockContainer = dockContainer(); if (d->ContentsLayout->isEmpty()) { std::cout << "Dock Area empty" << std::endl; dockContainer()->removeDockArea(this); - this->deleteLater(); + this->deleteLater();; } d->updateTabBar(); DockWidget->setDockArea(nullptr); + DockContainer->dumpLayout(); } diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index e3b31dc..1ad78d5 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -145,6 +145,11 @@ struct DockContainerWidgetPrivate */ bool restoreDockArea(QDataStream& Stream, QWidget*& CreatedWidget, bool Testing); + + /** + * Helper function for recursive dumping of layout + */ + void dumpRecursive(int level, QWidget* widget); }; // struct DockContainerWidgetPrivate @@ -169,7 +174,7 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float { Splitter->setOrientation(InsertParam.orientation()); } - else + else if (Splitter->orientation() != InsertParam.orientation()) { QSplitter* NewSplitter = internal::newSplitter(InsertParam.orientation()); QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter); @@ -178,13 +183,8 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float } // Now we can insert the floating widget content into this container - auto Widget = FloatingWidget->dockContainer()->findChild(QString(), Qt::FindDirectChildrenOnly); - auto FloatingSplitter = dynamic_cast(Widget); - if (DockAreas.isEmpty()) - { - Splitter->addWidget(Widget); - } - else if (FloatingSplitter->count() == 1) + auto FloatingSplitter = FloatingWidget->dockContainer()->rootSplitter(); + if (FloatingSplitter->count() == 1) { insertWidgetIntoSplitter(Splitter, FloatingSplitter->widget(0), InsertParam.append()); } @@ -203,6 +203,7 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float RootSplitter = Splitter; addDockAreasToList(NewDockAreas); FloatingWidget->deleteLater(); + _this->dumpLayout(); } @@ -278,6 +279,7 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin FloatingWidget->deleteLater(); addDockAreasToList(NewDockAreas); + _this->dumpLayout(); } @@ -523,6 +525,33 @@ void DockContainerWidgetPrivate::addDockArea(CDockAreaWidget* NewDockArea, DockW } +//============================================================================ +void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget) +{ + QSplitter* Splitter = dynamic_cast(widget); + QByteArray buf; + buf.fill(' ', level * 4); + if (Splitter) + { + std::cout << buf.toStdString() << "Splitter " << ((Splitter->orientation() == Qt::Vertical) + ? "-" : "|") << std::endl; + for (int i = 0; i < Splitter->count(); ++i) + { + dumpRecursive(level + 1, Splitter->widget(i)); + } + } + else + { + CDockAreaWidget* DockArea = dynamic_cast(widget); + if (!DockArea) + { + return; + } + std::cout << buf.toStdString() << "DockArea" << std::endl; + } +} + + //============================================================================ CDockAreaWidget* DockContainerWidgetPrivate::dockWidgetIntoDockArea(DockWidgetArea area, CDockWidget* Dockwidget, CDockAreaWidget* TargetDockArea) @@ -681,6 +710,7 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area) QSplitter* ParentSplitter = internal::findParent(Splitter); internal::replaceSplitterWidget(ParentSplitter, Splitter, widget); delete Splitter; + dumpLayout(); emit dockAreasRemoved(); } @@ -845,6 +875,20 @@ bool CDockContainerWidget::restoreState(QDataStream& stream, bool Testing) } +//============================================================================ +QSplitter* CDockContainerWidget::rootSplitter() const +{ + return d->RootSplitter; +} + + +//============================================================================ +void CDockContainerWidget::dumpLayout() +{ + d->dumpRecursive(0, d->RootSplitter); +} + + } // namespace ads //--------------------------------------------------------------------------- diff --git a/src/DockContainerWidget.h b/src/DockContainerWidget.h index 9d344bd..891fcce 100644 --- a/src/DockContainerWidget.h +++ b/src/DockContainerWidget.h @@ -59,6 +59,11 @@ protected: */ virtual bool event(QEvent *e) override; + /** + * Access function for the internal root splitter + */ + QSplitter* rootSplitter() const; + public: /** * Default Constructor @@ -147,6 +152,11 @@ public: */ bool restoreState(QDataStream& Stream, bool Testing); + /** + * Dumps the layout for debugging purposes + */ + void dumpLayout(); + signals: /** * This signal is emitted if one or multiple dock areas has been added to diff --git a/src/DockOverlay.cpp b/src/DockOverlay.cpp index 66078ce..177ac17 100644 --- a/src/DockOverlay.cpp +++ b/src/DockOverlay.cpp @@ -136,7 +136,7 @@ static QPixmap createDropIndicatorPixmap(const QPalette& pal, const QSizeF& size if (CDockOverlay::ModeContainerOverlay == Mode && DockWidgetArea != CenterDockWidgetArea) { QRectF ArrowRect; - ArrowRect.setSize(ShadowRect.size() * 0.7); + ArrowRect.setSize(baseSize); ArrowRect.setWidth(ArrowRect.width() / 4.6); ArrowRect.setHeight(ArrowRect.height() / 2); ArrowRect.moveCenter(QPointF(0, 0)); diff --git a/src/DockWidgetTitleBar.cpp b/src/DockWidgetTitleBar.cpp index 5aa2662..0ef0ae5 100644 --- a/src/DockWidgetTitleBar.cpp +++ b/src/DockWidgetTitleBar.cpp @@ -267,8 +267,8 @@ void CDockWidgetTitleBar::mouseReleaseEvent(QMouseEvent* ev) //============================================================================ void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev) { - std::cout << "CDockWidgetTitleBar::mouseMoveEventmouseMoveEvent DragState " - << d->DragState << std::endl; + /*std::cout << "CDockWidgetTitleBar::mouseMoveEventmouseMoveEvent DragState " + << d->DragState << std::endl;*/ if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive)) { d->DragState = DraggingInactive; @@ -278,7 +278,7 @@ void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev) if (d->isDraggingState(DraggingFloatingWidget)) { - std::cout << "DraggingFloatingWidget" << std::endl; + //std::cout << "DraggingFloatingWidget" << std::endl; d->FloatingWidget->moveFloating(); QFrame::mouseMoveEvent(ev); return;