diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 512921f..e4d8492 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -348,7 +348,7 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget, DockWidget->tabWidget()->setDockAreaWidget(this); auto TabWidget = DockWidget->tabWidget(); d->TabsLayout->insertWidget(index, TabWidget); - TabWidget->show(); + TabWidget->setVisible(!DockWidget->isClosed()); connect(TabWidget, SIGNAL(clicked()), this, SLOT(onDockWidgetTitleClicked())); DockWidget->setProperty(INDEX_PROPERTY, index); if (Activate) @@ -421,7 +421,7 @@ CDockWidget* CDockAreaWidget::currentDockWidget() const //============================================================================ void CDockAreaWidget::setCurrentDockWidget(CDockWidget* DockWidget) { - int Index = tabIndex(DockWidget); + int Index = index(DockWidget); if (Index < 0) { return; @@ -497,12 +497,19 @@ QRect CDockAreaWidget::contentAreaGeometry() const //============================================================================ -int CDockAreaWidget::tabIndex(CDockWidget* DockWidget) +int CDockAreaWidget::index(CDockWidget* DockWidget) { return d->ContentsLayout->indexOf(DockWidget); } +//============================================================================ +int CDockAreaWidget::tabIndex(CDockWidget* DockWidget) +{ + +} + + //============================================================================ QList CDockAreaWidget::dockWidgets() const { diff --git a/src/DockAreaWidget.h b/src/DockAreaWidget.h index c2e9a30..aba05be 100644 --- a/src/DockAreaWidget.h +++ b/src/DockAreaWidget.h @@ -113,6 +113,16 @@ protected: */ CDockWidget* nextOpenDockWidget(CDockWidget* DockWidget) const; + /** + * Returns the index of the given DockWidget in the internal layout + */ + int index(CDockWidget* DockWidget); + + /** + * Returns the tab index for the given dock widget + */ + int tabIndex(CDockWidget* DockWidget); + public: /** * Default Constructor @@ -145,11 +155,6 @@ public: */ QRect contentAreaGeometry() const; - /** - * Returns the tab index of the given DockWidget - */ - int tabIndex(CDockWidget* DockWidget); - /** * Returns a list of all dock widgets in this dock area. * This list contains open and closed dock widgets. diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index e56dcbc..8e0c532 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -49,6 +49,8 @@ #include "DockSplitter.h" #include "ads_globals.h" +#include + namespace ads { /** @@ -121,7 +123,7 @@ void DockWidgetPrivate::showDockWidget() else { DockArea->show(); - DockArea->setCurrentIndex(DockArea->tabIndex(_this)); + DockArea->setCurrentDockWidget(_this); QSplitter* Splitter = internal::findParent(_this); while (Splitter && !Splitter->isVisible()) { @@ -380,6 +382,8 @@ void CDockWidget::setToggleViewActionMode(eToggleViewActionMode Mode) //============================================================================ void CDockWidget::toggleView(bool Open) { + std::cout << "CDockWidget::toggleView " << objectName().toStdString() + << " " << Open << std::endl; QAction* Sender = qobject_cast(sender()); if (Sender == d->ToggleViewAction && !d->ToggleViewAction->isCheckable()) { @@ -412,7 +416,7 @@ void CDockWidget::toggleView(bool Open) void CDockWidget::setDockArea(CDockAreaWidget* DockArea) { d->DockArea = DockArea; - d->ToggleViewAction->setChecked(DockArea != nullptr); + d->ToggleViewAction->setChecked(DockArea != nullptr && !this->isClosed()); } diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index 5572551..28d3e23 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -244,14 +244,14 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev) { // Find tab under mouse QPoint pos = d->DockArea->mapFromGlobal(ev->globalPos()); - int fromIndex = d->DockArea->tabIndex(d->DockWidget); + int fromIndex = d->DockArea->index(d->DockWidget); int toIndex = d->DockArea->indexOfContentByTitlePos(pos, this); if (-1 == toIndex) { toIndex = d->DockArea->count() - 1; } qDebug() << "Move tab from " << fromIndex << " to " << toIndex; - d->DockArea->reorderDockWidget(fromIndex, toIndex); + //d->DockArea->reorderDockWidget(fromIndex, toIndex); } if (!d->DragStartMousePosition.isNull())