Compare commits

...

147 Commits
2.5.2 ... 3.1.0

Author SHA1 Message Date
Rodrigo Oliva
a4ef161f4f Fix using escape button when dragging non-opaque preview to cancel drag operation (#114)
* Added missing overrides.

* Escape button to cancel dragging was not working in Windows either. Using the event filter added for Linux works.
2020-02-07 23:07:07 +01:00
Uwe Kindler
8a16230213 Merge branch 'master' of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System 2020-02-07 22:54:02 +01:00
Uwe Kindler
8113bf63ba Added spacer widget to handle mouse events properly in CDockAreaTitleBar, added missing updateGeometry calls to CDockAreaTabBar 2020-02-07 22:49:10 +01:00
Rodrigo Oliva
2770837adc Added missing overrides. (#113) 2020-02-07 14:41:35 +01:00
Uwe Kindler
c4872c6b10 Added showcase for custom title bar widget to demo application 2020-02-07 14:29:02 +01:00
Uwe Kindler
efb9b879dd Added functions to insert custom dock area title bar widgets 2020-02-07 13:42:11 +01:00
Uwe Kindler
d10d59a8e2 Porperly moved title bar context menu code from DockAreaTabBar into DockAreaTitleBar 2020-02-07 12:23:26 +01:00
Uwe Kindler
b61f50982a Moved title bar dragging code from DockAreaTabBar into DockAreaTitleBar 2020-02-07 12:16:26 +01:00
Uwe Kindler
ae72f5e47d Changed sizeHints(), sizePolicy() and used updateGeometry() to properly size the tabBar 2020-02-07 11:49:45 +01:00
Uwe Kindler
9d7c692398 Fixed stylesheet typo 2020-02-06 15:37:50 +01:00
mvidelgauz
474dd13855 Disable tabs menu button when only single tab exists in a Dock area (#111) 2020-02-06 15:21:19 +01:00
Uwe Kindler
72496ebd48 Comitted missing app.css file 2020-02-06 12:55:26 +01:00
Uwe Kindler
b727274cd9 Implemented support for custom DockWidget actions for display in DockArea title bar 2020-02-06 09:15:13 +01:00
Uwe Kindler
094fa37135 Implemented supprt for customdock area title bar buttons 2020-02-06 00:31:57 +01:00
Uwe Kindler
6a8b26f415 Added function internal::setButtonIcon to unify code for setting DockAreaTitleBar and DockWidgetTab icons 2020-02-05 08:57:57 +01:00
Uwe Kindler
acb423872a Helper function internal::setToolTip() to remove as many #ifndef QT_NO_TOOLTIP tests as possible to cleanup the code 2020-02-05 08:33:40 +01:00
Uwe Kindler
505f14a601 Improved code for generation of default configuration flags 2020-02-05 08:16:07 +01:00
Uwe Kindler
05c58a4ca9 Merge branch 'master' of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System 2020-02-05 08:05:10 +01:00
mvidelgauz
b8ed70fa33 Added DockAreaHideDisabledButtons configuration flag (#110)
* CInvisibleButton generalized to CTitleBarButton to serve more purposes
* Disabled buttons are hidden if CDockManager::DockAreaHideDisabledButtons set to true
2020-02-05 08:04:27 +01:00
Uwe Kindler
b510686fe2 Added icon to ads_qt_marketplace_manifest.json 2020-02-04 11:29:18 +01:00
Uwe Kindler
50652b05b0 Fixed svg icon 2020-02-04 10:07:20 +01:00
Uwe Kindler
66795f2b12 Changes in donate section 2020-02-04 09:36:41 +01:00
Uwe Kindler
bc5e0ba7d8 Fixed some README.md markdown issues and added donate button 2020-02-04 09:32:15 +01:00
Uwe Kindler
d722482913 Added library icon 2020-02-04 08:49:34 +01:00
mvidelgauz
1d68e27558 Added DockAreaHasTabsMenuButton and DockAreaHasUndockButton to CDockManager config (#108)
* Added DockAreaHasUndockButton and DockAreaHasTabsMenuButton configuration flag
2020-02-02 16:22:05 +01:00
Uwe Kindler
1dbd3f3f06 Blocked tabyfing via moving over DockArea titlebar if the CenterDockWidgetArea is not in the allowed areas for DockAreaWidget 2020-02-02 16:03:58 +01:00
Uwe Kindler
68b0958119 Removed unused code 2020-02-02 16:02:12 +01:00
mvidelgauz
6c3f82547d setAllowedAreas for individual DockAreaWidget (#107)
* setAllowedAreas for individual DockAreaWidget

* alligning tab policy with master
2020-02-02 15:56:31 +01:00
Uwe Kindler
9fe8f291fb Fixed CDockManager::DockAreaHasCloseButton == false issue 2020-02-02 11:16:38 +01:00
githubuser0xFFFF
102e65a548 Update CMakeLists.txt 2020-01-31 21:39:10 +01:00
Uwe Kindler
4f62794946 Added documentation for new AlwaysShowTabs flag 2020-01-31 14:36:05 +01:00
Rodrigo Oliva
dd06d84206 Add option to always show all tabs (#102)
* Add option to always show tabs.

* Disable "Detach" context menu option in tab if there is only one tab in the floating container.
2020-01-31 14:27:01 +01:00
Krzysztof Machura
d4c179c48e Fix tabs not being active when restoring state (#101)
Regression introduced by 29ebc83b35
2020-01-31 14:26:02 +01:00
Uwe Kindler
ff68ad95a6 Updated LICENSE file for better GitHub integration 2020-01-31 13:40:39 +01:00
Uwe Kindler
8f696ea36a Fixed a regression in DockWidgetTab that caused wron positioning of FloatingDockContainer when moving the mouse 2020-01-16 15:24:01 +01:00
Uwe Kindler
ce1e8c8beb Fixed position calculation for tab dragging 2020-01-15 21:15:29 +01:00
Uwe Kindler
98ebdbea50 Added new DockWidget signals to DockWidget.sip 2020-01-15 10:08:13 +01:00
Uwe Kindler
418d0740d2 Switched from local event pos to global event pos in DockWidgetTab to fix jumping tabs when hiding / showing tabs close button 2020-01-15 10:03:50 +01:00
Uwe Kindler
50c3066eaa Removed std::cout debug output 2020-01-15 08:34:49 +01:00
Uwe Kindler
29ebc83b35 Some changes for debugging visibility changed stuff 2020-01-15 07:49:22 +01:00
Uwe Kindler
03bd4a4505 Added visibilityChanged code 2020-01-14 15:58:45 +01:00
Uwe Kindler
407af06a4a Fixed some issues with custom close handling 2020-01-14 12:43:42 +01:00
Uwe Kindler
9af9e43a5d Fixed MSVC build warning 2020-01-12 15:12:47 +01:00
Uwe Kindler
4c928071af Merge branch 'master' into closerequest
# Conflicts:
#	demo/MainWindow.cpp
2020-01-12 15:07:51 +01:00
Uwe Kindler
ea03b988e0 Fixed CMake Windows build 2020-01-11 23:44:46 +01:00
Uwe Kindler
e1044c3e91 Fixed compiler warning for MSVC 2020-01-11 15:21:10 +01:00
Uwe Kindler
8057d25f35 Fixed broken cmake build for Windows because of missing Qt5AxContainer library 2020-01-11 15:16:33 +01:00
Uwe Kindler
592193fc91 Updated MainWindwow to center it properly on start 2020-01-11 13:53:58 +01:00
Uwe Kindler
5cf4aa77d8 Build QAxWidget specific stuff only on Windows 2020-01-11 12:05:44 +01:00
Uwe Kindler
616e50c3f5 Fixed FloatingDockContainer closeEvent to properly support QAxWidgets 2020-01-10 08:54:44 +01:00
Uwe Kindler
1de42a9766 Updated doc images 2020-01-06 15:08:38 +01:00
Uwe Kindler
f07fcddd78 Added animated gif for grouped dragging 2020-01-06 13:06:17 +01:00
Uwe Kindler
225ab943bb Merge branch 'master' of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System 2020-01-06 12:00:30 +01:00
Uwe Kindler
3fe31ca62d Updated perspectives.gif 2020-01-06 11:59:53 +01:00
githubuser0xFFFF
d1f17e60f7 Update README.md
Added animated perspectives image
2020-01-06 11:52:24 +01:00
Uwe Kindler
8f78e608d1 Added perspectives gif for animated perspectives image 2020-01-06 11:50:59 +01:00
Uwe Kindler
a5e8011222 Implemented custom close handling 2020-01-06 11:42:36 +01:00
Uwe Kindler
0305d8a221 Experimental implementation of close request 2020-01-03 18:13:34 +01:00
Uwe Kindler
25e8d8691f Merge branch 'master' of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System 2019-12-22 13:17:54 +01:00
Hugo Slepicka
084c5c5995 ENH: Version info using Versioneer (#97)
* ENH: Use versioneer for version information.

* FIX: rc.py is a build artifact and should not be version controlled.

* FIX: Move processResourceFile to its own command.
2019-12-20 00:08:49 +01:00
githubuser0xFFFF
65c080ae8e Merge pull request #92 from hhslepicka/fix_sip_bindings
FIX: Update SIP Bindings
2019-12-19 06:16:11 +01:00
Hugo Slepicka
f9927cef29 FIX: SIP Binding changes to reflect changes from 2.7.0 to master. 2019-12-18 15:17:28 -08:00
Hugo Slepicka
5778dfe929 WIP: Changes between 2.5.2 and 2.7.0. 2019-12-18 14:21:34 -08:00
Uwe Kindler
c33c09eab1 Fixed some typos in MainWindow.cpp 2019-12-17 14:52:17 +01:00
githubuser0xFFFF
2150ebf45e Update README.md
Added animations for opaque and non opaque resizing
2019-12-17 14:44:57 +01:00
Uwe Kindler
6021ee8094 Added GIF animations for opaque and non opaque resizing 2019-12-17 14:41:58 +01:00
Uwe Kindler
eebb2a6297 Merge branch 'master' of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System 2019-12-17 14:11:28 +01:00
Uwe Kindler
0fb1363b1a Moved tab_menu.gif to the right location 2019-12-17 14:11:21 +01:00
githubuser0xFFFF
2ca03cc56d Update README.md 2019-12-17 14:10:55 +01:00
Uwe Kindler
4a2768015c Added tab_menu animated gif 2019-12-17 14:08:03 +01:00
Uwe Kindler
861ce67725 Fixed bug in DockContainerWidgetPrivate::moveIntoCenterOfSection
If a dock widget has been dropped into the center of a dock area via non-opaque docking the dropped widget did not become the active tab - this has been fixed
2019-12-17 13:45:33 +01:00
githubuser0xFFFF
c530a4a4ec Added documentation for dynamic creation of dock widgets 2019-12-16 15:05:44 +01:00
githubuser0xFFFF
2378f46067 Added documentation for tab menu 2019-12-16 14:54:29 +01:00
githubuser0xFFFF
ea707369a0 Added documentation for non-opaque undocking 2019-12-16 14:47:01 +01:00
githubuser0xFFFF
7640e9bdcf Documented opaque resizing 2019-12-16 14:31:02 +01:00
githubuser0xFFFF
4a0266bc76 Update README.md 2019-12-16 14:14:49 +01:00
githubuser0xFFFF
6d1f97649e Update README.md 2019-12-16 14:12:08 +01:00
Uwe Kindler
2af4b1f75c Blocked display of context menu when dragging floating widget 2019-12-16 13:56:20 +01:00
githubuser0xFFFF
c0cde1e31e Update README.md 2019-12-16 12:25:37 +01:00
githubuser0xFFFF
ee809da7a7 Added images for Ubuntu 19.10 and macOS 2019-12-16 12:08:57 +01:00
Uwe Kindler
a253e4a0b5 Added ned screenshots from ubuntu 1910 and macos 2019-12-16 12:05:06 +01:00
Uwe Kindler
779c4b928c Fixed build warning for FloatingDragPreview.cpp 2019-12-16 11:47:55 +01:00
Uwe Kindler
056f04d408 Properly implemented support for canceling non-opaque undocking on Linux 2019-12-16 11:45:18 +01:00
Uwe Kindler
e085a29484 Renamed FloatingOverlay into FloatingDragPreview to match naming of global DockManager flags (like DragPreviewHasWindowFrame..) 2019-12-16 11:18:22 +01:00
Uwe Kindler
ffd35cbce3 Added support for canceling non opaque docking with escape key, fixed state of non opaque docking when switching applications (if application becomes inactive) 2019-12-16 11:10:59 +01:00
Uwe Kindler
8c1f065f3f CHanged DockAreaTabBar to handle the dragging state via DragState member variable instead of testing for FloatingWidget nullptr 2019-12-16 08:41:15 +01:00
Uwe Kindler
5af6b4e324 Improved source documentation and images 2019-12-16 08:06:38 +01:00
Uwe Kindler
b47a777f5c Fixed issue #88 - floating widgets going to the background on OSX when moving them 2019-12-13 20:56:50 +01:00
Uwe Kindler
5b3a0a28df Fixed vertical alignment of label in FloatingWidgetTitleBar
Added call to FloatingWidget->finishDragging()
2019-12-13 13:19:24 +01:00
Uwe Kindler
02143eac71 Added finishDragging() function to IFloatingWidget to prevent installing event filters 2019-12-13 11:52:50 +01:00
Uwe Kindler
5e230d8874 Closing a dock area with only one single dock widget that has the DockWidgetDeleteOnCloseFeature will delete the dock widget and the area now 2019-12-11 16:06:07 +01:00
Uwe Kindler
a45a035bb3 Fixed problem with CDockAreaTabBar::onCloseOtherTabsRequested() if DockWidgets support the DockwidgetDeleteOnClose flag, enhanced demo to enabled creation of dynamic tables 2019-12-11 15:50:13 +01:00
Uwe Kindler
05f8ce15a2 Added support for dock widget feature DockWidgetDeleteOnClose, added toolbar action for creation of dynamic editors to demo appication, added new material design icons to improve demo gui 2019-12-10 14:44:44 +01:00
Uwe Kindler
45af8867b2 Fixed debug output, moved all calls to FloatingWidget->deleteLater() to a centra place in CDockContainerWidget::dropFloatingWidget 2019-12-10 12:47:55 +01:00
githubuser0xFFFF
8e522ce311 Update README.md 2019-12-02 12:07:43 +01:00
githubuser0xFFFF
178603e3ba Update linux-builds.yml 2019-12-02 08:19:11 +01:00
githubuser0xFFFF
552cee514d Update README.md 2019-12-02 08:14:32 +01:00
githubuser0xFFFF
4105f70089 Update linux-builds.yml 2019-12-02 08:11:49 +01:00
githubuser0xFFFF
0bd34a5a6e Update linux-builds.yml 2019-12-02 08:10:58 +01:00
githubuser0xFFFF
a5dd566b37 Update linux-builds.yml 2019-12-02 08:10:42 +01:00
githubuser0xFFFF
1724f7f5ec Update linux-builds.yml 2019-12-02 08:10:23 +01:00
Uwe Kindler
6cd09addae Fixed linux build workflow 2019-12-02 08:04:25 +01:00
Uwe Kindler
93382350db Updated acitons file for linux builds 2019-12-02 07:45:03 +01:00
githubuser0xFFFF
db90e5415f Update README.md 2019-11-29 23:39:04 +01:00
githubuser0xFFFF
9679fd67cc Update actions_test.yml 2019-11-29 23:34:11 +01:00
githubuser0xFFFF
c84c98f49a Update README.md 2019-11-29 23:24:45 +01:00
githubuser0xFFFF
716acd5f68 Update README.md 2019-11-29 23:17:17 +01:00
githubuser0xFFFF
e782b4813b Update actions_test.yml 2019-11-29 23:12:12 +01:00
githubuser0xFFFF
b27a24b3c4 Update actions_test.yml 2019-11-29 23:10:39 +01:00
githubuser0xFFFF
18c65cdf34 Update actions_test.yml 2019-11-29 23:04:35 +01:00
githubuser0xFFFF
e049cb0353 Update actions_test.yml 2019-11-29 23:02:02 +01:00
githubuser0xFFFF
8d42e7777d Update actions_test.yml 2019-11-29 22:59:24 +01:00
githubuser0xFFFF
e682ab8ea5 Update actions_test.yml 2019-11-29 22:52:47 +01:00
githubuser0xFFFF
c6ff7f5230 Update actions_test.yml 2019-11-29 22:44:07 +01:00
githubuser0xFFFF
309fe1a14a Update actions_test.yml 2019-11-29 22:39:07 +01:00
githubuser0xFFFF
6b45274686 Create actions_test.yml 2019-11-29 22:29:49 +01:00
Uwe Kindler
0f72fabe67 Merge branch 'master' of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System 2019-11-29 15:57:39 +01:00
Uwe Kindler
d3ad17d2c6 Added support for file version handling for dock state files, added support for reading version 0 state file with wrong orientation character 2019-11-29 15:56:57 +01:00
githubuser0xFFFF
a8e0f1904f Update README.md 2019-11-28 16:11:21 +01:00
Uwe Kindler
2ee7deb6d5 Fixed handling on spontaneous hide events in CFloatingDockContainer for Linux 2019-11-28 14:28:34 +01:00
Uwe Kindler
2e88d8651e Added missing source files to CMakeLists.txt 2019-11-28 14:12:50 +01:00
Uwe Kindler
232b6b9a61 Fixed demo configuration 2019-11-28 13:49:58 +01:00
Uwe Kindler
5978aaaedc Set attribute Qt::WA_X11NetWmWindowTypeDock permanently for floating widgets 2019-11-28 13:45:15 +01:00
Uwe Kindler
3332f6050e Changed initial position of floating widgets 2019-11-28 13:35:58 +01:00
Uwe Kindler
a1de28c969 Fixed demo application to properly use default settings 2019-11-28 13:22:59 +01:00
Uwe Kindler
8af53b4199 Merge branch 'master' of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System 2019-11-28 13:05:42 +01:00
Uwe Kindler
bddf4c417d Added Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint for dock overlay for linux 2019-11-28 13:05:09 +01:00
githubuser0xFFFF
e345773cfc Update README.md 2019-11-28 10:57:25 +01:00
githubuser0xFFFF
c1816bf507 Update README.md 2019-11-28 10:51:07 +01:00
Uwe Kindler
4f97e07eb6 Removed debug output, properly restored dragged tab position when floating starts 2019-11-28 10:32:39 +01:00
Uwe Kindler
2fe542c3ef Improved transparent docking 2019-11-28 09:09:36 +01:00
Uwe Kindler
07f9c6d016 Fixed setting of splitter sizes for transparent docking 2019-11-27 21:43:36 +01:00
Uwe Kindler
8ea7c265a7 Fixed emission of top level changed signal to properly support transparent docking 2019-11-27 15:50:18 +01:00
Uwe Kindler
3cd12ce1d3 Fixed creation a FloatingDockContainer 2019-11-27 14:44:17 +01:00
Uwe Kindler
1be8f2861d Continued implementation of transparent docking 2019-11-27 12:00:04 +01:00
Uwe Kindler
e15af4101a Added initial support for transparent undocking 2019-11-26 14:40:56 +01:00
Uwe Kindler
4504457da2 Removed debug code 2019-11-25 16:06:44 +01:00
Uwe Kindler
f497944d2c Added setFloating function to CDockWidget to support making a dock widget floating with from code 2019-11-25 15:59:08 +01:00
Uwe Kindler
aee9fb1c95 Added dock manager function addDockWidgetFloating to add initial floating dock widgets 2019-11-25 15:28:15 +01:00
Uwe Kindler
316d9a00b5 Fixed serialization and deserialization of splitter orientation: | means Horizontal and - means vertical - ATTENTION: this breaks backward compatibility with old saved states 2019-11-25 15:24:44 +01:00
Uwe Kindler
b353c210ee Added dockAreaCreated signal that is emitted whenever a new dock area is created - this allows an application to set custom icons and tooltips for the title bar buttons 2019-11-22 21:53:17 +01:00
Uwe Kindler
490e853435 Merge branch 'master' of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System 2019-11-22 21:42:05 +01:00
Uwe Kindler
7393addf64 Fixed setting of CloseButton icon in DockWidgetTab.cpp 2019-11-22 21:38:47 +01:00
Uwe Kindler
a2b9650469 Merge branch 'master' into IconProvider 2019-11-22 21:36:15 +01:00
Uwe Kindler
ca39ab0b44 Fixed comment in DockWidget.h 2019-11-22 21:35:49 +01:00
Uwe Kindler
05ff005613 Added new IconProvider source files to CMakeLists.txt 2019-10-18 14:22:06 +02:00
Uwe Kindler
3ff154aff1 Added global static icon provider to enable registration of custom icons 2019-10-18 08:31:26 +02:00
92 changed files with 6777 additions and 1592 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
PyQtAds/_version.py export-subst

22
.github/workflows/linux-builds.yml vendored Normal file
View File

@@ -0,0 +1,22 @@
name: linux-builds
on: [push]
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, ubuntu-18.04, ubuntu-16.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- name: install qt
run: |
sudo apt-get update --fix-missing
sudo apt-get install qt5-default
- name: qmake
run: qmake
- name: make
run: make -j4

3
.gitignore vendored
View File

@@ -15,4 +15,5 @@ Makefile
.eggs .eggs
*.pyc *.pyc
*.pyd *.pyd
__pycache__ __pycache__
PyQtAds/rc.py

View File

@@ -37,8 +37,11 @@ set(ads_SRCS
src/DockSplitter.cpp src/DockSplitter.cpp
src/DockWidget.cpp src/DockWidget.cpp
src/DockWidgetTab.cpp src/DockWidgetTab.cpp
src/DockingStateReader.cpp
src/ElidingLabel.cpp src/ElidingLabel.cpp
src/FloatingDockContainer.cpp src/FloatingDockContainer.cpp
src/FloatingDragPreview.cpp
src/IconProvider.cpp
src/ads.qrc src/ads.qrc
src/linux/FloatingWidgetTitleBar.cpp src/linux/FloatingWidgetTitleBar.cpp
) )
@@ -53,8 +56,11 @@ set(ads_INSTALL_INCLUDE
src/DockSplitter.h src/DockSplitter.h
src/DockWidget.h src/DockWidget.h
src/DockWidgetTab.h src/DockWidgetTab.h
src/DockingStateReader.h
src/ElidingLabel.h src/ElidingLabel.h
src/FloatingDockContainer.h src/FloatingDockContainer.h
src/FloatingDragPreview.h
src/IconProvider.h
src/linux/FloatingWidgetTitleBar.h src/linux/FloatingWidgetTitleBar.h
) )
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
@@ -74,7 +80,7 @@ install(FILES ${ads_INSTALL_INCLUDE}
COMPONENT headers COMPONENT headers
) )
install(FILES install(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md" "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
"${CMAKE_CURRENT_SOURCE_DIR}/gnu-lgpl-v2.1.md" "${CMAKE_CURRENT_SOURCE_DIR}/gnu-lgpl-v2.1.md"
DESTINATION license DESTINATION license
COMPONENT license COMPONENT license

504
LICENSE Normal file
View File

@@ -0,0 +1,504 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random
Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@@ -1,15 +0,0 @@
Qt Advanced Docking System
Copyright (C) 2017 Uwe Kindler
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; If not, see <http://www.gnu.org/licenses/>.

2
MANIFEST.in Normal file
View File

@@ -0,0 +1,2 @@
include versioneer.py
include PyQtAds/_version.py

View File

@@ -1 +1,9 @@
from .rc import * from .rc import *
from ._version import get_versions
__version__ = get_versions()['version']
short_version = __version__
version = __version__
full_version = __version__
git_revision = get_versions()['full-revisionid']
release = not get_versions()['dirty']
del get_versions

View File

@@ -1,9 +1,520 @@
# THIS FILE IS GENERATED FROM PyQtAds SETUP.PY
short_version = '2.5.1' # This file helps to compute a version number in source trees obtained from
version = '2.5.1' # git-archive tarball (such as those provided by githubs download-from-tag
full_version = '2.5.1' # feature). Distribution tarballs (built by setup.py sdist) and build
git_revision = 'c10ff7c688fb50fe9157bad3982164e0f955f9e4' # directories (produced by setup.py build) will contain a much shorter file
release = True # that just contains the computed version number.
if not release:
version = full_version # This file is released into the public domain. Generated by
# versioneer-0.18 (https://github.com/warner/python-versioneer)
"""Git implementation of _version.py."""
import errno
import os
import re
import subprocess
import sys
def get_keywords():
"""Get the keywords needed to look up the version information."""
# these strings will be replaced by git during git-archive.
# setup.py/versioneer.py will grep for the variable names, so they must
# each be defined on a line of their own. _version.py will just call
# get_keywords().
git_refnames = "$Format:%d$"
git_full = "$Format:%H$"
git_date = "$Format:%ci$"
keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
return keywords
class VersioneerConfig:
"""Container for Versioneer configuration parameters."""
def get_config():
"""Create, populate and return the VersioneerConfig() object."""
# these strings are filled in when 'setup.py versioneer' creates
# _version.py
cfg = VersioneerConfig()
cfg.VCS = "git"
cfg.style = "pep440"
cfg.tag_prefix = ""
cfg.parentdir_prefix = "None"
cfg.versionfile_source = "PyQtAds/_version.py"
cfg.verbose = False
return cfg
class NotThisMethod(Exception):
"""Exception raised if a method is not valid for the current scenario."""
LONG_VERSION_PY = {}
HANDLERS = {}
def register_vcs_handler(vcs, method): # decorator
"""Create decorator to mark a method as the handler of a VCS."""
def decorate(f):
"""Store f in HANDLERS[vcs][method]."""
if vcs not in HANDLERS:
HANDLERS[vcs] = {}
HANDLERS[vcs][method] = f
return f
return decorate
def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
env=None):
"""Call the given command(s)."""
assert isinstance(commands, list)
p = None
for c in commands:
try:
dispcmd = str([c] + args)
# remember shell=False, so use git.cmd on windows, not just git
p = subprocess.Popen([c] + args, cwd=cwd, env=env,
stdout=subprocess.PIPE,
stderr=(subprocess.PIPE if hide_stderr
else None))
break
except EnvironmentError:
e = sys.exc_info()[1]
if e.errno == errno.ENOENT:
continue
if verbose:
print("unable to run %s" % dispcmd)
print(e)
return None, None
else:
if verbose:
print("unable to find command, tried %s" % (commands,))
return None, None
stdout = p.communicate()[0].strip()
if sys.version_info[0] >= 3:
stdout = stdout.decode()
if p.returncode != 0:
if verbose:
print("unable to run %s (error)" % dispcmd)
print("stdout was %s" % stdout)
return None, p.returncode
return stdout, p.returncode
def versions_from_parentdir(parentdir_prefix, root, verbose):
"""Try to determine the version from the parent directory name.
Source tarballs conventionally unpack into a directory that includes both
the project name and a version string. We will also support searching up
two directory levels for an appropriately named parent directory
"""
rootdirs = []
for i in range(3):
dirname = os.path.basename(root)
if dirname.startswith(parentdir_prefix):
return {"version": dirname[len(parentdir_prefix):],
"full-revisionid": None,
"dirty": False, "error": None, "date": None}
else:
rootdirs.append(root)
root = os.path.dirname(root) # up a level
if verbose:
print("Tried directories %s but none started with prefix %s" %
(str(rootdirs), parentdir_prefix))
raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
@register_vcs_handler("git", "get_keywords")
def git_get_keywords(versionfile_abs):
"""Extract version information from the given file."""
# the code embedded in _version.py can just fetch the value of these
# keywords. When used from setup.py, we don't want to import _version.py,
# so we do it with a regexp instead. This function is not used from
# _version.py.
keywords = {}
try:
f = open(versionfile_abs, "r")
for line in f.readlines():
if line.strip().startswith("git_refnames ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["refnames"] = mo.group(1)
if line.strip().startswith("git_full ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["full"] = mo.group(1)
if line.strip().startswith("git_date ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["date"] = mo.group(1)
f.close()
except EnvironmentError:
pass
return keywords
@register_vcs_handler("git", "keywords")
def git_versions_from_keywords(keywords, tag_prefix, verbose):
"""Get version information from git keywords."""
if not keywords:
raise NotThisMethod("no keywords at all, weird")
date = keywords.get("date")
if date is not None:
# git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant
# datestamp. However we prefer "%ci" (which expands to an "ISO-8601
# -like" string, which we must then edit to make compliant), because
# it's been around since git-1.5.3, and it's too difficult to
# discover which version we're using, or to work around using an
# older one.
date = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
refnames = keywords["refnames"].strip()
if refnames.startswith("$Format"):
if verbose:
print("keywords are unexpanded, not using")
raise NotThisMethod("unexpanded keywords, not a git-archive tarball")
refs = set([r.strip() for r in refnames.strip("()").split(",")])
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
TAG = "tag: "
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
if not tags:
# Either we're using git < 1.8.3, or there really are no tags. We use
# a heuristic: assume all version tags have a digit. The old git %d
# expansion behaves like git log --decorate=short and strips out the
# refs/heads/ and refs/tags/ prefixes that would let us distinguish
# between branches and tags. By ignoring refnames without digits, we
# filter out many common branch names like "release" and
# "stabilization", as well as "HEAD" and "master".
tags = set([r for r in refs if re.search(r'\d', r)])
if verbose:
print("discarding '%s', no digits" % ",".join(refs - tags))
if verbose:
print("likely tags: %s" % ",".join(sorted(tags)))
for ref in sorted(tags):
# sorting will prefer e.g. "2.0" over "2.0rc1"
if ref.startswith(tag_prefix):
r = ref[len(tag_prefix):]
if verbose:
print("picking %s" % r)
return {"version": r,
"full-revisionid": keywords["full"].strip(),
"dirty": False, "error": None,
"date": date}
# no suitable tags, so version is "0+unknown", but full hex is still there
if verbose:
print("no suitable tags, using unknown + full revision id")
return {"version": "0+unknown",
"full-revisionid": keywords["full"].strip(),
"dirty": False, "error": "no suitable tags", "date": None}
@register_vcs_handler("git", "pieces_from_vcs")
def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
"""Get version from 'git describe' in the root of the source tree.
This only gets called if the git-archive 'subst' keywords were *not*
expanded, and _version.py hasn't already been rewritten with a short
version string, meaning we're inside a checked out source tree.
"""
GITS = ["git"]
if sys.platform == "win32":
GITS = ["git.cmd", "git.exe"]
out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root,
hide_stderr=True)
if rc != 0:
if verbose:
print("Directory %s not under git control" % root)
raise NotThisMethod("'git rev-parse --git-dir' returned error")
# if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
# if there isn't one, this yields HEX[-dirty] (no NUM)
describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty",
"--always", "--long",
"--match", "%s*" % tag_prefix],
cwd=root)
# --long was added in git-1.5.5
if describe_out is None:
raise NotThisMethod("'git describe' failed")
describe_out = describe_out.strip()
full_out, rc = run_command(GITS, ["rev-parse", "HEAD"], cwd=root)
if full_out is None:
raise NotThisMethod("'git rev-parse' failed")
full_out = full_out.strip()
pieces = {}
pieces["long"] = full_out
pieces["short"] = full_out[:7] # maybe improved later
pieces["error"] = None
# parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty]
# TAG might have hyphens.
git_describe = describe_out
# look for -dirty suffix
dirty = git_describe.endswith("-dirty")
pieces["dirty"] = dirty
if dirty:
git_describe = git_describe[:git_describe.rindex("-dirty")]
# now we have TAG-NUM-gHEX or HEX
if "-" in git_describe:
# TAG-NUM-gHEX
mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe)
if not mo:
# unparseable. Maybe git-describe is misbehaving?
pieces["error"] = ("unable to parse git-describe output: '%s'"
% describe_out)
return pieces
# tag
full_tag = mo.group(1)
if not full_tag.startswith(tag_prefix):
if verbose:
fmt = "tag '%s' doesn't start with prefix '%s'"
print(fmt % (full_tag, tag_prefix))
pieces["error"] = ("tag '%s' doesn't start with prefix '%s'"
% (full_tag, tag_prefix))
return pieces
pieces["closest-tag"] = full_tag[len(tag_prefix):]
# distance: number of commits since tag
pieces["distance"] = int(mo.group(2))
# commit: short hex revision ID
pieces["short"] = mo.group(3)
else:
# HEX: no tags
pieces["closest-tag"] = None
count_out, rc = run_command(GITS, ["rev-list", "HEAD", "--count"],
cwd=root)
pieces["distance"] = int(count_out) # total number of commits
# commit date: see ISO-8601 comment in git_versions_from_keywords()
date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"],
cwd=root)[0].strip()
pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
return pieces
def plus_or_dot(pieces):
"""Return a + if we don't already have one, else return a ."""
if "+" in pieces.get("closest-tag", ""):
return "."
return "+"
def render_pep440(pieces):
"""Build up version string, with post-release "local version identifier".
Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty
Exceptions:
1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"] or pieces["dirty"]:
rendered += plus_or_dot(pieces)
rendered += "%d.g%s" % (pieces["distance"], pieces["short"])
if pieces["dirty"]:
rendered += ".dirty"
else:
# exception #1
rendered = "0+untagged.%d.g%s" % (pieces["distance"],
pieces["short"])
if pieces["dirty"]:
rendered += ".dirty"
return rendered
def render_pep440_pre(pieces):
"""TAG[.post.devDISTANCE] -- No -dirty.
Exceptions:
1: no tags. 0.post.devDISTANCE
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"]:
rendered += ".post.dev%d" % pieces["distance"]
else:
# exception #1
rendered = "0.post.dev%d" % pieces["distance"]
return rendered
def render_pep440_post(pieces):
"""TAG[.postDISTANCE[.dev0]+gHEX] .
The ".dev0" means dirty. Note that .dev0 sorts backwards
(a dirty tree will appear "older" than the corresponding clean one),
but you shouldn't be releasing software with -dirty anyways.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"] or pieces["dirty"]:
rendered += ".post%d" % pieces["distance"]
if pieces["dirty"]:
rendered += ".dev0"
rendered += plus_or_dot(pieces)
rendered += "g%s" % pieces["short"]
else:
# exception #1
rendered = "0.post%d" % pieces["distance"]
if pieces["dirty"]:
rendered += ".dev0"
rendered += "+g%s" % pieces["short"]
return rendered
def render_pep440_old(pieces):
"""TAG[.postDISTANCE[.dev0]] .
The ".dev0" means dirty.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"] or pieces["dirty"]:
rendered += ".post%d" % pieces["distance"]
if pieces["dirty"]:
rendered += ".dev0"
else:
# exception #1
rendered = "0.post%d" % pieces["distance"]
if pieces["dirty"]:
rendered += ".dev0"
return rendered
def render_git_describe(pieces):
"""TAG[-DISTANCE-gHEX][-dirty].
Like 'git describe --tags --dirty --always'.
Exceptions:
1: no tags. HEX[-dirty] (note: no 'g' prefix)
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"]:
rendered += "-%d-g%s" % (pieces["distance"], pieces["short"])
else:
# exception #1
rendered = pieces["short"]
if pieces["dirty"]:
rendered += "-dirty"
return rendered
def render_git_describe_long(pieces):
"""TAG-DISTANCE-gHEX[-dirty].
Like 'git describe --tags --dirty --always -long'.
The distance/hash is unconditional.
Exceptions:
1: no tags. HEX[-dirty] (note: no 'g' prefix)
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
rendered += "-%d-g%s" % (pieces["distance"], pieces["short"])
else:
# exception #1
rendered = pieces["short"]
if pieces["dirty"]:
rendered += "-dirty"
return rendered
def render(pieces, style):
"""Render the given version pieces into the requested style."""
if pieces["error"]:
return {"version": "unknown",
"full-revisionid": pieces.get("long"),
"dirty": None,
"error": pieces["error"],
"date": None}
if not style or style == "default":
style = "pep440" # the default
if style == "pep440":
rendered = render_pep440(pieces)
elif style == "pep440-pre":
rendered = render_pep440_pre(pieces)
elif style == "pep440-post":
rendered = render_pep440_post(pieces)
elif style == "pep440-old":
rendered = render_pep440_old(pieces)
elif style == "git-describe":
rendered = render_git_describe(pieces)
elif style == "git-describe-long":
rendered = render_git_describe_long(pieces)
else:
raise ValueError("unknown style '%s'" % style)
return {"version": rendered, "full-revisionid": pieces["long"],
"dirty": pieces["dirty"], "error": None,
"date": pieces.get("date")}
def get_versions():
"""Get version information or return default if unable to do so."""
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
# __file__, we can work backwards from there to the root. Some
# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
# case we can only use expanded keywords.
cfg = get_config()
verbose = cfg.verbose
try:
return git_versions_from_keywords(get_keywords(), cfg.tag_prefix,
verbose)
except NotThisMethod:
pass
try:
root = os.path.realpath(__file__)
# versionfile_source is the relative path from the top of the source
# tree (where the .git directory might live) to this file. Invert
# this to find the root from __file__.
for i in cfg.versionfile_source.split('/'):
root = os.path.dirname(root)
except NameError:
return {"version": "0+unknown", "full-revisionid": None,
"dirty": None,
"error": "unable to find root of source tree",
"date": None}
try:
pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose)
return render(pieces, cfg.style)
except NotThisMethod:
pass
try:
if cfg.parentdir_prefix:
return versions_from_parentdir(cfg.parentdir_prefix, root, verbose)
except NotThisMethod:
pass
return {"version": "0+unknown", "full-revisionid": None,
"dirty": None,
"error": "unable to compute version", "date": None}

View File

@@ -1,670 +0,0 @@
# -*- coding: utf-8 -*-
# Resource object code
#
# Created by: The Resource Compiler for PyQt5 (Qt v5.9.7)
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore
qt_resource_data = b"\
\x00\x00\x0b\x04\
\x3c\
\x3f\x78\x6d\x6c\x20\x76\x65\x72\x73\x69\x6f\x6e\x3d\x22\x31\x2e\
\x30\x22\x20\x65\x6e\x63\x6f\x64\x69\x6e\x67\x3d\x22\x55\x54\x46\
\x2d\x38\x22\x20\x73\x74\x61\x6e\x64\x61\x6c\x6f\x6e\x65\x3d\x22\
\x6e\x6f\x22\x3f\x3e\x0d\x0a\x3c\x21\x2d\x2d\x20\x47\x65\x6e\x65\
\x72\x61\x74\x6f\x72\x3a\x20\x41\x64\x6f\x62\x65\x20\x49\x6c\x6c\
\x75\x73\x74\x72\x61\x74\x6f\x72\x20\x31\x36\x2e\x30\x2e\x30\x2c\
\x20\x53\x56\x47\x20\x45\x78\x70\x6f\x72\x74\x20\x50\x6c\x75\x67\
\x2d\x49\x6e\x20\x2e\x20\x53\x56\x47\x20\x56\x65\x72\x73\x69\x6f\
\x6e\x3a\x20\x36\x2e\x30\x30\x20\x42\x75\x69\x6c\x64\x20\x30\x29\
\x20\x20\x2d\x2d\x3e\x0d\x0a\x0d\x0a\x3c\x73\x76\x67\x0d\x0a\x20\
\x20\x20\x78\x6d\x6c\x6e\x73\x3a\x64\x63\x3d\x22\x68\x74\x74\x70\
\x3a\x2f\x2f\x70\x75\x72\x6c\x2e\x6f\x72\x67\x2f\x64\x63\x2f\x65\
\x6c\x65\x6d\x65\x6e\x74\x73\x2f\x31\x2e\x31\x2f\x22\x0d\x0a\x20\
\x20\x20\x78\x6d\x6c\x6e\x73\x3a\x63\x63\x3d\x22\x68\x74\x74\x70\
\x3a\x2f\x2f\x63\x72\x65\x61\x74\x69\x76\x65\x63\x6f\x6d\x6d\x6f\
\x6e\x73\x2e\x6f\x72\x67\x2f\x6e\x73\x23\x22\x0d\x0a\x20\x20\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x0d\x0a\x20\x20\x20\x78\x6d\x6c\x6e\
\x73\x3a\x73\x76\x67\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\
\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x32\x30\x30\x30\x2f\x73\x76\
\x67\x22\x0d\x0a\x20\x20\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\x74\
\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\
\x32\x30\x30\x30\x2f\x73\x76\x67\x22\x0d\x0a\x20\x20\x20\x78\x6d\
\x6c\x6e\x73\x3a\x73\x6f\x64\x69\x70\x6f\x64\x69\x3d\x22\x68\x74\
\x74\x70\x3a\x2f\x2f\x73\x6f\x64\x69\x70\x6f\x64\x69\x2e\x73\x6f\
\x75\x72\x63\x65\x66\x6f\x72\x67\x65\x2e\x6e\x65\x74\x2f\x44\x54\
\x44\x2f\x73\x6f\x64\x69\x70\x6f\x64\x69\x2d\x30\x2e\x64\x74\x64\
\x22\x0d\x0a\x20\x20\x20\x78\x6d\x6c\x6e\x73\x3a\x69\x6e\x6b\x73\
\x63\x61\x70\x65\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\
\x2e\x69\x6e\x6b\x73\x63\x61\x70\x65\x2e\x6f\x72\x67\x2f\x6e\x61\
\x6d\x65\x73\x70\x61\x63\x65\x73\x2f\x69\x6e\x6b\x73\x63\x61\x70\
\x65\x22\x0d\x0a\x20\x20\x20\x76\x65\x72\x73\x69\x6f\x6e\x3d\x22\
\x31\x2e\x31\x22\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x43\x61\x70\
\x61\x5f\x31\x22\x0d\x0a\x20\x20\x20\x78\x3d\x22\x30\x70\x78\x22\
\x0d\x0a\x20\x20\x20\x79\x3d\x22\x30\x70\x78\x22\x0d\x0a\x20\x20\
\x20\x77\x69\x64\x74\x68\x3d\x22\x35\x31\x32\x22\x0d\x0a\x20\x20\
\x20\x68\x65\x69\x67\x68\x74\x3d\x22\x35\x31\x32\x22\x0d\x0a\x20\
\x20\x20\x76\x69\x65\x77\x42\x6f\x78\x3d\x22\x30\x20\x30\x20\x35\
\x31\x32\x20\x35\x31\x32\x22\x0d\x0a\x20\x20\x20\x78\x6d\x6c\x3a\
\x73\x70\x61\x63\x65\x3d\x22\x70\x72\x65\x73\x65\x72\x76\x65\x22\
\x0d\x0a\x20\x20\x20\x73\x6f\x64\x69\x70\x6f\x64\x69\x3a\x64\x6f\
\x63\x6e\x61\x6d\x65\x3d\x22\x63\x6c\x6f\x73\x65\x2d\x62\x75\x74\
\x74\x6f\x6e\x2e\x73\x76\x67\x22\x0d\x0a\x20\x20\x20\x69\x6e\x6b\
\x73\x63\x61\x70\x65\x3a\x76\x65\x72\x73\x69\x6f\x6e\x3d\x22\x30\
\x2e\x39\x32\x2e\x33\x20\x28\x32\x34\x30\x35\x35\x34\x36\x2c\x20\
\x32\x30\x31\x38\x2d\x30\x33\x2d\x31\x31\x29\x22\x3e\x3c\x6d\x65\
\x74\x61\x64\x61\x74\x61\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x6d\
\x65\x74\x61\x64\x61\x74\x61\x38\x39\x37\x22\x3e\x3c\x72\x64\x66\
\x3a\x52\x44\x46\x3e\x3c\x63\x63\x3a\x57\x6f\x72\x6b\x0d\x0a\x20\
\x20\x20\x20\x20\x20\x20\x72\x64\x66\x3a\x61\x62\x6f\x75\x74\x3d\
\x22\x22\x3e\x3c\x64\x63\x3a\x66\x6f\x72\x6d\x61\x74\x3e\x69\x6d\
\x61\x67\x65\x2f\x73\x76\x67\x2b\x78\x6d\x6c\x3c\x2f\x64\x63\x3a\
\x66\x6f\x72\x6d\x61\x74\x3e\x3c\x64\x63\x3a\x74\x79\x70\x65\x0d\
\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x72\x64\x66\x3a\x72\x65\
\x73\x6f\x75\x72\x63\x65\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x70\
\x75\x72\x6c\x2e\x6f\x72\x67\x2f\x64\x63\x2f\x64\x63\x6d\x69\x74\
\x79\x70\x65\x2f\x53\x74\x69\x6c\x6c\x49\x6d\x61\x67\x65\x22\x20\
\x2f\x3e\x3c\x64\x63\x3a\x74\x69\x74\x6c\x65\x3e\x3c\x2f\x64\x63\
\x3a\x74\x69\x74\x6c\x65\x3e\x3c\x2f\x63\x63\x3a\x57\x6f\x72\x6b\
\x3e\x3c\x2f\x72\x64\x66\x3a\x52\x44\x46\x3e\x3c\x2f\x6d\x65\x74\
\x61\x64\x61\x74\x61\x3e\x3c\x64\x65\x66\x73\x0d\x0a\x20\x20\x20\
\x69\x64\x3d\x22\x64\x65\x66\x73\x38\x39\x35\x22\x20\x2f\x3e\x3c\
\x73\x6f\x64\x69\x70\x6f\x64\x69\x3a\x6e\x61\x6d\x65\x64\x76\x69\
\x65\x77\x0d\x0a\x20\x20\x20\x70\x61\x67\x65\x63\x6f\x6c\x6f\x72\
\x3d\x22\x23\x66\x66\x66\x66\x66\x66\x22\x0d\x0a\x20\x20\x20\x62\
\x6f\x72\x64\x65\x72\x63\x6f\x6c\x6f\x72\x3d\x22\x23\x36\x36\x36\
\x36\x36\x36\x22\x0d\x0a\x20\x20\x20\x62\x6f\x72\x64\x65\x72\x6f\
\x70\x61\x63\x69\x74\x79\x3d\x22\x31\x22\x0d\x0a\x20\x20\x20\x6f\
\x62\x6a\x65\x63\x74\x74\x6f\x6c\x65\x72\x61\x6e\x63\x65\x3d\x22\
\x31\x30\x22\x0d\x0a\x20\x20\x20\x67\x72\x69\x64\x74\x6f\x6c\x65\
\x72\x61\x6e\x63\x65\x3d\x22\x31\x30\x22\x0d\x0a\x20\x20\x20\x67\
\x75\x69\x64\x65\x74\x6f\x6c\x65\x72\x61\x6e\x63\x65\x3d\x22\x31\
\x30\x22\x0d\x0a\x20\x20\x20\x69\x6e\x6b\x73\x63\x61\x70\x65\x3a\
\x70\x61\x67\x65\x6f\x70\x61\x63\x69\x74\x79\x3d\x22\x30\x22\x0d\
\x0a\x20\x20\x20\x69\x6e\x6b\x73\x63\x61\x70\x65\x3a\x70\x61\x67\
\x65\x73\x68\x61\x64\x6f\x77\x3d\x22\x32\x22\x0d\x0a\x20\x20\x20\
\x69\x6e\x6b\x73\x63\x61\x70\x65\x3a\x77\x69\x6e\x64\x6f\x77\x2d\
\x77\x69\x64\x74\x68\x3d\x22\x31\x39\x32\x30\x22\x0d\x0a\x20\x20\
\x20\x69\x6e\x6b\x73\x63\x61\x70\x65\x3a\x77\x69\x6e\x64\x6f\x77\
\x2d\x68\x65\x69\x67\x68\x74\x3d\x22\x31\x30\x31\x37\x22\x0d\x0a\
\x20\x20\x20\x69\x64\x3d\x22\x6e\x61\x6d\x65\x64\x76\x69\x65\x77\
\x38\x39\x33\x22\x0d\x0a\x20\x20\x20\x73\x68\x6f\x77\x67\x72\x69\
\x64\x3d\x22\x66\x61\x6c\x73\x65\x22\x0d\x0a\x20\x20\x20\x66\x69\
\x74\x2d\x6d\x61\x72\x67\x69\x6e\x2d\x74\x6f\x70\x3d\x22\x30\x22\
\x0d\x0a\x20\x20\x20\x66\x69\x74\x2d\x6d\x61\x72\x67\x69\x6e\x2d\
\x6c\x65\x66\x74\x3d\x22\x30\x22\x0d\x0a\x20\x20\x20\x66\x69\x74\
\x2d\x6d\x61\x72\x67\x69\x6e\x2d\x72\x69\x67\x68\x74\x3d\x22\x30\
\x22\x0d\x0a\x20\x20\x20\x66\x69\x74\x2d\x6d\x61\x72\x67\x69\x6e\
\x2d\x62\x6f\x74\x74\x6f\x6d\x3d\x22\x30\x22\x0d\x0a\x20\x20\x20\
\x69\x6e\x6b\x73\x63\x61\x70\x65\x3a\x7a\x6f\x6f\x6d\x3d\x22\x30\
\x2e\x38\x35\x38\x36\x32\x39\x36\x36\x22\x0d\x0a\x20\x20\x20\x69\
\x6e\x6b\x73\x63\x61\x70\x65\x3a\x63\x78\x3d\x22\x33\x34\x35\x2e\
\x32\x39\x31\x34\x32\x22\x0d\x0a\x20\x20\x20\x69\x6e\x6b\x73\x63\
\x61\x70\x65\x3a\x63\x79\x3d\x22\x33\x32\x2e\x37\x33\x31\x32\x35\
\x38\x22\x0d\x0a\x20\x20\x20\x69\x6e\x6b\x73\x63\x61\x70\x65\x3a\
\x77\x69\x6e\x64\x6f\x77\x2d\x78\x3d\x22\x2d\x38\x22\x0d\x0a\x20\
\x20\x20\x69\x6e\x6b\x73\x63\x61\x70\x65\x3a\x77\x69\x6e\x64\x6f\
\x77\x2d\x79\x3d\x22\x2d\x38\x22\x0d\x0a\x20\x20\x20\x69\x6e\x6b\
\x73\x63\x61\x70\x65\x3a\x77\x69\x6e\x64\x6f\x77\x2d\x6d\x61\x78\
\x69\x6d\x69\x7a\x65\x64\x3d\x22\x31\x22\x0d\x0a\x20\x20\x20\x69\
\x6e\x6b\x73\x63\x61\x70\x65\x3a\x63\x75\x72\x72\x65\x6e\x74\x2d\
\x6c\x61\x79\x65\x72\x3d\x22\x43\x61\x70\x61\x5f\x31\x22\x20\x2f\
\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\x38\
\x36\x30\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\
\x6d\x3d\x22\x6d\x61\x74\x72\x69\x78\x28\x30\x2e\x37\x31\x37\x30\
\x38\x36\x38\x33\x2c\x30\x2c\x30\x2c\x30\x2e\x37\x31\x37\x30\x38\
\x36\x38\x33\x2c\x31\x32\x38\x2c\x31\x32\x38\x29\x22\x3e\x0d\x0a\
\x09\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x63\x6c\x6f\x73\
\x65\x22\x3e\x0d\x0a\x09\x09\x3c\x70\x6f\x6c\x79\x67\x6f\x6e\x0d\
\x0a\x20\x20\x20\x70\x6f\x69\x6e\x74\x73\x3d\x22\x33\x35\x37\x2c\
\x33\x32\x31\x2e\x33\x20\x32\x31\x34\x2e\x32\x2c\x31\x37\x38\x2e\
\x35\x20\x33\x35\x37\x2c\x33\x35\x2e\x37\x20\x33\x32\x31\x2e\x33\
\x2c\x30\x20\x31\x37\x38\x2e\x35\x2c\x31\x34\x32\x2e\x38\x20\x33\
\x35\x2e\x37\x2c\x30\x20\x30\x2c\x33\x35\x2e\x37\x20\x31\x34\x32\
\x2e\x38\x2c\x31\x37\x38\x2e\x35\x20\x30\x2c\x33\x32\x31\x2e\x33\
\x20\x33\x35\x2e\x37\x2c\x33\x35\x37\x20\x31\x37\x38\x2e\x35\x2c\
\x32\x31\x34\x2e\x32\x20\x33\x32\x31\x2e\x33\x2c\x33\x35\x37\x20\
\x22\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x70\x6f\x6c\x79\x67\x6f\
\x6e\x38\x35\x37\x22\x20\x2f\x3e\x0d\x0a\x09\x3c\x2f\x67\x3e\x0d\
\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\
\x3d\x22\x67\x38\x36\x32\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\
\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\
\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\
\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\x38\x36\x34\
\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\
\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\x2c\x31\x35\x35\
\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\
\x20\x20\x69\x64\x3d\x22\x67\x38\x36\x36\x22\x0d\x0a\x20\x20\x20\
\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\
\x6c\x61\x74\x65\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\
\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\
\x67\x38\x36\x38\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\x66\
\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\
\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\
\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\x38\x37\x30\x22\x0d\
\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\
\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\x2c\x31\x35\x35\x29\x22\
\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\
\x69\x64\x3d\x22\x67\x38\x37\x32\x22\x0d\x0a\x20\x20\x20\x74\x72\
\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\
\x74\x65\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\
\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\x38\
\x37\x34\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\
\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\x2c\x31\
\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\
\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\x38\x37\x36\x22\x0d\x0a\x20\
\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\
\x6e\x73\x6c\x61\x74\x65\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\
\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\
\x3d\x22\x67\x38\x37\x38\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\
\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\
\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\
\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\x38\x38\x30\
\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\
\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\x2c\x31\x35\x35\
\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\
\x20\x20\x69\x64\x3d\x22\x67\x38\x38\x32\x22\x0d\x0a\x20\x20\x20\
\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\
\x6c\x61\x74\x65\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\
\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\
\x67\x38\x38\x34\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\x66\
\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\
\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\
\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\x38\x38\x36\x22\x0d\
\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\
\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\x2c\x31\x35\x35\x29\x22\
\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\
\x69\x64\x3d\x22\x67\x38\x38\x38\x22\x0d\x0a\x20\x20\x20\x74\x72\
\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\
\x74\x65\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\
\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\x38\
\x39\x30\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\
\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\x2c\x31\
\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x2f\x73\
\x76\x67\x3e\
\x00\x00\x0b\xf7\
\x3c\
\x3f\x78\x6d\x6c\x20\x76\x65\x72\x73\x69\x6f\x6e\x3d\x22\x31\x2e\
\x30\x22\x20\x65\x6e\x63\x6f\x64\x69\x6e\x67\x3d\x22\x55\x54\x46\
\x2d\x38\x22\x20\x73\x74\x61\x6e\x64\x61\x6c\x6f\x6e\x65\x3d\x22\
\x6e\x6f\x22\x3f\x3e\x0d\x0a\x3c\x21\x2d\x2d\x20\x47\x65\x6e\x65\
\x72\x61\x74\x6f\x72\x3a\x20\x41\x64\x6f\x62\x65\x20\x49\x6c\x6c\
\x75\x73\x74\x72\x61\x74\x6f\x72\x20\x31\x36\x2e\x30\x2e\x30\x2c\
\x20\x53\x56\x47\x20\x45\x78\x70\x6f\x72\x74\x20\x50\x6c\x75\x67\
\x2d\x49\x6e\x20\x2e\x20\x53\x56\x47\x20\x56\x65\x72\x73\x69\x6f\
\x6e\x3a\x20\x36\x2e\x30\x30\x20\x42\x75\x69\x6c\x64\x20\x30\x29\
\x20\x20\x2d\x2d\x3e\x0d\x0a\x0d\x0a\x3c\x73\x76\x67\x0d\x0a\x20\
\x20\x20\x78\x6d\x6c\x6e\x73\x3a\x64\x63\x3d\x22\x68\x74\x74\x70\
\x3a\x2f\x2f\x70\x75\x72\x6c\x2e\x6f\x72\x67\x2f\x64\x63\x2f\x65\
\x6c\x65\x6d\x65\x6e\x74\x73\x2f\x31\x2e\x31\x2f\x22\x0d\x0a\x20\
\x20\x20\x78\x6d\x6c\x6e\x73\x3a\x63\x63\x3d\x22\x68\x74\x74\x70\
\x3a\x2f\x2f\x63\x72\x65\x61\x74\x69\x76\x65\x63\x6f\x6d\x6d\x6f\
\x6e\x73\x2e\x6f\x72\x67\x2f\x6e\x73\x23\x22\x0d\x0a\x20\x20\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x0d\x0a\x20\x20\x20\x78\x6d\x6c\x6e\
\x73\x3a\x73\x76\x67\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\
\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x32\x30\x30\x30\x2f\x73\x76\
\x67\x22\x0d\x0a\x20\x20\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\x74\
\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\
\x32\x30\x30\x30\x2f\x73\x76\x67\x22\x0d\x0a\x20\x20\x20\x78\x6d\
\x6c\x6e\x73\x3a\x73\x6f\x64\x69\x70\x6f\x64\x69\x3d\x22\x68\x74\
\x74\x70\x3a\x2f\x2f\x73\x6f\x64\x69\x70\x6f\x64\x69\x2e\x73\x6f\
\x75\x72\x63\x65\x66\x6f\x72\x67\x65\x2e\x6e\x65\x74\x2f\x44\x54\
\x44\x2f\x73\x6f\x64\x69\x70\x6f\x64\x69\x2d\x30\x2e\x64\x74\x64\
\x22\x0d\x0a\x20\x20\x20\x78\x6d\x6c\x6e\x73\x3a\x69\x6e\x6b\x73\
\x63\x61\x70\x65\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\
\x2e\x69\x6e\x6b\x73\x63\x61\x70\x65\x2e\x6f\x72\x67\x2f\x6e\x61\
\x6d\x65\x73\x70\x61\x63\x65\x73\x2f\x69\x6e\x6b\x73\x63\x61\x70\
\x65\x22\x0d\x0a\x20\x20\x20\x76\x65\x72\x73\x69\x6f\x6e\x3d\x22\
\x31\x2e\x31\x22\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x43\x61\x70\
\x61\x5f\x31\x22\x0d\x0a\x20\x20\x20\x78\x3d\x22\x30\x70\x78\x22\
\x0d\x0a\x20\x20\x20\x79\x3d\x22\x30\x70\x78\x22\x0d\x0a\x20\x20\
\x20\x77\x69\x64\x74\x68\x3d\x22\x35\x31\x32\x22\x0d\x0a\x20\x20\
\x20\x68\x65\x69\x67\x68\x74\x3d\x22\x35\x31\x32\x22\x0d\x0a\x20\
\x20\x20\x76\x69\x65\x77\x42\x6f\x78\x3d\x22\x30\x20\x30\x20\x35\
\x31\x32\x20\x35\x31\x32\x22\x0d\x0a\x20\x20\x20\x78\x6d\x6c\x3a\
\x73\x70\x61\x63\x65\x3d\x22\x70\x72\x65\x73\x65\x72\x76\x65\x22\
\x0d\x0a\x20\x20\x20\x73\x6f\x64\x69\x70\x6f\x64\x69\x3a\x64\x6f\
\x63\x6e\x61\x6d\x65\x3d\x22\x63\x6c\x6f\x73\x65\x2d\x62\x75\x74\
\x74\x6f\x6e\x2d\x64\x69\x73\x61\x62\x6c\x65\x64\x2e\x73\x76\x67\
\x22\x0d\x0a\x20\x20\x20\x69\x6e\x6b\x73\x63\x61\x70\x65\x3a\x76\
\x65\x72\x73\x69\x6f\x6e\x3d\x22\x30\x2e\x39\x32\x2e\x33\x20\x28\
\x32\x34\x30\x35\x35\x34\x36\x2c\x20\x32\x30\x31\x38\x2d\x30\x33\
\x2d\x31\x31\x29\x22\x3e\x3c\x6d\x65\x74\x61\x64\x61\x74\x61\x0d\
\x0a\x20\x20\x20\x69\x64\x3d\x22\x6d\x65\x74\x61\x64\x61\x74\x61\
\x38\x39\x37\x22\x3e\x3c\x72\x64\x66\x3a\x52\x44\x46\x3e\x3c\x63\
\x63\x3a\x57\x6f\x72\x6b\x0d\x0a\x20\x20\x20\x20\x20\x20\x20\x72\
\x64\x66\x3a\x61\x62\x6f\x75\x74\x3d\x22\x22\x3e\x3c\x64\x63\x3a\
\x66\x6f\x72\x6d\x61\x74\x3e\x69\x6d\x61\x67\x65\x2f\x73\x76\x67\
\x2b\x78\x6d\x6c\x3c\x2f\x64\x63\x3a\x66\x6f\x72\x6d\x61\x74\x3e\
\x3c\x64\x63\x3a\x74\x79\x70\x65\x0d\x0a\x20\x20\x20\x20\x20\x20\
\x20\x20\x20\x72\x64\x66\x3a\x72\x65\x73\x6f\x75\x72\x63\x65\x3d\
\x22\x68\x74\x74\x70\x3a\x2f\x2f\x70\x75\x72\x6c\x2e\x6f\x72\x67\
\x2f\x64\x63\x2f\x64\x63\x6d\x69\x74\x79\x70\x65\x2f\x53\x74\x69\
\x6c\x6c\x49\x6d\x61\x67\x65\x22\x20\x2f\x3e\x3c\x64\x63\x3a\x74\
\x69\x74\x6c\x65\x3e\x3c\x2f\x64\x63\x3a\x74\x69\x74\x6c\x65\x3e\
\x3c\x2f\x63\x63\x3a\x57\x6f\x72\x6b\x3e\x3c\x2f\x72\x64\x66\x3a\
\x52\x44\x46\x3e\x3c\x2f\x6d\x65\x74\x61\x64\x61\x74\x61\x3e\x3c\
\x64\x65\x66\x73\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x64\x65\x66\
\x73\x38\x39\x35\x22\x20\x2f\x3e\x3c\x73\x6f\x64\x69\x70\x6f\x64\
\x69\x3a\x6e\x61\x6d\x65\x64\x76\x69\x65\x77\x0d\x0a\x20\x20\x20\
\x70\x61\x67\x65\x63\x6f\x6c\x6f\x72\x3d\x22\x23\x66\x66\x66\x66\
\x66\x66\x22\x0d\x0a\x20\x20\x20\x62\x6f\x72\x64\x65\x72\x63\x6f\
\x6c\x6f\x72\x3d\x22\x23\x36\x36\x36\x36\x36\x36\x22\x0d\x0a\x20\
\x20\x20\x62\x6f\x72\x64\x65\x72\x6f\x70\x61\x63\x69\x74\x79\x3d\
\x22\x31\x22\x0d\x0a\x20\x20\x20\x6f\x62\x6a\x65\x63\x74\x74\x6f\
\x6c\x65\x72\x61\x6e\x63\x65\x3d\x22\x31\x30\x22\x0d\x0a\x20\x20\
\x20\x67\x72\x69\x64\x74\x6f\x6c\x65\x72\x61\x6e\x63\x65\x3d\x22\
\x31\x30\x22\x0d\x0a\x20\x20\x20\x67\x75\x69\x64\x65\x74\x6f\x6c\
\x65\x72\x61\x6e\x63\x65\x3d\x22\x31\x30\x22\x0d\x0a\x20\x20\x20\
\x69\x6e\x6b\x73\x63\x61\x70\x65\x3a\x70\x61\x67\x65\x6f\x70\x61\
\x63\x69\x74\x79\x3d\x22\x30\x22\x0d\x0a\x20\x20\x20\x69\x6e\x6b\
\x73\x63\x61\x70\x65\x3a\x70\x61\x67\x65\x73\x68\x61\x64\x6f\x77\
\x3d\x22\x32\x22\x0d\x0a\x20\x20\x20\x69\x6e\x6b\x73\x63\x61\x70\
\x65\x3a\x77\x69\x6e\x64\x6f\x77\x2d\x77\x69\x64\x74\x68\x3d\x22\
\x31\x39\x32\x30\x22\x0d\x0a\x20\x20\x20\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x3a\x77\x69\x6e\x64\x6f\x77\x2d\x68\x65\x69\x67\x68\x74\
\x3d\x22\x31\x30\x31\x37\x22\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\
\x6e\x61\x6d\x65\x64\x76\x69\x65\x77\x38\x39\x33\x22\x0d\x0a\x20\
\x20\x20\x73\x68\x6f\x77\x67\x72\x69\x64\x3d\x22\x66\x61\x6c\x73\
\x65\x22\x0d\x0a\x20\x20\x20\x66\x69\x74\x2d\x6d\x61\x72\x67\x69\
\x6e\x2d\x74\x6f\x70\x3d\x22\x30\x22\x0d\x0a\x20\x20\x20\x66\x69\
\x74\x2d\x6d\x61\x72\x67\x69\x6e\x2d\x6c\x65\x66\x74\x3d\x22\x30\
\x22\x0d\x0a\x20\x20\x20\x66\x69\x74\x2d\x6d\x61\x72\x67\x69\x6e\
\x2d\x72\x69\x67\x68\x74\x3d\x22\x30\x22\x0d\x0a\x20\x20\x20\x66\
\x69\x74\x2d\x6d\x61\x72\x67\x69\x6e\x2d\x62\x6f\x74\x74\x6f\x6d\
\x3d\x22\x30\x22\x0d\x0a\x20\x20\x20\x69\x6e\x6b\x73\x63\x61\x70\
\x65\x3a\x7a\x6f\x6f\x6d\x3d\x22\x30\x2e\x38\x35\x38\x36\x32\x39\
\x36\x36\x22\x0d\x0a\x20\x20\x20\x69\x6e\x6b\x73\x63\x61\x70\x65\
\x3a\x63\x78\x3d\x22\x33\x34\x35\x2e\x32\x39\x31\x34\x32\x22\x0d\
\x0a\x20\x20\x20\x69\x6e\x6b\x73\x63\x61\x70\x65\x3a\x63\x79\x3d\
\x22\x33\x32\x2e\x37\x33\x31\x32\x35\x38\x22\x0d\x0a\x20\x20\x20\
\x69\x6e\x6b\x73\x63\x61\x70\x65\x3a\x77\x69\x6e\x64\x6f\x77\x2d\
\x78\x3d\x22\x2d\x38\x22\x0d\x0a\x20\x20\x20\x69\x6e\x6b\x73\x63\
\x61\x70\x65\x3a\x77\x69\x6e\x64\x6f\x77\x2d\x79\x3d\x22\x2d\x38\
\x22\x0d\x0a\x20\x20\x20\x69\x6e\x6b\x73\x63\x61\x70\x65\x3a\x77\
\x69\x6e\x64\x6f\x77\x2d\x6d\x61\x78\x69\x6d\x69\x7a\x65\x64\x3d\
\x22\x31\x22\x0d\x0a\x20\x20\x20\x69\x6e\x6b\x73\x63\x61\x70\x65\
\x3a\x63\x75\x72\x72\x65\x6e\x74\x2d\x6c\x61\x79\x65\x72\x3d\x22\
\x43\x61\x70\x61\x5f\x31\x22\x20\x2f\x3e\x0d\x0a\x3c\x67\x0d\x0a\
\x20\x20\x20\x69\x64\x3d\x22\x67\x38\x36\x30\x22\x0d\x0a\x20\x20\
\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x6d\x61\x74\x72\
\x69\x78\x28\x30\x2e\x37\x31\x37\x30\x38\x36\x38\x33\x2c\x30\x2c\
\x30\x2c\x30\x2e\x37\x31\x37\x30\x38\x36\x38\x33\x2c\x31\x32\x38\
\x2c\x31\x32\x38\x29\x22\x0d\x0a\x20\x20\x20\x73\x74\x79\x6c\x65\
\x3d\x22\x73\x74\x72\x6f\x6b\x65\x3a\x6e\x6f\x6e\x65\x3b\x73\x74\
\x72\x6f\x6b\x65\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\x31\x3b\x66\
\x69\x6c\x6c\x3a\x23\x30\x30\x30\x30\x30\x30\x3b\x66\x69\x6c\x6c\
\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\x30\x2e\x35\x30\x31\x39\x36\
\x30\x38\x31\x22\x3e\x0d\x0a\x09\x3c\x67\x0d\x0a\x20\x20\x20\x69\
\x64\x3d\x22\x63\x6c\x6f\x73\x65\x22\x0d\x0a\x20\x20\x20\x73\x74\
\x79\x6c\x65\x3d\x22\x73\x74\x72\x6f\x6b\x65\x3a\x6e\x6f\x6e\x65\
\x3b\x73\x74\x72\x6f\x6b\x65\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\
\x31\x3b\x66\x69\x6c\x6c\x3a\x23\x30\x30\x30\x30\x30\x30\x3b\x66\
\x69\x6c\x6c\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\x30\x2e\x35\x30\
\x31\x39\x36\x30\x38\x31\x22\x3e\x0d\x0a\x09\x09\x3c\x70\x6f\x6c\
\x79\x67\x6f\x6e\x0d\x0a\x20\x20\x20\x70\x6f\x69\x6e\x74\x73\x3d\
\x22\x33\x35\x37\x2c\x33\x32\x31\x2e\x33\x20\x32\x31\x34\x2e\x32\
\x2c\x31\x37\x38\x2e\x35\x20\x33\x35\x37\x2c\x33\x35\x2e\x37\x20\
\x33\x32\x31\x2e\x33\x2c\x30\x20\x31\x37\x38\x2e\x35\x2c\x31\x34\
\x32\x2e\x38\x20\x33\x35\x2e\x37\x2c\x30\x20\x30\x2c\x33\x35\x2e\
\x37\x20\x31\x34\x32\x2e\x38\x2c\x31\x37\x38\x2e\x35\x20\x30\x2c\
\x33\x32\x31\x2e\x33\x20\x33\x35\x2e\x37\x2c\x33\x35\x37\x20\x31\
\x37\x38\x2e\x35\x2c\x32\x31\x34\x2e\x32\x20\x33\x32\x31\x2e\x33\
\x2c\x33\x35\x37\x20\x22\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x70\
\x6f\x6c\x79\x67\x6f\x6e\x38\x35\x37\x22\x0d\x0a\x20\x20\x20\x73\
\x74\x79\x6c\x65\x3d\x22\x73\x74\x72\x6f\x6b\x65\x3a\x6e\x6f\x6e\
\x65\x3b\x73\x74\x72\x6f\x6b\x65\x2d\x6f\x70\x61\x63\x69\x74\x79\
\x3a\x31\x3b\x66\x69\x6c\x6c\x3a\x23\x30\x30\x30\x30\x30\x30\x3b\
\x66\x69\x6c\x6c\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\x30\x2e\x35\
\x30\x31\x39\x36\x30\x38\x31\x22\x20\x2f\x3e\x0d\x0a\x09\x3c\x2f\
\x67\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\
\x20\x69\x64\x3d\x22\x67\x38\x36\x32\x22\x0d\x0a\x20\x20\x20\x74\
\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\
\x61\x74\x65\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\
\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\
\x38\x36\x34\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\
\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\x2c\
\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\
\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\x38\x36\x36\x22\x0d\x0a\
\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\
\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\
\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\
\x64\x3d\x22\x67\x38\x36\x38\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\
\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\
\x65\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\
\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\x38\x37\
\x30\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\
\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\x2c\x31\x35\
\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\
\x20\x20\x20\x69\x64\x3d\x22\x67\x38\x37\x32\x22\x0d\x0a\x20\x20\
\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\
\x73\x6c\x61\x74\x65\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\
\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\
\x22\x67\x38\x37\x34\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\
\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\
\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\
\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\x38\x37\x36\x22\
\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\
\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\x2c\x31\x35\x35\x29\
\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\
\x20\x69\x64\x3d\x22\x67\x38\x37\x38\x22\x0d\x0a\x20\x20\x20\x74\
\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\
\x61\x74\x65\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\
\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\
\x38\x38\x30\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\
\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\x2c\
\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\
\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\x38\x38\x32\x22\x0d\x0a\
\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\
\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\
\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\
\x64\x3d\x22\x67\x38\x38\x34\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\
\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\
\x65\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\
\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\x22\x67\x38\x38\
\x36\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\
\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\x30\x2c\x31\x35\
\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\
\x20\x20\x20\x69\x64\x3d\x22\x67\x38\x38\x38\x22\x0d\x0a\x20\x20\
\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\
\x73\x6c\x61\x74\x65\x28\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\
\x3c\x2f\x67\x3e\x0d\x0a\x3c\x67\x0d\x0a\x20\x20\x20\x69\x64\x3d\
\x22\x67\x38\x39\x30\x22\x0d\x0a\x20\x20\x20\x74\x72\x61\x6e\x73\
\x66\x6f\x72\x6d\x3d\x22\x74\x72\x61\x6e\x73\x6c\x61\x74\x65\x28\
\x30\x2c\x31\x35\x35\x29\x22\x3e\x0d\x0a\x3c\x2f\x67\x3e\x0d\x0a\
\x3c\x2f\x73\x76\x67\x3e\
\x00\x00\x06\x61\
\x0d\
\x0a\x2f\x2a\x0d\x0a\x20\x2a\x20\x44\x65\x66\x61\x75\x6c\x74\x20\
\x73\x74\x79\x6c\x65\x20\x73\x68\x65\x65\x74\x20\x6f\x6e\x20\x57\
\x69\x6e\x64\x6f\x77\x73\x20\x50\x6c\x61\x74\x66\x6f\x72\x6d\x73\
\x0d\x0a\x20\x2a\x20\x4e\x6f\x74\x65\x3a\x20\x41\x6c\x77\x61\x79\
\x73\x20\x75\x73\x65\x20\x43\x53\x53\x2d\x63\x6c\x61\x73\x73\x65\
\x73\x20\x77\x69\x74\x68\x20\x61\x6e\x64\x20\x77\x69\x74\x68\x6f\
\x75\x74\x20\x22\x61\x64\x73\x2d\x2d\x22\x20\x6e\x61\x6d\x65\x73\
\x70\x61\x63\x65\x20\x74\x6f\x20\x73\x75\x70\x70\x6f\x72\x74\x20\
\x51\x74\x34\x20\x26\x20\x51\x74\x35\x0d\x0a\x20\x2a\x2f\x0d\x0a\
\x0d\x0a\x61\x64\x73\x2d\x2d\x43\x44\x6f\x63\x6b\x43\x6f\x6e\x74\
\x61\x69\x6e\x65\x72\x57\x69\x64\x67\x65\x74\x0d\x0a\x7b\x0d\x0a\
\x20\x20\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\x64\x3a\x20\
\x70\x61\x6c\x65\x74\x74\x65\x28\x64\x61\x72\x6b\x29\x3b\x0d\x0a\
\x7d\x0d\x0a\x0d\x0a\x61\x64\x73\x2d\x2d\x43\x44\x6f\x63\x6b\x43\
\x6f\x6e\x74\x61\x69\x6e\x65\x72\x57\x69\x64\x67\x65\x74\x20\x51\
\x53\x70\x6c\x69\x74\x74\x65\x72\x3a\x3a\x68\x61\x6e\x64\x6c\x65\
\x0d\x0a\x7b\x0d\x0a\x20\x20\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\
\x75\x6e\x64\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x64\x61\x72\
\x6b\x29\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x61\x64\x73\x2d\x2d\x43\
\x44\x6f\x63\x6b\x41\x72\x65\x61\x57\x69\x64\x67\x65\x74\x0d\x0a\
\x7b\x0d\x0a\x20\x20\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\
\x64\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x77\x69\x6e\x64\x6f\
\x77\x29\x3b\x0d\x0a\x20\x20\x20\x20\x62\x6f\x72\x64\x65\x72\x3a\
\x20\x31\x70\x78\x20\x73\x6f\x6c\x69\x64\x20\x77\x68\x69\x74\x65\
\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x61\x64\x73\x2d\x2d\x43\x44\x6f\
\x63\x6b\x41\x72\x65\x61\x57\x69\x64\x67\x65\x74\x20\x23\x74\x61\
\x62\x73\x4d\x65\x6e\x75\x42\x75\x74\x74\x6f\x6e\x3a\x3a\x6d\x65\
\x6e\x75\x2d\x69\x6e\x64\x69\x63\x61\x74\x6f\x72\x0d\x0a\x7b\x0d\
\x0a\x20\x20\x20\x20\x69\x6d\x61\x67\x65\x3a\x20\x6e\x6f\x6e\x65\
\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x0d\x0a\x61\x64\x73\x2d\x2d\x43\
\x44\x6f\x63\x6b\x57\x69\x64\x67\x65\x74\x54\x61\x62\x0d\x0a\x7b\
\x0d\x0a\x20\x20\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\x64\
\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x77\x69\x6e\x64\x6f\x77\
\x29\x3b\x0d\x0a\x20\x20\x20\x20\x62\x6f\x72\x64\x65\x72\x2d\x63\
\x6f\x6c\x6f\x72\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x6c\x69\
\x67\x68\x74\x29\x3b\x0d\x0a\x20\x20\x20\x20\x62\x6f\x72\x64\x65\
\x72\x2d\x73\x74\x79\x6c\x65\x3a\x20\x73\x6f\x6c\x69\x64\x3b\x0d\
\x0a\x20\x20\x20\x20\x62\x6f\x72\x64\x65\x72\x2d\x77\x69\x64\x74\
\x68\x3a\x20\x30\x20\x31\x70\x78\x20\x30\x20\x30\x3b\x0d\x0a\x20\
\x20\x20\x20\x70\x61\x64\x64\x69\x6e\x67\x3a\x20\x30\x20\x30\x70\
\x78\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x61\x64\x73\x2d\x2d\x43\x44\
\x6f\x63\x6b\x57\x69\x64\x67\x65\x74\x54\x61\x62\x5b\x61\x63\x74\
\x69\x76\x65\x54\x61\x62\x3d\x22\x74\x72\x75\x65\x22\x5d\x0d\x0a\
\x7b\x0d\x0a\x20\x20\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\
\x64\x3a\x20\x71\x6c\x69\x6e\x65\x61\x72\x67\x72\x61\x64\x69\x65\
\x6e\x74\x28\x73\x70\x72\x65\x61\x64\x3a\x70\x61\x64\x2c\x20\x78\
\x31\x3a\x30\x2c\x20\x79\x31\x3a\x30\x2c\x20\x78\x32\x3a\x30\x2c\
\x20\x79\x32\x3a\x30\x2e\x35\x2c\x20\x73\x74\x6f\x70\x3a\x30\x20\
\x70\x61\x6c\x65\x74\x74\x65\x28\x77\x69\x6e\x64\x6f\x77\x29\x2c\
\x20\x73\x74\x6f\x70\x3a\x31\x20\x70\x61\x6c\x65\x74\x74\x65\x28\
\x6c\x69\x67\x68\x74\x29\x29\x3b\x0d\x0a\x20\x20\x20\x20\x2f\x2a\
\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\x64\x3a\x20\x70\x61\x6c\x65\
\x74\x74\x65\x28\x68\x69\x67\x68\x6c\x69\x67\x68\x74\x29\x3b\x2a\
\x2f\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x61\x64\x73\x2d\x2d\x43\x44\x6f\
\x63\x6b\x57\x69\x64\x67\x65\x74\x54\x61\x62\x20\x51\x4c\x61\x62\
\x65\x6c\x0d\x0a\x7b\x0d\x0a\x20\x20\x20\x20\x63\x6f\x6c\x6f\x72\
\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x64\x61\x72\x6b\x29\x3b\
\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x61\x64\x73\x2d\x2d\x43\x44\x6f\x63\
\x6b\x57\x69\x64\x67\x65\x74\x54\x61\x62\x5b\x61\x63\x74\x69\x76\
\x65\x54\x61\x62\x3d\x22\x74\x72\x75\x65\x22\x5d\x20\x51\x4c\x61\
\x62\x65\x6c\x0d\x0a\x7b\x0d\x0a\x20\x20\x20\x20\x63\x6f\x6c\x6f\
\x72\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x66\x6f\x72\x65\x67\
\x72\x6f\x75\x6e\x64\x29\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x61\x64\
\x73\x2d\x2d\x43\x44\x6f\x63\x6b\x57\x69\x64\x67\x65\x74\x0d\x0a\
\x7b\x0d\x0a\x20\x20\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\
\x64\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x6c\x69\x67\x68\x74\
\x29\x3b\x0d\x0a\x20\x20\x20\x20\x62\x6f\x72\x64\x65\x72\x2d\x63\
\x6f\x6c\x6f\x72\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x6c\x69\
\x67\x68\x74\x29\x3b\x0d\x0a\x20\x20\x20\x20\x62\x6f\x72\x64\x65\
\x72\x2d\x73\x74\x79\x6c\x65\x3a\x20\x73\x6f\x6c\x69\x64\x3b\x0d\
\x0a\x20\x20\x20\x20\x62\x6f\x72\x64\x65\x72\x2d\x77\x69\x64\x74\
\x68\x3a\x20\x31\x70\x78\x20\x30\x20\x30\x20\x30\x3b\x0d\x0a\x7d\
\x0d\x0a\x0d\x0a\x23\x74\x61\x62\x73\x4d\x65\x6e\x75\x42\x75\x74\
\x74\x6f\x6e\x2c\x0d\x0a\x23\x63\x6c\x6f\x73\x65\x42\x75\x74\x74\
\x6f\x6e\x2c\x0d\x0a\x23\x75\x6e\x64\x6f\x63\x6b\x42\x75\x74\x74\
\x6f\x6e\x0d\x0a\x7b\x0d\x0a\x09\x70\x61\x64\x64\x69\x6e\x67\x3a\
\x20\x30\x70\x78\x20\x2d\x32\x70\x78\x3b\x0d\x0a\x7d\x0d\x0a\x0d\
\x0a\x0d\x0a\x51\x53\x63\x72\x6f\x6c\x6c\x41\x72\x65\x61\x23\x64\
\x6f\x63\x6b\x57\x69\x64\x67\x65\x74\x53\x63\x72\x6f\x6c\x6c\x41\
\x72\x65\x61\x0d\x0a\x7b\x0d\x0a\x09\x70\x61\x64\x64\x69\x6e\x67\
\x3a\x20\x30\x70\x78\x3b\x0d\x0a\x09\x62\x6f\x72\x64\x65\x72\x3a\
\x20\x6e\x6f\x6e\x65\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x0d\x0a\x23\
\x74\x61\x62\x43\x6c\x6f\x73\x65\x42\x75\x74\x74\x6f\x6e\x0d\x0a\
\x7b\x0d\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x6d\x61\x72\x67\x69\
\x6e\x2d\x74\x6f\x70\x3a\x20\x32\x70\x78\x3b\x0d\x0a\x20\x20\x20\
\x20\x20\x20\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\x64\x3a\
\x20\x6e\x6f\x6e\x65\x3b\x0d\x0a\x20\x20\x20\x20\x20\x20\x20\x20\
\x62\x6f\x72\x64\x65\x72\x3a\x20\x6e\x6f\x6e\x65\x3b\x0d\x0a\x20\
\x20\x20\x20\x20\x20\x20\x20\x70\x61\x64\x64\x69\x6e\x67\x3a\x20\
\x30\x70\x78\x20\x2d\x32\x70\x78\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\
\x23\x74\x61\x62\x43\x6c\x6f\x73\x65\x42\x75\x74\x74\x6f\x6e\x3a\
\x68\x6f\x76\x65\x72\x0d\x0a\x7b\x0d\x0a\x20\x20\x20\x20\x20\x20\
\x20\x20\x62\x6f\x72\x64\x65\x72\x3a\x20\x31\x70\x78\x20\x73\x6f\
\x6c\x69\x64\x20\x72\x67\x62\x61\x28\x30\x2c\x20\x30\x2c\x20\x30\
\x2c\x20\x33\x32\x29\x3b\x0d\x0a\x20\x20\x20\x20\x20\x20\x20\x20\
\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\x64\x3a\x20\x72\x67\x62\x61\
\x28\x30\x2c\x20\x30\x2c\x20\x30\x2c\x20\x31\x36\x29\x3b\x0d\x0a\
\x7d\x0d\x0a\x0d\x0a\x23\x74\x61\x62\x43\x6c\x6f\x73\x65\x42\x75\
\x74\x74\x6f\x6e\x3a\x70\x72\x65\x73\x73\x65\x64\x0d\x0a\x7b\x0d\
\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\
\x75\x6e\x64\x3a\x20\x72\x67\x62\x61\x28\x30\x2c\x20\x30\x2c\x20\
\x30\x2c\x20\x33\x32\x29\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x0d\x0a\
\
\x00\x00\x06\x30\
\x0d\
\x0a\x2f\x2a\x0d\x0a\x20\x2a\x20\x44\x65\x66\x61\x75\x6c\x74\x20\
\x73\x74\x79\x6c\x65\x20\x73\x68\x65\x65\x74\x20\x6f\x6e\x20\x57\
\x69\x6e\x64\x6f\x77\x73\x20\x50\x6c\x61\x74\x66\x6f\x72\x6d\x73\
\x0d\x0a\x20\x2a\x20\x4e\x6f\x74\x65\x3a\x20\x41\x6c\x77\x61\x79\
\x73\x20\x75\x73\x65\x20\x43\x53\x53\x2d\x63\x6c\x61\x73\x73\x65\
\x73\x20\x77\x69\x74\x68\x20\x61\x6e\x64\x20\x77\x69\x74\x68\x6f\
\x75\x74\x20\x22\x61\x64\x73\x2d\x2d\x22\x20\x6e\x61\x6d\x65\x73\
\x70\x61\x63\x65\x20\x74\x6f\x20\x73\x75\x70\x70\x6f\x72\x74\x20\
\x51\x74\x34\x20\x26\x20\x51\x74\x35\x0d\x0a\x20\x2a\x2f\x0d\x0a\
\x0d\x0a\x61\x64\x73\x2d\x2d\x43\x44\x6f\x63\x6b\x43\x6f\x6e\x74\
\x61\x69\x6e\x65\x72\x57\x69\x64\x67\x65\x74\x0d\x0a\x7b\x0d\x0a\
\x20\x20\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\x64\x3a\x20\
\x70\x61\x6c\x65\x74\x74\x65\x28\x64\x61\x72\x6b\x29\x3b\x0d\x0a\
\x7d\x0d\x0a\x0d\x0a\x61\x64\x73\x2d\x2d\x43\x44\x6f\x63\x6b\x43\
\x6f\x6e\x74\x61\x69\x6e\x65\x72\x57\x69\x64\x67\x65\x74\x20\x51\
\x53\x70\x6c\x69\x74\x74\x65\x72\x3a\x3a\x68\x61\x6e\x64\x6c\x65\
\x0d\x0a\x7b\x0d\x0a\x20\x20\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\
\x75\x6e\x64\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x64\x61\x72\
\x6b\x29\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x61\x64\x73\x2d\x2d\x43\
\x44\x6f\x63\x6b\x41\x72\x65\x61\x57\x69\x64\x67\x65\x74\x0d\x0a\
\x7b\x0d\x0a\x20\x20\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\
\x64\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x77\x69\x6e\x64\x6f\
\x77\x29\x3b\x0d\x0a\x20\x20\x20\x20\x62\x6f\x72\x64\x65\x72\x3a\
\x20\x31\x70\x78\x20\x73\x6f\x6c\x69\x64\x20\x77\x68\x69\x74\x65\
\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x61\x64\x73\x2d\x2d\x43\x44\x6f\
\x63\x6b\x41\x72\x65\x61\x57\x69\x64\x67\x65\x74\x20\x23\x74\x61\
\x62\x73\x4d\x65\x6e\x75\x42\x75\x74\x74\x6f\x6e\x3a\x3a\x6d\x65\
\x6e\x75\x2d\x69\x6e\x64\x69\x63\x61\x74\x6f\x72\x0d\x0a\x7b\x0d\
\x0a\x20\x20\x20\x20\x69\x6d\x61\x67\x65\x3a\x20\x6e\x6f\x6e\x65\
\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x0d\x0a\x61\x64\x73\x2d\x2d\x43\
\x44\x6f\x63\x6b\x57\x69\x64\x67\x65\x74\x54\x61\x62\x0d\x0a\x7b\
\x0d\x0a\x20\x20\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\x64\
\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x77\x69\x6e\x64\x6f\x77\
\x29\x3b\x0d\x0a\x20\x20\x20\x20\x62\x6f\x72\x64\x65\x72\x2d\x63\
\x6f\x6c\x6f\x72\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x6c\x69\
\x67\x68\x74\x29\x3b\x0d\x0a\x20\x20\x20\x20\x62\x6f\x72\x64\x65\
\x72\x2d\x73\x74\x79\x6c\x65\x3a\x20\x73\x6f\x6c\x69\x64\x3b\x0d\
\x0a\x20\x20\x20\x20\x62\x6f\x72\x64\x65\x72\x2d\x77\x69\x64\x74\
\x68\x3a\x20\x30\x20\x31\x70\x78\x20\x30\x20\x30\x3b\x0d\x0a\x20\
\x20\x20\x20\x70\x61\x64\x64\x69\x6e\x67\x3a\x20\x30\x20\x30\x70\
\x78\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x61\x64\x73\x2d\x2d\x43\x44\
\x6f\x63\x6b\x57\x69\x64\x67\x65\x74\x54\x61\x62\x5b\x61\x63\x74\
\x69\x76\x65\x54\x61\x62\x3d\x22\x74\x72\x75\x65\x22\x5d\x0d\x0a\
\x7b\x0d\x0a\x20\x20\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\
\x64\x3a\x20\x71\x6c\x69\x6e\x65\x61\x72\x67\x72\x61\x64\x69\x65\
\x6e\x74\x28\x73\x70\x72\x65\x61\x64\x3a\x70\x61\x64\x2c\x20\x78\
\x31\x3a\x30\x2c\x20\x79\x31\x3a\x30\x2c\x20\x78\x32\x3a\x30\x2c\
\x20\x79\x32\x3a\x30\x2e\x35\x2c\x20\x73\x74\x6f\x70\x3a\x30\x20\
\x70\x61\x6c\x65\x74\x74\x65\x28\x77\x69\x6e\x64\x6f\x77\x29\x2c\
\x20\x73\x74\x6f\x70\x3a\x31\x20\x70\x61\x6c\x65\x74\x74\x65\x28\
\x6c\x69\x67\x68\x74\x29\x29\x3b\x0d\x0a\x20\x20\x20\x20\x2f\x2a\
\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\x64\x3a\x20\x70\x61\x6c\x65\
\x74\x74\x65\x28\x68\x69\x67\x68\x6c\x69\x67\x68\x74\x29\x3b\x2a\
\x2f\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x61\x64\x73\x2d\x2d\x43\x44\x6f\
\x63\x6b\x57\x69\x64\x67\x65\x74\x54\x61\x62\x20\x51\x4c\x61\x62\
\x65\x6c\x0d\x0a\x7b\x0d\x0a\x20\x20\x20\x20\x63\x6f\x6c\x6f\x72\
\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x64\x61\x72\x6b\x29\x3b\
\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x61\x64\x73\x2d\x2d\x43\x44\x6f\x63\
\x6b\x57\x69\x64\x67\x65\x74\x54\x61\x62\x5b\x61\x63\x74\x69\x76\
\x65\x54\x61\x62\x3d\x22\x74\x72\x75\x65\x22\x5d\x20\x51\x4c\x61\
\x62\x65\x6c\x0d\x0a\x7b\x0d\x0a\x20\x20\x20\x20\x63\x6f\x6c\x6f\
\x72\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x66\x6f\x72\x65\x67\
\x72\x6f\x75\x6e\x64\x29\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x61\x64\
\x73\x2d\x2d\x43\x44\x6f\x63\x6b\x57\x69\x64\x67\x65\x74\x0d\x0a\
\x7b\x0d\x0a\x20\x20\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\
\x64\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x6c\x69\x67\x68\x74\
\x29\x3b\x0d\x0a\x20\x20\x20\x20\x62\x6f\x72\x64\x65\x72\x2d\x63\
\x6f\x6c\x6f\x72\x3a\x20\x70\x61\x6c\x65\x74\x74\x65\x28\x6c\x69\
\x67\x68\x74\x29\x3b\x0d\x0a\x20\x20\x20\x20\x62\x6f\x72\x64\x65\
\x72\x2d\x73\x74\x79\x6c\x65\x3a\x20\x73\x6f\x6c\x69\x64\x3b\x0d\
\x0a\x20\x20\x20\x20\x62\x6f\x72\x64\x65\x72\x2d\x77\x69\x64\x74\
\x68\x3a\x20\x31\x70\x78\x20\x30\x20\x30\x20\x30\x3b\x0d\x0a\x7d\
\x0d\x0a\x0d\x0a\x23\x74\x61\x62\x73\x4d\x65\x6e\x75\x42\x75\x74\
\x74\x6f\x6e\x2c\x0d\x0a\x23\x63\x6c\x6f\x73\x65\x42\x75\x74\x74\
\x6f\x6e\x2c\x0d\x0a\x23\x75\x6e\x64\x6f\x63\x6b\x42\x75\x74\x74\
\x6f\x6e\x0d\x0a\x7b\x0d\x0a\x09\x70\x61\x64\x64\x69\x6e\x67\x3a\
\x20\x30\x70\x78\x20\x2d\x32\x70\x78\x3b\x0d\x0a\x7d\x0d\x0a\x0d\
\x0a\x0d\x0a\x51\x53\x63\x72\x6f\x6c\x6c\x41\x72\x65\x61\x23\x64\
\x6f\x63\x6b\x57\x69\x64\x67\x65\x74\x53\x63\x72\x6f\x6c\x6c\x41\
\x72\x65\x61\x0d\x0a\x7b\x0d\x0a\x09\x70\x61\x64\x64\x69\x6e\x67\
\x3a\x20\x30\x70\x78\x3b\x0d\x0a\x09\x62\x6f\x72\x64\x65\x72\x3a\
\x20\x6e\x6f\x6e\x65\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x0d\x0a\x23\
\x74\x61\x62\x43\x6c\x6f\x73\x65\x42\x75\x74\x74\x6f\x6e\x0d\x0a\
\x7b\x0d\x0a\x09\x6d\x61\x72\x67\x69\x6e\x2d\x74\x6f\x70\x3a\x20\
\x32\x70\x78\x3b\x0d\x0a\x09\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\
\x64\x3a\x20\x6e\x6f\x6e\x65\x3b\x0d\x0a\x09\x62\x6f\x72\x64\x65\
\x72\x3a\x20\x6e\x6f\x6e\x65\x3b\x0d\x0a\x09\x70\x61\x64\x64\x69\
\x6e\x67\x3a\x20\x30\x70\x78\x20\x2d\x32\x70\x78\x3b\x0d\x0a\x7d\
\x0d\x0a\x0d\x0a\x23\x74\x61\x62\x43\x6c\x6f\x73\x65\x42\x75\x74\
\x74\x6f\x6e\x3a\x68\x6f\x76\x65\x72\x0d\x0a\x7b\x0d\x0a\x09\x62\
\x6f\x72\x64\x65\x72\x3a\x20\x31\x70\x78\x20\x73\x6f\x6c\x69\x64\
\x20\x72\x67\x62\x61\x28\x30\x2c\x20\x30\x2c\x20\x30\x2c\x20\x33\
\x32\x29\x3b\x0d\x0a\x09\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\x64\
\x3a\x20\x72\x67\x62\x61\x28\x30\x2c\x20\x30\x2c\x20\x30\x2c\x20\
\x31\x36\x29\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x23\x74\x61\x62\x43\
\x6c\x6f\x73\x65\x42\x75\x74\x74\x6f\x6e\x3a\x70\x72\x65\x73\x73\
\x65\x64\x0d\x0a\x7b\x0d\x0a\x09\x62\x61\x63\x6b\x67\x72\x6f\x75\
\x6e\x64\x3a\x20\x72\x67\x62\x61\x28\x30\x2c\x20\x30\x2c\x20\x30\
\x2c\x20\x33\x32\x29\x3b\x0d\x0a\x7d\x0d\x0a\x0d\x0a\x0d\x0a\
"
qt_resource_name = b"\
\x00\x03\
\x00\x00\x67\xb3\
\x00\x61\
\x00\x64\x00\x73\
\x00\x0b\
\x0c\x6b\x3c\xf3\
\x00\x73\
\x00\x74\x00\x79\x00\x6c\x00\x65\x00\x73\x00\x68\x00\x65\x00\x65\x00\x74\x00\x73\
\x00\x06\
\x07\x03\x7d\xc3\
\x00\x69\
\x00\x6d\x00\x61\x00\x67\x00\x65\x00\x73\
\x00\x10\
\x08\x7c\xee\x07\
\x00\x63\
\x00\x6c\x00\x6f\x00\x73\x00\x65\x00\x2d\x00\x62\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x2e\x00\x73\x00\x76\x00\x67\
\x00\x19\
\x03\x4c\x6a\xc7\
\x00\x63\
\x00\x6c\x00\x6f\x00\x73\x00\x65\x00\x2d\x00\x62\x00\x75\x00\x74\x00\x74\x00\x6f\x00\x6e\x00\x2d\x00\x64\x00\x69\x00\x73\x00\x61\
\x00\x62\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x73\x00\x76\x00\x67\
\x00\x11\
\x0c\x15\xf2\x83\
\x00\x64\
\x00\x65\x00\x66\x00\x61\x00\x75\x00\x6c\x00\x74\x00\x5f\x00\x6c\x00\x69\x00\x6e\x00\x75\x00\x78\x00\x2e\x00\x63\x00\x73\x00\x73\
\
\x00\x0b\
\x0c\xe2\x33\xa3\
\x00\x64\
\x00\x65\x00\x66\x00\x61\x00\x75\x00\x6c\x00\x74\x00\x2e\x00\x63\x00\x73\x00\x73\
"
qt_resource_struct_v1 = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x02\
\x00\x00\x00\x28\x00\x02\x00\x00\x00\x02\x00\x00\x00\x06\
\x00\x00\x00\x0c\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04\
\x00\x00\x00\x98\x00\x00\x00\x00\x00\x01\x00\x00\x17\x03\
\x00\x00\x00\xc0\x00\x00\x00\x00\x00\x01\x00\x00\x1d\x68\
\x00\x00\x00\x60\x00\x00\x00\x00\x00\x01\x00\x00\x0b\x08\
\x00\x00\x00\x3a\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
"
qt_resource_struct_v2 = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x02\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x28\x00\x02\x00\x00\x00\x02\x00\x00\x00\x06\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x0c\x00\x02\x00\x00\x00\x02\x00\x00\x00\x04\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x98\x00\x00\x00\x00\x00\x01\x00\x00\x17\x03\
\x00\x00\x01\x6d\xaf\xb0\x91\x61\
\x00\x00\x00\xc0\x00\x00\x00\x00\x00\x01\x00\x00\x1d\x68\
\x00\x00\x01\x6d\xaf\xb0\x91\x60\
\x00\x00\x00\x60\x00\x00\x00\x00\x00\x01\x00\x00\x0b\x08\
\x00\x00\x01\x6d\xaf\xb0\x91\x5e\
\x00\x00\x00\x3a\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\x6d\xaf\xb0\x91\x5e\
"
qt_version = QtCore.qVersion().split('.')
if qt_version < ['5', '8', '0']:
rcc_version = 1
qt_resource_struct = qt_resource_struct_v1
else:
rcc_version = 2
qt_resource_struct = qt_resource_struct_v2
def qInitResources():
QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)
def qCleanupResources():
QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)
qInitResources()

136
README.md
View File

@@ -1,13 +1,15 @@
# Advanced Docking System for Qt # Advanced Docking System for Qt
[![Build Status](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System.svg?branch=master)](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System) [![Build Status](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System.svg?branch=master)](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System)
[![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) [![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)
[![License: LGPL v2.1](https://img.shields.io/badge/License-LGPL%20v2.1-blue.svg)](gnu-lgpl-v2.1.md) [![License: LGPL v2.1](https://img.shields.io/badge/License-LGPL%20v2.1-blue.svg)](gnu-lgpl-v2.1.md)
Qt Advanced Docking System lets you create customizable layouts using a full Qt Advanced Docking System lets you create customizable layouts using a full
featured window docking system similar to what is found in many popular featured window docking system similar to what is found in many popular
integrated development environements (IDEs) such as Visual Studio. integrated development environments (IDEs) such as Visual Studio.
[![Video Advanced Docking](doc/advanced-docking_video.png)](https://www.youtube.com/watch?v=7pdNfafg3Qc)
Everything is implemented with standard Qt functionality without any Everything is implemented with standard Qt functionality without any
platform specific code. Basic usage of QWidgets and QLayouts and using basic platform specific code. Basic usage of QWidgets and QLayouts and using basic
styles as much as possible. styles as much as possible.
@@ -18,12 +20,37 @@ from Manuel Freiholz. I did an almost complete rewrite of his code to improve
code quality, readibility and to fix all issues from the issue tracker code quality, readibility and to fix all issues from the issue tracker
of his docking system project. of his docking system project.
The following video gives a first impression what is possible with the Advanced Docking System for Qt.
[![Video Advanced Docking](doc/advanced-docking_video.png)](https://www.youtube.com/watch?v=7pdNfafg3Qc)
## Features ## Features
### Overview
- [Advanced Docking System for Qt](#advanced-docking-system-for-qt)
- [Features](#features)
- [Overview](#overview)
- [Docking everywhere - no central widget](#docking-everywhere---no-central-widget)
- [Docking inside floating windows](#docking-inside-floating-windows)
- [Grouped dragging](#grouped-dragging)
- [Perspectives for fast switching of the complete main window layout](#perspectives-for-fast-switching-of-the-complete-main-window-layout)
- [Opaque and non-opaque splitter resizing](#opaque-and-non-opaque-splitter-resizing)
- [Opaque and non-opaque undocking](#opaque-and-non-opaque-undocking)
- [Tab-menu for easy handling of many tabbed dock widgets](#tab-menu-for-easy-handling-of-many-tabbed-dock-widgets)
- [Many different ways to detach dock widgets](#many-different-ways-to-detach-dock-widgets)
- [Supports deletion of dynamically created dock widgets](#supports-deletion-of-dynamically-created-dock-widgets)
- [Tested Compatible Environments](#tested-compatible-environments)
- [Windows](#windows)
- [macOS](#macos)
- [Linux](#linux)
- [Build](#build)
- [Getting started / Example](#getting-started--example)
- [Developers](#developers)
- [License information](#license-information)
- [Alternative Docking System Implementations](#alternative-docking-system-implementations)
- [KDDockWidgets](#kddockwidgets)
- [QtitanDocking](#qtitandocking)
- [Donation](#donation)
### Docking everywhere - no central widget ### Docking everywhere - no central widget
There is no central widget like in the Qt docking system. You can dock on every There is no central widget like in the Qt docking system. You can dock on every
border of the main window or you can dock into each dock area - so you are border of the main window or you can dock into each dock area - so you are
free to dock almost everywhere. free to dock almost everywhere.
@@ -33,6 +60,7 @@ free to dock almost everywhere.
![Dropping widgets](doc/preview-dragndrop_dark.png) ![Dropping widgets](doc/preview-dragndrop_dark.png)
### Docking inside floating windows ### Docking inside floating windows
There is no difference between the main window and a floating window. Docking There is no difference between the main window and a floating window. Docking
into floating windows is supported. into floating windows is supported.
@@ -41,48 +69,102 @@ into floating windows is supported.
![Docking inside floating windows](doc/floating-widget-dragndrop_dark.png) ![Docking inside floating windows](doc/floating-widget-dragndrop_dark.png)
### Grouped dragging ### Grouped dragging
When dragging the titlebar of a dock, all the tabs that are tabbed with it are When dragging the titlebar of a dock, all the tabs that are tabbed with it are
going to be dragged. So you can move complete groups of tabbed widgets into going to be dragged. So you can move complete groups of tabbed widgets into
a floating widget or from one dock area to another one. a floating widget or from one dock area to another one.
![Grouped dragging](doc/grouped-dragging.png)\ ![Grouped dragging](doc/grouped-dragging.gif)\
\ \
![Grouped dragging](doc/grouped-dragging_dark.png) ![Grouped dragging](doc/grouped-dragging_dark.png)
### Perspectives for fast switching of the complete main window layout ### Perspectives for fast switching of the complete main window layout
A perspective defines the set and layout of dock windows in the main A perspective defines the set and layout of dock windows in the main
window. You can save the current layout of the dockmanager into a named window. You can save the current layout of the dockmanager into a named
perspective to make your own custom perspective. Later you can simply perspective to make your own custom perspective. Later you can simply
select a perspective from the perspective list to quickly switch the complete select a perspective from the perspective list to quickly switch the complete
main window layout. main window layout.
![Perspective](doc/perspectives.png)\ ![Perspective](doc/perspectives.gif)\
\ \
![Perspective](doc/perspectives_dark.png) ![Perspective](doc/perspectives_dark.png)
### Opaque and non-opaque splitter resizing
The advanced docking system uses standard QSplitters as resize separators and thus supports opaque and non-opaque resizing functionality of QSplitter. In some rare cases, for very complex widgets or on slow machines resizing via separator on the fly may cause flicking and glaring of rendered content inside a widget. The global dock manager flag `OpaqueSplitterResize` configures the resizing behaviour of the splitters. If this flag is set, then widgets are resized dynamically (opaquely) while interactively moving the splitters.
![Opaque resizing](doc/opaque_resizing.gif)
If this flag is cleared, the widget resizing is deferred until the mouse button is released - this is some kind of lazy resizing separator.
![Non-opaque resizing](doc/non_opaque_resizing.gif)
### Opaque and non-opaque undocking
By default, opaque undocking is active. That means, as soon as you drag a dock widget or a dock area with a number of dock widgets it will be undocked and moved into a floating widget and then the floating widget will be dragged around. That means undocking will take place immediatelly. You can compare this with opaque splitter resizing. If the flag `OpaqueUndocking` is cleared, then non-opaque undocking is active. In this mode, undocking is more like a standard drag and drop operation. That means, the dragged dock widget or dock area is not undocked immediatelly. Instead, a drag preview widget is created and dragged around to indicate the future position of the dock widget or dock area. The actual dock operation is only executed when the mouse button is released. That makes it possible, to cancel an active drag operation with the escape key.
The drag preview widget can be configured by a number of global dock manager flags:
- `DragPreviewIsDynamic`: if this flag is enabled, the preview will be adjusted dynamically to the drop area
- `DragPreviewShowsContentPixmap`: the created drag preview window shows a static copy of the content of the dock widget / dock are that is dragged
- `DragPreviewHasWindowFrame`: this flag configures if the drag preview is frameless like a QRubberBand or looks like a real window
The best way to test non-opaque undocking is to set the standard flags: `CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig)`.
### Tab-menu for easy handling of many tabbed dock widgets
Tabs are a good way to quickly switch between dockwidgets in a dockarea. However, if the number of dockwidgets in a dockarea is too large, this may affect the usability of the tab bar. To keep track in this situation, you can use the tab menu. The menu allows you to quickly select the dockwidget you want to activate from a drop down menu.
![Tab menu](doc/tab_menu.gif)
### Many different ways to detach dock widgets
You can detach dock widgets and also dock areas in the following ways:
- by dragging the dock widget tab or the dock area title bar
- by double clicking the tab or title bar
- by using the detach menu entry from the tab and title bar drop down menu
### Supports deletion of dynamically created dock widgets
Normally clicking the close button of a dock widget will just hide the widget and the user can show it again using the toggleView() action of the dock widget. This is meant for user interfaces with a static amount of widgets. But the advanced docking system also supports dynamic dock widgets that will get deleted on close. If you set the dock widget flag `DockWidgetDeleteOnClose` for a certain dock widget, then it will be deleted as soon as you close this dock widget. This enables the implementation of user interfaces with dynamically created editors, like in word processing applications or source code development tools.
## Tested Compatible Environments ## Tested Compatible Environments
### Windows ### Windows
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) 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)
The library was developed on and for Windows. It is used in a commercial Windows application and is therefore constantly tested. The library was developed on and for Windows. It is used in a commercial Windows application and is therefore constantly tested.
### macOS ### macOS
macOS [![Build Status](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System.svg?branch=master)](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System) macOS [![Build Status](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System.svg?branch=master)](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System)
The application can be compiled for macOS. A user reported, that the library works on macOS. If have not tested it. The application can be compiled for macOS. A user reported, that the library works on macOS. If have not tested it.
![Advanced Docking on macOS](doc/macos.png)
### Linux ### Linux
Ubuntu [![Build Status](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System.svg?branch=master)](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System) Ubuntu [![Build Status](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System.svg?branch=master)](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System)
[![Build status](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/workflows/linux-builds/badge.svg)](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/actions?query=workflow%3Alinux-builds)
The application can be compiled for Linux and has been developed and tested with **Kubuntu 18.04**. The application can be compiled for Linux and has been developed and tested with **Kubuntu 18.04** and **Kubuntu 19.10**.
![Advanced Docking on Linux](doc/linux_kubuntu_1804.png) ![Advanced Docking on Kubuntu Linux](doc/linux_kubuntu_1804.png)
and with **Ubuntu 19.10**
![Advanced Docking on Ubuntu Linux](doc/linux_ubuntu_1910.png)
## Build ## Build
Open the `ads.pro` with QtCreator and start the build, that's it. Open the `ads.pro` with QtCreator and start the build, that's it.
You can run the demo project and test it yourself. You can run the demo project and test it yourself.
## Getting started / Example ## Getting started / Example
The following example shows the minimum code required to use the advanced Qt docking system. The following example shows the minimum code required to use the advanced Qt docking system.
*MainWindow.h* *MainWindow.h*
@@ -110,7 +192,9 @@ private:
ads::CDockManager* m_DockManager; ads::CDockManager* m_DockManager;
}; };
``` ```
*MainWindow.cpp* *MainWindow.cpp*
```cpp ```cpp
#include "MainWindow.h" #include "MainWindow.h"
#include "ui_MainWindow.h" #include "ui_MainWindow.h"
@@ -154,10 +238,38 @@ MainWindow::~MainWindow()
``` ```
## Developers ## Developers
- Uwe Kindler, Project Maintainer - Uwe Kindler, Project Maintainer
- Manuel Freiholz - Manuel Freiholz
## License information ## License information
[![License: LGPL v2.1](https://img.shields.io/badge/License-LGPL%20v2.1-blue.svg)](gnu-lgpl-v2.1.md) [![License: LGPL v2.1](https://img.shields.io/badge/License-LGPL%20v2.1-blue.svg)](gnu-lgpl-v2.1.md)
This project uses the [LGPLv2.1 license](gnu-lgpl-v2.1.md) This project uses the [LGPLv2.1 license](gnu-lgpl-v2.1.md)
## Alternative Docking System Implementations
If this Qt Advanced Docking System does not fit to your needs you may consider some of the alternative docking system solutions for Qt.
### KDDockWidgets
This is an advanced docking framework for Qt from [KDAB](https://www.kdab.com/). The interesting thing is, that they separated GUI code from logic, so they can easily provide a QtQuick backend in the future.
- [Blog post about KDDockWidgets](https://www.kdab.com/kddockwidgets/)
- [GitHub project](https://github.com/KDAB/KDDockWidgets)
### QtitanDocking
This is a commercial component from [Developer Machines](https://www.devmachines.com/) for Qt Framework that allows to create a Microsoft like dockable user interface. They also offer a lot of other interesting and useful components for Qt.
- [Product page](https://www.devmachines.com/qtitandocking-overview.html)
## Donation
If this project help you reduce time to develop or if you just like it, you can give me a cup of coffee :coffee::wink:.
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=85R64TMMSY9T6">
<img src="doc/donate.png" alt="Donate with PayPal" width="160"/>
</a>

View File

@@ -19,11 +19,18 @@ set(ads_demo_COMPILE_DEFINE ${ads_demo_COMPILE_DEFINE} ${Qt5Gui_COMPILE_DEFINITI
set(ads_demo_LIBS ${ads_demo_LIBS} ${Qt5Widgets_LIBRARIES}) set(ads_demo_LIBS ${ads_demo_LIBS} ${Qt5Widgets_LIBRARIES})
set(ads_demo_INCLUDE ${ads_demo_INCLUDE} ${Qt5Widgets_INCLUDE_DIRS}) set(ads_demo_INCLUDE ${ads_demo_INCLUDE} ${Qt5Widgets_INCLUDE_DIRS})
set(ads_demo_COMPILE_DEFINE ${ads_demo_COMPILE_DEFINE} ${Qt5Widgets_COMPILE_DEFINITIONS}) set(ads_demo_COMPILE_DEFINE ${ads_demo_COMPILE_DEFINE} ${Qt5Widgets_COMPILE_DEFINITIONS})
if(WIN32)
find_package(Qt5AxContainer ${REQUIRED_QT_VERSION} REQUIRED)
set(ads_demo_LIBS ${ads_demo_LIBS} ${Qt5AxContainer_LIBRARIES})
set(ads_demo_INCLUDE ${ads_demo_INCLUDE} ${Qt5AxContainer_INCLUDE_DIRS})
set(ads_demo_COMPILE_DEFINE ${ads_demo_COMPILE_DEFINE} ${Qt5AxContainer_COMPILE_DEFINITIONS})
endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(ads_demo_SRCS set(ads_demo_SRCS
main.cpp main.cpp
MainWindow.cpp MainWindow.cpp
mainwindow.ui mainwindow.ui
demo.qrc
) )
add_executable(AdvancedDockingSystemDemo WIN32 ${ads_demo_SRCS}) add_executable(AdvancedDockingSystemDemo WIN32 ${ads_demo_SRCS})
if(BUILD_STATIC) if(BUILD_STATIC)

View File

@@ -50,6 +50,19 @@
#include <QWidgetAction> #include <QWidgetAction>
#include <QComboBox> #include <QComboBox>
#include <QInputDialog> #include <QInputDialog>
#include <QRubberBand>
#include <QPlainTextEdit>
#include <QTableWidget>
#include <QScreen>
#include <QStyle>
#include <QMessageBox>
#include <QMenu>
#include <QToolButton>
#ifdef Q_OS_WIN
#include <QAxWidget>
#endif
#include <QMap> #include <QMap>
#include <QElapsedTimer> #include <QElapsedTimer>
@@ -57,6 +70,9 @@
#include "DockManager.h" #include "DockManager.h"
#include "DockWidget.h" #include "DockWidget.h"
#include "DockAreaWidget.h" #include "DockAreaWidget.h"
#include "DockAreaTitleBar.h"
#include "DockAreaTabBar.h"
#include "FloatingDockContainer.h"
//============================================================================ //============================================================================
@@ -113,6 +129,18 @@ static void appendFeaturStringToWindowTitle(ads::CDockWidget* DockWidget)
+ QString(" (%1)").arg(featuresString(DockWidget))); + QString(" (%1)").arg(featuresString(DockWidget)));
} }
/**
* Helper function to create an SVG icon
*/
static QIcon svgIcon(const QString& File)
{
// This is a workaround, because in item views SVG icons are not
// properly scaled an look blurry or pixelate
QIcon SvgIcon(File);
SvgIcon.addPixmap(SvgIcon.pixmap(92));
return SvgIcon;
}
//============================================================================ //============================================================================
static ads::CDockWidget* createCalendarDockWidget(QMenu* ViewMenu) static ads::CDockWidget* createCalendarDockWidget(QMenu* ViewMenu)
@@ -122,6 +150,7 @@ static ads::CDockWidget* createCalendarDockWidget(QMenu* ViewMenu)
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Calendar %1").arg(CalendarCount++)); ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Calendar %1").arg(CalendarCount++));
DockWidget->setWidget(w); DockWidget->setWidget(w);
DockWidget->setToggleViewActionMode(ads::CDockWidget::ActionModeShow); DockWidget->setToggleViewActionMode(ads::CDockWidget::ActionModeShow);
DockWidget->setIcon(svgIcon(":/adsdemo/images/date_range.svg"));
ViewMenu->addAction(DockWidget->toggleViewAction()); ViewMenu->addAction(DockWidget->toggleViewAction());
return DockWidget; return DockWidget;
} }
@@ -143,6 +172,74 @@ static ads::CDockWidget* createFileSystemTreeDockWidget(QMenu* ViewMenu)
return DockWidget; return DockWidget;
} }
//============================================================================
static ads::CDockWidget* createEditorWidget(QMenu* ViewMenu)
{
static int EditorCount = 0;
QPlainTextEdit* w = new QPlainTextEdit();
w->setPlaceholderText("This is an editor. If you close the editor, it will be "
"deleted. Enter your text here.");
w->setStyleSheet("border: none");
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Editor %1").arg(EditorCount++));
DockWidget->setWidget(w);
DockWidget->setIcon(svgIcon(":/adsdemo/images/edit.svg"));
DockWidget->setFeature(ads::CDockWidget::CustomCloseHandling, true);
ViewMenu->addAction(DockWidget->toggleViewAction());
QMenu* OptionsMenu = new QMenu(DockWidget);
OptionsMenu->setTitle(QObject::tr("Options"));
OptionsMenu->setToolTip(OptionsMenu->title());
OptionsMenu->setIcon(svgIcon(":/adsdemo/images/custom-menu-button.svg"));
auto MenuAction = OptionsMenu->menuAction();
// The object name of the action will be set for the QToolButton that
// is created in the dock area title bar. You can use this name for CSS
// styling
MenuAction->setObjectName("optionsMenu");
DockWidget->setTitleBarActions({OptionsMenu->menuAction()});
auto a = OptionsMenu->addAction(QObject::tr("Clear Editor"));
w->connect(a, SIGNAL(triggered()), SLOT(clear()));
return DockWidget;
}
//============================================================================
static ads::CDockWidget* createTableWidget(QMenu* ViewMenu)
{
static int TableCount = 0;
QTableWidget* w = new QTableWidget();
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Table %1").arg(TableCount++));
static int colCount = 5;
static int rowCount = 30;
w->setColumnCount(colCount);
w->setRowCount(rowCount);
for (int col = 0; col < colCount; ++col)
{
w->setHorizontalHeaderItem(col, new QTableWidgetItem(QString("Col %1").arg(col+1)));
for (int row = 0; row < rowCount; ++row)
{
w->setItem(row, col, new QTableWidgetItem(QString("T %1-%2").arg(row + 1).arg(col+1)));
}
}
DockWidget->setWidget(w);
DockWidget->setIcon(svgIcon(":/adsdemo/images/grid_on.svg"));
ViewMenu->addAction(DockWidget->toggleViewAction());
return DockWidget;
}
#ifdef Q_OS_WIN
//============================================================================
static ads::CDockWidget* createActiveXWidget(QMenu* ViewMenu, QWidget* parent = nullptr)
{
static int ActiveXCount = 0;
QAxWidget* w = new QAxWidget("{6bf52a52-394a-11d3-b153-00c04f79faa6}", parent);
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Active X %1").arg(ActiveXCount++));
DockWidget->setWidget(w);
ViewMenu->addAction(DockWidget->toggleViewAction());
return DockWidget;
}
#endif
//============================================================================ //============================================================================
/** /**
@@ -190,16 +287,23 @@ struct MainWindowPrivate
void restorePerspectives(); void restorePerspectives();
}; };
//============================================================================ //============================================================================
void MainWindowPrivate::createContent() void MainWindowPrivate::createContent()
{ {
// Test container docking // Test container docking
QMenu* ViewMenu = ui.menuView; QMenu* ViewMenu = ui.menuView;
auto DockWidget = createCalendarDockWidget(ViewMenu); auto DockWidget = createCalendarDockWidget(ViewMenu);
DockWidget->setIcon(_this->style()->standardIcon(QStyle::SP_DialogOpenButton));
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false); DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget); DockWidget->setFeature(ads::CDockWidget::DockWidgetMovable, false);
DockWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
auto SpecialDockArea = DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
// For this Special Dock Area we want to avoid dropping on the center of it (i.e. we don't want this widget to be ever tabbified):
{
SpecialDockArea->setAllowedAreas(ads::OuterDockAreas);
//SpecialDockArea->setAllowedAreas({ads::LeftDockWidgetArea, ads::RightDockWidgetArea}); // just for testing
}
DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu)); DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu));
auto FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu); auto FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu);
auto ToolBar = FileSystemWidget->createDefaultToolBar(); auto ToolBar = FileSystemWidget->createDefaultToolBar();
@@ -215,23 +319,54 @@ void MainWindowPrivate::createContent()
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false); FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
appendFeaturStringToWindowTitle(FileSystemWidget); appendFeaturStringToWindowTitle(FileSystemWidget);
auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget); auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget);
// We create a calender widget and clear all flags to prevent the dock area
// from closing
DockWidget = createCalendarDockWidget(ViewMenu); DockWidget = createCalendarDockWidget(ViewMenu);
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false); DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
DockWidget->setFeature(ads::CDockWidget::DockWidgetMovable, false);
DockWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
DockWidget->setTabToolTip(QString("Tab ToolTip\nHodie est dies magna")); DockWidget->setTabToolTip(QString("Tab ToolTip\nHodie est dies magna"));
DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea); auto DockArea = DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
// Now we add a custom button to the dock area title bar that will create
// new editor widgets when clicked
auto CustomButton = new QToolButton(DockArea);
CustomButton->setToolTip(QObject::tr("Create Editor"));
CustomButton->setIcon(svgIcon(":/adsdemo/images/plus.svg"));
CustomButton->setAutoRaise(true);
auto TitleBar = DockArea->titleBar();
int Index = TitleBar->indexOf(TitleBar->tabBar());
TitleBar->insertWidget(Index + 1, CustomButton);
QObject::connect(CustomButton, &QToolButton::clicked, [=]()
{
auto DockWidget = createEditorWidget(ui.menuView);
DockWidget->setFeature(ads::CDockWidget::DockWidgetDeleteOnClose, true);
DockManager->addDockWidgetTabToArea(DockWidget, DockArea);
_this->connect(DockWidget, SIGNAL(closeRequested()), SLOT(onEditorCloseRequested()));
});
// Test dock area docking // Test dock area docking
auto RighDockArea = DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), TopDockArea); auto RighDockArea = DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), TopDockArea);
DockManager->addDockWidget(ads::TopDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea); DockManager->addDockWidget(ads::TopDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea); auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea); DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea); DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
//DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
//DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea); auto Action = ui.menuView->addAction(QString("Set %1 floating").arg(DockWidget->windowTitle()));
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(setFloating()));
#ifdef Q_OS_WIN
if (!DockManager->configFlags().testFlag(ads::CDockManager::OpaqueUndocking))
{
DockManager->addDockWidget(ads::CenterDockWidgetArea, createActiveXWidget(ViewMenu), RighDockArea);
}
#endif
for (auto DockWidget : DockManager->dockWidgetsMap()) for (auto DockWidget : DockManager->dockWidgetsMap())
{ {
_this->connect(DockWidget, SIGNAL(viewToggled(bool)), SLOT(onViewToggled(bool))); _this->connect(DockWidget, SIGNAL(viewToggled(bool)), SLOT(onViewToggled(bool)));
_this->connect(DockWidget, SIGNAL(visibilityChanged(bool)), SLOT(onViewVisibilityChanged(bool)));
} }
} }
@@ -240,11 +375,13 @@ void MainWindowPrivate::createContent()
void MainWindowPrivate::createActions() void MainWindowPrivate::createActions()
{ {
ui.toolBar->addAction(ui.actionSaveState); ui.toolBar->addAction(ui.actionSaveState);
ui.actionSaveState->setIcon(_this->style()->standardIcon(QStyle::SP_DialogSaveButton)); ui.toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui.actionSaveState->setIcon(svgIcon(":/adsdemo/images/save.svg"));
ui.toolBar->addAction(ui.actionRestoreState); ui.toolBar->addAction(ui.actionRestoreState);
ui.actionRestoreState->setIcon(_this->style()->standardIcon(QStyle::SP_DialogOpenButton)); ui.actionRestoreState->setIcon(svgIcon(":/adsdemo/images/restore.svg"));
SavePerspectiveAction = new QAction("Save Perspective", _this); SavePerspectiveAction = new QAction("Create Perspective", _this);
SavePerspectiveAction->setIcon(svgIcon(":/adsdemo/images/picture_in_picture.svg"));
_this->connect(SavePerspectiveAction, SIGNAL(triggered()), SLOT(savePerspective())); _this->connect(SavePerspectiveAction, SIGNAL(triggered()), SLOT(savePerspective()));
PerspectiveListAction = new QWidgetAction(_this); PerspectiveListAction = new QWidgetAction(_this);
PerspectiveComboBox = new QComboBox(_this); PerspectiveComboBox = new QComboBox(_this);
@@ -254,6 +391,16 @@ void MainWindowPrivate::createActions()
ui.toolBar->addSeparator(); ui.toolBar->addSeparator();
ui.toolBar->addAction(PerspectiveListAction); ui.toolBar->addAction(PerspectiveListAction);
ui.toolBar->addAction(SavePerspectiveAction); ui.toolBar->addAction(SavePerspectiveAction);
QAction* a = ui.toolBar->addAction("Create Editor");
a->setToolTip("Creates floating dynamic dockable editor windows that are deleted on close");
a->setIcon(svgIcon(":/adsdemo/images/note_add.svg"));
_this->connect(a, SIGNAL(triggered()), SLOT(createEditor()));
a = ui.toolBar->addAction("Create Table");
a->setToolTip("Creates floating dynamic dockable table with millions of entries");
a->setIcon(svgIcon(":/adsdemo/images/grid_on.svg"));
_this->connect(a, SIGNAL(triggered()), SLOT(createTable()));
} }
@@ -304,20 +451,40 @@ CMainWindow::CMainWindow(QWidget *parent) :
{ {
using namespace ads; using namespace ads;
d->ui.setupUi(this); d->ui.setupUi(this);
d->createActions(); d->createActions();
// uncomment the following line if the tab close button should be // uncomment the following line if the tab close button should be
// a QToolButton instead of a QPushButton // a QToolButton instead of a QPushButton
// CDockManager::setConfigFlags(CDockManager::configFlags() | CDockManager::TabCloseButtonIsToolButton); // CDockManager::setConfigFlags(CDockManager::configFlags() | CDockManager::TabCloseButtonIsToolButton);
// uncomment the following line if you wand a fixed tab width that does // comment the following line if you want to use opaque undocking and
// opaque splitter resizing
CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig);
// uncomment the following line if you want a fixed tab width that does
// not change if the visibility of the close button changes // not change if the visibility of the close button changes
// CDockManager::setConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden, true); //CDockManager::setConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden, true);
// uncomment the following line if you don't want close button on DockArea's title bar
//CDockManager::setConfigFlag(CDockManager::DockAreaHasCloseButton, false);
// uncomment the following line if you don't want undock button on DockArea's title bar
//CDockManager::setConfigFlag(CDockManager::DockAreaHasUndockButton, false);
// uncomment the following line if you don't want tabs menu button on DockArea's title bar
//CDockManager::setConfigFlag(CDockManager::DockAreaHasTabsMenuButton, false);
// uncomment the following line if you don't want disabled buttons to appear on DockArea's title bar
//CDockManager::setConfigFlag(CDockManager::DockAreaHideDisabledButtons, true);
// uncomment the following line if you want to show tabs menu button on DockArea's title bar only when there are more than one tab and at least of them has elided title
//CDockManager::setConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility, true);
// Now create the dock manager and its content // Now create the dock manager and its content
d->DockManager = new CDockManager(this); d->DockManager = new CDockManager(this);
// Uncomment the following line to have the old style where the dock // uncomment the following line to have the old style where the dock
// area close button closes the active tab // area close button closes the active tab
// CDockManager::setConfigFlags({CDockManager::DockAreaHasCloseButton // CDockManager::setConfigFlags({CDockManager::DockAreaHasCloseButton
// | CDockManager::DockAreaCloseButtonClosesTab}); // | CDockManager::DockAreaCloseButtonClosesTab});
@@ -325,10 +492,14 @@ CMainWindow::CMainWindow(QWidget *parent) :
d->DockManager, SLOT(openPerspective(const QString&))); d->DockManager, SLOT(openPerspective(const QString&)));
d->createContent(); d->createContent();
// Default window geometry // Default window geometry - center on screen
resize(1280, 720); resize(1280, 720);
setGeometry(QStyle::alignedRect(
Qt::LeftToRight, Qt::AlignCenter, frameSize(),
QGuiApplication::primaryScreen()->availableGeometry()
));
d->restoreState(); //d->restoreState();
d->restorePerspectives(); d->restorePerspectives();
} }
@@ -395,3 +566,51 @@ void CMainWindow::onViewToggled(bool Open)
qDebug() << DockWidget->objectName() << " viewToggled(" << Open << ")"; qDebug() << DockWidget->objectName() << " viewToggled(" << Open << ")";
} }
//============================================================================
void CMainWindow::onViewVisibilityChanged(bool Visible)
{
auto DockWidget = qobject_cast<ads::CDockWidget*>(sender());
if (!DockWidget)
{
return;
}
qDebug() << DockWidget->objectName() << " visibilityChanged(" << Visible << ")";
}
//============================================================================
void CMainWindow::createEditor()
{
auto DockWidget = createEditorWidget(d->ui.menuView);
DockWidget->setFeature(ads::CDockWidget::DockWidgetDeleteOnClose, true);
auto FloatingWidget = d->DockManager->addDockWidgetFloating(DockWidget);
FloatingWidget->move(QPoint(20, 20));
connect(DockWidget, SIGNAL(closeRequested()), SLOT(onEditorCloseRequested()));
}
//============================================================================
void CMainWindow::onEditorCloseRequested()
{
auto DockWidget = qobject_cast<ads::CDockWidget*>(sender());
int Result = QMessageBox::question(this, "Close Editor", QString("Editor %1 "
"contains unsaved changes? Would you like to close it?")
.arg(DockWidget->windowTitle()));
if (QMessageBox::Yes == Result)
{
DockWidget->closeDockWidget();
}
}
//============================================================================
void CMainWindow::createTable()
{
auto DockWidget = createTableWidget(d->ui.menuView);
DockWidget->setFeature(ads::CDockWidget::DockWidgetDeleteOnClose, true);
auto FloatingWidget = d->DockManager->addDockWidgetFloating(DockWidget);
FloatingWidget->move(QPoint(40, 40));
}

View File

@@ -59,6 +59,10 @@ private slots:
void on_actionRestoreState_triggered(bool); void on_actionRestoreState_triggered(bool);
void savePerspective(); void savePerspective();
void onViewToggled(bool Open); void onViewToggled(bool Open);
void onViewVisibilityChanged(bool Visible);
void createEditor();
void createTable();
void onEditorCloseRequested();
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

4
demo/app.css Normal file
View File

@@ -0,0 +1,4 @@
ads--CTitleBarButton::menu-indicator
{
image: none;
}

View File

@@ -3,6 +3,11 @@ ADS_OUT_ROOT = $${OUT_PWD}/..
TARGET = AdvancedDockingSystemDemo TARGET = AdvancedDockingSystemDemo
DESTDIR = $${ADS_OUT_ROOT}/lib DESTDIR = $${ADS_OUT_ROOT}/lib
QT += core gui widgets QT += core gui widgets
win32 {
QT += axcontainer
}
CONFIG += c++14 CONFIG += c++14
CONFIG += debug_and_release CONFIG += debug_and_release
DEFINES += QT_DEPRECATED_WARNINGS DEFINES += QT_DEPRECATED_WARNINGS
@@ -20,6 +25,8 @@ HEADERS += \
FORMS += \ FORMS += \
mainwindow.ui mainwindow.ui
RESOURCES += demo.qrc
LIBS += -L$${ADS_OUT_ROOT}/lib LIBS += -L$${ADS_OUT_ROOT}/lib

16
demo/demo.qrc Normal file
View File

@@ -0,0 +1,16 @@
<RCC>
<qresource prefix="/adsdemo">
<file>images/folder.svg</file>
<file>images/folder_open.svg</file>
<file>images/note_add.svg</file>
<file>images/picture_in_picture.svg</file>
<file>images/restore.svg</file>
<file>images/save.svg</file>
<file>images/date_range.svg</file>
<file>images/edit.svg</file>
<file>images/grid_on.svg</file>
<file>images/custom-menu-button.svg</file>
<file>app.css</file>
<file>images/plus.svg</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="16px" height="16px" viewBox="0 0 16 16" id="svg2" version="1.1" inkscape:version="0.91 r13725" sodipodi:docname="38 - menu bar lines option list hamburger web.svg">
<defs id="defs4">
<pattern y="0" x="0" height="6" width="6" patternUnits="userSpaceOnUse" id="EMFhbasepattern"/>
<pattern y="0" x="0" height="6" width="6" patternUnits="userSpaceOnUse" id="EMFhbasepattern-4"/>
<pattern y="0" x="0" height="6" width="6" patternUnits="userSpaceOnUse" id="EMFhbasepattern-3"/>
<pattern y="0" x="0" height="6" width="6" patternUnits="userSpaceOnUse" id="EMFhbasepattern-8"/>
</defs>
<sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="22.627417" inkscape:cx="6.2316889" inkscape:cy="7.4271635" inkscape:document-units="px" inkscape:current-layer="g5228" showgrid="true" units="px" inkscape:window-width="1366" inkscape:window-height="705" inkscape:window-x="-8" inkscape:window-y="-8" inkscape:window-maximized="1" inkscape:snap-bbox="true" inkscape:bbox-paths="true" inkscape:bbox-nodes="true" inkscape:snap-bbox-edge-midpoints="true" inkscape:snap-bbox-midpoints="true" inkscape:snap-global="true">
<inkscape:grid type="xygrid" id="grid3336"/>
</sodipodi:namedview>
<g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1" transform="translate(0,-1036.3622)">
<g transform="translate(628,-140.49998)" id="g5228">
<path style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" d="M 4.484375 4 A 0.50005 0.50005 0 0 0 4.5351562 5 L 11.464844 5 A 0.50005 0.50005 0 1 0 11.464844 4 L 4.5351562 4 A 0.50005 0.50005 0 0 0 4.484375 4 z M 4.484375 7 A 0.50005 0.50005 0 0 0 4.5351562 8 L 11.464844 8 A 0.50005 0.50005 0 1 0 11.464844 7 L 4.5351562 7 A 0.50005 0.50005 0 0 0 4.484375 7 z M 4.484375 10 A 0.50005 0.50005 0 0 0 4.5351562 11 L 11.464844 11 A 0.50005 0.50005 0 1 0 11.464844 10 L 4.5351562 10 A 0.50005 0.50005 0 0 0 4.484375 10 z " transform="translate(-628,1176.8622)" id="path3340"/>
</g>
</g>
<metadata>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description about="https://iconscout.com/legal#licenses" dc:title="Menu, Bar, Lines, Option, List, Hamburger, Web" dc:description="Menu, Bar, Lines, Option, List, Hamburger, Web" dc:publisher="Iconscout" dc:date="2016-12-14" dc:format="image/svg+xml" dc:language="en">
<dc:creator>
<rdf:Bag>
<rdf:li>Jemis Mali</rdf:li>
</rdf:Bag>
</dc:creator>
</rdf:Description>
</rdf:RDF>
</metadata></svg>

After

Width:  |  Height:  |  Size: 3.9 KiB

View 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>date_range 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="M896,256v597.33c0,46.93 -38.4,85.34 -85.33,85.34h-597.34c-47.36,0 -85.33,-38.41 -85.33,-85.34l0.43,-597.33c0,-46.93 37.54,-85.33 84.9,-85.33h42.67v-85.34h85.33v85.34h341.34v-85.34h85.33v85.34h42.67c46.93,0 85.33,38.4 85.33,85.33zM810.67,384h-597.34v469.33h597.34zM384,554.67h-85.33v-85.34h85.33zM554.67,554.67h-85.34v-85.34h85.34zM725.33,554.67h-85.33v-85.34h85.33z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 783 B

6
demo/images/edit.svg Normal file
View 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>create 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="M599.89,264.11l160,160l-471.89,471.89h-160v-160zM805.55,378.45l-160,-160l78.08,-78.08c16.64,-16.64 43.52,-16.64 60.16,0l99.84,99.84c16.64,16.64 16.64,43.52 0,60.16z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 578 B

6
demo/images/folder.svg Normal file
View 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>folder 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="M512,256h341.33c46.93,0 85.34,38.4 85.34,85.33v426.67c0,46.93 -38.41,85.33 -85.34,85.33h-682.66c-46.93,0 -85.34,-38.4 -85.34,-85.33l0.43,-512c0,-46.93 37.98,-85.33 84.91,-85.33h256z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 595 B

View 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>folder_open 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="M938.67,341.33v426.67c0,46.93 -38.41,85.33 -85.34,85.33h-682.66c-46.93,0 -85.34,-38.4 -85.34,-85.33l0.43,-512c0,-46.93 37.98,-85.33 84.91,-85.33h256l85.33,85.33h341.33c46.93,0 85.34,38.4 85.34,85.33zM853.33,341.33h-682.66v426.67h682.66z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 655 B

6
demo/images/grid_on.svg Normal file
View 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>grid_on 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="M938.67,170.67v682.66c0,46.93 -38.41,85.34 -85.34,85.34h-682.66c-46.93,0 -85.34,-38.41 -85.34,-85.34v-682.66c0,-46.93 38.41,-85.34 85.34,-85.34h682.66c46.93,0 85.34,38.41 85.34,85.34zM341.33,170.67h-170.66v170.66h170.66zM341.33,682.67h-170.66v170.66h170.66zM341.33,426.67h-170.66v170.66h170.66zM597.33,170.67h-170.66v170.66h170.66zM853.33,170.67h-170.66v170.66h170.66zM597.33,682.67h-170.66v170.66h170.66zM597.33,426.67h-170.66v170.66h170.66zM853.33,682.67h-170.66v170.66h170.66zM853.33,426.67h-170.66v170.66h170.66z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 931 B

View File

@@ -0,0 +1,211 @@
The Google Material icons and modifications can be used free of charge for
commerical and non-commerical projects according to the Apache License 2.0.
An attribution to https://material.io/icons/ and/or https://iconfu.com on
your website or in your app's "about" screen would be wonderful.
Please do not re-sell the icons.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

6
demo/images/note_add.svg Normal file
View 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>note_add 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="M853.33,341.33v512c0,46.93 -38.4,85.34 -85.33,85.34h-512.43c-46.93,0 -84.9,-38.41 -84.9,-85.34l0.42,-682.66c0,-46.93 37.98,-85.34 84.91,-85.34h341.33zM682.67,597.33h-128v-128h-85.34v128h-128v85.34h128v128h85.34v-128h128zM789.33,384l-234.66,-234.67v234.67z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 671 B

View 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>picture_in_picture 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,84.48 -85.33,84.48h-768c-46.93,0 -85.33,-37.55 -85.33,-84.48v-597.34c0,-46.93 38.4,-85.33 85.33,-85.33h768c46.93,0 85.33,38.4 85.33,85.33zM896,212.48h-768v598.61h768zM810.67,554.67h-341.34v-256h341.34z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 663 B

123
demo/images/plus.svg Normal file
View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16px"
height="16px"
viewBox="0 0 16 16"
id="svg2"
version="1.1"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
sodipodi:docname="plus.svg">
<defs
id="defs4">
<pattern
y="0"
x="0"
height="6"
width="6"
patternUnits="userSpaceOnUse"
id="EMFhbasepattern" />
<pattern
y="0"
x="0"
height="6"
width="6"
patternUnits="userSpaceOnUse"
id="EMFhbasepattern-4" />
<pattern
y="0"
x="0"
height="6"
width="6"
patternUnits="userSpaceOnUse"
id="EMFhbasepattern-3" />
<pattern
y="0"
x="0"
height="6"
width="6"
patternUnits="userSpaceOnUse"
id="EMFhbasepattern-8" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627417"
inkscape:cx="-2.5629517"
inkscape:cy="7.4271635"
inkscape:document-units="px"
inkscape:current-layer="g5228"
showgrid="true"
units="px"
inkscape:window-width="1920"
inkscape:window-height="1017"
inkscape:window-x="1912"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:snap-bbox="true"
inkscape:bbox-paths="true"
inkscape:bbox-nodes="true"
inkscape:snap-bbox-edge-midpoints="true"
inkscape:snap-bbox-midpoints="true"
inkscape:snap-global="true">
<inkscape:grid
type="xygrid"
id="grid3336" />
</sodipodi:namedview>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
<g
transform="translate(628,-140.49998)"
id="g5228">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m -620.5,1189.8622 v -11"
id="path822-5"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m -615,1184.3622 h -11"
id="path822-5-2"
inkscape:connector-curvature="0" />
</g>
</g>
<metadata
id="metadata12">
<rdf:RDF>
<rdf:Description
about="https://iconscout.com/legal#licenses"
dc:title="Menu, Bar, Lines, Option, List, Hamburger, Web"
dc:description="Menu, Bar, Lines, Option, List, Hamburger, Web"
dc:publisher="Iconscout"
dc:date="2016-12-14"
dc:format="image/svg+xml"
dc:language="en">
<dc:creator>
<rdf:Bag>
<rdf:li>Jemis Mali</rdf:li>
</rdf:Bag>
</dc:creator>
</rdf:Description>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
</svg>

After

Width:  |  Height:  |  Size: 3.6 KiB

6
demo/images/restore.svg Normal file
View 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>restore 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="M938.67,512c0,212.05 -171.95,384 -384,384c-106.24,0 -201.81,-43.09 -271.36,-112.64l60.58,-60.59c53.76,54.19 128.43,87.9 210.78,87.9c165.12,0 298.66,-133.55 298.66,-298.67c0,-165.12 -133.54,-298.67 -298.66,-298.67c-165.12,0 -298.67,133.55 -298.67,298.67h128l-172.37,171.95l-2.99,-5.98l-165.97,-165.97h128c0,-212.05 171.95,-384 384,-384c212.05,0 384,171.95 384,384zM576,341.33v181.34l149.33,88.74l-30.72,51.63l-182.61,-108.37v-213.34z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 847 B

6
demo/images/save.svg Normal file
View 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>save 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="M896,298.67v512c0,46.93 -38.4,85.33 -85.33,85.33h-597.34c-47.36,0 -85.33,-38.4 -85.33,-85.33v-597.34c0,-46.93 37.97,-85.33 85.33,-85.33h512zM640,213.33h-426.67v170.67h426.67zM640,682.67c0,-70.83 -57.17,-128 -128,-128c-70.83,0 -128,57.17 -128,128c0,70.83 57.17,128 128,128c70.83,0 128,-57.17 128,-128z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 712 B

View File

@@ -42,6 +42,13 @@ int main(int argc, char *argv[])
std::shared_ptr<int> b; std::shared_ptr<int> b;
QApplication a(argc, argv); QApplication a(argc, argv);
a.setQuitOnLastWindowClosed(true); a.setQuitOnLastWindowClosed(true);
QFile StyleSheetFile(":/adsdemo/app.css");
StyleSheetFile.open(QIODevice::ReadOnly);
QTextStream StyleSheetStream(&StyleSheetFile);
a.setStyleSheet(StyleSheetStream.readAll());
StyleSheetFile.close();
qInstallMessageHandler(myMessageOutput); qInstallMessageHandler(myMessageOutput);
qDebug() << "Message handler test"; qDebug() << "Message handler test";

123
doc/ads_icon.svg Normal file
View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
viewBox="0,0,1024,1024"
id="svg1145"
sodipodi:docname="ads_icon.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
inkscape:export-filename="C:\CodingXP\cetoni_projects\QtAdvancedDockingSystem\doc\ads_icon_256.png"
inkscape:export-xdpi="24"
inkscape:export-ydpi="24">
<metadata
id="metadata1151">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs1149" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1017"
id="namedview1147"
showgrid="false"
inkscape:zoom="0.32593202"
inkscape:cx="256.13402"
inkscape:cy="235.82602"
inkscape:window-x="1912"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="svg1145" />
<desc
id="desc1129">window_size icon - Licensed under Iconfu Standard License v1.0 (https://www.iconfu.com/iconfu_standard_license) - Incors GmbH</desc>
<path
id="path1797-1"
visibility="hidden"
d="M 71.53142,291.89723 H 950.1828 l 0.6743,0.6742 v 586.08 l -0.6743,0.6743 H 71.53142 l -0.6743,-0.6743 v -586.08 z"
inkscape:connector-curvature="0"
style="visibility:hidden;mix-blend-mode:normal;fill:#ffffff;fill-rule:nonzero;stroke-width:0.99999988;fill-opacity:1" />
<rect
transform="rotate(-90)"
y="412.13489"
x="-911.34436"
height="560.90375"
width="327.70862"
id="rect1739-8"
style="opacity:1;fill:#ffd292;fill-opacity:1;stroke:none;stroke-width:37.79526901;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke" />
<path
id="path1799"
d="M 988.40121,578.11175 V 651.2546 H 409.96541 V 578.11175 Z"
inkscape:connector-curvature="0"
style="mix-blend-mode:normal;fill:#546e7a;fill-rule:nonzero;stroke-width:0.99999988" />
<rect
style="opacity:1;fill:#b3c3cb;fill-opacity:1;stroke:none;stroke-width:37.79526901;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke"
id="rect1739-6-1"
width="655.41724"
height="338.99207"
x="-914.85529"
y="38.243896"
transform="rotate(-90)" />
<path
id="path1801-7"
d="m 73.1429,73.14287 h 877.7142 c 40.2857,0 73.1429,32.86857 73.1429,73.14285 V 914.2857 c 0,20.12571 -16.4458,36.57142 -36.5715,36.57142 H 36.5714 C 16.4343,950.85712 0,934.42284 0,914.2857 V 146.28572 C 0,106.00001 32.8571,73.14287 73.1429,73.14287 Z m 0,219.42856 V 877.71427 H 950.8571 V 292.57143 Z"
inkscape:connector-curvature="0"
style="mix-blend-mode:normal;fill:#546e7a;fill-rule:nonzero;stroke-width:0.99999988" />
<path
id="path1799-6"
d="M 359.8801,276.79402 H 433.023 V 886.78767 H 359.8801 Z"
inkscape:connector-curvature="0"
style="mix-blend-mode:normal;fill:#546e7a;fill-rule:nonzero;stroke-width:0.99999988" />
<circle
r="36.81749"
cy="169.78555"
cx="920.66248"
id="path1917-42"
style="opacity:1;fill:#ffa726;fill-opacity:1;stroke:none;stroke-width:63.79999924;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers" />
<circle
r="36.81749"
cy="169.78555"
cx="817.22302"
id="path1917-4-6"
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:63.79999924;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers" />
<path
id="path1799-8"
d="m 615.67076,292.13464 v 73.14285 H 433.023 v -73.14285 z"
inkscape:connector-curvature="0"
style="mix-blend-mode:normal;fill:#95abb6;fill-rule:nonzero;stroke-width:0.99999994;fill-opacity:1" />
<path
id="path1799-8-1"
d="m 798.31852,292.13464 v 73.14285 H 615.67076 v -73.14285 z"
inkscape:connector-curvature="0"
style="mix-blend-mode:normal;fill:#c7d4d9;fill-rule:nonzero;stroke-width:0.99999994;fill-opacity:1" />
<path
id="path1799-8-7"
d="m 255.79066,292.57143 v 73.14285 H 73.1429 v -73.14285 z"
inkscape:connector-curvature="0"
style="mix-blend-mode:normal;fill:#dfe5e9;fill-opacity:1;fill-rule:nonzero;stroke-width:0.99999994" />
<path
id="path1799-8-7-6"
d="m 616.34083,651.15739 v 73.14285 H 433.69307 v -73.14285 z"
inkscape:connector-curvature="0"
style="mix-blend-mode:normal;fill:#ffba56;fill-opacity:1;fill-rule:nonzero;stroke-width:0.99999994" />
</svg>

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
doc/ads_icon_256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
doc/ads_icon_512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@@ -0,0 +1,109 @@
# Advanced Docking System for Qt
Qt Advanced Docking System lets you create customizable layouts using a full
featured window docking system similar to what is found in many popular
integrated development environments (IDEs) such as Visual Studio.
[![Video Advanced Docking](https://raw.githubusercontent.com/githubuser0xFFFF/Qt-Advanced-Docking-System/master/doc/advanced-docking_video.png)](https://www.youtube.com/watch?v=7pdNfafg3Qc)
Everything is implemented with standard Qt functionality without any
platform specific code. Basic usage of QWidgets and QLayouts and using basic
styles as much as possible.
## Features
### Overview
- [Advanced Docking System for Qt](#advanced-docking-system-for-qt)
- [Features](#features)
- [Overview](#overview)
- [Docking everywhere - no central widget](#docking-everywhere---no-central-widget)
- [Docking inside floating windows](#docking-inside-floating-windows)
- [Grouped dragging](#grouped-dragging)
- [Perspectives for fast switching of the complete main window layout](#perspectives-for-fast-switching-of-the-complete-main-window-layout)
- [Opaque and non-opaque splitter resizing](#opaque-and-non-opaque-splitter-resizing)
- [Opaque and non-opaque undocking](#opaque-and-non-opaque-undocking)
- [Tab-menu for easy handling of many tabbed dock widgets](#tab-menu-for-easy-handling-of-many-tabbed-dock-widgets)
- [Many different ways to detach dock widgets](#many-different-ways-to-detach-dock-widgets)
- [Supports deletion of dynamically created dock widgets](#supports-deletion-of-dynamically-created-dock-widgets)
### Docking everywhere - no central widget
There is no central widget like in the Qt docking system. You can dock on every
border of the main window or you can dock into each dock area - so you are
free to dock almost everywhere.
![Dropping widgets](https://raw.githubusercontent.com/githubuser0xFFFF/Qt-Advanced-Docking-System/master/doc/preview-dragndrop.png)\
\
![Dropping widgets](https://raw.githubusercontent.com/githubuser0xFFFF/Qt-Advanced-Docking-System/master/doc/preview-dragndrop_dark.png)
### Docking inside floating windows
There is no difference between the main window and a floating window. Docking
into floating windows is supported.
![Docking inside floating windows](https://raw.githubusercontent.com/githubuser0xFFFF/Qt-Advanced-Docking-System/master/doc/floating-widget-dragndrop.png)\
\
![Docking inside floating windows](https://raw.githubusercontent.com/githubuser0xFFFF/Qt-Advanced-Docking-System/master/doc/floating-widget-dragndrop_dark.png)
### Grouped dragging
When dragging the titlebar of a dock, all the tabs that are tabbed with it are
going to be dragged. So you can move complete groups of tabbed widgets into
a floating widget or from one dock area to another one.
![Grouped dragging](https://raw.githubusercontent.com/githubuser0xFFFF/Qt-Advanced-Docking-System/master/doc/grouped-dragging.gif)\
\
![Grouped dragging](https://raw.githubusercontent.com/githubuser0xFFFF/Qt-Advanced-Docking-System/master/doc/grouped-dragging_dark.png)
### Perspectives for fast switching of the complete main window layout
A perspective defines the set and layout of dock windows in the main
window. You can save the current layout of the dockmanager into a named
perspective to make your own custom perspective. Later you can simply
select a perspective from the perspective list to quickly switch the complete
main window layout.
![Perspective](https://raw.githubusercontent.com/githubuser0xFFFF/Qt-Advanced-Docking-System/master/doc/perspectives.gif)\
\
![Perspective](https://raw.githubusercontent.com/githubuser0xFFFF/Qt-Advanced-Docking-System/master/doc/perspectives_dark.png)
### Opaque and non-opaque splitter resizing
The advanced docking system uses standard QSplitters as resize separators and thus supports opaque and non-opaque resizing functionality of QSplitter. In some rare cases, for very complex widgets or on slow machines resizing via separator on the fly may cause flicking and glaring of rendered content inside a widget. The global dock manager flag `OpaqueSplitterResize` configures the resizing behaviour of the splitters. If this flag is set, then widgets are resized dynamically (opaquely) while interactively moving the splitters.
![Opaque resizing](https://raw.githubusercontent.com/githubuser0xFFFF/Qt-Advanced-Docking-System/master/doc/opaque_resizing.gif)
If this flag is cleared, the widget resizing is deferred until the mouse button is released - this is some kind of lazy resizing separator.
![Non-opaque resizing](https://raw.githubusercontent.com/githubuser0xFFFF/Qt-Advanced-Docking-System/master/doc/non_opaque_resizing.gif)
### Opaque and non-opaque undocking
By default, opaque undocking is active. That means, as soon as you drag a dock widget or a dock area with a number of dock widgets it will be undocked and moved into a floating widget and then the floating widget will be dragged around. That means undocking will take place immediatelly. You can compare this with opaque splitter resizing. If the flag `OpaqueUndocking` is cleared, then non-opaque undocking is active. In this mode, undocking is more like a standard drag and drop operation. That means, the dragged dock widget or dock area is not undocked immediatelly. Instead, a drag preview widget is created and dragged around to indicate the future position of the dock widget or dock area. The actual dock operation is only executed when the mouse button is released. That makes it possible, to cancel an active drag operation with the escape key.
The drag preview widget can be configured by a number of global dock manager flags:
- `DragPreviewIsDynamic`: if this flag is enabled, the preview will be adjusted dynamically to the drop area
- `DragPreviewShowsContentPixmap`: the created drag preview window shows a static copy of the content of the dock widget / dock are that is dragged
- `DragPreviewHasWindowFrame`: this flag configures if the drag preview is frameless like a QRubberBand or looks like a real window
The best way to test non-opaque undocking is to set the standard flags: `CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig)`.
### Tab-menu for easy handling of many tabbed dock widgets
Tabs are a good way to quickly switch between dockwidgets in a dockarea. However, if the number of dockwidgets in a dockarea is too large, this may affect the usability of the tab bar. To keep track in this situation, you can use the tab menu. The menu allows you to quickly select the dockwidget you want to activate from a drop down menu.
![Tab menu](https://raw.githubusercontent.com/githubuser0xFFFF/Qt-Advanced-Docking-System/master/doc/tab_menu.gif)
### Many different ways to detach dock widgets
You can detach dock widgets and also dock areas in the following ways:
- by dragging the dock widget tab or the dock area title bar
- by double clicking the tab or title bar
- by using the detach menu entry from the tab and title bar drop down menu
### Supports deletion of dynamically created dock widgets
Normally clicking the close button of a dock widget will just hide the widget and the user can show it again using the toggleView() action of the dock widget. This is meant for user interfaces with a static amount of widgets. But the advanced docking system also supports dynamic dock widgets that will get deleted on close. If you set the dock widget flag `DockWidgetDeleteOnClose` for a certain dock widget, then it will be deleted as soon as you close this dock widget. This enables the implementation of user interfaces with dynamically created editors, like in word processing applications or source code development tools.

View File

@@ -0,0 +1,30 @@
{
"$schema": "http://qt.io/schema/extension-schema-v1#",
"title": "Qt Advanced Docking System",
"extensionType": [
"library"
],
"version": "3.0.0",
"vendor": {
"name": "githubuser0xFFFF",
"url": "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System"
},
"contact": "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues",
"icon": "https://raw.githubusercontent.com/githubuser0xFFFF/Qt-Advanced-Docking-System/master/doc/ads_icon_512.png",
"licenses": [
{ "licenseType": "LGPLv2.1",
"licenseUrl": "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html" }
],
"created": "2017-03-30",
"lastUpdate": "2020-01-16",
"platforms": [
"Windows 7-10", "Kubuntu 18.04", "Kubuntu 19.10", "Ubuntu 19.10"
],
"qtVersions": [
"5.5.1 or newer"
],
"tags": [
"Widgets", "Docking"],
"bugUrl": "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues",
"sourceRepoUrl": "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System"
}

BIN
doc/donate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 91 KiB

BIN
doc/grouped-dragging.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 232 KiB

After

Width:  |  Height:  |  Size: 142 KiB

BIN
doc/linux_ubuntu_1910.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

BIN
doc/macos.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 KiB

BIN
doc/non_opaque_resizing.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 KiB

BIN
doc/opaque_resizing.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 KiB

BIN
doc/perspectives.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 88 KiB

BIN
doc/tab_menu.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 KiB

7
setup.cfg Normal file
View File

@@ -0,0 +1,7 @@
[versioneer]
VCS = git
style = pep440
versionfile_source = PyQtAds/_version.py
versionfile_build = PyQtAds/_version.py
tag_prefix =

102
setup.py
View File

@@ -4,20 +4,18 @@ import shlex
import subprocess import subprocess
import glob import glob
import versioneer
from setuptools import setup, find_packages from setuptools import setup, find_packages
from setuptools.command.build_py import build_py
from setuptools.extension import Extension from setuptools.extension import Extension
from distutils import sysconfig, dir_util, spawn, log from distutils import sysconfig, dir_util, spawn, log, cmd
from distutils.dep_util import newer from distutils.dep_util import newer
import sipdistutils import sipdistutils
import sipconfig import sipconfig
from PyQt5.QtCore import PYQT_CONFIGURATION from PyQt5.QtCore import PYQT_CONFIGURATION
from PyQt5.pyrcc_main import processResourceFile from PyQt5.pyrcc_main import processResourceFile
MAJOR = 2
MINOR = 5
MICRO = 1
ISRELEASED = True
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
MODULE_NAME = "ads" MODULE_NAME = "ads"
SRC_PATH = "PyQtAds" SRC_PATH = "PyQtAds"
@@ -220,74 +218,31 @@ class build_ext(sipdistutils.build_ext):
sipdistutils.build_ext.build_extension(self, ext) sipdistutils.build_ext.build_extension(self, ext)
def git_version():
'''Return the git revision as a string'''
def _minimal_ext_cmd(cmd):
# construct minimal environment
env = {}
for k in ['SYSTEMROOT', 'PATH', 'HOME']:
v = os.environ.get(k)
if v is not None:
env[k] = v
# LANGUAGE is used on win32
env['LANGUAGE'] = 'C'
env['LANG'] = 'C'
env['LC_ALL'] = 'C'
out = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=env).communicate()[0]
return out
try: class ProcessResourceCommand(cmd.Command):
out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD']) """A custom command to compile the resource file into a Python file"""
GIT_REVISION = out.strip().decode('ascii')
except OSError:
GIT_REVISION = "Unknown"
return GIT_REVISION description = "Compile the qrc file into a python file"
def get_version_info(): def initialize_options(self):
# Adding the git rev number needs to be done inside write_version_py(), return
# otherwise the import of numpy.version messes up the build under Python 3.
FULLVERSION = VERSION
if os.path.exists('.git'):
GIT_REVISION = git_version()
elif os.path.exists(os.path.join(SRC_PATH, 'version.py')):
# must be a source distribution, use existing version file
try:
from PyQtAds.version import git_revision as GIT_REVISION
except ImportError:
raise ImportError("Unable to import git_revision. Try removing " \
"%(module)/version.py and the build directory " \
"before building." % {'module': SRC_PATH})
else:
GIT_REVISION = "Unknown"
if not ISRELEASED: def finalize_options(self):
FULLVERSION += '.dev0+' + GIT_REVISION[:7] return
return FULLVERSION, GIT_REVISION def run(self):
processResourceFile([os.path.join('src', 'ads.qrc')],
os.path.join(SRC_PATH, 'rc.py'), False)
class BuildPyCommand(build_py):
"""Custom build command to include ProcessResource command"""
def run(self):
self.run_command("process_resource")
build_py.run(self)
def write_version_py(filename=os.path.join(SRC_PATH, '_version.py')):
cnt = ("# THIS FILE IS GENERATED FROM %(module)s SETUP.PY\n\n"
"short_version = '%(version)s'\n"
"version = '%(version)s'\n"
"full_version = '%(full_version)s'\n"
"git_revision = '%(git_revision)s'\n"
"release = %(isrelease)s\n"
"if not release:\n"
" version = full_version\n")
FULLVERSION, GIT_REVISION = get_version_info()
with open(filename, 'w') as f:
f.write(cnt % {'module': SRC_PATH,
'version': VERSION,
'full_version': FULLVERSION,
'git_revision': GIT_REVISION,
'isrelease': str(ISRELEASED)})
setup_requires = ["PyQt5"] if REQUIRE_PYQT else [] setup_requires = ["PyQt5"] if REQUIRE_PYQT else []
cpp_sources = glob.glob(os.path.join('src', '*.cpp')) cpp_sources = glob.glob(os.path.join('src', '*.cpp'))
sip_sources = [os.path.join('sip', MODULE_NAME + '.sip')] sip_sources = [os.path.join('sip', MODULE_NAME + '.sip')]
@@ -300,18 +255,15 @@ if sys.platform == 'win32':
install_requires.append("pywin32") install_requires.append("pywin32")
write_version_py(os.path.join(SRC_PATH, '_version.py'))
processResourceFile([os.path.join('src', 'ads.qrc')],
os.path.join(SRC_PATH, 'rc.py'), False)
with open('README.md', 'r') as f: with open('README.md', 'r') as f:
LONG_DESCRIPTION = f.read() LONG_DESCRIPTION = f.read()
setup( setup(
name = SRC_PATH, name = SRC_PATH,
author = "Nicolas Elie", author = "Nicolas Elie",
author_email = "nicolas.elie@cnrs.fr", author_email = "nicolas.elie@cnrs.fr",
url = "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System", url = "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System",
version = get_version_info()[0], version = versioneer.get_version(),
description = "Advanced Docking System for Qt", description = "Advanced Docking System for Qt",
long_description = LONG_DESCRIPTION, long_description = LONG_DESCRIPTION,
keywords = ["qt"], keywords = ["qt"],
@@ -332,9 +284,9 @@ setup(
"Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7"], "Programming Language :: Python :: 3.7"],
ext_modules = ext_modules, ext_modules = ext_modules,
cmdclass = { cmdclass = versioneer.get_cmdclass({'process_resource': ProcessResourceCommand,
'build_ext': build_ext, 'build_py': BuildPyCommand,
}, 'build_ext': build_ext}),
packages = find_packages(), packages = find_packages(),
setup_requires = setup_requires, setup_requires = setup_requires,
install_requires = install_requires, install_requires = install_requires,

View File

@@ -18,9 +18,10 @@ protected:
virtual void mouseMoveEvent(QMouseEvent* ev); virtual void mouseMoveEvent(QMouseEvent* ev);
virtual void mouseDoubleClickEvent(QMouseEvent *event); virtual void mouseDoubleClickEvent(QMouseEvent *event);
void startFloating(const QPoint& Offset); void startFloating(const QPoint& Offset);
ads::CFloatingDockContainer* makeAreaFloating(const QPoint& Offset, ads::IFloatingWidget* makeAreaFloating(const QPoint& Offset,
ads::eDragState DragState); ads::eDragState DragState);
ads::eDragState dragState() const;
public: public:
CDockAreaTabBar(ads::CDockAreaWidget* parent /TransferThis/); CDockAreaTabBar(ads::CDockAreaWidget* parent /TransferThis/);
virtual ~CDockAreaTabBar(); virtual ~CDockAreaTabBar();

View File

@@ -23,10 +23,11 @@ protected:
QSplitter* rootSplitter() const; QSplitter* rootSplitter() const;
void createRootSplitter(); void createRootSplitter();
void dropFloatingWidget(ads::CFloatingDockContainer* FloatingWidget, const QPoint& TargetPos); void dropFloatingWidget(ads::CFloatingDockContainer* FloatingWidget, const QPoint& TargetPos);
void dropWidget(QWidget* widget, const QPoint& TargetPos);
void addDockArea(ads::CDockAreaWidget* DockAreaWidget /Transfer/, ads::DockWidgetArea area = ads::CenterDockWidgetArea); void addDockArea(ads::CDockAreaWidget* DockAreaWidget /Transfer/, ads::DockWidgetArea area = ads::CenterDockWidgetArea);
void removeDockArea(ads::CDockAreaWidget* area /Transfer/); void removeDockArea(ads::CDockAreaWidget* area /Transfer/);
void saveState(QXmlStreamWriter& Stream) const; void saveState(QXmlStreamWriter& Stream) const;
bool restoreState(QXmlStreamReader& Stream, bool Testing); bool restoreState(CDockingStateReader& Stream, bool Testing);
ads::CDockAreaWidget* lastAddedDockAreaWidget(ads::DockWidgetArea area) const; ads::CDockAreaWidget* lastAddedDockAreaWidget(ads::DockWidgetArea area) const;
bool hasTopLevelDockWidget() const; bool hasTopLevelDockWidget() const;
ads::CDockWidget* topLevelDockWidget() const; ads::CDockWidget* topLevelDockWidget() const;

View File

@@ -152,7 +152,13 @@ public:
TabCloseButtonIsToolButton, TabCloseButtonIsToolButton,
AllTabsHaveCloseButton, AllTabsHaveCloseButton,
RetainTabSizeWhenCloseButtonHidden, RetainTabSizeWhenCloseButtonHidden,
OpaqueUndocking,
DragPreviewIsDynamic,
DragPreviewShowsContentPixmap,
DragPreviewHasWindowFrame,
DefaultConfig, DefaultConfig,
DefaultNonOpaqueConfig,
NonOpaqueWithWindowFrame,
}; };
typedef QFlags<ads::CDockManager::eConfigFlag> ConfigFlags; typedef QFlags<ads::CDockManager::eConfigFlag> ConfigFlags;
@@ -161,20 +167,22 @@ public:
static ads::CDockManager::ConfigFlags configFlags(); static ads::CDockManager::ConfigFlags configFlags();
static void setConfigFlags(const ads::CDockManager::ConfigFlags Flags); static void setConfigFlags(const ads::CDockManager::ConfigFlags Flags);
static void setConfigFlag(ads::CDockManager::eConfigFlag Flag, bool On = true); static void setConfigFlag(ads::CDockManager::eConfigFlag Flag, bool On = true);
static ads::CIconProvider& iconProvider();
ads::CDockAreaWidget* addDockWidget(ads::DockWidgetArea area, ads::CDockWidget* Dockwidget /Transfer/, ads::CDockAreaWidget* addDockWidget(ads::DockWidgetArea area, ads::CDockWidget* Dockwidget /Transfer/,
ads::CDockAreaWidget* DockAreaWidget /Transfer/ = 0); ads::CDockAreaWidget* DockAreaWidget /Transfer/ = 0);
ads::CDockAreaWidget* addDockWidgetTab(ads::DockWidgetArea area, ads::CDockAreaWidget* addDockWidgetTab(ads::DockWidgetArea area,
ads::CDockWidget* Dockwidget /Transfer/); ads::CDockWidget* Dockwidget /Transfer/);
ads::CDockAreaWidget* addDockWidgetTabToArea(ads::CDockWidget* Dockwidget /Transfer/, ads::CDockAreaWidget* addDockWidgetTabToArea(ads::CDockWidget* Dockwidget /Transfer/,
ads::CDockAreaWidget* DockAreaWidget /Transfer/); ads::CDockAreaWidget* DockAreaWidget /Transfer/);
ads::CFloatingDockContainer* addDockWidgetFloating(ads::CDockWidget* DockWidget /Transfer/);
ads::CDockWidget* findDockWidget(const QString& ObjectName) const; ads::CDockWidget* findDockWidget(const QString& ObjectName) const;
void removeDockWidget(ads::CDockWidget* Dockwidget) /TransferBack/; void removeDockWidget(ads::CDockWidget* Dockwidget) /TransferBack/;
QMap<QString, ads::CDockWidget*> dockWidgetsMap() const; QMap<QString, ads::CDockWidget*> dockWidgetsMap() const;
const QList<ads::CDockContainerWidget*> dockContainers() const; const QList<ads::CDockContainerWidget*> dockContainers() const;
const QList<ads::CFloatingDockContainer*> floatingWidgets() const; const QList<ads::CFloatingDockContainer*> floatingWidgets() const;
virtual unsigned int zOrderIndex() const; virtual unsigned int zOrderIndex() const;
QByteArray saveState(int version = 0) const; QByteArray saveState(int version = 1) const;
bool restoreState(const QByteArray &state, int version = 0); bool restoreState(const QByteArray &state, int version = 1);
void addPerspective(const QString& UniquePrespectiveName); void addPerspective(const QString& UniquePrespectiveName);
void removePerspective(const QString& Name); void removePerspective(const QString& Name);
void removePerspectives(const QStringList& Names); void removePerspectives(const QStringList& Names);
@@ -198,8 +206,11 @@ signals:
void stateRestored(); void stateRestored();
void openingPerspective(const QString& PerspectiveName); void openingPerspective(const QString& PerspectiveName);
void perspectiveOpened(const QString& PerspectiveName); void perspectiveOpened(const QString& PerspectiveName);
void dockAreaCreated(ads::CDockAreaWidget* DockArea);
void dockWidgetAboutToBeRemoved(ads::CDockWidget* DockWidget);
void dockWidgetRemoved(ads::CDockWidget* DockWidget);
}; };
}; };
%End %End

View File

@@ -28,6 +28,7 @@ public:
DockWidgetClosable, DockWidgetClosable,
DockWidgetMovable, DockWidgetMovable,
DockWidgetFloatable, DockWidgetFloatable,
DockWidgetDeleteOnClose,
AllDockWidgetFeatures, AllDockWidgetFeatures,
NoDockWidgetFeatures NoDockWidgetFeatures
}; };
@@ -88,12 +89,16 @@ public:
public slots: public slots:
void toggleView(bool Open = true); void toggleView(bool Open = true);
void setFloating();
void deleteDockWidget();
signals: signals:
void viewToggled(bool Open); void viewToggled(bool Open);
void closed(); void closed();
void titleChanged(const QString& Title); void titleChanged(const QString& Title);
void topLevelChanged(bool topLevel); void topLevelChanged(bool topLevel);
void visibilityChanged(bool visible);
void featuresChanged(ads::CDockWidget::DockWidgetFeatures features);
}; };
}; };

View File

@@ -0,0 +1,21 @@
%If (Qt_5_0_0 -)
namespace ads
{
class CDockingStateReader : QXmlStreamReader
{
%TypeHeaderCode
#include <DockingStateReader.h>
%End
public:
void setFileVersion(int FileVersion);
int fileVersion() const;
};
};
%End

View File

@@ -5,7 +5,22 @@
namespace ads namespace ads
{ {
class CFloatingDockContainer : QWidget class IFloatingWidget
{
%TypeHeaderCode
#include <FloatingDockContainer.h>
%End
public:
virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
ads::eDragState DragState, QWidget* MouseEventHandler) = 0;
virtual void moveFloating() = 0;
virtual void finishDragging() = 0;
};
class CFloatingDockContainer : QWidget, ads::IFloatingWidget
{ {
%TypeHeaderCode %TypeHeaderCode
@@ -13,14 +28,14 @@ class CFloatingDockContainer : QWidget
%End %End
protected: protected:
void startFloating(const QPoint& DragStartMousePos, const QSize& Size, virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
ads::eDragState DragState, QWidget* MouseEventHandler); ads::eDragState DragState, QWidget* MouseEventHandler);
void startDragging(const QPoint& DragStartMousePos, const QSize& Size, void startDragging(const QPoint& DragStartMousePos, const QSize& Size,
QWidget* MouseEventHandler); QWidget* MouseEventHandler);
void finishDragging(); virtual void finishDragging();
void initFloatingGeometry(const QPoint& DragStartMousePos, const QSize& Size); void initFloatingGeometry(const QPoint& DragStartMousePos, const QSize& Size);
void moveFloating(); void moveFloating();
bool restoreState(QXmlStreamReader& Stream, bool Testing); bool restoreState(ads::CDockingStateReader& Stream, bool Testing);
void updateWindowTitle(); void updateWindowTitle();

View File

@@ -0,0 +1,38 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CFloatingDragPreview : QWidget, ads::IFloatingWidget
{
%TypeHeaderCode
#include <FloatingDragPreview.h>
%End
public:
CFloatingDragPreview(ads::CDockWidget* Content /TransferThis/ );
CFloatingDragPreview(ads::CDockAreaWidget* Content /TransferThis/ );
virtual ~CFloatingDragPreview();
virtual bool eventFilter(QObject* watched, QEvent* event);
virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
ads::eDragState DragState, QWidget* MouseEventHandler);
virtual void moveFloating();
virtual void finishDragging();
signals:
void draggingCanceled();
};
};
%End

28
sip/IconProvider.sip Normal file
View File

@@ -0,0 +1,28 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CIconProvider
{
%TypeHeaderCode
#include <IconProvider.h>
%End
public:
CIconProvider();
virtual ~CIconProvider();
QIcon customIcon(eIcon IconId);
void registerCustomIcon(eIcon IconId, const QIcon& icon /TransferThis/ );
};
};
%End

View File

@@ -9,12 +9,15 @@
%Include DockAreaTitleBar.sip %Include DockAreaTitleBar.sip
%Include DockAreaWidget.sip %Include DockAreaWidget.sip
%Include DockContainerWidget.sip %Include DockContainerWidget.sip
%Include DockingStateReader.sip
%Include DockManager.sip %Include DockManager.sip
%Include DockOverlay.sip %Include DockOverlay.sip
%Include DockSplitter.sip %Include DockSplitter.sip
%Include DockWidgetTab.sip %Include DockWidgetTab.sip
%Include ElidingLabel.sip %Include ElidingLabel.sip
%Include FloatingDockContainer.sip %Include FloatingDockContainer.sip
%Include FloatingDragPreview.sip
%Include IconProvider.sip
%If (Linux) %If (Linux)
%Include linux/FloatingWidgetTitleBar.sip %Include linux/FloatingWidgetTitleBar.sip
%End %End

View File

@@ -39,6 +39,16 @@ namespace ads
DraggingFloatingWidget DraggingFloatingWidget
}; };
enum eIcon
{
TabCloseIcon,
DockAreaMenuIcon,
DockAreaUndockIcon,
DockAreaCloseIcon,
IconCount,
};
}; };
%End %End

View File

@@ -27,6 +27,7 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <FloatingDragPreview.h>
#include "DockAreaTabBar.h" #include "DockAreaTabBar.h"
#include <QMouseEvent> #include <QMouseEvent>
@@ -53,9 +54,7 @@ namespace ads
struct DockAreaTabBarPrivate struct DockAreaTabBarPrivate
{ {
CDockAreaTabBar* _this; CDockAreaTabBar* _this;
QPoint DragStartMousePos;
CDockAreaWidget* DockArea; CDockAreaWidget* DockArea;
CFloatingDockContainer* FloatingWidget = nullptr;
QWidget* TabsContainerWidget; QWidget* TabsContainerWidget;
QBoxLayout* TabsLayout; QBoxLayout* TabsLayout;
int CurrentIndex = -1; int CurrentIndex = -1;
@@ -113,23 +112,24 @@ CDockAreaTabBar::CDockAreaTabBar(CDockAreaWidget* parent) :
d(new DockAreaTabBarPrivate(this)) d(new DockAreaTabBarPrivate(this))
{ {
d->DockArea = parent; d->DockArea = parent;
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
setFrameStyle(QFrame::NoFrame); setFrameStyle(QFrame::NoFrame);
setWidgetResizable(true); setWidgetResizable(true);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
d->TabsContainerWidget = new QWidget(); d->TabsContainerWidget = new QWidget();
d->TabsContainerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
d->TabsContainerWidget->setObjectName("tabsContainerWidget"); d->TabsContainerWidget->setObjectName("tabsContainerWidget");
setWidget(d->TabsContainerWidget);
d->TabsLayout = new QBoxLayout(QBoxLayout::LeftToRight); d->TabsLayout = new QBoxLayout(QBoxLayout::LeftToRight);
d->TabsLayout->setContentsMargins(0, 0, 0, 0); d->TabsLayout->setContentsMargins(0, 0, 0, 0);
d->TabsLayout->setSpacing(0); d->TabsLayout->setSpacing(0);
d->TabsLayout->addStretch(1); d->TabsLayout->addStretch(1);
d->TabsContainerWidget->setLayout(d->TabsLayout); d->TabsContainerWidget->setLayout(d->TabsLayout);
setWidget(d->TabsContainerWidget);
} }
//============================================================================ //============================================================================
CDockAreaTabBar::~CDockAreaTabBar() CDockAreaTabBar::~CDockAreaTabBar()
{ {
@@ -153,121 +153,6 @@ void CDockAreaTabBar::wheelEvent(QWheelEvent* Event)
} }
//============================================================================
void CDockAreaTabBar::mousePressEvent(QMouseEvent* ev)
{
if (ev->button() == Qt::LeftButton)
{
ev->accept();
d->DragStartMousePos = ev->pos();
return;
}
QScrollArea::mousePressEvent(ev);
}
//============================================================================
void CDockAreaTabBar::mouseReleaseEvent(QMouseEvent* ev)
{
if (ev->button() == Qt::LeftButton)
{
ADS_PRINT("CTabsScrollArea::mouseReleaseEvent");
ev->accept();
d->FloatingWidget = nullptr;
d->DragStartMousePos = QPoint();
return;
}
QScrollArea::mouseReleaseEvent(ev);
}
//============================================================================
void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
{
QScrollArea::mouseMoveEvent(ev);
if (ev->buttons() != Qt::LeftButton)
{
return;
}
if (d->FloatingWidget)
{
d->FloatingWidget->moveFloating();
return;
}
// If this is the last dock area in a dock container it does not make
// sense to move it to a new floating widget and leave this one
// empty
if (d->DockArea->dockContainer()->isFloating()
&& d->DockArea->dockContainer()->visibleDockAreaCount() == 1)
{
return;
}
// If one single dock widget in this area is not floatable then the whole
// area is not floatable
if (!d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
{
return;
}
int DragDistance = (d->DragStartMousePos - ev->pos()).manhattanLength();
if (DragDistance >= CDockManager::startDragDistance())
{
ADS_PRINT("CTabsScrollArea::startFloating");
startFloating(d->DragStartMousePos);
auto Overlay = d->DockArea->dockManager()->containerOverlay();
Overlay->setAllowedAreas(OuterDockAreas);
}
return;
}
//============================================================================
void CDockAreaTabBar::mouseDoubleClickEvent(QMouseEvent *event)
{
// If this is the last dock area in a dock container it does not make
// sense to move it to a new floating widget and leave this one
// empty
if (d->DockArea->dockContainer()->isFloating() && d->DockArea->dockContainer()->dockAreaCount() == 1)
{
return;
}
if (!d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
{
return;
}
makeAreaFloating(event->pos(), DraggingInactive);
}
//============================================================================
CFloatingDockContainer* CDockAreaTabBar::makeAreaFloating(const QPoint& Offset,
eDragState DragState)
{
QSize Size = d->DockArea->size();
CFloatingDockContainer* FloatingWidget = new CFloatingDockContainer(d->DockArea);
FloatingWidget->startFloating(Offset, Size, DragState, nullptr);
auto TopLevelDockWidget = FloatingWidget->topLevelDockWidget();
if (TopLevelDockWidget)
{
TopLevelDockWidget->emitTopLevelChanged(true);
}
return FloatingWidget;
}
//============================================================================
void CDockAreaTabBar::startFloating(const QPoint& Offset)
{
d->FloatingWidget = makeAreaFloating(Offset, DraggingFloatingWidget);
}
//============================================================================ //============================================================================
void CDockAreaTabBar::setCurrentIndex(int index) void CDockAreaTabBar::setCurrentIndex(int index)
{ {
@@ -285,6 +170,7 @@ void CDockAreaTabBar::setCurrentIndex(int index)
emit currentChanging(index); emit currentChanging(index);
d->CurrentIndex = index; d->CurrentIndex = index;
d->updateTabs(); d->updateTabs();
updateGeometry();
emit currentChanged(index); emit currentChanged(index);
} }
@@ -305,12 +191,15 @@ void CDockAreaTabBar::insertTab(int Index, CDockWidgetTab* Tab)
connect(Tab, SIGNAL(closeRequested()), this, SLOT(onTabCloseRequested())); connect(Tab, SIGNAL(closeRequested()), this, SLOT(onTabCloseRequested()));
connect(Tab, SIGNAL(closeOtherTabsRequested()), this, SLOT(onCloseOtherTabsRequested())); connect(Tab, SIGNAL(closeOtherTabsRequested()), this, SLOT(onCloseOtherTabsRequested()));
connect(Tab, SIGNAL(moved(const QPoint&)), this, SLOT(onTabWidgetMoved(const QPoint&))); connect(Tab, SIGNAL(moved(const QPoint&)), this, SLOT(onTabWidgetMoved(const QPoint&)));
connect(Tab, SIGNAL(elidedChanged(bool)), this, SIGNAL(elidedChanged(bool)));
Tab->installEventFilter(this); Tab->installEventFilter(this);
emit tabInserted(Index); emit tabInserted(Index);
if (Index <= d->CurrentIndex) if (Index <= d->CurrentIndex || d->CurrentIndex == -1)
{ {
setCurrentIndex(d->CurrentIndex + 1); setCurrentIndex(d->CurrentIndex + 1);
} }
updateGeometry();
} }
@@ -373,6 +262,8 @@ void CDockAreaTabBar::removeTab(CDockWidgetTab* Tab)
{ {
d->updateTabs(); d->updateTabs();
} }
updateGeometry();
} }
@@ -434,7 +325,20 @@ void CDockAreaTabBar::onCloseOtherTabsRequested()
auto Tab = tab(i); auto Tab = tab(i);
if (Tab->isClosable() && !Tab->isHidden() && Tab != Sender) if (Tab->isClosable() && !Tab->isHidden() && Tab != Sender)
{ {
// If the dock widget is deleted with the closeTab() call, its tab
// it will no longer be in the layout, and thus the index needs to
// be updated to not skip any tabs
int Offset = Tab->dockWidget()->features().testFlag(
CDockWidget::DockWidgetDeleteOnClose) ? 1 : 0;
closeTab(i); closeTab(i);
// If the the dock widget blocks closing, i.e. if the flag
// CustomCloseHandling is set, and the dock widget is still open,
// then we do not need to correct the index
if (Tab->dockWidget()->isClosed())
{
i -= Offset;
}
} }
} }
} }
@@ -511,7 +415,6 @@ void CDockAreaTabBar::onTabWidgetMoved(const QPoint& GlobalPos)
} }
} }
//=========================================================================== //===========================================================================
void CDockAreaTabBar::closeTab(int Index) void CDockAreaTabBar::closeTab(int Index)
{ {
@@ -525,7 +428,6 @@ void CDockAreaTabBar::closeTab(int Index)
{ {
return; return;
} }
Tab->hide();
emit tabCloseRequested(Index); emit tabCloseRequested(Index);
} }
@@ -543,9 +445,15 @@ bool CDockAreaTabBar::eventFilter(QObject *watched, QEvent *event)
switch (event->type()) switch (event->type())
{ {
case QEvent::Hide: case QEvent::Hide:
emit tabClosed(d->TabsLayout->indexOf(Tab)); break; emit tabClosed(d->TabsLayout->indexOf(Tab));
updateGeometry();
break;
case QEvent::Show: case QEvent::Show:
emit tabOpened(d->TabsLayout->indexOf(Tab)); break; emit tabOpened(d->TabsLayout->indexOf(Tab));
updateGeometry();
break;
default: default:
break; break;
} }
@@ -570,19 +478,19 @@ bool CDockAreaTabBar::isTabOpen(int Index) const
QSize CDockAreaTabBar::minimumSizeHint() const QSize CDockAreaTabBar::minimumSizeHint() const
{ {
QSize Size = sizeHint(); QSize Size = sizeHint();
Size.setWidth(Super::minimumSizeHint().width());// this defines the minimum width of a dock area Size.setWidth(10);
return Size; return Size;
} }
//=========================================================================== //===========================================================================
QSize CDockAreaTabBar::sizeHint() const QSize CDockAreaTabBar::sizeHint() const
{ {
QSize Size = Super::sizeHint(); return d->TabsContainerWidget->sizeHint();
Size.setHeight(d->TabsContainerWidget->sizeHint().height());
return Size;
} }
} // namespace ads } // namespace ads
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// EOF DockAreaTabBar.cpp // EOF DockAreaTabBar.cpp

View File

@@ -39,6 +39,7 @@ class CDockWidgetTab;
struct DockAreaTabBarPrivate; struct DockAreaTabBarPrivate;
class CDockAreaTitleBar; class CDockAreaTitleBar;
class CFloatingDockContainer; class CFloatingDockContainer;
class IFloatingWidget;
/** /**
* Custom tabbar implementation for tab area that is shown on top of a * Custom tabbar implementation for tab area that is shown on top of a
@@ -66,38 +67,6 @@ private slots:
protected: protected:
virtual void wheelEvent(QWheelEvent* Event) override; virtual void wheelEvent(QWheelEvent* Event) override;
/**
* Stores mouse position to detect dragging
*/
virtual void mousePressEvent(QMouseEvent* ev) override;
/**
* Stores mouse position to detect dragging
*/
virtual void mouseReleaseEvent(QMouseEvent* ev) override;
/**
* Starts floating the complete docking area including all dock widgets,
* if it is not the last dock area in a floating widget
*/
virtual void mouseMoveEvent(QMouseEvent* ev) override;
/**
* Double clicking the title bar also starts floating of the complete area
*/
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
/**
* Starts floating
*/
void startFloating(const QPoint& Offset);
/**
* Makes the dock area floating
*/
CFloatingDockContainer* makeAreaFloating(const QPoint& Offset,
eDragState DragState);
public: public:
using Super = QScrollArea; using Super = QScrollArea;
@@ -234,6 +203,11 @@ signals:
* This signal is emitted if a tab has been inserted * This signal is emitted if a tab has been inserted
*/ */
void tabInserted(int index); void tabInserted(int index);
/**
* This signal is emitted when a tab title elide state has been changed
*/
void elidedChanged(bool elided);
}; // class CDockAreaTabBar }; // class CDockAreaTabBar
} // namespace ads } // namespace ads
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -37,35 +37,46 @@
#include <QScrollArea> #include <QScrollArea>
#include <QMouseEvent> #include <QMouseEvent>
#include <QDebug> #include <QDebug>
#include <QPointer>
#include "ads_globals.h" #include "ads_globals.h"
#include "FloatingDockContainer.h" #include "FloatingDockContainer.h"
#include "FloatingDragPreview.h"
#include "DockAreaWidget.h" #include "DockAreaWidget.h"
#include "DockOverlay.h" #include "DockOverlay.h"
#include "DockManager.h" #include "DockManager.h"
#include "DockWidget.h" #include "DockWidget.h"
#include "DockWidgetTab.h" #include "DockWidgetTab.h"
#include "DockAreaTabBar.h" #include "DockAreaTabBar.h"
#include "IconProvider.h"
#include <iostream> #include <iostream>
namespace ads namespace ads
{ {
using tTileBarButton = QToolButton; using tTitleBarButton = QToolButton;
/** /**
* Private data class of CDockAreaTitleBar class (pimpl) * Private data class of CDockAreaTitleBar class (pimpl)
*/ */
struct DockAreaTitleBarPrivate struct DockAreaTitleBarPrivate
{ {
CDockAreaTitleBar* _this; CDockAreaTitleBar* _this;
tTileBarButton* TabsMenuButton; QPointer<tTitleBarButton> TabsMenuButton;
tTileBarButton* UndockButton; QPointer<tTitleBarButton> UndockButton;
tTileBarButton* CloseButton; QPointer<tTitleBarButton> CloseButton;
QBoxLayout* TopLayout; QBoxLayout* Layout;
CDockAreaWidget* DockArea; CDockAreaWidget* DockArea;
CDockAreaTabBar* TabBar; CDockAreaTabBar* TabBar;
bool MenuOutdated = true; bool MenuOutdated = true;
QMenu* TabsMenu; QMenu* TabsMenu;
QList<tTitleBarButton*> DockWidgetActionsButtons;
QPoint DragStartMousePos;
eDragState DragState = DraggingInactive;
IFloatingWidget* FloatingWidget = nullptr;
/** /**
* Private data constructor * Private data constructor
@@ -93,31 +104,110 @@ struct DockAreaTitleBarPrivate
/** /**
* Returns true if the given config flag is set * Returns true if the given config flag is set
*/ */
bool testConfigFlag(CDockManager::eConfigFlag Flag) const static bool testConfigFlag(CDockManager::eConfigFlag Flag)
{ {
return CDockManager::configFlags().testFlag(Flag); return CDockManager::configFlags().testFlag(Flag);
} }
/** /**
* Helper function to set title bar button icons depending on operating * Test function for current drag state
* system and to avoid duplicated code. On windows the standard icons */
* are blurry since Qt 5.11 so we need to do some additional steps bool isDraggingState(eDragState dragState) const
*/ {
void setTitleBarButtonIcon(tTileBarButton* Button, QStyle::StandardPixmap StandarPixmap) return this->DragState == dragState;
{ }
#ifdef Q_OS_LINUX
Button->setIcon(_this->style()->standardIcon(StandarPixmap));
#else /**
QIcon Icon; * Starts floating
QPixmap normalPixmap = _this->style()->standardPixmap(StandarPixmap, 0, Button); */
Icon.addPixmap(internal::createTransparentPixmap(normalPixmap, 0.25), QIcon::Disabled); void startFloating(const QPoint& Offset);
Icon.addPixmap(normalPixmap, QIcon::Normal);
Button->setIcon(Icon); /**
#endif * Makes the dock area floating
} */
IFloatingWidget* makeAreaFloating(const QPoint& Offset, eDragState DragState);
};// struct DockAreaTitleBarPrivate };// struct DockAreaTitleBarPrivate
/**
* Title bar button of a dock area that customizes tTitleBarButton appearance/behaviour
* according to various config flags such as:
* CDockManager::DockAreaHas_xxx_Button - if set to 'false' keeps the button always invisible
* CDockManager::DockAreaHideDisabledButtons - if set to 'true' hides button when it is disabled
*/
class CTitleBarButton : public tTitleBarButton
{
Q_OBJECT
bool Visible = true;
bool HideWhenDisabled = false;
public:
using Super = tTitleBarButton;
CTitleBarButton(bool visible = true, QWidget* parent = nullptr)
: tTitleBarButton(parent),
Visible(visible),
HideWhenDisabled(DockAreaTitleBarPrivate::testConfigFlag(CDockManager::DockAreaHideDisabledButtons))
{}
/**
* Adjust this visibility change request with our internal settings:
*/
virtual void setVisible(bool visible) override
{
// 'visible' can stay 'true' if and only if this button is configured to generaly visible:
visible = visible && this->Visible;
// 'visible' can stay 'true' unless: this button is configured to be invisible when it is disabled and it is currently disabled:
if(visible && HideWhenDisabled)
{
visible = isEnabled();
}
Super::setVisible(visible);
}
protected:
/**
* Handle EnabledChanged signal to set button invisible if the configured
*/
bool event(QEvent *ev) override
{
if(QEvent::EnabledChange == ev->type() && HideWhenDisabled)
{
// force setVisible() call
// Calling setVisible() directly here doesn't work well when button is expected to be shown first time
QMetaObject::invokeMethod(this, "setVisible", Qt::QueuedConnection, Q_ARG(bool, isEnabled()));
}
return Super::event(ev);
}
};
/**
* This spacer widget is here because of the following problem.
* The dock area title bar handles mouse dragging and moving the floating widget.
* The problem is, that if the title bar becomes invisible, i.e. if the dock
* area contains only one single dock widget and the dock area is moved
* into a floating widget, then mouse events are not handled anymore and dragging
* of the floating widget stops.
*/
class CSpacerWidget : public QWidget
{
Q_OBJECT
public:
using Super = QWidget;
CSpacerWidget(QWidget* Parent = 0)
: Super(Parent)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setStyleSheet("border: none; background: none;");
}
virtual QSize sizeHint() const override {return QSize(0, 0);}
virtual QSize minimumSizeHint() const override {return QSize(0, 0);}
};
//============================================================================ //============================================================================
DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) : DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) :
@@ -131,61 +221,51 @@ DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) :
void DockAreaTitleBarPrivate::createButtons() void DockAreaTitleBarPrivate::createButtons()
{ {
QSizePolicy ButtonSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); QSizePolicy ButtonSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
// Tabs menu button
TabsMenuButton = new tTileBarButton(); // Tabs menu button
TabsMenuButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasTabsMenuButton));
TabsMenuButton->setObjectName("tabsMenuButton"); TabsMenuButton->setObjectName("tabsMenuButton");
TabsMenuButton->setAutoRaise(true); TabsMenuButton->setAutoRaise(true);
TabsMenuButton->setPopupMode(QToolButton::InstantPopup); TabsMenuButton->setPopupMode(QToolButton::InstantPopup);
setTitleBarButtonIcon(TabsMenuButton, QStyle::SP_TitleBarUnshadeButton); internal::setButtonIcon(TabsMenuButton, QStyle::SP_TitleBarUnshadeButton, ads::DockAreaMenuIcon);
QMenu* TabsMenu = new QMenu(TabsMenuButton); QMenu* TabsMenu = new QMenu(TabsMenuButton);
#ifndef QT_NO_TOOLTIP #ifndef QT_NO_TOOLTIP
TabsMenu->setToolTipsVisible(true); TabsMenu->setToolTipsVisible(true);
#endif #endif
_this->connect(TabsMenu, SIGNAL(aboutToShow()), SLOT(onTabsMenuAboutToShow())); _this->connect(TabsMenu, SIGNAL(aboutToShow()), SLOT(onTabsMenuAboutToShow()));
TabsMenuButton->setMenu(TabsMenu); TabsMenuButton->setMenu(TabsMenu);
#ifndef QT_NO_TOOLTIP internal::setToolTip(TabsMenuButton, QObject::tr("List all tabs"));
TabsMenuButton->setToolTip(QObject::tr("List all tabs"));
#endif
TabsMenuButton->setSizePolicy(ButtonSizePolicy); TabsMenuButton->setSizePolicy(ButtonSizePolicy);
TopLayout->addWidget(TabsMenuButton, 0); Layout->addWidget(TabsMenuButton, 0);
_this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)), _this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)),
SLOT(onTabsMenuActionTriggered(QAction*))); SLOT(onTabsMenuActionTriggered(QAction*)));
// Undock button // Undock button
UndockButton = new tTileBarButton(); UndockButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasUndockButton));
UndockButton->setObjectName("undockButton"); UndockButton->setObjectName("undockButton");
UndockButton->setAutoRaise(true); UndockButton->setAutoRaise(true);
#ifndef QT_NO_TOOLTIP internal::setToolTip(UndockButton, QObject::tr("Detach Group"));
UndockButton->setToolTip(QObject::tr("Detach Group")); internal::setButtonIcon(UndockButton, QStyle::SP_TitleBarNormalButton, ads::DockAreaUndockIcon);
#endif UndockButton->setSizePolicy(ButtonSizePolicy);
setTitleBarButtonIcon(UndockButton, QStyle::SP_TitleBarNormalButton); Layout->addWidget(UndockButton, 0);
UndockButton->setSizePolicy(ButtonSizePolicy);
TopLayout->addWidget(UndockButton, 0);
_this->connect(UndockButton, SIGNAL(clicked()), SLOT(onUndockButtonClicked())); _this->connect(UndockButton, SIGNAL(clicked()), SLOT(onUndockButtonClicked()));
// Close button
// Close button CloseButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasCloseButton));
CloseButton = new tTileBarButton();
CloseButton->setObjectName("closeButton"); CloseButton->setObjectName("closeButton");
CloseButton->setAutoRaise(true); CloseButton->setAutoRaise(true);
setTitleBarButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton); internal::setButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton, ads::DockAreaCloseIcon);
#ifndef QT_NO_TOOLTIP
if (testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab)) if (testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
{ {
CloseButton->setToolTip(QObject::tr("Close Active Tab")); internal::setToolTip(CloseButton, QObject::tr("Close Active Tab"));
} }
else else
{ {
CloseButton->setToolTip(QObject::tr("Close Group")); internal::setToolTip(CloseButton, QObject::tr("Close Group"));
} }
#endif
CloseButton->setSizePolicy(ButtonSizePolicy); CloseButton->setSizePolicy(ButtonSizePolicy);
CloseButton->setIconSize(QSize(16, 16)); CloseButton->setIconSize(QSize(16, 16));
if (testConfigFlag(CDockManager::DockAreaHasCloseButton)) Layout->addWidget(CloseButton, 0);
{
TopLayout->addWidget(CloseButton, 0);
}
_this->connect(CloseButton, SIGNAL(clicked()), SLOT(onCloseButtonClicked())); _this->connect(CloseButton, SIGNAL(clicked()), SLOT(onCloseButtonClicked()));
} }
@@ -194,7 +274,8 @@ void DockAreaTitleBarPrivate::createButtons()
void DockAreaTitleBarPrivate::createTabBar() void DockAreaTitleBarPrivate::createTabBar()
{ {
TabBar = new CDockAreaTabBar(DockArea); TabBar = new CDockAreaTabBar(DockArea);
TopLayout->addWidget(TabBar); TabBar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
Layout->addWidget(TabBar);
_this->connect(TabBar, SIGNAL(tabClosed(int)), SLOT(markTabsMenuOutdated())); _this->connect(TabBar, SIGNAL(tabClosed(int)), SLOT(markTabsMenuOutdated()));
_this->connect(TabBar, SIGNAL(tabOpened(int)), SLOT(markTabsMenuOutdated())); _this->connect(TabBar, SIGNAL(tabOpened(int)), SLOT(markTabsMenuOutdated()));
_this->connect(TabBar, SIGNAL(tabInserted(int)), SLOT(markTabsMenuOutdated())); _this->connect(TabBar, SIGNAL(tabInserted(int)), SLOT(markTabsMenuOutdated()));
@@ -202,10 +283,51 @@ void DockAreaTitleBarPrivate::createTabBar()
_this->connect(TabBar, SIGNAL(tabMoved(int, int)), SLOT(markTabsMenuOutdated())); _this->connect(TabBar, SIGNAL(tabMoved(int, int)), SLOT(markTabsMenuOutdated()));
_this->connect(TabBar, SIGNAL(currentChanged(int)), SLOT(onCurrentTabChanged(int))); _this->connect(TabBar, SIGNAL(currentChanged(int)), SLOT(onCurrentTabChanged(int)));
_this->connect(TabBar, SIGNAL(tabBarClicked(int)), SIGNAL(tabBarClicked(int))); _this->connect(TabBar, SIGNAL(tabBarClicked(int)), SIGNAL(tabBarClicked(int)));
_this->connect(TabBar, SIGNAL(elidedChanged(bool)), SLOT(markTabsMenuOutdated()));
}
TabBar->setContextMenuPolicy(Qt::CustomContextMenu);
_this->connect(TabBar, SIGNAL(customContextMenuRequested(const QPoint&)), //============================================================================
SLOT(showContextMenu(const QPoint&))); IFloatingWidget* DockAreaTitleBarPrivate::makeAreaFloating(const QPoint& Offset, eDragState DragState)
{
QSize Size = DockArea->size();
this->DragState = DragState;
bool OpaqueUndocking = CDockManager::configFlags().testFlag(CDockManager::OpaqueUndocking) ||
(DraggingFloatingWidget != DragState);
CFloatingDockContainer* FloatingDockContainer = nullptr;
IFloatingWidget* FloatingWidget;
if (OpaqueUndocking)
{
FloatingWidget = FloatingDockContainer = new CFloatingDockContainer(DockArea);
}
else
{
auto w = new CFloatingDragPreview(DockArea);
QObject::connect(w, &CFloatingDragPreview::draggingCanceled, [=]()
{
this->DragState = DraggingInactive;
});
FloatingWidget = w;
}
FloatingWidget->startFloating(Offset, Size, DragState, nullptr);
if (FloatingDockContainer)
{
auto TopLevelDockWidget = FloatingDockContainer->topLevelDockWidget();
if (TopLevelDockWidget)
{
TopLevelDockWidget->emitTopLevelChanged(true);
}
}
return FloatingWidget;
}
//============================================================================
void DockAreaTitleBarPrivate::startFloating(const QPoint& Offset)
{
FloatingWidget = makeAreaFloating(Offset, DraggingFloatingWidget);
} }
@@ -217,21 +339,35 @@ CDockAreaTitleBar::CDockAreaTitleBar(CDockAreaWidget* parent) :
d->DockArea = parent; d->DockArea = parent;
setObjectName("dockAreaTitleBar"); setObjectName("dockAreaTitleBar");
d->TopLayout = new QBoxLayout(QBoxLayout::LeftToRight); d->Layout = new QBoxLayout(QBoxLayout::LeftToRight);
d->TopLayout->setContentsMargins(0, 0, 0, 0); d->Layout->setContentsMargins(0, 0, 0, 0);
d->TopLayout->setSpacing(0); d->Layout->setSpacing(0);
setLayout(d->TopLayout); setLayout(d->Layout);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
d->createTabBar(); d->createTabBar();
d->Layout->addWidget(new CSpacerWidget(this));
d->createButtons(); d->createButtons();
} }
//============================================================================ //============================================================================
CDockAreaTitleBar::~CDockAreaTitleBar() CDockAreaTitleBar::~CDockAreaTitleBar()
{ {
if (!d->CloseButton.isNull())
{
delete d->CloseButton;
}
if (!d->TabsMenuButton.isNull())
{
delete d->TabsMenuButton;
}
if (!d->UndockButton.isNull())
{
delete d->UndockButton;
}
delete d; delete d;
} }
@@ -242,14 +378,31 @@ CDockAreaTabBar* CDockAreaTitleBar::tabBar() const
return d->TabBar; return d->TabBar;
} }
//============================================================================ //============================================================================
void CDockAreaTitleBar::markTabsMenuOutdated() void CDockAreaTitleBar::markTabsMenuOutdated()
{ {
if(DockAreaTitleBarPrivate::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility))
{
bool hasElidedTabTitle = false;
for (int i = 0; i < d->TabBar->count(); ++i)
{
if (!d->TabBar->isTabOpen(i))
{
continue;
}
CDockWidgetTab* Tab = d->TabBar->tab(i);
if(Tab->isTitleElided())
{
hasElidedTabTitle = true;
break;
}
}
bool visible = (hasElidedTabTitle && (d->TabBar->count() > 1));
QMetaObject::invokeMethod(d->TabsMenuButton, "setVisible", Qt::QueuedConnection, Q_ARG(bool, visible));
}
d->MenuOutdated = true; d->MenuOutdated = true;
} }
//============================================================================ //============================================================================
void CDockAreaTitleBar::onTabsMenuAboutToShow() void CDockAreaTitleBar::onTabsMenuAboutToShow()
{ {
@@ -268,9 +421,7 @@ void CDockAreaTitleBar::onTabsMenuAboutToShow()
} }
auto Tab = d->TabBar->tab(i); auto Tab = d->TabBar->tab(i);
QAction* Action = menu->addAction(Tab->icon(), Tab->text()); QAction* Action = menu->addAction(Tab->icon(), Tab->text());
#ifndef QT_NO_TOOLTIP internal::setToolTip(Action, Tab->toolTip());
Action->setToolTip(Tab->toolTip());
#endif
Action->setData(i); Action->setData(i);
} }
@@ -298,7 +449,7 @@ void CDockAreaTitleBar::onUndockButtonClicked()
{ {
if (d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable)) if (d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
{ {
d->TabBar->makeAreaFloating(mapFromGlobal(QCursor::pos()), DraggingInactive); d->makeAreaFloating(mapFromGlobal(QCursor::pos()), DraggingInactive);
} }
} }
@@ -312,6 +463,40 @@ void CDockAreaTitleBar::onTabsMenuActionTriggered(QAction* Action)
} }
//============================================================================
void CDockAreaTitleBar::updateDockWidgetActionsButtons()
{
CDockWidget* DockWidget = d->TabBar->currentTab()->dockWidget();
if (!d->DockWidgetActionsButtons.isEmpty())
{
for (auto Button : d->DockWidgetActionsButtons)
{
d->Layout->removeWidget(Button);
delete Button;
}
d->DockWidgetActionsButtons.clear();
}
auto Actions = DockWidget->titleBarActions();
if (Actions.isEmpty())
{
return;
}
int InsertIndex = indexOf(d->TabsMenuButton);
for (auto Action : Actions)
{
auto Button = new CTitleBarButton(true, this);
Button->setDefaultAction(Action);
Button->setAutoRaise(true);
Button->setPopupMode(QToolButton::InstantPopup);
Button->setObjectName(Action->objectName());
d->Layout->insertWidget(InsertIndex++, Button, 0);
d->DockWidgetActionsButtons.append(Button);
}
}
//============================================================================ //============================================================================
void CDockAreaTitleBar::onCurrentTabChanged(int Index) void CDockAreaTitleBar::onCurrentTabChanged(int Index)
{ {
@@ -325,6 +510,8 @@ void CDockAreaTitleBar::onCurrentTabChanged(int Index)
CDockWidget* DockWidget = d->TabBar->tab(Index)->dockWidget(); CDockWidget* DockWidget = d->TabBar->tab(Index)->dockWidget();
d->CloseButton->setEnabled(DockWidget->features().testFlag(CDockWidget::DockWidgetClosable)); d->CloseButton->setEnabled(DockWidget->features().testFlag(CDockWidget::DockWidgetClosable));
} }
updateDockWidgetActionsButtons();
} }
@@ -351,8 +538,113 @@ void CDockAreaTitleBar::setVisible(bool Visible)
//============================================================================ //============================================================================
void CDockAreaTitleBar::showContextMenu(const QPoint& pos) void CDockAreaTitleBar::mousePressEvent(QMouseEvent* ev)
{ {
if (ev->button() == Qt::LeftButton)
{
ev->accept();
d->DragStartMousePos = ev->pos();
d->DragState = DraggingMousePressed;
return;
}
Super::mousePressEvent(ev);
}
//============================================================================
void CDockAreaTitleBar::mouseReleaseEvent(QMouseEvent* ev)
{
if (ev->button() == Qt::LeftButton)
{
ADS_PRINT("CDockAreaTitleBar::mouseReleaseEvent");
ev->accept();
auto CurrentDragState = d->DragState;
d->DragStartMousePos = QPoint();
d->DragState = DraggingInactive;
if (DraggingFloatingWidget == CurrentDragState)
{
d->FloatingWidget->finishDragging();
}
return;
}
Super::mouseReleaseEvent(ev);
}
//============================================================================
void CDockAreaTitleBar::mouseMoveEvent(QMouseEvent* ev)
{
Super::mouseMoveEvent(ev);
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
{
d->DragState = DraggingInactive;
return;
}
// move floating window
if (d->isDraggingState(DraggingFloatingWidget))
{
d->FloatingWidget->moveFloating();
return;
}
// If this is the last dock area in a dock container it does not make
// sense to move it to a new floating widget and leave this one
// empty
if (d->DockArea->dockContainer()->isFloating()
&& d->DockArea->dockContainer()->visibleDockAreaCount() == 1)
{
return;
}
// If one single dock widget in this area is not floatable then the whole
// area is not floatable
if (!d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
{
return;
}
int DragDistance = (d->DragStartMousePos - ev->pos()).manhattanLength();
if (DragDistance >= CDockManager::startDragDistance())
{
ADS_PRINT("CTabsScrollArea::startFloating");
d->startFloating(d->DragStartMousePos);
auto Overlay = d->DockArea->dockManager()->containerOverlay();
Overlay->setAllowedAreas(OuterDockAreas);
}
return;
}
//============================================================================
void CDockAreaTitleBar::mouseDoubleClickEvent(QMouseEvent *event)
{
// If this is the last dock area in a dock container it does not make
// sense to move it to a new floating widget and leave this one
// empty
if (d->DockArea->dockContainer()->isFloating() && d->DockArea->dockContainer()->dockAreaCount() == 1)
{
return;
}
if (!d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
{
return;
}
d->makeAreaFloating(event->pos(), DraggingInactive);
}
//============================================================================
void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
{
ev->accept();
if (d->isDraggingState(DraggingFloatingWidget))
{
return;
}
QMenu Menu(this); QMenu Menu(this);
auto Action = Menu.addAction(tr("Detach Area"), this, SLOT(onUndockButtonClicked())); auto Action = Menu.addAction(tr("Detach Area"), this, SLOT(onUndockButtonClicked()));
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable)); Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
@@ -360,11 +652,27 @@ void CDockAreaTitleBar::showContextMenu(const QPoint& pos)
Action = Menu.addAction(tr("Close Area"), this, SLOT(onCloseButtonClicked())); Action = Menu.addAction(tr("Close Area"), this, SLOT(onCloseButtonClicked()));
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable)); Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
Menu.addAction(tr("Close Other Areas"), d->DockArea, SLOT(closeOtherAreas())); Menu.addAction(tr("Close Other Areas"), d->DockArea, SLOT(closeOtherAreas()));
Menu.exec(mapToGlobal(pos)); Menu.exec(ev->globalPos());
}
//============================================================================
void CDockAreaTitleBar::insertWidget(int index, QWidget *widget)
{
d->Layout->insertWidget(index, widget);
}
//============================================================================
int CDockAreaTitleBar::indexOf(QWidget *widget) const
{
return d->Layout->indexOf(widget);
} }
} // namespace ads } // namespace ads
#include "DockAreaTitleBar.moc"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// EOF DockAreaTitleBar.cpp // EOF DockAreaTitleBar.cpp

View File

@@ -60,7 +60,33 @@ private slots:
void onUndockButtonClicked(); void onUndockButtonClicked();
void onTabsMenuActionTriggered(QAction* Action); void onTabsMenuActionTriggered(QAction* Action);
void onCurrentTabChanged(int Index); void onCurrentTabChanged(int Index);
void showContextMenu(const QPoint& pos);
protected:
/**
* Stores mouse position to detect dragging
*/
virtual void mousePressEvent(QMouseEvent* ev) override;
/**
* Stores mouse position to detect dragging
*/
virtual void mouseReleaseEvent(QMouseEvent* ev) override;
/**
* Starts floating the complete docking area including all dock widgets,
* if it is not the last dock area in a floating widget
*/
virtual void mouseMoveEvent(QMouseEvent* ev) override;
/**
* Double clicking the title bar also starts floating of the complete area
*/
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
/**
* Show context menu
*/
virtual void contextMenuEvent(QContextMenuEvent *event);
public slots: public slots:
/** /**
@@ -72,6 +98,7 @@ public slots:
public: public:
using Super = QFrame; using Super = QFrame;
/** /**
* Default Constructor * Default Constructor
*/ */
@@ -92,12 +119,34 @@ public:
*/ */
QAbstractButton* button(TitleBarButton which) const; QAbstractButton* button(TitleBarButton which) const;
/**
* Updates the visibility of the dock widget actions in the title bar
*/
void updateDockWidgetActionsButtons();
/** /**
* Marks the tabs menu outdated before it calls its base class * Marks the tabs menu outdated before it calls its base class
* implementation * implementation
*/ */
virtual void setVisible(bool Visible) override; virtual void setVisible(bool Visible) override;
/**
* Inserts a custom widget at position index into this title bar.
* If index is negative, the widget is added at the end.
* You can use this function to insert custom widgets into the title bar.
*/
void insertWidget(int index, QWidget *widget);
/**
* Searches for widget widget in this title bar.
* You can use this function, to get the position of the default
* widget in the tile bar.
* \code
* int tabBarIndex = TitleBar->indexOf(TitleBar->tabBar());
* int closeButtonIndex = TitleBar->indexOf(TitleBar->button(TitleBarButtonClose));
* \endcode
*/
int indexOf(QWidget *widget) const;
signals: signals:
/** /**

View File

@@ -245,6 +245,7 @@ struct DockAreaWidgetPrivate
CDockAreaTitleBar* TitleBar = nullptr; CDockAreaTitleBar* TitleBar = nullptr;
CDockManager* DockManager = nullptr; CDockManager* DockManager = nullptr;
bool UpdateTitleBarButtons = false; bool UpdateTitleBarButtons = false;
DockWidgetAreas AllowedAreas = AllDockAreas;
/** /**
* Private data constructor * Private data constructor
@@ -337,6 +338,7 @@ void DockAreaWidgetPrivate::updateTitleBarButtonStates()
_this->features().testFlag(CDockWidget::DockWidgetClosable)); _this->features().testFlag(CDockWidget::DockWidgetClosable));
TitleBar->button(TitleBarButtonUndock)->setEnabled( TitleBar->button(TitleBarButtonUndock)->setEnabled(
_this->features().testFlag(CDockWidget::DockWidgetFloatable)); _this->features().testFlag(CDockWidget::DockWidgetFloatable));
TitleBar->updateDockWidgetActionsButtons();
UpdateTitleBarButtons = false; UpdateTitleBarButtons = false;
} }
@@ -354,6 +356,10 @@ CDockAreaWidget::CDockAreaWidget(CDockManager* DockManager, CDockContainerWidget
d->createTitleBar(); d->createTitleBar();
d->ContentsLayout = new DockAreaLayout(d->Layout); d->ContentsLayout = new DockAreaLayout(d->Layout);
if (d->DockManager)
{
emit d->DockManager->dockAreaCreated(this);
}
} }
//============================================================================ //============================================================================
@@ -487,7 +493,16 @@ void CDockAreaWidget::hideAreaWithNoVisibleContent()
void CDockAreaWidget::onTabCloseRequested(int Index) void CDockAreaWidget::onTabCloseRequested(int Index)
{ {
ADS_PRINT("CDockAreaWidget::onTabCloseRequested " << Index); ADS_PRINT("CDockAreaWidget::onTabCloseRequested " << Index);
dockWidget(Index)->toggleView(false); auto* DockWidget = dockWidget(Index);
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
{
//DockWidget->deleteDockWidget();
DockWidget->closeDockWidgetInternal();
}
else
{
DockWidget->toggleView(false);
}
} }
@@ -539,6 +554,13 @@ void CDockAreaWidget::setCurrentIndex(int index)
return; return;
} }
auto cw = d->ContentsLayout->currentWidget();
auto nw = d->ContentsLayout->widget(index);
if (cw == nw && !nw->isHidden())
{
return;
}
emit currentChanging(index); emit currentChanging(index);
TabBar->setCurrentIndex(index); TabBar->setCurrentIndex(index);
d->ContentsLayout->setCurrentIndex(index); d->ContentsLayout->setCurrentIndex(index);
@@ -682,6 +704,11 @@ void CDockAreaWidget::updateTitleBarVisibility()
return; return;
} }
if (CDockManager::configFlags().testFlag(CDockManager::AlwaysShowTabs))
{
return;
}
if (d->TitleBar) if (d->TitleBar)
{ {
d->TitleBar->setVisible(!Container->isFloating() || !Container->hasTopLevelDockWidget()); d->TitleBar->setVisible(!Container->isFloating() || !Container->hasTopLevelDockWidget());
@@ -745,15 +772,26 @@ CDockWidget* CDockAreaWidget::nextOpenDockWidget(CDockWidget* DockWidget) const
//============================================================================ //============================================================================
CDockWidget::DockWidgetFeatures CDockAreaWidget::features() const CDockWidget::DockWidgetFeatures CDockAreaWidget::features(eBitwiseOperator Mode) const
{ {
CDockWidget::DockWidgetFeatures Features(CDockWidget::AllDockWidgetFeatures); if (BitwiseAnd == Mode)
for (const auto DockWidget : dockWidgets())
{ {
Features &= DockWidget->features(); CDockWidget::DockWidgetFeatures Features(CDockWidget::AllDockWidgetFeatures);
for (const auto DockWidget : dockWidgets())
{
Features &= DockWidget->features();
}
return Features;
}
else
{
CDockWidget::DockWidgetFeatures Features(CDockWidget::NoDockWidgetFeatures);
for (const auto DockWidget : dockWidgets())
{
Features |= DockWidget->features();
}
return Features;
} }
return Features;
} }
@@ -776,6 +814,15 @@ void CDockAreaWidget::setVisible(bool Visible)
} }
} }
void CDockAreaWidget::setAllowedAreas(DockWidgetAreas areas)
{
d->AllowedAreas = areas;
}
DockWidgetAreas CDockAreaWidget::allowedAreas() const
{
return d->AllowedAreas;
}
//============================================================================ //============================================================================
QAbstractButton* CDockAreaWidget::titleBarButton(TitleBarButton which) const QAbstractButton* CDockAreaWidget::titleBarButton(TitleBarButton which) const
@@ -787,9 +834,19 @@ QAbstractButton* CDockAreaWidget::titleBarButton(TitleBarButton which) const
//============================================================================ //============================================================================
void CDockAreaWidget::closeArea() void CDockAreaWidget::closeArea()
{ {
for (auto DockWidget : openedDockWidgets()) // If there is only one single dock widget and this widget has the
// DeleteOnClose feature, then we delete the dock widget now
auto OpenDockWidgets = openedDockWidgets();
if (OpenDockWidgets.count() == 1 && OpenDockWidgets[0]->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
{ {
DockWidget->toggleView(false); OpenDockWidgets[0]->closeDockWidgetInternal();
}
else
{
for (auto DockWidget : openedDockWidgets())
{
DockWidget->toggleView(false);
}
} }
} }
@@ -799,6 +856,13 @@ void CDockAreaWidget::closeOtherAreas()
{ {
dockContainer()->closeOtherAreas(this); dockContainer()->closeOtherAreas(this);
} }
//============================================================================
CDockAreaTitleBar* CDockAreaWidget::titleBar() const
{
return d->TitleBar;
}
} // namespace ads } // namespace ads
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -44,6 +44,7 @@ struct DockAreaWidgetPrivate;
class CDockManager; class CDockManager;
class CDockContainerWidget; class CDockContainerWidget;
class DockContainerWidgetPrivate; class DockContainerWidgetPrivate;
class CDockAreaTitleBar;
/** /**
@@ -63,6 +64,7 @@ private:
friend struct DockWidgetPrivate; friend struct DockWidgetPrivate;
friend class CDockWidget; friend class CDockWidget;
friend struct DockManagerPrivate; friend struct DockManagerPrivate;
friend class CDockManager;
private slots: private slots:
void onTabCloseRequested(int Index); void onTabCloseRequested(int Index);
@@ -130,7 +132,6 @@ protected:
*/ */
void internalSetCurrentDockWidget(CDockWidget* DockWidget); void internalSetCurrentDockWidget(CDockWidget* DockWidget);
/** /**
* Marks tabs menu to update * Marks tabs menu to update
*/ */
@@ -238,10 +239,10 @@ public:
* A bitwise and is used to combine the flags of all dock widgets. That * A bitwise and is used to combine the flags of all dock widgets. That
* means, if only one single dock widget does not support a certain flag, * means, if only one single dock widget does not support a certain flag,
* the whole dock are does not support the flag. I.e. if one single * the whole dock are does not support the flag. I.e. if one single
* dock widget in this area is not closabe, the whole dock are is not * dock widget in this area is not closable, the whole dock are is not
* closable. * closable.
*/ */
CDockWidget::DockWidgetFeatures features() const; CDockWidget::DockWidgetFeatures features(eBitwiseOperator Mode = BitwiseAnd) const;
/** /**
* Returns the title bar button corresponding to the given title bar * Returns the title bar button corresponding to the given title bar
@@ -254,6 +255,21 @@ public:
*/ */
virtual void setVisible(bool Visible) override; virtual void setVisible(bool Visible) override;
/**
* Configures the areas of this particular dock area that are allowed for docking
*/
void setAllowedAreas(DockWidgetAreas areas);
/**
* Returns flags with all allowed drop areas of this particular dock area
*/
DockWidgetAreas allowedAreas() const;
/**
* Returns the title bar of this dock area
*/
CDockAreaTitleBar* titleBar() const;
public slots: public slots:
/** /**
* This activates the tab for the given tab index. * This activates the tab for the given tab index.

View File

@@ -42,6 +42,7 @@
#include "DockManager.h" #include "DockManager.h"
#include "DockAreaWidget.h" #include "DockAreaWidget.h"
#include "DockWidget.h" #include "DockWidget.h"
#include "DockingStateReader.h"
#include "FloatingDockContainer.h" #include "FloatingDockContainer.h"
#include "DockOverlay.h" #include "DockOverlay.h"
#include "ads_globals.h" #include "ads_globals.h"
@@ -81,6 +82,12 @@ namespace ads
{ {
static unsigned int zOrderCounter = 0; static unsigned int zOrderCounter = 0;
enum eDropMode
{
DropModeIntoArea,///< drop widget into a dock area
DropModeIntoContainer,///< drop into container
DropModeInvalid///< invalid mode - do not drop
};
/** /**
* Converts dock area ID to an index for array access * Converts dock area ID to an index for array access
@@ -164,12 +171,30 @@ public:
void dropIntoSection(CFloatingDockContainer* FloatingWidget, void dropIntoSection(CFloatingDockContainer* FloatingWidget,
CDockAreaWidget* TargetArea, DockWidgetArea area); CDockAreaWidget* TargetArea, DockWidgetArea area);
/**
* Moves the dock widget or dock area given in Widget parameter to a
* new dock widget area
*/
void moveToNewSection(QWidget* Widget, CDockAreaWidget* TargetArea, DockWidgetArea area);
/**
* Moves the dock widget or dock area given in Widget parameter to a
* a dock area in container
*/
void moveToContainer(QWidget* Widgett, DockWidgetArea area);
/** /**
* Creates a new tab for a widget dropped into the center of a section * Creates a new tab for a widget dropped into the center of a section
*/ */
void dropIntoCenterOfSection(CFloatingDockContainer* FloatingWidget, void dropIntoCenterOfSection(CFloatingDockContainer* FloatingWidget,
CDockAreaWidget* TargetArea); CDockAreaWidget* TargetArea);
/**
* Creates a new tab for a widget dropped into the center of a section
*/
void moveIntoCenterOfSection(QWidget* Widget, CDockAreaWidget* TargetArea);
/** /**
* Adds new dock areas to the internal dock area list * Adds new dock areas to the internal dock area list
*/ */
@@ -194,21 +219,21 @@ public:
* \param[in] Testing If Testing is true, only the stream data is * \param[in] Testing If Testing is true, only the stream data is
* parsed without modifiying anything. * parsed without modifiying anything.
*/ */
bool restoreChildNodes(QXmlStreamReader& Stream, QWidget*& CreatedWidget, bool restoreChildNodes(CDockingStateReader& Stream, QWidget*& CreatedWidget,
bool Testing); bool Testing);
/** /**
* Restores a splitter. * Restores a splitter.
* \see restoreChildNodes() for details * \see restoreChildNodes() for details
*/ */
bool restoreSplitter(QXmlStreamReader& Stream, QWidget*& CreatedWidget, bool restoreSplitter(CDockingStateReader& Stream, QWidget*& CreatedWidget,
bool Testing); bool Testing);
/** /**
* Restores a dock area. * Restores a dock area.
* \see restoreChildNodes() for details * \see restoreChildNodes() for details
*/ */
bool restoreDockArea(QXmlStreamReader& Stream, QWidget*& CreatedWidget, bool restoreDockArea(CDockingStateReader& Stream, QWidget*& CreatedWidget,
bool Testing); bool Testing);
/** /**
@@ -216,6 +241,11 @@ public:
*/ */
void dumpRecursive(int level, QWidget* widget); void dumpRecursive(int level, QWidget* widget);
/**
* Calculate the drop mode from the given target position
*/
eDropMode getDropMode(const QPoint& TargetPos);
/** /**
* Initializes the visible dock area count variable if it is not initialized * Initializes the visible dock area count variable if it is not initialized
* yet * yet
@@ -294,6 +324,46 @@ DockContainerWidgetPrivate::DockContainerWidgetPrivate(CDockContainerWidget* _pu
} }
//============================================================================
eDropMode DockContainerWidgetPrivate::getDropMode(const QPoint& TargetPos)
{
CDockAreaWidget* DockArea = _this->dockAreaAt(TargetPos);
auto dropArea = InvalidDockWidgetArea;
auto ContainerDropArea = DockManager->containerOverlay()->dropAreaUnderCursor();
if (DockArea)
{
auto dropOverlay = DockManager->dockAreaOverlay();
dropOverlay->setAllowedAreas(DockArea->allowedAreas());
dropArea = dropOverlay->showOverlay(DockArea);
if (ContainerDropArea != InvalidDockWidgetArea &&
ContainerDropArea != dropArea)
{
dropArea = InvalidDockWidgetArea;
}
if (dropArea != InvalidDockWidgetArea)
{
ADS_PRINT("Dock Area Drop Content: " << dropArea);
return DropModeIntoArea;
}
}
// mouse is over container
if (InvalidDockWidgetArea == dropArea)
{
dropArea = ContainerDropArea;
ADS_PRINT("Container Drop Content: " << dropArea);
if (dropArea != InvalidDockWidgetArea)
{
return DropModeIntoContainer;
}
}
return DropModeInvalid;
}
//============================================================================ //============================================================================
void DockContainerWidgetPrivate::onVisibleDockAreaCountChanged() void DockContainerWidgetPrivate::onVisibleDockAreaCountChanged()
{ {
@@ -322,8 +392,6 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
CDockContainerWidget* FloatingDockContainer = FloatingWidget->dockContainer(); CDockContainerWidget* FloatingDockContainer = FloatingWidget->dockContainer();
auto NewDockAreas = FloatingDockContainer->findChildren<CDockAreaWidget*>( auto NewDockAreas = FloatingDockContainer->findChildren<CDockAreaWidget*>(
QString(), Qt::FindChildrenRecursively); QString(), Qt::FindChildrenRecursively);
CDockWidget* SingleDroppedDockWidget = FloatingDockContainer->topLevelDockWidget();
CDockWidget* SingleDockWidget = _this->topLevelDockWidget();
QSplitter* Splitter = RootSplitter; QSplitter* Splitter = RootSplitter;
if (DockAreas.count() <= 1) if (DockAreas.count() <= 1)
@@ -359,9 +427,6 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
RootSplitter = Splitter; RootSplitter = Splitter;
addDockAreasToList(NewDockAreas); addDockAreasToList(NewDockAreas);
FloatingWidget->deleteLater();
CDockWidget::emitTopLevelEventForWidget(SingleDroppedDockWidget, false);
CDockWidget::emitTopLevelEventForWidget(SingleDockWidget, false);
// If we dropped the floating widget into the main dock container that does // If we dropped the floating widget into the main dock container that does
// not contain any dock widgets, then splitter is invisible and we need to // not contain any dock widgets, then splitter is invisible and we need to
@@ -404,7 +469,6 @@ void DockContainerWidgetPrivate::dropIntoCenterOfSection(
} }
} }
TargetArea->setCurrentIndex(NewCurrentIndex); TargetArea->setCurrentIndex(NewCurrentIndex);
FloatingWidget->deleteLater();
TargetArea->updateTitleBarVisibility(); TargetArea->updateTitleBarVisibility();
return; return;
} }
@@ -497,12 +561,133 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
TargetAreaSplitter->setSizes(Sizes); TargetAreaSplitter->setSizes(Sizes);
} }
FloatingWidget->deleteLater();
addDockAreasToList(NewDockAreas); addDockAreasToList(NewDockAreas);
_this->dumpLayout(); _this->dumpLayout();
} }
//============================================================================
void DockContainerWidgetPrivate::moveIntoCenterOfSection(QWidget* Widget, CDockAreaWidget* TargetArea)
{
auto DroppedDockWidget = qobject_cast<CDockWidget*>(Widget);
auto DroppedArea = qobject_cast<CDockAreaWidget*>(Widget);
if (DroppedDockWidget)
{
CDockAreaWidget* OldDockArea = DroppedDockWidget->dockAreaWidget();
if (OldDockArea)
{
OldDockArea->removeDockWidget(DroppedDockWidget);
}
TargetArea->insertDockWidget(0, DroppedDockWidget, true);
}
else
{
QList<CDockWidget*> NewDockWidgets = DroppedArea->dockWidgets();
int NewCurrentIndex = DroppedArea->currentIndex();
for (int i = 0; i < NewDockWidgets.count(); ++i)
{
CDockWidget* DockWidget = NewDockWidgets[i];
TargetArea->insertDockWidget(i, DockWidget, false);
}
TargetArea->setCurrentIndex(NewCurrentIndex);
DroppedArea->dockContainer()->removeDockArea(DroppedArea);
DroppedArea->deleteLater();
}
TargetArea->updateTitleBarVisibility();
return;
}
//============================================================================
void DockContainerWidgetPrivate::moveToNewSection(QWidget* Widget, CDockAreaWidget* TargetArea, DockWidgetArea area)
{
// Dropping into center means all dock widgets in the dropped floating
// widget will become tabs of the drop area
if (CenterDockWidgetArea == area)
{
moveIntoCenterOfSection(Widget, TargetArea);
return;
}
CDockWidget* DroppedDockWidget = qobject_cast<CDockWidget*>(Widget);
CDockAreaWidget* DroppedDockArea = qobject_cast<CDockAreaWidget*>(Widget);
CDockAreaWidget* NewDockArea;
if (DroppedDockWidget)
{
NewDockArea = new CDockAreaWidget(DockManager, _this);
CDockAreaWidget* OldDockArea = DroppedDockWidget->dockAreaWidget();
if (OldDockArea)
{
OldDockArea->removeDockWidget(DroppedDockWidget);
}
NewDockArea->addDockWidget(DroppedDockWidget);
}
else
{
DroppedDockArea->dockContainer()->removeDockArea(DroppedDockArea);
NewDockArea = DroppedDockArea;
}
auto InsertParam = internal::dockAreaInsertParameters(area);
QSplitter* TargetAreaSplitter = internal::findParent<QSplitter*>(TargetArea);
int AreaIndex = TargetAreaSplitter->indexOf(TargetArea);
auto Sizes = TargetAreaSplitter->sizes();
if (TargetAreaSplitter->orientation() == InsertParam.orientation())
{
int TargetAreaSize = (InsertParam.orientation() == Qt::Horizontal) ? TargetArea->width() : TargetArea->height();
TargetAreaSplitter->insertWidget(AreaIndex + InsertParam.insertOffset(), NewDockArea);
int Size = (TargetAreaSize - TargetAreaSplitter->handleWidth()) / 2;
Sizes[AreaIndex] = Size;
Sizes.insert(AreaIndex, Size);
}
else
{
auto Sizes = TargetAreaSplitter->sizes();
int TargetAreaSize = (InsertParam.orientation() == Qt::Horizontal) ? TargetArea->width() : TargetArea->height();
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
NewSplitter->addWidget(TargetArea);
insertWidgetIntoSplitter(NewSplitter, NewDockArea, InsertParam.append());
int Size = TargetAreaSize / 2;
NewSplitter->setSizes({Size, Size});
TargetAreaSplitter->insertWidget(AreaIndex, NewSplitter);
}
TargetAreaSplitter->setSizes(Sizes);
addDockAreasToList({NewDockArea});
}
//============================================================================
void DockContainerWidgetPrivate::moveToContainer(QWidget* Widget, DockWidgetArea area)
{
CDockWidget* DroppedDockWidget = qobject_cast<CDockWidget*>(Widget);
CDockAreaWidget* DroppedDockArea = qobject_cast<CDockAreaWidget*>(Widget);
CDockAreaWidget* NewDockArea;
if (DroppedDockWidget)
{
NewDockArea = new CDockAreaWidget(DockManager, _this);
CDockAreaWidget* OldDockArea = DroppedDockWidget->dockAreaWidget();
if (OldDockArea)
{
OldDockArea->removeDockWidget(DroppedDockWidget);
}
NewDockArea->addDockWidget(DroppedDockWidget);
}
else
{
DroppedDockArea->dockContainer()->removeDockArea(DroppedDockArea);
NewDockArea = DroppedDockArea;
}
addDockArea(NewDockArea, area);
LastAddedAreaCache[areaIdToIndex(area)] = NewDockArea;
}
//============================================================================ //============================================================================
void DockContainerWidgetPrivate::addDockAreasToList(const QList<CDockAreaWidget*> NewDockAreas) void DockContainerWidgetPrivate::addDockAreasToList(const QList<CDockAreaWidget*> NewDockAreas)
{ {
@@ -555,7 +740,7 @@ void DockContainerWidgetPrivate::saveChildNodesState(QXmlStreamWriter& s, QWidge
if (Splitter) if (Splitter)
{ {
s.writeStartElement("Splitter"); s.writeStartElement("Splitter");
s.writeAttribute("Orientation", (Splitter->orientation() == Qt::Horizontal) ? "-" : "|"); s.writeAttribute("Orientation", (Splitter->orientation() == Qt::Horizontal) ? "|" : "-");
s.writeAttribute("Count", QString::number(Splitter->count())); s.writeAttribute("Count", QString::number(Splitter->count()));
ADS_PRINT("NodeSplitter orient: " << Splitter->orientation() ADS_PRINT("NodeSplitter orient: " << Splitter->orientation()
<< " WidgetCont: " << Splitter->count()); << " WidgetCont: " << Splitter->count());
@@ -584,25 +769,30 @@ void DockContainerWidgetPrivate::saveChildNodesState(QXmlStreamWriter& s, QWidge
//============================================================================ //============================================================================
bool DockContainerWidgetPrivate::restoreSplitter(QXmlStreamReader& s, bool DockContainerWidgetPrivate::restoreSplitter(CDockingStateReader& s,
QWidget*& CreatedWidget, bool Testing) QWidget*& CreatedWidget, bool Testing)
{ {
bool Ok; bool Ok;
QString OrientationStr = s.attributes().value("Orientation").toString(); QString OrientationStr = s.attributes().value("Orientation").toString();
int Orientation;
if (OrientationStr.startsWith("-")) // Check if the orientation string is right
{ if (!OrientationStr.startsWith("|") && !OrientationStr.startsWith("-"))
Orientation = Qt::Horizontal;
}
else if (OrientationStr.startsWith("|"))
{
Orientation = Qt::Vertical;
}
else
{ {
return false; return false;
} }
// The "|" shall indicate a vertical splitter handle which in turn means
// a Horizontal orientation of the splitter layout.
bool HorizontalSplitter = OrientationStr.startsWith("|");
// In version 0 we had a small bug. The "|" indicated a vertical orientation,
// but this is wrong, because only the splitter handle is vertical, the
// layout of the splitter is a horizontal layout. We fix this here
if (s.fileVersion() == 0)
{
HorizontalSplitter = !HorizontalSplitter;
}
int Orientation = HorizontalSplitter ? Qt::Horizontal : Qt::Vertical;
int WidgetCount = s.attributes().value("Count").toInt(&Ok); int WidgetCount = s.attributes().value("Count").toInt(&Ok);
if (!Ok) if (!Ok)
{ {
@@ -691,7 +881,7 @@ bool DockContainerWidgetPrivate::restoreSplitter(QXmlStreamReader& s,
//============================================================================ //============================================================================
bool DockContainerWidgetPrivate::restoreDockArea(QXmlStreamReader& s, bool DockContainerWidgetPrivate::restoreDockArea(CDockingStateReader& s,
QWidget*& CreatedWidget, bool Testing) QWidget*& CreatedWidget, bool Testing)
{ {
bool Ok; bool Ok;
@@ -772,7 +962,7 @@ bool DockContainerWidgetPrivate::restoreDockArea(QXmlStreamReader& s,
//============================================================================ //============================================================================
bool DockContainerWidgetPrivate::restoreChildNodes(QXmlStreamReader& s, bool DockContainerWidgetPrivate::restoreChildNodes(CDockingStateReader& s,
QWidget*& CreatedWidget, bool Testing) QWidget*& CreatedWidget, bool Testing)
{ {
bool Result = true; bool Result = true;
@@ -848,9 +1038,7 @@ void DockContainerWidgetPrivate::addDockArea(CDockAreaWidget* NewDockArea, DockW
RootSplitter = NewSplitter; RootSplitter = NewSplitter;
} }
appendDockAreas({NewDockArea}); addDockAreasToList({NewDockArea});
NewDockArea->updateTitleBarVisibility();
emitDockAreasAdded();
} }
@@ -1194,16 +1382,17 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
const QPoint& TargetPos) const QPoint& TargetPos)
{ {
ADS_PRINT("CDockContainerWidget::dropFloatingWidget"); ADS_PRINT("CDockContainerWidget::dropFloatingWidget");
CDockWidget* SingleDroppedDockWidget = FloatingWidget->topLevelDockWidget();
CDockWidget* SingleDockWidget = topLevelDockWidget();
CDockAreaWidget* DockArea = dockAreaAt(TargetPos); CDockAreaWidget* DockArea = dockAreaAt(TargetPos);
auto dropArea = InvalidDockWidgetArea; auto dropArea = InvalidDockWidgetArea;
auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor(); auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor();
CDockWidget* FloatingTopLevelDockWidget = FloatingWidget->topLevelDockWidget(); bool Dropped = false;
CDockWidget* TopLevelDockWidget = topLevelDockWidget();
if (DockArea) if (DockArea)
{ {
auto dropOverlay = d->DockManager->dockAreaOverlay(); auto dropOverlay = d->DockManager->dockAreaOverlay();
dropOverlay->setAllowedAreas(AllDockAreas); dropOverlay->setAllowedAreas(DockArea->allowedAreas());
dropArea = dropOverlay->showOverlay(DockArea); dropArea = dropOverlay->showOverlay(DockArea);
if (ContainerDropArea != InvalidDockWidgetArea && if (ContainerDropArea != InvalidDockWidgetArea &&
ContainerDropArea != dropArea) ContainerDropArea != dropArea)
@@ -1215,6 +1404,7 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
{ {
ADS_PRINT("Dock Area Drop Content: " << dropArea); ADS_PRINT("Dock Area Drop Content: " << dropArea);
d->dropIntoSection(FloatingWidget, DockArea, dropArea); d->dropIntoSection(FloatingWidget, DockArea, dropArea);
Dropped = true;
} }
} }
@@ -1226,22 +1416,66 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
if (dropArea != InvalidDockWidgetArea) if (dropArea != InvalidDockWidgetArea)
{ {
d->dropIntoContainer(FloatingWidget, dropArea); d->dropIntoContainer(FloatingWidget, dropArea);
Dropped = true;
}
}
if (Dropped)
{
FloatingWidget->deleteLater();
// If we dropped a floating widget with only one single dock widget, then we
// drop a top level widget that changes from floating to docked now
CDockWidget::emitTopLevelEventForWidget(SingleDroppedDockWidget, false);
// If there was a top level widget before the drop, then it is not top
// level widget anymore
CDockWidget::emitTopLevelEventForWidget(SingleDockWidget, false);
}
}
//============================================================================
void CDockContainerWidget::dropWidget(QWidget* Widget, const QPoint& TargetPos)
{
ADS_PRINT("CDockContainerWidget::dropFloatingWidget");
CDockWidget* SingleDockWidget = topLevelDockWidget();
CDockAreaWidget* DockArea = dockAreaAt(TargetPos);
auto dropArea = InvalidDockWidgetArea;
auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor();
if (DockArea)
{
auto dropOverlay = d->DockManager->dockAreaOverlay();
dropOverlay->setAllowedAreas(DockArea->allowedAreas());
dropArea = dropOverlay->showOverlay(DockArea);
if (ContainerDropArea != InvalidDockWidgetArea &&
ContainerDropArea != dropArea)
{
dropArea = InvalidDockWidgetArea;
}
if (dropArea != InvalidDockWidgetArea)
{
ADS_PRINT("Dock Area Drop Content: " << dropArea);
d->moveToNewSection(Widget, DockArea, dropArea);
}
}
// mouse is over container
if (InvalidDockWidgetArea == dropArea)
{
dropArea = ContainerDropArea;
ADS_PRINT("Container Drop Content: " << dropArea);
if (dropArea != InvalidDockWidgetArea)
{
d->moveToContainer(Widget, dropArea);
} }
} }
// If there was a top level widget before the drop, then it is not top // If there was a top level widget before the drop, then it is not top
// level widget anymore // level widget anymore
if (TopLevelDockWidget) CDockWidget::emitTopLevelEventForWidget(SingleDockWidget, false);
{
TopLevelDockWidget->emitTopLevelChanged(false);
}
// If we drop a floating widget with only one single dock widget, then we
// drop a top level widget that changes from floating to docked now
if (FloatingTopLevelDockWidget)
{
FloatingTopLevelDockWidget->emitTopLevelChanged(false);
}
} }
@@ -1285,7 +1519,7 @@ void CDockContainerWidget::saveState(QXmlStreamWriter& s) const
//============================================================================ //============================================================================
bool CDockContainerWidget::restoreState(QXmlStreamReader& s, bool Testing) bool CDockContainerWidget::restoreState(CDockingStateReader& s, bool Testing)
{ {
bool IsFloating = s.attributes().value("Floating").toInt(); bool IsFloating = s.attributes().value("Floating").toInt();
ADS_PRINT("Restore CDockContainerWidget Floating" << IsFloating); ADS_PRINT("Restore CDockContainerWidget Floating" << IsFloating);
@@ -1306,7 +1540,7 @@ bool CDockContainerWidget::restoreState(QXmlStreamReader& s, bool Testing)
return false; return false;
} }
QByteArray GeometryString = s.readElementText(QXmlStreamReader::ErrorOnUnexpectedElement).toLocal8Bit(); QByteArray GeometryString = s.readElementText(CDockingStateReader::ErrorOnUnexpectedElement).toLocal8Bit();
QByteArray Geometry = QByteArray::fromHex(GeometryString); QByteArray Geometry = QByteArray::fromHex(GeometryString);
if (Geometry.isEmpty()) if (Geometry.isEmpty())
{ {
@@ -1479,10 +1713,23 @@ void CDockContainerWidget::closeOtherAreas(CDockAreaWidget* KeepOpenArea)
{ {
for (const auto DockArea : d->DockAreas) for (const auto DockArea : d->DockAreas)
{ {
if (DockArea != KeepOpenArea && DockArea->features().testFlag(CDockWidget::DockWidgetClosable)) if (DockArea == KeepOpenArea)
{ {
DockArea->closeArea(); continue;
} }
if (!DockArea->features(BitwiseAnd).testFlag(CDockWidget::DockWidgetClosable))
{
continue;
}
// We do not close areas with widgets with custom close handling
if (DockArea->features(BitwiseOr).testFlag(CDockWidget::CustomCloseHandling))
{
continue;
}
DockArea->closeArea();
} }
} }

View File

@@ -36,7 +36,7 @@
#include "DockWidget.h" #include "DockWidget.h"
class QXmlStreamWriter; class QXmlStreamWriter;
class QXmlStreamReader;
namespace ads namespace ads
{ {
@@ -47,6 +47,9 @@ class CDockManager;
struct DockManagerPrivate; struct DockManagerPrivate;
class CFloatingDockContainer; class CFloatingDockContainer;
struct FloatingDockContainerPrivate; struct FloatingDockContainerPrivate;
class CFloatingDragPreview;
struct FloatingDragPreviewPrivate;
class CDockingStateReader;
/** /**
* Container that manages a number of dock areas with single dock widgets * Container that manages a number of dock areas with single dock widgets
@@ -68,6 +71,9 @@ private:
friend class CFloatingDockContainer; friend class CFloatingDockContainer;
friend struct FloatingDockContainerPrivate; friend struct FloatingDockContainerPrivate;
friend class CDockWidget; friend class CDockWidget;
friend class CFloatingDragPreview;
friend struct FloatingDragPreviewPrivate;
protected: protected:
/** /**
* Handles activation events to update zOrderIndex * Handles activation events to update zOrderIndex
@@ -89,6 +95,11 @@ protected:
*/ */
void dropFloatingWidget(CFloatingDockContainer* FloatingWidget, const QPoint& TargetPos); void dropFloatingWidget(CFloatingDockContainer* FloatingWidget, const QPoint& TargetPos);
/**
* Drop a dock area or a dock widget given in widget parameter
*/
void dropWidget(QWidget* Widget, const QPoint& TargetPos);
/** /**
* Adds the given dock area to this container widget * Adds the given dock area to this container widget
*/ */
@@ -110,7 +121,7 @@ protected:
* stream but does not restore anything. You can use this check for * stream but does not restore anything. You can use this check for
* faulty files before you start restoring the state * faulty files before you start restoring the state
*/ */
bool restoreState(QXmlStreamReader& Stream, bool Testing); bool restoreState(CDockingStateReader& Stream, bool Testing);
/** /**
* This function returns the last added dock area widget for the given * This function returns the last added dock area widget for the given
@@ -119,14 +130,6 @@ protected:
*/ */
CDockAreaWidget* lastAddedDockAreaWidget(DockWidgetArea area) const; CDockAreaWidget* lastAddedDockAreaWidget(DockWidgetArea area) const;
/**
* This function returns true if this dock area has only one single
* visible dock widget.
* A top level widget is a real floating widget. Only the isFloating()
* function of top level widgets may returns true.
*/
bool hasTopLevelDockWidget() const;
/** /**
* If hasSingleVisibleDockWidget() returns true, this function returns the * If hasSingleVisibleDockWidget() returns true, this function returns the
* one and only visible dock widget. Otherwise it returns a nullptr. * one and only visible dock widget. Otherwise it returns a nullptr.
@@ -203,6 +206,14 @@ public:
*/ */
QList<CDockAreaWidget*> openedDockAreas() const; QList<CDockAreaWidget*> openedDockAreas() const;
/**
* This function returns true if this dock area has only one single
* visible dock widget.
* A top level widget is a real floating widget. Only the isFloating()
* function of top level widgets may returns true.
*/
bool hasTopLevelDockWidget() const;
/** /**
* Returns the number of dock areas in this container * Returns the number of dock areas in this container
*/ */

View File

@@ -42,7 +42,6 @@
#include <QFile> #include <QFile>
#include <QAction> #include <QAction>
#include <QXmlStreamWriter> #include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include <QSettings> #include <QSettings>
#include <QMenu> #include <QMenu>
#include <QApplication> #include <QApplication>
@@ -52,11 +51,14 @@
#include "DockWidget.h" #include "DockWidget.h"
#include "ads_globals.h" #include "ads_globals.h"
#include "DockAreaWidget.h" #include "DockAreaWidget.h"
#include "IconProvider.h"
#include "DockingStateReader.h"
namespace ads namespace ads
{ {
static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultConfig; static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultOpaqueConfig;
/** /**
* Private data class of CDockManager class (pimpl) * Private data class of CDockManager class (pimpl)
@@ -74,6 +76,7 @@ struct DockManagerPrivate
QMenu* ViewMenu; QMenu* ViewMenu;
CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted; CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted;
bool RestoringState = false; bool RestoringState = false;
QVector<CFloatingDockContainer*> UninitializedFloatingWidgets;
/** /**
* Private data constructor * Private data constructor
@@ -120,7 +123,7 @@ struct DockManagerPrivate
/** /**
* Restores the container with the given index * Restores the container with the given index
*/ */
bool restoreContainer(int Index, QXmlStreamReader& stream, bool Testing); bool restoreContainer(int Index, CDockingStateReader& stream, bool Testing);
/** /**
* Loads the stylesheet * Loads the stylesheet
@@ -160,7 +163,7 @@ void DockManagerPrivate::loadStylesheet()
//============================================================================ //============================================================================
bool DockManagerPrivate::restoreContainer(int Index, QXmlStreamReader& stream, bool Testing) bool DockManagerPrivate::restoreContainer(int Index, CDockingStateReader& stream, bool Testing)
{ {
if (Testing) if (Testing)
{ {
@@ -202,11 +205,13 @@ bool DockManagerPrivate::checkFormat(const QByteArray &state, int version)
bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int version, bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int version,
bool Testing) bool Testing)
{ {
Q_UNUSED(version);
if (state.isEmpty()) if (state.isEmpty())
{ {
return false; return false;
} }
QXmlStreamReader s(state); CDockingStateReader s(state);
s.readNextStartElement(); s.readNextStartElement();
if (s.name() != "QtAdvancedDockingSystem") if (s.name() != "QtAdvancedDockingSystem")
{ {
@@ -215,11 +220,12 @@ bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int versi
ADS_PRINT(s.attributes().value("Version")); ADS_PRINT(s.attributes().value("Version"));
bool ok; bool ok;
int v = s.attributes().value("Version").toInt(&ok); int v = s.attributes().value("Version").toInt(&ok);
if (!ok || v != version) if (!ok || v > CurrentVersion)
{ {
return false; return false;
} }
s.setFileVersion(v);
bool Result = true; bool Result = true;
#ifdef ADS_DEBUG_PRINT #ifdef ADS_DEBUG_PRINT
int DockContainers = s.attributes().value("Containers").toInt(); int DockContainers = s.attributes().value("Containers").toInt();
@@ -558,6 +564,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, CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area,
CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget) CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget)
@@ -604,8 +652,10 @@ CDockWidget* CDockManager::findDockWidget(const QString& ObjectName) const
//============================================================================ //============================================================================
void CDockManager::removeDockWidget(CDockWidget* Dockwidget) void CDockManager::removeDockWidget(CDockWidget* Dockwidget)
{ {
emit dockWidgetAboutToBeRemoved(Dockwidget);
d->DockWidgetsMap.remove(Dockwidget->objectName()); d->DockWidgetsMap.remove(Dockwidget->objectName());
CDockContainerWidget::removeDockWidget(Dockwidget); CDockContainerWidget::removeDockWidget(Dockwidget);
emit dockWidgetRemoved(Dockwidget);
} }
//============================================================================ //============================================================================
@@ -787,6 +837,20 @@ void CDockManager::setConfigFlag(eConfigFlag Flag, bool On)
internal::setFlag(StaticConfigFlags, Flag, On); internal::setFlag(StaticConfigFlags, Flag, On);
} }
//===========================================================================
bool CDockManager::testConfigFlag(eConfigFlag Flag)
{
return configFlags().testFlag(Flag);
}
//===========================================================================
CIconProvider& CDockManager::iconProvider()
{
static CIconProvider Instance;
return Instance;
}
} // namespace ads } // namespace ads

View File

@@ -30,10 +30,18 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include "DockContainerWidget.h" #include <ads_globals.h>
#include <QIcon> #include <DockContainerWidget.h>
#include <DockWidget.h>
#include "ads_globals.h" #include <FloatingDockContainer.h>
#include <qbytearray.h>
#include <qflags.h>
#include <qlist.h>
#include <qmap.h>
#include <qobjectdefs.h>
#include <qstring.h>
#include <qstringlist.h>
#include <QtGui/qicon.h>
class QSettings; class QSettings;
class QMenu; class QMenu;
@@ -44,11 +52,13 @@ struct DockManagerPrivate;
class CFloatingDockContainer; class CFloatingDockContainer;
struct FloatingDockContainerPrivate; struct FloatingDockContainerPrivate;
class CDockContainerWidget; class CDockContainerWidget;
class DockContainerWidgetPrivate;
class CDockOverlay; class CDockOverlay;
class CDockAreaTabBar; class CDockAreaTabBar;
class CDockWidgetTab; class CDockWidgetTab;
struct DockWidgetTabPrivate; struct DockWidgetTabPrivate;
struct DockAreaWidgetPrivate; struct DockAreaWidgetPrivate;
class CIconProvider;
/** /**
* The central dock manager that maintains the complete docking system. * The central dock manager that maintains the complete docking system.
@@ -71,10 +81,14 @@ private:
friend class CFloatingDockContainer; friend class CFloatingDockContainer;
friend struct FloatingDockContainerPrivate; friend struct FloatingDockContainerPrivate;
friend class CDockContainerWidget; friend class CDockContainerWidget;
friend class DockContainerWidgetPrivate;
friend class CDockAreaTabBar; friend class CDockAreaTabBar;
friend class CDockWidgetTab; friend class CDockWidgetTab;
friend struct DockAreaWidgetPrivate; friend struct DockAreaWidgetPrivate;
friend struct DockWidgetTabPrivate; friend struct DockWidgetTabPrivate;
friend class CFloatingDragPreview;
friend struct FloatingDragPreviewPrivate;
friend class CDockAreaTitleBar;
protected: protected:
/** /**
@@ -110,7 +124,14 @@ protected:
*/ */
CDockOverlay* dockAreaOverlay() const; CDockOverlay* dockAreaOverlay() const;
/**
* Show the floating widgets that has been created floating
*/
virtual void showEvent(QShowEvent *event) override;
public: public:
using Super = CDockContainerWidget;
enum eViewMenuInsertionOrder enum eViewMenuInsertionOrder
{ {
MenuSortedByInsertion, MenuSortedByInsertion,
@@ -125,14 +146,41 @@ public:
{ {
ActiveTabHasCloseButton = 0x0001, //!< If this flag is set, the active tab in a tab area has a close button ActiveTabHasCloseButton = 0x0001, //!< If this flag is set, the active tab in a tab area has a close button
DockAreaHasCloseButton = 0x0002, //!< If the flag is set each dock area has a close button DockAreaHasCloseButton = 0x0002, //!< If the flag is set each dock area has a close button
DockAreaCloseButtonClosesTab = 0x0004,//!< If the flag is set, the dock area close button closes the active tab, if not set, it closes the complete cock area DockAreaCloseButtonClosesTab = 0x0004,//!< If the flag is set, the dock area close button closes the active tab, if not set, it closes the complete dock area
OpaqueSplitterResize = 0x0008, //!< See QSplitter::setOpaqueResize() documentation OpaqueSplitterResize = 0x0008, //!< See QSplitter::setOpaqueResize() documentation
XmlAutoFormattingEnabled = 0x0010,//!< If enabled, the XML writer automatically adds line-breaks and indentation to empty sections between elements (ignorable whitespace). XmlAutoFormattingEnabled = 0x0010,//!< If enabled, the XML writer automatically adds line-breaks and indentation to empty sections between elements (ignorable whitespace).
XmlCompressionEnabled = 0x0020,//!< If enabled, the XML output will be compressed and is not human readable anymore XmlCompressionEnabled = 0x0020,//!< If enabled, the XML output will be compressed and is not human readable anymore
TabCloseButtonIsToolButton = 0x0040,//! If enabled the tab close buttons will be QToolButtons instead of QPushButtons - disabled by default TabCloseButtonIsToolButton = 0x0040,//! If enabled the tab close buttons will be QToolButtons instead of QPushButtons - disabled by default
AllTabsHaveCloseButton = 0x0080, //!< if this flag is set, then all tabs that are closable show a close button AllTabsHaveCloseButton = 0x0080, //!< if this flag is set, then all tabs that are closable show a close button
RetainTabSizeWhenCloseButtonHidden = 0x0100, //!< if this flag is set, the space for the close button is reserved even if the close button is not visible RetainTabSizeWhenCloseButtonHidden = 0x0100, //!< if this flag is set, the space for the close button is reserved even if the close button is not visible
DefaultConfig = ActiveTabHasCloseButton | DockAreaHasCloseButton | OpaqueSplitterResize | XmlCompressionEnabled, ///< the default configuration OpaqueUndocking = 0x0200,///< If enabled, the widgets are immediately undocked into floating widgets, if disabled, only a draw preview is undocked and the real undocking is deferred until the mouse is released
DragPreviewIsDynamic = 0x0400,///< If opaque undocking is disabled, this flag defines the behavior of the drag preview window, if this flag is enabled, the preview will be adjusted dynamically to the drop area
DragPreviewShowsContentPixmap = 0x0800,///< If opaque undocking is disabled, the created drag preview window shows a copy of the content of the dock widget / dock are that is dragged
DragPreviewHasWindowFrame = 0x1000,///< If opaque undocking is disabled, then this flag configures if the drag preview is frameless or looks like a real window
AlwaysShowTabs = 0x2000,///< If this option is enabled, the tab of a dock widget is always displayed - even if it is the only visible dock widget in a floating widget.
DockAreaHasUndockButton = 0x4000, //!< If the flag is set each dock area has an undock button
DockAreaHasTabsMenuButton = 0x8000, //!< If the flag is set each dock area has a tabs menu button
DockAreaHideDisabledButtons = 0x10000, //!< If the flag is set disabled dock area buttons will not appear on the tollbar at all (enabling them will bring them back)
DockAreaDynamicTabsMenuButtonVisibility = 0x20000, //!< If the flag is set dock area will disable a tabs menu button when there is only one tab in the area
DefaultDockAreaButtons = DockAreaHasCloseButton
| DockAreaHasUndockButton
| DockAreaHasTabsMenuButton,///< default configuration of dock area title bar buttons
DefaultBaseConfig = DefaultDockAreaButtons
| ActiveTabHasCloseButton
| XmlCompressionEnabled,///< default base configuration settings
DefaultOpaqueConfig = DefaultBaseConfig
| OpaqueSplitterResize
| OpaqueUndocking, ///< the default configuration with opaque operations - this may cause issues if ActiveX or Qt 3D windows are involved
DefaultNonOpaqueConfig = DefaultBaseConfig
| DragPreviewShowsContentPixmap, ///< the default configuration for non opaque operations
NonOpaqueWithWindowFrame = DefaultNonOpaqueConfig
| DragPreviewHasWindowFrame ///< the default configuration for non opaque operations that show a real window with frame
}; };
Q_DECLARE_FLAGS(ConfigFlags, eConfigFlag) Q_DECLARE_FLAGS(ConfigFlags, eConfigFlag)
@@ -166,6 +214,18 @@ public:
*/ */
static void setConfigFlag(eConfigFlag Flag, bool On = true); static void setConfigFlag(eConfigFlag Flag, bool On = true);
/**
* Returns true if the given config flag is set
*/
static bool testConfigFlag(eConfigFlag Flag);
/**
* Returns the global icon provider.
* The icon provider enables the use of custom icons in case using
* styleheets for icons is not an option.
*/
static CIconProvider& iconProvider();
/** /**
* Adds dockwidget into the given area. * Adds dockwidget into the given area.
* If DockAreaWidget is not null, then the area parameter indicates the area * If DockAreaWidget is not null, then the area parameter indicates the area
@@ -198,6 +258,12 @@ public:
CDockAreaWidget* addDockWidgetTabToArea(CDockWidget* Dockwidget, CDockAreaWidget* addDockWidgetTabToArea(CDockWidget* Dockwidget,
CDockAreaWidget* DockAreaWidget); 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 * Searches for a registered doc widget with the given ObjectName
* \return Return the found dock widget or nullptr if a dock widget with the * \return Return the found dock widget or nullptr if a dock widget with the
@@ -231,7 +297,7 @@ public:
* This function always return 0 because the main window is always behind * This function always return 0 because the main window is always behind
* any floating widget * any floating widget
*/ */
virtual unsigned int zOrderIndex() const; unsigned int zOrderIndex() const override;
/** /**
* Saves the current state of the dockmanger and all its dock widgets * Saves the current state of the dockmanger and all its dock widgets
@@ -241,7 +307,7 @@ public:
* The XmlMode XmlAutoFormattingDisabled is better if you would like to have * The XmlMode XmlAutoFormattingDisabled is better if you would like to have
* a more compact XML output - i.e. for storage in ini files. * a more compact XML output - i.e. for storage in ini files.
*/ */
QByteArray saveState(int version = 0) const; QByteArray saveState(int version = Version1) const;
/** /**
* Restores the state of this dockmanagers dockwidgets. * Restores the state of this dockmanagers dockwidgets.
@@ -250,7 +316,7 @@ public:
* returns false; otherwise, the state is restored, and this function * returns false; otherwise, the state is restored, and this function
* returns true. * returns true.
*/ */
bool restoreState(const QByteArray &state, int version = 0); bool restoreState(const QByteArray &state, int version = Version1);
/** /**
* Saves the current perspective to the internal list of perspectives. * Saves the current perspective to the internal list of perspectives.
@@ -383,6 +449,27 @@ signals:
* perspective * perspective
*/ */
void perspectiveOpened(const QString& PerspectiveName); void perspectiveOpened(const QString& PerspectiveName);
/**
* This signal is emitted, if a new DockArea has been created.
* An application can use this signal to set custom icons or custom
* tooltips for the DockArea buttons.
*/
void dockAreaCreated(CDockAreaWidget* DockArea);
/**
* This signal is emitted just before the given dock widget is removed
* from the
*/
void dockWidgetAboutToBeRemoved(CDockWidget* DockWidget);
/**
* This signal is emitted if a dock widget has been removed with the remove
* removeDockWidget() function.
* If this signal is emitted, the dock widget has been removed from the
* docking system but it is not deleted yet.
*/
void dockWidgetRemoved(CDockWidget* DockWidget);
}; // class DockManager }; // class DockManager
} // namespace ads } // namespace ads
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -52,7 +52,6 @@ struct DockOverlayPrivate
DockWidgetAreas AllowedAreas = InvalidDockWidgetArea; DockWidgetAreas AllowedAreas = InvalidDockWidgetArea;
CDockOverlayCross* Cross; CDockOverlayCross* Cross;
QPointer<QWidget> TargetWidget; QPointer<QWidget> TargetWidget;
QRect TargetRect;
DockWidgetArea LastLocation = InvalidDockWidgetArea; DockWidgetArea LastLocation = InvalidDockWidgetArea;
bool DropPreviewEnabled = true; bool DropPreviewEnabled = true;
CDockOverlay::eMode Mode = CDockOverlay::ModeDockAreaOverlay; CDockOverlay::eMode Mode = CDockOverlay::ModeDockAreaOverlay;
@@ -333,7 +332,11 @@ CDockOverlay::CDockOverlay(QWidget* parent, eMode Mode) :
{ {
d->Mode = Mode; d->Mode = Mode;
d->Cross = new CDockOverlayCross(this); d->Cross = new CDockOverlayCross(this);
#ifdef Q_OS_LINUX
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
#else
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint); setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
#endif
setWindowOpacity(1); setWindowOpacity(1);
setWindowTitle("DockOverlay"); setWindowTitle("DockOverlay");
setAttribute(Qt::WA_NoSystemBackground); setAttribute(Qt::WA_NoSystemBackground);
@@ -383,7 +386,8 @@ DockWidgetArea CDockOverlay::dropAreaUnderCursor() const
return Result; return Result;
} }
if (DockArea->titleBarGeometry().contains(DockArea->mapFromGlobal(QCursor::pos()))) if (DockArea->allowedAreas().testFlag(CenterDockWidgetArea)
&& DockArea->titleBarGeometry().contains(DockArea->mapFromGlobal(QCursor::pos())))
{ {
return CenterDockWidgetArea; return CenterDockWidgetArea;
} }
@@ -408,7 +412,6 @@ DockWidgetArea CDockOverlay::showOverlay(QWidget* target)
} }
d->TargetWidget = target; d->TargetWidget = target;
d->TargetRect = QRect();
d->LastLocation = InvalidDockWidgetArea; d->LastLocation = InvalidDockWidgetArea;
// Move it over the target. // Move it over the target.
@@ -427,8 +430,8 @@ void CDockOverlay::hideOverlay()
{ {
hide(); hide();
d->TargetWidget.clear(); d->TargetWidget.clear();
d->TargetRect = QRect();
d->LastLocation = InvalidDockWidgetArea; d->LastLocation = InvalidDockWidgetArea;
d->DropAreaRect = QRect();
} }
@@ -440,6 +443,13 @@ void CDockOverlay::enableDropPreview(bool Enable)
} }
//============================================================================
bool CDockOverlay::dropPreviewEnabled() const
{
return d->DropPreviewEnabled;
}
//============================================================================ //============================================================================
void CDockOverlay::paintEvent(QPaintEvent* event) void CDockOverlay::paintEvent(QPaintEvent* event)
{ {
@@ -568,7 +578,11 @@ CDockOverlayCross::CDockOverlayCross(CDockOverlay* overlay) :
d(new DockOverlayCrossPrivate(this)) d(new DockOverlayCrossPrivate(this))
{ {
d->DockOverlay = overlay; d->DockOverlay = overlay;
#ifdef Q_OS_LINUX
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
#else
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint); setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
#endif
setWindowTitle("DockOverlayCross"); setWindowTitle("DockOverlayCross");
setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_TranslucentBackground);

View File

@@ -97,6 +97,11 @@ public:
*/ */
void enableDropPreview(bool Enable); void enableDropPreview(bool Enable);
/**
* Returns true if drop preview is enabled
*/
bool dropPreviewEnabled() const;
/** /**
* The drop overlay rectangle for the target area * The drop overlay rectangle for the target area
*/ */

View File

@@ -31,6 +31,8 @@
#include "DockWidgetTab.h" #include "DockWidgetTab.h"
#include "DockWidget.h" #include "DockWidget.h"
#include <iostream>
#include <QBoxLayout> #include <QBoxLayout>
#include <QAction> #include <QAction>
#include <QSplitter> #include <QSplitter>
@@ -43,6 +45,10 @@
#include <QToolBar> #include <QToolBar>
#include <QXmlStreamWriter> #include <QXmlStreamWriter>
#include <QGuiApplication>
#include <QScreen>
#include <QWindow>
#include "DockContainerWidget.h" #include "DockContainerWidget.h"
#include "DockAreaWidget.h" #include "DockAreaWidget.h"
#include "DockManager.h" #include "DockManager.h"
@@ -62,7 +68,7 @@ struct DockWidgetPrivate
QBoxLayout* Layout = nullptr; QBoxLayout* Layout = nullptr;
QWidget* Widget = nullptr; QWidget* Widget = nullptr;
CDockWidgetTab* TabWidget = nullptr; CDockWidgetTab* TabWidget = nullptr;
CDockWidget::DockWidgetFeatures Features = CDockWidget::AllDockWidgetFeatures; CDockWidget::DockWidgetFeatures Features = CDockWidget::DefaultDockWidgetFeatures;
CDockManager* DockManager = nullptr; CDockManager* DockManager = nullptr;
CDockAreaWidget* DockArea = nullptr; CDockAreaWidget* DockArea = nullptr;
QAction* ToggleViewAction = nullptr; QAction* ToggleViewAction = nullptr;
@@ -74,6 +80,7 @@ struct DockWidgetPrivate
QSize ToolBarIconSizeDocked = QSize(16, 16); QSize ToolBarIconSizeDocked = QSize(16, 16);
QSize ToolBarIconSizeFloating = QSize(24, 24); QSize ToolBarIconSizeFloating = QSize(24, 24);
bool IsFloatingTopLevel = false; bool IsFloatingTopLevel = false;
QList<QAction*> TitleBarActions;
/** /**
* Private data constructor * Private data constructor
@@ -128,8 +135,8 @@ void DockWidgetPrivate::showDockWidget()
} }
else else
{ {
DockArea->toggleView(true);
DockArea->setCurrentDockWidget(_this); DockArea->setCurrentDockWidget(_this);
DockArea->toggleView(true);
TabWidget->show(); TabWidget->show();
QSplitter* Splitter = internal::findParent<QSplitter*>(DockArea); QSplitter* Splitter = internal::findParent<QSplitter*>(DockArea);
while (Splitter && !Splitter->isVisible()) while (Splitter && !Splitter->isVisible())
@@ -294,6 +301,7 @@ void CDockWidget::setFeatures(DockWidgetFeatures features)
return; return;
} }
d->Features = features; d->Features = features;
emit featuresChanged(d->Features);
d->TabWidget->onDockWidgetFeaturesChanged(); d->TabWidget->onDockWidgetFeaturesChanged();
} }
@@ -515,23 +523,39 @@ void CDockWidget::flagAsUnassigned()
//============================================================================ //============================================================================
bool CDockWidget::event(QEvent *e) bool CDockWidget::event(QEvent *e)
{ {
if (e->type() == QEvent::WindowTitleChange) switch (e->type())
{ {
const auto title = windowTitle(); case QEvent::Hide:
if (d->TabWidget) emit visibilityChanged(false);
break;
case QEvent::Show:
emit visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0);
break;
case QEvent::WindowTitleChange :
{ {
d->TabWidget->setText(title); const auto title = windowTitle();
if (d->TabWidget)
{
d->TabWidget->setText(title);
}
if (d->ToggleViewAction)
{
d->ToggleViewAction->setText(title);
}
if (d->DockArea)
{
d->DockArea->markTitleBarMenuOutdated();//update tabs menu
}
emit titleChanged(title);
} }
if (d->ToggleViewAction) break;
{
d->ToggleViewAction->setText(title); default:
} break;
if (d->DockArea)
{
d->DockArea->markTitleBarMenuOutdated();//update tabs menu
}
emit titleChanged(title);
} }
return Super::event(e); return Super::event(e);
} }
@@ -726,6 +750,88 @@ QSize CDockWidget::minimumSizeHint() const
} }
//============================================================================
void CDockWidget::setFloating()
{
if (isClosed())
{
return;
}
d->TabWidget->detachDockWidget();
}
//============================================================================
void CDockWidget::deleteDockWidget()
{
dockManager()->removeDockWidget(this);
deleteLater();
d->Closed = true;
}
//============================================================================
void CDockWidget::closeDockWidget()
{
closeDockWidgetInternal(true);
}
//============================================================================
bool CDockWidget::closeDockWidgetInternal(bool ForceClose)
{
if (!ForceClose)
{
emit closeRequested();
}
if (!ForceClose && features().testFlag(CDockWidget::CustomCloseHandling))
{
return false;
}
if (features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
{
// If the dock widget is floating, then we check if we also need to
// delete the floating widget
if (isFloating())
{
CFloatingDockContainer* FloatingWidget = internal::findParent<
CFloatingDockContainer*>(this);
if (FloatingWidget->dockWidgets().count() == 1)
{
FloatingWidget->deleteLater();
}
else
{
FloatingWidget->hide();
}
}
deleteDockWidget();
}
else
{
toggleView(false);
}
return true;
}
//============================================================================
void CDockWidget::setTitleBarActions(QList<QAction*> actions)
{
d->TitleBarActions = actions;
}
//============================================================================
QList<QAction*> CDockWidget::titleBarActions() const
{
return d->TitleBarActions;
}
} // namespace ads } // namespace ads
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -53,389 +53,451 @@ class CFloatingDockContainer;
*/ */
class ADS_EXPORT CDockWidget : public QFrame class ADS_EXPORT CDockWidget : public QFrame
{ {
Q_OBJECT Q_OBJECT
private: private:
DockWidgetPrivate* d; ///< private data (pimpl) DockWidgetPrivate* d; ///< private data (pimpl)
friend struct DockWidgetPrivate; friend struct DockWidgetPrivate;
private slots: private slots:
/** /**
* Adjusts the toolbar icon sizes according to the floating state * Adjusts the toolbar icon sizes according to the floating state
*/ */
void setToolbarFloatingStyle(bool topLevel); void setToolbarFloatingStyle(bool topLevel);
protected: protected:
friend class CDockContainerWidget; friend class CDockContainerWidget;
friend class CDockAreaWidget; friend class CDockAreaWidget;
friend class CFloatingDockContainer; friend class CFloatingDockContainer;
friend class CDockManager; friend class CDockManager;
friend struct DockManagerPrivate; friend struct DockManagerPrivate;
friend class DockContainerWidgetPrivate; friend class DockContainerWidgetPrivate;
friend class CDockAreaTabBar; friend class CDockAreaTabBar;
friend class CDockWidgetTab; friend class CDockWidgetTab;
friend struct DockWidgetTabPrivate; friend struct DockWidgetTabPrivate;
friend struct DockAreaTitleBarPrivate;
/** /**
* Assigns the dock manager that manages this dock widget * Assigns the dock manager that manages this dock widget
*/ */
void setDockManager(CDockManager* DockManager); void setDockManager(CDockManager* DockManager);
/** /**
* If this dock widget is inserted into a dock area, the dock area will * If this dock widget is inserted into a dock area, the dock area will
* be registered on this widget via this function. If a dock widget is * be registered on this widget via this function. If a dock widget is
* removed from a dock area, this function will be called with nullptr * removed from a dock area, this function will be called with nullptr
* value. * value.
*/ */
void setDockArea(CDockAreaWidget* DockArea); void setDockArea(CDockAreaWidget* DockArea);
/** /**
* This function changes the toggle view action without emitting any * This function changes the toggle view action without emitting any
* signal * signal
*/ */
void setToggleViewActionChecked(bool Checked); void setToggleViewActionChecked(bool Checked);
/** /**
* Saves the state into the given stream * Saves the state into the given stream
*/ */
void saveState(QXmlStreamWriter& Stream) const; void saveState(QXmlStreamWriter& Stream) const;
/** /**
* This is a helper function for the dock manager to flag this widget * This is a helper function for the dock manager to flag this widget
* as unassigned. * as unassigned.
* When calling the restore function, it may happen, that the saved state * When calling the restore function, it may happen, that the saved state
* contains less dock widgets then currently available. All widgets whose * contains less dock widgets then currently available. All widgets whose
* data is not contained in the saved state, are flagged as unassigned * data is not contained in the saved state, are flagged as unassigned
* after the restore process. If the user shows an unassigned dock widget, * after the restore process. If the user shows an unassigned dock widget,
* a floating widget will be created to take up the dock widget. * a floating widget will be created to take up the dock widget.
*/ */
void flagAsUnassigned(); void flagAsUnassigned();
/** /**
* Call this function to emit a topLevelChanged() signal and to update * Call this function to emit a topLevelChanged() signal and to update
* the dock area tool bar visibility * the dock area tool bar visibility
*/ */
static void emitTopLevelEventForWidget(CDockWidget* TopLevelDockWidget, bool Floating); static void emitTopLevelEventForWidget(CDockWidget* TopLevelDockWidget, bool Floating);
/** /**
* Use this function to emit a top level changed event. * Use this function to emit a top level changed event.
* Do never use emit topLevelChanged(). Always use this function because * Do never use emit topLevelChanged(). Always use this function because
* it only emits a signal if the floating state has really changed * it only emits a signal if the floating state has really changed
*/ */
void emitTopLevelChanged(bool Floating); void emitTopLevelChanged(bool Floating);
/** /**
* Internal function for modifying the closed state when restoring * Internal function for modifying the closed state when restoring
* a saved docking state * a saved docking state
*/ */
void setClosedState(bool Closed); void setClosedState(bool Closed);
/** /**
* Internal toggle view function that does not check if the widget * Internal toggle view function that does not check if the widget
* already is in the given state * already is in the given state
*/ */
void toggleViewInternal(bool Open); void toggleViewInternal(bool Open);
/**
* Internal close dock widget implementation.
* The function returns true if the dock widget has been closed or hidden
*/
bool closeDockWidgetInternal(bool ForceClose = false);
public: public:
using Super = QFrame; using Super = QFrame;
enum DockWidgetFeature enum DockWidgetFeature
{ {
DockWidgetClosable = 0x01, DockWidgetClosable = 0x01,
DockWidgetMovable = 0x02,///< this feature is not properly implemented yet and is ignored DockWidgetMovable = 0x02,///< this feature is not properly implemented yet and is ignored
DockWidgetFloatable = 0x04, DockWidgetFloatable = 0x04,
AllDockWidgetFeatures = DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable, DockWidgetDeleteOnClose = 0x08, ///< deletes the dock widget when it is closed
NoDockWidgetFeatures = 0x00 CustomCloseHandling = 0x10,
}; DefaultDockWidgetFeatures = DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable,
Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature) AllDockWidgetFeatures = DefaultDockWidgetFeatures | DockWidgetDeleteOnClose | CustomCloseHandling,
NoDockWidgetFeatures = 0x00
};
Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)
enum eState enum eState
{ {
StateHidden, StateHidden,
StateDocked, StateDocked,
StateFloating StateFloating
}; };
/** /**
* Sets the widget for the dock widget to widget. * Sets the widget for the dock widget to widget.
* The InsertMode defines how the widget is inserted into the dock widget. * The InsertMode defines how the widget is inserted into the dock widget.
* The content of a dock widget should be resizable do a very small size to * The content of a dock widget should be resizable do a very small size to
* prevent the dock widget from blocking the resizing. To ensure, that a * prevent the dock widget from blocking the resizing. To ensure, that a
* dock widget can be resized very well, it is better to insert the content+ * dock widget can be resized very well, it is better to insert the content+
* widget into a scroll area or to provide a widget that is already a scroll * widget into a scroll area or to provide a widget that is already a scroll
* area or that contains a scroll area. * area or that contains a scroll area.
* If the InsertMode is AutoScrollArea, the DockWidget tries to automatically * If the InsertMode is AutoScrollArea, the DockWidget tries to automatically
* detect how to insert the given widget. If the widget is derived from * detect how to insert the given widget. If the widget is derived from
* QScrollArea (i.e. an QAbstractItemView), then the widget is inserted * QScrollArea (i.e. an QAbstractItemView), then the widget is inserted
* directly. If the given widget is not a scroll area, the widget will be * directly. If the given widget is not a scroll area, the widget will be
* inserted into a scroll area. * inserted into a scroll area.
* To force insertion into a scroll area, you can also provide the InsertMode * To force insertion into a scroll area, you can also provide the InsertMode
* ForceScrollArea. To prevent insertion into a scroll area, you can * ForceScrollArea. To prevent insertion into a scroll area, you can
* provide the InsertMode ForceNoScrollArea * provide the InsertMode ForceNoScrollArea
*/ */
enum eInsertMode enum eInsertMode
{ {
AutoScrollArea, AutoScrollArea,
ForceScrollArea, ForceScrollArea,
ForceNoScrollArea ForceNoScrollArea
}; };
/** /**
* This mode configures the behavior of the toggle view action. * This mode configures the behavior of the toggle view action.
* If the mode if ActionModeToggle, then the toggle view action is * If the mode if ActionModeToggle, then the toggle view action is
* a checkable action to show / hide the dock widget. If the mode * a checkable action to show / hide the dock widget. If the mode
* is ActionModeShow, then the action is not checkable an it will * is ActionModeShow, then the action is not checkable an it will
* always show the dock widget if clicked. If the mode is ActionModeShow, * always show the dock widget if clicked. If the mode is ActionModeShow,
* the user can only close the DockWidget with the close button. * the user can only close the DockWidget with the close button.
*/ */
enum eToggleViewActionMode enum eToggleViewActionMode
{ {
ActionModeToggle,//!< ActionModeToggle ActionModeToggle,//!< ActionModeToggle
ActionModeShow //!< ActionModeShow ActionModeShow //!< ActionModeShow
}; };
/** /**
* This constructor creates a dock widget with the given title. * This constructor creates a dock widget with the given title.
* The title is the text that is shown in the window title when the dock * The title is the text that is shown in the window title when the dock
* widget is floating and it is the title that is shown in the titlebar * widget is floating and it is the title that is shown in the titlebar
* or the tab of this dock widget if it is tabified. * or the tab of this dock widget if it is tabified.
* The object name of the dock widget is also set to the title. The * The object name of the dock widget is also set to the title. The
* object name is required by the dock manager to properly save and restore * object name is required by the dock manager to properly save and restore
* the state of the dock widget. That means, the title needs to be unique. * the state of the dock widget. That means, the title needs to be unique.
* If your title is not unique or if you would like to change the title * If your title is not unique or if you would like to change the title
* during runtime, you need to set a unique object name explicitely * during runtime, you need to set a unique object name explicitely
* by calling setObjectName() after construction. * by calling setObjectName() after construction.
* Use the layoutFlags to configure the layout of the dock widget. * Use the layoutFlags to configure the layout of the dock widget.
*/ */
CDockWidget(const QString &title, QWidget* parent = 0); CDockWidget(const QString &title, QWidget* parent = 0);
/** /**
* Virtual Destructor * Virtual Destructor
*/ */
virtual ~CDockWidget(); virtual ~CDockWidget();
/** /**
* We return a fixed minimum size hint for all dock widgets * We return a fixed minimum size hint for all dock widgets
*/ */
virtual QSize minimumSizeHint() const override; virtual QSize minimumSizeHint() const override;
/** /**
* Sets the widget for the dock widget to widget. * Sets the widget for the dock widget to widget.
* The InsertMode defines how the widget is inserted into the dock widget. * The InsertMode defines how the widget is inserted into the dock widget.
* The content of a dock widget should be resizable do a very small size to * The content of a dock widget should be resizable do a very small size to
* prevent the dock widget from blocking the resizing. To ensure, that a * prevent the dock widget from blocking the resizing. To ensure, that a
* dock widget can be resized very well, it is better to insert the content+ * dock widget can be resized very well, it is better to insert the content+
* widget into a scroll area or to provide a widget that is already a scroll * widget into a scroll area or to provide a widget that is already a scroll
* area or that contains a scroll area. * area or that contains a scroll area.
* If the InsertMode is AutoScrollArea, the DockWidget tries to automatically * If the InsertMode is AutoScrollArea, the DockWidget tries to automatically
* detect how to insert the given widget. If the widget is derived from * detect how to insert the given widget. If the widget is derived from
* QScrollArea (i.e. an QAbstractItemView), then the widget is inserted * QScrollArea (i.e. an QAbstractItemView), then the widget is inserted
* directly. If the given widget is not a scroll area, the widget will be * directly. If the given widget is not a scroll area, the widget will be
* inserted into a scroll area. * inserted into a scroll area.
* To force insertion into a scroll area, you can also provide the InsertMode * To force insertion into a scroll area, you can also provide the InsertMode
* ForceScrollArea. To prevent insertion into a scroll area, you can * ForceScrollArea. To prevent insertion into a scroll area, you can
* provide the InsertMode ForceNoScrollArea * provide the InsertMode ForceNoScrollArea
*/ */
void setWidget(QWidget* widget, eInsertMode InsertMode = AutoScrollArea); void setWidget(QWidget* widget, eInsertMode InsertMode = AutoScrollArea);
/** /**
* Remove the widget from the dock and give ownership back to the caller * Remove the widget from the dock and give ownership back to the caller
*/ */
QWidget* takeWidget(); QWidget* takeWidget();
/** /**
* Returns the widget for the dock widget. This function returns zero if * Returns the widget for the dock widget. This function returns zero if
* the widget has not been set. * the widget has not been set.
*/ */
QWidget* widget() const; QWidget* widget() const;
/** /**
* Returns the title bar widget of this dock widget * Returns the tab widget of this dock widget that is shown in the dock
*/ * area title bar
CDockWidgetTab* tabWidget() const; */
CDockWidgetTab* tabWidget() const;
/** /**
* Sets, whether the dock widget is movable, closable, and floatable. * Sets, whether the dock widget is movable, closable, and floatable.
*/ */
void setFeatures(DockWidgetFeatures features); void setFeatures(DockWidgetFeatures features);
/** /**
* Sets the feature flag for this dock widget if on is true; otherwise * Sets the feature flag for this dock widget if on is true; otherwise
* clears the flag. * clears the flag.
*/ */
void setFeature(DockWidgetFeature flag, bool on); void setFeature(DockWidgetFeature flag, bool on);
/** /**
* This property holds whether the dock widget is movable, closable, and * This property holds whether the dock widget is movable, closable, and
* floatable. * floatable.
* By default, this property is set to a combination of DockWidgetClosable, * By default, this property is set to a combination of DockWidgetClosable,
* DockWidgetMovable and DockWidgetFloatable. * DockWidgetMovable and DockWidgetFloatable.
*/ */
DockWidgetFeatures features() const; DockWidgetFeatures features() const;
/** /**
* Returns the dock manager that manages the dock widget or 0 if the widget * Returns the dock manager that manages the dock widget or 0 if the widget
* has not been assigned to any dock manager yet * has not been assigned to any dock manager yet
*/ */
CDockManager* dockManager() const; CDockManager* dockManager() const;
/** /**
* Returns the dock container widget this dock area widget belongs to or 0 * Returns the dock container widget this dock area widget belongs to or 0
* if this dock widget has not been docked yet * if this dock widget has not been docked yet
*/ */
CDockContainerWidget* dockContainer() const; CDockContainerWidget* dockContainer() const;
/** /**
* Returns the dock area widget this dock widget belongs to or 0 * Returns the dock area widget this dock widget belongs to or 0
* if this dock widget has not been docked yet * if this dock widget has not been docked yet
*/ */
CDockAreaWidget* dockAreaWidget() const; CDockAreaWidget* dockAreaWidget() const;
/** /**
* This property holds whether the dock widget is floating. * This property holds whether the dock widget is floating.
* A dock widget is only floating, if it is the one and only widget inside * A dock widget is only floating, if it is the one and only widget inside
* of a floating container. If there are more than one dock widget in a * of a floating container. If there are more than one dock widget in a
* floating container, the all dock widgets are docked and not floating. * floating container, the all dock widgets are docked and not floating.
*/ */
bool isFloating() const; bool isFloating() const;
/** /**
* This function returns true, if this dock widget is in a floating. * This function returns true, if this dock widget is in a floating.
* The function returns true, if the dock widget is floating and it also * The function returns true, if the dock widget is floating and it also
* returns true if it is docked inside of a floating container. * returns true if it is docked inside of a floating container.
*/ */
bool isInFloatingContainer() const; bool isInFloatingContainer() const;
/** /**
* Returns true, if this dock widget is closed. * Returns true, if this dock widget is closed.
*/ */
bool isClosed() const; bool isClosed() const;
/** /**
* Returns a checkable action that can be used to show or close this dock widget. * Returns a checkable action that can be used to show or close this dock widget.
* The action's text is set to the dock widget's window title. * The action's text is set to the dock widget's window title.
*/ */
QAction* toggleViewAction() const; QAction* toggleViewAction() const;
/** /**
* Configures the behavior of the toggle view action. * Configures the behavior of the toggle view action.
* \see eToggleViewActionMode for a detailed description * \see eToggleViewActionMode for a detailed description
*/ */
void setToggleViewActionMode(eToggleViewActionMode Mode); void setToggleViewActionMode(eToggleViewActionMode Mode);
/** /**
* Sets the dock widget icon that is shown in tabs and in toggle view * Sets the dock widget icon that is shown in tabs and in toggle view
* actions * actions
*/ */
void setIcon(const QIcon& Icon); void setIcon(const QIcon& Icon);
/** /**
* Returns the icon that has been assigned to the dock widget * Returns the icon that has been assigned to the dock widget
*/ */
QIcon icon() const; QIcon icon() const;
/** /**
* If the WithToolBar layout flag is enabled, then this function returns * If the WithToolBar layout flag is enabled, then this function returns
* the dock widget toolbar. If the flag is disabled, the function returns * the dock widget toolbar. If the flag is disabled, the function returns
* a nullptr. * a nullptr.
* This function returns the dock widget top tool bar. * This function returns the dock widget top tool bar.
* If no toolbar is assigned, this function returns nullptr. To get a vaild * If no toolbar is assigned, this function returns nullptr. To get a vaild
* toolbar you either need to create a default empty toolbar via * toolbar you either need to create a default empty toolbar via
* createDefaultToolBar() function or you need to assign you custom * createDefaultToolBar() function or you need to assign you custom
* toolbar via setToolBar(). * toolbar via setToolBar().
*/ */
QToolBar* toolBar() const; QToolBar* toolBar() const;
/** /**
* If you would like to use the default top tool bar, then call this * If you would like to use the default top tool bar, then call this
* function to create the default tool bar. * function to create the default tool bar.
* After this function the toolBar() function will return a valid toolBar() * After this function the toolBar() function will return a valid toolBar()
* object. * object.
*/ */
QToolBar* createDefaultToolBar(); QToolBar* createDefaultToolBar();
/** /**
* Assign a new tool bar that is shown above the content widget. * Assign a new tool bar that is shown above the content widget.
* The dock widget will become the owner of the tool bar and deletes it * The dock widget will become the owner of the tool bar and deletes it
* on destruction * on destruction
*/ */
void setToolBar(QToolBar* ToolBar); void setToolBar(QToolBar* ToolBar);
/** /**
* This function sets the tool button style for the given dock widget state. * This function sets the tool button style for the given dock widget state.
* It is possible to switch the tool button style depending on the state. * It is possible to switch the tool button style depending on the state.
* If a dock widget is floating, then here are more space and it is * If a dock widget is floating, then here are more space and it is
* possible to select a style that requires more space like * possible to select a style that requires more space like
* Qt::ToolButtonTextUnderIcon. For the docked state Qt::ToolButtonIconOnly * Qt::ToolButtonTextUnderIcon. For the docked state Qt::ToolButtonIconOnly
* might be better. * might be better.
*/ */
void setToolBarStyle(Qt::ToolButtonStyle Style, eState State); void setToolBarStyle(Qt::ToolButtonStyle Style, eState State);
/** /**
* Returns the tool button style for the given docking state. * Returns the tool button style for the given docking state.
* \see setToolBarStyle() * \see setToolBarStyle()
*/ */
Qt::ToolButtonStyle toolBarStyle(eState State) const; Qt::ToolButtonStyle toolBarStyle(eState State) const;
/** /**
* This function sets the tool button icon size for the given state. * This function sets the tool button icon size for the given state.
* If a dock widget is floating, there is more space an increasing the * If a dock widget is floating, there is more space an increasing the
* icon size is possible. For docked widgets, small icon sizes, eg. 16 x 16 * icon size is possible. For docked widgets, small icon sizes, eg. 16 x 16
* might be better. * might be better.
*/ */
void setToolBarIconSize(const QSize& IconSize, eState State); void setToolBarIconSize(const QSize& IconSize, eState State);
/** /**
* Returns the icon size for a given docking state. * Returns the icon size for a given docking state.
* \see setToolBarIconSize() * \see setToolBarIconSize()
*/ */
QSize toolBarIconSize(eState State) const; QSize toolBarIconSize(eState State) const;
/**
* Set the actions that will be shown in the dock area title bar
* if this dock widget is the active tab.
* You should not add to many actions to the title bar, because this
* will remove the available space for the tabs. If you have a number
* of actions, just add an action with a menu to show a popup menu
* button in the title bar.
*/
void setTitleBarActions(QList<QAction*> actions);
/**
* Returns a list of actions that will be inserted into the dock area title
* bar if this dock widget becomes the current widget
*/
virtual QList<QAction*> titleBarActions() const;
#ifndef QT_NO_TOOLTIP #ifndef QT_NO_TOOLTIP
/** /**
* This is function sets text tooltip for title bar widget * This is function sets text tooltip for title bar widget
* and tooltip for toggle view action * and tooltip for toggle view action
*/ */
void setTabToolTip(const QString &text); void setTabToolTip(const QString &text);
#endif #endif
public: // reimplements QFrame ----------------------------------------------- public: // reimplements QFrame -----------------------------------------------
/** /**
* Emits titleChanged signal if title change event occurs * Emits titleChanged signal if title change event occurs
*/ */
virtual bool event(QEvent *e) override; virtual bool event(QEvent *e) override;
public slots: public slots:
/** /**
* This property controls whether the dock widget is open or closed. * This property controls whether the dock widget is open or closed.
* The toogleViewAction triggers this slot * The toogleViewAction triggers this slot
*/ */
void toggleView(bool Open = true); void toggleView(bool Open = true);
/**
* This function will make a docked widget floating
*/
void setFloating();
/**
* This function will delete the dock widget and its content from the
* docking system
*/
void deleteDockWidget();
/**
* Closes the dock widget
*/
void closeDockWidget();
signals: signals:
/** /**
* This signal is emitted if the dock widget is opened or closed * This signal is emitted if the dock widget is opened or closed
*/ */
void viewToggled(bool Open); void viewToggled(bool Open);
/** /**
* This signal is emitted if the dock widget is closed * This signal is emitted if the dock widget is closed
*/ */
void closed(); void closed();
/** /**
* This signal is emitted if the window title of this dock widget * This signal is emitted if the window title of this dock widget
* changed * changed
*/ */
void titleChanged(const QString& Title); void titleChanged(const QString& Title);
/** /**
* This signal is emitted when the floating property changes. * This signal is emitted when the floating property changes.
* The topLevel parameter is true if the dock widget is now floating; * The topLevel parameter is true if the dock widget is now floating;
* otherwise it is false. * otherwise it is false.
*/ */
void topLevelChanged(bool topLevel); void topLevelChanged(bool topLevel);
/**
* This signal is emitted, if close is requested
*/
void closeRequested();
/**
* This signal is emitted when the dock widget becomes visible (or invisible).
* This happens when the widget is hidden or shown, as well as when it is
* docked in a tabbed dock area and its tab becomes selected or unselected.
*/
void visibilityChanged(bool visible);
/**
* This signal is emitted when the features property changes.
* The features parameter gives the new value of the property.
*/
void featuresChanged(DockWidgetFeatures features);
}; // class DockWidget }; // class DockWidget
} }
// namespace ads // namespace ads

View File

@@ -28,6 +28,7 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <FloatingDragPreview.h>
#include "ElidingLabel.h" #include "ElidingLabel.h"
#include "DockWidgetTab.h" #include "DockWidgetTab.h"
@@ -48,6 +49,7 @@
#include "FloatingDockContainer.h" #include "FloatingDockContainer.h"
#include "DockOverlay.h" #include "DockOverlay.h"
#include "DockManager.h" #include "DockManager.h"
#include "IconProvider.h"
#include <iostream> #include <iostream>
@@ -65,14 +67,15 @@ struct DockWidgetTabPrivate
CDockWidget* DockWidget; CDockWidget* DockWidget;
QLabel* IconLabel = nullptr; QLabel* IconLabel = nullptr;
tTabLabel* TitleLabel; tTabLabel* TitleLabel;
QPoint DragStartMousePosition; QPoint GlobalDragStartMousePosition;
bool IsActiveTab = false; bool IsActiveTab = false;
CDockAreaWidget* DockArea = nullptr; CDockAreaWidget* DockArea = nullptr;
eDragState DragState = DraggingInactive; eDragState DragState = DraggingInactive;
CFloatingDockContainer* FloatingWidget = nullptr; IFloatingWidget* FloatingWidget = nullptr;
QIcon Icon; QIcon Icon;
QAbstractButton* CloseButton = nullptr; QAbstractButton* CloseButton = nullptr;
QSpacerItem* IconTextSpacer; QSpacerItem* IconTextSpacer;
QPoint TabDragStartPosition;
/** /**
* Private data constructor * Private data constructor
@@ -92,20 +95,11 @@ struct DockWidgetTabPrivate
/** /**
* Test function for current drag state * Test function for current drag state
*/ */
bool isDraggingState(eDragState dragState) bool isDraggingState(eDragState dragState) const
{ {
return this->DragState == dragState; return this->DragState == dragState;
} }
/**
* Returns true if the given global point is inside the title area geometry
* rectangle.
* The position is given as global position.
*/
bool titleAreaGeometryContains(const QPoint& GlobalPos) const
{
return DockArea->titleBarGeometry().contains(DockArea->mapFromGlobal(GlobalPos));
}
/** /**
* Starts floating of the dock widget that belongs to this title bar * Starts floating of the dock widget that belongs to this title bar
@@ -138,6 +132,24 @@ struct DockWidgetTabPrivate
return new QPushButton(); return new QPushButton();
} }
} }
template <typename T>
IFloatingWidget* createFloatingWidget(T* Widget, bool OpaqueUndocking)
{
if (OpaqueUndocking)
{
return new CFloatingDockContainer(Widget);
}
else
{
auto w = new CFloatingDragPreview(Widget);
_this->connect(w, &CFloatingDragPreview::draggingCanceled, [=]()
{
DragState = DraggingInactive;
});
return w;
}
}
}; };
// struct DockWidgetTabPrivate // struct DockWidgetTabPrivate
@@ -158,20 +170,15 @@ void DockWidgetTabPrivate::createLayout()
TitleLabel->setText(DockWidget->windowTitle()); TitleLabel->setText(DockWidget->windowTitle());
TitleLabel->setObjectName("dockWidgetTabLabel"); TitleLabel->setObjectName("dockWidgetTabLabel");
TitleLabel->setAlignment(Qt::AlignCenter); TitleLabel->setAlignment(Qt::AlignCenter);
_this->connect(TitleLabel, SIGNAL(elidedChanged(bool)), SIGNAL(elidedChanged(bool)));
CloseButton = createCloseButton(); CloseButton = createCloseButton();
CloseButton->setObjectName("tabCloseButton"); CloseButton->setObjectName("tabCloseButton");
// The standard icons do does not look good on high DPI screens internal::setButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton, TabCloseIcon);
QIcon CloseIcon;
QPixmap normalPixmap = _this->style()->standardPixmap(QStyle::SP_TitleBarCloseButton, 0, CloseButton);
CloseIcon.addPixmap(normalPixmap, QIcon::Normal);
CloseIcon.addPixmap(internal::createTransparentPixmap(normalPixmap, 0.25), QIcon::Disabled);
CloseButton->setIcon(CloseIcon);
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
_this->onDockWidgetFeaturesChanged(); _this->onDockWidgetFeaturesChanged();
#ifndef QT_NO_TOOLTIP internal::setToolTip(CloseButton, QObject::tr("Close Tab"));
CloseButton->setToolTip(QObject::tr("Close Tab"));
#endif
_this->connect(CloseButton, SIGNAL(clicked()), SIGNAL(closeRequested())); _this->connect(CloseButton, SIGNAL(clicked()), SIGNAL(closeRequested()));
QFontMetrics fm(TitleLabel->font()); QFontMetrics fm(TitleLabel->font());
@@ -195,11 +202,10 @@ void DockWidgetTabPrivate::createLayout()
void DockWidgetTabPrivate::moveTab(QMouseEvent* ev) void DockWidgetTabPrivate::moveTab(QMouseEvent* ev)
{ {
ev->accept(); ev->accept();
int left, top, right, bottom; QPoint Distance = ev->globalPos() - GlobalDragStartMousePosition;
_this->getContentsMargins(&left, &top, &right, &bottom); Distance.setY(0);
QPoint moveToPos = _this->mapToParent(ev->pos()) - DragStartMousePosition; auto TargetPos = Distance + TabDragStartPosition;
moveToPos.setY(0); _this->move(TargetPos);
_this->move(moveToPos);
_this->raise(); _this->raise();
} }
@@ -223,32 +229,36 @@ bool DockWidgetTabPrivate::startFloating(eDragState DraggingState)
ADS_PRINT("startFloating"); ADS_PRINT("startFloating");
DragState = DraggingState; DragState = DraggingState;
auto DragStartMousePosition = _this->mapFromGlobal(GlobalDragStartMousePosition);
QSize Size = DockArea->size(); QSize Size = DockArea->size();
CFloatingDockContainer* FloatingWidget = nullptr; IFloatingWidget* FloatingWidget = nullptr;
bool OpaqueUndocking = CDockManager::configFlags().testFlag(CDockManager::OpaqueUndocking) ||
(DraggingFloatingWidget != DraggingState);
// If section widget has multiple tabs, we take only one tab
// If it has only one single tab, we can move the complete
// dock area into floating widget
if (DockArea->dockWidgetsCount() > 1) if (DockArea->dockWidgetsCount() > 1)
{ {
// If section widget has multiple tabs, we take only one tab FloatingWidget = createFloatingWidget(DockWidget, OpaqueUndocking);
FloatingWidget = new CFloatingDockContainer(DockWidget);
} }
else else
{ {
// If section widget has only one content widget, we can move the complete FloatingWidget = createFloatingWidget(DockArea, OpaqueUndocking);
// dock area into floating widget
FloatingWidget = new CFloatingDockContainer(DockArea);
} }
if (DraggingFloatingWidget == DraggingState) if (DraggingFloatingWidget == DraggingState)
{ {
FloatingWidget->startDragging(DragStartMousePosition, Size, _this); FloatingWidget->startFloating(DragStartMousePosition, Size, DraggingFloatingWidget, _this);
auto Overlay = DockWidget->dockManager()->containerOverlay(); auto Overlay = DockWidget->dockManager()->containerOverlay();
Overlay->setAllowedAreas(OuterDockAreas); Overlay->setAllowedAreas(OuterDockAreas);
this->FloatingWidget = FloatingWidget; this->FloatingWidget = FloatingWidget;
} }
else else
{ {
FloatingWidget->initFloatingGeometry(DragStartMousePosition, Size); FloatingWidget->startFloating(DragStartMousePosition, Size, DraggingInactive, nullptr);
} }
DockWidget->emitTopLevelChanged(true);
return true; return true;
} }
@@ -277,7 +287,7 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
if (ev->button() == Qt::LeftButton) if (ev->button() == Qt::LeftButton)
{ {
ev->accept(); ev->accept();
d->DragStartMousePosition = ev->pos(); d->GlobalDragStartMousePosition = ev->globalPos();
d->DragState = DraggingMousePressed; d->DragState = DraggingMousePressed;
emit clicked(); emit clicked();
return; return;
@@ -290,14 +300,30 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
//============================================================================ //============================================================================
void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev) void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
{ {
// End of tab moving, emit signal if (ev->button() == Qt::LeftButton)
if (d->isDraggingState(DraggingTab) && d->DockArea)
{ {
emit moved(ev->globalPos()); auto CurrentDragState = d->DragState;
d->GlobalDragStartMousePosition = QPoint();
d->DragState = DraggingInactive;
switch (CurrentDragState)
{
case DraggingTab:
// End of tab moving, emit signal
if (d->DockArea)
{
emit moved(ev->globalPos());
}
break;
case DraggingFloatingWidget:
d->FloatingWidget->finishDragging();
break;
default:; // do nothing
}
} }
d->DragStartMousePosition = QPoint();
d->DragState = DraggingInactive;
Super::mouseReleaseEvent(ev); Super::mouseReleaseEvent(ev);
} }
@@ -329,7 +355,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
} }
// Maybe a fixed drag distance is better here ? // Maybe a fixed drag distance is better here ?
int DragDistanceY = qAbs(d->DragStartMousePosition.y() - ev->pos().y()); int DragDistanceY = qAbs(d->GlobalDragStartMousePosition.y() - ev->globalPos().y());
if (DragDistanceY >= CDockManager::startDragDistance()) if (DragDistanceY >= CDockManager::startDragDistance())
{ {
// If this is the last dock area in a dock container with only // If this is the last dock area in a dock container with only
@@ -345,13 +371,25 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
// Floating is only allowed for widgets that are movable // Floating is only allowed for widgets that are movable
if (d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable)) if (d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
{ {
// If we undock, we need to restore the initial position of this
// tab because it looks strange if it remains on its dragged position
if (d->isDraggingState(DraggingTab) && !CDockManager::configFlags().testFlag(CDockManager::OpaqueUndocking))
{
this->move(d->TabDragStartPosition);
}
d->startFloating(); d->startFloating();
} }
return; return;
} }
else if (d->DockArea->openDockWidgetsCount() > 1 else if (d->DockArea->openDockWidgetsCount() > 1
&& (ev->pos() - d->DragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving && (ev->globalPos() - d->GlobalDragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving
{ {
// If we start dragging the tab, we save its inital position to
// restore it later
if (DraggingTab != d->DragState)
{
d->TabDragStartPosition = this->pos();
}
d->DragState = DraggingTab; d->DragState = DraggingTab;
return; return;
} }
@@ -364,16 +402,26 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev) void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
{ {
ev->accept(); ev->accept();
if (d->isDraggingState(DraggingFloatingWidget))
{
return;
}
d->DragStartMousePosition = ev->pos(); d->GlobalDragStartMousePosition = ev->globalPos();
QMenu Menu(this); QMenu Menu(this);
auto Action = Menu.addAction(tr("Detach"), this, SLOT(onDetachActionTriggered()));
Action->setEnabled(d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable)); const bool isFloatable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable);
const bool isNotOnlyTabInContainer = !d->DockArea->dockContainer()->hasTopLevelDockWidget();
const bool isDetachable = isFloatable && isNotOnlyTabInContainer;
auto Action = Menu.addAction(tr("Detach"), this, SLOT(detachDockWidget()));
Action->setEnabled(isDetachable);
Menu.addSeparator(); Menu.addSeparator();
Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested())); Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested()));
Action->setEnabled(isClosable()); Action->setEnabled(isClosable());
Menu.addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested())); Menu.addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested()));
Menu.exec(mapToGlobal(ev->pos())); Menu.exec(ev->globalPos());
} }
@@ -403,6 +451,7 @@ void CDockWidgetTab::setActiveTab(bool active)
d->TitleLabel->style()->unpolish(d->TitleLabel); d->TitleLabel->style()->unpolish(d->TitleLabel);
d->TitleLabel->style()->polish(d->TitleLabel); d->TitleLabel->style()->polish(d->TitleLabel);
update(); update();
updateGeometry();
emit activeTabChanged(); emit activeTabChanged();
} }
@@ -443,9 +492,7 @@ void CDockWidgetTab::setIcon(const QIcon& Icon)
d->IconLabel = new QLabel(); d->IconLabel = new QLabel();
d->IconLabel->setAlignment(Qt::AlignVCenter); d->IconLabel->setAlignment(Qt::AlignVCenter);
d->IconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); d->IconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
#ifndef QT_NO_TOOLTIP internal::setToolTip(d->IconLabel, d->TitleLabel->toolTip());
d->IconLabel->setToolTip(d->TitleLabel->toolTip());
#endif
Layout->insertWidget(0, d->IconLabel, Qt::AlignVCenter); Layout->insertWidget(0, d->IconLabel, Qt::AlignVCenter);
Layout->insertSpacing(1, qRound(1.5 * Layout->contentsMargins().left() / 2.0)); Layout->insertSpacing(1, qRound(1.5 * Layout->contentsMargins().left() / 2.0));
} }
@@ -490,7 +537,7 @@ void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event)
if ((!d->DockArea->dockContainer()->isFloating() || d->DockArea->dockWidgetsCount() > 1) if ((!d->DockArea->dockContainer()->isFloating() || d->DockArea->dockWidgetsCount() > 1)
&& d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable)) && d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
{ {
d->DragStartMousePosition = event->pos(); d->GlobalDragStartMousePosition = event->globalPos();
d->startFloating(DraggingInactive); d->startFloating(DraggingInactive);
} }
@@ -512,6 +559,11 @@ void CDockWidgetTab::setText(const QString& title)
d->TitleLabel->setText(title); d->TitleLabel->setText(title);
} }
bool CDockWidgetTab::isTitleElided() const
{
return d->TitleLabel->isElided();
}
//============================================================================ //============================================================================
@@ -522,13 +574,13 @@ bool CDockWidgetTab::isClosable() const
//=========================================================================== //===========================================================================
void CDockWidgetTab::onDetachActionTriggered() void CDockWidgetTab::detachDockWidget()
{ {
if (!d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable)) if (!d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
{ {
return; return;
} }
d->DragStartMousePosition = mapFromGlobal(QCursor::pos()); d->GlobalDragStartMousePosition = QCursor::pos();
d->startFloating(DraggingInactive); d->startFloating(DraggingInactive);
} }
@@ -536,13 +588,13 @@ void CDockWidgetTab::onDetachActionTriggered()
//============================================================================ //============================================================================
bool CDockWidgetTab::event(QEvent *e) bool CDockWidgetTab::event(QEvent *e)
{ {
#ifndef QT_NO_TOOLTIP #ifndef QT_NO_TOOLTIP
if (e->type() == QEvent::ToolTipChange) if (e->type() == QEvent::ToolTipChange)
{ {
const auto text = toolTip(); const auto text = toolTip();
d->TitleLabel->setToolTip(text); d->TitleLabel->setToolTip(text);
} }
#endif #endif
return Super::event(e); return Super::event(e);
} }

View File

@@ -57,7 +57,7 @@ private:
void onDockWidgetFeaturesChanged(); void onDockWidgetFeaturesChanged();
private slots: private slots:
void onDetachActionTriggered(); void detachDockWidget();
protected: protected:
virtual void mousePressEvent(QMouseEvent* ev) override; virtual void mousePressEvent(QMouseEvent* ev) override;
@@ -133,7 +133,12 @@ public:
void setText(const QString& title); void setText(const QString& title);
/** /**
* This function returns true if the assigned dock widget is closeable * Returns true if text is elided on the tab's title
*/
bool isTitleElided() const;
/**
* This function returns true if the assigned dock widget is closable
*/ */
bool isClosable() const; bool isClosable() const;
@@ -152,6 +157,7 @@ signals:
void closeRequested(); void closeRequested();
void closeOtherTabsRequested(); void closeOtherTabsRequested();
void moved(const QPoint& GlobalPos); void moved(const QPoint& GlobalPos);
void elidedChanged(bool elided);
}; // class DockWidgetTab }; // class DockWidgetTab
} }
// namespace ads // namespace ads

View File

@@ -0,0 +1,30 @@
//============================================================================
/// \file DockingStateReader.cpp
/// \author Uwe Kindler
/// \date 29.11.2019
/// \brief Implementation of CDockingStateReader
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include "DockingStateReader.h"
namespace ads
{
//============================================================================
void CDockingStateReader::setFileVersion(int FileVersion)
{
m_FileVersion = FileVersion;
}
//============================================================================
int CDockingStateReader::fileVersion() const
{
return m_FileVersion;
}
} // namespace ads
//---------------------------------------------------------------------------
// EOF DockingStateReader.cpp

43
src/DockingStateReader.h Normal file
View File

@@ -0,0 +1,43 @@
#ifndef DockingStateReaderH
#define DockingStateReaderH
//============================================================================
/// \file DockingStateReader.h
/// \author Uwe Kindler
/// \date 29.11.2019
/// \brief Declaration of CDockingStateReader
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include <QXmlStreamReader>
namespace ads
{
/**
* Extends QXmlStreamReader with file version information
*/
class CDockingStateReader : public QXmlStreamReader
{
private:
int m_FileVersion;
public:
using QXmlStreamReader::QXmlStreamReader;
/**
* Set the file version for this state reader
*/
void setFileVersion(int FileVersion);
/**
* Returns the file version set via setFileVersion
*/
int fileVersion() const;
};
} // namespace ads
//---------------------------------------------------------------------------
#endif // DockingStateReaderH

View File

@@ -41,6 +41,7 @@ struct ElidingLabelPrivate
CElidingLabel* _this; CElidingLabel* _this;
Qt::TextElideMode ElideMode = Qt::ElideNone; Qt::TextElideMode ElideMode = Qt::ElideNone;
QString Text; QString Text;
bool IsElided = false;
ElidingLabelPrivate(CElidingLabel* _public) : _this(_public) {} ElidingLabelPrivate(CElidingLabel* _public) : _this(_public) {}
@@ -69,6 +70,12 @@ void ElidingLabelPrivate::elideText(int Width)
{ {
str = Text.at(0); str = Text.at(0);
} }
bool WasElided = IsElided;
IsElided = str != Text;
if(IsElided != WasElided)
{
emit _this->elidedChanged(IsElided);
}
_this->QLabel::setText(str); _this->QLabel::setText(str);
} }
@@ -88,9 +95,7 @@ CElidingLabel::CElidingLabel(const QString& text, QWidget* parent, Qt::WindowFla
d(new ElidingLabelPrivate(this)) d(new ElidingLabelPrivate(this))
{ {
d->Text = text; d->Text = text;
#ifndef QT_NO_TOOLTIP internal::setToolTip(this, text);
setToolTip(text);
#endif
} }
@@ -115,6 +120,12 @@ void CElidingLabel::setElideMode(Qt::TextElideMode mode)
d->elideText(size().width()); d->elideText(size().width());
} }
//============================================================================
bool CElidingLabel::isElided() const
{
return d->IsElided;
}
//============================================================================ //============================================================================
void CElidingLabel::mouseReleaseEvent(QMouseEvent* event) void CElidingLabel::mouseReleaseEvent(QMouseEvent* event)
@@ -193,9 +204,7 @@ void CElidingLabel::setText(const QString &text)
else else
{ {
d->Text = text; d->Text = text;
#ifndef QT_NO_TOOLTIP internal::setToolTip(this, text);
setToolTip( text );
#endif
d->elideText(this->size().width()); d->elideText(this->size().width());
} }
} }

View File

@@ -73,6 +73,10 @@ public:
*/ */
void setElideMode(Qt::TextElideMode mode); void setElideMode(Qt::TextElideMode mode);
/**
* This function indicates whether the text on this label is currently elided
*/
bool isElided() const;
public: // reimplements QLabel ---------------------------------------------- public: // reimplements QLabel ----------------------------------------------
virtual QSize minimumSizeHint() const override; virtual QSize minimumSizeHint() const override;
@@ -91,6 +95,11 @@ signals:
* This signal is emitted if the user does a double click on the label * This signal is emitted if the user does a double click on the label
*/ */
void doubleClicked(); void doubleClicked();
/**
* This signal is emitted when isElided() state of this label is changed
*/
void elidedChanged(bool elided);
}; //class CElidingLabel }; //class CElidingLabel
} // namespace QtLabb } // namespace QtLabb

View File

@@ -28,6 +28,8 @@
//============================================================================ //============================================================================
#include "FloatingDockContainer.h" #include "FloatingDockContainer.h"
#include <iostream>
#include <QBoxLayout> #include <QBoxLayout>
#include <QApplication> #include <QApplication>
#include <QMouseEvent> #include <QMouseEvent>
@@ -205,7 +207,7 @@ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint &GlobalPos)
{ {
DockAreaOverlay->enableDropPreview(true); DockAreaOverlay->enableDropPreview(true);
DockAreaOverlay->setAllowedAreas( DockAreaOverlay->setAllowedAreas(
(VisibleDockAreas == 1) ? NoDockWidgetArea : AllDockAreas); (VisibleDockAreas == 1) ? NoDockWidgetArea : DockArea->allowedAreas());
DockWidgetArea Area = DockAreaOverlay->showOverlay(DockArea); DockWidgetArea Area = DockAreaOverlay->showOverlay(DockArea);
// A CenterDockWidgetArea for the dockAreaOverlay() indicates that // A CenterDockWidgetArea for the dockAreaOverlay() indicates that
@@ -260,11 +262,6 @@ CFloatingDockContainer::CFloatingDockContainer(CDockManager *DockManager) :
#endif #endif
DockManager->registerFloatingWidget(this); DockManager->registerFloatingWidget(this);
// We install an event filter to detect mouse release events because we
// do not receive mouse release event if the floating widget is behind
// the drop overlay cross
qApp->installEventFilter(this);
} }
//============================================================================ //============================================================================
@@ -275,6 +272,11 @@ CFloatingDockContainer::CFloatingDockContainer(CDockAreaWidget *DockArea) :
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
d->TitleBar->enableCloseButton(isClosable()); d->TitleBar->enableCloseButton(isClosable());
#endif #endif
auto TopLevelDockWidget = topLevelDockWidget();
if (TopLevelDockWidget)
{
TopLevelDockWidget->emitTopLevelChanged(true);
}
} }
//============================================================================ //============================================================================
@@ -285,6 +287,11 @@ CFloatingDockContainer::CFloatingDockContainer(CDockWidget *DockWidget) :
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
d->TitleBar->enableCloseButton(isClosable()); d->TitleBar->enableCloseButton(isClosable());
#endif #endif
auto TopLevelDockWidget = topLevelDockWidget();
if (TopLevelDockWidget)
{
TopLevelDockWidget->emitTopLevelChanged(true);
}
} }
//============================================================================ //============================================================================
@@ -329,6 +336,13 @@ void CFloatingDockContainer::moveEvent(QMoveEvent *event)
case DraggingFloatingWidget: case DraggingFloatingWidget:
d->updateDropOverlays(QCursor::pos()); d->updateDropOverlays(QCursor::pos());
#ifdef Q_OS_MACOS
// In OSX when hiding the DockAreaOverlay the application would set
// the main window as the active window for some reason. This fixes
// that by resetting the active window to the floating widget after
// updating the overlays.
QApplication::setActiveWindow(this);
#endif
break; break;
default: default:
break; break;
@@ -340,9 +354,19 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
{ {
ADS_PRINT("CFloatingDockContainer closeEvent"); ADS_PRINT("CFloatingDockContainer closeEvent");
d->setState(DraggingInactive); d->setState(DraggingInactive);
event->ignore();
if (isClosable()) if (isClosable())
{ {
auto TopLevelDockWidget = topLevelDockWidget();
if (TopLevelDockWidget && TopLevelDockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
{
if (!TopLevelDockWidget->closeDockWidgetInternal())
{
return;
}
}
// In Qt version after 5.9.2 there seems to be a bug that causes the // In Qt version after 5.9.2 there seems to be a bug that causes the
// QWidget::event() function to not receive any NonClientArea mouse // QWidget::event() function to not receive any NonClientArea mouse
// events anymore after a close/show cycle. The bug is reported here: // events anymore after a close/show cycle. The bug is reported here:
@@ -352,20 +376,7 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
// Starting from Qt version 5.12.2 this seems to work again. But // Starting from Qt version 5.12.2 this seems to work again. But
// now the QEvent::NonClientAreaMouseButtonPress function returns always // now the QEvent::NonClientAreaMouseButtonPress function returns always
// Qt::RightButton even if the left button was pressed // Qt::RightButton even if the left button was pressed
#ifndef Q_OS_LINUX
#if (QT_VERSION > QT_VERSION_CHECK(5, 9, 2) && QT_VERSION < QT_VERSION_CHECK(5, 12, 2))
event->ignore();
this->hide(); this->hide();
#else
Super::closeEvent(event);
#endif
#else // Q_OS_LINUX
Super::closeEvent(event);
#endif
}
else
{
event->ignore();
} }
} }
@@ -373,6 +384,11 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
void CFloatingDockContainer::hideEvent(QHideEvent *event) void CFloatingDockContainer::hideEvent(QHideEvent *event)
{ {
Super::hideEvent(event); Super::hideEvent(event);
if (event->spontaneous())
{
return;
}
// Prevent toogleView() events during restore state // Prevent toogleView() events during restore state
if (d->DockManager->isRestoringState()) if (d->DockManager->isRestoringState())
{ {
@@ -471,20 +487,6 @@ bool CFloatingDockContainer::event(QEvent *e)
return QWidget::event(e); return QWidget::event(e);
} }
//============================================================================
bool CFloatingDockContainer::eventFilter(QObject *watched, QEvent *event)
{
Q_UNUSED(watched);
if (event->type() == QEvent::MouseButtonRelease
&& d->isState(DraggingFloatingWidget))
{
ADS_PRINT("FloatingWidget::eventFilter QEvent::MouseButtonRelease");
finishDragging();
d->titleMouseReleaseEvent();
}
return false;
}
//============================================================================ //============================================================================
void CFloatingDockContainer::startFloating(const QPoint &DragStartMousePos, void CFloatingDockContainer::startFloating(const QPoint &DragStartMousePos,
@@ -497,17 +499,9 @@ void CFloatingDockContainer::startFloating(const QPoint &DragStartMousePos,
d->setState(DragState); d->setState(DragState);
d->DragStartMousePosition = DragStartMousePos; d->DragStartMousePosition = DragStartMousePos;
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
// I have not found a way on Linux to display the floating widget behind the
// dock overlay. That means if the user drags this floating widget around,
// it is always painted in front of the dock overlay and dock overlay cross.
// and the user will not see the dock overlay. To work around this issue,
// the window opacity is set to 0.6 to make the dock overlay visible
// again. If someone has an idea, how to place the dragged floating widget
// behind the dock overlay, then a pull request would be welcome.
if (DraggingFloatingWidget == DragState) if (DraggingFloatingWidget == DragState)
{ {
setAttribute(Qt::WA_X11NetWmWindowTypeDock, true); setAttribute(Qt::WA_X11NetWmWindowTypeDock, true);
setWindowOpacity(0.6);
d->MouseEventHandler = MouseEventHandler; d->MouseEventHandler = MouseEventHandler;
if (d->MouseEventHandler) if (d->MouseEventHandler)
{ {
@@ -517,7 +511,6 @@ void CFloatingDockContainer::startFloating(const QPoint &DragStartMousePos,
#endif #endif
moveFloating(); moveFloating();
show(); show();
} }
//============================================================================ //============================================================================
@@ -583,7 +576,7 @@ void CFloatingDockContainer::onDockAreaCurrentChanged(int Index)
} }
//============================================================================ //============================================================================
bool CFloatingDockContainer::restoreState(QXmlStreamReader &Stream, bool CFloatingDockContainer::restoreState(CDockingStateReader &Stream,
bool Testing) bool Testing)
{ {
if (!d->DockContainer->restoreState(Stream, Testing)) if (!d->DockContainer->restoreState(Stream, Testing))
@@ -627,6 +620,7 @@ void CFloatingDockContainer::finishDragging()
d->MouseEventHandler = nullptr; d->MouseEventHandler = nullptr;
} }
#endif #endif
d->titleMouseReleaseEvent();
} }
} // namespace ads } // namespace ads

View File

@@ -31,6 +31,8 @@
//============================================================================ //============================================================================
#include "ads_globals.h" #include "ads_globals.h"
#include <QRubberBand>
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
#include <QDockWidget> #include <QDockWidget>
#define tFloatingWidgetBase QDockWidget #define tFloatingWidgetBase QDockWidget
@@ -39,7 +41,7 @@
#define tFloatingWidgetBase QWidget #define tFloatingWidgetBase QWidget
#endif #endif
class QXmlStreamReader; class CDockingStateReader;
namespace ads namespace ads
{ {
@@ -56,6 +58,40 @@ struct DockWidgetTabPrivate;
class CDockAreaTitleBar; class CDockAreaTitleBar;
struct DockAreaTitleBarPrivate; struct DockAreaTitleBarPrivate;
class CFloatingWidgetTitleBar; class CFloatingWidgetTitleBar;
class CDockingStateReader;
/**
* Pure virtual interface for floating widgets.
* This interface is used for opaque and non-opaque undocking. If opaque
* undocking is used, the a real CFloatingDockContainer widget will be created
*/
class IFloatingWidget
{
public:
/**
* Starts floating.
* This function should get called typically from a mouse press event
* handler
*/
virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
eDragState DragState, QWidget* MouseEventHandler) = 0;
/**
* Moves the widget to a new position relative to the position given when
* startFloating() was called.
* This function should be called from a mouse mouve event handler to
* move the floating widget on mouse move events.
*/
virtual void moveFloating() = 0;
/**
* Tells the widget that to finish dragging if the mouse is released.
* This function should be called from a mouse release event handler
* to finish the dragging
*/
virtual void finishDragging() = 0;
};
/** /**
* This implements a floating widget that is a dock container that accepts * This implements a floating widget that is a dock container that accepts
@@ -63,7 +99,7 @@ class CFloatingWidgetTitleBar;
* another dock container. * another dock container.
* Every floating window of the docking system is a FloatingDockContainer. * Every floating window of the docking system is a FloatingDockContainer.
*/ */
class ADS_EXPORT CFloatingDockContainer : public tFloatingWidgetBase class ADS_EXPORT CFloatingDockContainer : public tFloatingWidgetBase, public IFloatingWidget
{ {
Q_OBJECT Q_OBJECT
private: private:
@@ -90,8 +126,8 @@ protected:
* Use moveToGlobalPos() to move the widget to a new position * Use moveToGlobalPos() to move the widget to a new position
* depending on the start position given in Pos parameter * depending on the start position given in Pos parameter
*/ */
void startFloating(const QPoint& DragStartMousePos, const QSize& Size, virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
eDragState DragState, QWidget* MouseEventHandler); eDragState DragState, QWidget* MouseEventHandler) override;
/** /**
* Call this function to start dragging the floating widget * Call this function to start dragging the floating widget
@@ -103,10 +139,10 @@ protected:
} }
/** /**
* Call this function if you explecitely want to signal that dragging has * Call this function if you explicitly want to signal that dragging has
* finished * finished
*/ */
void finishDragging(); virtual void finishDragging() override;
/** /**
* Call this function if you just want to initialize the position * Call this function if you just want to initialize the position
@@ -121,7 +157,7 @@ protected:
* Moves the widget to a new position relative to the position given when * Moves the widget to a new position relative to the position given when
* startFloating() was called * startFloating() was called
*/ */
void moveFloating(); void moveFloating() override;
/** /**
* Restores the state from given stream. * Restores the state from given stream.
@@ -129,7 +165,7 @@ protected:
* stream but does not restore anything. You can use this check for * stream but does not restore anything. You can use this check for
* faulty files before you start restoring the state * faulty files before you start restoring the state
*/ */
bool restoreState(QXmlStreamReader& Stream, bool Testing); bool restoreState(CDockingStateReader& Stream, bool Testing);
/** /**
* Call this function to update the window title * Call this function to update the window title
@@ -144,13 +180,12 @@ protected: // reimplements QWidget
virtual void closeEvent(QCloseEvent *event) override; virtual void closeEvent(QCloseEvent *event) override;
virtual void hideEvent(QHideEvent *event) override; virtual void hideEvent(QHideEvent *event) override;
virtual void showEvent(QShowEvent *event) override; virtual void showEvent(QShowEvent *event) override;
virtual bool eventFilter(QObject *watched, QEvent *event) override;
public: public:
using Super = QWidget; using Super = QWidget;
/** /**
* Create empty flatingb widget - required for restore state * Create empty floating widget - required for restore state
*/ */
CFloatingDockContainer(CDockManager* DockManager); CFloatingDockContainer(CDockManager* DockManager);

390
src/FloatingDragPreview.cpp Normal file
View File

@@ -0,0 +1,390 @@
//============================================================================
/// \file FloatingDragPreview.cpp
/// \author Uwe Kindler
/// \date 26.11.2019
/// \brief Implementation of CFloatingDragPreview
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include "FloatingDragPreview.h"
#include <iostream>
#include <QEvent>
#include <QApplication>
#include <QPainter>
#include <QKeyEvent>
#include "DockWidget.h"
#include "DockAreaWidget.h"
#include "DockManager.h"
#include "DockContainerWidget.h"
#include "DockOverlay.h"
namespace ads
{
/**
* Private data class (pimpl)
*/
struct FloatingDragPreviewPrivate
{
CFloatingDragPreview *_this;
QWidget* Content;
CDockAreaWidget* ContentSourceArea = nullptr;
CDockContainerWidget* ContenSourceContainer = nullptr;
QPoint DragStartMousePosition;
CDockManager* DockManager;
CDockContainerWidget *DropContainer = nullptr;
qreal WindowOpacity;
bool Hidden = false;
QPixmap ContentPreviewPixmap;
/**
* Private data constructor
*/
FloatingDragPreviewPrivate(CFloatingDragPreview *_public);
void updateDropOverlays(const QPoint &GlobalPos);
void setHidden(bool Value)
{
Hidden = Value;
_this->update();
}
/**
* Cancel dragging and emit the draggingCanceled event
*/
void cancelDragging()
{
emit _this->draggingCanceled();
DockManager->containerOverlay()->hideOverlay();
DockManager->dockAreaOverlay()->hideOverlay();
_this->close();
}
};
// struct LedArrayPanelPrivate
//============================================================================
void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos)
{
if (!_this->isVisible() || !DockManager)
{
return;
}
auto Containers = DockManager->dockContainers();
CDockContainerWidget *TopContainer = nullptr;
for (auto ContainerWidget : Containers)
{
if (!ContainerWidget->isVisible())
{
continue;
}
/*if (DockContainer == ContainerWidget)
{
continue;
}*/
QPoint MappedPos = ContainerWidget->mapFromGlobal(GlobalPos);
if (ContainerWidget->rect().contains(MappedPos))
{
if (!TopContainer || ContainerWidget->isInFrontOf(TopContainer))
{
TopContainer = ContainerWidget;
}
}
}
DropContainer = TopContainer;
auto ContainerOverlay = DockManager->containerOverlay();
auto DockAreaOverlay = DockManager->dockAreaOverlay();
auto DockDropArea = DockAreaOverlay->dropAreaUnderCursor();
auto ContainerDropArea = ContainerOverlay->dropAreaUnderCursor();
if (!TopContainer)
{
ContainerOverlay->hideOverlay();
DockAreaOverlay->hideOverlay();
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewIsDynamic))
{
setHidden(false);
}
return;
}
int VisibleDockAreas = TopContainer->visibleDockAreaCount();
ContainerOverlay->setAllowedAreas(
VisibleDockAreas > 1 ? OuterDockAreas : AllDockAreas);
DockWidgetArea ContainerArea = ContainerOverlay->showOverlay(TopContainer);
ContainerOverlay->enableDropPreview(ContainerArea != InvalidDockWidgetArea);
auto DockArea = TopContainer->dockAreaAt(GlobalPos);
if (DockArea && DockArea->isVisible() && VisibleDockAreas > 0 && DockArea != ContentSourceArea)
{
DockAreaOverlay->enableDropPreview(true);
DockAreaOverlay->setAllowedAreas(
(VisibleDockAreas == 1) ? NoDockWidgetArea : DockArea->allowedAreas());
DockWidgetArea Area = DockAreaOverlay->showOverlay(DockArea);
// A CenterDockWidgetArea for the dockAreaOverlay() indicates that
// the mouse is in the title bar. If the ContainerArea is valid
// then we ignore the dock area of the dockAreaOverlay() and disable
// the drop preview
if ((Area == CenterDockWidgetArea)
&& (ContainerArea != InvalidDockWidgetArea))
{
DockAreaOverlay->enableDropPreview(false);
ContainerOverlay->enableDropPreview(true);
}
else
{
ContainerOverlay->enableDropPreview(InvalidDockWidgetArea == Area);
}
}
else
{
DockAreaOverlay->hideOverlay();
if (DockArea == ContentSourceArea && InvalidDockWidgetArea == ContainerDropArea)
{
DropContainer = nullptr;
}
}
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewIsDynamic))
{
setHidden(DockDropArea != InvalidDockWidgetArea || ContainerDropArea != InvalidDockWidgetArea);
}
}
//============================================================================
FloatingDragPreviewPrivate::FloatingDragPreviewPrivate(CFloatingDragPreview *_public) :
_this(_public)
{
}
//============================================================================
CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
QWidget(parent),
d(new FloatingDragPreviewPrivate(this))
{
d->Content = Content;
setAttribute(Qt::WA_DeleteOnClose);
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame))
{
setWindowFlags(
Qt::Window | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);
}
else
{
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_TranslucentBackground);
}
#ifdef Q_OS_LINUX
auto Flags = windowFlags();
Flags |= Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint;
setWindowFlags(Flags);
#endif
setWindowOpacity(0.6);
// Create a static image of the widget that should get undocked
// This is like some kind preview image like it is uses in drag and drop
// operations
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewShowsContentPixmap))
{
d->ContentPreviewPixmap = QPixmap(Content->size());
Content->render(&d->ContentPreviewPixmap);
}
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
SLOT(onApplicationStateChanged(Qt::ApplicationState)));
// We need to install an event filter for the given Content
// widget to receive the escape key press
Content->installEventFilter(this);
}
//============================================================================
CFloatingDragPreview::CFloatingDragPreview(CDockWidget* Content)
: CFloatingDragPreview((QWidget*)Content, Content->dockManager())
{
d->DockManager = Content->dockManager();
if (Content->dockAreaWidget()->openDockWidgetsCount() == 1)
{
d->ContentSourceArea = Content->dockAreaWidget();
d->ContenSourceContainer = Content->dockContainer();
}
setWindowTitle(Content->windowTitle());
}
//============================================================================
CFloatingDragPreview::CFloatingDragPreview(CDockAreaWidget* Content)
: CFloatingDragPreview((QWidget*)Content, Content->dockManager())
{
d->DockManager = Content->dockManager();
d->ContentSourceArea = Content;
d->ContenSourceContainer = Content->dockContainer();
setWindowTitle(Content->currentDockWidget()->windowTitle());
}
//============================================================================
CFloatingDragPreview::~CFloatingDragPreview()
{
delete d;
}
//============================================================================
void CFloatingDragPreview::moveFloating()
{
int BorderSize = (frameSize().width() - size().width()) / 2;
const QPoint moveToPos = QCursor::pos() - d->DragStartMousePosition
- QPoint(BorderSize, 0);
move(moveToPos);
}
//============================================================================
void CFloatingDragPreview::startFloating(const QPoint &DragStartMousePos,
const QSize &Size, eDragState DragState, QWidget *MouseEventHandler)
{
Q_UNUSED(MouseEventHandler)
Q_UNUSED(DragState)
resize(Size);
d->DragStartMousePosition = DragStartMousePos;
moveFloating();
show();
}
//============================================================================
void CFloatingDragPreview::moveEvent(QMoveEvent *event)
{
QWidget::moveEvent(event);
d->updateDropOverlays(QCursor::pos());
}
//============================================================================
void CFloatingDragPreview::finishDragging()
{
ADS_PRINT("CFloatingDragPreview::finishDragging");
auto DockDropArea = d->DockManager->dockAreaOverlay()->dropAreaUnderCursor();
auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor();
bool DropPossible = (DockDropArea != InvalidDockWidgetArea) || (ContainerDropArea != InvalidDockWidgetArea);
if (d->DropContainer && DropPossible)
{
d->DropContainer->dropWidget(d->Content, QCursor::pos());
}
else
{
CDockWidget* DockWidget = qobject_cast<CDockWidget*>(d->Content);
CFloatingDockContainer* FloatingWidget;
if (DockWidget)
{
FloatingWidget = new CFloatingDockContainer(DockWidget);
}
else
{
CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(d->Content);
FloatingWidget = new CFloatingDockContainer(DockArea);
}
FloatingWidget->setGeometry(this->geometry());
FloatingWidget->show();
if (!CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame))
{
QApplication::processEvents();
int FrameHeight = FloatingWidget->frameGeometry().height() - FloatingWidget->geometry().height();
QRect FixedGeometry = this->geometry();
FixedGeometry.adjust(0, FrameHeight, 0, 0);
FloatingWidget->setGeometry(FixedGeometry);
}
}
this->close();
d->DockManager->containerOverlay()->hideOverlay();
d->DockManager->dockAreaOverlay()->hideOverlay();
}
//============================================================================
void CFloatingDragPreview::paintEvent(QPaintEvent* event)
{
Q_UNUSED(event);
if (d->Hidden)
{
return;
}
QPainter painter(this);
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewShowsContentPixmap))
{
painter.drawPixmap(QPoint(0, 0), d->ContentPreviewPixmap);
}
// If we do not have a window frame then we paint a QRubberBand like
// frameless window
if (!CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame))
{
QColor Color = palette().color(QPalette::Active, QPalette::Highlight);
QPen Pen = painter.pen();
Pen.setColor(Color.darker(120));
Pen.setStyle(Qt::SolidLine);
Pen.setWidth(1);
Pen.setCosmetic(true);
painter.setPen(Pen);
Color = Color.lighter(130);
Color.setAlpha(64);
painter.setBrush(Color);
painter.drawRect(rect().adjusted(0, 0, -1, -1));
}
}
//============================================================================
void CFloatingDragPreview::onApplicationStateChanged(Qt::ApplicationState state)
{
if (state != Qt::ApplicationActive)
{
disconnect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
this, SLOT(onApplicationStateChanged(Qt::ApplicationState)));
d->cancelDragging();
}
}
//============================================================================
bool CFloatingDragPreview::eventFilter(QObject *watched, QEvent *event)
{
Q_UNUSED(watched);
if (event->type() == QEvent::KeyPress)
{
QKeyEvent* e = static_cast<QKeyEvent*>(event);
if (e->key() == Qt::Key_Escape)
{
d->Content->removeEventFilter(this);
d->cancelDragging();
}
}
return false;
}
} // namespace ads
//---------------------------------------------------------------------------
// EOF FloatingDragPreview.cpp

113
src/FloatingDragPreview.h Normal file
View File

@@ -0,0 +1,113 @@
#ifndef FloatingDragPreviewH
#define FloatingDragPreviewH
//============================================================================
/// \file FloatingDragPreview.h
/// \author Uwe Kindler
/// \date 26.11.2019
/// \brief Declaration of CFloatingDragPreview
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include <QWidget>
#include "FloatingDockContainer.h"
namespace ads
{
class CDockWidget;
class CDockAreaWidget;
struct FloatingDragPreviewPrivate;
/**
* A floating overlay is a temporary floating widget that is just used to
* indicate the floating widget movement.
* This widget is used as a placeholder for drag operations for non-opaque
* docking
*/
class CFloatingDragPreview : public QWidget, public IFloatingWidget
{
Q_OBJECT
private:
FloatingDragPreviewPrivate* d;
friend struct FloatingDragPreviewPrivate;
private slots:
/**
* Cancel non opaque undocking if application becomes inactive
*/
void onApplicationStateChanged(Qt::ApplicationState state);
protected:
/**
* Updates the drop overlays
*/
virtual void moveEvent(QMoveEvent *event) override;
/**
* Cares about painting the
*/
virtual void paintEvent(QPaintEvent *e) override;
/**
* The content is a DockArea or a DockWidget
*/
CFloatingDragPreview(QWidget* Content, QWidget* parent);
public:
using Super = QWidget;
/**
* Creates an instance for undocking the DockWidget in Content parameter
*/
CFloatingDragPreview(CDockWidget* Content);
/**
* Creates an instance for undocking the DockArea given in Content
* parameters
*/
CFloatingDragPreview(CDockAreaWidget* Content);
/**
* Delete private data
*/
~CFloatingDragPreview();
/**
* We filter the events of the assigned content widget to receive
* escape key presses for canceling the drag operation
*/
virtual bool eventFilter(QObject *watched, QEvent *event) override;
public: // implements IFloatingWidget -----------------------------------------
virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
eDragState DragState, QWidget* MouseEventHandler) override;
/**
* Moves the widget to a new position relative to the position given when
* startFloating() was called
*/
virtual void moveFloating() override;
/**
* Finishes dragging.
* Hides the dock overlays and executes the real undocking and docking
* of the assigned Content widget
*/
virtual void finishDragging() override;
signals:
/**
* This signal is emitted, if dragging has been canceled by escape key
* or by active application switching via task manager
*/
void draggingCanceled();
};
} // namespace ads
//---------------------------------------------------------------------------
#endif // FloatingDragPreviewH

73
src/IconProvider.cpp Normal file
View File

@@ -0,0 +1,73 @@
//============================================================================
/// \file IconProvider.cpp
/// \author Uwe Kindler
/// \date 18.10.2019
/// \brief Implementation of CIconProvider
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include "IconProvider.h"
#include <QVector>
namespace ads
{
/**
* Private data class (pimpl)
*/
struct IconProviderPrivate
{
CIconProvider *_this;
QVector<QIcon> UserIcons{IconCount, QIcon()};
/**
* Private data constructor
*/
IconProviderPrivate(CIconProvider *_public);
};
// struct LedArrayPanelPrivate
//============================================================================
IconProviderPrivate::IconProviderPrivate(CIconProvider *_public) :
_this(_public)
{
}
//============================================================================
CIconProvider::CIconProvider() :
d(new IconProviderPrivate(this))
{
}
//============================================================================
CIconProvider::~CIconProvider()
{
delete d;
}
//============================================================================
QIcon CIconProvider::customIcon(eIcon IconId) const
{
Q_ASSERT(IconId < d->UserIcons.size());
return d->UserIcons[IconId];
}
//============================================================================
void CIconProvider::registerCustomIcon(eIcon IconId, const QIcon &icon)
{
Q_ASSERT(IconId < d->UserIcons.size());
d->UserIcons[IconId] = icon;
}
} // namespace ads
//---------------------------------------------------------------------------
// EOF IconProvider.cpp

61
src/IconProvider.h Normal file
View File

@@ -0,0 +1,61 @@
#ifndef IconProviderH
#define IconProviderH
//============================================================================
/// \file IconProvider.h
/// \author Uwe Kindler
/// \date 18.10.2019
/// \brief Declaration of CIconProvider
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include <QIcon>
#include "ads_globals.h"
namespace ads
{
struct IconProviderPrivate;
/**
* This object provides all icons that are required by the advanced docking
* system.
* The IconProvider enables the user to register custom icons in case using
* stylesheets is not an option.
*/
class ADS_EXPORT CIconProvider
{
private:
IconProviderPrivate* d; ///< private data (pimpl)
friend struct IconProviderPrivate;
public:
/**
* Default Constructor
*/
CIconProvider();
/**
* Virtual Destructor
*/
virtual ~CIconProvider();
/**
* The function returns a custom icon if one is registered and a null Icon
* if no custom icon is registered
*/
QIcon customIcon(eIcon IconId) const;
/**
* Registers a custom icon for the given IconId
*/
void registerCustomIcon(eIcon IconId, const QIcon &icon);
}; // class IconProvider
} // namespace ads
//---------------------------------------------------------------------------
#endif // IconProviderH

View File

@@ -30,8 +30,11 @@
//============================================================================ //============================================================================
#include <QVariant> #include <QVariant>
#include <QPainter> #include <QPainter>
#include <QAbstractButton>
#include "DockSplitter.h" #include "DockSplitter.h"
#include "DockManager.h"
#include "IconProvider.h"
#include "ads_globals.h" #include "ads_globals.h"
@@ -90,6 +93,31 @@ void hideEmptyParentSplitters(CDockSplitter* Splitter)
} }
} }
//============================================================================
void setButtonIcon(QAbstractButton* Button, QStyle::StandardPixmap StandarPixmap,
ads::eIcon CustomIconId)
{
// First we try to use custom icons if available
QIcon Icon = CDockManager::iconProvider().customIcon(CustomIconId);
if (!Icon.isNull())
{
Button->setIcon(Icon);
return;
}
#ifdef Q_OS_LINUX
Button->setIcon(Button->style()->standardIcon(StandarPixmap));
#else
// The standard icons does not look good on high DPI screens so we create
// our own "standard" icon here.
QPixmap normalPixmap = Button->style()->standardPixmap(StandarPixmap, 0, Button);
Icon.addPixmap(internal::createTransparentPixmap(normalPixmap, 0.25), QIcon::Disabled);
Icon.addPixmap(normalPixmap, QIcon::Normal);
Button->setIcon(Icon);
#endif
}
} // namespace internal } // namespace internal
} // namespace ads } // namespace ads

View File

@@ -34,6 +34,10 @@
#include <QtCore/QtGlobal> #include <QtCore/QtGlobal>
#include <QPixmap> #include <QPixmap>
#include <QWidget> #include <QWidget>
#include <QDebug>
#include <QStyle>
class QAbstractButton;
#ifndef ADS_STATIC #ifndef ADS_STATIC
#ifdef ADS_SHARED_EXPORT #ifdef ADS_SHARED_EXPORT
@@ -60,6 +64,13 @@ class QSplitter;
namespace ads namespace ads
{ {
enum eStateFileVersion
{
InitialVerison = 0,
Version1 = 1,
CurrentVersion = Version1
};
class CDockSplitter; class CDockSplitter;
enum DockWidgetArea enum DockWidgetArea
@@ -96,6 +107,28 @@ enum eDragState
DraggingFloatingWidget//!< DraggingFloatingWidget DraggingFloatingWidget//!< DraggingFloatingWidget
}; };
/**
* The different icons used in the UI
*/
enum eIcon
{
TabCloseIcon, //!< TabCloseIcon
DockAreaMenuIcon, //!< DockAreaMenuIcon
DockAreaUndockIcon,//!< DockAreaUndockIcon
DockAreaCloseIcon, //!< DockAreaCloseIcon
IconCount, //!< just a delimiter for range checks
};
/**
* For bitwise combination of dock wdget features
*/
enum eBitwiseOperator
{
BitwiseAnd,
BitwiseOr
};
namespace internal namespace internal
{ {
static const bool RestoreTesting = true; static const bool RestoreTesting = true;
@@ -185,6 +218,39 @@ void setFlag(T& Flags, typename T::enum_type flag, bool on = true)
#endif #endif
} }
/**
* Helper function for settings tooltips without cluttering the code with
* tests for preprocessor macros
*/
template <class QObjectPtr>
void setToolTip(QObjectPtr obj, const QString &tip)
{
#ifndef QT_NO_TOOLTIP
obj->setToolTip(tip);
#else
Q_UNUSED(obj);
Q_UNUSED(tip);
#endif
}
/**
* Helper function to set the icon of a certain button.
* Use this function to set the icons for the dock area and dock widget buttons.
* The function first uses the CustomIconId to get an icon from the
* CIconProvider. You can register your custom icons with the icon provider, if
* you do not want to use the default buttons and if you do not want to use
* stylesheets.
* If the IconProvider does not return a valid icon (icon is null), the function
* fetches the given standard pixmap from the QStyle.
* param[in] Button The button whose icons are to be set
* param[in] StandardPixmap The standard pixmap to be used for the button
* param[in] CustomIconId The identifier for the custom icon.
*/
void setButtonIcon(QAbstractButton* Button, QStyle::StandardPixmap StandarPixmap,
ads::eIcon CustomIconId);
} // namespace internal } // namespace internal
} // namespace ads } // namespace ads

View File

@@ -77,7 +77,7 @@ void FloatingWidgetTitleBarPrivate::createLayout()
TitleLabel->setElideMode(Qt::ElideRight); TitleLabel->setElideMode(Qt::ElideRight);
TitleLabel->setText("DockWidget->windowTitle()"); TitleLabel->setText("DockWidget->windowTitle()");
TitleLabel->setObjectName("floatingTitleLabel"); TitleLabel->setObjectName("floatingTitleLabel");
TitleLabel->setAlignment(Qt::AlignLeft); TitleLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
CloseButton = new tCloseButton(); CloseButton = new tCloseButton();
CloseButton->setObjectName("floatingTitleCloseButton"); CloseButton->setObjectName("floatingTitleCloseButton");
@@ -145,6 +145,10 @@ void CFloatingWidgetTitleBar::mousePressEvent(QMouseEvent *ev)
void CFloatingWidgetTitleBar::mouseReleaseEvent(QMouseEvent *ev) void CFloatingWidgetTitleBar::mouseReleaseEvent(QMouseEvent *ev)
{ {
d->DragState = DraggingInactive; d->DragState = DraggingInactive;
if (d->FloatingWidget)
{
d->FloatingWidget->finishDragging();
}
Super::mouseReleaseEvent(ev); Super::mouseReleaseEvent(ev);
} }

View File

@@ -35,12 +35,15 @@ HEADERS += \
DockContainerWidget.h \ DockContainerWidget.h \
DockManager.h \ DockManager.h \
DockWidget.h \ DockWidget.h \
DockWidgetTab.h \ DockWidgetTab.h \
DockingStateReader.h \
FloatingDockContainer.h \ FloatingDockContainer.h \
FloatingDragPreview.h \
DockOverlay.h \ DockOverlay.h \
DockSplitter.h \ DockSplitter.h \
DockAreaTitleBar.h \ DockAreaTitleBar.h \
ElidingLabel.h ElidingLabel.h \
IconProvider.h
SOURCES += \ SOURCES += \
@@ -50,12 +53,15 @@ SOURCES += \
DockContainerWidget.cpp \ DockContainerWidget.cpp \
DockManager.cpp \ DockManager.cpp \
DockWidget.cpp \ DockWidget.cpp \
DockingStateReader.cpp \
DockWidgetTab.cpp \ DockWidgetTab.cpp \
FloatingDockContainer.cpp \ FloatingDockContainer.cpp \
FloatingDragPreview.cpp \
DockOverlay.cpp \ DockOverlay.cpp \
DockSplitter.cpp \ DockSplitter.cpp \
DockAreaTitleBar.cpp \ DockAreaTitleBar.cpp \
ElidingLabel.cpp ElidingLabel.cpp \
IconProvider.cpp
unix { unix {

View File

@@ -59,11 +59,9 @@ ads--CDockWidget
border-width: 1px 0 0 0; border-width: 1px 0 0 0;
} }
#tabsMenuButton, ads--CTitleBarButton
#closeButton,
#undockButton
{ {
padding: 0px -2px; padding: 0px 0px;
} }

View File

@@ -59,14 +59,14 @@ ads--CDockWidget
border-width: 1px 0 0 0; border-width: 1px 0 0 0;
} }
#tabsMenuButton,
#closeButton, ads--CTitleBarButton
#undockButton
{ {
padding: 0px -2px; padding: 0px 0px;
} }
QScrollArea#dockWidgetScrollArea QScrollArea#dockWidgetScrollArea
{ {
padding: 0px; padding: 0px;

1833
versioneer.py Normal file

File diff suppressed because it is too large Load Diff