diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 13c8aca..3192971 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -546,17 +546,19 @@ void CDockAreaWidget::internalSetCurrentDockWidget(CDockWidget* DockWidget) void CDockAreaWidget::setCurrentIndex(int index) { auto TabBar = d->tabBar(); - /*if (TabBar->currentIndex() == index) - { - return; - }*/ - if (index < 0 || index > (TabBar->count() - 1)) { qWarning() << Q_FUNC_INFO << "Invalid index" << index; return; } + auto cw = d->ContentsLayout->currentWidget(); + auto nw = d->ContentsLayout->widget(index); + if (cw == nw && !nw->isHidden()) + { + return; + } + emit currentChanging(index); TabBar->setCurrentIndex(index); d->ContentsLayout->setCurrentIndex(index); diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index 5c07248..ec1efa7 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -134,8 +134,8 @@ void DockWidgetPrivate::showDockWidget() } else { - DockArea->toggleView(true); DockArea->setCurrentDockWidget(_this); + DockArea->toggleView(true); TabWidget->show(); QSplitter* Splitter = internal::findParent(DockArea); while (Splitter && !Splitter->isVisible()) @@ -525,20 +525,14 @@ bool CDockWidget::event(QEvent *e) switch (e->type()) { case QEvent::Hide: + std::cout << this->objectName().toStdString() << " visible: " << isVisible() + << " hidden: " << isHidden() << " visibleTo: " << isVisibleTo(d->DockManager) << std::endl; emit visibilityChanged(false); break; case QEvent::Show: { QPoint parentTopLeft(0, 0); - if (isWindow()) - { - if (const QWindow *window = windowHandle()) - parentTopLeft = window->screen()->availableVirtualGeometry().topLeft(); - else - parentTopLeft = QGuiApplication::primaryScreen()->availableVirtualGeometry().topLeft(); - std::cout << "QEvent::Show isWindow()" << std::endl; - } emit visibilityChanged(geometry().right() >= parentTopLeft.x() && geometry().bottom() >= parentTopLeft.y()); } break;