diff --git a/examples/deleteonclose/main.cpp b/examples/deleteonclose/main.cpp index 0d60fc1..f217dd0 100644 --- a/examples/deleteonclose/main.cpp +++ b/examples/deleteonclose/main.cpp @@ -10,6 +10,7 @@ int main(int argc, char *argv[]) QApplication a(argc, argv); QMainWindow w; + ads::CDockManager::setConfigFlag(ads::CDockManager::FocusStyling, true); auto dockManager = new ads::CDockManager(&w); QAction *action = new QAction("New Delete On Close", &w); diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index d10ce15..b3525e4 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -1461,6 +1461,12 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi } window()->activateWindow(); + if (SingleDroppedDockWidget) + { + std::cout << "SingleDockWidget dropped" << std::endl; + d->DockManager->emitWidgetDroppedSignals(SingleDroppedDockWidget); + } + d->DockManager->endFloatingWidgetDrop(FloatingWidget); } diff --git a/src/DockManager.cpp b/src/DockManager.cpp index c0efc46..049db8a 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -500,10 +500,16 @@ void DockManagerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget) updateDockAreaFocusStyle(FocusedArea, true); QObject::connect(FocusedArea, SIGNAL(viewToggled(bool)), _this, SLOT(onFocusedDockAreaViewToggled(bool))); + auto NewFloatingWidget = FocusedDockWidget->dockContainer()->floatingWidget(); + if (NewFloatingWidget) + { + NewFloatingWidget->setProperty("FocusedDockWidget", QVariant::fromValue(DockWidget)); + } + + #ifdef Q_OS_LINUX // This code is required for styling the floating widget titlebar for linux // depending on the current focus state - auto NewFloatingWidget = FocusedDockWidget->dockContainer()->floatingWidget(); if (FloatingWidget == NewFloatingWidget) { return; @@ -1061,6 +1067,28 @@ void CDockManager::emitWidgetDroppedSignals(QWidget* DroppedWidget) } +//=========================================================================== +void CDockManager::endFloatingWidgetDrop(CFloatingDockContainer* FloatingWidget) +{ + if (!FloatingWidget) + { + return; + } + + auto vDockWidget = FloatingWidget->property("FocusedDockWidget"); + if (!vDockWidget.isValid()) + { + return; + } + auto DockWidget = vDockWidget.value(); + if (DockWidget) + { + std::cout << "Dropped focus dock widget " << DockWidget->objectName().toStdString() << std::endl; + CDockManager::setWidgetFocus(DockWidget->tabWidget()); + } +} + + } // namespace ads //--------------------------------------------------------------------------- diff --git a/src/DockManager.h b/src/DockManager.h index 7702713..c6085b6 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -128,6 +128,14 @@ protected: */ void emitWidgetDroppedSignals(QWidget* DroppedWidget); + /** + * This function is called, if a floating widget has been dropped into + * an new position. + * When this function is called, all dock widgets of the FloatingWidget + * are already inserted into its new position + */ + void endFloatingWidgetDrop(CFloatingDockContainer* FloatingWidget); + /** * Show the floating widgets that has been created floating */