mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-24 07:21:32 +08:00
Added dock manager function addDockWidgetFloating to add initial floating dock widgets
This commit is contained in:
parent
316d9a00b5
commit
aee9fb1c95
@ -57,6 +57,7 @@
|
||||
#include "DockManager.h"
|
||||
#include "DockWidget.h"
|
||||
#include "DockAreaWidget.h"
|
||||
#include "FloatingDockContainer.h"
|
||||
|
||||
|
||||
//============================================================================
|
||||
@ -226,8 +227,11 @@ void MainWindowPrivate::createContent()
|
||||
auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
||||
DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
||||
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
|
||||
//DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
|
||||
//DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
|
||||
|
||||
// Test creation of floating dock widgets
|
||||
auto FloatingWidget = DockManager->addDockWidgetFloating(createFileSystemTreeDockWidget(ViewMenu));
|
||||
FloatingWidget->move(QPoint(0,0));
|
||||
DockManager->addDockWidgetFloating(createLongTextLabelDockWidget(ViewMenu));
|
||||
|
||||
for (auto DockWidget : DockManager->dockWidgetsMap())
|
||||
{
|
||||
@ -309,6 +313,10 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
||||
// uncomment the following line if the tab close button should be
|
||||
// a QToolButton instead of a QPushButton
|
||||
// CDockManager::setConfigFlags(CDockManager::configFlags() | CDockManager::TabCloseButtonIsToolButton);
|
||||
auto Flags = CDockManager::configFlags();
|
||||
Flags.setFlag(CDockManager::XmlAutoFormattingEnabled, true);
|
||||
Flags.setFlag(CDockManager::XmlCompressionEnabled, false);
|
||||
CDockManager::setConfigFlags(Flags);
|
||||
|
||||
// uncomment the following line if you wand a fixed tab width that does
|
||||
// not change if the visibility of the close button changes
|
||||
@ -328,7 +336,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
||||
// Default window geometry
|
||||
resize(1280, 720);
|
||||
|
||||
d->restoreState();
|
||||
//d->restoreState();
|
||||
d->restorePerspectives();
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,7 @@ private:
|
||||
friend struct DockWidgetPrivate;
|
||||
friend class CDockWidget;
|
||||
friend struct DockManagerPrivate;
|
||||
friend class CDockManager;
|
||||
|
||||
private slots:
|
||||
void onTabCloseRequested(int Index);
|
||||
|
@ -76,6 +76,7 @@ struct DockManagerPrivate
|
||||
QMenu* ViewMenu;
|
||||
CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted;
|
||||
bool RestoringState = false;
|
||||
QVector<CFloatingDockContainer*> UninitializedFloatingWidgets;
|
||||
|
||||
/**
|
||||
* Private data constructor
|
||||
@ -560,6 +561,48 @@ bool CDockManager::restoreState(const QByteArray &state, int version)
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CFloatingDockContainer* CDockManager::addDockWidgetFloating(CDockWidget* Dockwidget)
|
||||
{
|
||||
d->DockWidgetsMap.insert(Dockwidget->objectName(), Dockwidget);
|
||||
CDockAreaWidget* OldDockArea = Dockwidget->dockAreaWidget();
|
||||
if (OldDockArea)
|
||||
{
|
||||
OldDockArea->removeDockWidget(Dockwidget);
|
||||
}
|
||||
|
||||
Dockwidget->setDockManager(this);
|
||||
CFloatingDockContainer* FloatingWidget = new CFloatingDockContainer(Dockwidget);
|
||||
FloatingWidget->resize(Dockwidget->size());
|
||||
if (isVisible())
|
||||
{
|
||||
FloatingWidget->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
d->UninitializedFloatingWidgets.append(FloatingWidget);
|
||||
}
|
||||
return FloatingWidget;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockManager::showEvent(QShowEvent *event)
|
||||
{
|
||||
Super::showEvent(event);
|
||||
if (d->UninitializedFloatingWidgets.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto FloatingWidget : d->UninitializedFloatingWidgets)
|
||||
{
|
||||
FloatingWidget->show();
|
||||
}
|
||||
d->UninitializedFloatingWidgets.clear();
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area,
|
||||
CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget)
|
||||
|
@ -111,7 +111,14 @@ protected:
|
||||
*/
|
||||
CDockOverlay* dockAreaOverlay() const;
|
||||
|
||||
/**
|
||||
* Show the floating widgets that has been created floating
|
||||
*/
|
||||
virtual void showEvent(QShowEvent *event) override;
|
||||
|
||||
public:
|
||||
using Super = CDockContainerWidget;
|
||||
|
||||
enum eViewMenuInsertionOrder
|
||||
{
|
||||
MenuSortedByInsertion,
|
||||
@ -206,6 +213,12 @@ public:
|
||||
CDockAreaWidget* addDockWidgetTabToArea(CDockWidget* Dockwidget,
|
||||
CDockAreaWidget* DockAreaWidget);
|
||||
|
||||
/**
|
||||
* Adds the given DockWidget floating and returns the created
|
||||
* CFloatingDockContainer instance.
|
||||
*/
|
||||
CFloatingDockContainer* addDockWidgetFloating(CDockWidget* Dockwidget);
|
||||
|
||||
/**
|
||||
* Searches for a registered doc widget with the given ObjectName
|
||||
* \return Return the found dock widget or nullptr if a dock widget with the
|
||||
|
Loading…
Reference in New Issue
Block a user