From eda610409afaa51863a67228a43e2e5d89a8cf2c Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Mon, 7 Nov 2022 08:11:50 +0100 Subject: [PATCH] Added actions to demo applications to create floating, docked and auto hide image viewers --- demo/MainWindow.cpp | 48 +++++++++ demo/MainWindow.h | 1 + demo/RenderWidget.cpp | 6 -- demo/demo.qrc | 7 ++ demo/images/ads_icon.svg | 86 ++-------------- demo/images/ads_icon2.svg | 13 +++ demo/images/ads_logo.svg | 98 +++---------------- demo/images/ads_tile_blue.svg | 33 +++++++ demo/images/ads_tile_blue_light.svg | 147 ++++++++++++++++++++++++++++ demo/images/ads_tile_green.svg | 33 +++++++ demo/images/ads_tile_orange.svg | 33 +++++++ demo/images/crop_original.svg | 6 ++ demo/images/panorama.svg | 6 ++ demo/images/photo.svg | 6 ++ 14 files changed, 354 insertions(+), 169 deletions(-) create mode 100644 demo/images/ads_icon2.svg create mode 100644 demo/images/ads_tile_blue.svg create mode 100644 demo/images/ads_tile_blue_light.svg create mode 100644 demo/images/ads_tile_green.svg create mode 100644 demo/images/ads_tile_orange.svg create mode 100644 demo/images/crop_original.svg create mode 100644 demo/images/panorama.svg create mode 100644 demo/images/photo.svg diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index bf8a133..1325404 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -575,6 +575,22 @@ void MainWindowPrivate::createActions() _this->connect(a, SIGNAL(triggered()), SLOT(createTable())); ui.menuTests->addAction(a); + a = ui.toolBar->addAction("Create Image Viewer"); + auto ToolButton = qobject_cast(ui.toolBar->widgetForAction(a)); + ToolButton->setPopupMode(QToolButton::InstantPopup); + a->setToolTip("Creates floating, docked or pinned image viewer"); + a->setIcon(svgIcon(":/adsdemo/images/panorama.svg")); + ui.menuTests->addAction(a); + auto Menu = new QMenu(); + ToolButton->setMenu(Menu); + a = Menu->addAction("Floating Image Viewer"); + _this->connect(a, SIGNAL(triggered()), SLOT(createImageViewer())); + a = Menu->addAction("Docked Image Viewer"); + _this->connect(a, SIGNAL(triggered()), SLOT(createImageViewer())); + a = Menu->addAction("Pinned Image Viewer"); + _this->connect(a, SIGNAL(triggered()), SLOT(createImageViewer())); + + ui.menuTests->addSeparator(); a = ui.menuTests->addAction("Show Status Dialog"); _this->connect(a, SIGNAL(triggered()), SLOT(showStatusDialog())); @@ -587,6 +603,7 @@ void MainWindowPrivate::createActions() a->setToolTip("Applies a Visual Studio light style (visual_studio_light.css)." ); a->setIcon(svgIcon(":/adsdemo/images/color_lens.svg")); QObject::connect(a, &QAction::triggered, _this, &CMainWindow::applyVsStyle); + ui.menuTests->addAction(a); } @@ -902,3 +919,34 @@ void CMainWindow::applyVsStyle() d->DockManager->setStyleSheet(Stylesheet); } + +//============================================================================ +void CMainWindow::createImageViewer() +{ + QAction* a = qobject_cast(sender()); + qDebug() << "createImageViewer " << a->text(); + + auto DockWidget = d->createImageViewer(); + DockWidget->setFeature(ads::CDockWidget::DockWidgetDeleteOnClose, true); + DockWidget->setFeature(ads::CDockWidget::DockWidgetForceCloseWithArea, true); + DockWidget->setFeature(ads::CDockWidget::CustomCloseHandling, true); + DockWidget->resize(QSize(640, 480)); + connect(DockWidget, &ads::CDockWidget::closeRequested, [this](){ + qDebug() << "ImageViewer close requested"; + }); + + if (a->text().startsWith("Floating")) + { + auto FloatingWidget = d->DockManager->addDockWidgetFloating(DockWidget); + FloatingWidget->move(QPoint(20, 20)); + } + else if (a->text().startsWith("Docked")) + { + d->DockManager->addDockWidget(ads::RightDockWidgetArea, DockWidget); + } + else if (a->text().startsWith("Pinned")) + { + d->DockManager->addAutoHideDockWidget(ads::SideBarLeft, DockWidget); + } +} + diff --git a/demo/MainWindow.h b/demo/MainWindow.h index a4d78a8..0eeb525 100644 --- a/demo/MainWindow.h +++ b/demo/MainWindow.h @@ -66,6 +66,7 @@ private slots: void showStatusDialog(); void toggleDockWidgetWindowTitle(); void applyVsStyle(); + void createImageViewer(); }; #endif // MAINWINDOW_H diff --git a/demo/RenderWidget.cpp b/demo/RenderWidget.cpp index 41e3024..c168e96 100644 --- a/demo/RenderWidget.cpp +++ b/demo/RenderWidget.cpp @@ -19,12 +19,6 @@ CRenderWidget::CRenderWidget(QWidget* Parent) : QWidget(Parent), m_ScaleFactor(1) { - // - // OpaquePaintEvent indicates that we do not need an auto-filled - // background. It is used for widgets filling the whole paint area - // with its own opaque colors and need to draw its contents quickly. - // This applies for a capture widget. - // this->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); this->setCursor(Qt::OpenHandCursor); } diff --git a/demo/demo.qrc b/demo/demo.qrc index 3139b20..e6f2f40 100644 --- a/demo/demo.qrc +++ b/demo/demo.qrc @@ -26,5 +26,12 @@ images/zoom_in.svg images/zoom_out.svg images/zoom_out_map.svg + images/ads_tile_blue.svg + images/ads_tile_blue_light.svg + images/ads_tile_green.svg + images/ads_tile_orange.svg + images/photo.svg + images/crop_original.svg + images/panorama.svg diff --git a/demo/images/ads_icon.svg b/demo/images/ads_icon.svg index 4231be6..ee0ac56 100644 --- a/demo/images/ads_icon.svg +++ b/demo/images/ads_icon.svg @@ -1,77 +1,11 @@ - - - - - electric_iron icon - Licensed under Iconfu Standard License v1.0 (https://www.iconfu.com/iconfu_standard_license) - Incors GmbH - - - - - - - - + + + + + + + + + + diff --git a/demo/images/ads_icon2.svg b/demo/images/ads_icon2.svg new file mode 100644 index 0000000..91a0b02 --- /dev/null +++ b/demo/images/ads_icon2.svg @@ -0,0 +1,13 @@ + + + electric_iron icon - Licensed under Iconfu Standard License v1.0 (https://www.iconfu.com/iconfu_standard_license) - Incors GmbH + + + + + + + + + + diff --git a/demo/images/ads_logo.svg b/demo/images/ads_logo.svg index 1072540..da1b3b4 100644 --- a/demo/images/ads_logo.svg +++ b/demo/images/ads_logo.svg @@ -1,88 +1,12 @@ - - - - - electric_iron icon - Licensed under Iconfu Standard License v1.0 (https://www.iconfu.com/iconfu_standard_license) - Incors GmbH - - Qt Advanced Docking - - - - - - - + + + + Qt Advanced Docking + + + + + + + diff --git a/demo/images/ads_tile_blue.svg b/demo/images/ads_tile_blue.svg new file mode 100644 index 0000000..91ec6dc --- /dev/null +++ b/demo/images/ads_tile_blue.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/images/ads_tile_blue_light.svg b/demo/images/ads_tile_blue_light.svg new file mode 100644 index 0000000..aa9bb83 --- /dev/null +++ b/demo/images/ads_tile_blue_light.svg @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/images/ads_tile_green.svg b/demo/images/ads_tile_green.svg new file mode 100644 index 0000000..ce8075a --- /dev/null +++ b/demo/images/ads_tile_green.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/images/ads_tile_orange.svg b/demo/images/ads_tile_orange.svg new file mode 100644 index 0000000..bb343dd --- /dev/null +++ b/demo/images/ads_tile_orange.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/images/crop_original.svg b/demo/images/crop_original.svg new file mode 100644 index 0000000..a4a6513 --- /dev/null +++ b/demo/images/crop_original.svg @@ -0,0 +1,6 @@ + + crop_original icon - Licensed under Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) - Created with Iconfu.com - Derivative work of Material icons (Copyright Google Inc.) + + + + \ No newline at end of file diff --git a/demo/images/panorama.svg b/demo/images/panorama.svg new file mode 100644 index 0000000..5716c3d --- /dev/null +++ b/demo/images/panorama.svg @@ -0,0 +1,6 @@ + + panorama icon - Licensed under Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) - Created with Iconfu.com - Derivative work of Material icons (Copyright Google Inc.) + + + + \ No newline at end of file diff --git a/demo/images/photo.svg b/demo/images/photo.svg new file mode 100644 index 0000000..6da0234 --- /dev/null +++ b/demo/images/photo.svg @@ -0,0 +1,6 @@ + + photo icon - Licensed under Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) - Created with Iconfu.com - Derivative work of Material icons (Copyright Google Inc.) + + + + \ No newline at end of file