From 7ba20f37b7775c6b0f14fd8ef7e48d0f09f13c3e Mon Sep 17 00:00:00 2001 From: mvidelgauz Date: Mon, 10 Feb 2020 21:07:36 +0200 Subject: [PATCH 1/7] Icon of floating window (#116) * FloatingContainerHasWidgetTitle and FloatingContainerHasWidgetIcon config flags --- demo/MainWindow.cpp | 8 ++++++- src/DockManager.h | 5 +++- src/FloatingDockContainer.cpp | 45 +++++++++++++++++++++++++++++++---- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 518e76f..346d76d 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -320,7 +320,7 @@ void MainWindowPrivate::createContent() appendFeaturStringToWindowTitle(FileSystemWidget); auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget); - // We create a calender widget and clear all flags to prevent the dock area + // We create a calendar widget and clear all flags to prevent the dock area // from closing DockWidget = createCalendarDockWidget(ViewMenu); DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false); @@ -481,6 +481,12 @@ CMainWindow::CMainWindow(QWidget *parent) : // uncomment the following line if you want to show tabs menu button on DockArea's title bar only when there are more than one tab and at least of them has elided title //CDockManager::setConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility, true); + // uncomment the following line if you want floating container to always show application title instead of active dock widget's title + //CDockManager::setConfigFlag(CDockManager::FloatingContainerHasWidgetTitle, false); + + // uncomment the following line if you want floating container to show active dock widget's icon instead of always showing application icon + //CDockManager::setConfigFlag(CDockManager::FloatingContainerHasWidgetIcon, true); + // Now create the dock manager and its content d->DockManager = new CDockManager(this); diff --git a/src/DockManager.h b/src/DockManager.h index 73f6c22..a94ea41 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -162,6 +162,8 @@ public: DockAreaHasTabsMenuButton = 0x8000, //!< If the flag is set each dock area has a tabs menu button DockAreaHideDisabledButtons = 0x10000, //!< If the flag is set disabled dock area buttons will not appear on the tollbar at all (enabling them will bring them back) DockAreaDynamicTabsMenuButtonVisibility = 0x20000, //!< If the flag is set dock area will disable a tabs menu button when there is only one tab in the area + FloatingContainerHasWidgetTitle = 0x40000, + FloatingContainerHasWidgetIcon = 0x80000, DefaultDockAreaButtons = DockAreaHasCloseButton @@ -170,7 +172,8 @@ public: DefaultBaseConfig = DefaultDockAreaButtons | ActiveTabHasCloseButton - | XmlCompressionEnabled,///< default base configuration settings + | XmlCompressionEnabled + | FloatingContainerHasWidgetTitle,///< default base configuration settings DefaultOpaqueConfig = DefaultBaseConfig | OpaqueSplitterResize diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index e04dce5..ea782d4 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -79,6 +79,14 @@ struct FloatingDockContainerPrivate void titleMouseReleaseEvent(); void updateDropOverlays(const QPoint &GlobalPos); + /** + * Returns true if the given config flag is set + */ + static bool testConfigFlag(CDockManager::eConfigFlag Flag) + { + return CDockManager::configFlags().testFlag(Flag); + } + /** * Tests is a certain state is active */ @@ -100,6 +108,31 @@ struct FloatingDockContainerPrivate _this->setWindowTitle(Text); #endif } + + void reflectCurrentWidget(CDockWidget* CurrentWidget) + { + // reflect CurrentWidget's title if configured to do so, otherwise display application name as window title + if (testConfigFlag(CDockManager::FloatingContainerHasWidgetTitle)) + { + setWindowTitle(CurrentWidget->windowTitle()); + } + else + { + setWindowTitle(qApp->applicationDisplayName()); + } + + // reflect CurrentWidget's icon if configured to do so, otherwise display application icon as window icon + QIcon CurrentWidgetIcon = CurrentWidget->icon(); + if (testConfigFlag(CDockManager::FloatingContainerHasWidgetIcon) + && !CurrentWidgetIcon.isNull()) + { + _this->setWindowIcon(CurrentWidget->icon()); + } + else + { + _this->setWindowIcon(QApplication::windowIcon()); + } + } }; // struct FloatingDockContainerPrivate @@ -537,8 +570,8 @@ void CFloatingDockContainer::onDockAreasAddedOrRemoved() if (TopLevelDockArea) { d->SingleDockArea = TopLevelDockArea; - d->setWindowTitle( - d->SingleDockArea->currentDockWidget()->windowTitle()); + CDockWidget* CurrentWidget = d->SingleDockArea->currentDockWidget(); + d->reflectCurrentWidget(CurrentWidget); connect(d->SingleDockArea, SIGNAL(currentChanged(int)), this, SLOT(onDockAreaCurrentChanged(int))); } @@ -551,6 +584,7 @@ void CFloatingDockContainer::onDockAreasAddedOrRemoved() d->SingleDockArea = nullptr; } d->setWindowTitle(qApp->applicationDisplayName()); + setWindowIcon(QApplication::windowIcon()); } } @@ -560,11 +594,13 @@ void CFloatingDockContainer::updateWindowTitle() auto TopLevelDockArea = d->DockContainer->topLevelDockArea(); if (TopLevelDockArea) { - d->setWindowTitle(TopLevelDockArea->currentDockWidget()->windowTitle()); + CDockWidget* CurrentWidget = TopLevelDockArea->currentDockWidget(); + d->reflectCurrentWidget(CurrentWidget); } else { d->setWindowTitle(qApp->applicationDisplayName()); + setWindowIcon(QApplication::windowIcon()); } } @@ -572,7 +608,8 @@ void CFloatingDockContainer::updateWindowTitle() void CFloatingDockContainer::onDockAreaCurrentChanged(int Index) { Q_UNUSED(Index); - d->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle()); + CDockWidget* CurrentWidget = d->SingleDockArea->currentDockWidget(); + d->reflectCurrentWidget(CurrentWidget); } //============================================================================ From ff1439c719ac7eefafb175f488a13dd2134eec0b Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Tue, 11 Feb 2020 08:32:49 +0100 Subject: [PATCH 2/7] Added CDockComponentsFactory for creation of components for the docking framework --- CMakeLists.txt | 2 + src/DockAreaTitleBar.cpp | 3 +- src/DockAreaWidget.cpp | 9 +++-- src/DockComponentsFactory.cpp | 61 +++++++++++++++++++++++++++++++ src/DockComponentsFactory.h | 69 +++++++++++++++++++++++++++++++++++ src/DockManager.h | 1 + src/DockWidget.cpp | 3 +- src/src.pro | 6 ++- 8 files changed, 146 insertions(+), 8 deletions(-) create mode 100644 src/DockComponentsFactory.cpp create mode 100644 src/DockComponentsFactory.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a4b6b1..578dfc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ set(ads_SRCS src/FloatingDockContainer.cpp src/FloatingDragPreview.cpp src/IconProvider.cpp + src/DockComponentsFactory.cpp src/ads.qrc src/linux/FloatingWidgetTitleBar.cpp ) @@ -61,6 +62,7 @@ set(ads_INSTALL_INCLUDE src/FloatingDockContainer.h src/FloatingDragPreview.h src/IconProvider.h + src/DockComponentsFactory.h src/linux/FloatingWidgetTitleBar.h ) if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index 8aa724e..a5024e5 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -49,6 +49,7 @@ #include "DockWidgetTab.h" #include "DockAreaTabBar.h" #include "IconProvider.h" +#include "DockComponentsFactory.h" #include @@ -273,7 +274,7 @@ void DockAreaTitleBarPrivate::createButtons() //============================================================================ void DockAreaTitleBarPrivate::createTabBar() { - TabBar = new CDockAreaTabBar(DockArea); + TabBar = componentsFactory()->createDockAreaTabBar(DockArea); TabBar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); Layout->addWidget(TabBar); _this->connect(TabBar, SIGNAL(tabClosed(int)), SLOT(markTabsMenuOutdated())); diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 354102d..cda1d65 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -28,9 +28,10 @@ //============================================================================ // INCLUDES //============================================================================ -#include "DockWidgetTab.h" #include "DockAreaWidget.h" +#include + #include #include #include @@ -53,8 +54,8 @@ #include "DockAreaTabBar.h" #include "DockSplitter.h" #include "DockAreaTitleBar.h" - -#include +#include "DockComponentsFactory.h" +#include "DockWidgetTab.h" namespace ads @@ -317,7 +318,7 @@ DockAreaWidgetPrivate::DockAreaWidgetPrivate(CDockAreaWidget* _public) : //============================================================================ void DockAreaWidgetPrivate::createTitleBar() { - TitleBar = new CDockAreaTitleBar(_this); + TitleBar = componentsFactory()->createDockAreaTitleBar(_this); Layout->addWidget(TitleBar); QObject::connect(tabBar(), &CDockAreaTabBar::tabCloseRequested, _this, &CDockAreaWidget::onTabCloseRequested); QObject::connect(TitleBar, &CDockAreaTitleBar::tabBarClicked, _this, &CDockAreaWidget::setCurrentIndex); diff --git a/src/DockComponentsFactory.cpp b/src/DockComponentsFactory.cpp new file mode 100644 index 0000000..e41dff1 --- /dev/null +++ b/src/DockComponentsFactory.cpp @@ -0,0 +1,61 @@ +//============================================================================ +/// \file DockComponentsFactory.cpp +/// \author Uwe Kindler +/// \date 10.02.2020 +/// \brief Implementation of DockComponentsFactory +//============================================================================ + +//============================================================================ +// INCLUDES +//============================================================================ +#include +#include + +#include "DockWidgetTab.h" +#include "DockAreaTabBar.h" +#include "DockAreaTitleBar.h" +#include "DockWidget.h" +#include "DockAreaWidget.h" + +namespace ads +{ +static QScopedPointer DefaultFactory(new CDockComponentsFactory()); + + +//============================================================================ +CDockWidgetTab* CDockComponentsFactory::createDockWidgetTab(CDockWidget* DockWidget) const +{ + return new CDockWidgetTab(DockWidget); +} + + +//============================================================================ +CDockAreaTabBar* CDockComponentsFactory::createDockAreaTabBar(CDockAreaWidget* DockArea) const +{ + return new CDockAreaTabBar(DockArea); +} + + +//============================================================================ +CDockAreaTitleBar* CDockComponentsFactory::createDockAreaTitleBar(CDockAreaWidget* DockArea) const +{ + return new CDockAreaTitleBar(DockArea); +} + + +//============================================================================ +const CDockComponentsFactory* CDockComponentsFactory::defaultFactory() +{ + return DefaultFactory.get(); +} + + +//============================================================================ +void CDockComponentsFactory::setDefaultFactory(CDockComponentsFactory* Factory) +{ + DefaultFactory.reset(Factory); +} +} // namespace ads + +//--------------------------------------------------------------------------- +// EOF DockComponentsFactory.cpp diff --git a/src/DockComponentsFactory.h b/src/DockComponentsFactory.h new file mode 100644 index 0000000..8b9925a --- /dev/null +++ b/src/DockComponentsFactory.h @@ -0,0 +1,69 @@ +#ifndef DockComponentsFactoryH +#define DockComponentsFactoryH +//============================================================================ +/// \file DockComponentsFactory.h +/// \author Uwe Kindler +/// \date 10.02.2020 +/// \brief Declaration of DockComponentsFactory +//============================================================================ + +//============================================================================ +// INCLUDES +//============================================================================ +namespace ads +{ +class CDockWidgetTab; +class CDockAreaTitleBar; +class CDockAreaTabBar; +class CDockAreaWidget; +class CDockWidget; + + + +/** + * Factory for creation of certain GUI elements for the docking framework. + * A default unique instance provided by CDockComponentsFactory is used for + * creation of all supported components. To inject your custom components, + * you can create your own derived dock components factory and register + * it via setDefaultFactory() function. + * \code + * CDockComponentsFactory::setDefaultFactory(new MyComponentsFactory())); + * \endcode + */ +class CDockComponentsFactory +{ +public: + /** + * Force virtual destructor + */ + virtual ~CDockComponentsFactory() {} + + virtual CDockWidgetTab* createDockWidgetTab(CDockWidget* DockWidget) const; + virtual CDockAreaTabBar* createDockAreaTabBar(CDockAreaWidget* DockArea) const; + virtual CDockAreaTitleBar* createDockAreaTitleBar(CDockAreaWidget* DockArea) const; + + /** + * Returns the default components factory + */ + static const CDockComponentsFactory* defaultFactory(); + + /** + * Sets a new default factory for creation of GUI elements. + * This function takes ownership of the given Factory. + */ + static void setDefaultFactory(CDockComponentsFactory* Factory); +}; + + +/** + * Convenience function to ease factory instance access + */ +inline const CDockComponentsFactory* componentsFactory() +{ + return CDockComponentsFactory::defaultFactory(); +} + +} // namespace ads + +//--------------------------------------------------------------------------- +#endif // DockComponentsFactoryH diff --git a/src/DockManager.h b/src/DockManager.h index 73f6c22..dc099a2 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -59,6 +59,7 @@ class CDockWidgetTab; struct DockWidgetTabPrivate; struct DockAreaWidgetPrivate; class CIconProvider; +class CDockComponentsFactory; /** * The central dock manager that maintains the complete docking system. diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index 3080a62..338a5fa 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -54,6 +54,7 @@ #include "DockManager.h" #include "FloatingDockContainer.h" #include "DockSplitter.h" +#include "DockComponentsFactory.h" #include "ads_globals.h" @@ -220,7 +221,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) : setWindowTitle(title); setObjectName(title); - d->TabWidget = new CDockWidgetTab(this); + d->TabWidget = componentsFactory()->createDockWidgetTab(this); d->ToggleViewAction = new QAction(title, this); d->ToggleViewAction->setCheckable(true); connect(d->ToggleViewAction, SIGNAL(triggered(bool)), this, diff --git a/src/src.pro b/src/src.pro index 755c7e5..73367b0 100644 --- a/src/src.pro +++ b/src/src.pro @@ -43,7 +43,8 @@ HEADERS += \ DockSplitter.h \ DockAreaTitleBar.h \ ElidingLabel.h \ - IconProvider.h + IconProvider.h \ + DockComponentsFactory.h SOURCES += \ @@ -61,7 +62,8 @@ SOURCES += \ DockSplitter.cpp \ DockAreaTitleBar.cpp \ ElidingLabel.cpp \ - IconProvider.cpp + IconProvider.cpp \ + DockComponentsFactory.cpp unix { From 65eeffd5e168bd7d73c675d80d5c5d3262b34ac5 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Tue, 11 Feb 2020 09:31:57 +0100 Subject: [PATCH 3/7] Added showcase for DockComponentsFactory - a help button is injected into a title bar --- demo/MainWindow.cpp | 64 ++++++++++++++++++++++++----------- demo/demo.qrc | 1 + src/DockComponentsFactory.cpp | 11 ++++-- src/DockComponentsFactory.h | 15 +++++--- 4 files changed, 66 insertions(+), 25 deletions(-) diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 518e76f..186ad37 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -73,6 +73,8 @@ #include "DockAreaTitleBar.h" #include "DockAreaTabBar.h" #include "FloatingDockContainer.h" +#include "DockComponentsFactory.h" + //============================================================================ @@ -142,6 +144,25 @@ static QIcon svgIcon(const QString& File) } +//============================================================================ +class CCustomComponentsFactory : public ads::CDockComponentsFactory +{ +public: + using Super = ads::CDockComponentsFactory; + ads::CDockAreaTitleBar* createDockAreaTitleBar(ads::CDockAreaWidget* DockArea) const override + { + auto TitleBar = Super::createDockAreaTitleBar(DockArea); + auto CustomButton = new QToolButton(DockArea); + CustomButton->setToolTip(QObject::tr("Help")); + CustomButton->setIcon(svgIcon(":/adsdemo/images/help_outline.svg")); + CustomButton->setAutoRaise(true); + int Index = TitleBar->indexOf(TitleBar->button(ads::TitleBarButtonTabsMenu)); + TitleBar->insertWidget(Index + 1, CustomButton); + return TitleBar; + } +}; + + //============================================================================ static ads::CDockWidget* createCalendarDockWidget(QMenu* ViewMenu) { @@ -202,28 +223,29 @@ static ads::CDockWidget* createEditorWidget(QMenu* ViewMenu) return DockWidget; } + //============================================================================ static ads::CDockWidget* createTableWidget(QMenu* ViewMenu) { - static int TableCount = 0; - QTableWidget* w = new QTableWidget(); - ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Table %1").arg(TableCount++)); - static int colCount = 5; - static int rowCount = 30; - w->setColumnCount(colCount); - w->setRowCount(rowCount); - for (int col = 0; col < colCount; ++col) - { - w->setHorizontalHeaderItem(col, new QTableWidgetItem(QString("Col %1").arg(col+1))); - for (int row = 0; row < rowCount; ++row) - { - w->setItem(row, col, new QTableWidgetItem(QString("T %1-%2").arg(row + 1).arg(col+1))); - } - } - DockWidget->setWidget(w); - DockWidget->setIcon(svgIcon(":/adsdemo/images/grid_on.svg")); - ViewMenu->addAction(DockWidget->toggleViewAction()); - return DockWidget; + static int TableCount = 0; + QTableWidget* w = new QTableWidget(); + ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Table %1").arg(TableCount++)); + static int colCount = 5; + static int rowCount = 30; + w->setColumnCount(colCount); + w->setRowCount(rowCount); + for (int col = 0; col < colCount; ++col) + { + w->setHorizontalHeaderItem(col, new QTableWidgetItem(QString("Col %1").arg(col+1))); + for (int row = 0; row < rowCount; ++row) + { + w->setItem(row, col, new QTableWidgetItem(QString("T %1-%2").arg(row + 1).arg(col+1))); + } + } + DockWidget->setWidget(w); + DockWidget->setIcon(svgIcon(":/adsdemo/images/grid_on.svg")); + ViewMenu->addAction(DockWidget->toggleViewAction()); + return DockWidget; } @@ -318,7 +340,11 @@ void MainWindowPrivate::createContent() FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetMovable, false); FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false); appendFeaturStringToWindowTitle(FileSystemWidget); + + // Test custom factory - we inject a help button into the title bar + ads::CDockComponentsFactory::setFactory(new CCustomComponentsFactory()); auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget); + ads::CDockComponentsFactory::resetDefaultFactory(); // We create a calender widget and clear all flags to prevent the dock area // from closing diff --git a/demo/demo.qrc b/demo/demo.qrc index 7bc93db..ddd49d8 100644 --- a/demo/demo.qrc +++ b/demo/demo.qrc @@ -12,5 +12,6 @@ images/custom-menu-button.svg app.css images/plus.svg + images/help_outline.svg diff --git a/src/DockComponentsFactory.cpp b/src/DockComponentsFactory.cpp index e41dff1..8c717de 100644 --- a/src/DockComponentsFactory.cpp +++ b/src/DockComponentsFactory.cpp @@ -44,17 +44,24 @@ CDockAreaTitleBar* CDockComponentsFactory::createDockAreaTitleBar(CDockAreaWidge //============================================================================ -const CDockComponentsFactory* CDockComponentsFactory::defaultFactory() +const CDockComponentsFactory* CDockComponentsFactory::factory() { return DefaultFactory.get(); } //============================================================================ -void CDockComponentsFactory::setDefaultFactory(CDockComponentsFactory* Factory) +void CDockComponentsFactory::setFactory(CDockComponentsFactory* Factory) { DefaultFactory.reset(Factory); } + + +//============================================================================ +void CDockComponentsFactory::resetDefaultFactory() +{ + DefaultFactory.reset(new CDockComponentsFactory()); +} } // namespace ads //--------------------------------------------------------------------------- diff --git a/src/DockComponentsFactory.h b/src/DockComponentsFactory.h index 8b9925a..92e7f52 100644 --- a/src/DockComponentsFactory.h +++ b/src/DockComponentsFactory.h @@ -10,6 +10,8 @@ //============================================================================ // INCLUDES //============================================================================ +#include "ads_globals.h" + namespace ads { class CDockWidgetTab; @@ -30,7 +32,7 @@ class CDockWidget; * CDockComponentsFactory::setDefaultFactory(new MyComponentsFactory())); * \endcode */ -class CDockComponentsFactory +class ADS_EXPORT CDockComponentsFactory { public: /** @@ -45,13 +47,18 @@ public: /** * Returns the default components factory */ - static const CDockComponentsFactory* defaultFactory(); + static const CDockComponentsFactory* factory(); /** * Sets a new default factory for creation of GUI elements. * This function takes ownership of the given Factory. */ - static void setDefaultFactory(CDockComponentsFactory* Factory); + static void setFactory(CDockComponentsFactory* Factory); + + /** + * Resets the current factory to the + */ + static void resetDefaultFactory(); }; @@ -60,7 +67,7 @@ public: */ inline const CDockComponentsFactory* componentsFactory() { - return CDockComponentsFactory::defaultFactory(); + return CDockComponentsFactory::factory(); } } // namespace ads From 3eba02597ce2846b5ea7a43eb343538454af1fd2 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Tue, 11 Feb 2020 11:57:53 +0100 Subject: [PATCH 4/7] Added missing svg icon --- demo/images/help_outline.svg | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 demo/images/help_outline.svg diff --git a/demo/images/help_outline.svg b/demo/images/help_outline.svg new file mode 100644 index 0000000..66f85ee --- /dev/null +++ b/demo/images/help_outline.svg @@ -0,0 +1,6 @@ + + help_outline 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 From 3efc5f2ada7cae5c084fd25e5d86c3d68d62ad0d Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Tue, 11 Feb 2020 15:38:49 +0100 Subject: [PATCH 5/7] Added DockComponentsFactory.h documentation, changed DockComponentsFactory showcase in MainWindow after discussion on GitHub --- demo/MainWindow.cpp | 2 +- src/DockComponentsFactory.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 186ad37..5a19d91 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -151,7 +151,7 @@ public: using Super = ads::CDockComponentsFactory; ads::CDockAreaTitleBar* createDockAreaTitleBar(ads::CDockAreaWidget* DockArea) const override { - auto TitleBar = Super::createDockAreaTitleBar(DockArea); + auto TitleBar = new ads::CDockAreaTitleBar(DockArea); auto CustomButton = new QToolButton(DockArea); CustomButton->setToolTip(QObject::tr("Help")); CustomButton->setIcon(svgIcon(":/adsdemo/images/help_outline.svg")); diff --git a/src/DockComponentsFactory.h b/src/DockComponentsFactory.h index 92e7f52..f0598e9 100644 --- a/src/DockComponentsFactory.h +++ b/src/DockComponentsFactory.h @@ -40,8 +40,22 @@ public: */ virtual ~CDockComponentsFactory() {} + /** + * This default implementation just creates a dock widget tab with + * new CDockWidgetTab(DockWIdget). + */ virtual CDockWidgetTab* createDockWidgetTab(CDockWidget* DockWidget) const; + + /** + * This default implementation just creates a dock area tab bar with + * new CDockAreaTabBar(DockArea). + */ virtual CDockAreaTabBar* createDockAreaTabBar(CDockAreaWidget* DockArea) const; + + /** + * This default implementation just creates a dock area title bar with + * new CDockAreaTitleBar(DockArea). + */ virtual CDockAreaTitleBar* createDockAreaTitleBar(CDockAreaWidget* DockArea) const; /** From 1916bd726d92e55fae195a90ef510166d7e41d63 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Tue, 11 Feb 2020 15:46:19 +0100 Subject: [PATCH 6/7] Fixed build issue for older Qt versions --- src/DockComponentsFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DockComponentsFactory.cpp b/src/DockComponentsFactory.cpp index 8c717de..28004be 100644 --- a/src/DockComponentsFactory.cpp +++ b/src/DockComponentsFactory.cpp @@ -46,7 +46,7 @@ CDockAreaTitleBar* CDockComponentsFactory::createDockAreaTitleBar(CDockAreaWidge //============================================================================ const CDockComponentsFactory* CDockComponentsFactory::factory() { - return DefaultFactory.get(); + return DefaultFactory.data(); } From 41173d067bb73a874e6da54df7b75bb9e8f3da19 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Thu, 13 Feb 2020 13:45:40 +0100 Subject: [PATCH 7/7] Switched QScopedPointer to std::unique_ptr in DockComponentsFactory --- src/DockComponentsFactory.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/DockComponentsFactory.cpp b/src/DockComponentsFactory.cpp index 28004be..85a5475 100644 --- a/src/DockComponentsFactory.cpp +++ b/src/DockComponentsFactory.cpp @@ -9,7 +9,8 @@ // INCLUDES //============================================================================ #include -#include + +#include #include "DockWidgetTab.h" #include "DockAreaTabBar.h" @@ -19,7 +20,7 @@ namespace ads { -static QScopedPointer DefaultFactory(new CDockComponentsFactory()); +static std::unique_ptr DefaultFactory(new CDockComponentsFactory()); //============================================================================ @@ -46,7 +47,7 @@ CDockAreaTitleBar* CDockComponentsFactory::createDockAreaTitleBar(CDockAreaWidge //============================================================================ const CDockComponentsFactory* CDockComponentsFactory::factory() { - return DefaultFactory.data(); + return DefaultFactory.get(); }