Skip to content

Commit bbdf0ef

Browse files
Added test for resizing of DockAera
1 parent 401e8cf commit bbdf0ef

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

demo/MainWindow.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
#include "FloatingDockContainer.h"
8080
#include "DockComponentsFactory.h"
8181
#include "StatusDialog.h"
82-
82+
#include "DockSplitter.h"
8383

8484

8585
/**
@@ -417,6 +417,22 @@ void MainWindowPrivate::createContent()
417417
DockWidget = createCalendarDockWidget();
418418
DockWidget->setTabToolTip(QString("Tab ToolTip\nHodie est dies magna"));
419419
auto DockArea = DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
420+
// Now we create a action to test resizing of DockArea widget
421+
auto Action = ui.menuTests->addAction(QString("Resize %1").arg(DockWidget->windowTitle()));
422+
QObject::connect(Action, &QAction::triggered, [DockArea]()
423+
{
424+
// Resizing only works, if the Splitter is visible and has a valid
425+
// sizes
426+
auto Splitter = ads::internal::findParent<ads::CDockSplitter*>(DockArea);
427+
if (!Splitter)
428+
{
429+
return;
430+
}
431+
// We change the sizes of the splitter that contains the Calendar 1 widget
432+
// to resize the dock widget
433+
int Width = Splitter->width();
434+
Splitter->setSizes({Width * 2/3, Width * 1/3});
435+
});
420436

421437
// Now we add a custom button to the dock area title bar that will create
422438
// new editor widgets when clicked
@@ -443,13 +459,14 @@ void MainWindowPrivate::createContent()
443459
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(), RighDockArea);
444460
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(), BottomDockArea);
445461

446-
auto Action = ui.menuTests->addAction(QString("Set %1 Floating").arg(DockWidget->windowTitle()));
462+
Action = ui.menuTests->addAction(QString("Set %1 Floating").arg(DockWidget->windowTitle()));
447463
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(setFloating()));
448464
Action = ui.menuTests->addAction(QString("Set %1 As Current Tab").arg(DockWidget->windowTitle()));
449465
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(setAsCurrentTab()));
450466
Action = ui.menuTests->addAction(QString("Raise %1").arg(DockWidget->windowTitle()));
451467
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(raise()));
452468

469+
453470
#ifdef Q_OS_WIN
454471
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
455472
if (!ads::CDockManager::testConfigFlag(ads::CDockManager::OpaqueUndocking))

0 commit comments

Comments
 (0)