From 8dcdc8fad23dcaaeee08b98a9af9670b1811575e Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Mon, 28 Oct 2024 15:40:32 +0100 Subject: [PATCH] Improved autohidedragndrop example to check, if it also works when dragging with multiple auto hide tabs --- .../autohidedragndrop/autohidedragndrop.pro | 2 +- examples/autohidedragndrop/droppableitem.cpp | 1 + examples/autohidedragndrop/mainwindow.cpp | 35 +++++++++++++------ examples/examples.pro | 1 + 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/examples/autohidedragndrop/autohidedragndrop.pro b/examples/autohidedragndrop/autohidedragndrop.pro index ce86127..f812355 100644 --- a/examples/autohidedragndrop/autohidedragndrop.pro +++ b/examples/autohidedragndrop/autohidedragndrop.pro @@ -23,7 +23,7 @@ SOURCES += \ droppableitem.cpp HEADERS += \ - mainwindow.h + mainwindow.h \ droppableitem.h FORMS += \ diff --git a/examples/autohidedragndrop/droppableitem.cpp b/examples/autohidedragndrop/droppableitem.cpp index 390c1b8..d7d2add 100644 --- a/examples/autohidedragndrop/droppableitem.cpp +++ b/examples/autohidedragndrop/droppableitem.cpp @@ -24,6 +24,7 @@ void DroppableItem::dragEnterEvent(QDragEnterEvent* event) void DroppableItem::dragLeaveEvent(QDragLeaveEvent* event) { + Q_UNUSED(event); unsetCursor(); } diff --git a/examples/autohidedragndrop/mainwindow.cpp b/examples/autohidedragndrop/mainwindow.cpp index 6443b35..e6d405f 100644 --- a/examples/autohidedragndrop/mainwindow.cpp +++ b/examples/autohidedragndrop/mainwindow.cpp @@ -29,6 +29,7 @@ CMainWindow::CMainWindow(QWidget *parent) CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true); CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig); CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover, true); + CDockManager::setConfigParam(CDockManager::AutoHideOpenOnDragHoverDelay_ms, 500); DockManager = new CDockManager(this); // Set central widget @@ -39,16 +40,30 @@ CMainWindow::CMainWindow(QWidget *parent) auto* CentralDockArea = DockManager->setCentralWidget(CentralDockWidget); CentralDockArea->setAllowedAreas(DockWidgetArea::OuterDockAreas); - DroppableItem* droppableItem = new DroppableItem("Drop text here."); - CDockWidget* dropDockWidget = new CDockWidget("Tab"); - dropDockWidget->setWidget(droppableItem); - dropDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget); - dropDockWidget->setMinimumSize(200,150); - dropDockWidget->setAcceptDrops(true); - const auto autoHideContainer = DockManager->addAutoHideDockWidget(SideBarLocation::SideBarLeft, dropDockWidget); - autoHideContainer->setSize(480); - autoHideContainer->setAcceptDrops(true); - ui->menuView->addAction(dropDockWidget->toggleViewAction()); + { + DroppableItem* droppableItem = new DroppableItem("Drop text here."); + CDockWidget* dropDockWidget = new CDockWidget("Tab 1"); + dropDockWidget->setWidget(droppableItem); + dropDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget); + dropDockWidget->setMinimumSize(200,150); + dropDockWidget->setAcceptDrops(true); + const auto autoHideContainer = DockManager->addAutoHideDockWidget(SideBarLocation::SideBarLeft, dropDockWidget); + autoHideContainer->setSize(480); + autoHideContainer->setAcceptDrops(true); + ui->menuView->addAction(dropDockWidget->toggleViewAction()); + } + { + DroppableItem* droppableItem = new DroppableItem("Drop text here."); + CDockWidget* dropDockWidget = new CDockWidget("Tab 2"); + dropDockWidget->setWidget(droppableItem); + dropDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget); + dropDockWidget->setMinimumSize(200,150); + dropDockWidget->setAcceptDrops(true); + const auto autoHideContainer = DockManager->addAutoHideDockWidget(SideBarLocation::SideBarRight, dropDockWidget); + autoHideContainer->setSize(480); + autoHideContainer->setAcceptDrops(true); + ui->menuView->addAction(dropDockWidget->toggleViewAction()); + } QTableWidget* propertiesTable = new QTableWidget(); propertiesTable->setColumnCount(3); diff --git a/examples/examples.pro b/examples/examples.pro index e2b0705..05e739a 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -2,6 +2,7 @@ TEMPLATE = subdirs SUBDIRS = \ autohide \ + autohidedragndrop \ centralwidget \ simple \ hideshow \