Skip to content

Commit 8853c75

Browse files
Merge branch 'master' into linux_experimental
2 parents 5425f2b + e978a32 commit 8853c75

10 files changed

+75
-9
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Advanced Docking System for Qt
22
[![Build Status](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System.svg?branch=master)](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System)
33
[![Build status](https://ci.appveyor.com/api/projects/status/qcfb3cy932jw9mpy/branch/master?svg=true)](https://ci.appveyor.com/project/githubuser0xFFFF/qt-advanced-docking-system/branch/master)
4+
[![License: LGPL v2.1](https://img.shields.io/badge/License-LGPL%20v2.1-blue.svg)](gnu-lgpl-v2.1.md)
45

56

67

@@ -60,9 +61,22 @@ main window layout.
6061
![Perspective](doc/perspectives_dark.png)
6162

6263
## Tested Compatible Environments
63-
- Windows 10 [![Build status](https://ci.appveyor.com/api/projects/status/qcfb3cy932jw9mpy/branch/master?svg=true)](https://ci.appveyor.com/project/githubuser0xFFFF/qt-advanced-docking-system/branch/master)
64-
- Ubuntu [![Build Status](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System.svg?branch=master)](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System)
65-
- macOS [![Build Status](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System.svg?branch=master)](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System)
64+
### Windows
65+
Windows 10 [![Build status](https://ci.appveyor.com/api/projects/status/qcfb3cy932jw9mpy/branch/master?svg=true)](https://ci.appveyor.com/project/githubuser0xFFFF/qt-advanced-docking-system/branch/master)
66+
67+
The library was developed on and for Windows. It is used in a commercial Windows application and is therefore constantly tested.
68+
69+
### macOS
70+
macOS [![Build Status](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System.svg?branch=master)](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System)
71+
72+
The application can be compiled for macOS. A user reported, that the library works on macOS. If have not tested it.
73+
74+
### Linux
75+
Ubuntu [![Build Status](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System.svg?branch=master)](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System)
76+
77+
The application can be compiled for Linux but the master branch doesn't work under Linux because some required features are not supported by Linux. But there is the branch **linux_experimental** which was developed and tested with **Kubuntu 18.04**. and which should also work on other Linux distributions. The branch needs more testing and maybe some imrpovements before it can be merged into master.
78+
79+
![Advanced Docking on Linux](doc/linux_kubuntu_1804.png)
6680

6781
## Build
6882
Open the `ads.pro` with QtCreator and start the build, that's it.
@@ -144,5 +158,6 @@ MainWindow::~MainWindow()
144158
- Manuel Freiholz
145159
146160
## License information
161+
[![License: LGPL v2.1](https://img.shields.io/badge/License-LGPL%20v2.1-blue.svg)](gnu-lgpl-v2.1.md)
147162
This project uses the [LGPLv2.1 license](gnu-lgpl-v2.1.md)
148163

demo/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
2323
set(ads_demo_SRCS
2424
main.cpp
2525
MainWindow.cpp
26-
MainWindow.ui
26+
mainwindow.ui
2727
main.qrc
2828
)
2929
add_executable(AdvancedDockingSystemDemo WIN32 ${ads_demo_SRCS})

doc/linux_kubuntu_1804.png

232 KB
Loading

src/DockAreaWidget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,14 +414,15 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
414414
auto TabWidget = DockWidget->tabWidget();
415415
TabWidget->hide();
416416
d->tabBar()->removeTab(TabWidget);
417+
CDockContainerWidget* DockContainer = dockContainer();
417418
if (NextOpenDockWidget)
418419
{
419420
setCurrentDockWidget(NextOpenDockWidget);
420421
}
421-
else if (d->ContentsLayout->isEmpty())
422+
else if (d->ContentsLayout->isEmpty() && DockContainer->dockAreaCount() > 1)
422423
{
423424
qDebug() << "Dock Area empty";
424-
dockContainer()->removeDockArea(this);
425+
DockContainer->removeDockArea(this);
425426
this->deleteLater();
426427
}
427428
else
@@ -434,14 +435,13 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
434435

435436
d->updateCloseButtonState();
436437
updateTitleBarVisibility();
437-
auto TopLevelDockWidget = dockContainer()->topLevelDockWidget();
438+
auto TopLevelDockWidget = DockContainer->topLevelDockWidget();
438439
if (TopLevelDockWidget)
439440
{
440441
TopLevelDockWidget->emitTopLevelChanged(true);
441442
}
442443

443444
#if (ADS_DEBUG_LEVEL > 0)
444-
CDockContainerWidget* DockContainer = dockContainer();
445445
DockContainer->dumpLayout();
446446
#endif
447447
}

src/DockContainerWidget.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,15 @@ CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockW
998998
}
999999
}
10001000

1001+
//============================================================================
1002+
void CDockContainerWidget::removeDockWidget(CDockWidget* Dockwidget)
1003+
{
1004+
CDockAreaWidget* Area = Dockwidget->dockAreaWidget();
1005+
if (Area)
1006+
{
1007+
Area->removeDockWidget(Dockwidget);
1008+
}
1009+
}
10011010

10021011
//============================================================================
10031012
unsigned int CDockContainerWidget::zOrderIndex() const
@@ -1057,6 +1066,12 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
10571066
area->setParent(nullptr);
10581067
internal::hideEmptyParentSplitters(Splitter);
10591068

1069+
// Remove this area from cached areas
1070+
const auto& cache = d->LastAddedAreaCache;
1071+
if (auto p = std::find(cache, cache+sizeof(cache)/sizeof(cache[0]), area)) {
1072+
d->LastAddedAreaCache[std::distance(cache, p)] = nullptr;
1073+
}
1074+
10601075
// If splitter has more than 1 widgets, we are finished and can leave
10611076
if (Splitter->count() > 1)
10621077
{
@@ -1274,6 +1289,7 @@ bool CDockContainerWidget::restoreState(QXmlStreamReader& s, bool Testing)
12741289
{
12751290
d->VisibleDockAreaCount = -1;// invalidate the dock area count
12761291
d->DockAreas.clear();
1292+
std::fill(std::begin(d->LastAddedAreaCache),std::end(d->LastAddedAreaCache), nullptr);
12771293
}
12781294

12791295
if (IsFloating)

src/DockContainerWidget.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ class ADS_EXPORT CDockContainerWidget : public QFrame
166166
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
167167
CDockAreaWidget* DockAreaWidget = nullptr);
168168

169+
/**
170+
* Removes dockwidget
171+
*/
172+
void removeDockWidget(CDockWidget* Dockwidget);
173+
169174
/**
170175
* Returns the current zOrderIndex
171176
*/

src/DockManager.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,13 @@ CDockAreaWidget* CDockManager::addDockWidgetTab(DockWidgetArea area,
569569
{
570570
return addDockWidget(ads::CenterDockWidgetArea, Dockwidget, AreaWidget);
571571
}
572+
else if (!openedDockAreas().isEmpty())
573+
{
574+
return addDockWidget(area, Dockwidget, openedDockAreas().last());
575+
}
572576
else
573577
{
574-
return addDockWidget(area, Dockwidget, AreaWidget);
578+
return addDockWidget(area, Dockwidget, nullptr);
575579
}
576580
}
577581

@@ -590,6 +594,12 @@ CDockWidget* CDockManager::findDockWidget(const QString& ObjectName) const
590594
return d->DockWidgetsMap.value(ObjectName, nullptr);
591595
}
592596

597+
//============================================================================
598+
void CDockManager::removeDockWidget(CDockWidget* Dockwidget)
599+
{
600+
d->DockWidgetsMap.remove(Dockwidget->objectName());
601+
CDockContainerWidget::removeDockWidget(Dockwidget);
602+
}
593603

594604
//============================================================================
595605
QMap<QString, CDockWidget*> CDockManager::dockWidgetsMap() const

src/DockManager.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
192192
*/
193193
CDockWidget* findDockWidget(const QString& ObjectName) const;
194194

195+
/**
196+
* Remove the given Dock from the dock manager
197+
*/
198+
void removeDockWidget(CDockWidget* Dockwidget);
199+
195200
/**
196201
* This function returns a readable reference to the internal dock
197202
* widgets map so that it is possible to iterate over all dock widgets

src/DockWidget.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,16 @@ void CDockWidget::setWidget(QWidget* widget, eInsertMode InsertMode)
262262
}
263263

264264

265+
//============================================================================
266+
QWidget* CDockWidget::takeWidget()
267+
{
268+
d->ScrollArea->takeWidget();
269+
d->Layout->removeWidget(d->Widget);
270+
d->Widget->setParent(nullptr);
271+
return d->Widget;
272+
}
273+
274+
265275
//============================================================================
266276
QWidget* CDockWidget::widget() const
267277
{

src/DockWidget.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ private slots:
238238
*/
239239
void setWidget(QWidget* widget, eInsertMode InsertMode = AutoScrollArea);
240240

241+
/**
242+
* Remove the widget from the dock and give ownership back to the caller
243+
*/
244+
QWidget* takeWidget();
245+
241246
/**
242247
* Returns the widget for the dock widget. This function returns zero if
243248
* the widget has not been set.

0 commit comments

Comments
 (0)