mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 23:51:33 +08:00
Added CDockComponentsFactory for creation of components for the docking framework
This commit is contained in:
parent
a4ef161f4f
commit
ff1439c719
@ -42,6 +42,7 @@ set(ads_SRCS
|
|||||||
src/FloatingDockContainer.cpp
|
src/FloatingDockContainer.cpp
|
||||||
src/FloatingDragPreview.cpp
|
src/FloatingDragPreview.cpp
|
||||||
src/IconProvider.cpp
|
src/IconProvider.cpp
|
||||||
|
src/DockComponentsFactory.cpp
|
||||||
src/ads.qrc
|
src/ads.qrc
|
||||||
src/linux/FloatingWidgetTitleBar.cpp
|
src/linux/FloatingWidgetTitleBar.cpp
|
||||||
)
|
)
|
||||||
@ -61,6 +62,7 @@ set(ads_INSTALL_INCLUDE
|
|||||||
src/FloatingDockContainer.h
|
src/FloatingDockContainer.h
|
||||||
src/FloatingDragPreview.h
|
src/FloatingDragPreview.h
|
||||||
src/IconProvider.h
|
src/IconProvider.h
|
||||||
|
src/DockComponentsFactory.h
|
||||||
src/linux/FloatingWidgetTitleBar.h
|
src/linux/FloatingWidgetTitleBar.h
|
||||||
)
|
)
|
||||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
|
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include "DockWidgetTab.h"
|
#include "DockWidgetTab.h"
|
||||||
#include "DockAreaTabBar.h"
|
#include "DockAreaTabBar.h"
|
||||||
#include "IconProvider.h"
|
#include "IconProvider.h"
|
||||||
|
#include "DockComponentsFactory.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -273,7 +274,7 @@ void DockAreaTitleBarPrivate::createButtons()
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void DockAreaTitleBarPrivate::createTabBar()
|
void DockAreaTitleBarPrivate::createTabBar()
|
||||||
{
|
{
|
||||||
TabBar = new CDockAreaTabBar(DockArea);
|
TabBar = componentsFactory()->createDockAreaTabBar(DockArea);
|
||||||
TabBar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
TabBar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||||
Layout->addWidget(TabBar);
|
Layout->addWidget(TabBar);
|
||||||
_this->connect(TabBar, SIGNAL(tabClosed(int)), SLOT(markTabsMenuOutdated()));
|
_this->connect(TabBar, SIGNAL(tabClosed(int)), SLOT(markTabsMenuOutdated()));
|
||||||
|
@ -28,9 +28,10 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
#include "DockWidgetTab.h"
|
|
||||||
#include "DockAreaWidget.h"
|
#include "DockAreaWidget.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
@ -53,8 +54,8 @@
|
|||||||
#include "DockAreaTabBar.h"
|
#include "DockAreaTabBar.h"
|
||||||
#include "DockSplitter.h"
|
#include "DockSplitter.h"
|
||||||
#include "DockAreaTitleBar.h"
|
#include "DockAreaTitleBar.h"
|
||||||
|
#include "DockComponentsFactory.h"
|
||||||
#include <iostream>
|
#include "DockWidgetTab.h"
|
||||||
|
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
@ -317,7 +318,7 @@ DockAreaWidgetPrivate::DockAreaWidgetPrivate(CDockAreaWidget* _public) :
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void DockAreaWidgetPrivate::createTitleBar()
|
void DockAreaWidgetPrivate::createTitleBar()
|
||||||
{
|
{
|
||||||
TitleBar = new CDockAreaTitleBar(_this);
|
TitleBar = componentsFactory()->createDockAreaTitleBar(_this);
|
||||||
Layout->addWidget(TitleBar);
|
Layout->addWidget(TitleBar);
|
||||||
QObject::connect(tabBar(), &CDockAreaTabBar::tabCloseRequested, _this, &CDockAreaWidget::onTabCloseRequested);
|
QObject::connect(tabBar(), &CDockAreaTabBar::tabCloseRequested, _this, &CDockAreaWidget::onTabCloseRequested);
|
||||||
QObject::connect(TitleBar, &CDockAreaTitleBar::tabBarClicked, _this, &CDockAreaWidget::setCurrentIndex);
|
QObject::connect(TitleBar, &CDockAreaTitleBar::tabBarClicked, _this, &CDockAreaWidget::setCurrentIndex);
|
||||||
|
61
src/DockComponentsFactory.cpp
Normal file
61
src/DockComponentsFactory.cpp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
//============================================================================
|
||||||
|
/// \file DockComponentsFactory.cpp
|
||||||
|
/// \author Uwe Kindler
|
||||||
|
/// \date 10.02.2020
|
||||||
|
/// \brief Implementation of DockComponentsFactory
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// INCLUDES
|
||||||
|
//============================================================================
|
||||||
|
#include <DockComponentsFactory.h>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
|
#include "DockWidgetTab.h"
|
||||||
|
#include "DockAreaTabBar.h"
|
||||||
|
#include "DockAreaTitleBar.h"
|
||||||
|
#include "DockWidget.h"
|
||||||
|
#include "DockAreaWidget.h"
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
static QScopedPointer<CDockComponentsFactory> 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
|
69
src/DockComponentsFactory.h
Normal file
69
src/DockComponentsFactory.h
Normal file
@ -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
|
@ -59,6 +59,7 @@ class CDockWidgetTab;
|
|||||||
struct DockWidgetTabPrivate;
|
struct DockWidgetTabPrivate;
|
||||||
struct DockAreaWidgetPrivate;
|
struct DockAreaWidgetPrivate;
|
||||||
class CIconProvider;
|
class CIconProvider;
|
||||||
|
class CDockComponentsFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The central dock manager that maintains the complete docking system.
|
* The central dock manager that maintains the complete docking system.
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
#include "DockManager.h"
|
#include "DockManager.h"
|
||||||
#include "FloatingDockContainer.h"
|
#include "FloatingDockContainer.h"
|
||||||
#include "DockSplitter.h"
|
#include "DockSplitter.h"
|
||||||
|
#include "DockComponentsFactory.h"
|
||||||
#include "ads_globals.h"
|
#include "ads_globals.h"
|
||||||
|
|
||||||
|
|
||||||
@ -220,7 +221,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
|
|||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
setObjectName(title);
|
setObjectName(title);
|
||||||
|
|
||||||
d->TabWidget = new CDockWidgetTab(this);
|
d->TabWidget = componentsFactory()->createDockWidgetTab(this);
|
||||||
d->ToggleViewAction = new QAction(title, this);
|
d->ToggleViewAction = new QAction(title, this);
|
||||||
d->ToggleViewAction->setCheckable(true);
|
d->ToggleViewAction->setCheckable(true);
|
||||||
connect(d->ToggleViewAction, SIGNAL(triggered(bool)), this,
|
connect(d->ToggleViewAction, SIGNAL(triggered(bool)), this,
|
||||||
|
@ -43,7 +43,8 @@ HEADERS += \
|
|||||||
DockSplitter.h \
|
DockSplitter.h \
|
||||||
DockAreaTitleBar.h \
|
DockAreaTitleBar.h \
|
||||||
ElidingLabel.h \
|
ElidingLabel.h \
|
||||||
IconProvider.h
|
IconProvider.h \
|
||||||
|
DockComponentsFactory.h
|
||||||
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
@ -61,7 +62,8 @@ SOURCES += \
|
|||||||
DockSplitter.cpp \
|
DockSplitter.cpp \
|
||||||
DockAreaTitleBar.cpp \
|
DockAreaTitleBar.cpp \
|
||||||
ElidingLabel.cpp \
|
ElidingLabel.cpp \
|
||||||
IconProvider.cpp
|
IconProvider.cpp \
|
||||||
|
DockComponentsFactory.cpp
|
||||||
|
|
||||||
|
|
||||||
unix {
|
unix {
|
||||||
|
Loading…
Reference in New Issue
Block a user