Skip to content

Commit b320bb1

Browse files
committed
Merge remote-tracking branch 'upstream/master' into forceclose
2 parents 646211c + 81afe2d commit b320bb1

33 files changed

+517
-72
lines changed

.travis.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ matrix:
1010
dist: trusty
1111
group: stable
1212
before_install:
13-
- sudo apt-get install libqt5x11extras5-dev
13+
- sudo apt-get -y install libqt5x11extras5-dev
1414
addons:
1515
apt:
1616
sources:
@@ -21,6 +21,7 @@ matrix:
2121
- qt55base
2222
- qt55tools
2323
- qt55x11extras
24+
- libqt5x11extras5-dev
2425
- gcc-9
2526
- g++-9
2627
script:
@@ -39,7 +40,7 @@ matrix:
3940
- xvfb
4041
compiler: gcc
4142
before_install:
42-
- sudo apt-get install libqt5x11extras5-dev
43+
- sudo apt-get -y install libqt5x11extras5-dev
4344
addons:
4445
apt:
4546
sources:
@@ -50,6 +51,7 @@ matrix:
5051
- qt514base
5152
- qt514tools
5253
- qt514x11extras
54+
- libqt5x11extras5-dev
5355
- gcc-9
5456
- g++-9
5557
- libc6-i386
@@ -71,9 +73,9 @@ matrix:
7173
services:
7274
- xvfb
7375
compiler: gcc
74-
addons:
7576
before_install:
76-
- sudo apt-get install libqt5x11extras5-dev
77+
- sudo apt-get -y install libqt5x11extras5-dev
78+
addons:
7779
apt:
7880
sources:
7981
- ubuntu-toolchain-r-test
@@ -83,6 +85,7 @@ matrix:
8385
- qt514base
8486
- qt514tools
8587
- qt514x11extras
88+
- libqt5x11extras5-dev
8689
- gcc-9
8790
- g++-9
8891
- libc6-i386
@@ -105,7 +108,7 @@ matrix:
105108
- xvfb
106109
compiler: gcc
107110
before_install:
108-
- sudo apt-get install libqt5x11extras5-dev
111+
- sudo apt-get -y install libqt5x11extras5-dev
109112
addons:
110113
apt:
111114
sources:
@@ -116,6 +119,7 @@ matrix:
116119
- qt514base
117120
- qt514tools
118121
- qt514x11extras
122+
- libqt5x11extras5-dev
119123
- gcc-9
120124
- g++-9
121125
- libc6-i386
@@ -144,7 +148,7 @@ matrix:
144148
- xvfb
145149
compiler: gcc
146150
before_install:
147-
- sudo apt-get install libqt5x11extras5-dev
151+
- sudo apt-get -y install libqt5x11extras5-dev
148152
addons:
149153
apt:
150154
sources:
@@ -155,6 +159,7 @@ matrix:
155159
- qt514base
156160
- qt514tools
157161
- qt514x11extras
162+
- libqt5x11extras5-dev
158163
- gcc-9
159164
- g++-9
160165
- libc6-i386

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ integrated development environments (IDEs) such as Visual Studio.
1515

1616
## New and Noteworthy
1717

18+
The [release 3.6.0](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/releases/tag/3.6.0)
19+
adds some nice new features:
20+
21+
- support for [central widget](doc/user-guide.md#central-widget) concept
22+
23+
![Central Widget](doc/central_widget.gif)
24+
25+
- support for [native floating widgets](doc/user-guide.md#floatingcontainerforcenativetitlebar-linux-only) on Linux
26+
27+
![FloatingContainerForceNativeTitleBar true](doc/cfg_flag_FloatingContainerForceNativeTitleBar_true.png)
28+
29+
Both features are contributions from ADS users. Read the [documentation](doc/user-guide.md)
30+
to learn more about both new features.
31+
1832
The [release 3.5.0](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/releases/tag/3.5.0)
1933
adds the new [focus highlighting](doc/user-guide.md#focushighlighting) feature.
2034
This optional feature enables highlighting of the focused dock widget like you

demo/MainWindow.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static void appendFeaturStringToWindowTitle(ads::CDockWidget* DockWidget)
109109
static QIcon svgIcon(const QString& File)
110110
{
111111
// This is a workaround, because in item views SVG icons are not
112-
// properly scaled an look blurry or pixelate
112+
// properly scaled and look blurry or pixelate
113113
QIcon SvgIcon(File);
114114
SvgIcon.addPixmap(SvgIcon.pixmap(92));
115115
return SvgIcon;
@@ -166,6 +166,7 @@ struct MainWindowPrivate
166166
QComboBox* PerspectiveComboBox = nullptr;
167167
ads::CDockManager* DockManager = nullptr;
168168
ads::CDockWidget* WindowTitleTestDockWidget = nullptr;
169+
ads::CDockWidget* LastDockedEditor = nullptr;
169170

170171
MainWindowPrivate(CMainWindow* _public) : _this(_public) {}
171172

@@ -720,7 +721,17 @@ void CMainWindow::createEditor()
720721
}
721722
else
722723
{
723-
d->DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
724+
ads::CDockAreaWidget* EditorArea = d->LastDockedEditor ? d->LastDockedEditor->dockAreaWidget() : nullptr;
725+
if (EditorArea)
726+
{
727+
d->DockManager->setConfigFlag(ads::CDockManager::EqualSplitOnInsertion, true);
728+
d->DockManager->addDockWidget(ads::RightDockWidgetArea, DockWidget, EditorArea);
729+
}
730+
else
731+
{
732+
d->DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
733+
}
734+
d->LastDockedEditor = DockWidget;
724735
}
725736
}
726737

demo/demo.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def append_feature_string_to_window_title(dock_widget: QtAds.CDockWidget):
6565
def svg_icon(filename: str):
6666
'''Helper function to create an SVG icon'''
6767
# This is a workaround, because because in item views SVG icons are not
68-
# properly scaled an look blurry or pixelate
68+
# properly scaled and look blurry or pixelate
6969
icon = QIcon(filename)
7070
icon.addPixmap(icon.pixmap(92))
7171
return icon
@@ -104,6 +104,8 @@ def __init__(self, parent=None):
104104
self.perspective_list_action = None
105105
self.perspective_combo_box = None
106106
self.dock_manager = None
107+
self.window_title_test_dock_widget = None
108+
self.last_docked_editor = None
107109

108110
self.setupUi(self)
109111
self.create_actions()
@@ -184,6 +186,7 @@ def create_content(self):
184186
# special_dock_area.setAllowedAreas(QtAds.LeftDockWidgetArea | QtAds.RightDockWidgetArea) # just for testing
185187

186188
dock_widget = self.create_long_text_label_dock_widget()
189+
self.window_title_test_dock_widget = dock_widget
187190
dock_widget.setFeature(QtAds.CDockWidget.DockWidgetFocusable, False)
188191
self.dock_manager.addDockWidget(QtAds.LeftDockWidgetArea, dock_widget)
189192
file_system_widget = self.create_file_system_tree_dock_widget()
@@ -203,8 +206,8 @@ def create_content(self):
203206
QtAds.CDockComponentsFactory.setFactory(CCustomComponentsFactory())
204207
top_dock_area = self.dock_manager.addDockWidget(QtAds.TopDockWidgetArea, file_system_widget)
205208
# Uncomment the next line if you would like to test the
206-
# setHideSingleWidgetTitleBar() functionality
207-
# top_dock_area.setHideSingleWidgetTitleBar(True)
209+
# HideSingleWidgetTitleBar functionality
210+
# top_dock_area.setDockAreaFlag(QtAds.CDockAreaWidget.HideSingleWidgetTitleBar, True)
208211
QtAds.CDockComponentsFactory.resetDefaultFactory()
209212

210213
# We create a calendar widget and clear all flags to prevent the dock area
@@ -354,7 +357,6 @@ def on_view_visibility_changed(self, visible: bool):
354357
def create_editor(self):
355358
sender = self.sender()
356359
floating = sender.property("Floating")
357-
print("Floating:", floating)
358360
dock_widget = self.create_editor_widget()
359361
dock_widget.setFeature(QtAds.CDockWidget.DockWidgetDeleteOnClose, True)
360362
dock_widget.closeRequested.connect(self.on_editor_close_requested)
@@ -363,7 +365,13 @@ def create_editor(self):
363365
floating_widget = self.dock_manager.addDockWidgetFloating(dock_widget)
364366
floating_widget.move(QPoint(20, 20))
365367
else:
366-
self.dock_manager.addDockWidget(QtAds.TopDockWidgetArea, dock_widget)
368+
editor_area = self.last_docked_editor.dockAreaWidget() if self.last_docked_editor is not None else None
369+
if editor_area is not None:
370+
self.dock_manager.setConfigFlag(QtAds.CDockManager.EqualSplitOnInsertion, True)
371+
self.dock_manager.addDockWidget(QtAds.RightDockWidgetArea, dock_widget, editor_area)
372+
else:
373+
self.dock_manager.addDockWidget(QtAds.TopDockWidgetArea, dock_widget)
374+
self.last_docked_editor = dock_widget
367375

368376
def on_editor_close_requested(self):
369377
dock_widget = self.sender()
@@ -382,6 +390,16 @@ def show_status_dialog(self):
382390
dialog = CStatusDialog(self.dock_manager)
383391
dialog.exec_()
384392

393+
394+
def toggle_dock_widget_window_title(self):
395+
title = self.window_title_test_dock_widget.windowTitle()
396+
i = title.find(" (Test) ")
397+
if i == -1:
398+
title += " (Test) "
399+
else:
400+
title = title[i]
401+
self.window_title_test_dock_widget.setWindowTitle(title)
402+
385403
def save_state(self):
386404
'''
387405
Saves the dock manager state and the main window geometry

doc/central_widget.gif

572 KB
Loading
5.17 KB
Loading
5.06 KB
Loading
Loading
Loading

doc/user-guide.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
- [`FloatingContainerHasWidgetIcon`](#floatingcontainerhaswidgeticon)
2525
- [`HideSingleCentralWidgetTitleBar`](#hidesinglecentralwidgettitlebar)
2626
- [`FocusHighlighting`](#focushighlighting)
27+
- [`EqualSplitOnInsertion`](#equalsplitoninsertion)
28+
- [`FloatingContainerForceNativeTitleBar` (Linux only)](#floatingcontainerforcenativetitlebar-linux-only)
29+
- [`FloatingContainerForceQWidgetTitleBar` (Linux only)](#floatingcontainerforceqwidgettitlebar-linux-only)
30+
- [Central Widget](#central-widget)
2731
- [Styling](#styling)
2832
- [Disabling the Internal Style Sheet](#disabling-the-internal-style-sheet)
2933

@@ -409,6 +413,93 @@ bool CMainWindow::eventFilter(QObject *watched, QEvent *event)
409413
}
410414
```
411415

416+
### `EqualSplitOnInsertion`
417+
418+
This flag configures how the space is distributed if a new dock widget is
419+
inserted into an existing dock area. The flag is disabled by default. If 3
420+
dock widgets are inserted with the following code
421+
422+
```c++
423+
d->DockManager->addDockWidget(ads::RightDockWidgetArea, DockWidget, EditorArea);
424+
```
425+
426+
then this is the result, if the flag is disabled:
427+
428+
![EqualSplitOnInsertion false](cfg_flag_EqualSplitOnInsertion_false.png)
429+
430+
If the flag is enabled, then the space is equally distributed to all widgets
431+
in a splitter:
432+
433+
![EqualSplitOnInsertion true](cfg_flag_EqualSplitOnInsertion_true.png)
434+
435+
436+
### `FloatingContainerForceNativeTitleBar` (Linux only)
437+
438+
Since release 3.6 the library supports native title bars and window decorations
439+
for floating widgets on Linux (thanks to a user contribution).
440+
Native title bars and window decorations are supported by most Linux window
441+
managers, such as Compiz or Xfwm. Some window managers like KWin do not properly
442+
support this feature. Native floating widgets look better because of the native
443+
styling and the support all window manager features like snapping to window
444+
borders or maximizing. The library tries to detect the window manager during
445+
runtime and activates native window decorations if possible:
446+
447+
![FloatingContainerForceNativeTitleBar true](cfg_flag_FloatingContainerForceNativeTitleBar_true.png)
448+
449+
If you would like to overwrite this autodetection, then you can activate this
450+
flag to force native window titlebars. You can overwrite autodetection and this
451+
flag, if you set the environment variable `ADS_UseNativeTitle` to 0 or 1.
452+
453+
### `FloatingContainerForceQWidgetTitleBar` (Linux only)
454+
455+
If your window manager (i.e. KWin) does not properly support native floating
456+
windows, the docking library falls back to QWidget based floating widget
457+
title bars.
458+
459+
![FloatingContainerForceNativeTitleBar false](cfg_flag_FloatingContainerForceNativeTitleBar_false.png)
460+
461+
If you would like to overwrite autodetection, then you can activate this flag
462+
to force QWidget based title bars. You can overwrite autodetection and this
463+
flag, if you set the environment variable `ADS_UseNativeTitle` to 0 or 1.
464+
465+
## Central Widget
466+
467+
The Advanced Docking System has been developed to overcome the limitations of
468+
the native Qt docking system with its central widget concept. This was the
469+
reason that until version 3.6 of the library, there was no support for such
470+
thing like a central widget. Thanks to the contribution of a user the library
471+
now supports a central widget.
472+
473+
In the Advanced Docking System a central widget is a docking widget that is
474+
neither closable nor movable or floatable. A central widget has no title bar
475+
and so it is not possible for the user to hide, close or drag the central
476+
widget. If there is a central widget, then also the distribution of the sizes
477+
for the dock widgets around the central widget is different:
478+
479+
- **no central widget (default)** - on resizing the available space is
480+
distributed to all dock widgets - the size of all dock widgets
481+
shrinks or grows
482+
- **with central widget** - on resizing only the central widget is resized - the
483+
dock widgets around the central widget keep their size (see the animation below)
484+
485+
![Central Widget](central_widget.gif)
486+
487+
To set a central widget, you just need to pass your central dock widget
488+
to the dock manager `setCentralWidget` function:
489+
490+
```c++
491+
auto* CentralDockArea = DockManager->setCentralWidget(CentralDockWidget);
492+
```
493+
494+
See the `centralwidget` example to learn how it works.
495+
496+
> ##### Note
497+
> The central widget needs to be the first dock widget that is added to the
498+
> dock manager. The function does not work and returns a `nullptr` if there
499+
> are already other dock widgets registered. So `setCentralWidget` should be
500+
> the first function that you call when adding dock widgets.
501+
502+
412503
## Styling
413504

414505
The Advanced Docking System supports styling via [Qt Style Sheets](https://doc.qt.io/qt-5/stylesheet.html). All components like splitters, tabs, buttons, titlebar and

0 commit comments

Comments
 (0)