Compare commits

...

191 Commits
2.1.0 ... 2.5.2

Author SHA1 Message Date
githubuser0xFFFF
ae997d3d75 Merge pull request #80 from simulton/master
Hide tab before emitting event
2019-11-18 20:16:42 +01:00
githubuser0xFFFF
c48cf3875d Merge pull request #82 from ddemidov/master
Fix import in QtAds.__init__.py
2019-11-18 20:15:32 +01:00
Denis Demidov
46fb18fc58 Fix import in QtAds.__init__.py 2019-11-18 12:54:28 +03:00
Joel Bodenmann
8da6904dcd Merge pull request #4 from XenotriX/feature/hide_tab_after_event
Hide tab after viewToggled event
2019-11-14 14:54:56 +01:00
Tibo Clausen
2a51359159 Hide tab before emitting event 2019-11-14 14:07:19 +00:00
githubuser0xFFFF
ec48140309 Merge pull request #75 from simulton/master
Fix cmake when compiling to a static lib
2019-10-24 14:15:23 +02:00
Joel Bodenmann
fe64f407c0 Merge pull request #3 from XenotriX/bugfix/cmake_static_lib
Partially reverse previous change
2019-10-22 13:57:56 +02:00
Tibo Clausen
136d6d966c Partially reverse previous change 2019-10-22 13:47:07 +01:00
Uwe Kindler
de645b3cca Fixed DLL export of DockAreaTabBar, DockAreaTitleBar and ElidingLabel 2019-10-18 07:41:28 +02:00
githubuser0xFFFF
f6174faebb Merge pull request #71 from metgem/master
Add PyQt5 bindings
2019-10-18 07:31:04 +02:00
Joel Bodenmann
0d3ec46095 Merge pull request #2 from XenotriX/bugfix/cmake_static_lib
Fix cmake when compiling to a static lib
2019-10-17 16:31:53 +02:00
githubuser0xFFFF
53fed8b765 Merge pull request #72 from yozka/change_include_files
Change include files
2019-10-09 22:05:08 +02:00
Nicolas ELIE
5752bfb58b Add PyQt5 bindings 2019-10-09 14:15:53 +02:00
Tibo Clausen
5378d90ba7 Fix cmake when compiling to a static lib 2019-10-09 11:39:32 +01:00
Yozka
ae96bbc0a0 include file path change 2019-10-06 23:47:36 +02:00
githubuser0xFFFF
c10ff7c688 Merge pull request #69 from nairaner/feature/cmake-find
Add support for CMake Find config module
2019-10-01 11:58:37 +02:00
githubuser0xFFFF
d2fb1579a5 Merge pull request #68 from nairaner/bugfix/floating-window-add-dock
Update floating widget titlebar visibility after adding new tab
2019-10-01 11:54:38 +02:00
Uwe Kindler
156cc71040 Fix emission of viewToggled() signal for dock widgets that are not part of the state that is restored 2019-10-01 11:48:53 +02:00
Krzysztof Machura
909c189d7f Add support for CMake Find config module 2019-10-01 10:25:24 +02:00
Krzysztof Machura
50c529b77f Update floating widget titlebar visibility after adding new tab 2019-09-30 17:33:40 +02:00
Andreev Alexander
84b501205a Merge pull request #4 from githubuser0xFFFF/master
fork update
2019-09-14 20:18:35 +02:00
Uwe Kindler
664a1674ab Fixed a bug in the new internal setFlag function 2019-09-13 14:26:18 +02:00
Uwe Kindler
0c5ef5e158 Added support for new configuration flag RetainTabSizeWhenCloseButtonHidden 2019-09-13 14:19:43 +02:00
Uwe Kindler
b776fc24a6 Fixed sizeHints and sizePolicies to properly support different font sizes i.e. set via QApplication::setFont 2019-09-13 10:25:33 +02:00
Uwe Kindler
c5e7104413 Set autoRaise property to true for QToolButton of DockWidgetTab 2019-09-13 08:27:02 +02:00
Uwe Kindler
2c7764ecf7 Properly implemented flag DockAreaHasCloseButton 2019-09-12 21:24:48 +02:00
Uwe Kindler
bed99eacc2 DockManager configFlags functions are now static because the configuration flags are global, added support for QToolButton as tab close button 2019-09-12 21:15:35 +02:00
Uwe Kindler
dae677e479 Added support for QToolButton tab close buttons 2019-09-10 09:23:12 +02:00
Uwe Kindler
a05078c947 Added information about resetting the styleheet of the dock manager 2019-09-09 16:01:51 +02:00
githubuser0xFFFF
3fcf05fb29 Merge pull request #57 from simulton/master
Fix PR #44
2019-09-09 15:16:19 +02:00
Joel Bodenmann
cdca8c2ac0 Merge pull request #1 from XenotriX1337/deprecated_function
Replace deprecated function
2019-09-09 14:31:19 +02:00
Tibo Clausen
53ec8b896a Replace deprecated function call 2019-09-09 14:05:37 +01:00
githubuser0xFFFF
6e6c1512a6 Merge pull request #55 from duerr-ndt/use_qt_style_icon_size
Use small icon size from QStyle for dock widget tab icon.
2019-09-09 08:25:45 +02:00
githubuser0xFFFF
8e0ea57319 Update README.md 2019-08-30 21:15:39 +02:00
Uwe Kindler
9bd55cc15a Fixed broken CMake build 2019-08-29 08:16:19 +02:00
Uwe Kindler
c8d4487a95 Improved source code documentation, removed empty main.qrc to silence qmake warning 2019-08-26 07:58:56 +02:00
Nick D'Ademo
12b0182337 Use small icon size from QStyle for dock widget tab icon. 2019-08-22 21:04:02 +08:00
Uwe Kindler
a2b07fd97f Reverted change of last pull request because it broke ElidingLabel on Windows 2019-08-13 20:13:19 +02:00
githubuser0xFFFF
078905181e Merge pull request #44 from simulton/master
Replace deprecated function call to QFontMetrics::width()
2019-08-13 19:44:09 +02:00
githubuser0xFFFF
7c9ed9b624 Merge pull request #47 from LoganBarnes/master
fix: Add quotes to CMake BUILD_INTERFACE generator
2019-08-12 22:02:14 +02:00
Logan Barnes
ac164c3a97 fix: Add quotes to cmake BUILD_INTERFACE generator 2019-08-11 00:46:30 +01:00
Joel Bodenmann
2b7232c9b3 Replace deprecated function call
QFontMetrics::width() has been deprecated. Using QFontMetrics::horizontalAdvance() is the proper way to go (introduce in Qt 5.11).
2019-08-06 22:43:30 +02:00
githubuser0xFFFF
6cc7d79832 Merge pull request #42 from simulton/master
Add .idea folders to .gitignore
2019-07-26 09:24:27 +02:00
Joel Bodenmann
0b88843d76 Add .idea folders to .gitignore
All JetBrains IDEs create a .idea folder in the project root that is local to the system/user and should not be included in a repository.
2019-07-25 14:24:00 +02:00
githubuser0xFFFF
554f26a614 Merge pull request #41 from kozodeevv/Conditional_prints
Make debug messages conditional.
2019-07-22 22:44:41 +02:00
Jak Erdy - SBI
10fbb6f302 Make debug messages conditional.
You can swich it on/off via defining ADS_DEBUG_PRINT
By default massages wouldn't be printed.
2019-07-21 14:53:24 +07:00
githubuser0xFFFF
bf27207dd9 Merge pull request #40 from kozodeevv/Fix_CDockWidget_Action_Leak
Fix of action leak in CDockWidget
2019-07-15 09:58:05 +02:00
JakErdy
97f02d39e6 Fix of action leak in CDockWidget, that apears when deleting DockWidget after tab closing 2019-07-14 01:35:20 +07:00
Uwe Kindler
64231d037d Fixed build for Qt5.5.1 2019-07-12 14:45:35 +02:00
githubuser0xFFFF
6eb869014e Merge pull request #38 from tatatupi/bugfix/linux_cmake
adding linux src files to CMake
2019-07-12 14:41:39 +02:00
Taiguara
a564ca5ce5 adding linux src files to CMake 2019-07-12 09:35:06 -03:00
githubuser0xFFFF
365b989364 Update README.md
Updated Linux documentation because linux_experimental branch has been merged into master
2019-07-12 11:05:12 +02:00
Uwe Kindler
a3baf7dcf6 Changes in eclipse project file 2019-07-12 10:51:21 +02:00
Uwe Kindler
538e690c22 Fixed warning for unused parameter in DockOverlay.cpp 2019-07-12 10:39:59 +02:00
Uwe Kindler
b1309da89a Some changes to fix build for windows 2019-07-12 10:37:14 +02:00
Uwe Kindler
d2f751ef87 Moved linux specific code into linux sub folder 2019-07-11 16:12:15 +02:00
Uwe Kindler
35c1b04c58 Merge branch 'refs/heads/master' into linux_experimental 2019-07-11 15:50:24 +02:00
Uwe Kindler
0de1a9ccae Properly implemented support for DockWidgetFloatable feature - now detaching a DockWidget or a DockAre that is not floatable is not possible (support for DockWidgetMovable feature is not implemented yet) 2019-07-11 15:12:39 +02:00
Uwe Kindler
c45327aafd Removed enum eXmlMode and added XmlAutoFormatting flag anc XmlCompressionEnabled flag to eConfigFlags. Added support for XML compression for the XML generated by the store function. If enabled then XML the generated XML is not human readable anymore but it needs less space when storing into settings file 2019-06-26 14:57:14 +02:00
Uwe Kindler
8853c751d6 Merge branch 'master' into linux_experimental 2019-06-04 13:40:20 +02:00
githubuser0xFFFF
e978a32a09 Merge pull request #32 from simulton/master
Feature: Remove docks
2019-06-04 13:32:15 +02:00
Joel Bodenmann
ca5683f5bf Merge pull request #1 from simulton/feature/remove_docks
Feature/remove docks
2019-05-17 21:40:36 +02:00
Tibo Clausen
c630a59afe Replace CDockWidget::releaseWidget() with CDockWidget::takeWidget() 2019-05-16 13:08:48 +01:00
Tibo Clausen
b9b8ff9c76 Add CDockWidget::releaseWidget() 2019-05-16 11:53:31 +01:00
Tibo Clausen
e2c5204d00 Clear LastAddedAreaCache when restoring 2019-05-15 16:13:55 +01:00
Tibo Clausen
5ee94d7602 Improve CDockManager::addDockWidgetTab() for dynamically added widgets 2019-05-15 14:30:32 +01:00
Tibo Clausen
69894f3f88 Remove area from LastAddedAreaCache 2019-05-15 14:20:08 +01:00
Tibo Clausen
641946bff5 Add CDockManager::removeDockWidget() 2019-05-15 13:47:58 +01:00
githubuser0xFFFF
27dd7a1b75 Update README.md 2019-05-15 10:14:22 +02:00
Uwe Kindler
5425f2b9e1 Added missing FloatingWidgetTitleBar.cpp and missing stylesheet file for linux 2019-05-15 09:12:22 +02:00
githubuser0xFFFF
4320e350c8 Update README.md 2019-05-14 16:03:47 +02:00
Uwe Kindler
8351aa11e7 Added linux screenshot 2019-05-14 15:42:47 +02:00
Uwe Kindler
e98fd5bcb3 Improved icons for all button, adjusted size of dock marker 2019-05-14 15:32:50 +02:00
Uwe Kindler
a012af2aac Created experimental linux branch with initial experimental linux
support
2019-05-14 14:09:10 +02:00
githubuser0xFFFF
df285dd385 Merge pull request #26 from gameraccoon/master
Fix compilation on linux using cmake
2019-05-13 09:02:43 +02:00
Uwe Kindler
a6ed4354a9 Implemented workaround for blurry icons in latest Qt versions 2019-05-10 11:33:26 +02:00
Uwe Kindler
1fccb943fe Fixed setWidget function of DockWidget to properly setup the internal scroll area 2019-05-10 10:32:06 +02:00
Pavel Grebnev
7bd3765fa7 Fix compilation on linux 2019-05-04 19:08:47 +03:00
Uwe Kindler
9b56ca08e1 Changes to work around new QT issues in non client area code that comes with the new Qt version 5.12.2 2019-03-22 13:57:17 +01:00
Uwe Kindler
49a7682e74 Merge branch 'master' of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System 2019-03-06 14:37:35 +01:00
Uwe Kindler
e25bf2eac2 Disabled minimize button for floating widgets because user cannot restore minimized windows because they do not have a taskbar entry 2019-03-06 14:36:20 +01:00
Andreev Alexander
f7c8384b73 Merge pull request #3 from githubuser0xFFFF/master
merge
2019-02-01 20:47:51 +05:00
githubuser0xFFFF
9bd06401d9 Update README.md
Fixed Travis CI and Appveyor badges to use the right account
2019-01-28 13:37:01 +01:00
Uwe Kindler
b44a7e75ca Implemented workarund for NonClientArea mouse event bug in Qt versions > 5.9.2. 2019-01-26 14:44:14 +01:00
githubuser0xFFFF
c9645ef85b Update README.md
Added travis badge
2019-01-26 13:54:35 +01:00
githubuser0xFFFF
fd09a681c4 Merge pull request #19 from VSRonin/master
Various fixes to the project files to uniform names and correctly compile static libraries.

Added configuration files for Appveyor and Travis CI, adding the project to those services should work out of the box.
2019-01-26 13:45:21 +01:00
Luca Beldi
e113790bbe Various fixes after code review
Minimum required Qt lowered to 5.5.0
Added CI for Qt 5.5.1 build
Increased C++ standard to C++14
Fixed use of spaces instead of tabs
Removed duplicate constructors
2019-01-25 16:28:36 +00:00
Andreev Alexander
957dce5d1f Merge pull request #2 from githubuser0xFFFF/master
merge
2019-01-25 14:05:55 +05:00
githubuser0xFFFF
e352ce559b Merge pull request #20 from yozka/feature_2
set tooltip for titlebar and menu
2019-01-25 09:21:46 +01:00
Yozka
0c3ef64d3e Fixed? remove space in tabs 2019-01-25 09:05:30 +05:00
Yozka
f72e2ce058 Added demo example tooltip for calendar dockWidget #20 2019-01-25 08:56:30 +05:00
yozka
befdcce343 set tooltip for titlebar and menu #20 2019-01-23 22:04:37 +05:00
Yozka
6fc8964ffc set tooltip for titlebar and menu #20 2019-01-23 22:01:30 +05:00
Yozka
6cb1f33451 ToolTip from titlebar and menu 2019-01-23 11:43:07 +05:00
Luca Beldi
ee616c2541 fixed travis script 2019-01-18 08:33:11 +00:00
Luca Beldi
7dd2a3c83c added travis configuration 2019-01-17 09:00:41 +00:00
Luca Beldi
9db502e652 Fixed appveyor project 2019-01-17 08:31:04 +00:00
Andreev Alexander
1ad6caeb8a Merge pull request #1 from githubuser0xFFFF/master
merge base
2019-01-17 10:54:30 +05:00
githubuser0xFFFF
4dde545c8f Merge pull request #18 from yozka/feature
set title bar and title toggle view action
2019-01-16 21:54:43 +01:00
Luca Beldi
b7a5918974 Fixed project files
Fixed compilation on compilers that do not support C++14
Only 2 minor places required C++14, no need to impose it
2019-01-16 17:52:53 +00:00
Luca Beldi
ddfa6c2a43 added appveyor project 2019-01-16 16:52:45 +00:00
Luca Beldi
275520ae29 Fixes to project files
Fixed naming of projects using CMake
Added working static compile using qmake
Added conventional naming of debug libraries
Added install target to qmake
2019-01-16 16:49:59 +00:00
Andreev Alexander
1078387f5d Merge branch 'master' into feature 2019-01-16 18:28:09 +05:00
Yozka
c33dddbd47 set title bar and title toggle view action 2019-01-16 16:23:07 +05:00
githubuser0xFFFF
2570a880af Merge pull request #17 from VSRonin/master
Added CMake project file
2019-01-16 12:22:43 +01:00
Luca Beldi
40a8d9e6b4 Added CMake project file
CMake has been announced as the build system of choice for Qt in the
future so it's useful to provide a project file for it

Also added the possibility to compile as a static library
2019-01-16 09:44:34 +00:00
Uwe Kindler
9af6622466 Removed non existing resources from main.qrc 2019-01-15 19:45:14 +01:00
githubuser0xFFFF
4fa89374c4 Merge pull request #16 from sgaist/various_fixes
Various fixes
2019-01-15 19:29:32 +01:00
Samuel Gaist
1aaa56ef29 Removed non existing header in include 2019-01-15 17:24:29 +01:00
Samuel Gaist
d298a47bda Removed unused constants 2019-01-15 17:24:11 +01:00
Samuel Gaist
146b65206a Fix missing override warning 2019-01-15 17:23:47 +01:00
Samuel Gaist
616ad9f86e Add more generated files to gitignore 2019-01-15 17:20:29 +01:00
Samuel Gaist
aa9762718c Fix subdirs handling
It's considered bad practice to use the ordered CONFIG option. This
patch properly setups the subdirs dependencies.
2019-01-15 17:17:45 +01:00
githubuser0xFFFF
f26bee6677 Update README.md
Added video
2019-01-15 13:05:21 +01:00
Uwe Kindler
fb18de4868 Added new image for faking embedded youtube video 2019-01-15 13:01:47 +01:00
Uwe Kindler
e204e10113 Removed unused function 2019-01-15 11:47:57 +01:00
githubuser0xFFFF
a06a14d6cd Merge pull request #15 from skartashev/master
Qt 5.5.1 (ubuntu 16.04) compatibility buildfixes
2019-01-15 11:41:37 +01:00
Sergey Kartashev
88d4bea2c1 Qt 5.5.1 (ubuntu 16.04) compatibility buildfixes 2019-01-15 10:12:34 +03:00
Uwe Kindler
b8ad2f7577 Removed superfluous windows.h include from main.cpp and removed unused local variable FloatingContainer from dropIntoSection() function 2019-01-14 14:18:44 +01:00
Uwe Kindler
32e5d599f7 Improved handling of sizes when dropping or removing content 2019-01-14 13:58:40 +01:00
Uwe Kindler
48382ccd82 Merged the two draging state enumerations into a single one and reused it in FloatingDockContainer 2018-12-20 16:25:30 +01:00
Uwe Kindler
e37e4fdf57 Added context menu for dock area title bar to enable closing of area and other areas via context menu and to enable detaching of dock area via context menu 2018-12-20 15:29:38 +01:00
Uwe Kindler
c9a97534a8 Fixed indentationin README.md example 2018-12-20 09:20:17 +01:00
Uwe Kindler
8f54dd2a82 Added example project and updated documentation 2018-12-20 09:15:02 +01:00
githubuser0xFFFF
c0d6f959ec Merge pull request #12 from skartashev/master
fix forward declarations (class/struct)
2018-12-17 16:21:30 +01:00
Sergey Kartashev
8570139cd1 fix forward declarations (class/struct) 2018-12-17 14:41:43 +03:00
githubuser0xFFFF
b38919e909 Update README.md 2018-12-14 23:18:15 +01:00
githubuser0xFFFF
b19cc98c84 Update README.md 2018-12-14 23:16:49 +01:00
githubuser0xFFFF
f3f5b668e5 Update README.md 2018-12-12 11:59:29 +01:00
Uwe Kindler
82d15fbe29 Added new images for documentation 2018-12-12 11:46:16 +01:00
Uwe Kindler
01533a9f85 Merge branch 'master' of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System 2018-12-11 16:15:16 +01:00
Uwe Kindler
fb9f1d851b Updated doc images 2018-12-11 16:14:34 +01:00
githubuser0xFFFF
6fb80fdeb7 Update README.md 2018-12-11 15:26:38 +01:00
githubuser0xFFFF
e94cf9bcb7 Update README.md 2018-12-11 15:25:42 +01:00
Uwe Kindler
da0ec6dd4b Moved images into doc folder 2018-12-11 15:24:08 +01:00
Uwe Kindler
80efed693e Removed unused DockStateSerialization files, added support for opaque splitter resizing 2018-12-11 15:19:59 +01:00
Uwe Kindler
653f475e72 Removed wrong visibility initialisation of titlebar close button, added hideEmptyParentSplitters() function to properly hide tree of empty parent splitters if DockArea or DockWidget is removed, 2018-12-03 12:52:57 +01:00
Uwe Kindler
87e3777e37 Fixed hiding and showing of close button for tab group, added support for removing perspectives 2018-12-02 12:09:31 +01:00
Uwe Kindler
71f66ea6dc Improved ElidingLabel 2018-11-30 16:09:57 +01:00
Uwe Kindler
0b3f419c80 Added missing main.qrc file 2018-11-20 08:00:51 +01:00
Uwe Kindler
f69af82a49 Implemented context menu for dock widget tab to close or detach tab or to close all other tabs 2018-11-09 10:07:56 +01:00
Uwe Kindler
854f542164 Added global config flags to support different dock manager behaviour 2018-11-08 12:57:25 +01:00
Uwe Kindler
b9265fccec Properly implemented setting enable state of dock area close button 2018-11-08 12:22:15 +01:00
Uwe Kindler
b3a272110a Some changes for dockwidget tab close button, some refactorings to make insertion of widgets into dock widget easier, added createDefaultToolBar function for creation of toolbar and removed layout flags from CDockWidget 2018-11-08 10:04:29 +01:00
Uwe Kindler
316e5324ad Fixed showing of unassigned dock widgets 2018-11-07 14:34:49 +01:00
Uwe Kindler
6843703484 Fixed title bar button minimum size to enable stylesheet styling, fixed restore functionality 2018-11-07 13:50:43 +01:00
Uwe Kindler
115a9a5b3d Added High DPI support for the creation of drop indicator pixmaps 2018-11-05 14:12:34 +01:00
Uwe Kindler
a4838a41ac Added ElidingLabel to support text eliding for dock area tabs, removed debug output 2018-11-05 12:00:56 +01:00
Uwe Kindler
74b9d35c7b Fixed start drag distance to be based on QApplication::startDragDistance, fixed dragging of dock widget title bar to support dragging in x and y direction 2018-11-05 09:58:46 +01:00
Uwe Kindler
c973482b2b Properly implemented showing and hiding of TitleBarUndockButton 2018-11-05 09:07:18 +01:00
Uwe Kindler
188624440b Fixed proper selection and deselection of current tab in tabbar 2018-11-03 21:48:35 +01:00
Uwe Kindler
72ec61a043 Added access functions for the titlebar buttons 2018-11-03 20:51:02 +01:00
Uwe Kindler
0ac19ebdfb Update qrc and pro file 2018-11-02 09:31:13 +01:00
Uwe Kindler
bc6ffcc02c Fixed update of floating widget window title, make disabled close button look nicer, fixed restoring of floating dock container, change save and restore functionality of dock area to save the current dock widget name instead of the current index to ensure that the right dock widget is active in an area if the number of dock widgets changes for some reasons (i.e. in plugin based applications) 2018-11-02 09:19:53 +01:00
Uwe Kindler
a9246f7ce4 Switched to ToolButton instead of PushButtons for Close- and TabsMenu button in dock area title bar 2018-11-01 09:07:10 +01:00
Uwe Kindler
3f5697554a Changed store and restore functioality to save the current dock widget name of an dock area instead of the current index because if some dock widgets are missing when loading the configuration, the dock index might be wrong 2018-11-01 08:52:14 +01:00
Uwe Kindler
5e6c82b68d Started implementing VisibleDockAreaCount cache 2018-11-01 07:53:54 +01:00
Uwe Kindler
268f8655a1 Some smal improvements in FloatingDockContainer 2018-10-31 22:13:34 +01:00
Uwe Kindler
1dfabb3bef Fixed handling of dock area removal in floating dock container, added close-button.svg icon to enable display of disabled close button 2018-10-31 00:50:18 +01:00
Uwe Kindler
6617cf6f19 Implemented proper updating of floating widget title 2018-10-30 23:45:59 +01:00
Uwe Kindler
81523b0346 Removed code for disabling close button because this caused trouble, fixed updating of window title if dock area is removed 2018-10-30 14:30:02 +01:00
Uwe Kindler
927be9a7d9 Improved detection of dock widget dragging - uses a distance now (half the height of dock area title bar) 2018-10-15 15:09:59 +02:00
Uwe Kindler
ada3d6b3b5 Added minimumSizeHint function to DockWidget to prevent jumping of the height of a dock area when switching between dock widgets, fixed use of findParent function in DockWidget - non current dock widgets do not have a parent so this function will fail 2018-10-15 08:29:30 +02:00
Uwe Kindler
30bbd26d0a Added license information to DockAreTabBar and to DockAreTitleBar 2018-10-12 15:29:41 +02:00
Uwe Kindler
8637c89a6b Added proper support for closable feature, now the close button is disabled for floating widgets 2018-10-12 15:18:05 +02:00
Uwe Kindler
11e5f9c95a Properly implemented DockAreaTitle bar to encapsulate title bar functionality 2018-10-12 14:51:57 +02:00
Uwe Kindler
9bfb3fbea1 Created new DockAreaTitleBar class to encapsulate all title bar functionality 2018-10-12 13:37:37 +02:00
Uwe Kindler
9c95e34df5 Fixed some bugs in tabbar handling 2018-10-12 11:51:35 +02:00
Uwe Kindler
ceebda7431 Properly implemented tab removal in new DockAreaTabBar class 2018-10-12 10:41:19 +02:00
Uwe Kindler
75288af88c Properly implemented tab moving 2018-10-12 09:17:14 +02:00
Uwe Kindler
7c67d71f68 Fixed DockAreaTabBar.cpp to properly count the contained tabs (ignore stretch item) 2018-10-11 15:23:19 +02:00
Uwe Kindler
548dfb363a Fixed the return value of dockContainer() function if no dock area is assigned, fixed flagAsUnassigned() function 2018-10-11 14:15:27 +02:00
Uwe Kindler
9fec2bd515 Fixed chrash on restore state when accessing FloatingWidget that has been marked for deletion (deleteLater()) 2018-10-11 13:30:12 +02:00
Uwe Kindler
fc04aa2411 Added some debug output 2018-10-11 13:07:27 +02:00
Uwe Kindler
c3a5e3ef21 Fixed dropping of floating widgets with multiple dock widgets 2018-10-11 10:55:36 +02:00
Uwe Kindler
0e85431405 Changed stylesheet to highlight the active tab to improve debugging 2018-10-11 09:21:01 +02:00
Uwe Kindler
b3b6d20d96 Added dockWidgets() function to DockContainerWidget.h because invisible dock widgets are no children of a dock area and therefore FindChildrenRecursively() does not work 2018-10-11 08:54:32 +02:00
Uwe Kindler
272bbe275e Started implementing DockAreaTabBar to improve code, encapsulation and performance 2018-10-10 15:15:59 +02:00
Uwe Kindler
496aec211e Added new signals restoringState(), stateRestored(), openingPerspective(), perspectiveOpened(), improved restore state function to protect against multiple calls and to prevent show() events for all CDockWidgets and content if the widgets are removed from internal stack layout 2018-09-27 16:21:14 +02:00
Uwe Kindler
b9b72df9d4 Fixed some bugs that caused problems when calling toggleView() with the same state, some refactorings to improve code 2018-09-26 09:57:36 +02:00
Uwe Kindler
fcb1846bf5 Fixed resizing of dropped widget to the size of the dock overlay, small improve to improve performance when dropping into a container with many widgets 2018-09-14 15:02:47 +02:00
Uwe Kindler
9f1b2c122a Fixed showing and hiding of dock widget title bar. If a dock widget is the one and only visible widget in a FloatingDockContainer, then this widget does not have a tile bar because the window already has a window frame that provides the same functionality 2018-09-14 13:21:29 +02:00
Uwe Kindler
6ec38b48ef Fixed proper hiding of dock areas without any visible content when dragging out singkle widgets, prevente single dock widget from dragging if it is the last dock widget in a floating widget 2018-09-14 08:46:10 +02:00
Uwe Kindler
b93e723a83 Fixed problem in FloatingDockContainer.cpp that caused problem when dragging a maximized window, added support for sorted insertion of toggleView actions into vieMenu 2018-09-13 22:19:13 +02:00
Uwe Kindler
1a47918bdb Changed FloatingDockContainer to use an internal state machine to improve code clarity and to handle some corner cases on Windows where resizing and moving the floating window to the screen edges caused trouble 2018-09-12 15:37:07 +02:00
Uwe Kindler
ff9d965726 Fixed FloatingDockContainer dragging states 2018-09-12 15:00:16 +02:00
Uwe Kindler
77d2cebe39 Added support for a default tool bar in dockwidgets that can ajust the tool button size according to the floating state, added support for inserting the content widget in a scoll area to provide better resizing for dock widgets 2018-09-12 13:52:10 +02:00
Uwe Kindler
5d380708e1 Added support for make a single tab floating via double click 2018-09-07 13:13:44 +02:00
Uwe Kindler
aa7b36dbd1 Removed debug output 2018-09-07 12:56:20 +02:00
Uwe Kindler
c9123c3640 Fixed setting of tab widget visibility and toggleViewAction() state when dragging dock areas with closed dock widgets 2018-09-07 12:38:11 +02:00
Uwe Kindler
67199a81f4 Fixed docking into empty main dock container, fixed tab handling to properly show the right dock widget tab when removing a dock widget, fixed tab menu to only show visible tabs, tab menu is now dynamically created just befor menu is shown 2018-09-07 11:10:14 +02:00
93 changed files with 8714 additions and 1029 deletions

160
.appveyor.yml Normal file
View File

@@ -0,0 +1,160 @@
version: '2.3.2.{build}'
branches:
only:
- master
image: Visual Studio 2015
clone_depth: 1
environment:
global:
# Appveyor doesn't have Qt 12 yet
LatestLTSQtVersion: 5.9
LatestQtVersion: 5.11
matrix:
# Latest version of Qt, dll, 64bit, MSVC 2015, qmake
- QT5: C:\Qt\%LatestQtVersion%\msvc2015_64
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
targetPlatform: amd64
use_mingw: "false"
use_static: "false"
use_cmake: "false"
# 32 bit builds
# MSVC 2015 builds
# Dynamic Library builds
# LTS version of Qt, dll, 32bit, MSVC 2015, qmake
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
targetPlatform: x86
use_mingw: "false"
use_static: "false"
use_cmake: "false"
# LTS version of Qt, dll, 32bit, MSVC 2015, cmake
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
targetPlatform: x86
use_mingw: "false"
use_static: "false"
use_cmake: "true"
# end Dynamic Library builds
# Static Library builds
# LTS version of Qt, static, 32bit, MSVC 2015, qmake
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
targetPlatform: x86
use_mingw: "false"
use_static: "true"
use_cmake: "false"
# LTS version of Qt, static, 32bit, MSVC 2015, cmake
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
targetPlatform: x86
use_mingw: "false"
use_static: "true"
use_cmake: "true"
# end Static Library builds
# end MSVC 2015 builds
# MinGW builds
# Dynamic Library builds
# LTS version of Qt, dll, 32bit, MinGW, qmake
- QT5: C:\Qt\%LatestLTSQtVersion%\mingw53_32
COMPILER: C:\Qt\Tools\mingw530_32
targetPlatform: x86
use_mingw: "true"
use_static: "false"
use_cmake: "false"
# LTS version of Qt, dll, 32bit, MinGW, cmake
- QT5: C:\Qt\%LatestLTSQtVersion%\mingw53_32
COMPILER: C:\Qt\Tools\mingw530_32
targetPlatform: x86
use_mingw: "true"
use_static: "false"
use_cmake: "true"
# end Dynamic Library builds
# Static Library builds
# LTS version of Qt, static, 32bit, MinGW, qmake
- QT5: C:\Qt\%LatestLTSQtVersion%\mingw53_32
COMPILER: C:\Qt\Tools\mingw530_32
targetPlatform: x86
use_mingw: "true"
use_static: "true"
use_cmake: "false"
# LTS version of Qt, static, 32bit, MinGW, cmake
- QT5: C:\Qt\%LatestLTSQtVersion%\mingw53_32
COMPILER: C:\Qt\Tools\mingw530_32
targetPlatform: x86
use_mingw: "true"
use_static: "true"
use_cmake: "true"
# end Static Library builds
# end MinGW builds
# end 32 bit builds
# 64 bit builds
# MSVC 2015 builds
# Dynamic Library builds
# LTS version of Qt, dll, 64bit, MSVC 2015, qmake
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015_64
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
targetPlatform: amd64
use_mingw: "false"
use_static: "false"
use_cmake: "false"
# LTS version of Qt, dll, 64bit, MSVC 2015, cmake
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015_64
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
targetPlatform: amd64
use_mingw: "false"
use_static: "false"
use_cmake: "true"
# end Dynamic Library builds
# Static Library builds
# LTS version of Qt, static, 64bit, MSVC 2015, qmake
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015_64
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
targetPlatform: amd64
use_mingw: "false"
use_static: "true"
use_cmake: "false"
# LTS version of Qt, static, 64bit, MSVC 2015, cmake
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015_64
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
targetPlatform: amd64
use_mingw: "false"
use_static: "true"
use_cmake: "true"
# end Static Library builds
# end MSVC 2015 builds
# end 64 bit builds
matrix:
fast_finish: true
before_build:
- set PATH=%COMPILER%\bin;%QT5%\bin;%PATH%
- set originalWD=%CD%
- call "%QT5%\bin\qtenv2.bat"
- cd %originalWD%
- if %use_mingw%==false call "%COMPILER%\vcvarsall.bat" %targetPlatform%
- if %use_static%==true (set USESTATIC=ON) else (set USESTATIC=OFF)
- if %use_mingw%==true (set CMAKEGENERATOR="MinGW Makefiles") else (set CMAKEGENERATOR="NMake Makefiles")
- if %use_mingw%==true (set MAKEENGINE=mingw32-make) else (set MAKEENGINE=nmake)
- if %use_mingw%==true set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
build_script:
- if %use_cmake%==true mkdir .\build
- if %use_cmake%==true cd .\build
- if %use_cmake%==true cmake --version
- if %use_cmake%==true cmake -G %CMAKEGENERATOR% -DCMAKE_BUILD_TYPE=DEBUG -DBUILD_EXAMPLES=ON -DCMAKE_DEBUG_POSTFIX=d -DBUILD_STATIC=%USESTATIC% -DCMAKE_INSTALL_PREFIX="./installed" ../
- if %use_cmake%==true cmake --build .
- if %use_cmake%==true cmake --build . --target install
- if %use_cmake%==true cmake -G %CMAKEGENERATOR% -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_EXAMPLES=ON -DBUILD_STATIC=%USESTATIC% -DCMAKE_INSTALL_PREFIX="./installed" ../
- if %use_cmake%==true cmake --build .
- if %use_cmake%==true cmake --build . --target install
- if %use_cmake%==false if %use_static%==true qmake "CONFIG+=adsBuildStatic"
- if %use_cmake%==false if %use_static%==false qmake
- if %use_cmake%==false %MAKEENGINE% debug
- if %use_cmake%==false %MAKEENGINE% install
- if %use_cmake%==false %MAKEENGINE% release
- if %use_cmake%==false %MAKEENGINE% install
after_build:
- if %use_mingw%==true set PATH=C:\Program Files\Git\usr\bin;%PATH%

View File

@@ -83,6 +83,7 @@
</target>
<target name="Clean" path=" build" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@@ -99,7 +100,6 @@
<target name="qmake" path=" build" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>qmake</buildCommand>
<buildArguments>-recursive ../ads.pro</buildArguments>
<buildTarget/>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
@@ -122,7 +122,6 @@
</target>
<target name="Clean" path=" build/src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@@ -139,7 +138,6 @@
<target name="qmake" path=" build/src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>qmake</buildCommand>
<buildArguments>-recursive ../../src/src.pro</buildArguments>
<buildTarget/>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
@@ -152,6 +150,46 @@
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Build all" path=" build/example" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j</buildArguments>
<buildTarget>all</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Clean" path=" build/example" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Debug Build" path=" build/example" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j6</buildArguments>
<buildTarget>debug</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="qmake" path=" build/example" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>qmake</buildCommand>
<buildArguments>-recursive ../../example/example.pro</buildArguments>
<buildTarget/>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Release Build" path=" build/example" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j4</buildArguments>
<buildTarget>release</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Build all" path=" build/demo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j</buildArguments>
@@ -162,7 +200,6 @@
</target>
<target name="Clean" path=" build/demo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@@ -179,7 +216,6 @@
<target name="qmake" path=" build/demo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>qmake</buildCommand>
<buildArguments>-recursive ../../demo/demo.pro</buildArguments>
<buildTarget/>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
@@ -202,6 +238,7 @@
</target>
<target name="Clean" path=" build/AdvancedDockingSystemDemo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@@ -240,6 +277,7 @@
</target>
<target name="Clean" path=" build/AdvancedDockingSystemDemo_v2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@@ -278,6 +316,7 @@
</target>
<target name="Clean" path=" build/AdvancedDockingSystem" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@@ -294,7 +333,6 @@
<target name="qmake" path=" build/AdvancedDockingSystem" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>qmake</buildCommand>
<buildArguments>-recursive ../../AdvancedDockingSystem/src.pro</buildArguments>
<buildTarget/>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>

18
.gitignore vendored
View File

@@ -1,2 +1,18 @@
*.pro.user
/ build
/build
*.o
*.dylib
*.app
qrc_*
moc_*
ui_*
Makefile
# IDEs
.idea
# Python
.eggs
*.pyc
*.pyd
__pycache__

155
.travis.yml Normal file
View File

@@ -0,0 +1,155 @@
language: cpp
# gcc is clang on mac
compiler: gcc
git:
depth: 1
matrix:
fast_finish: true
include:
- name: Ubuntu qmake Qt5.5.1
os: linux
dist: trusty
group: stable
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt551-trusty'
update: true
packages:
- qt55base
- qt55tools
- gcc-6
- g++-6
- libc6-i386
script:
- PATH="/opt/qt55/bin:$PATH"
- CXX="g++-6"
- CC="gcc-6"
- qt55-env.sh
- qmake
- make
- make install
- name: Ubuntu qmake dll
os: linux
dist: xenial
group: stable
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt-5.12.0-xenial'
update: true
packages:
- qt512base
- qt512tools
- gcc-6
- g++-6
- libc6-i386
- libgl-dev
- libgl1-mesa-dev
- mesa-common-dev
script:
- PATH="/opt/qt512/bin:$PATH"
- CXX="g++-6"
- CC="gcc-6"
- qt512-env.sh
- qmake
- make
- make install
- name: Ubuntu qmake static
os: linux
dist: xenial
group: stable
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt-5.12.0-xenial'
update: true
packages:
- qt512base
- qt512tools
- gcc-6
- g++-6
- libc6-i386
- libgl-dev
- libgl1-mesa-dev
- mesa-common-dev
script:
- PATH="/opt/qt512/bin:$PATH"
- CXX="g++-6"
- CC="gcc-6"
- qt512-env.sh
- qmake "CONFIG+=adsBuildStatic"
- make
- make install
- name: macOS CMake dll
os: osx
osx_image: xcode10.1
addons:
homebrew:
packages:
- qt
update: true
script:
- PATH="/usr/local/opt/qt5/bin:$PATH"
- mkdir -p build
- cd build
- cmake --version
- cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_DEBUG_POSTFIX=_debug -DBUILD_EXAMPLES=ON -DBUILD_STATIC=OFF -DCMAKE_INSTALL_PREFIX="./installed" ../
- cmake --build .
- cmake --build . --target install
- cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_EXAMPLES=ON -DBUILD_STATIC=OFF -DCMAKE_INSTALL_PREFIX="./installed" ../
- cmake --build .
- cmake --build . --target install
- name: macOS CMake static
os: osx
osx_image: xcode10.1
addons:
homebrew:
packages:
- qt
update: true
script:
- PATH="/usr/local/opt/qt5/bin:$PATH"
- mkdir -p build
- cd build
- cmake --version
- cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_DEBUG_POSTFIX=_debug -DBUILD_EXAMPLES=ON -DBUILD_STATIC=ON -DCMAKE_INSTALL_PREFIX="./installed" ../
- cmake --build .
- cmake --build . --target install
- cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_EXAMPLES=ON -DBUILD_STATIC=ON -DCMAKE_INSTALL_PREFIX="./installed" ../
- cmake --build .
- cmake --build . --target install
- name: macOS qmake dll
os: osx
osx_image: xcode10.1
addons:
homebrew:
packages:
- qt
update: true
script:
- PATH="/usr/local/opt/qt5/bin:$PATH"
- qmake
- make
- make install
- name: macOS qmake static
os: osx
osx_image: xcode10.1
addons:
homebrew:
packages:
- qt
update: true
script:
- PATH="/usr/local/opt/qt5/bin:$PATH"
- qmake "CONFIG+=adsBuildStatic"
- make
- make install
notifications:
email: false

121
CMakeLists.txt Normal file
View File

@@ -0,0 +1,121 @@
cmake_minimum_required(VERSION 3.3)
set(ads_VERSION "2.3.2")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
project(QtAdvancedDockingSystem VERSION ${ads_VERSION})
option(BUILD_STATIC "Build the static library" OFF)
option(BUILD_EXAMPLES "Build the examples" ON)
set(REQUIRED_QT_VERSION 5.5.0)
find_package(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED)
message(STATUS "Found Qt ${Qt5Core_VERSION}")
set(ads_INCLUDE ${ads_INCLUDE} ${Qt5Core_INCLUDE_DIRS})
set(ads_INCLUDE ${ads_INCLUDE} "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(ads_LIBS ${ads_LIBS} ${Qt5Core_LIBRARIES})
set(ads_COMPILE_DEFINE ${ads_COMPILE_DEFINE} ${Qt5Core_COMPILE_DEFINITIONS})
set(ads_LIBS ${ads_LIBS} ${Qt5Gui_LIBRARIES})
set(ads_INCLUDE ${ads_INCLUDE} ${Qt5Gui_INCLUDE_DIRS})
set(ads_COMPILE_DEFINE ${ads_COMPILE_DEFINE} ${Qt5Gui_COMPILE_DEFINITIONS})
set(ads_LIBS ${ads_LIBS} ${Qt5Widgets_LIBRARIES})
set(ads_INCLUDE ${ads_INCLUDE} ${Qt5Widgets_INCLUDE_DIRS})
set(ads_COMPILE_DEFINE ${ads_COMPILE_DEFINE} ${Qt5Widgets_COMPILE_DEFINITIONS})
if(BUILD_STATIC)
set(CMAKE_STATIC_LIBRARY_SUFFIX "_static${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()
set(ads_SRCS
src/ads_globals.cpp
src/DockAreaTabBar.cpp
src/DockAreaTitleBar.cpp
src/DockAreaWidget.cpp
src/DockContainerWidget.cpp
src/DockManager.cpp
src/DockOverlay.cpp
src/DockSplitter.cpp
src/DockWidget.cpp
src/DockWidgetTab.cpp
src/ElidingLabel.cpp
src/FloatingDockContainer.cpp
src/ads.qrc
src/linux/FloatingWidgetTitleBar.cpp
)
set(ads_INSTALL_INCLUDE
src/ads_globals.h
src/DockAreaTabBar.h
src/DockAreaTitleBar.h
src/DockAreaWidget.h
src/DockContainerWidget.h
src/DockManager.h
src/DockOverlay.h
src/DockSplitter.h
src/DockWidget.h
src/DockWidgetTab.h
src/ElidingLabel.h
src/FloatingDockContainer.h
src/linux/FloatingWidgetTitleBar.h
)
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
set(ads_PlatformDir "x86")
else()
set(ads_PlatformDir "x64")
endif()
if(BUILD_STATIC)
add_library(qtadvanceddocking STATIC ${ads_SRCS})
target_compile_definitions(qtadvanceddocking PUBLIC ADS_STATIC)
else()
add_library(qtadvanceddocking SHARED ${ads_SRCS})
set(ads_COMPILE_DEFINE ${ads_COMPILE_DEFINE} ADS_SHARED_EXPORT)
endif()
install(FILES ${ads_INSTALL_INCLUDE}
DESTINATION include
COMPONENT headers
)
install(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md"
"${CMAKE_CURRENT_SOURCE_DIR}/gnu-lgpl-v2.1.md"
DESTINATION license
COMPONENT license
)
install(TARGETS qtadvanceddocking
EXPORT adsTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file("adsConfigVersion.cmake"
VERSION ${ads_VERSION}
COMPATIBILITY SameMajorVersion
)
install(EXPORT adsTargets
FILE adsTargets.cmake
NAMESPACE ads::
DESTINATION lib/cmake/ads
)
install(FILES "adsConfig.cmake" "${CMAKE_BINARY_DIR}/adsConfigVersion.cmake"
DESTINATION lib/cmake/ads
)
target_include_directories(qtadvanceddocking PUBLIC
"$<BUILD_INTERFACE:${ads_INCLUDE}>"
$<INSTALL_INTERFACE:include>
)
target_link_libraries(qtadvanceddocking PUBLIC ${ads_LIBS})
target_compile_definitions(qtadvanceddocking PRIVATE ${ads_COMPILE_DEFINE})
set_target_properties(qtadvanceddocking PROPERTIES
VERSION ${ads_VERSION}
EXPORT_NAME "QtAdvancedDockingSystem"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/bin"
)
if(BUILD_EXAMPLES)
add_subdirectory(example)
add_subdirectory(demo)
endif()

10
PyQtAds/QtAds/__init__.py Normal file
View File

@@ -0,0 +1,10 @@
from .ads import ads
from .._version import *
import inspect
for name, member in inspect.getmembers(ads):
if not name.startswith('_'):
globals()[name] = member
del ads

1
PyQtAds/__init__.py Normal file
View File

@@ -0,0 +1 @@
from .rc import *

9
PyQtAds/_version.py Normal file
View File

@@ -0,0 +1,9 @@
# THIS FILE IS GENERATED FROM PyQtAds SETUP.PY
short_version = '2.5.1'
version = '2.5.1'
full_version = '2.5.1'
git_revision = 'c10ff7c688fb50fe9157bad3982164e0f955f9e4'
release = True
if not release:
version = full_version

670
PyQtAds/rc.py Normal file
View File

@@ -0,0 +1,670 @@
# -*- 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()

120
README.md
View File

@@ -1,10 +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://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)
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 environements (IDEs) such as Visual Studio.
Everything is implemented with standard Qt functionality without any
platform specific code. Basic usage of QWidgets an QLayouts and using basic
platform specific code. Basic usage of QWidgets and QLayouts and using basic
styles as much as possible.
This work is based on and inspired by the
@@ -13,28 +18,36 @@ 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
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
### 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.
![Layout of widgets](preview.png)
![Dropping widgets](preview-dragndrop.png)
![Dropping widgets](doc/preview-dragndrop.png)\
\
![Dropping widgets](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](floating-widget-dragndrop.png)
![Docking inside floating windows](doc/floating-widget-dragndrop.png)\
\
![Docking inside floating windows](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](grouped-dragging.png)
![Grouped dragging](doc/grouped-dragging.png)\
\
![Grouped dragging](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
@@ -43,19 +56,108 @@ 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](perspectives.png)
![Perspective](doc/perspectives.png)\
\
![Perspective](doc/perspectives_dark.png)
## Tested Compatible Environments
- Windows 10
### 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)
The library was developed on and for Windows. It is used in a commercial Windows application and is therefore constantly tested.
### 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)
The application can be compiled for macOS. A user reported, that the library works on macOS. If have not tested it.
### 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)
The application can be compiled for Linux and has been developed and tested with **Kubuntu 18.04**.
![Advanced Docking on Linux](doc/linux_kubuntu_1804.png)
## Build
Open the `ads.pro` with QtCreator and start the build, that's it.
You can run the demo project and test it yourself.
## Getting started / Example
The following example shows the minimum code required to use the advanced Qt docking system.
*MainWindow.h*
```cpp
#include <QMainWindow>
#include "DockManager.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
// The main container for docking
ads::CDockManager* m_DockManager;
};
```
*MainWindow.cpp*
```cpp
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <QLabel>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
// Create the dock manager. Because the parent parameter is a QMainWindow
// the dock manager registers itself as the central widget.
m_DockManager = new ads::CDockManager(this);
// Create example content label - this can be any application specific
// widget
QLabel* l = new QLabel();
l->setWordWrap(true);
l->setAlignment(Qt::AlignTop | Qt::AlignLeft);
l->setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. ");
// Create a dock widget with the title Label 1 and set the created label
// as the dock widget content
ads::CDockWidget* DockWidget = new ads::CDockWidget("Label 1");
DockWidget->setWidget(l);
// Add the toggleViewAction of the dock widget to the menu to give
// the user the possibility to show the dock widget if it has been closed
ui->menuView->addAction(DockWidget->toggleViewAction());
// Add the dock widget to the top dock widget area
m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
}
MainWindow::~MainWindow()
{
delete ui;
}
```
## Developers
- Uwe Kindler, Project Maintainer
- Manuel Freiholz
## License information
[![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)

View File

@@ -2,4 +2,8 @@ TEMPLATE = subdirs
SUBDIRS = \
src \
demo
demo \
example
demo.depends = src
example.depends = src

5
adsConfig.cmake Normal file
View File

@@ -0,0 +1,5 @@
include(CMakeFindDependencyMacro)
find_dependency(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED)
find_dependency(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED)
find_dependency(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/adsTargets.cmake")

316
demo.py Normal file
View File

@@ -0,0 +1,316 @@
import datetime
import logging
from PyQt5.QtCore import (QCoreApplication, QDir, Qt, QSettings, QSignalBlocker,
QRect)
from PyQt5.QtGui import QGuiApplication
from PyQt5.QtWidgets import (QCalendarWidget, QFileSystemModel, QFrame, QLabel,
QMenu, QTreeView, QAction, QWidgetAction,
QComboBox, QStyle, QSizePolicy, QInputDialog)
from PyQt5 import QtWidgets
from PyQtAds import QtAds
class _State:
label_count = 0
calendar_count = 0
file_system_count = 0
def create_long_text_label_dock_widget(view_menu: QMenu) -> QtAds.CDockWidget:
'''
Create long text label dock widget
Parameters
----------
view_menu : QMenu
Returns
-------
value : QtAds.CDockWidget
'''
label = QLabel()
label.setWordWrap(True)
label.setAlignment(Qt.AlignTop | Qt.AlignLeft)
label.setText('''\
Label {} {} - Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum
sociis natoque penatibus et magnis dis parturient montes, nascetur
ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium
quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla
vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis
pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi.
Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu,
consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra
quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet.
'''.format(_State.label_count, str(datetime.datetime.now())))
_State.label_count += 1
dock_widget = QtAds.CDockWidget("Label {}".format(_State.label_count))
dock_widget.setWidget(label)
view_menu.addAction(dock_widget.toggleViewAction())
return dock_widget
def create_calendar_dock_widget(view_menu: QMenu) -> QtAds.CDockWidget:
'''
Create calendar dock widget
Parameters
----------
view_menu : QMenu
Returns
-------
value : QtAds.CDockWidget
'''
widget = QCalendarWidget()
dock_widget = QtAds.CDockWidget("Calendar {}".format(_State.calendar_count))
_State.calendar_count += 1
dock_widget.setWidget(widget)
dock_widget.setToggleViewActionMode(QtAds.CDockWidget.ActionModeShow)
view_menu.addAction(dock_widget.toggleViewAction())
return dock_widget
def create_file_system_tree_dock_widget(view_menu: QMenu) -> QtAds.CDockWidget:
'''
Create file system tree dock widget
Parameters
----------
view_menu : QMenu
Returns
-------
value : QtAds.CDockWidget
'''
widget = QTreeView()
widget.setFrameShape(QFrame.NoFrame)
m = QFileSystemModel(widget)
m.setRootPath(QDir.currentPath())
widget.setModel(m)
dock_widget = QtAds.CDockWidget("Filesystem {}".format(_State.file_system_count))
_State.file_system_count += 1
dock_widget.setWidget(widget)
view_menu.addAction(dock_widget.toggleViewAction())
return dock_widget
class MainWindow(QtWidgets.QMainWindow):
save_perspective_action: QAction
perspective_list_action: QWidgetAction
perspective_combo_box: QComboBox
dock_manager: QtAds.CDockManager
def __init__(self, parent=None):
super().__init__(parent)
self.save_perspective_action = None
self.perspective_list_action = None
self.perspective_combo_box = None
self.dock_manager = None
self.setup_ui()
self.dock_manager = QtAds.CDockManager(self)
self.perspective_combo_box.activated[str].connect(self.dock_manager.openPerspective)
self.create_content()
self.resize(800, 600)
self.restore_state()
self.restore_perspectives()
def setup_ui(self):
self.setObjectName("MainWindow")
self.resize(400, 300)
self.setDockOptions(QtWidgets.QMainWindow.AllowTabbedDocks)
self.centralWidget = QtWidgets.QWidget(self)
self.centralWidget.setObjectName("centralWidget")
self.setCentralWidget(self.centralWidget)
self.status_bar = QtWidgets.QStatusBar(self)
self.status_bar.setObjectName("statusBar")
self.setStatusBar(self.status_bar)
self.menu_bar = QtWidgets.QMenuBar(self)
self.menu_bar.setGeometry(QRect(0, 0, 400, 21))
self.menu_bar.setObjectName("menuBar")
self.menu_file = QtWidgets.QMenu(self.menu_bar)
self.menu_file.setObjectName("menuFile")
self.menu_view = QtWidgets.QMenu(self.menu_bar)
self.menu_view.setObjectName("menuView")
self.menu_about = QtWidgets.QMenu(self.menu_bar)
self.menu_about.setObjectName("menuAbout")
self.setMenuBar(self.menu_bar)
self.tool_bar = QtWidgets.QToolBar(self)
self.tool_bar.setObjectName("toolBar")
self.addToolBar(Qt.TopToolBarArea, self.tool_bar)
self.action_exit = QtWidgets.QAction(self)
self.action_exit.setObjectName("actionExit")
self.action_save_state = QtWidgets.QAction(self)
self.action_save_state.setObjectName("actionSaveState")
self.action_save_state.triggered.connect(self.saveState)
self.action_restore_state = QtWidgets.QAction(self)
self.action_restore_state.setObjectName("actionRestoreState")
self.action_restore_state.triggered.connect(self.restore_state)
self.menu_file.addAction(self.action_exit)
self.menu_file.addAction(self.action_save_state)
self.menu_file.addAction(self.action_restore_state)
self.menu_bar.addAction(self.menu_file.menuAction())
self.menu_bar.addAction(self.menu_view.menuAction())
self.menu_bar.addAction(self.menu_about.menuAction())
self.setWindowTitle("MainWindow")
self.menu_file.setTitle("File")
self.menu_view.setTitle("View")
self.menu_about.setTitle("About")
self.tool_bar.setWindowTitle("toolBar")
self.action_exit.setText("Exit")
self.action_save_state.setText("Save State")
self.action_restore_state.setText("Restore State")
self.create_actions()
def create_actions(self):
'''
Creates the toolbar actions
'''
self.tool_bar.addAction(self.action_save_state)
self.action_save_state.setIcon(self.style().standardIcon(QStyle.SP_DialogSaveButton))
self.tool_bar.addAction(self.action_restore_state)
self.action_restore_state.setIcon(self.style().standardIcon(QStyle.SP_DialogOpenButton))
self.save_perspective_action = QAction("Save Perspective", self)
self.save_perspective_action.triggered.connect(self.save_perspective)
self.perspective_list_action = QWidgetAction(self)
self.perspective_combo_box = QComboBox(self)
self.perspective_combo_box.setSizeAdjustPolicy(QComboBox.AdjustToContents)
self.perspective_combo_box.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
self.perspective_list_action.setDefaultWidget(self.perspective_combo_box)
self.tool_bar.addSeparator()
self.tool_bar.addAction(self.perspective_list_action)
self.tool_bar.addAction(self.save_perspective_action)
def create_content(self):
'''
Fill the dock manager with dock widgets
'''
# Test container docking
view_menu = self.menu_view
dock_widget = create_calendar_dock_widget(view_menu)
dock_widget.setIcon(self.style().standardIcon(QStyle.SP_DialogOpenButton))
dock_widget.setFeature(QtAds.CDockWidget.DockWidgetClosable, False)
self.dock_manager.addDockWidget(QtAds.LeftDockWidgetArea, dock_widget)
self.dock_manager.addDockWidget(QtAds.LeftDockWidgetArea, create_long_text_label_dock_widget(view_menu))
file_system_widget = create_file_system_tree_dock_widget(view_menu)
tool_bar = file_system_widget.createDefaultToolBar()
tool_bar.addAction(self.action_save_state)
tool_bar.addAction(self.action_restore_state)
self.dock_manager.addDockWidget(QtAds.BottomDockWidgetArea, file_system_widget)
file_system_widget = create_file_system_tree_dock_widget(view_menu)
tool_bar = file_system_widget.createDefaultToolBar()
tool_bar.addAction(self.action_save_state)
tool_bar.addAction(self.action_restore_state)
file_system_widget.setFeature(QtAds.CDockWidget.DockWidgetMovable, False)
top_dock_area = self.dock_manager.addDockWidget(QtAds.TopDockWidgetArea, file_system_widget)
dock_widget = create_calendar_dock_widget(view_menu)
dock_widget.setFeature(QtAds.CDockWidget.DockWidgetClosable, False)
dock_widget.setTabToolTip("Tab ToolTip\nHodie est dies magna")
self.dock_manager.addDockWidget(QtAds.CenterDockWidgetArea, dock_widget, top_dock_area)
# Test dock area docking
right_dock_area = self.dock_manager.addDockWidget(
QtAds.RightDockWidgetArea,
create_long_text_label_dock_widget(view_menu), top_dock_area)
self.dock_manager.addDockWidget(
QtAds.TopDockWidgetArea,
create_long_text_label_dock_widget(view_menu), right_dock_area)
bottom_dock_area = self.dock_manager.addDockWidget(
QtAds.BottomDockWidgetArea,
create_long_text_label_dock_widget(view_menu), right_dock_area)
self.dock_manager.addDockWidget(
QtAds.RightDockWidgetArea,
create_long_text_label_dock_widget(view_menu), right_dock_area)
self.dock_manager.addDockWidget(
QtAds.CenterDockWidgetArea,
create_long_text_label_dock_widget(view_menu), bottom_dock_area)
def save_state(self):
'''
Saves the dock manager state and the main window geometry
'''
settings = QSettings("Settings.ini", QSettings.IniFormat)
settings.setValue("mainWindow/Geometry", self.saveGeometry())
settings.setValue("mainWindow/State", self.saveState())
settings.setValue("mainWindow/DockingState", self.dock_manager.saveState())
def save_perspectives(self):
'''
Save the list of perspectives
'''
settings = QSettings("Settings.ini", QSettings.IniFormat)
self.dock_manager.savePerspectives(settings)
def restore_state(self):
'''
Restores the dock manager state
'''
settings = QSettings("Settings.ini", QSettings.IniFormat)
geom = settings.value("mainWindow/Geometry")
if geom is not None:
self.restoreGeometry(geom)
state = settings.value("mainWindow/State")
if state is not None:
self.restoreState(state)
state = settings.value("mainWindow/DockingState")
if state is not None:
self.dock_manager.restore_state(state)
def restore_perspectives(self):
'''
Restore the perspective listo of the dock manager
'''
settings = QSettings("Settings.ini", QSettings.IniFormat)
self.dock_manager.loadPerspectives(settings)
self.perspective_combo_box.clear()
self.perspective_combo_box.addItems(self.dock_manager.perspectiveNames())
def save_perspective(self):
perspective_name, ok = QInputDialog.getText(self, 'Save perspective', 'Enter unique name:')
if ok and perspective_name:
self.dock_manager.addPerspective(perspective_name)
_ = QSignalBlocker(self.perspective_combo_box)
self.perspective_combo_box.clear()
self.perspective_combo_box.addItems(self.dock_manager.perspectiveNames())
self.perspective_combo_box.setCurrentText(perspective_name)
self.save_perspectives()
def main(app_):
main_window = MainWindow()
main_window.show()
state = main_window.dock_manager.saveState()
# print('This is what the saved state looks like in XML:')
# print(str(state, 'utf-8'))
# print()
# main_window.dock_manager.restore_state(state)
return main_window
if __name__ == '__main__':
# logging.basicConfig(level='DEBUG')
QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
app = QtWidgets.QApplication([])
window = main(app)
window.show()
app.exec_()

47
demo/CMakeLists.txt Normal file
View File

@@ -0,0 +1,47 @@
cmake_minimum_required(VERSION 3.3)
set (CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
project(ads_demo VERSION "1.0")
set(REQUIRED_QT_VERSION 5.5.0)
find_package(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED)
set(ads_demo_LIBS ${ads_demo_LIBS} ${Qt5Core_LIBRARIES})
set(ads_demo_INCLUDE ${ads_demo_INCLUDE} ${Qt5Core_INCLUDE_DIRS})
set(ads_demo_COMPILE_DEFINE ${ads_demo_COMPILE_DEFINE} ${Qt5Core_COMPILE_DEFINITIONS} )
set(ads_demo_LIBS ${ads_demo_LIBS} ${Qt5Gui_LIBRARIES})
set(ads_demo_INCLUDE ${ads_demo_INCLUDE} ${Qt5Gui_INCLUDE_DIRS})
set(ads_demo_COMPILE_DEFINE ${ads_demo_COMPILE_DEFINE} ${Qt5Gui_COMPILE_DEFINITIONS})
set(ads_demo_LIBS ${ads_demo_LIBS} ${Qt5Widgets_LIBRARIES})
set(ads_demo_INCLUDE ${ads_demo_INCLUDE} ${Qt5Widgets_INCLUDE_DIRS})
set(ads_demo_COMPILE_DEFINE ${ads_demo_COMPILE_DEFINE} ${Qt5Widgets_COMPILE_DEFINITIONS})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(ads_demo_SRCS
main.cpp
MainWindow.cpp
mainwindow.ui
)
add_executable(AdvancedDockingSystemDemo WIN32 ${ads_demo_SRCS})
if(BUILD_STATIC)
set(ads_demo_DEFINE ${ads_demo_DEFINE} ADS_STATIC)
endif()
add_dependencies(AdvancedDockingSystemDemo qtadvanceddocking)
target_include_directories(AdvancedDockingSystemDemo PUBLIC
$<BUILD_INTERFACE:${ads_demo_INCLUDE}>
$<INSTALL_INTERFACE:include>
)
target_include_directories(AdvancedDockingSystemDemo PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../src" ${ads_demo_INCLUDE})
target_link_libraries(AdvancedDockingSystemDemo PRIVATE qtadvanceddocking ${ads_demo_LIBS})
target_compile_definitions(AdvancedDockingSystemDemo PRIVATE ${ads_demo_DEFINE})
set_target_properties(AdvancedDockingSystemDemo PROPERTIES
VERSION "1.0"
SOVERSION 1
EXPORT_NAME "Qt Advanced Docking System Demo"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/bin"
)

View File

@@ -88,6 +88,32 @@ static ads::CDockWidget* createLongTextLabelDockWidget(QMenu* ViewMenu)
}
/**
* Function returns a features string with closable (c), movable (m) and floatable (f)
* features. i.e. The following string is for a not closable but movable and floatable
* widget: c- m+ f+
*/
static QString featuresString(ads::CDockWidget* DockWidget)
{
auto f = DockWidget->features();
return QString("c%1 m%2 f%3")
.arg(f.testFlag(ads::CDockWidget::DockWidgetClosable) ? "+" : "-")
.arg(f.testFlag(ads::CDockWidget::DockWidgetMovable) ? "+" : "-")
.arg(f.testFlag(ads::CDockWidget::DockWidgetFloatable) ? "+" : "-");
}
/**
* Appends the string returned by featuresString() to the window title of
* the given DockWidget
*/
static void appendFeaturStringToWindowTitle(ads::CDockWidget* DockWidget)
{
DockWidget->setWindowTitle(DockWidget->windowTitle()
+ QString(" (%1)").arg(featuresString(DockWidget)));
}
//============================================================================
static ads::CDockWidget* createCalendarDockWidget(QMenu* ViewMenu)
{
@@ -110,7 +136,8 @@ static ads::CDockWidget* createFileSystemTreeDockWidget(QMenu* ViewMenu)
QFileSystemModel* m = new QFileSystemModel(w);
m->setRootPath(QDir::currentPath());
w->setModel(m);
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Filesystem %1").arg(FileSystemCount++));
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Filesystem %1")
.arg(FileSystemCount++));
DockWidget->setWidget(w);
ViewMenu->addAction(DockWidget->toggleViewAction());
return DockWidget;
@@ -127,7 +154,7 @@ struct MainWindowPrivate
Ui::MainWindow ui;
QAction* SavePerspectiveAction = nullptr;
QWidgetAction* PerspectiveListAction = nullptr;
QComboBox* PerspectiveComboBox = nullptr;;
QComboBox* PerspectiveComboBox = nullptr;
ads::CDockManager* DockManager = nullptr;
MainWindowPrivate(CMainWindow* _public) : _this(_public) {}
@@ -174,13 +201,23 @@ void MainWindowPrivate::createContent()
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu));
DockManager->addDockWidget(ads::BottomDockWidgetArea, createFileSystemTreeDockWidget(ViewMenu));
auto FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu);
auto ToolBar = FileSystemWidget->createDefaultToolBar();
ToolBar->addAction(ui.actionSaveState);
ToolBar->addAction(ui.actionRestoreState);
DockManager->addDockWidget(ads::BottomDockWidgetArea, FileSystemWidget);
FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu);
ToolBar = FileSystemWidget->createDefaultToolBar();
ToolBar->addAction(ui.actionSaveState);
ToolBar->addAction(ui.actionRestoreState);
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetMovable, false);
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
appendFeaturStringToWindowTitle(FileSystemWidget);
auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget);
DockWidget = createCalendarDockWidget(ViewMenu);
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
DockWidget->setTabToolTip(QString("Tab ToolTip\nHodie est dies magna"));
DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
// Test dock area docking
@@ -189,6 +226,13 @@ void MainWindowPrivate::createContent()
auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
//DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
//DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
for (auto DockWidget : DockManager->dockWidgetsMap())
{
_this->connect(DockWidget, SIGNAL(viewToggled(bool)), SLOT(onViewToggled(bool)));
}
}
@@ -258,17 +302,31 @@ CMainWindow::CMainWindow(QWidget *parent) :
QMainWindow(parent),
d(new MainWindowPrivate(this))
{
using namespace ads;
d->ui.setupUi(this);
d->createActions();
// uncomment the following line if the tab close button should be
// a QToolButton instead of a QPushButton
// CDockManager::setConfigFlags(CDockManager::configFlags() | CDockManager::TabCloseButtonIsToolButton);
// uncomment the following line if you wand a fixed tab width that does
// not change if the visibility of the close button changes
// CDockManager::setConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden, true);
// Now create the dock manager and its content
d->DockManager = new ads::CDockManager(this);
d->DockManager = new CDockManager(this);
// Uncomment the following line to have the old style where the dock
// area close button closes the active tab
// CDockManager::setConfigFlags({CDockManager::DockAreaHasCloseButton
// | CDockManager::DockAreaCloseButtonClosesTab});
connect(d->PerspectiveComboBox, SIGNAL(activated(const QString&)),
d->DockManager, SLOT(openPerspective(const QString&)));
d->createContent();
// Default window geometry
resize(800, 600);
resize(1280, 720);
d->restoreState();
d->restorePerspectives();
@@ -309,7 +367,6 @@ void CMainWindow::on_actionRestoreState_triggered(bool)
//============================================================================
void CMainWindow::savePerspective()
{
std::cout << "savePerspective" << std::endl;
QString PerspectiveName = QInputDialog::getText(this, "Save Perspective", "Enter unique name:");
if (PerspectiveName.isEmpty())
{
@@ -325,3 +382,16 @@ void CMainWindow::savePerspective()
d->savePerspectives();
}
//============================================================================
void CMainWindow::onViewToggled(bool Open)
{
auto DockWidget = qobject_cast<ads::CDockWidget*>(sender());
if (!DockWidget)
{
return;
}
qDebug() << DockWidget->objectName() << " viewToggled(" << Open << ")";
}

View File

@@ -58,6 +58,7 @@ private slots:
void on_actionSaveState_triggered(bool);
void on_actionRestoreState_triggered(bool);
void savePerspective();
void onViewToggled(bool Open);
};
#endif // MAINWINDOW_H

View File

@@ -1,29 +1,44 @@
ADS_ROOT = $${PWD}/..
ADS_OUT_ROOT = $${OUT_PWD}/..
TARGET = AdvancedDockingSystemDemo
DESTDIR = $${ADS_OUT_ROOT}/lib
QT += core gui widgets
CONFIG *= c++14
CONFIG += c++14
CONFIG += debug_and_release
DEFINES += QT_DEPRECATED_WARNINGS
adsBuildStatic {
DEFINES += ADS_STATIC
}
SOURCES += \
main.cpp \
MainWindow.cpp
HEADERS += \
MainWindow.h
FORMS += \
mainwindow.ui
LIBS += -L$${ADS_OUT_ROOT}/lib
# Dependency: AdvancedDockingSystem (shared)
win32:CONFIG(release, debug|release): LIBS += -lAdvancedDockingSystem
else:win32:CONFIG(debug, debug|release): LIBS += -lAdvancedDockingSystemd
else:unix: LIBS += -lAdvancedDockingSystem
CONFIG(debug, debug|release){
win32 {
LIBS += -lqtadvanceddockingd
}
else:mac {
LIBS += -lqtadvanceddocking_debug
}
else {
LIBS += -lqtadvanceddocking
}
}
else{
LIBS += -lqtadvanceddocking
}
INCLUDEPATH += ../src
DEPENDPATH += ../src

View File

@@ -35,6 +35,10 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#if QT_VERSION >= 0x050600
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
std::shared_ptr<int> b;
QApplication a(argc, argv);
a.setQuitOnLastWindowClosed(true);

BIN
doc/TabMenu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
doc/TabMenu_dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

BIN
doc/grouped-dragging.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
doc/linux_kubuntu_1804.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

BIN
doc/perspectives.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

BIN
doc/perspectives_dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
doc/preview-dragndrop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

BIN
doc/preview_dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

46
example/CMakeLists.txt Normal file
View File

@@ -0,0 +1,46 @@
cmake_minimum_required(VERSION 3.3)
set (CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
project(ads_example VERSION "1.0")
set(REQUIRED_QT_VERSION 5.5.0)
find_package(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED)
set(ads_example_LIBS ${ads_example_LIBS} ${Qt5Core_LIBRARIES})
set(ads_example_INCLUDE ${ads_example_INCLUDE} ${Qt5Core_INCLUDE_DIRS})
set(ads_example_COMPILE_DEFINE ${ads_example_COMPILE_DEFINE} ${Qt5Core_COMPILE_DEFINITIONS} )
set(ads_example_LIBS ${ads_example_LIBS} ${Qt5Gui_LIBRARIES})
set(ads_example_INCLUDE ${ads_example_INCLUDE} ${Qt5Gui_INCLUDE_DIRS})
set(ads_example_COMPILE_DEFINE ${ads_example_COMPILE_DEFINE} ${Qt5Gui_COMPILE_DEFINITIONS})
set(ads_example_LIBS ${ads_example_LIBS} ${Qt5Widgets_LIBRARIES})
set(ads_example_INCLUDE ${ads_example_INCLUDE} ${Qt5Widgets_INCLUDE_DIRS})
set(ads_example_COMPILE_DEFINE ${ads_example_COMPILE_DEFINE} ${Qt5Widgets_COMPILE_DEFINITIONS})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(ads_example_SRCS
main.cpp
MainWindow.cpp
MainWindow.ui
)
add_executable(Example1 WIN32 ${ads_example_SRCS})
if(BUILD_STATIC)
set(ads_example_DEFINE ${ads_example_DEFINE} ADS_STATIC)
endif()
add_dependencies(Example1 qtadvanceddocking)
target_include_directories(Example1 PUBLIC
$<BUILD_INTERFACE:${ads_example_INCLUDE}>
$<INSTALL_INTERFACE:include>
)
target_include_directories(Example1 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../src" ${ads_example_INCLUDE})
target_link_libraries(Example1 PRIVATE qtadvanceddocking ${ads_example_LIBS})
target_compile_definitions(Example1 PRIVATE ${ads_example_DEFINE})
set_target_properties(Example1 PROPERTIES
VERSION "1.0"
SOVERSION 1
EXPORT_NAME "Qt Advanced Docking System Example"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/bin"
)

39
example/MainWindow.cpp Normal file
View File

@@ -0,0 +1,39 @@
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <QLabel>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
// Create the dock manager. Because the parent parameter is a QMainWindow
// the dock manager registers itself as the central widget.
m_DockManager = new ads::CDockManager(this);
// Create example content label - this can be any application specific
// widget
QLabel* l = new QLabel();
l->setWordWrap(true);
l->setAlignment(Qt::AlignTop | Qt::AlignLeft);
l->setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. ");
// Create a dock widget with the title Label 1 and set the created label
// as the dock widget content
ads::CDockWidget* DockWidget = new ads::CDockWidget("Label 1");
DockWidget->setWidget(l);
// Add the toggleViewAction of the dock widget to the menu to give
// the user the possibility to show the dock widget if it has been closed
ui->menuView->addAction(DockWidget->toggleViewAction());
// Add the dock widget to the top dock widget area
m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
}
MainWindow::~MainWindow()
{
delete ui;
}

24
example/MainWindow.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "DockManager.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
ads::CDockManager* m_DockManager;
};
#endif // MAINWINDOW_H

38
example/MainWindow.ui Normal file
View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuView">
<property name="title">
<string>View</string>
</property>
</widget>
<addaction name="menuView"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

47
example/example.pro Normal file
View File

@@ -0,0 +1,47 @@
ADS_OUT_ROOT = $${OUT_PWD}/..
QT += core gui widgets
TARGET = Example1
DESTDIR = $${ADS_OUT_ROOT}/lib
TEMPLATE = app
CONFIG += c++14
CONFIG += debug_and_release
adsBuildStatic {
DEFINES += ADS_STATIC
}
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
MainWindow.cpp
HEADERS += \
MainWindow.h
FORMS += \
MainWindow.ui
LIBS += -L$${ADS_OUT_ROOT}/lib
# Dependency: AdvancedDockingSystem (shared)
CONFIG(debug, debug|release){
win32 {
LIBS += -lqtadvanceddockingd
}
else:mac {
LIBS += -lqtadvanceddocking_debug
}
else {
LIBS += -lqtadvanceddocking
}
}
else{
LIBS += -lqtadvanceddocking
}
INCLUDEPATH += ../src
DEPENDPATH += ../src

11
example/main.cpp Normal file
View File

@@ -0,0 +1,11 @@
#include "MainWindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

41
recipes/meta.yaml Normal file
View File

@@ -0,0 +1,41 @@
{% set data = load_setup_py_data() %}
package:
name: pyqtads
version: {{ data.get('version') }}
source:
path: ../
build:
number: 0
script: python setup.py install --single-version-externally-managed --record=record.txt --conda-recipe
requirements:
build:
- python
- setuptools
- pyqt>=5.9
- sip>=4.19
run:
- python
- pyqt>=5.9
- sip>=4.19
- pywin32 [win]
test:
imports:
- PyQtAds
about:
home: {{ data.get('url') }}
license: {{ data.get('license') }}
license_family: LGPL
license_file: 'LICENSE.md'
summary: {{ data.get('description') }}
description: {{ data.get('description') }}
doc_url: ''
dev_url: {{ data.get('url') }}
extra:
recipe-maintainers: 'nicolas.elie@cnrs.fr'

342
setup.py Normal file
View File

@@ -0,0 +1,342 @@
import os
import sys
import shlex
import subprocess
import glob
from setuptools import setup, find_packages
from setuptools.extension import Extension
from distutils import sysconfig, dir_util, spawn, log
from distutils.dep_util import newer
import sipdistutils
import sipconfig
from PyQt5.QtCore import PYQT_CONFIGURATION
from PyQt5.pyrcc_main import processResourceFile
MAJOR = 2
MINOR = 5
MICRO = 1
ISRELEASED = True
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
MODULE_NAME = "ads"
SRC_PATH = "PyQtAds"
REQUIRE_PYQT = True
if "--conda-recipe" in sys.argv:
REQUIRE_PYQT = False
sys.argv.remove("--conda-recipe")
class HostPythonConfiguration(object):
def __init__(self):
self.platform = sys.platform
self.version = sys.hexversion>>8
self.inc_dir = sysconfig.get_python_inc()
self.venv_inc_dir = sysconfig.get_python_inc(prefix=sys.prefix)
self.module_dir = sysconfig.get_python_lib(plat_specific=1)
if sys.platform == 'win32':
self.data_dir = sys.prefix
self.lib_dir = sys.prefix +'\\libs'
else:
self.data_dir = sys.prefix + '/share'
self.lib_dir = sys.prefix + '/lib'
class TargetQtConfiguration(object):
def __init__(self, qmake):
pipe = os.popen(' '.join([qmake, '-query']))
for l in pipe:
l = l.strip()
tokens = l.split(':', 1)
if isinstance(tokens, list):
if len(tokens) != 2:
error("Unexpected output from qmake: '%s'\n" % l)
name, value = tokens
else:
name = tokens
value = None
name = name.replace('/', '_')
setattr(self, name, value)
pipe.close()
class build_ext(sipdistutils.build_ext):
description = "Builds the " + MODULE_NAME + " module."
user_options = sipdistutils.build_ext.user_options + [
('qmake-bin=', None, "Path to qmake binary"),
('sip-bin=', None, "Path to sip binary"),
('qt-include-dir=', None, "Path to Qt headers"),
('pyqt-sip-dir=', None, "Path to PyQt's SIP files"),
('pyqt-sip-flags=', None, "SIP flags used to generate PyQt bindings"),
('sip-dir=', None, "Path to module's SIP files"),
('inc-dir=', None, "Path to module's include files")
]
def initialize_options (self):
super().initialize_options()
self.qmake_bin = 'qmake'
self.sip_bin = None
self.qt_include_dir = None
self.qt_libinfix = ''
self.pyqt_sip_dir = None
self.pyqt_sip_flags = None
self.sip_files_dir = None
self.sip_inc_dir = None
self.inc_dir = None
self.pyconfig = HostPythonConfiguration()
self.qtconfig = TargetQtConfiguration(self.qmake_bin)
self.config = sipconfig.Configuration()
self.config.default_mod_dir = ("/usr/local/lib/python%i.%i/dist-packages" %
(sys.version_info.major, sys.version_info.minor))
def finalize_options (self):
super().finalize_options()
if not self.qt_include_dir:
self.qt_include_dir = self.qtconfig.QT_INSTALL_HEADERS
if not self.qt_libinfix:
try:
with open(os.path.join(self.qtconfig.QT_INSTALL_PREFIX, 'mkspecs', 'qconfig.pri'), 'r') as f:
for line in f.readlines():
if line.startswith('QT_LIBINFIX'):
self.qt_libinfix = line.split('=')[1].strip('\n').strip()
except (FileNotFoundError, IndexError):
pass
if not self.pyqt_sip_dir:
self.pyqt_sip_dir = os.path.join(self.pyconfig.data_dir, 'sip', 'PyQt5')
if not self.pyqt_sip_flags:
self.pyqt_sip_flags = PYQT_CONFIGURATION.get('sip_flags', '')
if not self.sip_files_dir:
self.sip_files_dir = os.path.abspath(os.path.join(".", "sip"))
if not self.sip_inc_dir:
self.sip_inc_dir = self.pyconfig.venv_inc_dir
if not self.inc_dir:
self.inc_dir = os.path.abspath(os.path.join(".", "src"))
if not self.qt_include_dir:
raise SystemExit('Could not find Qt5 headers. '
'Please specify via --qt-include-dir=')
if not self.pyqt_sip_dir:
raise SystemExit('Could not find PyQt SIP files. '
'Please specify containing directory via '
'--pyqt-sip-dir=')
if not self.pyqt_sip_flags:
raise SystemExit('Could not find PyQt SIP flags. '
'Please specify via --pyqt-sip-flags=')
def _find_sip(self):
"""override _find_sip to allow for manually speficied sip path."""
return self.sip_bin or super()._find_sip()
def _sip_compile(self, sip_bin, source, sbf):
cmd = [sip_bin]
if hasattr(self, 'sip_opts'):
cmd += self.sip_opts
if hasattr(self, '_sip_sipfiles_dir'):
cmd += ['-I', self._sip_sipfiles_dir()]
cmd += [
"-I", self.sip_files_dir,
"-I", self.pyqt_sip_dir,
"-I", self.sip_inc_dir,
"-I", self.inc_dir,
"-c", self._sip_output_dir(),
"-b", sbf,
"-w", "-o"]
cmd += shlex.split(self.pyqt_sip_flags) # use same SIP flags as for PyQt5
cmd.append(source)
self.spawn(cmd)
def swig_sources (self, sources, extension=None):
if not self.extensions:
return
# Add the local include directory to the include path
if extension is not None:
extension.extra_compile_args += ['-D', 'QT_CORE_LIB',
'-D', 'QT_GUI_LIB',
'-D', 'QT_WIDGETS_LIB',
'-D', 'ADS_SHARED_EXPORT']
extension.include_dirs += [self.qt_include_dir, self.inc_dir,
os.path.join(self.qt_include_dir, 'QtCore'),
os.path.join(self.qt_include_dir, 'QtGui'),
os.path.join(self.qt_include_dir, 'QtWidgets')]
extension.libraries += ['Qt5Core' + self.qt_libinfix,
'Qt5Gui' + self.qt_libinfix,
'Qt5Widgets' + self.qt_libinfix]
if sys.platform == 'win32':
extension.library_dirs += [self.qtconfig.QT_INSTALL_LIBS,
self.inc_dir, self._sip_output_dir()]
elif sys.platform == 'darwin':
extension.extra_compile_args += ['-F' + self.qtconfig.QT_INSTALL_LIBS,
'-std=c++11', '-stdlib=libc++', '-mmacosx-version-min=10.9']
extension.extra_link_args += ['-F' + self.qtconfig.QT_INSTALL_LIBS,
'-mmacosx-version-min=10.9']
elif sys.platform == 'linux':
extension.extra_compile_args += ['-std=c++11']
return super().swig_sources(sources, extension)
def build_extension(self, ext):
cppsources = [source for source in ext.sources if source.endswith(".cpp")]
dir_util.mkpath(self.build_temp, dry_run=self.dry_run)
# Run moc on all header files.
for source in cppsources:
header = source.replace(".cpp", ".h")
if os.path.exists(header):
moc_file = "moc_" + os.path.basename(header).replace(".h", ".cpp")
out_file = os.path.join(self.build_temp, moc_file)
if newer(header, out_file) or self.force:
call_arg = ["moc", "-o", out_file, header]
spawn.spawn(call_arg, dry_run=self.dry_run)
if os.path.getsize(out_file) > 0:
ext.sources.append(out_file)
# Add the temp build directory to include path, for compiler to find
# the created .moc files
ext.include_dirs += [self._sip_output_dir()]
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:
out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
GIT_REVISION = out.strip().decode('ascii')
except OSError:
GIT_REVISION = "Unknown"
return GIT_REVISION
def get_version_info():
# Adding the git rev number needs to be done inside write_version_py(),
# 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:
FULLVERSION += '.dev0+' + GIT_REVISION[:7]
return FULLVERSION, GIT_REVISION
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 []
cpp_sources = glob.glob(os.path.join('src', '*.cpp'))
sip_sources = [os.path.join('sip', MODULE_NAME + '.sip')]
if sys.platform == 'linux':
cpp_sources += glob.glob(os.path.join('src', 'linux', '*.cpp'))
ext_modules = [Extension('PyQtAds.QtAds.ads', cpp_sources + sip_sources)]
install_requires = ["PyQt5"]
if sys.platform == 'win32':
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:
LONG_DESCRIPTION = f.read()
setup(
name = SRC_PATH,
author = "Nicolas Elie",
author_email = "nicolas.elie@cnrs.fr",
url = "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System",
version = get_version_info()[0],
description = "Advanced Docking System for Qt",
long_description = LONG_DESCRIPTION,
keywords = ["qt"],
license = "LGPLv2+",
classifiers = ["Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
"Environment :: Win32 (MS Windows)",
"Environment :: MacOS X",
"Environment :: X11 Applications :: Qt",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7"],
ext_modules = ext_modules,
cmdclass = {
'build_ext': build_ext,
},
packages = find_packages(),
setup_requires = setup_requires,
install_requires = install_requires,
zip_safe=False
)

82
simple.py Normal file
View File

@@ -0,0 +1,82 @@
import logging
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtCore import Qt
from PyQtAds import QtAds
class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.setup_ui()
self.dock_manager = QtAds.CDockManager(self)
self.dock_widgets = []
for label_text, area in (
('1 Top', QtAds.TopDockWidgetArea),
('2 Bottom', QtAds.BottomDockWidgetArea),
('3 Left', QtAds.LeftDockWidgetArea),
('4 Right', QtAds.RightDockWidgetArea),
):
# Create example content label - this can be any application specific
# widget
label = QtWidgets.QLabel()
label.setWordWrap(True)
label.setAlignment(Qt.AlignTop | Qt.AlignLeft)
label.setText(f"{label_text}: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. ")
# Create a dock widget with the title Label 1 and set the created label
# as the dock widget content
dock_widget = QtAds.CDockWidget(label_text)
dock_widget.setWidget(label)
self.dock_widgets.append(dock_widget)
# Add the toggleViewAction of the dock widget to the menu to give
# the user the possibility to show the dock widget if it has been closed
self.menu_view.addAction(dock_widget.toggleViewAction())
# Add the dock widget to the top dock widget area
self.dock_manager.addDockWidget(area, dock_widget)
def setup_ui(self):
self.setWindowTitle("MainWindow")
self.setObjectName("MainWindow")
self.resize(400, 300)
self.central_widget = QtWidgets.QWidget(self)
self.central_widget.setObjectName("central_widget")
self.setCentralWidget(self.central_widget)
self.menu_bar = QtWidgets.QMenuBar(self)
self.menu_bar.setGeometry(QtCore.QRect(0, 0, 400, 21))
self.menu_bar.setObjectName("menuBar")
self.menu_view = QtWidgets.QMenu(self.menu_bar)
self.menu_view.setObjectName("menu_view")
self.menu_view.setTitle("View")
self.setMenuBar(self.menu_bar)
self.status_bar = QtWidgets.QStatusBar(self)
self.status_bar.setObjectName("statusBar")
self.setStatusBar(self.status_bar)
self.menu_bar.addAction(self.menu_view.menuAction())
def main(app):
main = MainWindow()
main.show()
state = main.dock_manager.saveState()
print('This is what the saved state looks like in XML:')
print(state)
print()
main.dock_manager.restoreState(state)
return main
if __name__ == '__main__':
logging.basicConfig(level='DEBUG')
app = QtWidgets.QApplication([])
window = main(app)
window.show()
print('shown')
app.exec_()

56
sip/DockAreaTabBar.sip Normal file
View File

@@ -0,0 +1,56 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CDockAreaTabBar : QScrollArea
{
%TypeHeaderCode
#include <DockAreaTabBar.h>
%End
protected:
virtual void wheelEvent(QWheelEvent* Event);
virtual void mousePressEvent(QMouseEvent* ev);
virtual void mouseReleaseEvent(QMouseEvent* ev);
virtual void mouseMoveEvent(QMouseEvent* ev);
virtual void mouseDoubleClickEvent(QMouseEvent *event);
void startFloating(const QPoint& Offset);
ads::CFloatingDockContainer* makeAreaFloating(const QPoint& Offset,
ads::eDragState DragState);
public:
CDockAreaTabBar(ads::CDockAreaWidget* parent /TransferThis/);
virtual ~CDockAreaTabBar();
void insertTab(int Index, ads::CDockWidgetTab* Tab /Transfer/);
void removeTab(ads::CDockWidgetTab* Tab) /TransferBack/;
int count() const;
int currentIndex() const;
ads::CDockWidgetTab* currentTab() const;
ads::CDockWidgetTab* tab(int Index) const;
virtual bool eventFilter(QObject *watched, QEvent *event);
bool isTabOpen(int Index) const;
virtual QSize minimumSizeHint() const;
virtual QSize sizeHint() const;
public slots:
void setCurrentIndex(int Index);
void closeTab(int Index);
signals:
void currentChanging(int Index);
void currentChanged(int Index);
void tabBarClicked(int index);
void tabCloseRequested(int index);
void tabClosed(int index);
void tabOpened(int index);
void tabMoved(int from, int to);
void removingTab(int index);
void tabInserted(int index);
};
};
%End

32
sip/DockAreaTitleBar.sip Normal file
View File

@@ -0,0 +1,32 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CDockAreaTitleBar : QFrame
{
%TypeHeaderCode
#include <DockAreaTitleBar.h>
%End
public slots:
void markTabsMenuOutdated();
public:
CDockAreaTitleBar(ads::CDockAreaWidget* parent /TransferThis/);
virtual ~CDockAreaTitleBar();
ads::CDockAreaTabBar* tabBar() const;
QAbstractButton* button(ads::TitleBarButton which) const;
virtual void setVisible(bool Visible);
signals:
void tabBarClicked(int index);
};
};
%End

65
sip/DockAreaWidget.sip Normal file
View File

@@ -0,0 +1,65 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CDockAreaWidget : QFrame
{
%TypeHeaderCode
#include <DockAreaWidget.h>
%End
protected:
void insertDockWidget(int index, ads::CDockWidget* DockWidget /Transfer/, bool Activate = true);
void addDockWidget(ads::CDockWidget* DockWidget /Transfer/);
void removeDockWidget(ads::CDockWidget* DockWidget) /TransferBack/;
void toggleDockWidgetView(ads::CDockWidget* DockWidget, bool Open);
CDockWidget* nextOpenDockWidget(ads::CDockWidget* DockWidget) const;
int index(ads::CDockWidget* DockWidget);
void hideAreaWithNoVisibleContent();
void updateTitleBarVisibility();
void internalSetCurrentDockWidget(ads::CDockWidget* DockWidget /Transfer/);
void markTitleBarMenuOutdated();
protected slots:
void toggleView(bool Open);
public:
CDockAreaWidget(ads::CDockManager* DockManager /TransferThis/, ads::CDockContainerWidget* parent /TransferThis/);
virtual ~CDockAreaWidget();
ads::CDockManager* dockManager() const;
ads::CDockContainerWidget* dockContainer() const;
QRect titleBarGeometry() const;
QRect contentAreaGeometry() const;
int dockWidgetsCount() const;
QList<ads::CDockWidget*> dockWidgets() const;
int openDockWidgetsCount() const;
QList<ads::CDockWidget*> openedDockWidgets() const;
ads::CDockWidget* dockWidget(int Index) const;
int currentIndex() const;
int indexOfFirstOpenDockWidget() const;
ads::CDockWidget* currentDockWidget() const;
void setCurrentDockWidget(ads::CDockWidget* DockWidget /Transfer/);
void saveState(QXmlStreamWriter& Stream) const;
ads::CDockWidget::DockWidgetFeatures features() const;
QAbstractButton* titleBarButton(ads::TitleBarButton which) const;
virtual void setVisible(bool Visible);
public slots:
void setCurrentIndex(int index);
void closeArea();
void closeOtherAreas();
signals:
void tabBarClicked(int index);
void currentChanging(int index);
void currentChanged(int index);
void viewToggled(bool Open);
};
};
%End

154
sip/DockContainerWidget.sip Normal file
View File

@@ -0,0 +1,154 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
/**
* Container that manages a number of dock areas with single dock widgets
* or tabyfied dock widgets in each area.
* Each window that support docking has a DockContainerWidget. That means
* the main application window and all floating windows are ore contain
* an DockContainerWidget.
*/
class CDockContainerWidget : QFrame
{
%TypeHeaderCode
#include <DockContainerWidget.h>
%End
protected:
virtual bool event(QEvent *e);
QSplitter* rootSplitter() const;
void createRootSplitter();
void dropFloatingWidget(ads::CFloatingDockContainer* FloatingWidget, const QPoint& TargetPos);
void addDockArea(ads::CDockAreaWidget* DockAreaWidget /Transfer/, ads::DockWidgetArea area = ads::CenterDockWidgetArea);
void removeDockArea(ads::CDockAreaWidget* area /Transfer/);
void saveState(QXmlStreamWriter& Stream) const;
bool restoreState(QXmlStreamReader& Stream, bool Testing);
ads::CDockAreaWidget* lastAddedDockAreaWidget(ads::DockWidgetArea area) const;
bool hasTopLevelDockWidget() const;
ads::CDockWidget* topLevelDockWidget() const;
ads::CDockAreaWidget* topLevelDockArea() const;
QList<ads::CDockWidget*> dockWidgets() const;
public:
/**
* Default Constructor
*/
CDockContainerWidget(ads::CDockManager* DockManager /TransferThis/, QWidget* parent /TransferThis/ = 0);
/**
* Virtual Destructor
*/
virtual ~CDockContainerWidget();
/**
* Adds dockwidget into the given area.
* If DockAreaWidget is not null, then the area parameter indicates the area
* into the DockAreaWidget. If DockAreaWidget is null, the Dockwidget will
* be dropped into the container.
* \return Returns the dock area widget that contains the new DockWidget
*/
ads::CDockAreaWidget* addDockWidget(ads::DockWidgetArea area, ads::CDockWidget* Dockwidget /Transfer/,
ads::CDockAreaWidget* DockAreaWidget /Transfer/ = 0);
/**
* Removes dockwidget
*/
void removeDockWidget(ads::CDockWidget* Dockwidget) /TransferBack/;
/**
* Returns the current zOrderIndex
*/
virtual unsigned int zOrderIndex() const;
/**
* This function returns true if this container widgets z order index is
* higher than the index of the container widget given in Other parameter
*/
bool isInFrontOf(ads::CDockContainerWidget* Other) const;
/**
* Returns the dock area at teh given global position or 0 if there is no
* dock area at this position
*/
ads::CDockAreaWidget* dockAreaAt(const QPoint& GlobalPos) const;
/**
* Returns the dock area at the given Index or 0 if the index is out of
* range
*/
ads::CDockAreaWidget* dockArea(int Index) const;
/**
* Returns the list of dock areas that are not closed
* If all dock widgets in a dock area are closed, the dock area will be closed
*/
QList<ads::CDockAreaWidget*> openedDockAreas() const;
/**
* Returns the number of dock areas in this container
*/
int dockAreaCount() const;
/**
* Returns the number of visible dock areas
*/
int visibleDockAreaCount() const;
/**
* This function returns true, if this container is in a floating widget
*/
bool isFloating() const;
/**
* Dumps the layout for debugging purposes
*/
void dumpLayout();
/**
* This functions returns the dock widget features of all dock widget in
* this container.
* A bitwise and is used to combine the flags of all dock widgets. That
* means, if only dock widget does not support a certain flag, the whole
* dock are does not support the flag.
*/
ads::CDockWidget::DockWidgetFeatures features() const;
/**
* If this dock container is in a floating widget, this function returns
* the floating widget.
* Else, it returns a nullptr.
*/
ads::CFloatingDockContainer* floatingWidget() const;
/**
* Call this function to close all dock areas except the KeepOpenArea
*/
void closeOtherAreas(ads::CDockAreaWidget* KeepOpenArea);
signals:
/**
* This signal is emitted if one or multiple dock areas has been added to
* the internal list of dock areas.
* If multiple dock areas are inserted, this signal is emitted only once
*/
void dockAreasAdded();
/**
* This signal is emitted if one or multiple dock areas has been removed
*/
void dockAreasRemoved();
/**
* This signal is emitted if a dock area is opened or closed via
* toggleView() function
*/
void dockAreaViewToggled(ads::CDockAreaWidget* DockArea, bool Open);
}; // class DockContainerWidget
};
// namespace ads
%End

205
sip/DockManager.sip Normal file
View File

@@ -0,0 +1,205 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
%MappedType QMap<QString, ads::CDockWidget*>
/TypeHint="Dict[QString, CDockWidget*]", TypeHintValue="{}"/
{
%TypeHeaderCode
#include <qmap.h>
%End
%ConvertFromTypeCode
PyObject *d = PyDict_New();
if (!d)
return 0;
QMap<QString, ads::CDockWidget*>::const_iterator it = sipCpp->constBegin();
QMap<QString, ads::CDockWidget*>::const_iterator end = sipCpp->constEnd();
while (it != end)
{
QString *k = new QString(it.key());
PyObject *kobj = sipConvertFromType(k, sipType_QString,
sipTransferObj);
if (!kobj)
{
delete k;
Py_DECREF(d);
return 0;
}
PyObject *vobj = sipConvertFromType(it.value(), sipType_ads_CDockWidget,
sipTransferObj);
if (!vobj)
{
Py_DECREF(kobj);
Py_DECREF(d);
return 0;
}
int rc = PyDict_SetItem(d, kobj, vobj);
Py_DECREF(vobj);
Py_DECREF(kobj);
if (rc < 0)
{
Py_DECREF(d);
return 0;
}
++it;
}
return d;
%End
%ConvertToTypeCode
if (!sipIsErr)
return PyDict_Check(sipPy);
QMap<QString, ads::CDockWidget*> *qm = new QMap<QString, ads::CDockWidget*>;
Py_ssize_t pos = 0;
PyObject *kobj, *vobj;
while (PyDict_Next(sipPy, &pos, &kobj, &vobj))
{
int kstate;
QString *k = reinterpret_cast<QString *>(
sipForceConvertToType(kobj, sipType_QString, sipTransferObj,
SIP_NOT_NONE, &kstate, sipIsErr));
if (*sipIsErr)
{
PyErr_Format(PyExc_TypeError,
"a dict key has type '%s' but '_TYPE1_' is expected",
sipPyTypeName(Py_TYPE(kobj)));
delete qm;
return 0;
}
int vstate;
ads::CDockWidget *v = reinterpret_cast<ads::CDockWidget *>(
sipForceConvertToType(vobj, sipType_ads_CDockWidget, sipTransferObj,
SIP_NOT_NONE, &vstate, sipIsErr));
if (*sipIsErr)
{
PyErr_Format(PyExc_TypeError,
"a dict value has type '%s' but '_TYPE2_' is expected",
sipPyTypeName(Py_TYPE(vobj)));
sipReleaseType(k, sipType_QString, kstate);
delete qm;
return 0;
}
qm->insert(*k, v);
sipReleaseType(v, sipType_ads_CDockWidget, vstate);
sipReleaseType(k, sipType_QString, kstate);
}
*sipCppPtr = qm;
return sipGetState(sipTransferObj);
%End
};
namespace ads
{
class CDockManager : ads::CDockContainerWidget
{
%TypeHeaderCode
#include <DockManager.h>
%End
protected:
void registerFloatingWidget(ads::CFloatingDockContainer* FloatingWidget /Transfer/);
void removeFloatingWidget(ads::CFloatingDockContainer* FloatingWidget) /TransferBack/;
void registerDockContainer(ads::CDockContainerWidget* DockContainer /Transfer/);
void removeDockContainer(ads::CDockContainerWidget* DockContainer /TransferBack/);
ads::CDockOverlay* containerOverlay() const;
ads::CDockOverlay* dockAreaOverlay() const;
public:
enum eViewMenuInsertionOrder
{
MenuSortedByInsertion,
MenuAlphabeticallySorted
};
enum eConfigFlag
{
ActiveTabHasCloseButton,
DockAreaHasCloseButton,
DockAreaCloseButtonClosesTab,
OpaqueSplitterResize,
XmlAutoFormattingEnabled,
XmlCompressionEnabled,
TabCloseButtonIsToolButton,
AllTabsHaveCloseButton,
RetainTabSizeWhenCloseButtonHidden,
DefaultConfig,
};
typedef QFlags<ads::CDockManager::eConfigFlag> ConfigFlags;
CDockManager(QWidget* parent /TransferThis/ = 0);
virtual ~CDockManager();
static ads::CDockManager::ConfigFlags configFlags();
static void setConfigFlags(const ads::CDockManager::ConfigFlags Flags);
static void setConfigFlag(ads::CDockManager::eConfigFlag Flag, bool On = true);
ads::CDockAreaWidget* addDockWidget(ads::DockWidgetArea area, ads::CDockWidget* Dockwidget /Transfer/,
ads::CDockAreaWidget* DockAreaWidget /Transfer/ = 0);
ads::CDockAreaWidget* addDockWidgetTab(ads::DockWidgetArea area,
ads::CDockWidget* Dockwidget /Transfer/);
ads::CDockAreaWidget* addDockWidgetTabToArea(ads::CDockWidget* Dockwidget /Transfer/,
ads::CDockAreaWidget* DockAreaWidget /Transfer/);
ads::CDockWidget* findDockWidget(const QString& ObjectName) const;
void removeDockWidget(ads::CDockWidget* Dockwidget) /TransferBack/;
QMap<QString, ads::CDockWidget*> dockWidgetsMap() const;
const QList<ads::CDockContainerWidget*> dockContainers() const;
const QList<ads::CFloatingDockContainer*> floatingWidgets() const;
virtual unsigned int zOrderIndex() const;
QByteArray saveState(int version = 0) const;
bool restoreState(const QByteArray &state, int version = 0);
void addPerspective(const QString& UniquePrespectiveName);
void removePerspective(const QString& Name);
void removePerspectives(const QStringList& Names);
QStringList perspectiveNames() const;
void savePerspectives(QSettings& Settings) const;
void loadPerspectives(QSettings& Settings);
QAction* addToggleViewActionToMenu(QAction* ToggleViewAction /Transfer/,
const QString& Group = QString(), const QIcon& GroupIcon = QIcon());
QMenu* viewMenu() const;
void setViewMenuInsertionOrder(ads::CDockManager::eViewMenuInsertionOrder Order);
bool isRestoringState() const;
static int startDragDistance();
public slots:
void openPerspective(const QString& PerspectiveName);
signals:
void perspectiveListChanged();
void perspectivesRemoved();
void restoringState();
void stateRestored();
void openingPerspective(const QString& PerspectiveName);
void perspectiveOpened(const QString& PerspectiveName);
};
};
%End

77
sip/DockOverlay.sip Normal file
View File

@@ -0,0 +1,77 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CDockOverlay : public QFrame
{
%TypeHeaderCode
#include <DockOverlay.h>
%End
public:
enum eMode
{
ModeDockAreaOverlay,
ModeContainerOverlay
};
CDockOverlay(QWidget* parent /TransferThis/, eMode Mode = ads::CDockOverlay::ModeDockAreaOverlay);
virtual ~CDockOverlay();
void setAllowedAreas(ads::DockWidgetAreas areas);
ads::DockWidgetAreas allowedAreas() const;
ads::DockWidgetArea dropAreaUnderCursor() const;
ads::DockWidgetArea showOverlay(QWidget* target);
void hideOverlay();
void enableDropPreview(bool Enable);
QRect dropOverlayRect() const;
virtual bool event(QEvent *e);
protected:
virtual void paintEvent(QPaintEvent *e);
virtual void showEvent(QShowEvent* e);
virtual void hideEvent(QHideEvent* e);
};
class CDockOverlayCross : public QWidget
{
public:
enum eIconColor
{
FrameColor,
WindowBackgroundColor,
OverlayColor,
ArrowColor,
ShadowColor
};
protected:
QString iconColors() const;
QColor iconColor() const;
void setIconFrameColor(const QColor& Color);
void setIconBackgroundColor(const QColor& Color);
void setIconOverlayColor(const QColor& Color);
void setIconArrowColor(const QColor& Color);
void setIconShadowColor(const QColor& Color);
public:
CDockOverlayCross(ads::CDockOverlay* overlay /TransferThis/);
virtual ~CDockOverlayCross();
void setIconColor(ads::CDockOverlayCross::eIconColor ColorIndex, const QColor& Color);
QColor iconColor(ads::CDockOverlayCross::eIconColor ColorIndex) const;
ads::DockWidgetArea cursorLocation() const;
void setupOverlayCross(ads::CDockOverlay::eMode Mode);
void updateOverlayIcons();
void reset();
void updatePosition();
void setIconColors(const QString& Colors);
};
};
%End

23
sip/DockSplitter.sip Normal file
View File

@@ -0,0 +1,23 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CDockSplitter : QSplitter
{
%TypeHeaderCode
#include <DockSplitter.h>
%End
public:
CDockSplitter(QWidget *parent /TransferThis/ = 0);
CDockSplitter(Qt::Orientation orientation, QWidget *parent /TransferThis/ = 0);
virtual ~CDockSplitter();
bool hasVisibleContent() const;
};
};
%End

101
sip/DockWidget.sip Normal file
View File

@@ -0,0 +1,101 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CDockWidget : QFrame
{
%TypeHeaderCode
#include <DockWidget.h>
%End
protected:
void setDockManager(ads::CDockManager* DockManager /Transfer/);
void setDockArea(ads::CDockAreaWidget* DockArea /Transfer/);
void setToggleViewActionChecked(bool Checked);
void saveState(QXmlStreamWriter& Stream) const;
void flagAsUnassigned();
static void emitTopLevelEventForWidget(ads::CDockWidget* TopLevelDockWidget, bool Floating);
void emitTopLevelChanged(bool Floating);
void setClosedState(bool Closed);
void toggleViewInternal(bool Open);
public:
enum DockWidgetFeature
{
DockWidgetClosable,
DockWidgetMovable,
DockWidgetFloatable,
AllDockWidgetFeatures,
NoDockWidgetFeatures
};
typedef QFlags<ads::CDockWidget::DockWidgetFeature> DockWidgetFeatures;
enum eState
{
StateHidden,
StateDocked,
StateFloating
};
enum eInsertMode
{
AutoScrollArea,
ForceScrollArea,
ForceNoScrollArea
};
enum eToggleViewActionMode
{
ActionModeToggle,
ActionModeShow
};
CDockWidget(const QString &title, QWidget* parent /TransferThis/ = 0);
virtual ~CDockWidget();
virtual QSize minimumSizeHint() const;
void setWidget(QWidget* widget /Transfer/, ads::CDockWidget::eInsertMode InsertMode = AutoScrollArea);
QWidget* takeWidget() /TransferBack/;
QWidget* widget() const;
ads::CDockWidgetTab* tabWidget() const;
void setFeatures(ads::CDockWidget::DockWidgetFeatures features);
void setFeature(ads::CDockWidget::DockWidgetFeature flag, bool on);
ads::CDockWidget::DockWidgetFeatures features() const;
ads::CDockManager* dockManager() const;
ads::CDockContainerWidget* dockContainer() const;
ads::CDockAreaWidget* dockAreaWidget() const;
bool isFloating() const;
bool isInFloatingContainer() const;
bool isClosed() const;
QAction* toggleViewAction() const;
void setToggleViewActionMode(ads::CDockWidget::eToggleViewActionMode Mode);
void setIcon(const QIcon& Icon);
QIcon icon() const;
QToolBar* toolBar() const;
QToolBar* createDefaultToolBar();
void setToolBar(QToolBar* ToolBar);
void setToolBarStyle(Qt::ToolButtonStyle Style, ads::CDockWidget::eState State);
Qt::ToolButtonStyle toolBarStyle(ads::CDockWidget::eState State) const;
void setToolBarIconSize(const QSize& IconSize, ads::CDockWidget::eState State);
QSize toolBarIconSize(eState State) const;
void setTabToolTip(const QString &text);
public:
virtual bool event(QEvent *e);
public slots:
void toggleView(bool Open = true);
signals:
void viewToggled(bool Open);
void closed();
void titleChanged(const QString& Title);
void topLevelChanged(bool topLevel);
};
};
%End

50
sip/DockWidgetTab.sip Normal file
View File

@@ -0,0 +1,50 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CDockWidgetTab : QFrame
{
%TypeHeaderCode
#include <DockWidgetTab.h>
%End
protected:
virtual void mousePressEvent(QMouseEvent* ev);
virtual void mouseReleaseEvent(QMouseEvent* ev);
virtual void mouseMoveEvent(QMouseEvent* ev);
virtual void contextMenuEvent(QContextMenuEvent* ev);
virtual void mouseDoubleClickEvent(QMouseEvent *event);
public:
CDockWidgetTab(ads::CDockWidget* DockWidget /TransferThis/, QWidget* parent /TransferThis/ = 0);
virtual ~CDockWidgetTab();
bool isActiveTab() const;
void setActiveTab(bool active);
ads::CDockWidget* dockWidget() const;
void setDockAreaWidget(ads::CDockAreaWidget* DockArea /Transfer/);
ads::CDockAreaWidget* dockAreaWidget() const;
void setIcon(const QIcon& Icon);
const QIcon& icon() const;
QString text() const;
void setText(const QString& title);
bool isClosable() const;
virtual bool event(QEvent *e);
public slots:
virtual void setVisible(bool visible);
signals:
void activeTabChanged();
void clicked();
void closeRequested();
void closeOtherTabsRequested();
void moved(const QPoint& GlobalPos);
}; // class DockWidgetTab
};
// namespace ads
%End

40
sip/ElidingLabel.sip Normal file
View File

@@ -0,0 +1,40 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CElidingLabel : QLabel
{
%TypeHeaderCode
#include <ElidingLabel.h>
%End
protected:
virtual void mouseReleaseEvent(QMouseEvent* event);
virtual void resizeEvent( QResizeEvent *event );
virtual void mouseDoubleClickEvent( QMouseEvent *ev );
public:
CElidingLabel(QWidget* parent /TransferThis/ = 0, Qt::WindowFlags f = 0);
CElidingLabel(const QString& text, QWidget* parent /TransferThis/ = 0, Qt::WindowFlags f = 0);
virtual ~CElidingLabel();
Qt::TextElideMode elideMode() const;
void setElideMode(Qt::TextElideMode mode);
public:
virtual QSize minimumSizeHint() const;
virtual QSize sizeHint() const;
void setText(const QString &text);
QString text() const;
signals:
void clicked();
void doubleClicked();
};
};
%End

View File

@@ -0,0 +1,50 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
class CFloatingDockContainer : QWidget
{
%TypeHeaderCode
#include <FloatingDockContainer.h>
%End
protected:
void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
ads::eDragState DragState, QWidget* MouseEventHandler);
void startDragging(const QPoint& DragStartMousePos, const QSize& Size,
QWidget* MouseEventHandler);
void finishDragging();
void initFloatingGeometry(const QPoint& DragStartMousePos, const QSize& Size);
void moveFloating();
bool restoreState(QXmlStreamReader& Stream, bool Testing);
void updateWindowTitle();
protected:
virtual void changeEvent(QEvent *event);
virtual void moveEvent(QMoveEvent *event);
virtual bool event(QEvent *e);
virtual void closeEvent(QCloseEvent *event);
virtual void hideEvent(QHideEvent *event);
virtual void showEvent(QShowEvent *event);
virtual bool eventFilter(QObject *watched, QEvent *event);
public:
CFloatingDockContainer(ads::CDockManager* DockManager /TransferThis/);
CFloatingDockContainer(ads::CDockAreaWidget* DockArea /TransferThis/);
CFloatingDockContainer(ads::CDockWidget* DockWidget /TransferThis/);
virtual ~CFloatingDockContainer();
ads::CDockContainerWidget* dockContainer() const;
bool isClosable() const;
bool hasTopLevelDockWidget() const;
ads::CDockWidget* topLevelDockWidget() const;
QList<ads::CDockWidget*> dockWidgets() const;
};
};
%End

20
sip/ads.sip Normal file
View File

@@ -0,0 +1,20 @@
%Module(name=PyQtAds.QtAds.ads, call_super_init=True, keyword_arguments="Optional", use_limited_api=True)
%Import QtCore/QtCoremod.sip
%DefaultSupertype sip.simplewrapper
%Platforms {Linux macOS Windows}
%Include ads_globals.sip
%Include DockWidget.sip
%Include DockAreaTabBar.sip
%Include DockAreaTitleBar.sip
%Include DockAreaWidget.sip
%Include DockContainerWidget.sip
%Include DockManager.sip
%Include DockOverlay.sip
%Include DockSplitter.sip
%Include DockWidgetTab.sip
%Include ElidingLabel.sip
%Include FloatingDockContainer.sip
%If (Linux)
%Include linux/FloatingWidgetTitleBar.sip
%End

44
sip/ads_globals.sip Normal file
View File

@@ -0,0 +1,44 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
%TypeHeaderCode
#include <ads_globals.h>
%End
enum DockWidgetArea
{
NoDockWidgetArea,
LeftDockWidgetArea,
RightDockWidgetArea,
TopDockWidgetArea,
BottomDockWidgetArea,
CenterDockWidgetArea,
InvalidDockWidgetArea,
OuterDockAreas,
AllDockAreas
};
typedef QFlags<ads::DockWidgetArea> DockWidgetAreas;
enum TitleBarButton
{
TitleBarButtonTabsMenu,
TitleBarButtonUndock,
TitleBarButtonClose
};
enum eDragState
{
DraggingInactive,
DraggingMousePressed,
DraggingTab,
DraggingFloatingWidget
};
};
%End

View File

@@ -0,0 +1,31 @@
%Import QtWidgets/QtWidgetsmod.sip
%If (Qt_5_0_0 -)
namespace ads
{
%TypeHeaderCode
#include <FloatingWidgetTitleBar.h>
%End
class CFloatingWidgetTitleBar : QWidget
{
protected:
virtual void mousePressEvent(QMouseEvent *ev);
virtual void mouseReleaseEvent(QMouseEvent *ev);
virtual void mouseMoveEvent(QMouseEvent *ev);
public:
explicit CFloatingWidgetTitleBar(CFloatingDockContainer *parent /TransferThis/ = 0);
virtual ~CFloatingWidgetTitleBar();
void enableCloseButton(bool Enable);
void setTitle(const QString &Text);
signals:
void closeRequested();
};
};
%End

View File

@@ -1,3 +1,22 @@
/*******************************************************************************
** 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/>.
******************************************************************************/
//============================================================================
/// \file DockAreaTabBar.cpp
/// \author Uwe Kindler
@@ -13,11 +32,18 @@
#include <QMouseEvent>
#include <QScrollBar>
#include <QDebug>
#include <QBoxLayout>
#include <QApplication>
#include "FloatingDockContainer.h"
#include "DockAreaWidget.h"
#include "DockOverlay.h"
#include "DockManager.h"
#include "DockWidget.h"
#include "DockWidgetTab.h"
#include <iostream>
namespace ads
{
@@ -30,11 +56,20 @@ struct DockAreaTabBarPrivate
QPoint DragStartMousePos;
CDockAreaWidget* DockArea;
CFloatingDockContainer* FloatingWidget = nullptr;
QWidget* TabsContainerWidget;
QBoxLayout* TabsLayout;
int CurrentIndex = -1;
/**
* Private data constructor
*/
DockAreaTabBarPrivate(CDockAreaTabBar* _public);
/**
* Update tabs after current index changed or when tabs are removed.
* The function reassigns the stylesheet to update the tabs
*/
void updateTabs();
};
// struct DockAreaTabBarPrivate
@@ -45,17 +80,54 @@ DockAreaTabBarPrivate::DockAreaTabBarPrivate(CDockAreaTabBar* _public) :
}
//============================================================================
void DockAreaTabBarPrivate::updateTabs()
{
// Set active TAB and update all other tabs to be inactive
for (int i = 0; i < _this->count(); ++i)
{
auto TabWidget = _this->tab(i);
if (!TabWidget)
{
continue;
}
if (i == CurrentIndex)
{
TabWidget->show();
TabWidget->setActiveTab(true);
_this->ensureWidgetVisible(TabWidget);
}
else
{
TabWidget->setActiveTab(false);
}
}
}
//============================================================================
CDockAreaTabBar::CDockAreaTabBar(CDockAreaWidget* parent) :
QScrollArea(parent),
d(new DockAreaTabBarPrivate(this))
{
d->DockArea = parent;
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
setFrameStyle(QFrame::NoFrame);
setWidgetResizable(true);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
d->TabsContainerWidget = new QWidget();
d->TabsContainerWidget->setObjectName("tabsContainerWidget");
setWidget(d->TabsContainerWidget);
d->TabsLayout = new QBoxLayout(QBoxLayout::LeftToRight);
d->TabsLayout->setContentsMargins(0, 0, 0, 0);
d->TabsLayout->setSpacing(0);
d->TabsLayout->addStretch(1);
d->TabsContainerWidget->setLayout(d->TabsLayout);
}
//============================================================================
@@ -99,7 +171,7 @@ void CDockAreaTabBar::mouseReleaseEvent(QMouseEvent* ev)
{
if (ev->button() == Qt::LeftButton)
{
qDebug() << "CTabsScrollArea::mouseReleaseEvent";
ADS_PRINT("CTabsScrollArea::mouseReleaseEvent");
ev->accept();
d->FloatingWidget = nullptr;
d->DragStartMousePos = QPoint();
@@ -133,9 +205,17 @@ void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
return;
}
if (!this->geometry().contains(ev->pos()))
// 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))
{
qDebug() << "CTabsScrollArea::startFloating";
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);
@@ -155,18 +235,353 @@ void CDockAreaTabBar::mouseDoubleClickEvent(QMouseEvent *event)
{
return;
}
startFloating(event->pos());
if (!d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
{
return;
}
makeAreaFloating(event->pos(), DraggingInactive);
}
//============================================================================
void CDockAreaTabBar::startFloating(const QPoint& Pos)
CFloatingDockContainer* CDockAreaTabBar::makeAreaFloating(const QPoint& Offset,
eDragState DragState)
{
QSize Size = d->DockArea->size();
CFloatingDockContainer* FloatingWidget = new CFloatingDockContainer(d->DockArea);
FloatingWidget->startFloating(Pos, Size);
d->FloatingWidget = FloatingWidget;
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)
{
if (index == d->CurrentIndex)
{
return;
}
if (index < -1 || index > (count() - 1))
{
qWarning() << Q_FUNC_INFO << "Invalid index" << index;
return;
}
emit currentChanging(index);
d->CurrentIndex = index;
d->updateTabs();
emit currentChanged(index);
}
//============================================================================
int CDockAreaTabBar::count() const
{
// The tab bar contains a stretch item as last item
return d->TabsLayout->count() - 1;
}
//===========================================================================
void CDockAreaTabBar::insertTab(int Index, CDockWidgetTab* Tab)
{
d->TabsLayout->insertWidget(Index, Tab);
connect(Tab, SIGNAL(clicked()), this, SLOT(onTabClicked()));
connect(Tab, SIGNAL(closeRequested()), this, SLOT(onTabCloseRequested()));
connect(Tab, SIGNAL(closeOtherTabsRequested()), this, SLOT(onCloseOtherTabsRequested()));
connect(Tab, SIGNAL(moved(const QPoint&)), this, SLOT(onTabWidgetMoved(const QPoint&)));
Tab->installEventFilter(this);
emit tabInserted(Index);
if (Index <= d->CurrentIndex)
{
setCurrentIndex(d->CurrentIndex + 1);
}
}
//===========================================================================
void CDockAreaTabBar::removeTab(CDockWidgetTab* Tab)
{
if (!count())
{
return;
}
ADS_PRINT("CDockAreaTabBar::removeTab ");
int NewCurrentIndex = currentIndex();
int RemoveIndex = d->TabsLayout->indexOf(Tab);
if (count() == 1)
{
NewCurrentIndex = -1;
}
if (NewCurrentIndex > RemoveIndex)
{
NewCurrentIndex--;
}
else if (NewCurrentIndex == RemoveIndex)
{
NewCurrentIndex = -1;
// First we walk to the right to search for the next visible tab
for (int i = (RemoveIndex + 1); i < count(); ++i)
{
if (tab(i)->isVisibleTo(this))
{
NewCurrentIndex = i - 1;
break;
}
}
// If there is no visible tab right to this tab then we walk to
// the left to find a visible tab
if (NewCurrentIndex < 0)
{
for (int i = (RemoveIndex - 1); i >= 0; --i)
{
if (tab(i)->isVisibleTo(this))
{
NewCurrentIndex = i;
break;
}
}
}
}
emit removingTab(RemoveIndex);
d->TabsLayout->removeWidget(Tab);
Tab->disconnect(this);
Tab->removeEventFilter(this);
ADS_PRINT("NewCurrentIndex " << NewCurrentIndex);
if (NewCurrentIndex != d->CurrentIndex)
{
setCurrentIndex(NewCurrentIndex);
}
else
{
d->updateTabs();
}
}
//===========================================================================
int CDockAreaTabBar::currentIndex() const
{
return d->CurrentIndex;
}
//===========================================================================
CDockWidgetTab* CDockAreaTabBar::currentTab() const
{
if (d->CurrentIndex < 0)
{
return nullptr;
}
else
{
return qobject_cast<CDockWidgetTab*>(d->TabsLayout->itemAt(d->CurrentIndex)->widget());
}
}
//===========================================================================
void CDockAreaTabBar::onTabClicked()
{
CDockWidgetTab* Tab = qobject_cast<CDockWidgetTab*>(sender());
if (!Tab)
{
return;
}
int index = d->TabsLayout->indexOf(Tab);
if (index < 0)
{
return;
}
setCurrentIndex(index);
emit tabBarClicked(index);
}
//===========================================================================
void CDockAreaTabBar::onTabCloseRequested()
{
CDockWidgetTab* Tab = qobject_cast<CDockWidgetTab*>(sender());
int Index = d->TabsLayout->indexOf(Tab);
closeTab(Index);
}
//===========================================================================
void CDockAreaTabBar::onCloseOtherTabsRequested()
{
auto Sender = qobject_cast<CDockWidgetTab*>(sender());
for (int i = 0; i < count(); ++i)
{
auto Tab = tab(i);
if (Tab->isClosable() && !Tab->isHidden() && Tab != Sender)
{
closeTab(i);
}
}
}
//===========================================================================
CDockWidgetTab* CDockAreaTabBar::tab(int Index) const
{
if (Index >= count() || Index < 0)
{
return nullptr;
}
return qobject_cast<CDockWidgetTab*>(d->TabsLayout->itemAt(Index)->widget());
}
//===========================================================================
void CDockAreaTabBar::onTabWidgetMoved(const QPoint& GlobalPos)
{
CDockWidgetTab* MovingTab = qobject_cast<CDockWidgetTab*>(sender());
if (!MovingTab)
{
return;
}
int fromIndex = d->TabsLayout->indexOf(MovingTab);
auto MousePos = mapFromGlobal(GlobalPos);
int toIndex = -1;
// Find tab under mouse
for (int i = 0; i < count(); ++i)
{
CDockWidgetTab* DropTab = tab(i);
if (DropTab == MovingTab || !DropTab->isVisibleTo(this)
|| !DropTab->geometry().contains(MousePos))
{
continue;
}
toIndex = d->TabsLayout->indexOf(DropTab);
if (toIndex == fromIndex)
{
toIndex = -1;
continue;
}
if (toIndex < 0)
{
toIndex = 0;
}
break;
}
// Now check if the mouse is behind the last tab
if (toIndex < 0)
{
if (MousePos.x() > tab(count() - 1)->geometry().right())
{
ADS_PRINT("after all tabs");
toIndex = count() - 1;
}
else
{
toIndex = fromIndex;
}
}
d->TabsLayout->removeWidget(MovingTab);
d->TabsLayout->insertWidget(toIndex, MovingTab);
if (toIndex >= 0)
{
ADS_PRINT("tabMoved from " << fromIndex << " to " << toIndex);
emit tabMoved(fromIndex, toIndex);
setCurrentIndex(toIndex);
}
}
//===========================================================================
void CDockAreaTabBar::closeTab(int Index)
{
if (Index < 0 || Index >= count())
{
return;
}
auto Tab = tab(Index);
if (Tab->isHidden())
{
return;
}
Tab->hide();
emit tabCloseRequested(Index);
}
//===========================================================================
bool CDockAreaTabBar::eventFilter(QObject *watched, QEvent *event)
{
bool Result = Super::eventFilter(watched, event);
CDockWidgetTab* Tab = qobject_cast<CDockWidgetTab*>(watched);
if (!Tab)
{
return Result;
}
switch (event->type())
{
case QEvent::Hide:
emit tabClosed(d->TabsLayout->indexOf(Tab)); break;
case QEvent::Show:
emit tabOpened(d->TabsLayout->indexOf(Tab)); break;
default:
break;
}
return Result;
}
//===========================================================================
bool CDockAreaTabBar::isTabOpen(int Index) const
{
if (Index < 0 || Index >= count())
{
return false;
}
return !tab(Index)->isHidden();
}
//===========================================================================
QSize CDockAreaTabBar::minimumSizeHint() const
{
QSize Size = sizeHint();
Size.setWidth(Super::minimumSizeHint().width());// this defines the minimum width of a dock area
return Size;
}
//===========================================================================
QSize CDockAreaTabBar::sizeHint() const
{
QSize Size = Super::sizeHint();
Size.setHeight(d->TabsContainerWidget->sizeHint().height());
return Size;
}
} // namespace ads
//---------------------------------------------------------------------------

View File

@@ -1,5 +1,24 @@
#ifndef DockAreaTabBarH
#define DockAreaTabBarH
/*******************************************************************************
** 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/>.
******************************************************************************/
//============================================================================
/// \file DockAreaTabBar.h
/// \author Uwe Kindler
@@ -11,26 +30,42 @@
// INCLUDES
//============================================================================
#include <QScrollArea>
#include "ads_globals.h"
namespace ads
{
class CDockAreaWidget;
class CDockWidgetTab;
struct DockAreaTabBarPrivate;
class CDockAreaTitleBar;
class CFloatingDockContainer;
/**
* Custom tabbar implementation for tab area that is shown on top of a
* dock area widget.
* The tabbar displays the tab widgets of the contained dock widgets.
* We cannot use QTabBar here because it does a lot of fancy animations
* that will crash the application if a tab is removed while the animation
* has not finished. And we need to remove a tab, if the user drags a
* a dock widget out of a group of tabbed widgets
*/
class CDockAreaTabBar : public QScrollArea
class ADS_EXPORT CDockAreaTabBar : public QScrollArea
{
Q_OBJECT
private:
DockAreaTabBarPrivate* d; ///< private data (pimpl)
friend class DockAreaTabBarPrivate;
friend struct DockAreaTabBarPrivate;
friend class CDockAreaTitleBar;
private slots:
void onTabClicked();
void onTabCloseRequested();
void onCloseOtherTabsRequested();
void onTabWidgetMoved(const QPoint& GlobalPos);
protected:
virtual void wheelEvent(QWheelEvent* Event) override;
/**
* Stores mouse position to detect dragging
*/
@@ -55,9 +90,18 @@ protected:
/**
* Starts floating
*/
void startFloating(const QPoint& Pos);
void startFloating(const QPoint& Offset);
/**
* Makes the dock area floating
*/
CFloatingDockContainer* makeAreaFloating(const QPoint& Offset,
eDragState DragState);
public:
using Super = QScrollArea;
/**
* Default Constructor
*/
@@ -67,6 +111,129 @@ public:
* Virtual Destructor
*/
virtual ~CDockAreaTabBar();
/**
* Inserts the given dock widget tab at the given position.
* Inserting a new tab at an index less than or equal to the current index
* will increment the current index, but keep the current tab.
*/
void insertTab(int Index, CDockWidgetTab* Tab);
/**
* Removes the given DockWidgetTab from the tabbar
*/
void removeTab(CDockWidgetTab* Tab);
/**
* Returns the number of tabs in this tabbar
*/
int count() const;
/**
* Returns the current index or -1 if no tab is selected
*/
int currentIndex() const;
/**
* Returns the current tab or a nullptr if no tab is selected.
*/
CDockWidgetTab* currentTab() const;
/**
* Returns the tab with the given index
*/
CDockWidgetTab* tab(int Index) const;
/**
* Filters the tab widget events
*/
virtual bool eventFilter(QObject *watched, QEvent *event) override;
/**
* This function returns true if the tab is open, that means if it is
* visible to the user. If the function returns false, the tab is
* closed
*/
bool isTabOpen(int Index) const;
/**
* Overrides the minimumSizeHint() function of QScrollArea
* The minimumSizeHint() is bigger than the sizeHint () for the scroll
* area because even if the scrollbars are invisible, the required speace
* is reserved in the minimumSizeHint(). This override simply returns
* sizeHint();
*/
virtual QSize minimumSizeHint() const override;
/**
* The function provides a sizeHint that matches the height of the
* internal viewport.
*/
virtual QSize sizeHint() const override;
public slots:
/**
* This property sets the index of the tab bar's visible tab
*/
void setCurrentIndex(int Index);
/**
* This function will close the tab given in Index param.
* Closing a tab means, the tab will be hidden, it will not be removed
*/
void closeTab(int Index);
signals:
/**
* This signal is emitted when the tab bar's current tab is about to be changed. The new
* current has the given index, or -1 if there isn't a new one.
*/
void currentChanging(int Index);
/**
* This signal is emitted when the tab bar's current tab changes. The new
* current has the given index, or -1 if there isn't a new one
*/
void currentChanged(int Index);
/**
* This signal is emitted when user clicks on a tab
*/
void tabBarClicked(int index);
/**
* This signal is emitted when the close button on a tab is clicked.
* The index is the index that should be closed.
*/
void tabCloseRequested(int index);
/**
* This signal is emitted if a tab has been closed
*/
void tabClosed(int index);
/**
* This signal is emitted if a tab has been opened.
* A tab is opened if it has been made visible
*/
void tabOpened(int index);
/**
* This signal is emitted when the tab has moved the tab at index position
* from to index position to.
*/
void tabMoved(int from, int to);
/**
* This signal is emitted, just before the tab with the given index is
* removed
*/
void removingTab(int index);
/**
* This signal is emitted if a tab has been inserted
*/
void tabInserted(int index);
}; // class CDockAreaTabBar
} // namespace ads
//-----------------------------------------------------------------------------

370
src/DockAreaTitleBar.cpp Normal file
View File

@@ -0,0 +1,370 @@
/*******************************************************************************
** 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/>.
******************************************************************************/
//============================================================================
/// \file DockAreaTitleBar.cpp
/// \author Uwe Kindler
/// \date 12.10.2018
/// \brief Implementation of CDockAreaTitleBar class
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include "DockAreaTitleBar.h"
#include <QPushButton>
#include <QToolButton>
#include <QBoxLayout>
#include <QStyle>
#include <QMenu>
#include <QScrollArea>
#include <QMouseEvent>
#include <QDebug>
#include "ads_globals.h"
#include "FloatingDockContainer.h"
#include "DockAreaWidget.h"
#include "DockOverlay.h"
#include "DockManager.h"
#include "DockWidget.h"
#include "DockWidgetTab.h"
#include "DockAreaTabBar.h"
#include <iostream>
namespace ads
{
using tTileBarButton = QToolButton;
/**
* Private data class of CDockAreaTitleBar class (pimpl)
*/
struct DockAreaTitleBarPrivate
{
CDockAreaTitleBar* _this;
tTileBarButton* TabsMenuButton;
tTileBarButton* UndockButton;
tTileBarButton* CloseButton;
QBoxLayout* TopLayout;
CDockAreaWidget* DockArea;
CDockAreaTabBar* TabBar;
bool MenuOutdated = true;
QMenu* TabsMenu;
/**
* Private data constructor
*/
DockAreaTitleBarPrivate(CDockAreaTitleBar* _public);
/**
* Creates the title bar close and menu buttons
*/
void createButtons();
/**
* Creates the internal TabBar
*/
void createTabBar();
/**
* Convenience function for DockManager access
*/
CDockManager* dockManager() const
{
return DockArea->dockManager();
}
/**
* Returns true if the given config flag is set
*/
bool testConfigFlag(CDockManager::eConfigFlag Flag) const
{
return CDockManager::configFlags().testFlag(Flag);
}
/**
* Helper function to set title bar button icons depending on operating
* 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
*/
void setTitleBarButtonIcon(tTileBarButton* Button, QStyle::StandardPixmap StandarPixmap)
{
#ifdef Q_OS_LINUX
Button->setIcon(_this->style()->standardIcon(StandarPixmap));
#else
QIcon Icon;
QPixmap normalPixmap = _this->style()->standardPixmap(StandarPixmap, 0, Button);
Icon.addPixmap(internal::createTransparentPixmap(normalPixmap, 0.25), QIcon::Disabled);
Icon.addPixmap(normalPixmap, QIcon::Normal);
Button->setIcon(Icon);
#endif
}
};// struct DockAreaTitleBarPrivate
//============================================================================
DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) :
_this(_public)
{
}
//============================================================================
void DockAreaTitleBarPrivate::createButtons()
{
QSizePolicy ButtonSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
// Tabs menu button
TabsMenuButton = new tTileBarButton();
TabsMenuButton->setObjectName("tabsMenuButton");
TabsMenuButton->setAutoRaise(true);
TabsMenuButton->setPopupMode(QToolButton::InstantPopup);
setTitleBarButtonIcon(TabsMenuButton, QStyle::SP_TitleBarUnshadeButton);
QMenu* TabsMenu = new QMenu(TabsMenuButton);
#ifndef QT_NO_TOOLTIP
TabsMenu->setToolTipsVisible(true);
#endif
_this->connect(TabsMenu, SIGNAL(aboutToShow()), SLOT(onTabsMenuAboutToShow()));
TabsMenuButton->setMenu(TabsMenu);
#ifndef QT_NO_TOOLTIP
TabsMenuButton->setToolTip(QObject::tr("List all tabs"));
#endif
TabsMenuButton->setSizePolicy(ButtonSizePolicy);
TopLayout->addWidget(TabsMenuButton, 0);
_this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)),
SLOT(onTabsMenuActionTriggered(QAction*)));
// Undock button
UndockButton = new tTileBarButton();
UndockButton->setObjectName("undockButton");
UndockButton->setAutoRaise(true);
#ifndef QT_NO_TOOLTIP
UndockButton->setToolTip(QObject::tr("Detach Group"));
#endif
setTitleBarButtonIcon(UndockButton, QStyle::SP_TitleBarNormalButton);
UndockButton->setSizePolicy(ButtonSizePolicy);
TopLayout->addWidget(UndockButton, 0);
_this->connect(UndockButton, SIGNAL(clicked()), SLOT(onUndockButtonClicked()));
// Close button
CloseButton = new tTileBarButton();
CloseButton->setObjectName("closeButton");
CloseButton->setAutoRaise(true);
setTitleBarButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton);
#ifndef QT_NO_TOOLTIP
if (testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
{
CloseButton->setToolTip(QObject::tr("Close Active Tab"));
}
else
{
CloseButton->setToolTip(QObject::tr("Close Group"));
}
#endif
CloseButton->setSizePolicy(ButtonSizePolicy);
CloseButton->setIconSize(QSize(16, 16));
if (testConfigFlag(CDockManager::DockAreaHasCloseButton))
{
TopLayout->addWidget(CloseButton, 0);
}
_this->connect(CloseButton, SIGNAL(clicked()), SLOT(onCloseButtonClicked()));
}
//============================================================================
void DockAreaTitleBarPrivate::createTabBar()
{
TabBar = new CDockAreaTabBar(DockArea);
TopLayout->addWidget(TabBar);
_this->connect(TabBar, SIGNAL(tabClosed(int)), SLOT(markTabsMenuOutdated()));
_this->connect(TabBar, SIGNAL(tabOpened(int)), SLOT(markTabsMenuOutdated()));
_this->connect(TabBar, SIGNAL(tabInserted(int)), SLOT(markTabsMenuOutdated()));
_this->connect(TabBar, SIGNAL(removingTab(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(tabBarClicked(int)), SIGNAL(tabBarClicked(int)));
TabBar->setContextMenuPolicy(Qt::CustomContextMenu);
_this->connect(TabBar, SIGNAL(customContextMenuRequested(const QPoint&)),
SLOT(showContextMenu(const QPoint&)));
}
//============================================================================
CDockAreaTitleBar::CDockAreaTitleBar(CDockAreaWidget* parent) :
QFrame(parent),
d(new DockAreaTitleBarPrivate(this))
{
d->DockArea = parent;
setObjectName("dockAreaTitleBar");
d->TopLayout = new QBoxLayout(QBoxLayout::LeftToRight);
d->TopLayout->setContentsMargins(0, 0, 0, 0);
d->TopLayout->setSpacing(0);
setLayout(d->TopLayout);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
d->createTabBar();
d->createButtons();
}
//============================================================================
CDockAreaTitleBar::~CDockAreaTitleBar()
{
delete d;
}
//============================================================================
CDockAreaTabBar* CDockAreaTitleBar::tabBar() const
{
return d->TabBar;
}
//============================================================================
void CDockAreaTitleBar::markTabsMenuOutdated()
{
d->MenuOutdated = true;
}
//============================================================================
void CDockAreaTitleBar::onTabsMenuAboutToShow()
{
if (!d->MenuOutdated)
{
return;
}
QMenu* menu = d->TabsMenuButton->menu();
menu->clear();
for (int i = 0; i < d->TabBar->count(); ++i)
{
if (!d->TabBar->isTabOpen(i))
{
continue;
}
auto Tab = d->TabBar->tab(i);
QAction* Action = menu->addAction(Tab->icon(), Tab->text());
#ifndef QT_NO_TOOLTIP
Action->setToolTip(Tab->toolTip());
#endif
Action->setData(i);
}
d->MenuOutdated = false;
}
//============================================================================
void CDockAreaTitleBar::onCloseButtonClicked()
{
ADS_PRINT("CDockAreaTitleBar::onCloseButtonClicked");
if (d->testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
{
d->TabBar->closeTab(d->TabBar->currentIndex());
}
else
{
d->DockArea->closeArea();
}
}
//============================================================================
void CDockAreaTitleBar::onUndockButtonClicked()
{
if (d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
{
d->TabBar->makeAreaFloating(mapFromGlobal(QCursor::pos()), DraggingInactive);
}
}
//============================================================================
void CDockAreaTitleBar::onTabsMenuActionTriggered(QAction* Action)
{
int Index = Action->data().toInt();
d->TabBar->setCurrentIndex(Index);
emit tabBarClicked(Index);
}
//============================================================================
void CDockAreaTitleBar::onCurrentTabChanged(int Index)
{
if (Index < 0)
{
return;
}
if (d->testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
{
CDockWidget* DockWidget = d->TabBar->tab(Index)->dockWidget();
d->CloseButton->setEnabled(DockWidget->features().testFlag(CDockWidget::DockWidgetClosable));
}
}
//============================================================================
QAbstractButton* CDockAreaTitleBar::button(TitleBarButton which) const
{
switch (which)
{
case TitleBarButtonTabsMenu: return d->TabsMenuButton;
case TitleBarButtonUndock: return d->UndockButton;
case TitleBarButtonClose: return d->CloseButton;
default:
return nullptr;
}
}
//============================================================================
void CDockAreaTitleBar::setVisible(bool Visible)
{
Super::setVisible(Visible);
markTabsMenuOutdated();
}
//============================================================================
void CDockAreaTitleBar::showContextMenu(const QPoint& pos)
{
QMenu Menu(this);
auto Action = Menu.addAction(tr("Detach Area"), this, SLOT(onUndockButtonClicked()));
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
Menu.addSeparator();
Action = Menu.addAction(tr("Close Area"), this, SLOT(onCloseButtonClicked()));
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
Menu.addAction(tr("Close Other Areas"), d->DockArea, SLOT(closeOtherAreas()));
Menu.exec(mapToGlobal(pos));
}
} // namespace ads
//---------------------------------------------------------------------------
// EOF DockAreaTitleBar.cpp

112
src/DockAreaTitleBar.h Normal file
View File

@@ -0,0 +1,112 @@
#ifndef DockAreaTitleBarH
#define DockAreaTitleBarH
/*******************************************************************************
** 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/>.
******************************************************************************/
//============================================================================
/// \file DockAreaTitleBar.h
/// \author Uwe Kindler
/// \date 12.10.2018
/// \brief Declaration of CDockAreaTitleBar class
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include <QFrame>
#include "ads_globals.h"
class QAbstractButton;
namespace ads
{
class CDockAreaTabBar;
class CDockAreaWidget;
struct DockAreaTitleBarPrivate;
/**
* Title bar of a dock area.
* The title bar contains a tabbar with all tabs for a dock widget group and
* with a tabs menu button, a undock button and a close button.
*/
class ADS_EXPORT CDockAreaTitleBar : public QFrame
{
Q_OBJECT
private:
DockAreaTitleBarPrivate* d; ///< private data (pimpl)
friend struct DockAreaTitleBarPrivate;
private slots:
void onTabsMenuAboutToShow();
void onCloseButtonClicked();
void onUndockButtonClicked();
void onTabsMenuActionTriggered(QAction* Action);
void onCurrentTabChanged(int Index);
void showContextMenu(const QPoint& pos);
public slots:
/**
* Call this slot to tell the title bar that it should update the tabs menu
* the next time it is shown.
*/
void markTabsMenuOutdated();
public:
using Super = QFrame;
/**
* Default Constructor
*/
CDockAreaTitleBar(CDockAreaWidget* parent);
/**
* Virtual Destructor
*/
virtual ~CDockAreaTitleBar();
/**
* Returns the pointer to the tabBar()
*/
CDockAreaTabBar* tabBar() const;
/**
* Returns the button corresponding to the given title bar button identifier
*/
QAbstractButton* button(TitleBarButton which) const;
/**
* Marks the tabs menu outdated before it calls its base class
* implementation
*/
virtual void setVisible(bool Visible) override;
signals:
/**
* This signal is emitted if a tab in the tab bar is clicked by the user
* or if the user clicks on a tab item in the title bar tab menu.
*/
void tabBarClicked(int index);
}; // class name
}
// namespace ads
//-----------------------------------------------------------------------------
#endif // DockAreaTitleBarH

View File

@@ -1,17 +1,17 @@
/*******************************************************************************
** 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/>.
******************************************************************************/
@@ -28,7 +28,7 @@
//============================================================================
// INCLUDES
//============================================================================
#include <DockWidgetTab.h>
#include "DockWidgetTab.h"
#include "DockAreaWidget.h"
#include <QStackedLayout>
@@ -41,6 +41,8 @@
#include <QMenu>
#include <QSplitter>
#include <QXmlStreamWriter>
#include <QVector>
#include <QList>
#include "DockContainerWidget.h"
@@ -49,13 +51,187 @@
#include "DockManager.h"
#include "DockOverlay.h"
#include "DockAreaTabBar.h"
#include "DockSplitter.h"
#include "DockAreaTitleBar.h"
#include <iostream>
namespace ads
{
static const char* const INDEX_PROPERTY = "index";
static const char* const ACTION_PROPERTY = "action";
static const int APPEND = -1;
/**
* Internal dock area layout mimics stack layout but only inserts the current
* widget into the internal QLayout object.
* \warning Only the current widget has a parent. All other widgets
* do not have a parent. That means, a widget that is in this layout may
* return nullptr for its parent() function if it is not the current widget.
*/
class CDockAreaLayout
{
private:
QBoxLayout* m_ParentLayout;
QList<QWidget*> m_Widgets;
int m_CurrentIndex = -1;
QWidget* m_CurrentWidget = nullptr;
public:
/**
* Creates an instance with the given parent layout
*/
CDockAreaLayout(QBoxLayout* ParentLayout)
: m_ParentLayout(ParentLayout)
{
}
/**
* Returns the number of widgets in this layout
*/
int count() const
{
return m_Widgets.count();
}
/**
* Inserts the widget at the given index position into the internal widget
* list
*/
void insertWidget(int index, QWidget* Widget)
{
Widget->setParent(nullptr);
if (index < 0)
{
index = m_Widgets.count();
}
m_Widgets.insert(index, Widget);
if (m_CurrentIndex < 0)
{
setCurrentIndex(index);
}
else
{
if (index <= m_CurrentIndex )
{
++m_CurrentIndex;
}
}
}
/**
* Removes the given widget from the layout
*/
void removeWidget(QWidget* Widget)
{
if (currentWidget() == Widget)
{
auto LayoutItem = m_ParentLayout->takeAt(1);
if (LayoutItem)
{
LayoutItem->widget()->setParent(nullptr);
}
m_CurrentWidget = nullptr;
m_CurrentIndex = -1;
}
m_Widgets.removeOne(Widget);
}
/**
* Returns the current selected widget
*/
QWidget* currentWidget() const
{
return m_CurrentWidget;
}
/**
* Activates the widget with the give index.
*/
void setCurrentIndex(int index)
{
QWidget *prev = currentWidget();
QWidget *next = widget(index);
if (!next || (next == prev && !m_CurrentWidget))
{
return;
}
bool reenableUpdates = false;
QWidget *parent = m_ParentLayout->parentWidget();
if (parent && parent->updatesEnabled())
{
reenableUpdates = true;
parent->setUpdatesEnabled(false);
}
auto LayoutItem = m_ParentLayout->takeAt(1);
if (LayoutItem)
{
LayoutItem->widget()->setParent(nullptr);
}
m_ParentLayout->addWidget(next);
if (prev)
{
prev->hide();
}
m_CurrentIndex = index;
m_CurrentWidget = next;
if (reenableUpdates)
{
parent->setUpdatesEnabled(true);
}
}
/**
* Returns the index of the current active widget
*/
int currentIndex() const
{
return m_CurrentIndex;
}
/**
* Returns true if there are no widgets in the layout
*/
bool isEmpty() const
{
return m_Widgets.empty();
}
/**
* Returns the index of the given widget
*/
int indexOf(QWidget* w) const
{
return m_Widgets.indexOf(w);
}
/**
* Returns the widget for the given index
*/
QWidget* widget(int index) const
{
return (index < m_Widgets.size()) ? m_Widgets.at(index) : nullptr;
}
/**
* Returns the geometry of the current active widget
*/
QRect geometry() const
{
return m_Widgets.empty() ? QRect() : currentWidget()->geometry();
}
};
using DockAreaLayout = CDockAreaLayout;
/**
@@ -63,18 +239,12 @@ static const int APPEND = -1;
*/
struct DockAreaWidgetPrivate
{
CDockAreaWidget* _this;
QBoxLayout* Layout;
QFrame* TitleBar;
QBoxLayout* TopLayout;
QStackedLayout* ContentsLayout;
CDockAreaTabBar* TabBar;
QWidget* TabsContainerWidget;
QBoxLayout* TabsLayout;
QPushButton* TabsMenuButton;
QPushButton* CloseButton;
int TabsLayoutInitCount;
CDockManager* DockManager = nullptr;
CDockAreaWidget* _this = nullptr;
QBoxLayout* Layout = nullptr;
DockAreaLayout* ContentsLayout = nullptr;
CDockAreaTitleBar* TitleBar = nullptr;
CDockManager* DockManager = nullptr;
bool UpdateTitleBarButtons = false;
/**
* Private data constructor
@@ -84,7 +254,7 @@ struct DockAreaWidgetPrivate
/**
* Creates the layout for top area with tabs and close button
*/
void createTabBar();
void createTitleBar();
/**
* Returns the dock widget with the given index
@@ -97,18 +267,11 @@ struct DockAreaWidgetPrivate
/**
* Convenience function to ease title widget access by index
*/
CDockWidgetTab* titleWidgetAt(int index)
CDockWidgetTab* tabWidgetAt(int index)
{
return dockWidgetAt(index)->titleBar();
return dockWidgetAt(index)->tabWidget();
}
/**
* Adds a tabs menu entry for the given dock widget
* If menu is 0, a menu entry is added to the menu of the TabsMenuButton
* member. If menu is a valid menu pointer, the entry will be added to
* the given menu
*/
void addTabsMenuEntry(CDockWidget* DockWidget, int Index = -1, QMenu* menu = 0);
/**
* Returns the tab action of the given dock widget
@@ -127,16 +290,17 @@ struct DockAreaWidgetPrivate
}
/**
* Update the tabs menu if dock widget order changed or if dock widget has
* been removed
* Convenience function for tabbar access
*/
void updateTabsMenu();
CDockAreaTabBar* tabBar() const
{
return TitleBar->tabBar();
}
/**
* Updates the tab bar visibility depending on the number of dock widgets
* in this area
* Udpates the enable state of the close and detach button
*/
void updateTabBar();
void updateTitleBarButtonStates();
};
// struct DockAreaWidgetPrivate
@@ -150,102 +314,30 @@ DockAreaWidgetPrivate::DockAreaWidgetPrivate(CDockAreaWidget* _public) :
//============================================================================
void DockAreaWidgetPrivate::createTabBar()
void DockAreaWidgetPrivate::createTitleBar()
{
TitleBar = new QFrame(_this);
TitleBar->setObjectName("dockAreaTitleBar");
TopLayout = new QBoxLayout(QBoxLayout::LeftToRight);
TopLayout->setContentsMargins(0, 0, 0, 0);
TopLayout->setSpacing(0);
TitleBar->setLayout(TopLayout);
TitleBar = new CDockAreaTitleBar(_this);
Layout->addWidget(TitleBar);
TabBar = new CDockAreaTabBar(_this);
TopLayout->addWidget(TabBar, 1);
TabsContainerWidget = new QWidget();
TabsContainerWidget->setObjectName("tabsContainerWidget");
TabBar->setWidget(TabsContainerWidget);
TabsLayout = new QBoxLayout(QBoxLayout::LeftToRight);
TabsLayout->setContentsMargins(0, 0, 0, 0);
TabsLayout->setSpacing(0);
TabsLayout->addStretch(1);
TabsContainerWidget->setLayout(TabsLayout);
TabsMenuButton = new QPushButton();
TabsMenuButton->setObjectName("tabsMenuButton");
TabsMenuButton->setFlat(true);
TabsMenuButton->setIcon(_this->style()->standardIcon(QStyle::SP_TitleBarUnshadeButton));
TabsMenuButton->setMaximumWidth(TabsMenuButton->iconSize().width());
TabsMenuButton->setMenu(new QMenu(TabsMenuButton));
TopLayout->addWidget(TabsMenuButton, 0);
TabsMenuButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
_this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)),
SLOT(onTabsMenuActionTriggered(QAction*)));
CloseButton = new QPushButton();
CloseButton->setObjectName("closeButton");
CloseButton->setFlat(true);
CloseButton->setIcon(_this->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
CloseButton->setToolTip(_this->tr("Close"));
CloseButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
TopLayout->addWidget(CloseButton, 0);
_this->connect(CloseButton, SIGNAL(clicked()), SLOT(onCloseButtonClicked()));
TabsLayoutInitCount = TabsLayout->count();
QObject::connect(tabBar(), &CDockAreaTabBar::tabCloseRequested, _this, &CDockAreaWidget::onTabCloseRequested);
QObject::connect(TitleBar, &CDockAreaTitleBar::tabBarClicked, _this, &CDockAreaWidget::setCurrentIndex);
QObject::connect(tabBar(), &CDockAreaTabBar::tabMoved, _this, &CDockAreaWidget::reorderDockWidget);
}
//============================================================================
void DockAreaWidgetPrivate::updateTabBar()
void DockAreaWidgetPrivate::updateTitleBarButtonStates()
{
CDockContainerWidget* Container = _this->dockContainer();
if (!Container)
if (_this->isHidden())
{
UpdateTitleBarButtons = true;
return;
}
if (Container->isFloating() && (Container->dockAreaCount() == 1) && (_this->count() == 1))
{
TitleBar->setVisible(false);
}
else
{
TitleBar->setVisible(true);
}
}
//============================================================================
void DockAreaWidgetPrivate::addTabsMenuEntry(CDockWidget* DockWidget,
int Index, QMenu* menu)
{
menu = menu ? menu : TabsMenuButton->menu();
QAction* Action;
if (Index >= 0 && Index < menu->actions().count())
{
Action = new QAction(DockWidget->icon(), DockWidget->windowTitle());
menu->insertAction(menu->actions().at(Index), Action);
}
else
{
Action = menu->addAction(DockWidget->icon(), DockWidget->windowTitle());
}
QVariant vAction = QVariant::fromValue(Action);
DockWidget->setProperty(ACTION_PROPERTY, vAction);
}
//============================================================================
void DockAreaWidgetPrivate::updateTabsMenu()
{
QMenu* menu = TabsMenuButton->menu();
menu->clear();
for (int i = 0; i < ContentsLayout->count(); ++i)
{
addTabsMenuEntry(dockWidgetAt(i), APPEND, menu);
}
TitleBar->button(TitleBarButtonClose)->setEnabled(
_this->features().testFlag(CDockWidget::DockWidgetClosable));
TitleBar->button(TitleBarButtonUndock)->setEnabled(
_this->features().testFlag(CDockWidget::DockWidgetFloatable));
UpdateTitleBarButtons = false;
}
@@ -260,18 +352,15 @@ CDockAreaWidget::CDockAreaWidget(CDockManager* DockManager, CDockContainerWidget
d->Layout->setSpacing(0);
setLayout(d->Layout);
d->createTabBar();
d->ContentsLayout = new QStackedLayout();
d->ContentsLayout->setContentsMargins(0, 0, 0, 0);
d->ContentsLayout->setSpacing(0);
d->Layout->addLayout(d->ContentsLayout, 1);
d->createTitleBar();
d->ContentsLayout = new DockAreaLayout(d->Layout);
}
//============================================================================
CDockAreaWidget::~CDockAreaWidget()
{
qDebug() << "~CDockAreaWidget()";
ADS_PRINT("~CDockAreaWidget()");
delete d->ContentsLayout;
delete d;
}
@@ -286,18 +375,7 @@ CDockManager* CDockAreaWidget::dockManager() const
//============================================================================
CDockContainerWidget* CDockAreaWidget::dockContainer() const
{
QWidget* Parent = parentWidget();
while (Parent)
{
CDockContainerWidget* Container = dynamic_cast<CDockContainerWidget*>(Parent);
if (Container)
{
return Container;
}
Parent = Parent->parentWidget();
}
return 0;
return internal::findParent<CDockContainerWidget*>(this);
}
@@ -313,83 +391,140 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
bool Activate)
{
d->ContentsLayout->insertWidget(index, DockWidget);
DockWidget->titleBar()->setDockAreaWidget(this);
auto TitleBar = DockWidget->titleBar();
d->TabsLayout->insertWidget(index, TitleBar);
TitleBar->show();
connect(TitleBar, SIGNAL(clicked()), this, SLOT(onDockWidgetTitleClicked()));
DockWidget->tabWidget()->setDockAreaWidget(this);
auto TabWidget = DockWidget->tabWidget();
// Inserting the tab will change the current index which in turn will
// make the tab widget visible in the slot
d->tabBar()->blockSignals(true);
d->tabBar()->insertTab(index, TabWidget);
d->tabBar()->blockSignals(false);
TabWidget->setVisible(!DockWidget->isClosed());
DockWidget->setProperty(INDEX_PROPERTY, index);
if (Activate)
{
setCurrentIndex(index);
}
d->addTabsMenuEntry(DockWidget, index);
DockWidget->setDockArea(this);
d->updateTitleBarButtonStates();
}
//============================================================================
void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
{
qDebug() << "CDockAreaWidget::removeDockWidget";
d->ContentsLayout->removeWidget(DockWidget);
auto TitleBar = DockWidget->titleBar();
TitleBar->hide();
d->TabsLayout->removeWidget(TitleBar);
disconnect(TitleBar, SIGNAL(clicked()), this, SLOT(onDockWidgetTitleClicked()));
setCurrentIndex(d->ContentsLayout->currentIndex());
d->updateTabsMenu();
ADS_PRINT("CDockAreaWidget::removeDockWidget");
auto NextOpenDockWidget = nextOpenDockWidget(DockWidget);
d->ContentsLayout->removeWidget(DockWidget);
auto TabWidget = DockWidget->tabWidget();
TabWidget->hide();
d->tabBar()->removeTab(TabWidget);
CDockContainerWidget* DockContainer = dockContainer();
if (d->ContentsLayout->isEmpty())
if (NextOpenDockWidget)
{
qDebug() << "Dock Area empty";
dockContainer()->removeDockArea(this);
this->deleteLater();;
setCurrentDockWidget(NextOpenDockWidget);
}
else if (d->ContentsLayout->isEmpty() && DockContainer->dockAreaCount() > 1)
{
ADS_PRINT("Dock Area empty");
DockContainer->removeDockArea(this);
this->deleteLater();
}
else
{
// if contents layout is not empty but there are no more open dock
// widgets, then we need to hide the dock area because it does not
// contain any visible content
hideAreaWithNoVisibleContent();
}
d->updateTabBar();
DockWidget->setDockArea(nullptr);
d->updateTitleBarButtonStates();
updateTitleBarVisibility();
auto TopLevelDockWidget = DockContainer->topLevelDockWidget();
if (TopLevelDockWidget)
{
TopLevelDockWidget->emitTopLevelChanged(true);
}
#if (ADS_DEBUG_LEVEL > 0)
DockContainer->dumpLayout();
#endif
}
//============================================================================
void CDockAreaWidget::onDockWidgetTitleClicked()
void CDockAreaWidget::hideAreaWithNoVisibleContent()
{
CDockWidgetTab* TitleWidget = qobject_cast<CDockWidgetTab*>(sender());
if (!TitleWidget)
this->toggleView(false);
// Hide empty parent splitters
auto Splitter = internal::findParent<CDockSplitter*>(this);
internal::hideEmptyParentSplitters(Splitter);
//Hide empty floating widget
CDockContainerWidget* Container = this->dockContainer();
if (!Container->isFloating())
{
return;
}
int index = d->TabsLayout->indexOf(TitleWidget);
setCurrentIndex(index);
updateTitleBarVisibility();
auto TopLevelWidget = Container->topLevelDockWidget();
auto FloatingWidget = Container->floatingWidget();
if (TopLevelWidget)
{
FloatingWidget->updateWindowTitle();
CDockWidget::emitTopLevelEventForWidget(TopLevelWidget, true);
}
else if (Container->openedDockAreas().isEmpty())
{
FloatingWidget->hide();
}
}
//============================================================================
void CDockAreaWidget::onCloseButtonClicked()
void CDockAreaWidget::onTabCloseRequested(int Index)
{
currentDockWidget()->toggleView(false);
ADS_PRINT("CDockAreaWidget::onTabCloseRequested " << Index);
dockWidget(Index)->toggleView(false);
}
//============================================================================
CDockWidget* CDockAreaWidget::currentDockWidget() const
{
return dockWidget(currentIndex());
int CurrentIndex = currentIndex();
if (CurrentIndex < 0)
{
return nullptr;
}
return dockWidget(CurrentIndex);
}
//============================================================================
void CDockAreaWidget::setCurrentDockWidget(CDockWidget* DockWidget)
{
int Index = tabIndex(DockWidget);
if (dockManager()->isRestoringState())
{
return;
}
internalSetCurrentDockWidget(DockWidget);
}
//============================================================================
void CDockAreaWidget::internalSetCurrentDockWidget(CDockWidget* DockWidget)
{
int Index = index(DockWidget);
if (Index < 0)
{
return;
}
setCurrentIndex(Index);
}
@@ -397,43 +532,15 @@ void CDockAreaWidget::setCurrentDockWidget(CDockWidget* DockWidget)
//============================================================================
void CDockAreaWidget::setCurrentIndex(int index)
{
if (index < 0 || index > (d->TabsLayout->count() - 1))
auto TabBar = d->tabBar();
if (index < 0 || index > (TabBar->count() - 1))
{
qWarning() << Q_FUNC_INFO << "Invalid index" << index;
return;
}
emit currentChanging(index);
// Set active TAB and update all other tabs to be inactive
for (int i = 0; i < d->TabsLayout->count(); ++i)
{
QLayoutItem* item = d->TabsLayout->itemAt(i);
if (!item->widget())
{
continue;
}
auto TitleWidget = dynamic_cast<CDockWidgetTab*>(item->widget());
if (!TitleWidget)
{
continue;
}
if (i == index)
{
TitleWidget->show();
TitleWidget->setActiveTab(true);
d->TabBar->ensureWidgetVisible(TitleWidget);
auto Features = TitleWidget->dockWidget()->features();
d->CloseButton->setVisible(Features.testFlag(CDockWidget::DockWidgetClosable));
}
else
{
TitleWidget->setActiveTab(false);
}
}
TabBar->setCurrentIndex(index);
d->ContentsLayout->setCurrentIndex(index);
d->ContentsLayout->currentWidget()->show();
emit currentChanged(index);
@@ -448,9 +555,9 @@ int CDockAreaWidget::currentIndex() const
//============================================================================
QRect CDockAreaWidget::titleAreaGeometry() const
QRect CDockAreaWidget::titleBarGeometry() const
{
return d->TopLayout->geometry();
return d->TitleBar->geometry();
}
//============================================================================
@@ -461,7 +568,7 @@ QRect CDockAreaWidget::contentAreaGeometry() const
//============================================================================
int CDockAreaWidget::tabIndex(CDockWidget* DockWidget)
int CDockAreaWidget::index(CDockWidget* DockWidget)
{
return d->ContentsLayout->indexOf(DockWidget);
}
@@ -479,6 +586,21 @@ QList<CDockWidget*> CDockAreaWidget::dockWidgets() const
}
//============================================================================
int CDockAreaWidget::openDockWidgetsCount() const
{
int Count = 0;
for (int i = 0; i < d->ContentsLayout->count(); ++i)
{
if (!dockWidget(i)->isClosed())
{
++Count;
}
}
return Count;
}
//============================================================================
QList<CDockWidget*> CDockAreaWidget::openedDockWidgets() const
{
@@ -496,22 +618,22 @@ QList<CDockWidget*> CDockAreaWidget::openedDockWidgets() const
//============================================================================
int CDockAreaWidget::indexOfContentByTitlePos(const QPoint& p, QWidget* exclude) const
int CDockAreaWidget::indexOfFirstOpenDockWidget() const
{
for (int i = 0; i < d->ContentsLayout->count(); ++i)
{
auto TitleWidget = d->titleWidgetAt(i);
if (TitleWidget->geometry().contains(p) && (!exclude || TitleWidget != exclude))
if (!dockWidget(i)->isClosed())
{
return i;
}
}
return -1;
}
//============================================================================
int CDockAreaWidget::count() const
int CDockAreaWidget::dockWidgetsCount() const
{
return d->ContentsLayout->count();
}
@@ -520,70 +642,74 @@ int CDockAreaWidget::count() const
//============================================================================
CDockWidget* CDockAreaWidget::dockWidget(int Index) const
{
return dynamic_cast<CDockWidget*>(d->ContentsLayout->widget(Index));
return qobject_cast<CDockWidget*>(d->ContentsLayout->widget(Index));
}
//============================================================================
void CDockAreaWidget::reorderDockWidget(int fromIndex, int toIndex)
{
ADS_PRINT("CDockAreaWidget::reorderDockWidget");
if (fromIndex >= d->ContentsLayout->count() || fromIndex < 0
|| toIndex >= d->ContentsLayout->count() || toIndex < 0 || fromIndex == toIndex)
{
qDebug() << "Invalid index for tab movement" << fromIndex << toIndex;
d->TabsLayout->update();
ADS_PRINT("Invalid index for tab movement" << fromIndex << toIndex);
return;
}
CDockWidget* DockWidget = dockWidget(fromIndex);
// reorder tabs menu action to match new order of contents
auto Menu = d->TabsMenuButton->menu();
auto TabsAction = d->dockWidgetTabAction(DockWidget);
Menu->removeAction(TabsAction);
if (toIndex >= Menu->actions().count())
{
Menu->addAction(TabsAction);
}
else
{
Menu->insertAction(Menu->actions().at(toIndex), TabsAction);
}
// now reorder contents and title bars
QLayoutItem* liFrom = nullptr;
liFrom = d->TabsLayout->takeAt(fromIndex);
d->TabsLayout->insertItem(toIndex, liFrom);
liFrom = d->ContentsLayout->takeAt(fromIndex);
d->ContentsLayout->insertWidget(toIndex, liFrom->widget());
delete liFrom;
auto Widget = d->ContentsLayout->widget(fromIndex);
d->ContentsLayout->removeWidget(Widget);
d->ContentsLayout->insertWidget(toIndex, Widget);
setCurrentIndex(toIndex);
}
//============================================================================
void CDockAreaWidget::onTabsMenuActionTriggered(QAction* Action)
void CDockAreaWidget::toggleDockWidgetView(CDockWidget* DockWidget, bool Open)
{
int Index = d->TabsMenuButton->menu()->actions().indexOf(Action);
setCurrentIndex(Index);
Q_UNUSED(DockWidget);
Q_UNUSED(Open);
updateTitleBarVisibility();
}
//============================================================================
void CDockAreaWidget::updateDockArea()
void CDockAreaWidget::updateTitleBarVisibility()
{
d->updateTabBar();
CDockContainerWidget* Container = dockContainer();
if (!Container)
{
return;
}
if (d->TitleBar)
{
d->TitleBar->setVisible(!Container->isFloating() || !Container->hasTopLevelDockWidget());
}
}
//============================================================================
void CDockAreaWidget::markTitleBarMenuOutdated()
{
if (d->TitleBar)
{
d->TitleBar->markTabsMenuOutdated();
}
}
//============================================================================
void CDockAreaWidget::saveState(QXmlStreamWriter& s) const
{
s.writeStartElement("DockAreaWidget");
s.writeStartElement("Area");
s.writeAttribute("Tabs", QString::number(d->ContentsLayout->count()));
s.writeAttribute("CurrentIndex", QString::number(d->ContentsLayout->currentIndex()));
qDebug() << "CDockAreaWidget::saveState TabCount: " << d->ContentsLayout->count()
<< " CurrentIndex: " << d->ContentsLayout->currentIndex();
auto CurrentDockWidget = currentDockWidget();
QString Name = CurrentDockWidget ? CurrentDockWidget->objectName() : "";
s.writeAttribute("Current", Name);
ADS_PRINT("CDockAreaWidget::saveState TabCount: " << d->ContentsLayout->count()
<< " Current: " << Name);
for (int i = 0; i < d->ContentsLayout->count(); ++i)
{
dockWidget(i)->saveState(s);
@@ -591,6 +717,88 @@ void CDockAreaWidget::saveState(QXmlStreamWriter& s) const
s.writeEndElement();
}
//============================================================================
CDockWidget* CDockAreaWidget::nextOpenDockWidget(CDockWidget* DockWidget) const
{
auto OpenDockWidgets = openedDockWidgets();
if (OpenDockWidgets.count() > 1 || (OpenDockWidgets.count() == 1 && OpenDockWidgets[0] != DockWidget))
{
CDockWidget* NextDockWidget;
if (OpenDockWidgets.last() == DockWidget)
{
NextDockWidget = OpenDockWidgets[OpenDockWidgets.count() - 2];
}
else
{
int NextIndex = OpenDockWidgets.indexOf(DockWidget) + 1;
NextDockWidget = OpenDockWidgets[NextIndex];
}
return NextDockWidget;
}
else
{
return nullptr;
}
}
//============================================================================
CDockWidget::DockWidgetFeatures CDockAreaWidget::features() const
{
CDockWidget::DockWidgetFeatures Features(CDockWidget::AllDockWidgetFeatures);
for (const auto DockWidget : dockWidgets())
{
Features &= DockWidget->features();
}
return Features;
}
//============================================================================
void CDockAreaWidget::toggleView(bool Open)
{
setVisible(Open);
emit viewToggled(Open);
}
//============================================================================
void CDockAreaWidget::setVisible(bool Visible)
{
Super::setVisible(Visible);
if (d->UpdateTitleBarButtons)
{
d->updateTitleBarButtonStates();
}
}
//============================================================================
QAbstractButton* CDockAreaWidget::titleBarButton(TitleBarButton which) const
{
return d->TitleBar->button(which);
}
//============================================================================
void CDockAreaWidget::closeArea()
{
for (auto DockWidget : openedDockWidgets())
{
DockWidget->toggleView(false);
}
}
//============================================================================
void CDockAreaWidget::closeOtherAreas()
{
dockContainer()->closeOtherAreas(this);
}
} // namespace ads
//---------------------------------------------------------------------------

View File

@@ -33,16 +33,17 @@
#include <QFrame>
#include "ads_globals.h"
#include "DockWidget.h"
class QXmlStreamWriter;
class QAbstractButton;
namespace ads
{
struct DockAreaWidgetPrivate;
class CDockManager;
class CDockContainerWidget;
struct DockContainerWidgetPrivate;
class CDockWidget;
class DockContainerWidgetPrivate;
/**
@@ -59,11 +60,18 @@ private:
friend class CDockContainerWidget;
friend class DockContainerWidgetPrivate;
friend class CDockWidgetTab;
friend struct DockWidgetPrivate;
friend class CDockWidget;
friend struct DockManagerPrivate;
private slots:
void onDockWidgetTitleClicked();
void onTabsMenuActionTriggered(QAction* Action);
void onCloseButtonClicked();
void onTabCloseRequested(int Index);
/**
* Reorder the index position of DockWidget at fromIndx to toIndex
* if a tab in the tabbar is dragged from one index to another one
*/
void reorderDockWidget(int fromIndex, int toIndex);
protected:
/**
@@ -87,18 +95,53 @@ protected:
void removeDockWidget(CDockWidget* DockWidget);
/**
* Returns the index of contents of the title widget that is located at
* mouse position pos
* Called from dock widget if it is opened or closed
*/
int indexOfContentByTitlePos(const QPoint& pos, QWidget* exclude = nullptr) const;
void toggleDockWidgetView(CDockWidget* DockWidget, bool Open);
/**
* Reorder the index position of DockWidget at fromIndx to toIndex.
* This is a helper function to get the next open dock widget to activate
* if the given DockWidget will be closed or removed.
* The function returns the next widget that should be activated or
* nullptr in case there are no more open widgets in this area.
*/
void reorderDockWidget(int fromIndex, int toIndex);
CDockWidget* nextOpenDockWidget(CDockWidget* DockWidget) const;
/**
* Returns the index of the given DockWidget in the internal layout
*/
int index(CDockWidget* DockWidget);
/**
* Call this function, if you already know, that the dock does not
* contain any visible content (any open dock widgets).
*/
void hideAreaWithNoVisibleContent();
/**
* Updates the dock area layout and components visibility
*/
void updateTitleBarVisibility();
/**
* This is the internal private function for setting the current widget.
* This function is called by the public setCurrentDockWidget() function
* and by the dock manager when restoring the state
*/
void internalSetCurrentDockWidget(CDockWidget* DockWidget);
/**
* Marks tabs menu to update
*/
void markTitleBarMenuOutdated();
protected slots:
void toggleView(bool Open);
public:
using Super = QFrame;
/**
* Default Constructor
*/
@@ -123,7 +166,7 @@ public:
/**
* Returns the rectangle of the title area
*/
QRect titleAreaGeometry() const;
QRect titleBarGeometry() const;
/**
* Returns the rectangle of the content
@@ -131,9 +174,9 @@ public:
QRect contentAreaGeometry() const;
/**
* Returns the tab index of the given DockWidget
* Returns the number of dock widgets in this area
*/
int tabIndex(CDockWidget* DockWidget);
int dockWidgetsCount() const;
/**
* Returns a list of all dock widgets in this dock area.
@@ -142,14 +185,14 @@ public:
QList<CDockWidget*> dockWidgets() const;
/**
* Returns a list of dock widgets that are not closed
* Returns the number of open dock widgets in this area
*/
QList<CDockWidget*> openedDockWidgets() const;
int openDockWidgetsCount() const;
/**
* Returns the number of dock widgets in this area
* Returns a list of dock widgets that are not closed.
*/
int count() const;
QList<CDockWidget*> openedDockWidgets() const;
/**
* Returns a dock widget by its index
@@ -157,12 +200,25 @@ public:
CDockWidget* dockWidget(int Index) const;
/**
* Returns the index of the current active dock widget
* Returns the index of the current active dock widget or -1 if there
* are is no active dock widget (ie.e if all dock widgets are closed)
*/
int currentIndex() const;
/**
* Returns the current active dock widget
* Returns the index of the first open dock widgets in the list of
* dock widgets.
* This function is here for performance reasons. Normally it would
* be possible to take the first dock widget from the list returned by
* openedDockWidgets() function. But that function enumerates all
* dock widgets while this functions stops after the first open dock widget.
* If there are no open dock widgets, the function returns -1.
*/
int indexOfFirstOpenDockWidget() const;
/**
* Returns the current active dock widget or a nullptr if there is no
* active dock widget (i.e. if all dock widgets are closed)
*/
CDockWidget* currentDockWidget() const;
@@ -176,16 +232,45 @@ public:
*/
void saveState(QXmlStreamWriter& Stream) const;
/**
* This functions returns the dock widget features of all dock widget in
* this area.
* 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,
* 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
* closable.
*/
CDockWidget::DockWidgetFeatures features() const;
/**
* Returns the title bar button corresponding to the given title bar
* button identifier
*/
QAbstractButton* titleBarButton(TitleBarButton which) const;
/**
* Update the close button if visibility changed
*/
virtual void setVisible(bool Visible) override;
public slots:
/**
* This sets the index position of the current tab page.
* This activates the tab for the given tab index.
* If the dock widget for the given tab is not visible, the this function
* call will make it visible.
*/
void setCurrentIndex(int index);
/**
* Updates the dock area layout and components visibility
* Closes the dock area and all dock widgets in this area
*/
void updateDockArea();
void closeArea();
/**
* This function closes all other areas except of this area
*/
void closeOtherAreas();
signals:
/**
@@ -206,6 +291,12 @@ signals:
* @param index
*/
void currentChanged(int index);
/**
* This signal is emitted if the visibility of this dock area is toggled
* via toggle view function
*/
void viewToggled(bool Open);
}; // class DockAreaWidget
}
// namespace ads

File diff suppressed because it is too large Load Diff

View File

@@ -33,14 +33,14 @@
#include <QFrame>
#include "ads_globals.h"
#include "DockWidget.h"
class QXmlStreamWriter;
class QXmlStreamReader;
namespace ads
{
struct DockContainerWidgetPrivate;
class DockContainerWidgetPrivate;
class CDockAreaWidget;
class CDockWidget;
class CDockManager;
@@ -50,20 +50,24 @@ struct FloatingDockContainerPrivate;
/**
* Container that manages a number of dock areas with single dock widgets
* or tabyfied dock widgets in each area
* or tabyfied dock widgets in each area.
* Each window that support docking has a DockContainerWidget. That means
* the main application window and all floating windows are ore contain
* an DockContainerWidget.
*/
class ADS_EXPORT CDockContainerWidget : public QFrame
{
Q_OBJECT
private:
DockContainerWidgetPrivate* d; ///< private data (pimpl)
friend struct DockContainerWidgetPrivate;
friend class DockContainerWidgetPrivate;
friend class CDockManager;
friend struct DockManagerPrivate;
friend class CDockAreaWidget;
friend struct DockAreaWidgetPrivate;
friend class CFloatingDockContainer;
friend struct FloatingDockContainerPrivate;
friend class CDockWidget;
protected:
/**
* Handles activation events to update zOrderIndex
@@ -75,6 +79,11 @@ protected:
*/
QSplitter* rootSplitter() const;
/**
* Helper function for creation of the root splitter
*/
void createRootSplitter();
/**
* Drop floating widget into the container
*/
@@ -103,6 +112,42 @@ protected:
*/
bool restoreState(QXmlStreamReader& Stream, bool Testing);
/**
* This function returns the last added dock area widget for the given
* area identifier or 0 if no dock area widget has been added for the given
* area
*/
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
* one and only visible dock widget. Otherwise it returns a nullptr.
*/
CDockWidget* topLevelDockWidget() const;
/**
* Returns the top level dock area.
*/
CDockAreaWidget* topLevelDockArea() const;
/**
* This function returns a list of all dock widgets in this floating widget.
* It may be possible, depending on the implementation, that dock widgets,
* that are not visible to the user have no parent widget. Therefore simply
* calling findChildren() would not work here. Therefore this function
* iterates over all dock areas and creates a list that contains all
* dock widgets returned from all dock areas.
*/
QList<CDockWidget*> dockWidgets() const;
public:
/**
* Default Constructor
@@ -124,6 +169,11 @@ public:
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
CDockAreaWidget* DockAreaWidget = nullptr);
/**
* Removes dockwidget
*/
void removeDockWidget(CDockWidget* Dockwidget);
/**
* Returns the current zOrderIndex
*/
@@ -173,6 +223,27 @@ public:
*/
void dumpLayout();
/**
* This functions returns the dock widget features of all dock widget in
* this container.
* A bitwise and is used to combine the flags of all dock widgets. That
* means, if only dock widget does not support a certain flag, the whole
* dock are does not support the flag.
*/
CDockWidget::DockWidgetFeatures features() const;
/**
* If this dock container is in a floating widget, this function returns
* the floating widget.
* Else, it returns a nullptr.
*/
CFloatingDockContainer* floatingWidget() const;
/**
* Call this function to close all dock areas except the KeepOpenArea
*/
void closeOtherAreas(CDockAreaWidget* KeepOpenArea);
signals:
/**
* This signal is emitted if one or multiple dock areas has been added to
@@ -185,6 +256,12 @@ signals:
* This signal is emitted if one or multiple dock areas has been removed
*/
void dockAreasRemoved();
/**
* This signal is emitted if a dock area is opened or closed via
* toggleView() function
*/
void dockAreaViewToggled(CDockAreaWidget* DockArea, bool Open);
}; // class DockContainerWidget
} // namespace ads
//-----------------------------------------------------------------------------

View File

@@ -28,9 +28,10 @@
//============================================================================
// INCLUDES
//============================================================================
#include <DockWidgetTab.h>
#include "DockWidgetTab.h"
#include "DockManager.h"
#include <algorithm>
#include <iostream>
#include <QMainWindow>
@@ -39,21 +40,24 @@
#include <QVariant>
#include <QDebug>
#include <QFile>
#include <QApplication>
#include <QAction>
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include <QSettings>
#include <QMenu>
#include <QApplication>
#include "FloatingDockContainer.h"
#include "DockOverlay.h"
#include "DockWidget.h"
#include "ads_globals.h"
#include "DockStateSerialization.h"
#include "DockAreaWidget.h"
namespace ads
{
static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultConfig;
/**
* Private data class of CDockManager class (pimpl)
*/
@@ -66,6 +70,10 @@ struct DockManagerPrivate
CDockOverlay* DockAreaOverlay;
QMap<QString, CDockWidget*> DockWidgetsMap;
QMap<QString, QByteArray> Perspectives;
QMap<QString, QMenu*> ViewMenuGroups;
QMenu* ViewMenu;
CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted;
bool RestoringState = false;
/**
* Private data constructor
@@ -81,7 +89,33 @@ struct DockManagerPrivate
/**
* Restores the state
*/
bool restoreState(const QByteArray &state, int version, bool Testing = internal::Restore);
bool restoreStateFromXml(const QByteArray &state, int version, bool Testing = internal::Restore);
/**
* Restore state
*/
bool restoreState(const QByteArray &state, int version);
void restoreDockWidgetsOpenState();
void restoreDockAreasIndices();
void emitTopLevelEvents();
void hideFloatingWidgets()
{
// Hide updates of floating widgets from user
for (auto FloatingWidget : FloatingWidgets)
{
FloatingWidget->hide();
}
}
void markDockWidgetsDirty()
{
for (auto DockWidget : DockWidgetsMap)
{
DockWidget->setProperty("dirty", true);
}
}
/**
* Restores the container with the given index
@@ -92,6 +126,11 @@ struct DockManagerPrivate
* Loads the stylesheet
*/
void loadStylesheet();
/**
* Adds action to menu - optionally in sorted order
*/
void addActionToMenu(QAction* Action, QMenu* Menu, bool InsertSorted);
};
// struct DockManagerPrivate
@@ -107,7 +146,11 @@ DockManagerPrivate::DockManagerPrivate(CDockManager* _public) :
void DockManagerPrivate::loadStylesheet()
{
QString Result;
#ifdef Q_OS_LINUX
QFile StyleSheetFile(":ads/stylesheets/default_linux.css");
#else
QFile StyleSheetFile(":ads/stylesheets/default.css");
#endif
StyleSheetFile.open(QIODevice::ReadOnly);
QTextStream StyleSheetStream(&StyleSheetFile);
Result = StyleSheetStream.readAll();
@@ -124,28 +167,39 @@ bool DockManagerPrivate::restoreContainer(int Index, QXmlStreamReader& stream, b
Index = 0;
}
bool Result = false;
if (Index >= Containers.count())
{
CFloatingDockContainer* FloatingWidget = new CFloatingDockContainer(_this);
return FloatingWidget->restoreState(stream, Testing);
Result = FloatingWidget->restoreState(stream, Testing);
}
else
{
qDebug() << "d->Containers[i]->restoreState ";
return Containers[Index]->restoreState(stream, Testing);
ADS_PRINT("d->Containers[i]->restoreState ");
auto Container = Containers[Index];
if (Container->isFloating())
{
Result = Container->floatingWidget()->restoreState(stream, Testing);
}
else
{
Result = Container->restoreState(stream, Testing);
}
}
return Result;
}
//============================================================================
bool DockManagerPrivate::checkFormat(const QByteArray &state, int version)
{
return restoreState(state, version, internal::RestoreTesting);
return restoreStateFromXml(state, version, internal::RestoreTesting);
}
//============================================================================
bool DockManagerPrivate::restoreState(const QByteArray &state, int version,
bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int version,
bool Testing)
{
if (state.isEmpty())
@@ -158,7 +212,7 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version,
{
return false;
}
qDebug() << s.attributes().value("Version");
ADS_PRINT(s.attributes().value("Version"));
bool ok;
int v = s.attributes().value("Version").toInt(&ok);
if (!ok || v != version)
@@ -167,12 +221,14 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version,
}
bool Result = true;
int DockContainers = s.attributes().value("DockContainers").toInt();
qDebug() << DockContainers;
#ifdef ADS_DEBUG_PRINT
int DockContainers = s.attributes().value("Containers").toInt();
#endif
ADS_PRINT(DockContainers);
int DockContainerCount = 0;
while (s.readNextStartElement())
{
if (s.name() == "DockContainerWidget")
if (s.name() == "Container")
{
Result = restoreContainer(DockContainerCount, s, Testing);
if (!Result)
@@ -191,6 +247,7 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version,
for (int i = 0; i < DeleteCount; ++i)
{
FloatingWidgets[FloatingWidgetIndex + i]->deleteLater();
_this->removeDockContainer(FloatingWidgets[FloatingWidgetIndex + i]->dockContainer());
}
}
@@ -198,17 +255,163 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version,
}
//============================================================================
void DockManagerPrivate::restoreDockWidgetsOpenState()
{
// All dock widgets, that have not been processed in the restore state
// function are invisible to the user now and have no assigned dock area
// They do not belong to any dock container, until the user toggles the
// toggle view action the next time
for (auto DockWidget : DockWidgetsMap)
{
if (DockWidget->property(internal::DirtyProperty).toBool())
{
DockWidget->flagAsUnassigned();
emit DockWidget->viewToggled(false);
}
else
{
DockWidget->toggleViewInternal(!DockWidget->property(internal::ClosedProperty).toBool());
}
}
}
//============================================================================
void DockManagerPrivate::restoreDockAreasIndices()
{
// Now all dock areas are properly restored and we setup the index of
// The dock areas because the previous toggleView() action has changed
// the dock area index
int Count = 0;
for (auto DockContainer : Containers)
{
Count++;
for (int i = 0; i < DockContainer->dockAreaCount(); ++i)
{
CDockAreaWidget* DockArea = DockContainer->dockArea(i);
QString DockWidgetName = DockArea->property("currentDockWidget").toString();
CDockWidget* DockWidget = nullptr;
if (!DockWidgetName.isEmpty())
{
DockWidget = _this->findDockWidget(DockWidgetName);
}
if (!DockWidget || DockWidget->isClosed())
{
int Index = DockArea->indexOfFirstOpenDockWidget();
if (Index < 0)
{
continue;
}
DockArea->setCurrentIndex(Index);
}
else
{
DockArea->internalSetCurrentDockWidget(DockWidget);
}
}
}
}
//============================================================================
void DockManagerPrivate::emitTopLevelEvents()
{
// Finally we need to send the topLevelChanged() signals for all dock
// widgets if top level changed
for (auto DockContainer : Containers)
{
CDockWidget* TopLevelDockWidget = DockContainer->topLevelDockWidget();
if (TopLevelDockWidget)
{
TopLevelDockWidget->emitTopLevelChanged(true);
}
else
{
for (int i = 0; i < DockContainer->dockAreaCount(); ++i)
{
auto DockArea = DockContainer->dockArea(i);
for (auto DockWidget : DockArea->dockWidgets())
{
DockWidget->emitTopLevelChanged(false);
}
}
}
}
}
//============================================================================
bool DockManagerPrivate::restoreState(const QByteArray& State, int version)
{
QByteArray state = State.startsWith("<?xml") ? State : qUncompress(State);
if (!checkFormat(state, version))
{
ADS_PRINT("checkFormat: Error checking format!!!!!!!");
return false;
}
// Hide updates of floating widgets from use
hideFloatingWidgets();
markDockWidgetsDirty();
if (!restoreStateFromXml(state, version))
{
ADS_PRINT("restoreState: Error restoring state!!!!!!!");
return false;
}
restoreDockWidgetsOpenState();
restoreDockAreasIndices();
emitTopLevelEvents();
return true;
}
//============================================================================
void DockManagerPrivate::addActionToMenu(QAction* Action, QMenu* Menu, bool InsertSorted)
{
if (InsertSorted)
{
auto Actions = Menu->actions();
auto it = std::find_if(Actions.begin(), Actions.end(),
[&Action](const QAction* a)
{
return a->text().compare(Action->text(), Qt::CaseInsensitive) > 0;
});
if (it == Actions.end())
{
Menu->addAction(Action);
}
else
{
Menu->insertAction(*it, Action);
}
}
else
{
Menu->addAction(Action);
}
}
//============================================================================
CDockManager::CDockManager(QWidget *parent) :
CDockContainerWidget(this, parent),
d(new DockManagerPrivate(this))
{
createRootSplitter();
QMainWindow* MainWindow = dynamic_cast<QMainWindow*>(parent);
if (MainWindow)
{
MainWindow->setCentralWidget(this);
}
d->ViewMenu = new QMenu(tr("Show View"), this);
d->DockAreaOverlay = new CDockOverlay(this, CDockOverlay::ModeDockAreaOverlay);
d->ContainerOverlay = new CDockOverlay(this, CDockOverlay::ModeContainerOverlay);
d->Containers.append(this);
@@ -231,7 +434,7 @@ CDockManager::~CDockManager()
void CDockManager::registerFloatingWidget(CFloatingDockContainer* FloatingWidget)
{
d->FloatingWidgets.append(FloatingWidget);
qDebug() << "d->FloatingWidgets.count() " << d->FloatingWidgets.count();
ADS_PRINT("d->FloatingWidgets.count() " << d->FloatingWidgets.count());
}
@@ -299,11 +502,12 @@ QByteArray CDockManager::saveState(int version) const
{
QByteArray xmldata;
QXmlStreamWriter s(&xmldata);
s.setAutoFormatting(true);
auto ConfigFlags = CDockManager::configFlags();
s.setAutoFormatting(ConfigFlags.testFlag(XmlAutoFormattingEnabled));
s.writeStartDocument();
s.writeStartElement("QtAdvancedDockingSystem");
s.writeAttribute("Version", QString::number(version));
s.writeAttribute("DockContainers", QString::number(d->Containers.count()));
s.writeAttribute("Containers", QString::number(d->Containers.count()));
for (auto Container : d->Containers)
{
Container->saveState(s);
@@ -312,64 +516,45 @@ QByteArray CDockManager::saveState(int version) const
s.writeEndElement();
s.writeEndDocument();
return xmldata;
return ConfigFlags.testFlag(XmlCompressionEnabled)
? qCompress(xmldata, 9) : xmldata;
}
//============================================================================
bool CDockManager::restoreState(const QByteArray &state, int version)
{
if (!d->checkFormat(state, version))
{
qDebug() << "checkFormat: Error checking format!!!!!!!";
return false;
}
// Prevent multiple calls as long as state is not restore. This may
// happen, if QApplication::processEvents() is called somewhere
if (d->RestoringState)
{
return false;
}
for (auto DockWidget : d->DockWidgetsMap)
{
DockWidget->setProperty("dirty", true);
}
// We hide the complete dock manager here. Restoring the state means
// that DockWidgets are removed from the DockArea internal stack layout
// which in turn means, that each time a widget is removed the stack
// will show and raise the next available widget which in turn
// triggers show events for the dock widgets. To avoid this we hide the
// dock manager. Because there will be no processing of application
// events until this function is finished, the user will not see this
// hiding
bool IsHidden = this->isHidden();
if (!IsHidden)
{
hide();
}
d->RestoringState = true;
emit restoringState();
bool Result = d->restoreState(state, version);
d->RestoringState = false;
emit stateRestored();
if (!IsHidden)
{
show();
}
if (!d->restoreState(state, version))
{
qDebug() << "restoreState: Error restoring state!!!!!!!";
return false;
}
// All dock widgets, that have not been processed in the restore state
// function are invisible to the user now and have no assigned dock area
// They do not belong to any dock container, until the user toggles the
// toggle view action the next time
for (auto DockWidget : d->DockWidgetsMap)
{
if (DockWidget->property("dirty").toBool())
{
DockWidget->flagAsUnassigned();
}
else
{
DockWidget->toggleView(!DockWidget->property("closed").toBool());
}
}
// Now all dock areas are properly restored and we setup the index of
// The dock areas because the previous toggleView() action has changed
// the dock area index
for (auto DockContainer : d->Containers)
{
for (int i = 0; i < DockContainer->dockAreaCount(); ++i)
{
CDockAreaWidget* DockArea = DockContainer->dockArea(i);
int CurrentIndex = DockArea->property("currentIndex").toInt();
if (CurrentIndex < DockArea->count() && DockArea->count() > 1 && CurrentIndex > -1)
{
DockArea->setCurrentIndex(CurrentIndex);
}
}
}
emit stateChanged();
return true;
return Result;
}
@@ -383,11 +568,52 @@ CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area,
//============================================================================
CDockWidget* CDockManager::findDockWidget(const QString& ObjectName)
CDockAreaWidget* CDockManager::addDockWidgetTab(DockWidgetArea area,
CDockWidget* Dockwidget)
{
CDockAreaWidget* AreaWidget = lastAddedDockAreaWidget(area);
if (AreaWidget)
{
return addDockWidget(ads::CenterDockWidgetArea, Dockwidget, AreaWidget);
}
else if (!openedDockAreas().isEmpty())
{
return addDockWidget(area, Dockwidget, openedDockAreas().last());
}
else
{
return addDockWidget(area, Dockwidget, nullptr);
}
}
//============================================================================
CDockAreaWidget* CDockManager::addDockWidgetTabToArea(CDockWidget* Dockwidget,
CDockAreaWidget* DockAreaWidget)
{
return addDockWidget(ads::CenterDockWidgetArea, Dockwidget, DockAreaWidget);
}
//============================================================================
CDockWidget* CDockManager::findDockWidget(const QString& ObjectName) const
{
return d->DockWidgetsMap.value(ObjectName, nullptr);
}
//============================================================================
void CDockManager::removeDockWidget(CDockWidget* Dockwidget)
{
d->DockWidgetsMap.remove(Dockwidget->objectName());
CDockContainerWidget::removeDockWidget(Dockwidget);
}
//============================================================================
QMap<QString, CDockWidget*> CDockManager::dockWidgetsMap() const
{
return d->DockWidgetsMap;
}
//============================================================================
void CDockManager::addPerspective(const QString& UniquePrespectiveName)
@@ -397,6 +623,30 @@ void CDockManager::addPerspective(const QString& UniquePrespectiveName)
}
//============================================================================
void CDockManager::removePerspective(const QString& Name)
{
removePerspectives({Name});
}
//============================================================================
void CDockManager::removePerspectives(const QStringList& Names)
{
int Count = 0;
for (auto Name : Names)
{
Count += d->Perspectives.remove(Name);
}
if (Count)
{
emit perspectivesRemoved();
emit perspectiveListChanged();
}
}
//============================================================================
QStringList CDockManager::perspectiveNames() const
{
@@ -413,7 +663,9 @@ void CDockManager::openPerspective(const QString& PerspectiveName)
return;
}
emit openingPerspective(PerspectiveName);
restoreState(Iterator.value());
emit perspectiveOpened(PerspectiveName);
}
@@ -459,6 +711,83 @@ void CDockManager::loadPerspectives(QSettings& Settings)
Settings.endArray();
}
//============================================================================
QAction* CDockManager::addToggleViewActionToMenu(QAction* ToggleViewAction,
const QString& Group, const QIcon& GroupIcon)
{
bool AlphabeticallySorted = (MenuAlphabeticallySorted == d->MenuInsertionOrder);
if (!Group.isEmpty())
{
QMenu* GroupMenu = d->ViewMenuGroups.value(Group, 0);
if (!GroupMenu)
{
GroupMenu = new QMenu(Group, this);
GroupMenu->setIcon(GroupIcon);
d->addActionToMenu(GroupMenu->menuAction(), d->ViewMenu, AlphabeticallySorted);
d->ViewMenuGroups.insert(Group, GroupMenu);
}
d->addActionToMenu(ToggleViewAction, GroupMenu, AlphabeticallySorted);
return GroupMenu->menuAction();
}
else
{
d->addActionToMenu(ToggleViewAction, d->ViewMenu, AlphabeticallySorted);
return ToggleViewAction;
}
}
//============================================================================
QMenu* CDockManager::viewMenu() const
{
return d->ViewMenu;
}
//============================================================================
void CDockManager::setViewMenuInsertionOrder(eViewMenuInsertionOrder Order)
{
d->MenuInsertionOrder = Order;
}
//===========================================================================
bool CDockManager::isRestoringState() const
{
return d->RestoringState;
}
//===========================================================================
int CDockManager::startDragDistance()
{
return QApplication::startDragDistance() * 1.5;
}
//===========================================================================
CDockManager::ConfigFlags CDockManager::configFlags()
{
return StaticConfigFlags;
}
//===========================================================================
void CDockManager::setConfigFlags(const ConfigFlags Flags)
{
StaticConfigFlags = Flags;
}
//===========================================================================
void CDockManager::setConfigFlag(eConfigFlag Flag, bool On)
{
internal::setFlag(StaticConfigFlags, Flag, On);
}
} // namespace ads
//---------------------------------------------------------------------------

View File

@@ -31,10 +31,12 @@
// INCLUDES
//============================================================================
#include "DockContainerWidget.h"
#include <QIcon>
#include "ads_globals.h"
class QSettings;
class QMenu;
namespace ads
{
@@ -49,7 +51,16 @@ struct DockWidgetTabPrivate;
struct DockAreaWidgetPrivate;
/**
* The central dock manager that maintains the complete docking system
* The central dock manager that maintains the complete docking system.
* With the configuration flags you can globally control the functionality
* of the docking system. The dock manager uses an internal stylesheet to
* style its components like splitters, tabs and buttons. If you want to
* disable this stylesheet because your application uses its own,
* just call the function for settings the stylesheet with an empty
* string.
* \code
* DockManager->setStyleSheet("");
* \endcode
**/
class ADS_EXPORT CDockManager : public CDockContainerWidget
{
@@ -100,10 +111,37 @@ protected:
CDockOverlay* dockAreaOverlay() const;
public:
enum eViewMenuInsertionOrder
{
MenuSortedByInsertion,
MenuAlphabeticallySorted
};
/**
* These global configuration flags configure some global dock manager
* settings.
*/
enum eConfigFlag
{
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
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
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).
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
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
DefaultConfig = ActiveTabHasCloseButton | DockAreaHasCloseButton | OpaqueSplitterResize | XmlCompressionEnabled, ///< the default configuration
};
Q_DECLARE_FLAGS(ConfigFlags, eConfigFlag)
/**
* Default Constructor.
* If the given parent is a QMainWindow, the dock manager sets itself as the
* central widget
* central widget.
* Before you create any dock widgets, you should properly setup the
* configuration flags via setConfigFlags().
*/
CDockManager(QWidget* parent = 0);
@@ -112,6 +150,22 @@ public:
*/
virtual ~CDockManager();
/**
* This function returns the global configuration flags
*/
static ConfigFlags configFlags();
/**
* Sets the global configuration flags for the whole docking system.
* Call this function before you create your first dock widget.
*/
static void setConfigFlags(const ConfigFlags Flags);
/**
* Set a certain config flag
*/
static void setConfigFlag(eConfigFlag Flag, bool On = true);
/**
* Adds dockwidget into the given area.
* If DockAreaWidget is not null, then the area parameter indicates the area
@@ -128,12 +182,39 @@ public:
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
CDockAreaWidget* DockAreaWidget = nullptr);
/**
* This function will add the given Dockwidget to the given dock area as
* a new tab.
* If no dock area widget exists for the given area identifier, a new
* dock area widget is created.
*/
CDockAreaWidget* addDockWidgetTab(DockWidgetArea area,
CDockWidget* Dockwidget);
/**
* This function will add the given Dockwidget to the given DockAreaWidget
* as a new tab.
*/
CDockAreaWidget* addDockWidgetTabToArea(CDockWidget* Dockwidget,
CDockAreaWidget* DockAreaWidget);
/**
* Searches for a registered doc widget with the given ObjectName
* \return Return the found dock widget or nullptr if a dock widget with the
* given name is not registered
*/
CDockWidget* findDockWidget(const QString& ObjectName);
CDockWidget* findDockWidget(const QString& ObjectName) const;
/**
* Remove the given Dock from the dock manager
*/
void removeDockWidget(CDockWidget* Dockwidget);
/**
* This function returns a readable reference to the internal dock
* widgets map so that it is possible to iterate over all dock widgets
*/
QMap<QString, CDockWidget*> dockWidgetsMap() const;
/**
* Returns the list of all active and visible dock containers
@@ -154,7 +235,11 @@ public:
/**
* Saves the current state of the dockmanger and all its dock widgets
* into the returned QByteArray
* into the returned QByteArray.
* The XmlMode enables / disables the auto formatting for the XmlStreamWriter.
* If auto formatting is enabled, the output is intended and line wrapped.
* The XmlMode XmlAutoFormattingDisabled is better if you would like to have
* a more compact XML output - i.e. for storage in ini files.
*/
QByteArray saveState(int version = 0) const;
@@ -177,6 +262,16 @@ public:
*/
void addPerspective(const QString& UniquePrespectiveName);
/**
* Removes the perspective with the given name from the list of perspectives
*/
void removePerspective(const QString& Name);
/**
* Removes the given perspectives from the dock manager
*/
void removePerspectives(const QStringList& Names);
/**
* Returns the names of all available perspectives
*/
@@ -192,6 +287,56 @@ public:
*/
void loadPerspectives(QSettings& Settings);
/**
* Adds a toggle view action to the the internal view menu.
* You can either manage the insertion of the toggle view actions in your
* application or you can add the actions to the internal view menu and
* then simply insert the menu object into your.
* \param[in] ToggleViewAction The action to insert. If no group is provided
* the action is directly inserted into the menu. If a group
* is provided, the action is inserted into the group and the
* group is inserted into the menu if it is not existing yet.
* \param[in] Group This is the text used for the group menu item
* \param[in] GroupIcon The icon used for grouping the workbenches in the
* view menu. I.e. if there is a workbench for each device
* like for spectrometer devices, it is good to group all these
* workbenches under a menu item
* \return If Group is not empty, this function returns the GroupAction
* for this group. If the group is empty, the function returns
* the given ToggleViewAction.
*/
QAction* addToggleViewActionToMenu(QAction* ToggleViewAction,
const QString& Group = QString(), const QIcon& GroupIcon = QIcon());
/**
* This function returns the internal view menu.
* To fill the view menu, you can use the addToggleViewActionToMenu()
* function.
*/
QMenu* viewMenu() const;
/**
* Define the insertion order for toggle view menu items.
* The order defines how the actions are added to the view menu.
* The default insertion order is MenuAlphabeticallySorted to make it
* easier for users to find the menu entry for a certain dock widget.
* You need to call this function befor you insert the first menu item
* into the view menu.
*/
void setViewMenuInsertionOrder(eViewMenuInsertionOrder Order);
/**
* This function returns true between the restoringState() and
* stateRestored() signals.
*/
bool isRestoringState() const;
/**
* The distance the user needs to move the mouse with the left button
* hold down before a dock widget start floating
*/
static int startDragDistance();
public slots:
/**
* Opens the perspective with the given name.
@@ -204,12 +349,40 @@ signals:
*/
void perspectiveListChanged();
/**
* This signal is emitted if perspectives have been removed
*/
void perspectivesRemoved();
/**
* This signal is emitted, if the restore function is called, just before
* the dock manager starts restoring the state.
* If this function is called, nothing has changed yet
*/
void restoringState();
/**
* This signal is emitted if the state changed in restoreState.
* The signal is emitted if the restoreState() function is called or
* if the openPerspective() function is called
*/
void stateChanged();
void stateRestored();
/**
* This signal is emitted, if the dock manager starts opening a
* perspective.
* Opening a perspective may take more than a second if there are
* many complex widgets. The application may use this signal
* to show some progress indicator or to change the mouse cursor
* into a busy cursor.
*/
void openingPerspective(const QString& PerspectiveName);
/**
* This signal is emitted if the dock manager finished opening a
* perspective
*/
void perspectiveOpened(const QString& PerspectiveName);
}; // class DockManager
} // namespace ads
//-----------------------------------------------------------------------------

View File

@@ -34,6 +34,7 @@
#include <QtGlobal>
#include <QDebug>
#include <QMap>
#include <QWindow>
#include "DockAreaWidget.h"
@@ -75,6 +76,7 @@ struct DockOverlayCrossPrivate
QGridLayout* GridLayout;
QColor IconColors[5];
bool UpdateRequired = false;
double LastDevicePixelRatio = 0.1;
/**
* Private data constructor
@@ -130,6 +132,21 @@ struct DockOverlayCrossPrivate
return Color;
}
//============================================================================
/**
* Helper function that returns the drop indicator width depending on the
* operating system
*/
qreal dropIndicatiorWidth(QLabel* l) const
{
#ifdef Q_OS_LINUX
Q_UNUSED(l)
return 40;
#else
return static_cast<qreal>(l->fontMetrics().height()) * 3.f;
#endif
}
//============================================================================
QWidget* createDropIndicatorWidget(DockWidgetArea DockWidgetArea,
@@ -138,24 +155,41 @@ struct DockOverlayCrossPrivate
QLabel* l = new QLabel();
l->setObjectName("DockWidgetAreaLabel");
const qreal metric = static_cast<qreal>(l->fontMetrics().height()) * 3.f;
const qreal metric = dropIndicatiorWidth(l);
const QSizeF size(metric, metric);
l->setPixmap(createDropIndicatorPixmap(size, DockWidgetArea, Mode));
l->setPixmap(createHighDpiDropIndicatorPixmap(size, DockWidgetArea, Mode));
l->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
l->setAttribute(Qt::WA_TranslucentBackground);
l->setProperty("dockWidgetArea", DockWidgetArea);
return l;
}
//============================================================================
void updateDropIndicatorIcon(QWidget* DropIndicatorWidget)
{
QLabel* l = qobject_cast<QLabel*>(DropIndicatorWidget);
const qreal metric = dropIndicatiorWidth(l);
const QSizeF size(metric, metric);
int Area = l->property("dockWidgetArea").toInt();
l->setPixmap(createHighDpiDropIndicatorPixmap(size, (DockWidgetArea)Area, Mode));
}
//============================================================================
QPixmap createDropIndicatorPixmap(const QSizeF& size, DockWidgetArea DockWidgetArea,
QPixmap createHighDpiDropIndicatorPixmap(const QSizeF& size, DockWidgetArea DockWidgetArea,
CDockOverlay::eMode Mode)
{
QColor borderColor = iconColor(CDockOverlayCross::FrameColor);
QColor backgroundColor = iconColor(CDockOverlayCross::WindowBackgroundColor);
QPixmap pm(size.width(), size.height());
#if QT_VERSION >= 0x050600
double DevicePixelRatio = _this->window()->devicePixelRatioF();
#else
double DevicePixelRatio = _this->window()->devicePixelRatio();
#endif
QSizeF PixmapSize = size * DevicePixelRatio;
QPixmap pm(PixmapSize.toSize());
pm.fill(QColor(0, 0, 0, 0));
QPainter p(&pm);
@@ -225,6 +259,7 @@ struct DockOverlayCrossPrivate
p.drawRect(areaRect);
pen = p.pen();
pen.setWidth(1);
pen.setColor(borderColor);
pen.setStyle(Qt::DashLine);
p.setPen(pen);
@@ -284,6 +319,7 @@ struct DockOverlayCrossPrivate
p.drawPolygon(Arrow);
}
pm.setDevicePixelRatio(DevicePixelRatio);
return pm;
}
@@ -347,7 +383,7 @@ DockWidgetArea CDockOverlay::dropAreaUnderCursor() const
return Result;
}
if (DockArea->titleAreaGeometry().contains(DockArea->mapFromGlobal(QCursor::pos())))
if (DockArea->titleBarGeometry().contains(DockArea->mapFromGlobal(QCursor::pos())))
{
return CenterDockWidgetArea;
}
@@ -381,6 +417,7 @@ DockWidgetArea CDockOverlay::showOverlay(QWidget* target)
move(TopLeft);
show();
d->Cross->updatePosition();
d->Cross->updateOverlayIcons();
return dropAreaUnderCursor();
}
@@ -430,9 +467,16 @@ void CDockOverlay::paintEvent(QPaintEvent* event)
}
QPainter painter(this);
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.setPen(Qt::NoPen);
painter.fillRect(r, Color);
painter.setBrush(Color);
painter.drawRect(r.adjusted(0, 0, -1, -1));
d->DropAreaRect = r;
}
@@ -552,12 +596,36 @@ void CDockOverlayCross::setupOverlayCross(CDockOverlay::eMode Mode)
areaWidgets.insert(BottomDockWidgetArea, d->createDropIndicatorWidget(BottomDockWidgetArea, Mode));
areaWidgets.insert(LeftDockWidgetArea, d->createDropIndicatorWidget(LeftDockWidgetArea, Mode));
areaWidgets.insert(CenterDockWidgetArea, d->createDropIndicatorWidget(CenterDockWidgetArea, Mode));
#if QT_VERSION >= 0x050600
d->LastDevicePixelRatio = devicePixelRatioF();
#else
d->LastDevicePixelRatio = devicePixelRatio();
#endif
setAreaWidgets(areaWidgets);
d->UpdateRequired = false;
}
//============================================================================
void CDockOverlayCross::updateOverlayIcons()
{
if (windowHandle()->devicePixelRatio() == d->LastDevicePixelRatio)
{
return;
}
for (auto Widget : d->DropIndicatorWidgets)
{
d->updateDropIndicatorIcon(Widget);
}
#if QT_VESION >= 0x050600
d->LastDevicePixelRatio = devicePixelRatioF();
#else
d->LastDevicePixelRatio = devicePixelRatio();
#endif
}
//============================================================================
void CDockOverlayCross::setIconColor(eIconColor ColorIndex, const QColor& Color)
{

View File

@@ -214,6 +214,11 @@ public:
*/
void setupOverlayCross(CDockOverlay::eMode Mode);
/**
* Recreates the overlay icons.
*/
void updateOverlayIcons();
/**
* Resets and updates the
*/
@@ -240,9 +245,6 @@ public:
protected:
virtual void showEvent(QShowEvent* e) override;
void setAreaWidgets(const QHash<DockWidgetArea, QWidget*>& widgets);
private:
}; // CDockOverlayCross
} // namespace ads

View File

@@ -52,7 +52,8 @@ CDockSplitter::CDockSplitter(QWidget *parent)
: QSplitter(parent),
d(new DockSplitterPrivate(this))
{
setProperty("ads-splitter", true);
setChildrenCollapsible(false);
}
@@ -67,7 +68,7 @@ CDockSplitter::CDockSplitter(Qt::Orientation orientation, QWidget *parent)
//============================================================================
CDockSplitter::~CDockSplitter()
{
qDebug() << "~CDockSplitter";
ADS_PRINT("~CDockSplitter");
delete d;
}
@@ -78,7 +79,7 @@ bool CDockSplitter::hasVisibleContent() const
// TODO Cache or precalculate this to speed up
for (int i = 0; i < count(); ++i)
{
if (widget(i)->isVisibleTo(this))
if (!widget(i)->isHidden())
{
return true;
}

View File

@@ -38,7 +38,8 @@ namespace ads
struct DockSplitterPrivate;
/**
* Splitter used internally instead of QSplitter
* Splitter used internally instead of QSplitter with some additional
* fuctionality.
*/
class ADS_EXPORT CDockSplitter : public QSplitter
{

View File

@@ -1,32 +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/>.
******************************************************************************/
//============================================================================
/// \file DockStateSerialization.cpp
/// \author Uwe Kindler
/// \date 26.02.2017
/// \brief Serialization related data, constants and stuff
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include "DockStateSerialization.h"

View File

@@ -1,55 +0,0 @@
#ifndef DockStateSerializationH
#define DockStateSerializationH
/*******************************************************************************
** 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/>.
******************************************************************************/
//============================================================================
/// \file DockStateSerialization.h
/// \author Uwe Kindler
/// \date 26.02.2017
/// \brief Declaration of serialization related data, constants and stuff
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
namespace ads
{
namespace internal
{
// sentinel values used to validate state data
enum VersionMarkers
{
VersionMarker = 0xff,
ContainerMarker = 0xfe,
SplitterMarker = 0xfd,
DockAreaMarker = 0xfc,
DockWidgetMarker = 0xfb
};
static const bool RestoreTesting = true;
static const bool Restore = false;
} // internal
} // namespace ads
//-----------------------------------------------------------------------------
#endif // DockManagerH

View File

@@ -28,27 +28,29 @@
//============================================================================
// INCLUDES
//============================================================================
#include <DockWidgetTab.h>
#include "DockWidgetTab.h"
#include "DockWidget.h"
#include <QBoxLayout>
#include <QAction>
#include <QSplitter>
#include <QStack>
#include <QScrollArea>
#include <QTextStream>
#include <QPointer>
#include <QEvent>
#include <QDebug>
#include <QToolBar>
#include <QXmlStreamWriter>
#include "DockContainerWidget.h"
#include "DockAreaWidget.h"
#include "DockManager.h"
#include "FloatingDockContainer.h"
#include "DockStateSerialization.h"
#include "DockSplitter.h"
#include "ads_globals.h"
namespace ads
{
/**
@@ -56,15 +58,22 @@ namespace ads
*/
struct DockWidgetPrivate
{
CDockWidget* _this;
QBoxLayout* Layout;
CDockWidget* _this = nullptr;
QBoxLayout* Layout = nullptr;
QWidget* Widget = nullptr;
CDockWidgetTab* TitleWidget;
CDockWidgetTab* TabWidget = nullptr;
CDockWidget::DockWidgetFeatures Features = CDockWidget::AllDockWidgetFeatures;
CDockManager* DockManager = nullptr;
CDockAreaWidget* DockArea = nullptr;
QAction* ToggleViewAction;
QAction* ToggleViewAction = nullptr;
bool Closed = false;
QScrollArea* ScrollArea = nullptr;
QToolBar* ToolBar = nullptr;
Qt::ToolButtonStyle ToolBarStyleDocked = Qt::ToolButtonIconOnly;
Qt::ToolButtonStyle ToolBarStyleFloating = Qt::ToolButtonTextUnderIcon;
QSize ToolBarIconSizeDocked = QSize(16, 16);
QSize ToolBarIconSizeFloating = QSize(24, 24);
bool IsFloatingTopLevel = false;
/**
* Private data constructor
@@ -82,20 +91,21 @@ struct DockWidgetPrivate
void hideDockWidget();
/**
* Hides a parent splitter if all dock widgets in the splitter are closed
* Hides a dock area if all dock widgets in the area are closed.
* This function updates the current selected tab and hides the parent
* dock area if it is empty
*/
void hideEmptyParentSplitters();
void updateParentDockArea();
/**
* Hides a dock area if all dock widgets in the area are closed
* Setup the top tool bar
*/
void hideEmptyParentDockArea();
void setupToolBar();
/**
* Hides a floating widget if all dock areas are empty - that means,
* if all dock widgets in all dock areas are closed
* Setup the main scroll area
*/
void hideEmptyFloatingWidget();
void setupScrollArea();
};
// struct DockWidgetPrivate
@@ -118,9 +128,10 @@ void DockWidgetPrivate::showDockWidget()
}
else
{
DockArea->show();
DockArea->setCurrentIndex(DockArea->tabIndex(_this));
QSplitter* Splitter = internal::findParent<QSplitter*>(_this);
DockArea->toggleView(true);
DockArea->setCurrentDockWidget(_this);
TabWidget->show();
QSplitter* Splitter = internal::findParent<QSplitter*>(DockArea);
while (Splitter && !Splitter->isVisible())
{
Splitter->show();
@@ -141,63 +152,52 @@ void DockWidgetPrivate::showDockWidget()
//============================================================================
void DockWidgetPrivate::hideDockWidget()
{
TitleWidget->hide();
hideEmptyParentDockArea();
hideEmptyParentSplitters();
hideEmptyFloatingWidget();
TabWidget->hide();
updateParentDockArea();
}
//============================================================================
void DockWidgetPrivate::hideEmptyParentSplitters()
void DockWidgetPrivate::updateParentDockArea()
{
auto Splitter = internal::findParent<CDockSplitter*>(_this);
while (Splitter && Splitter->isVisible())
if (!DockArea)
{
if (!Splitter->hasVisibleContent())
{
Splitter->hide();
}
Splitter = internal::findParent<CDockSplitter*>(Splitter);
return;
}
}
//============================================================================
void DockWidgetPrivate::hideEmptyParentDockArea()
{
auto OpenDockWidgets = DockArea->openedDockWidgets();
if (OpenDockWidgets.count() > 1)
auto NextDockWidget = DockArea->nextOpenDockWidget(_this);
if (NextDockWidget)
{
CDockWidget* NextDockWidget;
if (OpenDockWidgets.last() == _this)
{
NextDockWidget = OpenDockWidgets[OpenDockWidgets.count() - 2];
}
else
{
int NextIndex = OpenDockWidgets.indexOf(_this) + 1;
NextDockWidget = OpenDockWidgets[NextIndex];
}
DockArea->setCurrentDockWidget(NextDockWidget);
}
else
{
DockArea->hide();
DockArea->hideAreaWithNoVisibleContent();
}
}
//============================================================================
void DockWidgetPrivate::hideEmptyFloatingWidget()
void DockWidgetPrivate::setupToolBar()
{
CDockContainerWidget* Container = _this->dockContainer();
if (Container->isFloating() && Container->openedDockAreas().isEmpty())
{
CFloatingDockContainer* FloatingWidget = internal::findParent<CFloatingDockContainer*>(Container);
FloatingWidget->hide();
}
ToolBar = new QToolBar(_this);
ToolBar->setObjectName("dockWidgetToolBar");
Layout->insertWidget(0, ToolBar);
ToolBar->setIconSize(QSize(16, 16));
ToolBar->toggleViewAction()->setEnabled(false);
ToolBar->toggleViewAction()->setVisible(false);
_this->connect(_this, SIGNAL(topLevelChanged(bool)), SLOT(setToolbarFloatingStyle(bool)));
}
//============================================================================
void DockWidgetPrivate::setupScrollArea()
{
ScrollArea = new QScrollArea(_this);
ScrollArea->setObjectName("dockWidgetScrollArea");
ScrollArea->setWidgetResizable(true);
Layout->addWidget(ScrollArea);
}
@@ -213,17 +213,18 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
setWindowTitle(title);
setObjectName(title);
d->TitleWidget = new CDockWidgetTab(this);
d->ToggleViewAction = new QAction(title);
d->TabWidget = new CDockWidgetTab(this);
d->ToggleViewAction = new QAction(title, this);
d->ToggleViewAction->setCheckable(true);
connect(d->ToggleViewAction, SIGNAL(triggered(bool)), this,
SLOT(toggleView(bool)));
setToolbarFloatingStyle(false);
}
//============================================================================
CDockWidget::~CDockWidget()
{
qDebug() << "~CDockWidget()";
ADS_PRINT("~CDockWidget()");
delete d;
}
@@ -239,18 +240,35 @@ void CDockWidget::setToggleViewActionChecked(bool Checked)
//============================================================================
void CDockWidget::setWidget(QWidget* widget)
void CDockWidget::setWidget(QWidget* widget, eInsertMode InsertMode)
{
if (d->Widget)
QScrollArea* ScrollAreaWidget = qobject_cast<QScrollArea*>(widget);
if (ScrollAreaWidget || ForceNoScrollArea == InsertMode)
{
d->Layout->replaceWidget(d->Widget, widget);
d->Layout->addWidget(widget);
if (ScrollAreaWidget && ScrollAreaWidget->viewport())
{
ScrollAreaWidget->viewport()->setProperty("dockWidgetContent", true);
}
}
else
{
d->Layout->addWidget(widget);
d->setupScrollArea();
d->ScrollArea->setWidget(widget);
}
d->Widget = widget;
d->Widget->setProperty("dockWidgetContent", true);
}
//============================================================================
QWidget* CDockWidget::takeWidget()
{
d->ScrollArea->takeWidget();
d->Layout->removeWidget(d->Widget);
d->Widget->setParent(nullptr);
return d->Widget;
}
@@ -262,23 +280,30 @@ QWidget* CDockWidget::widget() const
//============================================================================
CDockWidgetTab* CDockWidget::titleBar() const
CDockWidgetTab* CDockWidget::tabWidget() const
{
return d->TitleWidget;
return d->TabWidget;
}
//============================================================================
void CDockWidget::setFeatures(DockWidgetFeatures features)
{
if (d->Features == features)
{
return;
}
d->Features = features;
d->TabWidget->onDockWidgetFeaturesChanged();
}
//============================================================================
void CDockWidget::setFeature(DockWidgetFeature flag, bool on)
{
d->Features.setFlag(flag, on);
auto Features = features();
internal::setFlag(Features, flag, on);
setFeatures(Features);
}
@@ -306,21 +331,51 @@ void CDockWidget::setDockManager(CDockManager* DockManager)
//============================================================================
CDockContainerWidget* CDockWidget::dockContainer() const
{
return internal::findParent<CDockContainerWidget*>(this);
if (d->DockArea)
{
return d->DockArea->dockContainer();
}
else
{
return 0;
}
}
//============================================================================
CDockAreaWidget* CDockWidget::dockAreaWidget() const
{
return internal::findParent<CDockAreaWidget*>(this);
return d->DockArea;
}
//============================================================================
bool CDockWidget::isFloating() const
{
return dockContainer() ? dockContainer()->isFloating() : false;
if (!isInFloatingContainer())
{
return false;
}
return dockContainer()->topLevelDockWidget() == this;
}
//============================================================================
bool CDockWidget::isInFloatingContainer() const
{
auto Container = dockContainer();
if (!Container)
{
return false;
}
if (!Container->isFloating())
{
return false;
}
return true;
}
@@ -349,7 +404,7 @@ void CDockWidget::setToggleViewActionMode(eToggleViewActionMode Mode)
else
{
d->ToggleViewAction->setCheckable(false);
d->ToggleViewAction->setIcon(d->TitleWidget->icon());
d->ToggleViewAction->setIcon(d->TabWidget->icon());
}
}
@@ -357,11 +412,33 @@ void CDockWidget::setToggleViewActionMode(eToggleViewActionMode Mode)
//============================================================================
void CDockWidget::toggleView(bool Open)
{
// If the toggle view action mode is ActionModeShow, then Open is always
// true if the sender is the toggle view action
QAction* Sender = qobject_cast<QAction*>(sender());
if (Sender == d->ToggleViewAction && !d->ToggleViewAction->isCheckable())
{
Open = true;
}
// If the dock widget state is different, then we really need to toggle
// the state. If we are in the right state, then we simply make this
// dock widget the current dock widget
if (d->Closed != !Open)
{
toggleViewInternal(Open);
}
else if (Open && d->DockArea)
{
d->DockArea->setCurrentDockWidget(this);
}
}
//============================================================================
void CDockWidget::toggleViewInternal(bool Open)
{
CDockContainerWidget* DockContainer = dockContainer();
CDockWidget* TopLevelDockWidgetBefore = DockContainer
? DockContainer->topLevelDockWidget() : nullptr;
if (Open)
{
@@ -375,6 +452,29 @@ void CDockWidget::toggleView(bool Open)
d->ToggleViewAction->blockSignals(true);
d->ToggleViewAction->setChecked(Open);
d->ToggleViewAction->blockSignals(false);
if (d->DockArea)
{
d->DockArea->toggleDockWidgetView(this, Open);
}
if (Open && TopLevelDockWidgetBefore)
{
CDockWidget::emitTopLevelEventForWidget(TopLevelDockWidgetBefore, false);
}
// Here we need to call the dockContainer() function again, because if
// this dock widget was unassigned before the call to showDockWidget() then
// it has a dock container now
DockContainer = dockContainer();
CDockWidget* TopLevelDockWidgetAfter = DockContainer
? DockContainer->topLevelDockWidget() : nullptr;
CDockWidget::emitTopLevelEventForWidget(TopLevelDockWidgetAfter, true);
CFloatingDockContainer* FloatingContainer = DockContainer->floatingWidget();
if (FloatingContainer)
{
FloatingContainer->updateWindowTitle();
}
if (!Open)
{
emit closed();
@@ -387,15 +487,15 @@ void CDockWidget::toggleView(bool Open)
void CDockWidget::setDockArea(CDockAreaWidget* DockArea)
{
d->DockArea = DockArea;
d->ToggleViewAction->setChecked(DockArea != nullptr);
d->ToggleViewAction->setChecked(DockArea != nullptr && !this->isClosed());
}
//============================================================================
void CDockWidget::saveState(QXmlStreamWriter& s) const
{
s.writeStartElement("DockWidget");
s.writeAttribute("ObjectName", objectName());
s.writeStartElement("Widget");
s.writeAttribute("Name", objectName());
s.writeAttribute("Closed", QString::number(d->Closed ? 1 : 0));
s.writeEndElement();
}
@@ -404,9 +504,11 @@ void CDockWidget::saveState(QXmlStreamWriter& s) const
//============================================================================
void CDockWidget::flagAsUnassigned()
{
d->Closed = true;
setParent(d->DockManager);
setVisible(false);
setDockArea(nullptr);
titleBar()->setParent(this);
tabWidget()->setParent(this);
}
@@ -415,16 +517,49 @@ bool CDockWidget::event(QEvent *e)
{
if (e->type() == QEvent::WindowTitleChange)
{
emit titleChanged(windowTitle());
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);
}
return QFrame::event(e);
return Super::event(e);
}
#ifndef QT_NO_TOOLTIP
//============================================================================
void CDockWidget::setTabToolTip(const QString &text)
{
if (d->TabWidget)
{
d->TabWidget->setToolTip(text);
}
if (d->ToggleViewAction)
{
d->ToggleViewAction->setToolTip(text);
}
if (d->DockArea)
{
d->DockArea->markTitleBarMenuOutdated();//update tabs menu
}
}
#endif
//============================================================================
void CDockWidget::setIcon(const QIcon& Icon)
{
d->TitleWidget->setIcon(Icon);
d->TabWidget->setIcon(Icon);
if (!d->ToggleViewAction->isCheckable())
{
d->ToggleViewAction->setIcon(Icon);
@@ -435,10 +570,161 @@ void CDockWidget::setIcon(const QIcon& Icon)
//============================================================================
QIcon CDockWidget::icon() const
{
return d->TitleWidget->icon();
return d->TabWidget->icon();
}
//============================================================================
QToolBar* CDockWidget::toolBar() const
{
return d->ToolBar;
}
//============================================================================
QToolBar* CDockWidget::createDefaultToolBar()
{
if (!d->ToolBar)
{
d->setupToolBar();
}
return d->ToolBar;
}
//============================================================================
void CDockWidget::setToolBar(QToolBar* ToolBar)
{
if (d->ToolBar)
{
delete d->ToolBar;
}
d->ToolBar = ToolBar;
d->Layout->insertWidget(0, d->ToolBar);
this->connect(this, SIGNAL(topLevelChanged(bool)), SLOT(setToolbarFloatingStyle(bool)));
setToolbarFloatingStyle(isFloating());
}
//============================================================================
void CDockWidget::setToolBarStyle(Qt::ToolButtonStyle Style, eState State)
{
if (StateFloating == State)
{
d->ToolBarStyleFloating = Style;
}
else
{
d->ToolBarStyleDocked = Style;
}
setToolbarFloatingStyle(isFloating());
}
//============================================================================
Qt::ToolButtonStyle CDockWidget::toolBarStyle(eState State) const
{
if (StateFloating == State)
{
return d->ToolBarStyleFloating;
}
else
{
return d->ToolBarStyleDocked;
}
}
//============================================================================
void CDockWidget::setToolBarIconSize(const QSize& IconSize, eState State)
{
if (StateFloating == State)
{
d->ToolBarIconSizeFloating = IconSize;
}
else
{
d->ToolBarIconSizeDocked = IconSize;
}
setToolbarFloatingStyle(isFloating());
}
//============================================================================
QSize CDockWidget::toolBarIconSize(eState State) const
{
if (StateFloating == State)
{
return d->ToolBarIconSizeFloating;
}
else
{
return d->ToolBarIconSizeDocked;
}
}
//============================================================================
void CDockWidget::setToolbarFloatingStyle(bool Floating)
{
if (!d->ToolBar)
{
return;
}
auto IconSize = Floating ? d->ToolBarIconSizeFloating : d->ToolBarIconSizeDocked;
if (IconSize != d->ToolBar->iconSize())
{
d->ToolBar->setIconSize(IconSize);
}
auto ButtonStyle = Floating ? d->ToolBarStyleFloating : d->ToolBarStyleDocked;
if (ButtonStyle != d->ToolBar->toolButtonStyle())
{
d->ToolBar->setToolButtonStyle(ButtonStyle);
}
}
//============================================================================
void CDockWidget::emitTopLevelEventForWidget(CDockWidget* TopLevelDockWidget, bool Floating)
{
if (TopLevelDockWidget)
{
TopLevelDockWidget->dockAreaWidget()->updateTitleBarVisibility();
TopLevelDockWidget->emitTopLevelChanged(Floating);
}
}
//============================================================================
void CDockWidget::emitTopLevelChanged(bool Floating)
{
if (Floating != d->IsFloatingTopLevel)
{
d->IsFloatingTopLevel = Floating;
emit topLevelChanged(d->IsFloatingTopLevel);
}
}
//============================================================================
void CDockWidget::setClosedState(bool Closed)
{
d->Closed = Closed;
}
//============================================================================
QSize CDockWidget::minimumSizeHint() const
{
return QSize(60, 40);
}
} // namespace ads

View File

@@ -34,6 +34,7 @@
#include "ads_globals.h"
class QToolBar;
class QXmlStreamWriter;
namespace ads
@@ -43,7 +44,8 @@ class CDockWidgetTab;
class CDockManager;
class CDockContainerWidget;
class CDockAreaWidget;
struct DockContainerWidgetPrivate;
class DockContainerWidgetPrivate;
class CFloatingDockContainer;
/**
* The QDockWidget class provides a widget that can be docked inside a
@@ -56,12 +58,22 @@ private:
DockWidgetPrivate* d; ///< private data (pimpl)
friend struct DockWidgetPrivate;
private slots:
/**
* Adjusts the toolbar icon sizes according to the floating state
*/
void setToolbarFloatingStyle(bool topLevel);
protected:
friend class CDockContainerWidget;
friend class CDockAreaWidget;
friend class CFloatingDockContainer;
friend class CDockManager;
friend struct DockContainerWidgetPrivate;
friend struct DockManagerPrivate;
friend class DockContainerWidgetPrivate;
friend class CDockAreaTabBar;
friend class CDockWidgetTab;
friend struct DockWidgetTabPrivate;
/**
* Assigns the dock manager that manages this dock widget
@@ -98,18 +110,44 @@ protected:
*/
void flagAsUnassigned();
/**
* Call this function to emit a topLevelChanged() signal and to update
* the dock area tool bar visibility
*/
static void emitTopLevelEventForWidget(CDockWidget* TopLevelDockWidget, bool Floating);
/**
* Use this function to emit a top level changed event.
* Do never use emit topLevelChanged(). Always use this function because
* it only emits a signal if the floating state has really changed
*/
void emitTopLevelChanged(bool Floating);
/**
* Internal function for modifying the closed state when restoring
* a saved docking state
*/
void setClosedState(bool Closed);
/**
* Internal toggle view function that does not check if the widget
* already is in the given state
*/
void toggleViewInternal(bool Open);
public:
using Super = QFrame;
enum DockWidgetFeature
{
DockWidgetClosable = 0x01,
DockWidgetMovable = 0x02,
DockWidgetMovable = 0x02,///< this feature is not properly implemented yet and is ignored
DockWidgetFloatable = 0x04,
AllDockWidgetFeatures = DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable,
NoDockWidgetFeatures = 0x00
};
Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)
enum eState
{
StateHidden,
@@ -117,6 +155,30 @@ public:
StateFloating
};
/**
* Sets the widget for the dock widget to 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
* 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+
* widget into a scroll area or to provide a widget that is already a scroll
* area or that contains a scroll area.
* If the InsertMode is AutoScrollArea, the DockWidget tries to automatically
* detect how to insert the given widget. If the widget is derived from
* QScrollArea (i.e. an QAbstractItemView), then the widget is inserted
* directly. If the given widget is not a scroll area, the widget will be
* inserted into a scroll area.
* To force insertion into a scroll area, you can also provide the InsertMode
* ForceScrollArea. To prevent insertion into a scroll area, you can
* provide the InsertMode ForceNoScrollArea
*/
enum eInsertMode
{
AutoScrollArea,
ForceScrollArea,
ForceNoScrollArea
};
/**
* This mode configures the behavior of the toggle view action.
* If the mode if ActionModeToggle, then the toggle view action is
@@ -131,6 +193,7 @@ public:
ActionModeShow //!< ActionModeShow
};
/**
* 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
@@ -142,6 +205,7 @@ public:
* 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
* by calling setObjectName() after construction.
* Use the layoutFlags to configure the layout of the dock widget.
*/
CDockWidget(const QString &title, QWidget* parent = 0);
@@ -151,9 +215,33 @@ public:
virtual ~CDockWidget();
/**
* Sets the widget for the dock widget to widget.
* We return a fixed minimum size hint for all dock widgets
*/
void setWidget(QWidget* widget);
virtual QSize minimumSizeHint() const override;
/**
* Sets the widget for the dock widget to 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
* 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+
* widget into a scroll area or to provide a widget that is already a scroll
* area or that contains a scroll area.
* If the InsertMode is AutoScrollArea, the DockWidget tries to automatically
* detect how to insert the given widget. If the widget is derived from
* QScrollArea (i.e. an QAbstractItemView), then the widget is inserted
* directly. If the given widget is not a scroll area, the widget will be
* inserted into a scroll area.
* To force insertion into a scroll area, you can also provide the InsertMode
* ForceScrollArea. To prevent insertion into a scroll area, you can
* provide the InsertMode ForceNoScrollArea
*/
void setWidget(QWidget* widget, eInsertMode InsertMode = AutoScrollArea);
/**
* Remove the widget from the dock and give ownership back to the caller
*/
QWidget* takeWidget();
/**
* Returns the widget for the dock widget. This function returns zero if
@@ -164,7 +252,7 @@ public:
/**
* Returns the title bar widget of this dock widget
*/
CDockWidgetTab* titleBar() const;
CDockWidgetTab* tabWidget() const;
/**
* Sets, whether the dock widget is movable, closable, and floatable.
@@ -193,7 +281,7 @@ public:
/**
* Returns the dock container widget this dock area widget belongs to or 0
* if this dock widget has nt been docked yet
* if this dock widget has not been docked yet
*/
CDockContainerWidget* dockContainer() const;
@@ -205,9 +293,19 @@ public:
/**
* This property holds whether the dock widget is floating.
* 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
* floating container, the all dock widgets are docked and not floating.
*/
bool isFloating() const;
/**
* 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
* returns true if it is docked inside of a floating container.
*/
bool isInFloatingContainer() const;
/**
* Returns true, if this dock widget is closed.
*/
@@ -232,10 +330,75 @@ public:
void setIcon(const QIcon& Icon);
/**
* Returns tzhe icon that has been assigned to the dock widget
* Returns the icon that has been assigned to the dock widget
*/
QIcon icon() const;
/**
* If the WithToolBar layout flag is enabled, then this function returns
* the dock widget toolbar. If the flag is disabled, the function returns
* a nullptr.
* This function returns the dock widget top tool bar.
* If no toolbar is assigned, this function returns nullptr. To get a vaild
* toolbar you either need to create a default empty toolbar via
* createDefaultToolBar() function or you need to assign you custom
* toolbar via setToolBar().
*/
QToolBar* toolBar() const;
/**
* If you would like to use the default top tool bar, then call this
* function to create the default tool bar.
* After this function the toolBar() function will return a valid toolBar()
* object.
*/
QToolBar* createDefaultToolBar();
/**
* 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
* on destruction
*/
void setToolBar(QToolBar* ToolBar);
/**
* 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.
* If a dock widget is floating, then here are more space and it is
* possible to select a style that requires more space like
* Qt::ToolButtonTextUnderIcon. For the docked state Qt::ToolButtonIconOnly
* might be better.
*/
void setToolBarStyle(Qt::ToolButtonStyle Style, eState State);
/**
* Returns the tool button style for the given docking state.
* \see setToolBarStyle()
*/
Qt::ToolButtonStyle toolBarStyle(eState State) const;
/**
* 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
* icon size is possible. For docked widgets, small icon sizes, eg. 16 x 16
* might be better.
*/
void setToolBarIconSize(const QSize& IconSize, eState State);
/**
* Returns the icon size for a given docking state.
* \see setToolBarIconSize()
*/
QSize toolBarIconSize(eState State) const;
#ifndef QT_NO_TOOLTIP
/**
* This is function sets text tooltip for title bar widget
* and tooltip for toggle view action
*/
void setTabToolTip(const QString &text);
#endif
public: // reimplements QFrame -----------------------------------------------
/**
@@ -266,6 +429,13 @@ signals:
* changed
*/
void titleChanged(const QString& Title);
/**
* This signal is emitted when the floating property changes.
* The topLevel parameter is true if the dock widget is now floating;
* otherwise it is false.
*/
void topLevelChanged(bool topLevel);
}; // class DockWidget
}
// namespace ads

View File

@@ -28,6 +28,7 @@
//============================================================================
// INCLUDES
//============================================================================
#include "ElidingLabel.h"
#include "DockWidgetTab.h"
#include <QBoxLayout>
@@ -37,6 +38,9 @@
#include <QApplication>
#include <QSplitter>
#include <QDebug>
#include <QToolButton>
#include <QPushButton>
#include <QMenu>
#include "ads_globals.h"
#include "DockWidget.h"
@@ -45,19 +49,12 @@
#include "DockOverlay.h"
#include "DockManager.h"
#include <iostream>
namespace ads
{
/**
* The different dragging states
*/
enum eDragState
{
DraggingInactive, //!< DraggingInactive
DraggingMousePressed, //!< DraggingMousePressed
DraggingTab, //!< DraggingTab
DraggingFloatingWidget//!< DraggingFloatingWidget
};
using tTabLabel = CElidingLabel;
/**
* Private data class of CDockWidgetTab class (pimpl)
@@ -66,14 +63,16 @@ struct DockWidgetTabPrivate
{
CDockWidgetTab* _this;
CDockWidget* DockWidget;
QLabel* IconLabel;
QLabel* TitleLabel;
QLabel* IconLabel = nullptr;
tTabLabel* TitleLabel;
QPoint DragStartMousePosition;
bool IsActiveTab = false;
CDockAreaWidget* DockArea = nullptr;
eDragState DragState = DraggingInactive;
CFloatingDockContainer* FloatingWidget = nullptr;
QIcon Icon;
QAbstractButton* CloseButton = nullptr;
QSpacerItem* IconTextSpacer;
/**
* Private data constructor
@@ -105,7 +104,7 @@ struct DockWidgetTabPrivate
*/
bool titleAreaGeometryContains(const QPoint& GlobalPos) const
{
return DockArea->titleAreaGeometry().contains(DockArea->mapFromGlobal(GlobalPos));
return DockArea->titleBarGeometry().contains(DockArea->mapFromGlobal(GlobalPos));
}
/**
@@ -113,7 +112,32 @@ struct DockWidgetTabPrivate
* Returns true, if floating has been started and false if floating
* is not possible for any reason
*/
bool startFloating();
bool startFloating(eDragState DraggingState = DraggingFloatingWidget);
/**
* Returns true if the given config flag is set
*/
bool testConfigFlag(CDockManager::eConfigFlag Flag) const
{
return CDockManager::configFlags().testFlag(Flag);
}
/**
* Creates the close button as QPushButton or as QToolButton
*/
QAbstractButton* createCloseButton() const
{
if (testConfigFlag(CDockManager::TabCloseButtonIsToolButton))
{
auto Button = new QToolButton();
Button->setAutoRaise(true);
return Button;
}
else
{
return new QPushButton();
}
}
};
// struct DockWidgetTabPrivate
@@ -129,21 +153,42 @@ DockWidgetTabPrivate::DockWidgetTabPrivate(CDockWidgetTab* _public) :
//============================================================================
void DockWidgetTabPrivate::createLayout()
{
QBoxLayout* l = new QBoxLayout(QBoxLayout::LeftToRight);
l->setContentsMargins(0, 0, 0, 0);
_this->setLayout(l);
IconLabel = new QLabel();
IconLabel->setAlignment(Qt::AlignVCenter);
l->addWidget(IconLabel, Qt::AlignVCenter);
TitleLabel = new QLabel();
TitleLabel->setObjectName("dockWidgetTabLabel");
l->addWidget(TitleLabel, 1);
IconLabel->setVisible(false);
TitleLabel->setVisible(true);
TitleLabel = new tTabLabel();
TitleLabel->setElideMode(Qt::ElideRight);
TitleLabel->setText(DockWidget->windowTitle());
TitleLabel->setObjectName("dockWidgetTabLabel");
TitleLabel->setAlignment(Qt::AlignCenter);
CloseButton = createCloseButton();
CloseButton->setObjectName("tabCloseButton");
// The standard icons do does not look good on high DPI screens
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);
_this->onDockWidgetFeaturesChanged();
#ifndef QT_NO_TOOLTIP
CloseButton->setToolTip(QObject::tr("Close Tab"));
#endif
_this->connect(CloseButton, SIGNAL(clicked()), SIGNAL(closeRequested()));
QFontMetrics fm(TitleLabel->font());
int Spacing = qRound(fm.height() / 4.0);
// Fill the layout
QBoxLayout* Layout = new QBoxLayout(QBoxLayout::LeftToRight);
Layout->setContentsMargins(2 * Spacing,0,0,0);
Layout->setSpacing(0);
_this->setLayout(Layout);
Layout->addWidget(TitleLabel, 1);
Layout->addSpacing(Spacing);
Layout->addWidget(CloseButton);
Layout->addSpacing(qRound(Spacing * 4.0 / 3.0));
Layout->setAlignment(Qt::AlignCenter);
TitleLabel->setVisible(true);
}
//============================================================================
@@ -160,42 +205,50 @@ void DockWidgetTabPrivate::moveTab(QMouseEvent* ev)
//============================================================================
bool DockWidgetTabPrivate::startFloating()
bool DockWidgetTabPrivate::startFloating(eDragState DraggingState)
{
qDebug() << "isFloating " << DockWidget->dockContainer()->isFloating();
qDebug() << "areaCount " << DockWidget->dockContainer()->dockAreaCount();
qDebug() << "widgetCount " << DockWidget->dockAreaWidget()->count();
auto dockContainer = DockWidget->dockContainer();
ADS_PRINT("isFloating " << dockContainer->isFloating());
ADS_PRINT("areaCount " << dockContainer->dockAreaCount());
ADS_PRINT("widgetCount " << DockWidget->dockAreaWidget()->dockWidgetsCount());
// if this is the last dock widget inside of this floating widget,
// then it does not make any sense, to make it floating because
// it is already floating
if (DockWidget->dockContainer()->isFloating()
&& (DockWidget->dockContainer()->visibleDockAreaCount() == 1)
&& (DockWidget->dockAreaWidget()->count() == 1))
if (dockContainer->isFloating()
&& (dockContainer->visibleDockAreaCount() == 1)
&& (DockWidget->dockAreaWidget()->dockWidgetsCount() == 1))
{
return false;
}
qDebug() << "startFloating";
DragState = DraggingFloatingWidget;
ADS_PRINT("startFloating");
DragState = DraggingState;
QSize Size = DockArea->size();
CFloatingDockContainer* FloatingWidget = nullptr;
if (DockArea->count() > 1)
if (DockArea->dockWidgetsCount() > 1)
{
// If section widget has multiple tabs, we take only one tab
FloatingWidget = new CFloatingDockContainer(DockWidget);
}
else
{
qDebug() << "DockWidgetTabPrivate::startFloating DockArea";
// If section widget has only one content widget, we can move the complete
// dock area into floating widget
FloatingWidget = new CFloatingDockContainer(DockArea);
}
FloatingWidget->startFloating(DragStartMousePosition, Size);
auto Overlay = DockWidget->dockManager()->containerOverlay();
Overlay->setAllowedAreas(OuterDockAreas);
this->FloatingWidget = FloatingWidget;
if (DraggingFloatingWidget == DraggingState)
{
FloatingWidget->startDragging(DragStartMousePosition, Size, _this);
auto Overlay = DockWidget->dockManager()->containerOverlay();
Overlay->setAllowedAreas(OuterDockAreas);
this->FloatingWidget = FloatingWidget;
}
else
{
FloatingWidget->initFloatingGeometry(DragStartMousePosition, Size);
}
DockWidget->emitTopLevelChanged(true);
return true;
}
@@ -213,7 +266,7 @@ CDockWidgetTab::CDockWidgetTab(CDockWidget* DockWidget, QWidget *parent) :
//============================================================================
CDockWidgetTab::~CDockWidgetTab()
{
qDebug() << "~CDockWidgetTab()";
ADS_PRINT("~CDockWidgetTab()");
delete d;
}
@@ -223,13 +276,13 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
{
if (ev->button() == Qt::LeftButton)
{
qDebug() << "CDockWidgetTab::mousePressEvent";
ev->accept();
d->DragStartMousePosition = ev->pos();
d->DragState = DraggingMousePressed;
emit clicked();
return;
}
QFrame::mousePressEvent(ev);
Super::mousePressEvent(ev);
}
@@ -237,30 +290,15 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
//============================================================================
void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
{
qDebug() << "CDockWidgetTab::mouseReleaseEvent";
// End of tab moving, change order now
// End of tab moving, emit signal
if (d->isDraggingState(DraggingTab) && d->DockArea)
{
// Find tab under mouse
QPoint pos = d->DockArea->mapFromGlobal(ev->globalPos());
int fromIndex = d->DockArea->tabIndex(d->DockWidget);
int toIndex = d->DockArea->indexOfContentByTitlePos(pos, this);
if (-1 == toIndex)
{
toIndex = d->DockArea->count() - 1;
}
qDebug() << "Move tab from " << fromIndex << " to " << toIndex;
d->DockArea->reorderDockWidget(fromIndex, toIndex);
emit moved(ev->globalPos());
}
if (!d->DragStartMousePosition.isNull())
{
emit clicked();
}
d->DragStartMousePosition = QPoint();
d->DragState = DraggingInactive;
QFrame::mouseReleaseEvent(ev);
Super::mouseReleaseEvent(ev);
}
@@ -270,15 +308,15 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
{
d->DragState = DraggingInactive;
QFrame::mouseMoveEvent(ev);
Super::mouseMoveEvent(ev);
return;
}
// move floating winwdow
// move floating window
if (d->isDraggingState(DraggingFloatingWidget))
{
d->FloatingWidget->moveFloating();
QFrame::mouseMoveEvent(ev);
Super::mouseMoveEvent(ev);
return;
}
@@ -290,24 +328,52 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
d->moveTab(ev);
}
bool MouseInsideTitleArea = d->titleAreaGeometryContains(ev->globalPos());
if (!MouseInsideTitleArea)
// Maybe a fixed drag distance is better here ?
int DragDistanceY = qAbs(d->DragStartMousePosition.y() - ev->pos().y());
if (DragDistanceY >= CDockManager::startDragDistance())
{
// If this is the last dock area in a dock container with only
// one single dock widget 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->openDockWidgetsCount() == 1
&& d->DockArea->dockContainer()->visibleDockAreaCount() == 1)
{
return;
}
// Floating is only allowed for widgets that are movable
if (d->DockWidget->features().testFlag(CDockWidget::DockWidgetMovable))
if (d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
{
d->startFloating();
}
return;
}
else if (d->DockArea->count() > 1
else if (d->DockArea->openDockWidgetsCount() > 1
&& (ev->pos() - d->DragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving
{
d->DragState = DraggingTab;
return;
}
QFrame::mouseMoveEvent(ev);
Super::mouseMoveEvent(ev);
}
//============================================================================
void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
{
ev->accept();
d->DragStartMousePosition = ev->pos();
QMenu Menu(this);
auto Action = Menu.addAction(tr("Detach"), this, SLOT(onDetachActionTriggered()));
Action->setEnabled(d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable));
Menu.addSeparator();
Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested()));
Action->setEnabled(isClosable());
Menu.addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested()));
Menu.exec(mapToGlobal(ev->pos()));
}
@@ -321,6 +387,11 @@ bool CDockWidgetTab::isActiveTab() const
//============================================================================
void CDockWidgetTab::setActiveTab(bool active)
{
bool DockWidgetClosable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetClosable);
bool ActiveTabHasCloseButton = d->testConfigFlag(CDockManager::ActiveTabHasCloseButton);
bool AllTabsHaveCloseButton = d->testConfigFlag(CDockManager::AllTabsHaveCloseButton);
bool TabHasCloseButton = (ActiveTabHasCloseButton && active) | AllTabsHaveCloseButton;
d->CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton);
if (d->IsActiveTab == active)
{
return;
@@ -361,9 +432,38 @@ CDockAreaWidget* CDockWidgetTab::dockAreaWidget() const
//============================================================================
void CDockWidgetTab::setIcon(const QIcon& Icon)
{
QBoxLayout* Layout = qobject_cast<QBoxLayout*>(layout());
if (!d->IconLabel && Icon.isNull())
{
return;
}
if (!d->IconLabel)
{
d->IconLabel = new QLabel();
d->IconLabel->setAlignment(Qt::AlignVCenter);
d->IconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
#ifndef QT_NO_TOOLTIP
d->IconLabel->setToolTip(d->TitleLabel->toolTip());
#endif
Layout->insertWidget(0, d->IconLabel, Qt::AlignVCenter);
Layout->insertSpacing(1, qRound(1.5 * Layout->contentsMargins().left() / 2.0));
}
else if (Icon.isNull())
{
// Remove icon label and spacer item
Layout->removeWidget(d->IconLabel);
Layout->removeItem(Layout->itemAt(0));
delete d->IconLabel;
d->IconLabel = nullptr;
}
d->Icon = Icon;
d->IconLabel->setPixmap(Icon.pixmap(this->windowHandle(), QSize(16, 16)));
d->IconLabel->setVisible(true);
if (d->IconLabel)
{
d->IconLabel->setPixmap(Icon.pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this)));
d->IconLabel->setVisible(true);
}
}
@@ -372,7 +472,94 @@ const QIcon& CDockWidgetTab::icon() const
{
return d->Icon;
}
} // namespace ads
//============================================================================
QString CDockWidgetTab::text() const
{
return d->TitleLabel->text();
}
//============================================================================
void CDockWidgetTab::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->dockWidgetsCount() > 1)
&& d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
{
d->DragStartMousePosition = event->pos();
d->startFloating(DraggingInactive);
}
Super::mouseDoubleClickEvent(event);
}
//============================================================================
void CDockWidgetTab::setVisible(bool visible)
{
// Just here for debugging to insert debug output
Super::setVisible(visible);
}
//============================================================================
void CDockWidgetTab::setText(const QString& title)
{
d->TitleLabel->setText(title);
}
//============================================================================
bool CDockWidgetTab::isClosable() const
{
return d->DockWidget && d->DockWidget->features().testFlag(CDockWidget::DockWidgetClosable);
}
//===========================================================================
void CDockWidgetTab::onDetachActionTriggered()
{
if (!d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
{
return;
}
d->DragStartMousePosition = mapFromGlobal(QCursor::pos());
d->startFloating(DraggingInactive);
}
//============================================================================
bool CDockWidgetTab::event(QEvent *e)
{
#ifndef QT_NO_TOOLTIP
if (e->type() == QEvent::ToolTipChange)
{
const auto text = toolTip();
d->TitleLabel->setToolTip(text);
}
#endif
return Super::event(e);
}
//============================================================================
void CDockWidgetTab::onDockWidgetFeaturesChanged()
{
auto Features = d->DockWidget->features();
auto SizePolicy = d->CloseButton->sizePolicy();
SizePolicy.setRetainSizeWhenHidden(Features.testFlag(CDockWidget::DockWidgetClosable)
&& d->testConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden));
d->CloseButton->setSizePolicy(SizePolicy);
}
} // namespace ads
//---------------------------------------------------------------------------
// EOF DockWidgetTab.cpp

View File

@@ -53,13 +53,25 @@ class ADS_EXPORT CDockWidgetTab : public QFrame
private:
DockWidgetTabPrivate* d; ///< private data (pimpl)
friend struct DockWidgetTabPrivate;
friend class CDockWidget;
void onDockWidgetFeaturesChanged();
private slots:
void onDetachActionTriggered();
protected:
virtual void mousePressEvent(QMouseEvent* ev) override;
virtual void mouseReleaseEvent(QMouseEvent* ev) override;
virtual void mouseMoveEvent(QMouseEvent* ev) override;
virtual void contextMenuEvent(QContextMenuEvent* ev) override;
/**
* Double clicking the tab widget makes the assigned dock widget floating
*/
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
public:
using Super = QFrame;
/**
* Default Constructor
* param[in] DockWidget The dock widget this title bar belongs to
@@ -110,9 +122,36 @@ public:
*/
const QIcon& icon() const;
/**
* Returns the tab text
*/
QString text() const;
/**
* Sets the tab text
*/
void setText(const QString& title);
/**
* This function returns true if the assigned dock widget is closeable
*/
bool isClosable() const;
/**
* Track event ToolTipChange and set child ToolTip
*/
virtual bool event(QEvent *e) override;
public slots:
virtual void setVisible(bool visible) override;
signals:
void activeTabChanged();
void clicked();
void closeRequested();
void closeOtherTabsRequested();
void moved(const QPoint& GlobalPos);
}; // class DockWidgetTab
}
// namespace ads

212
src/ElidingLabel.cpp Normal file
View File

@@ -0,0 +1,212 @@
/*******************************************************************************
** 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/>.
******************************************************************************/
//============================================================================
/// \file ElidingLabel.cpp
/// \author Uwe Kindler
/// \date 05.11.2018
/// \brief Implementation of CElidingLabel
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include "ElidingLabel.h"
#include <QMouseEvent>
namespace ads
{
/**
* Private data of public CClickableLabel
*/
struct ElidingLabelPrivate
{
CElidingLabel* _this;
Qt::TextElideMode ElideMode = Qt::ElideNone;
QString Text;
ElidingLabelPrivate(CElidingLabel* _public) : _this(_public) {}
void elideText(int Width);
/**
* Convenience function to check if the
*/
bool isModeElideNone() const
{
return Qt::ElideNone == ElideMode;
}
};
//============================================================================
void ElidingLabelPrivate::elideText(int Width)
{
if (isModeElideNone())
{
return;
}
QFontMetrics fm = _this->fontMetrics();
QString str = fm.elidedText(Text, ElideMode, Width - _this->margin() * 2 - _this->indent());
if (str == "")
{
str = Text.at(0);
}
_this->QLabel::setText(str);
}
//============================================================================
CElidingLabel::CElidingLabel(QWidget* parent, Qt::WindowFlags f)
: QLabel(parent, f),
d(new ElidingLabelPrivate(this))
{
}
//============================================================================
CElidingLabel::CElidingLabel(const QString& text, QWidget* parent, Qt::WindowFlags f)
: QLabel(text, parent,f),
d(new ElidingLabelPrivate(this))
{
d->Text = text;
#ifndef QT_NO_TOOLTIP
setToolTip(text);
#endif
}
//============================================================================
CElidingLabel::~CElidingLabel()
{
delete d;
}
//============================================================================
Qt::TextElideMode CElidingLabel::elideMode() const
{
return d->ElideMode;
}
//============================================================================
void CElidingLabel::setElideMode(Qt::TextElideMode mode)
{
d->ElideMode = mode;
d->elideText(size().width());
}
//============================================================================
void CElidingLabel::mouseReleaseEvent(QMouseEvent* event)
{
Super::mouseReleaseEvent(event);
if (event->button() != Qt::LeftButton)
{
return;
}
emit clicked();
}
//============================================================================
void CElidingLabel::mouseDoubleClickEvent( QMouseEvent *ev )
{
Q_UNUSED(ev)
emit doubleClicked();
Super::mouseDoubleClickEvent(ev);
}
//============================================================================
void CElidingLabel::resizeEvent(QResizeEvent *event)
{
if (!d->isModeElideNone())
{
d->elideText(event->size().width());
}
Super::resizeEvent(event);
}
//============================================================================
QSize CElidingLabel::minimumSizeHint() const
{
if (pixmap() != nullptr || d->isModeElideNone())
{
return QLabel::minimumSizeHint();
}
const QFontMetrics &fm = fontMetrics();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
QSize size(fm.horizontalAdvance(d->Text.left(2) + ""), fm.height());
#else
QSize size(fm.width(d->Text.left(2) + ""), fm.height());
#endif
return size;
}
//============================================================================
QSize CElidingLabel::sizeHint() const
{
if (pixmap() != nullptr || d->isModeElideNone())
{
return QLabel::sizeHint();
}
const QFontMetrics& fm = fontMetrics();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
QSize size(fm.horizontalAdvance(d->Text), QLabel::sizeHint().height());
#else
QSize size(fm.width(d->Text), QLabel::sizeHint().height());
#endif
return size;
}
//============================================================================
void CElidingLabel::setText(const QString &text)
{
if (d->isModeElideNone())
{
Super::setText(text);
}
else
{
d->Text = text;
#ifndef QT_NO_TOOLTIP
setToolTip( text );
#endif
d->elideText(this->size().width());
}
}
//============================================================================
QString CElidingLabel::text() const
{
return d->Text;
}
} // namespace QtLabb
//---------------------------------------------------------------------------
// EOF ClickableLabel.cpp

99
src/ElidingLabel.h Normal file
View File

@@ -0,0 +1,99 @@
#ifndef ElidingLabelH
#define ElidingLabelH
/*******************************************************************************
** 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/>.
******************************************************************************/
//============================================================================
/// \file ElidingLabel.h
/// \author Uwe Kindler
/// \date 05.11.2018
/// \brief Declaration of CElidingLabel
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include <QLabel>
#include "ads_globals.h"
namespace ads
{
struct ElidingLabelPrivate;
/**
* A QLabel that supports eliding text.
* Because the functions setText() and text() are no virtual functions setting
* and reading the text via a pointer to the base class QLabel does not work
* properly
*/
class ADS_EXPORT CElidingLabel : public QLabel
{
Q_OBJECT
private:
ElidingLabelPrivate* d;
friend struct ElidingLabelPrivate;
protected:
virtual void mouseReleaseEvent(QMouseEvent* event) override;
virtual void resizeEvent( QResizeEvent *event ) override;
virtual void mouseDoubleClickEvent( QMouseEvent *ev ) override;
public:
using Super = QLabel;
CElidingLabel(QWidget* parent = 0, Qt::WindowFlags f = 0);
CElidingLabel(const QString& text, QWidget* parent = 0, Qt::WindowFlags f = 0);
virtual ~CElidingLabel();
/**
* Returns the text elide mode.
* The default mode is ElideNone
*/
Qt::TextElideMode elideMode() const;
/**
* Sets the text elide mode
*/
void setElideMode(Qt::TextElideMode mode);
public: // reimplements QLabel ----------------------------------------------
virtual QSize minimumSizeHint() const override;
virtual QSize sizeHint() const override;
void setText(const QString &text);
QString text() const;
signals:
/**
* This signal is emitted if the user clicks on the label (i.e. pressed
* down then released while the mouse cursor is inside the label)
*/
void clicked();
/**
* This signal is emitted if the user does a double click on the label
*/
void doubleClicked();
}; //class CElidingLabel
} // namespace QtLabb
//---------------------------------------------------------------------------
#endif // ElidingLabelH

View File

@@ -1,21 +1,20 @@
/*******************************************************************************
** 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/>.
******************************************************************************/
** 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/>.
******************************************************************************/
//============================================================================
/// \file FloatingDockContainer.cpp
@@ -24,7 +23,6 @@
/// \brief Implementation of CFloatingDockContainer class
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
@@ -36,6 +34,8 @@
#include <QPointer>
#include <QAction>
#include <QDebug>
#include <QAbstractButton>
#include <QElapsedTimer>
#include "DockContainerWidget.h"
#include "DockAreaWidget.h"
@@ -43,70 +43,107 @@
#include "DockWidget.h"
#include "DockOverlay.h"
#include <iostream>
#ifdef Q_OS_LINUX
#include "linux/FloatingWidgetTitleBar.h"
#include <xcb/xcb.h>
#endif
namespace ads
{
static unsigned int zOrderCounter = 0;
/**
* Private data class of CFloatingDockContainer class (pimpl)
*/
struct FloatingDockContainerPrivate
{
CFloatingDockContainer* _this;
CDockContainerWidget* DockContainer;
CFloatingDockContainer *_this;
CDockContainerWidget *DockContainer;
unsigned int zOrderIndex = ++zOrderCounter;
QPointer<CDockManager> DockManager;
bool DraggingActive = false;
bool NonClientAreaMouseButtonPress = false;
eDragState DraggingState = DraggingInactive;
QPoint DragStartMousePosition;
CDockContainerWidget* DropContainer = nullptr;
CDockAreaWidget* SingleDockArea = nullptr;
CDockContainerWidget *DropContainer = nullptr;
CDockAreaWidget *SingleDockArea = nullptr;
#ifdef Q_OS_LINUX
QWidget* MouseEventHandler = nullptr;
CFloatingWidgetTitleBar* TitleBar = nullptr;
#endif
/**
* Private data constructor
*/
FloatingDockContainerPrivate(CFloatingDockContainer* _public);
FloatingDockContainerPrivate(CFloatingDockContainer *_public);
void titleMouseReleaseEvent();
void updateDropOverlays(const QPoint& GlobalPos);
void setDraggingActive(bool Active);
void updateDropOverlays(const QPoint &GlobalPos);
/**
* Tests is a certain state is active
*/
bool isState(eDragState StateId) const
{
return StateId == DraggingState;
}
void setState(eDragState StateId)
{
DraggingState = StateId;
}
void setWindowTitle(const QString &Text)
{
#ifdef Q_OS_LINUX
TitleBar->setTitle(Text);
#else
_this->setWindowTitle(Text);
#endif
}
};
// struct FloatingDockContainerPrivate
//============================================================================
FloatingDockContainerPrivate::FloatingDockContainerPrivate(CFloatingDockContainer* _public) :
FloatingDockContainerPrivate::FloatingDockContainerPrivate(
CFloatingDockContainer *_public) :
_this(_public)
{
}
//============================================================================
void FloatingDockContainerPrivate::titleMouseReleaseEvent()
{
setDraggingActive(false);
setState(DraggingInactive);
if (!DropContainer)
{
return;
}
if (DockManager->dockAreaOverlay()->dropAreaUnderCursor() != InvalidDockWidgetArea
|| DockManager->containerOverlay()->dropAreaUnderCursor() != InvalidDockWidgetArea)
if (DockManager->dockAreaOverlay()->dropAreaUnderCursor()
!= InvalidDockWidgetArea
|| DockManager->containerOverlay()->dropAreaUnderCursor()
!= InvalidDockWidgetArea)
{
// Resize the floating widget to the size of the highlighted drop area
// rectangle
QRect Rect = DockManager->containerOverlay()->dropOverlayRect();
if (!Rect.isValid())
CDockOverlay *Overlay = DockManager->containerOverlay();
if (!Overlay->dropOverlayRect().isValid())
{
Rect = DockManager->dockAreaOverlay()->rect();
Overlay = DockManager->dockAreaOverlay();
}
QRect Rect = Overlay->dropOverlayRect();
int FrameWidth = (_this->frameSize().width() - _this->rect().width())
/ 2;
int TitleBarHeight = _this->frameSize().height()
- _this->rect().height() - FrameWidth;
if (Rect.isValid())
{
_this->resize(Rect.size());
QPoint TopLeft = Overlay->mapToGlobal(Rect.topLeft());
TopLeft.ry() += TitleBarHeight;
_this->setGeometry(
QRect(TopLeft,
QSize(Rect.width(), Rect.height() - TitleBarHeight)));
QApplication::processEvents();
}
DropContainer->dropFloatingWidget(_this, QCursor::pos());
}
@@ -115,111 +152,113 @@ void FloatingDockContainerPrivate::titleMouseReleaseEvent()
DockManager->dockAreaOverlay()->hideOverlay();
}
//============================================================================
void FloatingDockContainerPrivate::updateDropOverlays(const QPoint& GlobalPos)
void FloatingDockContainerPrivate::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();
if (!TopContainer)
{
ContainerOverlay->hideOverlay();
DockAreaOverlay->hideOverlay();
return;
}
int VisibleDockAreas = TopContainer->visibleDockAreaCount();
ContainerOverlay->setAllowedAreas(VisibleDockAreas > 1 ?
OuterDockAreas : AllDockAreas);
DockWidgetArea ContainerArea = ContainerOverlay->showOverlay(TopContainer);
auto DockArea = TopContainer->dockAreaAt(GlobalPos);
if (DockArea && DockArea->isVisible() && VisibleDockAreas > 0)
{
DockAreaOverlay->enableDropPreview(true);
DockAreaOverlay->setAllowedAreas((VisibleDockAreas == 1) ?
NoDockWidgetArea : AllDockAreas);
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();
}
}
//============================================================================
void FloatingDockContainerPrivate::setDraggingActive(bool Active)
{
DraggingActive = Active;
if (!DraggingActive)
auto Containers = DockManager->dockContainers();
CDockContainerWidget *TopContainer = nullptr;
for (auto ContainerWidget : Containers)
{
NonClientAreaMouseButtonPress = false;
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();
if (!TopContainer)
{
ContainerOverlay->hideOverlay();
DockAreaOverlay->hideOverlay();
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)
{
DockAreaOverlay->enableDropPreview(true);
DockAreaOverlay->setAllowedAreas(
(VisibleDockAreas == 1) ? NoDockWidgetArea : AllDockAreas);
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();
}
}
//============================================================================
CFloatingDockContainer::CFloatingDockContainer(CDockManager* DockManager) :
QWidget(DockManager, Qt::Window),
CFloatingDockContainer::CFloatingDockContainer(CDockManager *DockManager) :
tFloatingWidgetBase(DockManager),
d(new FloatingDockContainerPrivate(this))
{
d->DockManager = DockManager;
QBoxLayout* l = new QBoxLayout(QBoxLayout::TopToBottom);
l->setContentsMargins(0, 0, 0, 0);
l->setSpacing(0);
setLayout(l);
d->DockContainer = new CDockContainerWidget(DockManager, this);
connect(d->DockContainer, SIGNAL(dockAreasAdded()), this,
SLOT(onDockAreasAddedOrRemoved()));
connect(d->DockContainer, SIGNAL(dockAreasRemoved()), this,
SLOT(onDockAreasAddedOrRemoved()));
d->DockContainer = new CDockContainerWidget(DockManager, this);
connect(d->DockContainer, SIGNAL(dockAreasAdded()), this, SLOT(onDockAreasAddedOrRemoved()));
connect(d->DockContainer, SIGNAL(dockAreasRemoved()), this, SLOT(onDockAreasAddedOrRemoved()));
#ifdef Q_OS_LINUX
d->TitleBar = new CFloatingWidgetTitleBar(this);
setWindowFlags(windowFlags() | Qt::Tool);
QDockWidget::setWidget(d->DockContainer);
QDockWidget::setFloating(true);
QDockWidget::setFeatures(QDockWidget::AllDockWidgetFeatures);
setTitleBarWidget(d->TitleBar);
connect(d->TitleBar, SIGNAL(closeRequested()), SLOT(close()));
#else
setWindowFlags(
Qt::Window | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);
QBoxLayout *l = new QBoxLayout(QBoxLayout::TopToBottom);
l->setContentsMargins(0, 0, 0, 0);
l->setSpacing(0);
setLayout(l);
l->addWidget(d->DockContainer);
#endif
DockManager->registerFloatingWidget(this);
// We install an event filter to detect mouse release events because we
@@ -228,26 +267,30 @@ CFloatingDockContainer::CFloatingDockContainer(CDockManager* DockManager) :
qApp->installEventFilter(this);
}
//============================================================================
CFloatingDockContainer::CFloatingDockContainer(CDockAreaWidget* DockArea) :
CFloatingDockContainer::CFloatingDockContainer(CDockAreaWidget *DockArea) :
CFloatingDockContainer(DockArea->dockManager())
{
d->DockContainer->addDockArea(DockArea);
#ifdef Q_OS_LINUX
d->TitleBar->enableCloseButton(isClosable());
#endif
}
//============================================================================
CFloatingDockContainer::CFloatingDockContainer(CDockWidget* DockWidget) :
CFloatingDockContainer::CFloatingDockContainer(CDockWidget *DockWidget) :
CFloatingDockContainer(DockWidget->dockManager())
{
d->DockContainer->addDockWidget(CenterDockWidgetArea, DockWidget);
#ifdef Q_OS_LINUX
d->TitleBar->enableCloseButton(isClosable());
#endif
}
//============================================================================
CFloatingDockContainer::~CFloatingDockContainer()
{
qDebug() << "~CFloatingDockContainer";
ADS_PRINT("~CFloatingDockContainer");
if (d->DockManager)
{
d->DockManager->removeFloatingWidget(this);
@@ -255,231 +298,336 @@ CFloatingDockContainer::~CFloatingDockContainer()
delete d;
}
//============================================================================
CDockContainerWidget* CFloatingDockContainer::dockContainer() const
{
return d->DockContainer;
}
//============================================================================
void CFloatingDockContainer::changeEvent(QEvent *event)
{
QWidget::changeEvent(event);
if ((event->type() == QEvent::ActivationChange) && isActiveWindow())
{
qDebug() << "FloatingWidget::changeEvent QEvent::ActivationChange ";
{
ADS_PRINT("FloatingWidget::changeEvent QEvent::ActivationChange ");
d->zOrderIndex = ++zOrderCounter;
return;
}
return;
}
}
//============================================================================
void CFloatingDockContainer::moveEvent(QMoveEvent *event)
{
QWidget::moveEvent(event);
if (!qApp->mouseButtons().testFlag(Qt::LeftButton))
{
if (d->DraggingActive)
{
d->setDraggingActive(false);
}
return;
}
if (d->DraggingActive)
switch (d->DraggingState)
{
case DraggingMousePressed:
d->setState(DraggingFloatingWidget);
d->updateDropOverlays(QCursor::pos());
break;
case DraggingFloatingWidget:
d->updateDropOverlays(QCursor::pos());
break;
default:
break;
}
}
//============================================================================
void CFloatingDockContainer::closeEvent(QCloseEvent *event)
{
qDebug() << "CFloatingDockContainer closeEvent";
d->setDraggingActive(false);
ADS_PRINT("CFloatingDockContainer closeEvent");
d->setState(DraggingInactive);
if (isClosable())
QWidget::closeEvent(event);
else
if (isClosable())
{
// 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
// events anymore after a close/show cycle. The bug is reported here:
// https://bugreports.qt.io/browse/QTBUG-73295
// The following code is a workaround for Qt versions > 5.9.2 that seems
// to work
// Starting from Qt version 5.12.2 this seems to work again. But
// now the QEvent::NonClientAreaMouseButtonPress function returns always
// 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();
#else
Super::closeEvent(event);
#endif
#else // Q_OS_LINUX
Super::closeEvent(event);
#endif
}
else
{
event->ignore();
}
}
//============================================================================
void CFloatingDockContainer::hideEvent(QHideEvent *event)
{
qDebug() << "CFloatingDockContainer hideEvent";
QWidget::hideEvent(event);
auto OpenDockAreas = d->DockContainer->openedDockAreas();
for (auto DockArea : OpenDockAreas)
Super::hideEvent(event);
// Prevent toogleView() events during restore state
if (d->DockManager->isRestoringState())
{
return;
}
for (auto DockArea : d->DockContainer->openedDockAreas())
{
auto OpenDockWidgets = DockArea->openedDockWidgets();
for (auto DockWidget : OpenDockWidgets)
for (auto DockWidget : DockArea->openedDockWidgets())
{
DockWidget->toggleView(false);
}
}
}
//============================================================================
void CFloatingDockContainer::showEvent(QShowEvent *event)
{
QWidget::showEvent(event);
CDockContainerWidget* DockContainer = dockContainer();
for (int i = 0; i < DockContainer->dockAreaCount(); ++i)
{
auto DockArea = DockContainer->dockArea(i);
for (auto DockWidget : DockArea->openedDockWidgets())
{
DockWidget->setToggleViewActionChecked(true);
}
}
Super::showEvent(event);
}
//============================================================================
bool CFloatingDockContainer::event(QEvent *e)
{
if (e->type() == QEvent::NonClientAreaMouseButtonPress)
switch (d->DraggingState)
{
if (QGuiApplication::mouseButtons() == Qt::LeftButton)
case DraggingInactive:
{
// Normally we would check here, if the left mouse button is pressed.
// But from QT version 5.12.2 on the mouse events from
// QEvent::NonClientAreaMouseButtonPress return the wrong mouse button
// The event always returns Qt::RightButton even if the left button
// is clicked.
// It is really great to work around the whole NonClientMouseArea
// bugs
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 2))
if (e->type()
== QEvent::NonClientAreaMouseButtonPress /*&& QGuiApplication::mouseButtons().testFlag(Qt::LeftButton)*/)
{
qDebug() << "FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type();
d->setDraggingActive(true);
d->NonClientAreaMouseButtonPress = true;
ADS_PRINT("FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type());
d->setState(DraggingMousePressed);
}
}
else if (e->type() == QEvent::NonClientAreaMouseButtonDblClick)
{
qDebug() << "FloatingWidget::event QEvent::NonClientAreaMouseButtonDblClick";
d->setDraggingActive(false);
}
else if ((e->type() == QEvent::NonClientAreaMouseButtonRelease) && d->DraggingActive)
{
qDebug() << "FloatingWidget::event QEvent::NonClientAreaMouseButtonRelease";
d->titleMouseReleaseEvent();
}
else if (d->NonClientAreaMouseButtonPress && (e->type() == QEvent::Resize))
{
// If user resizes the floating widget, we do not want to show any
// drop overlays or drop overlay icons. If the window is maximized,
// then dragging the window via title bar will cause the widget to
// leave the maximized state. This in turn will trigger a resize event.
// To know, if the resize event was triggered by user via moving a
// corner of the window frame or if it was caused by a windows state
// change, we check, if we are not in maximized state.
if (!isMaximized())
#else
if (e->type() == QEvent::NonClientAreaMouseButtonPress && QGuiApplication::mouseButtons().testFlag(Qt::LeftButton))
{
d->setDraggingActive(false);
ADS_PRINT("FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type());
d->setState(DraggingMousePressed);
}
#endif
}
break;
case DraggingMousePressed:
switch (e->type())
{
case QEvent::NonClientAreaMouseButtonDblClick:
ADS_PRINT("FloatingWidget::event QEvent::NonClientAreaMouseButtonDblClick");
d->setState(DraggingInactive);
break;
case QEvent::Resize:
// If the first event after the mouse press is a resize event, then
// the user resizes the window instead of dragging it around.
// But there is one exception. If the window is maximized,
// then dragging the window via title bar will cause the widget to
// leave the maximized state. This in turn will trigger a resize event.
// To know, if the resize event was triggered by user via moving a
// corner of the window frame or if it was caused by a windows state
// change, we check, if we are not in maximized state.
if (!isMaximized())
{
d->setState(DraggingInactive);
}
break;
default:
break;
}
break;
case DraggingFloatingWidget:
if (e->type() == QEvent::NonClientAreaMouseButtonRelease)
{
ADS_PRINT("FloatingWidget::event QEvent::NonClientAreaMouseButtonRelease");
d->titleMouseReleaseEvent();
}
break;
default:
break;
}
#if (ADS_DEBUG_LEVEL > 0)
qDebug() << "CFloatingDockContainer::event " << e->type();
#endif
return QWidget::event(e);
}
//============================================================================
bool CFloatingDockContainer::eventFilter(QObject *watched, QEvent *event)
{
Q_UNUSED(watched);
if (event->type() == QEvent::MouseButtonRelease && d->DraggingActive)
if (event->type() == QEvent::MouseButtonRelease
&& d->isState(DraggingFloatingWidget))
{
qDebug() << "FloatingWidget::eventFilter QEvent::MouseButtonRelease";
ADS_PRINT("FloatingWidget::eventFilter QEvent::MouseButtonRelease");
finishDragging();
d->titleMouseReleaseEvent();
}
return false;
}
//============================================================================
void CFloatingDockContainer::startFloating(const QPoint& Pos, const QSize& Size)
void CFloatingDockContainer::startFloating(const QPoint &DragStartMousePos,
const QSize &Size, eDragState DragState, QWidget *MouseEventHandler)
{
#ifndef Q_OS_LINUX
Q_UNUSED(MouseEventHandler)
#endif
resize(Size);
d->setDraggingActive(true);
QPoint TargetPos = QCursor::pos() - Pos;
move(TargetPos);
show();
d->DragStartMousePosition = Pos;
}
d->setState(DragState);
d->DragStartMousePosition = DragStartMousePos;
#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)
{
setAttribute(Qt::WA_X11NetWmWindowTypeDock, true);
setWindowOpacity(0.6);
d->MouseEventHandler = MouseEventHandler;
if (d->MouseEventHandler)
{
d->MouseEventHandler->grabMouse();
}
}
#endif
moveFloating();
show();
}
//============================================================================
void CFloatingDockContainer::moveFloating()
{
int BorderSize = (frameSize().width() - size().width()) / 2;
const QPoint moveToPos = QCursor::pos() - d->DragStartMousePosition - QPoint(BorderSize, 0);
const QPoint moveToPos = QCursor::pos() - d->DragStartMousePosition
- QPoint(BorderSize, 0);
move(moveToPos);
}
//============================================================================
bool CFloatingDockContainer::isClosable() const
{
auto OpenDockAreas = d->DockContainer->openedDockAreas();
for (auto DockArea : OpenDockAreas)
{
auto OpenDockWidgets = DockArea->openedDockWidgets();
for (auto DockWidget : OpenDockWidgets)
{
if (!DockWidget->features().testFlag(CDockWidget::DockWidgetClosable))
{
return false;
}
}
}
return true;
return d->DockContainer->features().testFlag(
CDockWidget::DockWidgetClosable);
}
//============================================================================
void CFloatingDockContainer::onDockAreasAddedOrRemoved()
{
qDebug() << "CFloatingDockContainer::onDockAreasAddedOrRemoved()";
if (d->DockContainer->dockAreaCount() == 1)
ADS_PRINT("CFloatingDockContainer::onDockAreasAddedOrRemoved()");
auto TopLevelDockArea = d->DockContainer->topLevelDockArea();
if (TopLevelDockArea)
{
d->SingleDockArea = d->DockContainer->dockArea(0);
this->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
d->SingleDockArea = TopLevelDockArea;
d->setWindowTitle(
d->SingleDockArea->currentDockWidget()->windowTitle());
connect(d->SingleDockArea, SIGNAL(currentChanged(int)), this,
SLOT(onDockAreaCurrentChanged(int)));
SLOT(onDockAreaCurrentChanged(int)));
}
else
{
if (d->SingleDockArea)
{
disconnect(d->SingleDockArea, SIGNAL(currentChanged(int)), this,
SLOT(onDockAreaCurrentChanged(int)));
SLOT(onDockAreaCurrentChanged(int)));
d->SingleDockArea = nullptr;
}
this->setWindowTitle(qApp->applicationDisplayName());
d->setWindowTitle(qApp->applicationDisplayName());
}
}
//============================================================================
void CFloatingDockContainer::updateWindowTitle()
{
auto TopLevelDockArea = d->DockContainer->topLevelDockArea();
if (TopLevelDockArea)
{
d->setWindowTitle(TopLevelDockArea->currentDockWidget()->windowTitle());
}
else
{
d->setWindowTitle(qApp->applicationDisplayName());
}
}
//============================================================================
void CFloatingDockContainer::onDockAreaCurrentChanged(int Index)
{
Q_UNUSED(Index);
this->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
d->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
}
//============================================================================
bool CFloatingDockContainer::restoreState(QXmlStreamReader& Stream, bool Testing)
bool CFloatingDockContainer::restoreState(QXmlStreamReader &Stream,
bool Testing)
{
if (!d->DockContainer->restoreState(Stream, Testing))
{
return false;
}
onDockAreasAddedOrRemoved();
return true;
}
//============================================================================
bool CFloatingDockContainer::hasTopLevelDockWidget() const
{
return d->DockContainer->hasTopLevelDockWidget();
}
//============================================================================
CDockWidget* CFloatingDockContainer::topLevelDockWidget() const
{
return d->DockContainer->topLevelDockWidget();
}
//============================================================================
QList<CDockWidget*> CFloatingDockContainer::dockWidgets() const
{
return d->DockContainer->dockWidgets();
}
//============================================================================
void CFloatingDockContainer::finishDragging()
{
ADS_PRINT("CFloatingDockContainer::finishDragging");
#ifdef Q_OS_LINUX
setAttribute(Qt::WA_X11NetWmWindowTypeDock, false);
setWindowOpacity(1);
activateWindow();
if (d->MouseEventHandler)
{
d->MouseEventHandler->releaseMouse();
d->MouseEventHandler = nullptr;
}
#endif
}
} // namespace ads

View File

@@ -29,10 +29,16 @@
//============================================================================
// INCLUDES
//============================================================================
#include <QWidget>
#include "ads_globals.h"
#ifdef Q_OS_LINUX
#include <QDockWidget>
#define tFloatingWidgetBase QDockWidget
#else
#include <QWidget>
#define tFloatingWidgetBase QWidget
#endif
class QXmlStreamReader;
namespace ads
@@ -47,13 +53,17 @@ class CDockManager;
class CDockAreaTabBar;
class CDockWidgetTab;
struct DockWidgetTabPrivate;
class CDockAreaTitleBar;
struct DockAreaTitleBarPrivate;
class CFloatingWidgetTitleBar;
/**
* This implements a floating widget that is a dock container that accepts
* docking of dock widgets like the main window and that can be docked into
* another dock container
* another dock container.
* Every floating window of the docking system is a FloatingDockContainer.
*/
class ADS_EXPORT CFloatingDockContainer : public QWidget
class ADS_EXPORT CFloatingDockContainer : public tFloatingWidgetBase
{
Q_OBJECT
private:
@@ -64,6 +74,11 @@ private:
friend class CDockAreaTabBar;
friend struct DockWidgetTabPrivate;
friend class CDockWidgetTab;
friend class CDockAreaTitleBar;
friend struct DockAreaTitleBarPrivate;
friend class CDockWidget;
friend class CDockAreaWidget;
friend class CFloatingWidgetTitleBar;
private slots:
void onDockAreasAddedOrRemoved();
@@ -75,7 +90,32 @@ protected:
* Use moveToGlobalPos() to move the widget to a new position
* depending on the start position given in Pos parameter
*/
void startFloating(const QPoint& Pos, const QSize& Size = QSize());
void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
eDragState DragState, QWidget* MouseEventHandler);
/**
* Call this function to start dragging the floating widget
*/
void startDragging(const QPoint& DragStartMousePos, const QSize& Size,
QWidget* MouseEventHandler)
{
startFloating(DragStartMousePos, Size, DraggingFloatingWidget, MouseEventHandler);
}
/**
* Call this function if you explecitely want to signal that dragging has
* finished
*/
void finishDragging();
/**
* Call this function if you just want to initialize the position
* and size of the floating widget
*/
void initFloatingGeometry(const QPoint& DragStartMousePos, const QSize& Size)
{
startFloating(DragStartMousePos, Size, DraggingInactive, nullptr);
}
/**
* Moves the widget to a new position relative to the position given when
@@ -91,6 +131,11 @@ protected:
*/
bool restoreState(QXmlStreamReader& Stream, bool Testing);
/**
* Call this function to update the window title
*/
void updateWindowTitle();
protected: // reimplements QWidget
virtual void changeEvent(QEvent *event) override;
@@ -102,6 +147,8 @@ protected: // reimplements QWidget
virtual bool eventFilter(QObject *watched, QEvent *event) override;
public:
using Super = QWidget;
/**
* Create empty flatingb widget - required for restore state
*/
@@ -132,6 +179,28 @@ public:
* It can be closed, if all dock widgets in all dock areas can be closed
*/
bool isClosable() const;
/**
* This function returns true, if this floating widget has only one single
* visible dock widget in a single visible dock area.
* The single dock widget is a real top level floating widget because no
* other widgets are docked.
*/
bool hasTopLevelDockWidget() const;
/**
* This function returns the first dock widget in the first dock area.
* If the function hasSingleDockWidget() returns true, then this function
* returns this single dock widget.
*/
CDockWidget* topLevelDockWidget() const;
/**
* This function returns a list of all dock widget in this floating widget.
* This is a simple convenience function that simply calls the dockWidgets()
* function of the internal container widget.
*/
QList<CDockWidget*> dockWidgets() const;
}; // class FloatingDockContainer
}
// namespace ads

View File

@@ -1,5 +1,8 @@
<RCC>
<qresource prefix="/ads">
<file>stylesheets/default.css</file>
<file>images/close-button.svg</file>
<file>images/close-button-disabled.svg</file>
<file>stylesheets/default_linux.css</file>
</qresource>
</RCC>

View File

@@ -29,6 +29,7 @@
// INCLUDES
//============================================================================
#include <QVariant>
#include <QPainter>
#include "DockSplitter.h"
#include "ads_globals.h"
@@ -39,21 +40,11 @@ namespace ads
namespace internal
{
//============================================================================
QSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent)
{
QSplitter* s = new CDockSplitter(orientation, parent);
s->setProperty("ads-splitter", QVariant(true));
s->setChildrenCollapsible(false);
s->setOpaqueResize(false);
return s;
}
//============================================================================
void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To)
{
int index = Splitter->indexOf(From);
From->setParent(0);
From->setParent(nullptr);
Splitter->insertWidget(index, To);
}
@@ -73,6 +64,32 @@ CDockInsertParam dockAreaInsertParameters(DockWidgetArea Area)
return CDockInsertParam(Qt::Vertical, false);
}
//============================================================================
QPixmap createTransparentPixmap(const QPixmap& Source, qreal Opacity)
{
QPixmap TransparentPixmap(Source.size());
TransparentPixmap.fill(Qt::transparent);
QPainter p(&TransparentPixmap);
p.setOpacity(Opacity);
p.drawPixmap(0, 0, Source);
return TransparentPixmap;
}
//============================================================================
void hideEmptyParentSplitters(CDockSplitter* Splitter)
{
while (Splitter && Splitter->isVisible())
{
if (!Splitter->hasVisibleContent())
{
Splitter->hide();
}
Splitter = internal::findParent<CDockSplitter*>(Splitter);
}
}
} // namespace internal
} // namespace ads

View File

@@ -32,17 +32,36 @@
//============================================================================
#include <QPair>
#include <QtCore/QtGlobal>
#include <QPixmap>
#include <QWidget>
#ifndef ADS_STATIC
#ifdef ADS_SHARED_EXPORT
#define ADS_EXPORT Q_DECL_EXPORT
#else
#define ADS_EXPORT Q_DECL_IMPORT
#endif
#else
#define ADS_EXPORT
#endif
// Define ADS_DEBUG_PRINT to enable a lot of debug output
#ifdef ADS_DEBUG_PRINT
#define ADS_PRINT(s) qDebug() << s
#else
#define ADS_PRINT(s)
#endif
// Set ADS_DEBUG_LEVEL to enable additional debug output and to enable layout
// dumps to qDebug and std::cout after layout changes
#define ADS_DEBUG_LEVEL 0
class QSplitter;
namespace ads
{
class CDockSplitter;
enum DockWidgetArea
{
NoDockWidgetArea = 0x00,
@@ -59,20 +78,42 @@ enum DockWidgetArea
Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)
namespace internal
enum TitleBarButton
{
TitleBarButtonTabsMenu,
TitleBarButtonUndock,
TitleBarButtonClose
};
/**
* Helper function to create new splitter widgets
* The different dragging states
*/
QSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent = 0);
enum eDragState
{
DraggingInactive, //!< DraggingInactive
DraggingMousePressed, //!< DraggingMousePressed
DraggingTab, //!< DraggingTab
DraggingFloatingWidget//!< DraggingFloatingWidget
};
namespace internal
{
static const bool RestoreTesting = true;
static const bool Restore = false;
static const char* const ClosedProperty = "close";
static const char* const DirtyProperty = "dirty";
/**
* Replace the from widget in the given splitter with the To widget
*/
void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To);
/**
* This function walks the splitter tree upwards to hides all splitters
* that do not have visible content
*/
void hideEmptyParentSplitters(CDockSplitter* FirstParentSplitter);
/**
* Convenience class for QPair to provide better naming than first and
* second
@@ -95,6 +136,10 @@ CDockInsertParam dockAreaInsertParameters(DockWidgetArea Area);
* Searches for the parent widget of the given type.
* Returns the parent widget of the given widget or 0 if the widget is not
* child of any widget of type T
*
* It is not safe to use this function in in CDockWidget because only
* the current dock widget has a parent. All dock widgets that are not the
* current dock widget in a dock area have no parent.
*/
template <class T>
T findParent(const QWidget* w)
@@ -102,7 +147,7 @@ T findParent(const QWidget* w)
QWidget* parentWidget = w->parentWidget();
while (parentWidget)
{
T ParentImpl = dynamic_cast<T>(parentWidget);
T ParentImpl = qobject_cast<T>(parentWidget);
if (ParentImpl)
{
return ParentImpl;
@@ -112,6 +157,34 @@ T findParent(const QWidget* w)
return 0;
}
/**
* Creates a semi transparent pixmap from the given pixmap Source.
* The Opacity parameter defines the opacity from completely transparent (0.0)
* to completely opaque (1.0)
*/
QPixmap createTransparentPixmap(const QPixmap& Source, qreal Opacity);
/**
* Helper function for settings flags in a QFlags instance.
*/
template <class T>
void setFlag(T& Flags, typename T::enum_type flag, bool on = true)
{
#if QT_VERSION >= 0x050700
Flags.setFlag(flag, on);
#else
if(on)
{
Flags |= flag;
}
else
{
Flags &= ~flag;
}
#endif
}
} // namespace internal
} // namespace ads

View File

@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<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"
id="Capa_1"
x="0px"
y="0px"
width="512"
height="512"
viewBox="0 0 512 512"
xml:space="preserve"
sodipodi:docname="close-button-disabled.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)"><metadata
id="metadata897"><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></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs895" /><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="namedview893"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="0.85862966"
inkscape:cx="345.29142"
inkscape:cy="32.731258"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="Capa_1" />
<g
id="g860"
transform="matrix(0.71708683,0,0,0.71708683,128,128)"
style="stroke:none;stroke-opacity:1;fill:#000000;fill-opacity:0.50196081">
<g
id="close"
style="stroke:none;stroke-opacity:1;fill:#000000;fill-opacity:0.50196081">
<polygon
points="357,321.3 214.2,178.5 357,35.7 321.3,0 178.5,142.8 35.7,0 0,35.7 142.8,178.5 0,321.3 35.7,357 178.5,214.2 321.3,357 "
id="polygon857"
style="stroke:none;stroke-opacity:1;fill:#000000;fill-opacity:0.50196081" />
</g>
</g>
<g
id="g862"
transform="translate(0,155)">
</g>
<g
id="g864"
transform="translate(0,155)">
</g>
<g
id="g866"
transform="translate(0,155)">
</g>
<g
id="g868"
transform="translate(0,155)">
</g>
<g
id="g870"
transform="translate(0,155)">
</g>
<g
id="g872"
transform="translate(0,155)">
</g>
<g
id="g874"
transform="translate(0,155)">
</g>
<g
id="g876"
transform="translate(0,155)">
</g>
<g
id="g878"
transform="translate(0,155)">
</g>
<g
id="g880"
transform="translate(0,155)">
</g>
<g
id="g882"
transform="translate(0,155)">
</g>
<g
id="g884"
transform="translate(0,155)">
</g>
<g
id="g886"
transform="translate(0,155)">
</g>
<g
id="g888"
transform="translate(0,155)">
</g>
<g
id="g890"
transform="translate(0,155)">
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

119
src/images/close-button.svg Normal file
View File

@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<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"
id="Capa_1"
x="0px"
y="0px"
width="512"
height="512"
viewBox="0 0 512 512"
xml:space="preserve"
sodipodi:docname="close-button.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)"><metadata
id="metadata897"><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></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs895" /><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="namedview893"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="0.85862966"
inkscape:cx="345.29142"
inkscape:cy="32.731258"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="Capa_1" />
<g
id="g860"
transform="matrix(0.71708683,0,0,0.71708683,128,128)">
<g
id="close">
<polygon
points="357,321.3 214.2,178.5 357,35.7 321.3,0 178.5,142.8 35.7,0 0,35.7 142.8,178.5 0,321.3 35.7,357 178.5,214.2 321.3,357 "
id="polygon857" />
</g>
</g>
<g
id="g862"
transform="translate(0,155)">
</g>
<g
id="g864"
transform="translate(0,155)">
</g>
<g
id="g866"
transform="translate(0,155)">
</g>
<g
id="g868"
transform="translate(0,155)">
</g>
<g
id="g870"
transform="translate(0,155)">
</g>
<g
id="g872"
transform="translate(0,155)">
</g>
<g
id="g874"
transform="translate(0,155)">
</g>
<g
id="g876"
transform="translate(0,155)">
</g>
<g
id="g878"
transform="translate(0,155)">
</g>
<g
id="g880"
transform="translate(0,155)">
</g>
<g
id="g882"
transform="translate(0,155)">
</g>
<g
id="g884"
transform="translate(0,155)">
</g>
<g
id="g886"
transform="translate(0,155)">
</g>
<g
id="g888"
transform="translate(0,155)">
</g>
<g
id="g890"
transform="translate(0,155)">
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1,183 @@
/*******************************************************************************
** 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/>.
******************************************************************************/
//============================================================================
/// \file FloatingWidgetTitleBar.cpp
/// \author Uwe Kindler
/// \date 13.05.2019
/// \brief Implementation of CFloatingWidgetTitleBar class
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include "FloatingWidgetTitleBar.h"
#include <iostream>
#include <QHBoxLayout>
#include <QPushButton>
#include <QToolButton>
#include <QPixmap>
#include <QStyle>
#include <QMouseEvent>
#include "ads_globals.h"
#include "ElidingLabel.h"
#include "FloatingDockContainer.h"
namespace ads
{
using tTabLabel = CElidingLabel;
using tCloseButton = QPushButton;
/**
* @brief Private data class of public interface CFloatingWidgetTitleBar
*/
struct FloatingWidgetTitleBarPrivate
{
CFloatingWidgetTitleBar *_this; ///< public interface class
QLabel *IconLabel = nullptr;
tTabLabel *TitleLabel;
tCloseButton *CloseButton = nullptr;
CFloatingDockContainer *FloatingWidget = nullptr;
eDragState DragState = DraggingInactive;
FloatingWidgetTitleBarPrivate(CFloatingWidgetTitleBar *_public) :
_this(_public)
{
}
/**
* Creates the complete layout including all controls
*/
void createLayout();
};
//============================================================================
void FloatingWidgetTitleBarPrivate::createLayout()
{
TitleLabel = new tTabLabel();
TitleLabel->setElideMode(Qt::ElideRight);
TitleLabel->setText("DockWidget->windowTitle()");
TitleLabel->setObjectName("floatingTitleLabel");
TitleLabel->setAlignment(Qt::AlignLeft);
CloseButton = new tCloseButton();
CloseButton->setObjectName("floatingTitleCloseButton");
CloseButton->setFlat(true);
// The standard icons do does not look good on high DPI screens
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(
_this->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
CloseButton->setVisible(true);
CloseButton->setFocusPolicy(Qt::NoFocus);
_this->connect(CloseButton, SIGNAL(clicked()), SIGNAL(closeRequested()));
QFontMetrics fm(TitleLabel->font());
int Spacing = qRound(fm.height() / 4.0);
// Fill the layout
QBoxLayout *Layout = new QBoxLayout(QBoxLayout::LeftToRight);
Layout->setContentsMargins(6, 0, 0, 0);
Layout->setSpacing(0);
_this->setLayout(Layout);
Layout->addWidget(TitleLabel, 1);
Layout->addSpacing(Spacing);
Layout->addWidget(CloseButton);
Layout->setAlignment(Qt::AlignCenter);
TitleLabel->setVisible(true);
}
//============================================================================
CFloatingWidgetTitleBar::CFloatingWidgetTitleBar(CFloatingDockContainer *parent) :
QWidget(parent),
d(new FloatingWidgetTitleBarPrivate(this))
{
d->FloatingWidget = parent;
d->createLayout();
}
//============================================================================
CFloatingWidgetTitleBar::~CFloatingWidgetTitleBar()
{
delete d;
}
//============================================================================
void CFloatingWidgetTitleBar::mousePressEvent(QMouseEvent *ev)
{
if (ev->button() == Qt::LeftButton)
{
d->DragState = DraggingFloatingWidget;
d->FloatingWidget->startDragging(ev->pos(), d->FloatingWidget->size(),
this);
return;
}
Super::mousePressEvent(ev);
}
//============================================================================
void CFloatingWidgetTitleBar::mouseReleaseEvent(QMouseEvent *ev)
{
d->DragState = DraggingInactive;
Super::mouseReleaseEvent(ev);
}
//============================================================================
void CFloatingWidgetTitleBar::mouseMoveEvent(QMouseEvent *ev)
{
if (!(ev->buttons() & Qt::LeftButton) || DraggingInactive == d->DragState)
{
d->DragState = DraggingInactive;
Super::mouseMoveEvent(ev);
return;
}
// move floating window
if (DraggingFloatingWidget == d->DragState)
{
d->FloatingWidget->moveFloating();
Super::mouseMoveEvent(ev);
return;
}
Super::mouseMoveEvent(ev);
}
//============================================================================
void CFloatingWidgetTitleBar::enableCloseButton(bool Enable)
{
d->CloseButton->setEnabled(Enable);
}
//============================================================================
void CFloatingWidgetTitleBar::setTitle(const QString &Text)
{
d->TitleLabel->setText(Text);
}
} // namespace ads

View File

@@ -0,0 +1,85 @@
#ifndef FLOATINGWIDGETTITLEBAR_H
#define FLOATINGWIDGETTITLEBAR_H
/*******************************************************************************
** 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/>.
******************************************************************************/
//============================================================================
/// \file FloatingWidgetTitleBar.h
/// \author Uwe Kindler
/// \date 13.05.2019
/// \brief Declaration of CFloatingWidgetTitleBar class
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include <QWidget>
namespace ads
{
class CFloatingDockContainer;
struct FloatingWidgetTitleBarPrivate;
/**
* Titlebar for floating widgets to capture non client are mouse events.
* Linux does not support NonClieantArea mouse events like
* QEvent::NonClientAreaMouseButtonPress. Because these events are required
* for the docking system to work properly, we use our own titlebar here to
* capture the required mouse events.
*/
class CFloatingWidgetTitleBar : public QWidget
{
Q_OBJECT
private:
FloatingWidgetTitleBarPrivate *d; ///< private data (pimpl)
protected:
virtual void mousePressEvent(QMouseEvent *ev) override;
virtual void mouseReleaseEvent(QMouseEvent *ev) override;
virtual void mouseMoveEvent(QMouseEvent *ev) override;
public:
using Super = QWidget;
explicit CFloatingWidgetTitleBar(CFloatingDockContainer *parent = nullptr);
/**
* Virtual Destructor
*/
virtual ~CFloatingWidgetTitleBar();
/**
* Enables / disables the window close button.
*/
void enableCloseButton(bool Enable);
/**
* Sets the window title, that means, the text of the internal tile label.
*/
void setTitle(const QString &Text);
signals:
/**
* This signal is emitted, if the close button is clicked.
*/
void closeRequested();
};
} // namespace ads
#endif // FLOATINGWIDGETTITLEBAR_H

View File

@@ -1,26 +1,24 @@
ADS_ROOT = $${PWD}/..
ADS_OUT_ROOT = $${OUT_PWD}/..
TARGET = $$qtLibraryTarget(AdvancedDockingSystem)
CONFIG += c++14
CONFIG += debug_and_release
TARGET = $$qtLibraryTarget(qtadvanceddocking)
DEFINES += QT_DEPRECATED_WARNINGS
TEMPLATE = lib
DESTDIR = $${ADS_OUT_ROOT}/lib
QT += core gui widgets
CONFIG += adsBuildShared
adsBuildShared {
!adsBuildStatic {
CONFIG += shared
DEFINES += ADS_SHARED_EXPORT
}
!adsBuildShared {
adsBuildStatic {
CONFIG += staticlib
DEFINES += ADS_STATIC
}
windows {
# MinGW
*-g++* {
QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -Wall -Wextra -pedantic
}
# MSVC
@@ -40,10 +38,11 @@ HEADERS += \
DockWidgetTab.h \
FloatingDockContainer.h \
DockOverlay.h \
DockSplitter.h
DockSplitter.h \
DockAreaTitleBar.h \
ElidingLabel.h
SOURCES += \
ads_globals.cpp \
DockAreaWidget.cpp \
@@ -54,4 +53,23 @@ SOURCES += \
DockWidgetTab.cpp \
FloatingDockContainer.cpp \
DockOverlay.cpp \
DockSplitter.cpp
DockSplitter.cpp \
DockAreaTitleBar.cpp \
ElidingLabel.cpp
unix {
HEADERS += linux/FloatingWidgetTitleBar.h
SOURCES += linux/FloatingWidgetTitleBar.cpp
}
isEmpty(PREFIX){
PREFIX=..\installed
warning("Install Prefix not set")
}
headers.path=$$PREFIX/include
headers.files=$$HEADERS
target.path=$$PREFIX/lib
INSTALLS += headers target
DISTFILES +=

View File

@@ -25,18 +25,20 @@ ads--CDockAreaWidget #tabsMenuButton::menu-indicator
image: none;
}
ads--CDockWidgetTab
{
background: palette(window);
border-color: palette(light);
border-style: solid;
border-width: 0 1px 0 0;
padding: 0 9px;
padding: 0 0px;
}
ads--CDockWidgetTab[activeTab="true"]
{
background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:0.5, stop:0 palette(window), stop:1 palette(light));
/*background: palette(highlight);*/
}
ads--CDockWidgetTab QLabel
@@ -57,10 +59,38 @@ ads--CDockWidget
border-width: 1px 0 0 0;
}
QPushButton#closeButton,
QPushButton#tabsMenuButton
#tabsMenuButton,
#closeButton,
#undockButton
{
padding: 2px;
padding: 0px -2px;
}
QScrollArea#dockWidgetScrollArea
{
padding: 0px;
border: none;
}
#tabCloseButton
{
margin-top: 2px;
background: none;
border: none;
padding: 0px -2px;
}
#tabCloseButton:hover
{
border: 1px solid rgba(0, 0, 0, 32);
background: rgba(0, 0, 0, 16);
}
#tabCloseButton:pressed
{
background: rgba(0, 0, 0, 32);
}

View File

@@ -0,0 +1,96 @@
/*
* Default style sheet on Windows Platforms
* Note: Always use CSS-classes with and without "ads--" namespace to support Qt4 & Qt5
*/
ads--CDockContainerWidget
{
background: palette(dark);
}
ads--CDockContainerWidget QSplitter::handle
{
background: palette(dark);
}
ads--CDockAreaWidget
{
background: palette(window);
border: 1px solid white;
}
ads--CDockAreaWidget #tabsMenuButton::menu-indicator
{
image: none;
}
ads--CDockWidgetTab
{
background: palette(window);
border-color: palette(light);
border-style: solid;
border-width: 0 1px 0 0;
padding: 0 0px;
}
ads--CDockWidgetTab[activeTab="true"]
{
background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:0.5, stop:0 palette(window), stop:1 palette(light));
/*background: palette(highlight);*/
}
ads--CDockWidgetTab QLabel
{
color: palette(dark);
}
ads--CDockWidgetTab[activeTab="true"] QLabel
{
color: palette(foreground);
}
ads--CDockWidget
{
background: palette(light);
border-color: palette(light);
border-style: solid;
border-width: 1px 0 0 0;
}
#tabsMenuButton,
#closeButton,
#undockButton
{
padding: 0px -2px;
}
QScrollArea#dockWidgetScrollArea
{
padding: 0px;
border: none;
}
#tabCloseButton
{
margin-top: 2px;
background: none;
border: none;
padding: 0px -2px;
}
#tabCloseButton:hover
{
border: 1px solid rgba(0, 0, 0, 32);
background: rgba(0, 0, 0, 16);
}
#tabCloseButton:pressed
{
background: rgba(0, 0, 0, 32);
}