3232#include < MainWindow.h>
3333#include " ui_mainwindow.h"
3434
35- #include < iostream>
36-
3735#include < QTime>
3836#include < QLabel>
3937#include < QTextEdit>
@@ -109,13 +107,12 @@ int randomNumberBounded(int highest)
109107static QString featuresString (ads::CDockWidget* DockWidget)
110108{
111109 auto f = DockWidget->features ();
112- return QString (" c%1 m%2 f%3" )
113- .arg (f.testFlag (ads::CDockWidget::DockWidgetClosable) ? " +" : " -" )
114- . arg ( f.testFlag (ads::CDockWidget::DockWidgetMovable) ? " +" : " -" )
115- . arg ( f.testFlag (ads::CDockWidget::DockWidgetFloatable) ? " +" : " -" );
110+ return QString (" c%1 m%2 f%3" )
111+ .arg (f.testFlag (ads::CDockWidget::DockWidgetClosable) ? " +" : " -" ,
112+ f.testFlag (ads::CDockWidget::DockWidgetMovable) ? " +" : " -" ,
113+ f.testFlag (ads::CDockWidget::DockWidgetFloatable) ? " +" : " -" );
116114}
117115
118-
119116/* *
120117 * Appends the string returned by featuresString() to the window title of
121118 * the given DockWidget
@@ -396,32 +393,30 @@ struct MainWindowPrivate
396393 DockWidget->setMinimumSizeHintMode (ads::CDockWidget::MinimumSizeHintFromContent);
397394 auto ToolBar = DockWidget->createDefaultToolBar ();
398395 auto Action = ToolBar->addAction (svgIcon (" :/adsdemo/images/fullscreen.svg" ), " Toggle Fullscreen" );
399- QObject::connect (Action, &QAction::triggered, [DockWidget]()
400- {
401- if (DockWidget->isFullScreen ())
402- {
403- DockWidget->showNormal ();
404- }
405- else
406- {
407- DockWidget->showFullScreen ();
408- }
409- });
410- ui.menuView ->addAction (DockWidget->toggleViewAction ());
411- return DockWidget;
412- }
396+ QObject::connect (Action, &QAction::triggered, DockWidget, [DockWidget]() {
397+ if (DockWidget->isFullScreen ())
398+ {
399+ DockWidget->showNormal ();
400+ }
401+ else
402+ {
403+ DockWidget->showFullScreen ();
404+ }
405+ });
406+ ui.menuView ->addAction (DockWidget->toggleViewAction ());
407+ return DockWidget;
408+ }
413409
414- /* *
415- * Create QQuickWidget for test for OpenGL and QQuick
416- */
417- ads::CDockWidget * createQQuickWidget ()
418- {
419- QQuickWidget * widget = new QQuickWidget ();
420- ads::CDockWidget *dockWidget = DockManager->createDockWidget (" Quick" );
410+ /* *
411+ * Create QQuickWidget for test for OpenGL and QQuick
412+ */
413+ ads::CDockWidget* createQQuickWidget ()
414+ {
415+ QQuickWidget* widget = new QQuickWidget ();
416+ ads::CDockWidget *dockWidget = DockManager->createDockWidget (" Quick" );
421417 dockWidget->setWidget (widget);
422418 return dockWidget;
423- }
424-
419+ }
425420
426421#ifdef Q_OS_WIN
427422#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
@@ -484,45 +479,47 @@ void MainWindowPrivate::createContent()
484479 auto DockArea = DockManager->addDockWidget (ads::CenterDockWidgetArea, DockWidget, TopDockArea);
485480 // Now we create a action to test resizing of DockArea widget
486481 auto Action = ui.menuTests ->addAction (QString (" Resize %1" ).arg (DockWidget->windowTitle ()));
487- QObject::connect (Action, &QAction::triggered, [DockArea]()
488- {
489- // Resizing only works, if the Splitter is visible and has a valid
490- // sizes
491- auto Splitter = ads::internal::findParent<ads::CDockSplitter*>(DockArea);
492- if (!Splitter)
493- {
494- return ;
495- }
496- // We change the sizes of the splitter that contains the Calendar 1 widget
482+ QObject::connect (Action, &QAction::triggered, DockArea, [DockArea]() {
483+ // Resizing only works, if the Splitter is visible and has a valid
484+ // sizes
485+ auto Splitter = ads::internal::findParent<ads::CDockSplitter*>(DockArea);
486+ if (!Splitter)
487+ {
488+ return ;
489+ }
490+ // We change the sizes of the splitter that contains the Calendar 1 widget
497491 // to resize the dock widget
498492 int Width = Splitter->width ();
499493 Splitter->setSizes ({Width * 2 /3 , Width * 1 /3 });
500- });
501- DockWidget->setWindowTitle (QString (" My " + DockWidget->windowTitle ()));
494+ });
495+ DockWidget->setWindowTitle (QString (" My " + DockWidget->windowTitle ()));
502496
503- // Now we add a custom button to the dock area title bar that will create
504- // new editor widgets when clicked
505- auto CustomButton = new QToolButton (DockArea);
506- CustomButton->setToolTip (QObject::tr (" Create Editor" ));
507- CustomButton->setIcon (svgIcon (" :/adsdemo/images/plus.svg" ));
508- CustomButton->setAutoRaise (true );
497+ // Now we add a custom button to the dock area title bar that will create
498+ // new editor widgets when clicked
499+ auto CustomButton = new QToolButton (DockArea);
500+ CustomButton->setToolTip (QObject::tr (" Create Editor" ));
501+ CustomButton->setIcon (svgIcon (" :/adsdemo/images/plus.svg" ));
502+ CustomButton->setAutoRaise (true );
509503
510504 auto TitleBar = DockArea->titleBar ();
511505 int Index = TitleBar->indexOf (TitleBar->tabBar ());
512506 TitleBar->insertWidget (Index + 1 , CustomButton);
513- QObject::connect (CustomButton, &QToolButton::clicked, [DockArea, this ]()
514- {
515- auto DockWidget = createEditorWidget ();
516- DockWidget->setFeature (ads::CDockWidget::DockWidgetDeleteOnClose, true );
517- DockManager->addDockWidgetTabToArea (DockWidget, DockArea);
518- _this->connect (DockWidget, SIGNAL (closeRequested ()), SLOT (onEditorCloseRequested ()));
519- });
520-
521- // Test dock area docking
522- auto RighDockArea = DockManager->addDockWidget (ads::RightDockWidgetArea, createLongTextLabelDockWidget (), TopDockArea);
523- DockWidget = createLongTextLabelDockWidget ();
524- DockWidget->setFeature (ads::CDockWidget::DockWidgetPinnable, false );
525- DockManager->addDockWidget (ads::TopDockWidgetArea, DockWidget, RighDockArea);
507+ QObject::connect (
508+ CustomButton, &QToolButton::clicked, DockArea, [DockArea, this ]() {
509+ auto DockWidget = createEditorWidget ();
510+ DockWidget->setFeature (ads::CDockWidget::DockWidgetDeleteOnClose,
511+ true );
512+ DockManager->addDockWidgetTabToArea (DockWidget, DockArea);
513+ _this->connect (DockWidget, SIGNAL (closeRequested ()),
514+ SLOT (onEditorCloseRequested ()));
515+ });
516+
517+ // Test dock area docking
518+ auto RighDockArea = DockManager->addDockWidget (
519+ ads::RightDockWidgetArea, createLongTextLabelDockWidget (), TopDockArea);
520+ DockWidget = createLongTextLabelDockWidget ();
521+ DockWidget->setFeature (ads::CDockWidget::DockWidgetPinnable, false );
522+ DockManager->addDockWidget (ads::TopDockWidgetArea, DockWidget, RighDockArea);
526523 auto BottomDockArea = DockManager->addDockWidget (ads::BottomDockWidgetArea, createLongTextLabelDockWidget (), RighDockArea);
527524 DockManager->addDockWidget (ads::CenterDockWidgetArea, createLongTextLabelDockWidget (), RighDockArea);
528525 auto LabelDockWidget = createLongTextLabelDockWidget ();
@@ -531,15 +528,16 @@ void MainWindowPrivate::createContent()
531528 // Tests CustomCloseHandling without DeleteOnClose
532529 LabelDockWidget->setFeature (ads::CDockWidget::CustomCloseHandling, true );
533530 LabelDockWidget->setWindowTitle (LabelDockWidget->windowTitle () + " [Custom Close]" );
534- QObject::connect (LabelDockWidget, &ads::CDockWidget::closeRequested, [LabelDockWidget, this ]()
535- {
536- int Result = QMessageBox::question (_this, " Custom Close Request" ,
537- " Do you really want to close this dock widget?" );
538- if (QMessageBox::Yes == Result)
539- {
540- LabelDockWidget->closeDockWidget ();
541- }
542- });
531+ QObject::connect (LabelDockWidget, &ads::CDockWidget::closeRequested,
532+ LabelDockWidget, [LabelDockWidget, this ]() {
533+ int Result = QMessageBox::question (
534+ _this, " Custom Close Request" ,
535+ " Do you really want to close this dock widget?" );
536+ if (QMessageBox::Yes == Result)
537+ {
538+ LabelDockWidget->closeDockWidget ();
539+ }
540+ });
543541
544542 Action = ui.menuTests ->addAction (QString (" Set %1 Floating" ).arg (DockWidget->windowTitle ()));
545543 DockWidget->connect (Action, SIGNAL (triggered ()), SLOT (setFloating ()));
@@ -565,14 +563,15 @@ void MainWindowPrivate::createContent()
565563#endif
566564#endif
567565
568- for (auto DockWidget : DockManager->dockWidgetsMap ())
569- {
570- _this->connect (DockWidget, SIGNAL (viewToggled (bool )), SLOT (onViewToggled (bool )));
571- _this->connect (DockWidget, SIGNAL (visibilityChanged (bool )), SLOT (onViewVisibilityChanged (bool )));
572- }
566+ for (auto & DockWidget : DockManager->dockWidgetsMap ())
567+ {
568+ _this->connect (DockWidget, SIGNAL (viewToggled (bool )),
569+ SLOT (onViewToggled (bool )));
570+ _this->connect (DockWidget, SIGNAL (visibilityChanged (bool )), SLOT (onViewVisibilityChanged (bool )));
571+ }
573572
574- // Create image viewer
575- DockWidget = createImageViewer ();
573+ // Create image viewer
574+ DockWidget = createImageViewer ();
576575 DockManager->addDockWidget (ads::LeftDockWidgetArea, DockWidget);
577576
578577 // Create quick widget
0 commit comments