mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-26 08:01:32 +08:00
Merge branch 'master' into auto_hide_feature
This commit is contained in:
commit
3fded82f26
@ -578,6 +578,14 @@ void MainWindowPrivate::createActions()
|
||||
_this->connect(a, SIGNAL(triggered()), SLOT(createEditor()));
|
||||
ui.menuTests->addAction(a);
|
||||
|
||||
a = ui.toolBar->addAction("Create Editor Tab");
|
||||
a->setProperty("Floating", false);
|
||||
a->setToolTip("Creates a editor tab and inserts it as second tab into an area");
|
||||
a->setIcon(svgIcon(":/adsdemo/images/tab.svg"));
|
||||
a->setProperty("Tabbed", true);
|
||||
_this->connect(a, SIGNAL(triggered()), SLOT(createEditor()));
|
||||
ui.menuTests->addAction(a);
|
||||
|
||||
a = ui.toolBar->addAction("Create Floating Table");
|
||||
a->setToolTip("Creates floating dynamic dockable table with millions of entries");
|
||||
a->setIcon(svgIcon(":/adsdemo/images/grid_on.svg"));
|
||||
@ -829,6 +837,8 @@ void CMainWindow::createEditor()
|
||||
QObject* Sender = sender();
|
||||
QVariant vFloating = Sender->property("Floating");
|
||||
bool Floating = vFloating.isValid() ? vFloating.toBool() : true;
|
||||
QVariant vTabbed = Sender->property("Tabbed");
|
||||
bool Tabbed = vTabbed.isValid() ? vTabbed.toBool() : true;
|
||||
auto DockWidget = d->createEditorWidget();
|
||||
DockWidget->setFeature(ads::CDockWidget::DockWidgetDeleteOnClose, true);
|
||||
DockWidget->setFeature(ads::CDockWidget::DockWidgetForceCloseWithArea, true);
|
||||
@ -840,15 +850,26 @@ void CMainWindow::createEditor()
|
||||
FloatingWidget->move(QPoint(20, 20));
|
||||
d->LastCreatedFloatingEditor = DockWidget;
|
||||
d->LastDockedEditor.clear();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
ads::CDockAreaWidget* EditorArea = d->LastDockedEditor ? d->LastDockedEditor->dockAreaWidget() : nullptr;
|
||||
if (EditorArea)
|
||||
{
|
||||
if (Tabbed)
|
||||
{
|
||||
// Test inserting the dock widget tab at a given position instead
|
||||
// of appending it. This function inserts the new dock widget as
|
||||
// first tab
|
||||
d->DockManager->addDockWidgetTabToArea(DockWidget, EditorArea, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
d->DockManager->setConfigFlag(ads::CDockManager::EqualSplitOnInsertion, true);
|
||||
d->DockManager->addDockWidget(ads::RightDockWidgetArea, DockWidget, EditorArea);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d->LastCreatedFloatingEditor)
|
||||
@ -862,7 +883,6 @@ void CMainWindow::createEditor()
|
||||
}
|
||||
d->LastDockedEditor = DockWidget;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
|
@ -17,6 +17,7 @@
|
||||
<file>images/create_floating_editor.svg</file>
|
||||
<file>images/create_floating_table.svg</file>
|
||||
<file>images/docked_editor.svg</file>
|
||||
<file>images/tab.svg</file>
|
||||
<file>res/visual_studio_light.css</file>
|
||||
<file>images/color_lens.svg</file>
|
||||
<file>images/ads_icon.svg</file>
|
||||
|
6
demo/images/tab.svg
Normal file
6
demo/images/tab.svg
Normal file
@ -0,0 +1,6 @@
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,1024,1024">
|
||||
<desc>tab 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.)</desc>
|
||||
<g fill="#03b8e5" fill-rule="nonzero" style="mix-blend-mode: normal">
|
||||
<path d="M981.33,213.33v597.34c0,46.93 -38.4,85.33 -85.33,85.33h-768c-46.93,0 -85.33,-38.4 -85.33,-85.33v-597.34c0,-46.93 38.4,-85.33 85.33,-85.33h768c46.93,0 85.33,38.4 85.33,85.33zM896,384h-341.33v-170.67h-426.67v597.34h768z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 628 B |
@ -480,6 +480,10 @@ void CDockAreaWidget::addDockWidget(CDockWidget* DockWidget)
|
||||
void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
|
||||
bool Activate)
|
||||
{
|
||||
if (index < 0 || index > d->ContentsLayout->count())
|
||||
{
|
||||
index = d->ContentsLayout->count();
|
||||
}
|
||||
d->ContentsLayout->insertWidget(index, DockWidget);
|
||||
DockWidget->setDockArea(this);
|
||||
DockWidget->tabWidget()->setDockAreaWidget(this);
|
||||
|
@ -169,7 +169,7 @@ public:
|
||||
* Adds dock widget to a existing DockWidgetArea
|
||||
*/
|
||||
CDockAreaWidget* addDockWidgetToDockArea(DockWidgetArea area, CDockWidget* Dockwidget,
|
||||
CDockAreaWidget* TargetDockArea);
|
||||
CDockAreaWidget* TargetDockArea, int Index = -1);
|
||||
|
||||
/**
|
||||
* Add dock area to this container
|
||||
@ -1278,11 +1278,11 @@ void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget)
|
||||
|
||||
//============================================================================
|
||||
CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetArea area,
|
||||
CDockWidget* Dockwidget, CDockAreaWidget* TargetDockArea)
|
||||
CDockWidget* Dockwidget, CDockAreaWidget* TargetDockArea, int Index)
|
||||
{
|
||||
if (CenterDockWidgetArea == area)
|
||||
{
|
||||
TargetDockArea->addDockWidget(Dockwidget);
|
||||
TargetDockArea->insertDockWidget(Index, Dockwidget);
|
||||
TargetDockArea->updateTitleBarVisibility();
|
||||
return TargetDockArea;
|
||||
}
|
||||
@ -1370,7 +1370,7 @@ CDockContainerWidget::~CDockContainerWidget()
|
||||
|
||||
//============================================================================
|
||||
CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
||||
CDockAreaWidget* DockAreaWidget)
|
||||
CDockAreaWidget* DockAreaWidget, int Index)
|
||||
{
|
||||
auto TopLevelDockWidget = topLevelDockWidget();
|
||||
CDockAreaWidget* OldDockArea = Dockwidget->dockAreaWidget();
|
||||
@ -1383,7 +1383,7 @@ CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockW
|
||||
CDockAreaWidget* DockArea;
|
||||
if (DockAreaWidget)
|
||||
{
|
||||
DockArea = d->addDockWidgetToDockArea(area, Dockwidget, DockAreaWidget);
|
||||
DockArea = d->addDockWidgetToDockArea(area, Dockwidget, DockAreaWidget, Index);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -221,7 +221,7 @@ public:
|
||||
* \return Returns the dock area widget that contains the new DockWidget
|
||||
*/
|
||||
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
||||
CDockAreaWidget* DockAreaWidget = nullptr);
|
||||
CDockAreaWidget* DockAreaWidget = nullptr, int Index = -1);
|
||||
|
||||
/**
|
||||
* Removes dockwidget
|
||||
|
@ -851,11 +851,11 @@ void CDockManager::restoreHiddenFloatingWidgets()
|
||||
|
||||
//============================================================================
|
||||
CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area,
|
||||
CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget)
|
||||
CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget, int Index)
|
||||
{
|
||||
d->DockWidgetsMap.insert(Dockwidget->objectName(), Dockwidget);
|
||||
auto Container = DockAreaWidget ? DockAreaWidget->dockContainer() : this;
|
||||
auto AreaOfAddedDockWidget = Container->addDockWidget(area, Dockwidget, DockAreaWidget);
|
||||
auto AreaOfAddedDockWidget = Container->addDockWidget(area, Dockwidget, DockAreaWidget, Index);
|
||||
Q_EMIT dockWidgetAdded(Dockwidget);
|
||||
return AreaOfAddedDockWidget;
|
||||
}
|
||||
@ -907,9 +907,9 @@ CDockAreaWidget* CDockManager::addDockWidgetTab(DockWidgetArea area,
|
||||
|
||||
//============================================================================
|
||||
CDockAreaWidget* CDockManager::addDockWidgetTabToArea(CDockWidget* Dockwidget,
|
||||
CDockAreaWidget* DockAreaWidget)
|
||||
CDockAreaWidget* DockAreaWidget, int Index)
|
||||
{
|
||||
return addDockWidget(ads::CenterDockWidgetArea, Dockwidget, DockAreaWidget);
|
||||
return addDockWidget(ads::CenterDockWidgetArea, Dockwidget, DockAreaWidget, Index);
|
||||
}
|
||||
|
||||
|
||||
|
@ -328,7 +328,7 @@ public:
|
||||
* \return Returns the dock area widget that contains the new DockWidget
|
||||
*/
|
||||
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
||||
CDockAreaWidget* DockAreaWidget = nullptr);
|
||||
CDockAreaWidget* DockAreaWidget = nullptr, int Index = -1);
|
||||
|
||||
/**
|
||||
* Adds dockwidget into the given container.
|
||||
@ -366,9 +366,11 @@ public:
|
||||
/**
|
||||
* This function will add the given Dockwidget to the given DockAreaWidget
|
||||
* as a new tab.
|
||||
* If index is out of range, the tab is simply appended. Otherwise it is
|
||||
* inserted at the specified position.
|
||||
*/
|
||||
CDockAreaWidget* addDockWidgetTabToArea(CDockWidget* Dockwidget,
|
||||
CDockAreaWidget* DockAreaWidget);
|
||||
CDockAreaWidget* DockAreaWidget, int Index = -1);
|
||||
|
||||
/**
|
||||
* Adds the given DockWidget floating and returns the created
|
||||
|
Loading…
Reference in New Issue
Block a user