Compare commits

...

842 Commits

Author SHA1 Message Date
Allen Winter
8a51c31663 OBS - update for 1.1.0 release 2020-10-26 12:14:46 -04:00
Sergio Martins
a586a7894b cmake: Qt5::GuiPrivate is only needed on Windows 2020-10-26 16:14:07 +00:00
Sergio Martins
31fcbebaff ChangeLog: Add the date of 1.1 release 2020-10-26 15:29:47 +00:00
Sergio Martins
392dac5691 Use Qt::WA_PendingMoveEvent instead of Qt::WA_Moved
We check if the user provided position before putting a floating
window in a default position. Qt::WA_Moved however has the problem
that it's not cleared, so second time you show a window, it will
have it, even if user didn't set geometry.

Use Qt::WA_PendingMoveEvent instead, which was made for tracking
moves made before the first show.
2020-10-23 17:07:14 +01:00
Sergio Martins
29744c01c6 ChangeLog: Added Config::setTabbingAllowedFunc 2020-10-23 10:33:37 +01:00
Sergio Martins
49e488df24 remove roadmap from 1.1 ChangeLog
We only have it for master
2020-10-23 10:29:57 +01:00
Sergio Martins
1a3f00eac8 ChangeLog: Added HDPI improvements 2020-10-23 10:29:00 +01:00
Sérgio Martins
c6ea8d5525 ChangeLog: Remove mention to 1.0.1 release
We're releasing 1.1 asap
2020-10-23 10:23:52 +01:00
Sergio Martins
8f62004f5b cmake: Remove QTQUICK option for 1.1
Leave it in master only.
2020-10-19 21:23:44 +01:00
Sergio Martins
f698b56dad relax test
Seems to happen with 5.15 static. It's benign anyway
2020-10-16 22:02:45 +01:00
Sergio Martins
4ed18fdf1d Introduce Config::setTabbingAllowedFunc(<lambda>)
This gives a lot of power to the user to disallow tabbing two dock
widgets, while still allowing them to be docked side by side. As
this can't be achieved with affinities.

Instead of adding API which might not be enough soon, just allow
the user to pass a lambda and implement his very custom requirement.

Fixes #91
2020-10-16 21:56:33 +01:00
Sergio Martins
6e05f13c77 Added FloatingWindow::dockWidgets() 2020-10-16 21:48:47 +01:00
Sergio Martins
a146cd81b2 Fix mac tests build 2020-10-16 20:52:22 +01:00
Sergio Martins
ac6d845c8d Skip tests on macOS+offscreen if Qt <= 5.15.0
There's a bug in Qt qpa only fixed in 5.15.1
2020-10-16 20:35:04 +01:00
Allen Winter
77f259a435 README.md - contact info 2020-10-15 16:06:26 -04:00
Allen Winter
7ebc3f3533 src/DockWidgetBase.h - fix compile after merge from master 2020-10-15 12:43:29 -04:00
Renato Araujo Oliveira Filho
0ee94b425e Fixed python bindings generation 2020-10-15 12:38:32 -04:00
Allen Winter
e57b46979d buildsystem - fix installation path for Python bindings 2020-10-14 16:27:18 -04:00
Allen Winter
683b67abb0 buildsystem - install libs with symlinks for the major vers 2020-10-14 15:59:53 -04:00
Allen Winter
697c140883 set version to 1.1.0 2020-10-14 10:07:48 -04:00
Sergio Martins
819725351a Fix -Wweak-vtables warnings 2020-10-14 14:55:28 +01:00
Allen Winter
07db9f9a7a cmake/Python/FindShiboken2.cmake - clean 2020-10-13 13:23:39 -04:00
Allen Winter
77d7cd7d58 buildsystem - namespace CMake options
OPTION_DEVELOPER_MODE => KDDockWidgets_DEVELOPER_MODE
OPTION_BUILD_PYTHON_BINDINGS => KDDockWidgets_PYTHON_BINDINGS
PYTHON_BINDINGS_INSTALL_PREFIX =>
  KDDockWidgets_PYTHON_BINDINGS_INSTALL_PREFIX
OPTION_QTQUICK => KDDockWidgets_QTQUICK
2020-10-13 12:28:49 -04:00
Allen Winter
e5cb42c4fe CMakeLists.txt - improve installing to non-KDAB location 2020-10-13 11:32:12 -04:00
Allen Winter
1fe1d619a9 footer.html - update tag line 2020-10-13 11:30:14 -04:00
Sergio Martins
b00d1d80b0 Merge branch '1.0' into 1.1 2020-10-12 18:09:54 +01:00
Sergio Martins
67bb42c5b4 Fix infinite loop when updating title bar visibility
Not exactly infinite, just exponential growth or worse
Fixes #92
2020-10-12 18:09:32 +01:00
Allen Winter
f5099167b6 misspelling-- 2020-10-10 05:29:08 -04:00
Sergio Martins
17df7b5b4e Install DragController_p.h
Still private. It's for advanced used only.
2020-10-09 16:56:43 +01:00
Sergio Martins
15dc64d550 quick: Fix positioning windows when floating them
- Resizing the FloatingWindow wasn't resizing the QQuickView
- QQuickItems were being created as visible, while QWidgets are
created invisible. Fixed this difference in behaviour
2020-10-07 19:43:40 +01:00
Sergio Martins
03b575d16e quick: Fix MultiSplitter()::mainWindow()
Works now for QtQuick
2020-10-06 21:04:25 +01:00
Sergio Martins
4cacee45e8 Export MultiSplitter
Has powerful private api which could be useful
2020-10-06 11:03:52 +01:00
Sergio Martins
873b860203 ItemContainer: Make some getters public
They're decent private api for some very custom use cases
2020-10-06 10:53:15 +01:00
Sergio Martins
128ae2d889 Fix separators not being deleted
Bug found with QtQuick but also reproducible with QtWidgets.
Added unit-test for both stacks.
2020-10-05 18:25:33 +01:00
Sergio Martins
b0ec0e22e4 quick: Remove unused Separator.qml
We have one in multisplitter/ already
2020-10-05 17:34:27 +01:00
Sergio Martins
6aa4e979dc Added DockWidgetBase::hasPreviousDockedLocation() 2020-10-05 13:52:36 +01:00
Sergio Martins
36f225b859 Fix build with MinGW, no pragma link
Instead use cmake to link, which is cleaner anyway.

As a drive-by, remove the QtWidget check from the headers includes,
as QtQuick also needs Dwm lib
2020-10-05 03:15:36 -07:00
Sergio Martins
48a75b2450 Fix namespaced build 2020-10-05 10:21:20 +01:00
Sergio Martins
2af4f939dd tests|quick: Fix leak 2020-10-04 20:37:00 +01:00
Sergio Martins
b592d21064 quick: Also run tst_resizeWindow2 for QtQuick 2020-10-04 20:22:43 +01:00
Sergio Martins
3cdd5afe7a quick: Fix ownership of the floating view
Not nice to delete it in two places.
2020-10-04 20:16:30 +01:00
Sergio Martins
0ef56c1302 quick: Fix the overlay from minimizing windows being dragged 2020-10-04 19:41:26 +01:00
Sergio Martins
96f7f38a0e tests|quick: Set a source in the view, so we have a root item 2020-10-04 19:39:13 +01:00
Sergio Martins
689ba7da8f quick: Make dealing with window flags more stable
There's only one place where we need to set the flags, it's when
creating the FloatingWindowQuick. So no need to complex machinery
which is bug propne
2020-10-04 11:12:35 +01:00
Sergio Martins
951aeece6e quick: Make DockWidgetBase::setWidget() virtual
The QtQuick counter-part needs to do some specific things, like
settings anchors.parent: fill on it, and parenting it
2020-10-04 00:01:32 +01:00
Sergio Martins
2ea0d54e6c quick: Fix floating windows not having the correct window flags
Add a unit-test too.
2020-10-03 23:30:13 +01:00
Sergio Martins
1c98fe04ca Fix build 2020-10-03 23:11:40 +01:00
Sergio Martins
59a9ab6642 tests: Remove org.kde.desktop from warning blacklist
It's now solved by not using the kde QQC2 style. So no need to polute
the warning list
2020-10-03 23:07:49 +01:00
Sergio Martins
7ee5949ae2 tests|quick: Fix memory leaks 2020-10-03 23:07:04 +01:00
Sergio Martins
721f08e29b tests: Show the QQuickView and cleanit up
Also commit main.qml I forgot
2020-10-03 22:49:27 +01:00
Sergio Martins
df07133c9d tests: Silence some QML warnings from KDE theme plugin Kirigami
We don't want tests to abort because of that
2020-10-03 22:48:28 +01:00
Sergio Martins
b9e3024720 tst_common now passes for QtQuick
Needed a view
2020-10-03 22:10:38 +01:00
Sergio Martins
d848d3e39a MainWindow: Receive either QWidget or QQuickItem as parent
No need to receive the more complex adapters
2020-10-03 22:09:56 +01:00
Sergio Martins
3f26f4c8f2 Remove unused variable 2020-10-03 22:09:26 +01:00
Sergio Martins
dc9d709dd7 quick: Use proper icons for close and float
No more red rectangles
2020-10-03 18:55:33 +01:00
Sergio Martins
543f734650 Added DragController::enableFallbackMouseGrabber()
So it's easier to test the fallback mouse grabber
2020-10-03 18:37:26 +01:00
Sergio Martins
3fb723a82f quick: Fix QtQuick build 2020-10-03 18:27:22 +01:00
Sergio Martins
71c2f34ed4 quick: Add needed pure virtual FrameQuick::renameTab()
Not needed to have much of an impl, it's just to fix the build.
For QtQuick the tab's titles are updated via bindings
2020-10-03 18:15:56 +01:00
Sergio Martins
d4b3bf9de6 quick: Added support for showMinimized() 2020-10-03 18:11:33 +01:00
Sergio Martins
2b234f313c quick: Remove some QWidget specific code from MainWindowBase 2020-10-03 18:10:23 +01:00
Sergio Martins
d1b2d17f7d Allow the normal/restore icon to be different than float/dock
Allow we use the same icon, the user might now want to, so allow
them to use a different icon
2020-10-03 14:58:07 +01:00
Sergio Martins
f062ab7a64 TitleBar: Move button construction into the FrameWorkWidgetFactory
So it can be more easily overridden by the user.
A virtual in TitleBarWidget is not good enough as we can't call virtuals
when in the ctor
2020-10-03 14:52:44 +01:00
Sergio Martins
f009f57581 Move TitleBarButtonType next to all other enums 2020-10-03 14:29:36 +01:00
Sergio Martins
f86a818e69 TitleBar: Add an enum to describe each button type 2020-10-03 14:24:40 +01:00
Sergio Martins
bb80c2158d Fix outter_bottom_active.png
Was missing an outline for some reason
2020-10-03 13:57:32 +01:00
Sergio Martins
86fa6258f6 Comment++ 2020-10-03 13:56:51 +01:00
Sergio Martins
545536fab5 Support high-res icons when on 1.5x scaling and Qt >= 5.15.2
Icons look nice now on linux with 1.5x. Windows and macOS don't use
fractional scaling, so not affected

Fixes #11

Will open a separate bug report to get high-res docking indicators.
2020-10-03 13:21:06 +01:00
Sergio Martins
ef23553b66 Fix high-res unauto-hide icon
We had it but we were still using the old one in C++
2020-10-03 12:04:39 +01:00
Sergio Martins
fcf56664cc Add high-res icons for minimize and maximize 2020-10-03 11:50:33 +01:00
Sergio Martins
d932166bcd Add high-res icons for dock/float 2020-10-03 11:43:15 +01:00
Sergio Martins
0c5783774d Added high-res close icon 2020-10-03 11:38:26 +01:00
Sergio Martins
aa42ea15f7 Add high-res versions for auto-hide and unauto-hide png
1.5x is disabled for now, as Qt < 5.15.2 has a rounding bug
rendering them
2020-10-03 11:28:21 +01:00
Sergio Martins
9dd778d55d Pass the correct icon size when rendering a button
Needed when rendering with different scaling
2020-10-03 10:57:54 +01:00
Sergio Martins
ac35a919f4 Don't show center/tab docking indicator when there's no affinity
If the dock widget can't dock there as tabbed, don't show the
indicator
2020-10-02 17:35:15 +01:00
Sergio Martins
a32c5017e6 Minor: Remove unneeded variable 2020-10-02 17:24:50 +01:00
Sergio Martins
7995a6d13b Windows: Fix dragging sometimes not showing indicators
DragController thought there was a resize going on.
The hardcoded margins in FloatingWindow::isInDragArea() arent
needed anymore.

iPlease enter the commit message for your changes. Lines starting
2020-10-02 17:05:16 +01:00
Sergio Martins
d4ec2eec88 Windows: Added support for drop shadow for floating windows 2020-10-01 18:31:46 +01:00
Sergio Martins
12ad3b3484 Fix floating window's border, was appearing black
QPen was unused
2020-10-01 18:22:07 +01:00
Sergio Martins
9a53c36c14 Also honour affinities when dropping into a dock widget as tabbed
Fixes #89
2020-10-01 17:55:19 +01:00
Sergio Martins
8fb3802343 tests: Add an xfail for an affinities bug
This is for #89. They shouldn't be allowed to tab
together since they have different affinities

Minor refactoring in drop area so we can call DropArea::drop()
directly without having to move the mouse, as that's not relevant
for this test.
2020-10-01 17:45:53 +01:00
Sergio Martins
c035df7e85 Improve the heuristics for auto-hide prefered side bar
Now it counts the number of borders it's touching to decide.
Then checks aspect ratio too.

Can still be improved, but it's a start. Will gather feedback
before changing it further.
2020-10-01 17:16:41 +01:00
Sergio Martins
92f81e28ca Merge branch '1.0' into master 2020-10-01 11:08:39 +01:00
Sergio Martins
7a87db608b README: Updated build instructions
use cmake to call the generator, this way it's generic and
works with any generator
2020-10-01 11:07:11 +01:00
Sergio Martins
d42fb81790 Windows: Fix artifacts when dragging window to another screen
Qt does its best to honour our custom WM_NCCALCSIZE processing,
except when the window moves to another screen. So help Qt a bit
and trigger a WM_NCCALCSIZE message, which Qt intercepts and takes
notes of the custom margins.

Fixes #46
2020-09-30 22:12:40 +01:00
Sergio Martins
73934e2f90 Always call FloatingWindow::create() in the CTOR
0x051000 was a typo, as it's Qt 5.16, not 5.10.
Since it's been running fine for 5.15 for so long, let's remove
special cases and have the same path for all Qt versions.
2020-09-30 22:07:07 +01:00
Allen Winter
1c8642298b src/private/multisplitter/Item.cpp - fix compile with msvc2013
might be choking on the QStringLiteral being a lambda
used into a [] ??
2020-09-30 12:51:02 -04:00
Allen Winter
bfc45bb0e9 tst_multisplitter.cpp - add braces to make msvc2013 happy
Change-Id: I562a8b14c9c6713fc15116397b5c215138a0c9cb
2020-09-30 12:50:03 -04:00
Allen Winter
58af9e2516 tst_multisplitter.cpp - add braces to make msvc2013 happy
Change-Id: I562a8b14c9c6713fc15116397b5c215138a0c9cb
2020-09-30 09:25:01 -04:00
Sergio Martins
4228c044ea Fix false-positive caught by Coverity
It's benign
2020-09-30 10:58:36 +01:00
Sergio Martins
ccc0aec968 Remove some dead code which is no longer used 2020-09-30 10:39:04 +01:00
Sergio Martins
3718d3fe79 Silence false-positive pointed out by Coverity 2020-09-30 10:33:58 +01:00
Sergio Martins
26ed9b722b Don't allow to turn off native dragging on Windows
Native dragging is much better as Windows deals with crossing screen
boundaries, there's no reason not to want that.

Client-side moving is buggy within Qt, depending on the HDPI setting.

Fixes #86
Fixes #78
2020-09-30 09:01:09 +01:00
Sergio Martins
6751669249 Fix flaky test on 5.14, it's benign 2020-09-29 23:21:36 +01:00
Sergio Martins
c7955dce1e Update ChangeLog and README
1.1 is due out soon, won't have QtQuick yetx
2020-09-29 21:10:47 +01:00
Sergio Martins
2e432f402f Also update floating action when removing from a FloatingWindow
Fixes #79
2020-09-29 21:05:45 +01:00
Sergio Martins
07791cd901 Fix another case where floating actions weren't updated
Relates to issue #79
2020-09-29 20:50:02 +01:00
Sergio Martins
1458da92d9 minimal example: Use fusion too
Looks better in general
2020-09-29 18:10:12 +01:00
Sergio Martins
c56f998292 Use Qt::MitterJoin when drawing rectangle
As it's not the default. Otherwise there's artifacts with hdpi scaling
2020-09-29 13:38:44 +01:00
Sergio Martins
991075d69e Windows: Start a native drag as soon as possible
Native drag works much better with HDPI crossing screens.
Relates to issue #78
2020-09-29 12:39:10 +01:00
Sergio Martins
234ca75728 tests: minor: Use QCOMPARE instead of QVERIFY 2020-09-28 22:10:00 +01:00
Allen Winter
e34d62d3e5 src/private/multisplitter/Item.cpp - fix compile with msvc2013
might be choking on the QStringLiteral being a lambda
used into a [] ??
2020-09-28 16:49:59 -04:00
Allen Winter
423be28afd various - misspelling-- 2020-09-28 16:40:27 -04:00
Sergio Martins
eb7bed9601 Fix build with -Werror 2020-09-28 19:00:40 +01:00
Sergio Martins
fa09521012 Adjust unit-test, according to the latest change 2020-09-28 18:55:55 +01:00
Sergio Martins
bb30f322a3 Fix size when docking a floating window
The docked widget would have the size of the window's contents,
we should use the size of the floating window instead.

The difference is just the title bar. When docked, the title bar
belongs do Frame, while when Floating it belongs to FloatingWindow.
When doing the docking calculation the frame's title bar is still hidden

Fixes issue #84
2020-09-28 18:47:46 +01:00
Sergio Martins
0e35c93ae5 Update ChangeLog 2020-09-27 18:02:56 +01:00
Sergio Martins
603224e553 FrameWidget: Fix painting the border on HDPI
Work in floating point instead of int.
2020-09-27 18:00:15 +01:00
Sergio Martins
9b82063d52 Fix drawing the FloatingWindowWidget border on HDPI
left and top margins were smaller than bottom and right.
2020-09-27 17:49:29 +01:00
Sergio Martins
c210a523e3 Focus the newly dropped dock widget
When we drag a dock widget into a another widget, we should focus it

Fixes issue #77
2020-09-26 17:44:30 +01:00
Sergio Martins
e33151d482 Add a failing test for issue #77 2020-09-26 17:15:46 +01:00
Sergio Martins
835f67a106 Mark DropArea::drop() as private
It's an implementation detail
2020-09-26 17:08:23 +01:00
Sergio Martins
a50f6ec602 Added DockWidgetBase::isFocused Q_PROPERTY
For GammaRay convenience. For QML too.
The getter and signal already existed.

For issue #73
2020-09-25 19:35:28 +01:00
Sergio Martins
4a49dbc6b4 Add a DockWidget::isFloatingChanged() signal
For issue #73
2020-09-25 19:25:58 +01:00
Sergio Martins
05c843397b Add one more test
tabbed dock widget aren't floating either
2020-09-25 18:32:06 +01:00
Sergio Martins
e4871eb340 Fix floating action not being triggered in some cases
When docking a dock widget into a floating widget, then both
are not "floating" anymore, as there's two of them in the layout

Fixes #79
2020-09-25 18:28:32 +01:00
Sergio Martins
0e696ff2dd FloatingWindow: Also use margin when using aero-snap
It's always good to have contents margin. Initially the idea was
that we were adding margin just to make the client resize handler
work better. But no reason to have different visual aspect depending
on if you have aero-snap or not

Fixes applications needing to look the same on all platforms.
2020-09-25 11:23:03 +01:00
Sergio Martins
9f15773a9b Fix dragging by tabbar if there's a line edit in the tab bar
User was able to drag and line edit wouldn't get focus.
This is a hot fix, not the most elegant way to do it.
2020-09-25 11:02:35 +01:00
Sergio Martins
a00984f95a Fix potential crash at shutdown
QWidget DTOR can trigger a focus change, which triggers
DockRegistry::onFocusObjectChanged(), which would dereference the
dockwidget
2020-09-24 16:05:38 +01:00
Allen Winter
c7e9632f18 src/MainWindow.cpp - minor header order 2020-09-22 11:22:40 -04:00
Sergio Martins
7080712501 Rename the tab's title if its dock widget changes 2020-09-21 16:19:35 +01:00
Sergio Martins
03b574434c Fix non-developer build
Fixes #76
2020-09-21 10:07:04 +01:00
Sergio Martins
6a46744073 Make Flag_AutoHideSupport public
Ready to be tested by the public
2020-09-21 00:19:20 +01:00
Sergio Martins
7e52c510b3 Fix rendering vertical sidebars on scaled monitors 2020-09-21 00:14:09 +01:00
Sergio Martins
9bf060af9a SideBar: Support sending to West/East too
Algorithm can be made smarter, but this is good for now
2020-09-20 23:53:26 +01:00
Sergio Martins
b5973fcf8c Fix sidebar test
We're not hidding them, they just occupy 0 it seems
2020-09-20 23:50:46 +01:00
Sergio Martins
ac7d06d4fe When closing overlay, remove it from side bar too
Added test.
2020-09-20 23:46:37 +01:00
Sergio Martins
75e9137e3a Increase a bit the side of the overlays 2020-09-20 23:18:46 +01:00
Sergio Martins
5168940422 When enabling auto-hide, don't overlay it immediately
Instead, hide it. Will be overlayed when the user toggles it.
2020-09-20 23:16:40 +01:00
Sergio Martins
cfd2dafa53 Remove bogus debug 2020-09-20 23:15:01 +01:00
Sergio Martins
188b0a0edd Don't style side-bar buttons of overlayed widgets
As mouse-over is already using the same color. Would be nice
to have some different style for the currently overlayed window.
2020-09-20 23:09:33 +01:00
Sergio Martins
206c418ebc Make TitleBarWidget::buttonAreaWidth() generic
Nowadays we have much more buttons
2020-09-20 22:59:25 +01:00
Sergio Martins
b0acf8d1ae Disable floating button when using auto-hide
TitleBar is a bit crowded otherwise. User can still pass
& ~Flag_TitleBarNoFloatButton if he really wants both buttons.
2020-09-20 22:54:51 +01:00
Sergio Martins
f279ea41e6 Add tooltips to title bar buttons 2020-09-20 22:43:10 +01:00
Sergio Martins
d2a929f35d Minor whitespace fix 2020-09-20 22:26:51 +01:00
Sergio Martins
6f5258b5dd Add auto-hide iconsz 2020-09-20 22:25:56 +01:00
Sergio Martins
4f223a9439 Change color of active/hovered SideBarButton 2020-09-20 20:59:54 +01:00
Sergio Martins
ea98eb3d44 Restyle the StyleBarButtons a bit 2020-09-20 20:30:40 +01:00
Sergio Martins
cdb8f85620 Fix overlay positions when on left/right
Was off by a few pixels, looks good now
2020-09-20 19:37:53 +01:00
Sergio Martins
f459dcb8b3 length of overlayed dockwidgets now accounts for open sidebars
For example, if we're showing a bottom overlay, but the left
sidebar is visible, then the bottom overlay can't be so wide
2020-09-20 19:20:35 +01:00
Sergio Martins
967a539e71 Simplify SideBarButton::sizeHint() 2020-09-20 19:08:52 +01:00
Sergio Martins
db615da0ee Override from QToolButton to have our own SideBarButton
Has proper size when vertical.
Text isn't vertical yet though.
2020-09-20 19:06:47 +01:00
Sergio Martins
c4b420bd31 Add a fwd-header for SideBarWidget too 2020-09-20 18:09:54 +01:00
Sergio Martins
a6c4730c44 SideBar is now constructed by the framework widget factory
Means it can be overridden by the user
2020-09-20 18:08:23 +01:00
Sergio Martins
eb1f4c5a14 Auto-hide overlays when clicking elsewhere
That's what auto-hide is all about
2020-09-20 17:25:40 +01:00
Sergio Martins
b303af738c Improve position for north/south overlays 2020-09-20 16:56:57 +01:00
Sergio Martins
af5e11a265 Update the overlay's geometry when we resize the main window 2020-09-20 16:38:03 +01:00
Sergio Martins
8d7627069c Factor out some code into updateOverlayGeometry()
So it's reusable
2020-09-20 16:30:43 +01:00
Sergio Martins
9e94c0d67d The auto-hide button now works as expected
1st click it show the overlay and adds to sidebar
2nd click it hides the overlay, removes from sidebar and restores the dockwidget
2020-09-20 14:13:39 +01:00
Sergio Martins
55ddacf978 Partially revert previous commit
toggling overlay visibility won't remove it from the sidebar afterall.
User will need to explicitly press the auto-hide button
2020-09-20 13:56:52 +01:00
Sergio Martins
005e0552b6 Delete SideBarButton when dock widget is removed from sidebar 2020-09-20 13:53:49 +01:00
Sergio Martins
54b28c42e2 Added DockWidgetBase::isOverlayed() 2020-09-20 13:48:17 +01:00
Sergio Martins
2659ddb76b refactor: Decouple moveToSideBar from overlaying
overlaying just shows/hides the overlay, and not requires
the dock widget was added to the sidebar before
2020-09-20 13:44:04 +01:00
Sergio Martins
c85873c6ce Added MainWindowBase::sideBarForDockWidget(dw)
Just a getter.
2020-09-20 13:24:18 +01:00
Sergio Martins
6e32f3f915 Added SideBar::mainWindow()
It's just a getter.
2020-09-20 13:18:34 +01:00
Sergio Martins
b8891a5727 Start implementing overlaying on top of main window 2020-09-20 12:56:31 +01:00
Sergio Martins
fcb6f5a6af Use the top sidebar too 2020-09-19 12:16:51 +01:00
Sergio Martins
0365f3194d Added Item::adjacentLayoutBorders() 2020-09-19 11:50:00 +01:00
Sergio Martins
76e2ec6429 Add East, West and North sidebars too
Instead of just south.
Only south is used for now though.
2020-09-19 11:00:42 +01:00
Sergio Martins
a5d0a202a5 Add enum with sidebar location 2020-09-19 10:35:36 +01:00
Sergio Martins
def752632f tests: fix flaky test on macOS 2020-09-19 00:08:47 +01:00
Sergio Martins
f296048063 tests: Stabilize two tests on XCB
Spacings/margins are different. Anyway, that QVERIFY isn't
very important, mostly useless.
2020-09-18 23:44:34 +01:00
Sergio Martins
1c1b816292 Fix tst_maximumSizePolicy with qpa xcb 2020-09-18 23:28:14 +01:00
Sergio Martins
fbd463e18b tests: debug++ 2020-09-18 19:42:26 +01:00
Sergio Martins
9e01363648 tests: debug++ 2020-09-18 19:40:37 +01:00
Sergio Martins
67bf7e9775 tst_raise: raise the window before starting
needed on macOS
2020-09-18 19:34:09 +01:00
Sergio Martins
d8c2100b24 tests: Set object name for debugging 2020-09-18 19:30:28 +01:00
Sergio Martins
d1a3e39f17 tests: Improve debug message 2020-09-18 19:27:17 +01:00
Sergio Martins
3d5c081333 tests: Debugging a macOS failure 2020-09-18 19:24:49 +01:00
Sergio Martins
e1085fb770 Add experimental support for minimization to side-bar
Auto-hide not working yet. Just minimization.
Internal for now. Will be public once finished.
2020-09-18 18:35:41 +01:00
Sergio Martins
c294c19be7 Fix Frame having a null DropArea
Fixes inMainWindow() signal not being emitted sometimes
2020-09-18 18:34:49 +01:00
Sergio Martins
87726fb0a7 Minor style: Reduce nesting level in Frame::setDropArea() 2020-09-18 18:34:28 +01:00
Sergio Martins
d28e61f412 Minor tidying 2020-09-18 17:48:31 +01:00
Sergio Martins
890e750c23 Trying to fix Windows/MinGW build 2020-09-18 17:48:04 +01:00
Sergio Martins
1fe5cfd121 Added Frame::mainWindow() 2020-09-18 17:40:38 +01:00
Sergio Martins
c8eaf88cf1 Added DockWidgetBase::mainWindow() 2020-09-18 17:20:41 +01:00
Sergio Martins
f3f812205d Pass the new title to DockWidget::titleChanged() signal 2020-09-18 17:12:38 +01:00
Sergio Martins
7b2ec52831 Fix build on 5.9/mingw 2020-09-18 16:59:01 +01:00
Sergio Martins
72785cf869 Updated ChangeLog and README with new features and bugfixes 2020-09-17 21:54:36 +01:00
Sergio Martins
e92ef472b3 Floating windows now support a minimize button
Introduced Flag_TitleBarHasMinimizeButton for it.
It implies Flag_DontUseUtilityFloatingWindows too, since Qt::Tool
don't appear in the task bar.

example: kddockwidgets_example -k
2020-09-17 21:46:28 +01:00
Sergio Martins
deec6ffa31 Windows: Fix windows have 0 min-size
Also tested on HDPI configurations and added the device pixel ratio
into account, as Windows works in native pixels
2020-09-17 18:37:13 +01:00
Sergio Martins
47779c8d0a Fix non-native move screwing up the size when moving across screens
The drag to the 2nd monitor was native, as we detected HTCAPTION,
but the drag back to 1st monitor was non-native. Non native is not
recommended, not great with HDPI in Qt.

The bug we were mixing native pos from win32 with Qt's logical
positions.

Fixes #72
2020-09-17 09:43:38 +01:00
Allen Winter
3e9e802b6c buildsystem - do not build docs by default 2020-09-16 16:04:18 -04:00
Allen Winter
8bd429db4c buildsystem - do not build docs by default 2020-09-16 16:03:31 -04:00
Sergio Martins
d76b27863f Don't center floating window if user moved it
Fixes #75
2020-09-16 16:51:05 +01:00
Sergio Martins
576627eb17 Always outter indicators if the center is obscured with something else
If there's some other floating window over our drop zone, then it's
very difficult to drop if there's no outter indicators.

Now we'll show the outter indicators if we suspect there's some other
window obscuring
2020-09-16 12:54:09 +01:00
Sergio Martins
74adb5f021 Fix floating window's title bar not being correct
FloatingWindow::hasSingleFrame() was true, but FloatingWindow::frames()
returned 2 of them, since frames() is based on child count and it hadn't
been reparented yet

Not commiting to 1.0 since it touches the layouting engine.
All tests pass and testing showed no side effects though, so should be fine for
1.0 too

Fixes #74
2020-09-15 19:52:48 +01:00
Allen Winter
dcdcef1fb2 Merge branch '1.0' 2020-09-15 08:45:20 -04:00
Allen Winter
cf7311682e images - add svg version of logo. update other png's 2020-09-15 08:44:37 -04:00
Sergio Martins
beb2128804 example: Added --no-aero-snap for debugging purposes 2020-09-14 22:28:15 +01:00
Sergio Martins
85cb289bc4 Also focus when clicking on the current tab
Fixes issue #71
2020-09-14 21:08:48 +01:00
Sergio Martins
5293943a50 Add TabBar::frame()
Returns the Frame this TabBar is in.
2020-09-14 21:07:51 +01:00
Sergio Martins
ee4d720c51 Added test for issue #71 2020-09-14 20:54:35 +01:00
Allen Winter
f8b698e669 Merge branch '1.0' 2020-09-13 09:41:53 -04:00
Allen Winter
0e3fcc7749 update home page URL 2020-09-13 09:29:36 -04:00
Allen Winter
5755e5ff65 Doxygen - add product logo to page header and footer 2020-09-13 09:16:23 -04:00
Allen Winter
d9db3d0b29 images - add logo and banner images 2020-09-13 09:14:04 -04:00
Sergio Martins
87ba2e0ee7 example: Add option to test combinations of Qt::Tool and parent
for internal testing
2020-09-13 13:30:55 +01:00
Sergio Martins
eaeed567f3 Don't have a parent window when using Qt::Window
Otherwise Qt::Window behaves like Qt::Tool, on Windows
2020-09-13 13:22:48 +01:00
Sergio Martins
a2054359a2 Minor code move, so next diff is short 2020-09-13 12:48:25 +01:00
Sergio Martins
85b533d4c4 Minor code move 2020-09-13 12:47:04 +01:00
Sergio Martins
2d2c8524ee Introduce Config::Flag_DontUseUtilityWindowsForFloating
Controls whether windows get Qt::Tool or not
2020-09-13 12:24:26 +01:00
Sergio Martins
62271b11a7 Update .gitignore 2020-09-13 12:12:13 +01:00
Sergio Martins
869cacc568 Use mouse events for tst_titleBarFocusedWhenTabsChange
So we can test clicking on a current tab too.
Also since changing tabs programatically shouldn't change focus,
which I'll fix soon
2020-09-12 00:39:10 +01:00
Sergio Martins
0155790b02 tests: add Test::clickOn() 2020-09-12 00:33:34 +01:00
Sergio Martins
2cb25fefe4 Minor: Add the tab widget as a member 2020-09-11 23:40:41 +01:00
Sergio Martins
98225ac9a3 Fix DockWidget::isInMainWindow()
FloatingWindows are parented to the main window, so we need to stop
the loop once isWindow().

The tests didn't catch this because the floating window in the test
was created before the main window, so it truly didn't have a parent

Fixes #69
2020-09-11 22:33:25 +01:00
Sergio Martins
4bdfc35c8c Changing tabs should also activate our focus scope
Fixes #70
2020-09-09 21:03:00 +01:00
Sergio Martins
f090a51485 example: Make title bar focusable when debugging focus 2020-09-07 20:26:09 +01:00
Sergio Martins
b510c2fd5f Added DockWidget::isInMainWindow()
For task #69.
A signal would be nice too, though.
2020-09-07 15:27:54 +01:00
Sergio Martins
03e58c7443 update change log regarding issue #68 2020-09-04 17:17:23 +01:00
Sergio Martins
676086ba90 Update .gitignore 2020-09-04 17:17:23 +01:00
Sergio Martins
4f6b9e3dff update change log regarding issue #68 2020-09-04 17:16:00 +01:00
Allen Winter
c8a5bd3f15 .../quick/qml/ClassicIndicator.qml - license+copyright header 2020-09-04 12:15:31 -04:00
Sergio Martins
5e83ddf7bd Update .gitignore 2020-09-04 17:13:58 +01:00
Sergio Martins
6b28a804f8 example: Allow to demo the focus scope
set KDDW_DEBUG_FOCUS
2020-09-04 17:06:32 +01:00
Allen Winter
7c5e159677 Merge branch '1.0' 2020-09-03 18:55:08 -04:00
Allen Winter
63f8468f48 cmake/Python - don't require pkg-config, only use if available.
Issue#68
2020-09-03 18:14:14 -04:00
Allen Winter
933a535494 Merge branch '1.0' 2020-09-03 08:08:55 -04:00
Allen Winter
518a7cb398 Changelog - fix typo 2020-09-03 08:08:14 -04:00
Allen Winter
eac2cff09c Merge branch '1.0' 2020-09-03 08:07:47 -04:00
Allen Winter
9a601a5172 CMakeLists.txt, Changelog - bump to 1.0.1 2020-09-03 08:06:12 -04:00
Allen Winter
cf8f25988c Merge branch '1.0' 2020-09-03 07:58:52 -04:00
Allen Winter
a613e401e2 ready for 1.0.0 release 2020-09-02 12:29:58 -04:00
Sergio Martins
23e27ee953 Add 1.0 release date to the ChangeLog 2020-09-02 17:27:51 +01:00
Allen Winter
633dc06e6f Merge branch '1.0' 2020-09-02 11:54:06 -04:00
Allen Winter
5ddf0ada76 Changelog - reorder versions 2020-09-02 11:50:53 -04:00
Allen Winter
c8664c4d44 cmake/Python/* - sync with the KDAB toolbox 2020-09-02 11:11:29 -04:00
Allen Winter
d6d28b3f7b src/DockWidgetBase.h - minor spelling fixes 2020-09-02 11:11:06 -04:00
Allen Winter
eddcfef5d8 Merge branch '1.0' 2020-08-31 18:19:44 -04:00
Allen Winter
737d63eede CMakeLists.txt - document PYTHON_BINDINGS_INSTALL_PREFIX 2020-08-31 18:19:20 -04:00
Allen Winter
ba3890acfa Merge branch '1.0' 2020-08-31 13:22:24 -04:00
Allen Winter
9e8353f50f cmake/Python/PySide2ModuleBuild.cmake - another fix for Mac 2020-08-31 12:11:33 -04:00
Renato Araujo Oliveira Filho
2db4398637 Python/PySide2ModuleBuild.cmake - fix for Windows build 2020-08-31 11:19:04 -04:00
Allen Winter
1348434b50 docs/api/Doxyfile.cmake - remove CLANG options
to quiet the doxygen warnings:
"belongs to an option that was not enabled at compile time."
2020-08-31 11:15:47 -04:00
Renato Araujo Oliveira Filho
4ebf60a9c8 Python/PySide2ModuleBuild.cmake - fix for Mac frameworks 2020-08-31 10:53:03 -04:00
Sergio Martins
6cf527403e Merge branch '1.0' into master 2020-08-30 17:53:04 +01:00
Sergio Martins
d738f6f43f Fix Config::Flag enumerators with the same value 2020-08-30 17:52:01 +01:00
Sergio Martins
92843b4972 Merge branch '1.0' into master 2020-08-30 14:46:28 +01:00
Sergio Martins
ae000e75bc Allow DockWidget::setWidget() to be called multiple times
Fixes #66
2020-08-30 14:43:12 +01:00
Allen Winter
e017438605 FindShiboken2.cmake - fix finding the library on MacOS 2020-08-28 18:40:19 -04:00
Allen Winter
bcd29f1dcc README.md - improve python bindings instructions 2020-08-28 12:14:32 -04:00
Allen Winter
b2df16dcb0 Merge branch '1.0' 2020-08-27 12:23:38 -04:00
Allen Winter
9903780792 kddockwidgets.spec - improve description text 2020-08-27 12:17:15 -04:00
Sergio Martins
8bb15f5447 Updated ChangeLog 2020-08-27 15:30:17 +01:00
Sergio Martins
2977f0b8c6 Introduce Config::Flag_AlwaysTitleBarWhenFloating
Allows to improve on Flag_HideTitleBarWhenTabsVisible.

Flag_HideTitleBarWhenTabsVisible will hide title bar regardless
if the window is floating or docked. By enabling Flag_AlwaysTitleBarWhenFloating
the title bar will only be hidden if docked.

Demo: ./bin/kddockwidgets_example -qt

Fixes #64
2020-08-27 15:14:55 +01:00
Sergio Martins
251423116f Merge branch '1.0' into master 2020-08-27 14:54:18 +01:00
Sergio Martins
5a66d09266 example: Decouple Flag_HideTitleBarWhenTabsVisible from Flag_AlwaysShowTabs
New swtich -z will trigger Flag_AlwaysShowTabs.
use -zt for what was -t before.

This is more granular now, as they are mix and match
2020-08-27 14:52:48 +01:00
Sergio Martins
04e2a71b66 Merge branch '1.0' into master 2020-08-25 22:00:25 +01:00
Sergio Martins
e3f89b6c17 Remove unneeded include 2020-08-25 21:57:55 +01:00
Sergio Martins
9d8587aa40 Remove empty file 2020-08-25 21:56:23 +01:00
Sergio Martins
a06fec51c8 Merge branch '1.0' into master 2020-08-25 21:54:32 +01:00
Sergio Martins
4b4d839074 Expose more private API so users can use the full power
Installed more private headers.
TabWidget_p.h was moved into widgets/ as the QtQuick impl won't
use that abstraction. Could even be folded into TabWidgetWidget.

Fixes #65
2020-08-25 21:46:46 +01:00
Sergio Martins
83eda81263 Minor code simplification 2020-08-24 17:58:42 +01:00
Sergio Martins
1bb476ca95 Merge branch '1.0' into master 2020-08-24 14:38:06 +01:00
Sergio Martins
1c65b3e453 Remove examples/qtquick from the 1.0 branch
Should be in master only
2020-08-24 14:36:30 +01:00
Sergio Martins
70a4ca6533 Updated README with the new features 2020-08-24 14:35:07 +01:00
Sergio Martins
073647cf79 Add a minimal example
The other example is getting too big. Minimal is best to get
started
2020-08-24 13:49:56 +01:00
Sergio Martins
f0ac455ec1 Allow the window being dragged to be transparent 2020-08-23 17:44:57 +01:00
Sergio Martins
44b2fc6944 indicators: Improve style for segmented indicators 2020-08-23 17:23:37 +01:00
Sergio Martins
113e6453ea example: Show usage of segmented indicators 2020-08-23 16:57:48 +01:00
Sergio Martins
283d814dc6 indicators: Also install the headers
So that the example app can show how to switch style type
2020-08-23 16:43:54 +01:00
Sergio Martins
034dc25483 indicators: Remove type()
There's no point in using it
2020-08-23 16:22:21 +01:00
Sergio Martins
b1333b2c4c ChangeLog: Update the changelog for 1.1 2020-08-23 13:52:16 +01:00
Sergio Martins
ff58ff72f9 Merge branch '1.0' into master 2020-08-23 13:47:52 +01:00
Sergio Martins
90da74b211 ChangeLog: Fill in the changes for 1.0 2020-08-23 13:46:29 +01:00
Sergio Martins
fbe88f7b99 ChangeLog: Remove the mention to 1.1
Since we're on 1.0 branch
2020-08-23 13:34:29 +01:00
Sergio Martins
05276999ad ChangeLog: Fix dates and versions
1.0 wasn't released yet
2020-08-23 13:34:11 +01:00
Sergio Martins
00b4dbc821 Add a Segmented Indicator
Just a POC of a new indicator style
2020-08-23 13:24:27 +01:00
Sergio Martins
35076bbdb6 indicators: Update the indicator's visibility in the base class
So derived classes don't have to.
Doesn't affect ClassicIndicators, since it uses a separate
window for them. But useful for new indicator types.
2020-08-22 19:58:45 +01:00
Sergio Martins
2dc98804f4 qml|indicators: Use frame geometry instead of frame rect
The rect is always at 0,0, not very useful.
2020-08-22 19:53:20 +01:00
Sergio Martins
961600fe74 qtquick: fix build
MainWindow.h is specific to QtWidgets
2020-08-22 19:19:59 +01:00
Sergio Martins
7fdca76a4c indicators: Use enum class for the type 2020-08-22 19:16:24 +01:00
Sergio Martins
32592f6ad1 classic indicators: Remove unneeded hidding in ctor
Already done in base class
2020-08-22 19:13:26 +01:00
Sergio Martins
1545e98e6d Merge branch '1.0' into master 2020-08-22 18:58:42 +01:00
Sergio Martins
a1c473fb0e Override QMainWindow::setCentralWindow() to make it private
The central widget is used internally by KDDW to make all of this
possible. It shouldn't be used by users
2020-08-22 17:03:55 +01:00
Allen Winter
85b3feb10b Merge branch '1.0' 2020-08-15 10:15:26 -04:00
Allen Winter
721b4de55e .krazy - add checks 2020-08-15 10:14:53 -04:00
Sergio Martins
d9fdd20caa Add DockWidgetBase::isFocusedChanged
Fixes: #60
2020-08-15 00:46:41 +01:00
Sergio Martins
9e2d001ac5 Add DockWidget::isFocused() for issue #60
Needs a signal now
2020-08-14 23:51:35 +01:00
Sergio Martins
750f9b6142 tests: Add strong-focus to the widget 2020-08-14 23:00:14 +01:00
Sergio Martins
1c3cf8cf2d Merge branch '1.0' into master 2020-08-14 18:47:42 +01:00
Sergio Martins
f1b9ce714b Fix building user apps out of repo
Our example was being built as part of KDDW, so that worked fine.
Now it can also be built with an installed KDDW.

Problem was the folder hiearchy in the installed include dir
didn't match the folder hiearchy in the source repo

Fixes #62

Cherry-picked from master's 037fa76fff
1.0 makes more sense
2020-08-14 18:47:03 +01:00
Sergio Martins
db19cb40d7 Merge branch '1.0' into master 2020-08-14 18:30:00 +01:00
Sergio Martins
2b0a426135 Fix crash if a FloatingWindow gets a native event too late
If delete is already scheduled and the multisplitter is already gone
we shouldn't handle the native event anymore

Fixes #63
2020-08-14 18:29:38 +01:00
Sergio Martins
369a020d81 readability: Rename m_beingDeleted to m_deleteScheduled 2020-08-14 18:29:38 +01:00
Sergio Martins
037fa76fff Fix building user apps out of repo
Our example was being built as part of KDDW, so that worked fine.
Now it can also be built with an installed KDDW.

Problem was the folder hiearchy in the installed include dir
didn't match the folder hiearchy in the source repo

Fixes #62
2020-08-14 17:49:24 +01:00
Sergio Martins
caa2ece751 qml: Move the 1st test from tst_docks to tst_common 2020-08-13 00:46:55 +01:00
Sergio Martins
22f2975f3c tests: createMainWindow() works for qml now too 2020-08-13 00:46:55 +01:00
Sergio Martins
d3323d824a tests: Make createMainWindow return MainWindowBase
Instead of QMainWindow, so it works with qml too
2020-08-13 00:46:55 +01:00
Allen Winter
41d1ea8f61 various fixes for the OBS config 2020-08-12 18:07:40 -04:00
Allen Winter
b1b5cd169a various fixes for the OBS config 2020-08-12 18:06:07 -04:00
Sergio Martins
1e85b1e7fb tests: Share EnsureTopLevelsDeleted with qml too
So we can start to copy tests to tst_common without hacking them
2020-08-12 22:45:59 +01:00
Sergio Martins
75464708af Remove unneeded debug 2020-08-12 22:00:23 +01:00
Sergio Martins
f007451442 Fix case where floatAction() wouldn't trigger
Fixes #58
2020-08-12 21:21:04 +01:00
Allen Winter
f591270d46 CMakeLists.txt - increase numbers. this will be v1.1 some day 2020-08-12 13:00:35 -04:00
Allen Winter
390423d0c1 Merge branch '1.0' 2020-08-12 12:59:09 -04:00
Allen Winter
5061620f46 kddockwidgets.spec - build requires qt5-qtx11extras-devel 2020-08-12 12:55:22 -04:00
Allen Winter
23ee5d538c buildsystem - install versioned .so libraries (non-Windows) 2020-08-12 12:49:42 -04:00
Sergio Martins
1aed8c7429 Merge branch '1.0' into master 2020-08-12 11:09:06 +01:00
Sergio Martins
fa0576362d Don't install the BSD license
The ECM modules aren't installed nor redistributed with the binaries,
they're just used while developing. Also don't want to create licensing
confusion
2020-08-12 11:07:32 +01:00
Sergio Martins
0aee56114b qml: Dropping a dragged window now works 2020-08-11 23:40:07 +01:00
Sergio Martins
b3ec7423e8 qml: The inner indicators are now centered 2020-08-11 22:19:51 +01:00
Sergio Martins
179cd4cf45 qml: Add properties for outter/inner indicators visibility 2020-08-11 22:19:51 +01:00
Sergio Martins
75d26c3cce qml: Draw the inner indicators too 2020-08-11 22:19:51 +01:00
Allen Winter
40d868581b .krazy - add another checker 2020-08-11 12:10:34 -04:00
Allen Winter
9071664ef2 .../ClassicIndicatorsOverlay.qml - copyright+license header 2020-08-11 08:14:00 -04:00
Sergio Martins
1980f9c42c qml: Fix namespaced build 2020-08-11 09:59:25 +01:00
Sergio Martins
2c917dcd7c qml: Show 4 proper indicators when dragging in a floating window
They don't do much yet, but at least appear.
2020-08-11 01:35:28 +01:00
Allen Winter
5ccf15b9ed Merge branch '1.0' 2020-08-10 17:07:05 -04:00
Allen Winter
f8a6bd7ad4 cmake/QtInstallPaths.cmake - update SPDX info in header 2020-08-10 17:00:30 -04:00
Allen Winter
635a63deba add license+copyright header to some CMake files. 2020-08-10 16:54:04 -04:00
Allen Winter
8731450cda fwd_headers - add copyright+license header
makes reuse happy
2020-08-10 16:38:29 -04:00
Allen Winter
1eb5392aef cmake/.../ECMEnableSanitizers.cmake - update from upstream 2020-08-10 16:27:55 -04:00
Allen Winter
f58a76426a examples/qtquick/main.cpp - add copyright+license header 2020-08-10 16:27:37 -04:00
Allen Winter
2e6623c9e7 LICENSES/BSD-3-Clause.txt - add for the cmake ECM files 2020-08-10 16:21:27 -04:00
Sergio Martins
7eaac87640 qml: Add a ClassicIndicatorsOverlay.qml file
Doesn't do much yet
2020-08-10 19:05:59 +01:00
Sergio Martins
5b9f08c754 Remove mapTo/From global from Layouting::Widget
Use the ones from QWidgetAdapter instead
2020-08-10 19:05:02 +01:00
Sergio Martins
02c165163a DragController: Use the geometry of the QWindow
While this works fine for QtWidgets, where the geometry of the
top-level QWidget is the same as the QWindow, it doesn't work
for QtQuick, where the geometry of the root item starts at 0,0
2020-08-10 19:03:15 +01:00
Sergio Martins
4bbc0f1d4f qml: Create drop indicator overlay too
The actual impl isn't done yet though
2020-08-09 22:45:15 +01:00
Sergio Martins
cf692797b6 qml: ClassicIndicators are now abstracted and built
The QtQuick counterpart just needs to be implemented
2020-08-09 20:27:05 +01:00
Sergio Martins
0e4ec055b2 Remove unused function 2020-08-09 20:05:38 +01:00
Sergio Martins
cf7c25cd88 Remove old cruft "rubberBandIsTopLevel" which we don't use 2020-08-09 19:23:52 +01:00
Sergio Martins
60b5eb00a3 Move IndicatorWindow to its own file
As it's the part that will be different with QtQuick.
ClassicIndicators can be shared.
2020-08-09 19:19:31 +01:00
Sergio Martins
0705b4da72 qml: Make Indicator class a implementation detail of QtWidgets
No longer accessed by ClassicIndicators
2020-08-09 18:57:23 +01:00
Sergio Martins
09b3e685a9 IndicatorWindow: Make some members private 2020-08-09 18:53:30 +01:00
Sergio Martins
64791eec82 qml: decouple ClassicIndicator from QRubberBand
the rubber band is now returned from the factory, meaning it can
be a QQuickItem when QtQuick is being used

Still need to remove the QtWidget'isms from IndicatorWindow
though
2020-08-09 18:39:56 +01:00
Sergio Martins
dc3aa354ec Minor code styling: Remove unneeded indentation 2020-08-09 18:13:23 +01:00
Sergio Martins
890784ba5a Finish FocusScope support
When clicking on a TitleBar the focus will be redirected to either:
- Last widget that had focus inside the scope
- To the DockWidget. Implies the user setting a guest widget that
accepts focus

Fixes: #56
2020-08-08 17:34:06 +01:00
Sergio Martins
c9468bef8a example: Add some helper code to debug focus 2020-08-08 17:34:06 +01:00
Sergio Martins
0b4c017f22 qml: Add subs regarding focus 2020-08-08 17:34:06 +01:00
Sergio Martins
6de558773f Merge branch '1.0' into master 2020-08-08 17:33:53 +01:00
Sergio Martins
2fdb85f3fb Fix build with 5.9 2020-08-08 17:32:26 +01:00
Sergio Martins
94258abf43 Decouple title bar icon from tab bar icon
You can now use different icons, or even just set an icon for the
title bar but not tab bar

Fixes #57
2020-08-08 14:05:42 +01:00
Sergio Martins
10026ba191 Add FocusScope behaviour to TitleBar
Github issue #56 is not a KDDW bug, it's how Qt works. QtWidgets don't
have focus scope. But let's workaround and handroll our own FocusScope.

Now the title bar can be colored differently if the dock widget it controls
contains any focused children.

This just implements half of the story. You have to focus a child
for the title bar to change color. Clicking the title bar directly
isn't done yet. Needs to be figured out. What do we focus when clicking it?
TitleBars usually don't care about keyboard focus. Probably we
just use the user's widget as a focus proxy.
2020-08-08 12:33:23 +01:00
Sergio Martins
0a6f760100 Fix a couple of clazy warnings 2020-08-07 22:23:08 +01:00
Sergio Martins
8db40d368c pass QStringList by const-ref 2020-08-07 22:00:44 +01:00
Sergio Martins
96a3eea108 Silence some clazy warnings which are benign in this context 2020-08-07 21:56:17 +01:00
Sergio Martins
47b20f03f9 Fix -Wclazy-copyable-polymorphic 2020-08-07 21:52:20 +01:00
Sergio Martins
bdcd8c1e20 Fix -Wclazy-range-loop 2020-08-07 21:50:46 +01:00
Sergio Martins
eaff83251c Fix -Wclazy-fully-qualified-moc-types 2020-08-07 21:47:46 +01:00
Sergio Martins
1cdd1a1b74 Fix static build on Windows
The STATICBUILD macros should:
- Be PUBLIC, so anyone linking against kddw gets them
- Not needed to be included in all targets, just link other targets and
they'll inherit

fixes linker errors
2020-08-07 21:24:43 +01:00
Sergio Martins
21938e4b3f Fix Windows build
The "BUILDING_*" macros are only to be defined on the dll that's
being build, so that the export macros expand to QT_EXPORT

The kddockwidgets target had the BUILDING_MULTISPLITTER macro, so
it included multisplitter.dll's symbols with QT_EXPORT, instead of
import, so couldn't work, resulting in linker errors
2020-08-07 21:12:52 +01:00
Allen Winter
95710d9e5e README.md - add more info links 2020-08-07 12:41:03 -04:00
Allen Winter
8a3252473f buildsystem - support static library build 2020-08-07 12:26:27 -04:00
Allen Winter
c52c8922dc add OBS files 2020-08-07 12:19:27 -04:00
Sergio Martins
80dcd57d91 qml: warn instead of crashing 2020-08-06 23:39:50 +01:00
Sergio Martins
37590b44d7 qml: DragController now compiles with the QtQuick frontend 2020-08-06 23:31:44 +01:00
Sergio Martins
051f8ab3a6 qml: Implement widgetForWindow 2020-08-06 23:17:28 +01:00
Sergio Martins
78dcb0f7f3 qml: Abstract some methods that QQuickItem doesn't have
geometry(), isMinimized(), etc.
2020-08-06 23:10:08 +01:00
Sergio Martins
6bb0d7ab08 Silence debug noise 2020-08-06 18:34:50 +01:00
Sergio Martins
c7afbf0803 qml: make qtTopLevelUnderCursor_impl() receive QWindow
QWindow works for both QtWidgets and QtQuick
2020-08-06 18:30:53 +01:00
Sergio Martins
bbea17b81b Make DockRegistry use QWindow to represent top-levels
Not QWidget/QQuickItem, since QtQuick uses QWindow (QQuickWindow),
not QQuickItem. Unlike QtWidgets, where QWidget can be used for both
purposes.
2020-08-06 18:03:25 +01:00
Sergio Martins
769d34d746 qml: implement childAt
Added a namespace-level parentWidget() helper, so it works for
both widgets and quick
2020-08-06 17:51:49 +01:00
Sergio Martins
64020568d6 Remove unused topLevel() method 2020-08-06 17:51:49 +01:00
Allen Winter
b7df2fb5f5 examples/qtquick - add license+copyright header 2020-08-05 17:52:49 -04:00
Allen Winter
ddc6da5894 add conanfile 2020-08-05 17:34:20 -04:00
Sergio Martins
6502ee5071 DragControl: Remove some dead code paths
Neither DockWidget nor DropArea are ever a top-level
2020-08-04 18:23:55 +01:00
Sergio Martins
22a13c7c9c Fix widgets example
Committed some things I shouldn't have during the qml port
2020-08-04 18:23:22 +01:00
Sergio Martins
a29f80f90b qml: set a transient parent to the floating QQuickWindow
so when it's frameless it get shown when we show the main window
(depending on the window manager)
2020-08-04 16:44:44 +01:00
Sergio Martins
0ccd4b8afa qml: Fix warnings and crash when closing windows 2020-08-04 14:56:12 +01:00
Sergio Martins
48433a05fb qml: Fix stray windows not being deleted 2020-08-04 14:13:42 +01:00
Sergio Martins
c6a455a059 qml: Fix anchoring
There's situations where neither title bar or tab bar are visible
2020-08-04 13:54:45 +01:00
Sergio Martins
3e3df799e6 qml: Deliver the close event 2020-08-04 13:53:31 +01:00
Sergio Martins
912f2de1ee qml: Fix close 2020-08-04 13:16:49 +01:00
Sergio Martins
1ad8a67caf qml: Fix Frame's title bar not being visible
It was being covered by the stack layout
2020-08-04 12:17:26 +01:00
Sergio Martins
a0588cd312 qml: Make floating window follow its QWindow
Means if you resize the window then FloatingWindow resizes too
2020-08-03 20:43:21 +01:00
Sergio Martins
40f0c0f322 qml: Fix guest not filling its DockWidget 2020-08-03 20:31:49 +01:00
Sergio Martins
52626b1874 qml: Add support for the MainWindow
Not really a MainWindow in the sense of toolbars and all.
For qml it's just the drop area, acepting drops
2020-08-03 20:05:36 +01:00
Sergio Martins
1cfceb4d07 MainWindow: Move the drop area to the base class
QtQuick impl will also use it
2020-08-03 19:39:01 +01:00
Sergio Martins
fd56ab7932 qml: Introduce tst_common
Will be moving tests that are common to both QtWidgets and QtQuick
2020-08-02 22:16:03 +01:00
Sergio Martins
4fd28f9577 qml: Implement more QtQuick API 2020-08-02 22:10:54 +01:00
Sergio Martins
fd6d9654bc qml: Start running some tests for the QtQuick version too
tst_multisplitter for now.
tst_docks will have to be split into common and widgets
2020-08-02 20:16:07 +01:00
Sergio Martins
31f391294c qml: Implement a few "Implement me"s in the QtQuick glue 2020-08-02 20:05:02 +01:00
Sergio Martins
9dd4e733eb qml: Empty FloatingWindows no longer stay around 2020-08-02 17:47:40 +01:00
Sergio Martins
e4f6893324 qml: Fix warnings about dereferencing null types 2020-08-02 17:43:44 +01:00
Sergio Martins
3c841aa2a9 qml: Make FrameQuick have a model for the dock widgets
More versatil for QML
2020-08-02 17:05:57 +01:00
Sergio Martins
85b4fc3751 qml: Hide TabBar if only 1 tab exists 2020-08-02 12:28:00 +01:00
Sergio Martins
197a0abb7e qml: Wire up some events for DockWidget
Some events like QEvent::Show, Hide and Close are for QWidget only,
so we have to synthetize them, as KDDW expects them
2020-08-02 12:15:26 +01:00
Sergio Martins
1df0e6d6dd qml: Add Guest #3 2020-08-01 18:09:49 +01:00
Sergio Martins
36407d2abe qml: Separators now work 2020-08-01 17:44:07 +01:00
Sergio Martins
2ffdfcad24 qml: Calling DockWidget::setWidget(filename) now loads a QML 2020-07-31 21:23:35 +01:00
Sergio Martins
0e1dc4bd45 qml: Remove some QWidget'isms 2020-07-31 21:06:11 +01:00
Sergio Martins
2853f54ac7 qml: Add a visual item for DockWidget
DockWidget.qml, in case the user wants to make style changes
2020-07-31 21:00:29 +01:00
Sergio Martins
76efd45e2d qml: Fix parenting dock widgets to the stack layout 2020-07-31 20:48:37 +01:00
Sergio Martins
7c5e0826c6 qml: Add a tabbar from QQC2 to Frame.qml 2020-07-31 20:37:56 +01:00
Sergio Martins
7c77c9597e qml: less debug noise 2020-07-31 20:37:28 +01:00
Sergio Martins
312d95a376 qml: link to QQC2 too, needed for TabBar 2020-07-31 18:51:39 +01:00
Sergio Martins
dc1b4f79e4 qml: Parent dock widget to Frame 2020-07-30 23:10:42 +01:00
Sergio Martins
44da2dca65 qml: Implement dragging via title bar
needs to redirect the events from the mouse area to the
C++ draggable
2020-07-30 22:34:36 +01:00
Sergio Martins
9657bc50a3 qml: Remove QtWidget'ism from DragController 2020-07-30 22:18:05 +01:00
Sergio Martins
affd7dfb87 qml: Fix two title bars being shown 2020-07-30 17:56:56 +01:00
Sergio Martins
dc59ecb4eb qml: Fix title bars not showing their title 2020-07-30 17:28:27 +01:00
Allen Winter
f95e3d10e7 Doxyfile.cmake - comment another setting too new for our CI 2020-07-30 11:53:18 -04:00
Allen Winter
a664a05201 docs/api/CMakeLists.txt - copy screencap.gif by-hand 2020-07-30 11:45:51 -04:00
Allen Winter
7b3e858aa3 docs/api/CMakeLists.txt - fix qch file name 2020-07-30 11:18:36 -04:00
Sergio Martins
1d032abb72 Fix some doxygen bugs 2020-07-30 16:15:25 +01:00
Allen Winter
61a5fec3cb Doxyfile.cmake - comment settings that are too new for our CI 2020-07-30 10:52:42 -04:00
Allen Winter
4e6022e529 README.md - possible fix for screen capture link in doxygen 2020-07-30 10:14:28 -04:00
Allen Winter
9216964b02 Doxyfile.cmake - improvements 2020-07-30 10:14:28 -04:00
Allen Winter
a87a694e3c docs/api/Doxyfile.cmake.bak - remove. added by mistake 2020-07-30 10:14:28 -04:00
Sergio Martins
8736d2cdb6 qml: Implement QWidgetAdapter::close() and window()
Clicking the title bar's close button now works
2020-07-29 23:58:46 +01:00
Allen Winter
fc633f2547 various minor documentation fixes for doxygen 2020-07-29 18:58:17 -04:00
Allen Winter
82abc90133 Build API documentation with doxygen 2020-07-29 18:44:42 -04:00
Sergio Martins
f8f596ad30 qml: Layout the drop area and title bar inside the FloatingWindow
We could just control geometry of the c++ title bar and geometry,
but then the user wouldn't be able to style it, and users rather
style things in QML than subclassing FloatingWindow and writing C++.

So instance some .qml files to represent the drop area and floating
window, so user can muck with.

Hierarchy looks like this now:

-QQuickWindow
--FloatingWindowQuick (C++ QQuickItem)
---FloatingWindow.qml
----TitleBar.qml (reads state from TitleBar c++)
----DropArea.qml
-----DropArea (C++ QQuickItem)
------Frame
      etc
2020-07-29 23:28:05 +01:00
Sergio Martins
c13f9c00aa minor coding style 2020-07-29 22:07:51 +01:00
Sergio Martins
0ff9b95577 Move some typedefs into KDDockWidget namespace
So they don't conflict with user code
2020-07-29 10:30:21 +01:00
Sergio Martins
ab28c63273 Fix possible crash when deserializing 2020-07-29 09:31:46 +01:00
Sergio Martins
cbe6e47233 qml: Make the windows bigger for now 2020-07-28 22:27:15 +01:00
Sergio Martins
dc3a598594 qml: Fix no QEvent::ParentChange being sent
QWidget::setParent() does this but QQuickWidget doesn't, so do
it manually.
2020-07-28 22:25:43 +01:00
Sergio Martins
6738bb0ae1 qml: Implement QWidgetAdapter::parentWidget()
Frame gets access to its DropArea now
2020-07-28 22:25:09 +01:00
Sergio Martins
1286fc28ca qml: Wire up TitleBar buttons 2020-07-28 21:41:41 +01:00
Sergio Martins
6104fdf2e0 qml: Implemented QWidgetAdapter::setFlag
FloatingWindow is frameless now.
2020-07-28 21:28:15 +01:00
Sergio Martins
f42f3804a1 qml: Add a default size for items
Otherwise it's 0x0
2020-07-28 21:17:28 +01:00
Sergio Martins
10226fc61a qml: FloatingWindow now creates a real top level QWindow 2020-07-28 21:17:01 +01:00
Sergio Martins
ba2ce8b8db qml: Implement QWidgetAdapter::isWindow and initialize min/max 2020-07-28 20:41:26 +01:00
Sergio Martins
dccdeda18a qml: debug++ 2020-07-28 20:41:12 +01:00
Sergio Martins
a23c76f6fb qml: create a dock widget in the example
So we can debug why it's not creating a floating window
2020-07-28 20:40:39 +01:00
Sergio Martins
0245b6e81b qml: Fix path for Frame.qml 2020-07-28 19:25:10 +01:00
Allen Winter
35728f54cd src/CMakeLists.txt - ${PROJECT_NAME}_VERSION for PACKAGE_VERSION
we haven't set a PACKAGE_VERSION needed by
write_basic_package_version_file() but we don't need one
since we can simply use ${PROJECT_NAME}_VERSION
2020-07-27 17:49:59 -04:00
Allen Winter
fc7af85c83 CMakeLists.txt - must set *_VERSION_* after project() call
project() sets ${PROJECT_NAME}
then we can use ${PROJECT_NAME} to set VERSION variables
2020-07-27 17:48:07 -04:00
Sergio Martins
c87f5ba6eb Move utility function into tests
used by the tests only
2020-07-27 21:32:58 +01:00
Sergio Martins
a574364100 vscode: Add settings for QtQuick too 2020-07-27 21:32:31 +01:00
Sergio Martins
88e10ffb31 qml: Add the skeleton for the example
Doesn't do much yet, but has background.
2020-07-27 18:00:06 +01:00
Sergio Martins
2895de3ef5 qml: Add missing export macro 2020-07-27 10:52:34 +01:00
Sergio Martins
5346f808f9 qml: Don't include the widgets MainWindow in LayoutSaver 2020-07-27 10:51:03 +01:00
Sergio Martins
36e6613f6a Fix build 2020-07-27 10:46:59 +01:00
Sergio Martins
0090799f7f qml: Add missing API in QWidgetAdapter_quick_p.h 2020-07-27 10:44:02 +01:00
Sergio Martins
c64b938e40 qml: Fix FloatingWindow.cpp building on Windows 2020-07-27 10:32:33 +01:00
Sergio Martins
08721ea458 qml: Fix linking
Abstractions are all in place now.
Let the port start!
2020-07-26 21:57:19 +01:00
Sergio Martins
fa7e8af014 qml: Remove QWidget'isms from MultiSplitter 2020-07-26 21:53:05 +01:00
Sergio Martins
7d01b7649a qml: Move MultiSplitter out of widgets/
Will make it shared to both stacks
2020-07-26 21:46:09 +01:00
Sergio Martins
9275432aea Remove a couple of unneeded includes 2020-07-26 21:42:29 +01:00
Sergio Martins
df5738dd34 qml: Don't build layoutlinter yet
needs some work and not a priority at this point
2020-07-26 21:37:54 +01:00
Sergio Martins
119cadae30 build the layouting engine with quick support if kddw is too
it's required
2020-07-26 21:33:20 +01:00
Sergio Martins
f6837ee4e5 qml: Fix compile for layoutlinter
Doesn't link yet though
2020-07-26 21:33:10 +01:00
Sergio Martins
ed752d953a Fix include 2020-07-26 21:01:22 +01:00
Sergio Martins
34ea666007 qml: Remove LayoutSaverQuick
LayoutSaver is generic enough and works with both stacks
2020-07-26 21:00:51 +01:00
Sergio Martins
0659f1e52b qml: Add missing API to the QtQuick wrapper
related to size hints and such
2020-07-26 21:00:22 +01:00
Sergio Martins
1f09bfa9d5 qml: Don't build the QWidgets example 2020-07-26 21:00:00 +01:00
Sergio Martins
ebda537a11 qml: Make DockWidgetBase inherit from QWidgetAdapter
So we get access to maximumSize, sizePolicy and such API
for QQuickItems too
2020-07-26 20:37:49 +01:00
Sergio Martins
ac115bc078 Fix typo 2020-07-26 20:37:49 +01:00
Sergio Martins
a84fea36fe qml: Move widgetMaxSize to the base class
The logic is not specific to QWidget. It will be reused for QtQuick
2020-07-26 20:24:24 +01:00
Sergio Martins
e4c87f60e9 qml: Fix Layout's saver API 2020-07-26 20:12:55 +01:00
Sergio Martins
a21abef6bd Make MultiSplitter::rectForDrop() take a FloatingWindow directly
Which is the only use case. Also since FloatingWindow inherits
from Layouting::Widget that will be nice to make this code work
with QtQuick version too. Otherwise it's complicated as QQuickItem
doesn't have min/max/sizePolicy
2020-07-26 20:05:41 +01:00
Sergio Martins
6fe8d7aea0 qml: MultiSplitter also inherits from LayoutGuestWidget now 2020-07-26 19:55:31 +01:00
Sergio Martins
2a34ecd563 qml: Frame inherits from Widget_quick when built with QtQuick support 2020-07-26 18:56:24 +01:00
Sergio Martins
2e2288cc0f Update .gitignore 2020-07-26 17:59:37 +01:00
Sergio Martins
1a44d36838 qml: Make ClassicIndicator widgets only 2020-07-26 17:51:13 +01:00
Sergio Martins
c53d71e2de qml: Remove more QWidget'isms, make code generic 2020-07-26 16:49:01 +01:00
Sergio Martins
e2674d2a68 qml: Port screenSizeForWidget() 2020-07-26 16:16:06 +01:00
Sergio Martins
e66cbae09f qml: Remove QWidget'isms from TitleBar and from the overlay interface 2020-07-26 16:16:06 +01:00
Sergio Martins
08dc55ea06 qml: Adjust API of the quick specialization of the factory 2020-07-26 16:16:06 +01:00
Sergio Martins
5c0c204859 qml: Remove QWidget'isms from DockRegistry
The DebugWindow is QWidgets only too.
2020-07-26 16:16:06 +01:00
Sergio Martins
85c32abdf0 minor: Silence warning about unused variable 2020-07-26 16:16:06 +01:00
Sergio Martins
b7353d2bba qml: Fix signatures for Frame and FloatingWindow quick specializations 2020-07-26 16:16:06 +01:00
Sergio Martins
e9131897e4 qml: Remove QWidget'isms from DockWidgetBase 2020-07-26 16:16:06 +01:00
Sergio Martins
fab0c5f8f8 qml: Remove QWidget'isms from DropArea
It's generic now
2020-07-26 16:04:17 +01:00
Sergio Martins
77307a1664 qml: Add more API to match the QWidget counter part
Namely isMaximized, showNormal and showMaximized
2020-07-26 16:01:13 +01:00
Sergio Martins
40e944ee9d qml|cmake: Move some widget only .cpp files into the widgets-only section
These won't be used by the QtQuick impl
2020-07-26 16:00:10 +01:00
Sergio Martins
a9402d1073 qml: fix the qml paths in the qrc file 2020-07-26 15:59:36 +01:00
Sergio Martins
9a15ac4bfa Fix running cmake with OPTION_QUICK 2020-07-26 14:47:09 +01:00
Sergio Martins
6a13085e77 qml: Fix another import 2020-07-25 21:04:39 +01:00
Sergio Martins
14e862f1fb qml: Add import statements which were removed when adding copyright headers 2020-07-25 21:01:15 +01:00
Allen Winter
b4f49895c2 clarify: licensing is GPL2 or GPL3 or commercial licensed
follow the REUSE specs
2020-07-24 18:16:13 -04:00
Allen Winter
2d0dcb9dbe multisplitter qml examples - add license+copyright header 2020-07-24 17:24:40 -04:00
Allen Winter
9b2b8bbc02 src/Qt5Qt6Compat_p.h - minor tweak for the include guard 2020-07-24 17:23:37 -04:00
Sergio Martins
1ae66eb8c2 minor cleanup 2020-07-22 17:01:45 +01:00
Sergio Martins
478c6e3bbc Fix crash when loading a bogus layout 2020-07-21 17:36:45 +01:00
Allen Winter
41b48bd41c private/multisplitter/Item.cpp - minor comments readability 2020-07-19 10:57:02 -04:00
Sergio Martins
709728e456 Revert "Add support for Qt6"
This reverts commit e1bf1cd786.

This breaks the build with older CMake (3.9 for example), which
doesn't support alias to imported targets.
2020-07-19 15:42:59 +01:00
Sergio Martins
e1bf1cd786 Add support for Qt6
Build with -DOPTION_QT6=ON
2020-07-18 21:56:18 +01:00
Sérgio Martins
8474f246ae Fix Qt6 build
Didn't include the cmake changes, as those are hacks for now.
Only included fixes to cpp code.
2020-07-18 18:51:47 +01:00
Sergio Martins
beaa45d16d Use QStyleOption::initFrom() instead of QStyleOption::init()
The later is deprecated and removed in Qt6
2020-07-18 18:08:26 +01:00
Sergio Martins
ffe13f4bea Fix macOS build due to -Werror extra-semi 2020-07-07 17:33:11 +01:00
Sergio Martins
2559b29b30 Fix separators not moving in some situations
We were mixing heights with widths... root->length() can be a width()
(if vertical), while we're calculating available width to grow
on a nested horizontal container
2020-07-06 23:54:42 +01:00
Sergio Martins
7dfcdd1981 Merge pull request #54 from KDAB/mac-testing
CMakeLists.txt - disable test_launcher tests on Mac && Qt<5.15.1
2020-07-06 23:21:30 +01:00
Allen Winter
341f682274 CMakeLists.txt - disable test_launcher tests on Mac && Qt<5.15.1 2020-07-06 17:58:17 -04:00
Sergio Martins
5349ff3832 Fix potential crash 2020-07-06 22:40:13 +01:00
Sergio Martins
259a78ebaf Also simplify layouts that only have 1 child
Those have any orientation, so can be simplified, as its "orientation"
matches its parent one
2020-07-06 21:15:23 +01:00
Sergio Martins
090392a02e tests++ 2020-07-06 20:27:45 +01:00
Sergio Martins
563d569ec4 tests: When removing a dock widget, check if max-size is honoured 2020-07-06 19:20:08 +01:00
Sergio Martins
0899a4e0c8 Simplify layouts after adding items
A vertical layout inside another vertical layout is redundant (same for horizontal),
so grab the contents of the sub-layout and delete it
2020-07-06 19:19:01 +01:00
Sergio Martins
29e625b85f Fix Item::requestEqualSize() when items have max-size
It already honoured max-size, but was bailing out early if
both items had the same size. Which is fine, unless one of them
has max-size, where we want to honour it
2020-07-06 12:31:47 +01:00
Sergio Martins
380c3eee81 Fix separators not being movable in some cases
The 'minPos' isn't a special case, should follow the same logic as 'maxPos'.
Confused separator min pos with dock widget's min-size,
which is a special case for dock widgets.
2020-07-06 12:18:39 +01:00
Sergio Martins
21ef8017e8 Honour max-size when dropping a widget that can grow
We already honoured max-size in the case of dropping a widget with
some max-size. Now we also honour it when an existing docked widget
has max-size and we're dropping a widget that can grow. Now the
dropped widget will occupy more space in this case
2020-07-06 11:01:29 +01:00
Sergio Martins
eee8cb8341 Minor, remove unneeded check 2020-07-06 11:00:57 +01:00
Allen Winter
9630f0f48a tst_docks.cpp - fix link. remove unneeded method declaration
tst_maxSizeHonouredWhenAnotherDropped didn't have an
implementation so I removed its declaration.
2020-07-04 12:10:36 -04:00
Sergio Martins
0f71b30096 Allow to drag separators when they are past their max-pos
As long they are moving in Side1 direction. i.e: left/up, i.e:
reducing their distance to the max-pos.
2020-07-04 13:02:46 +01:00
Sergio Martins
2ec226c432 Dragging separators now honours max-size recursively too
Previously only min-size propagated.
Now, when dragging a separator, let's say to the right, and the left
widget can't grow more, we start to move the previous separator to
the right
2020-07-04 12:32:10 +01:00
Sergio Martins
fa2cd1bc74 Also honour max-size when resizing nested container via separator 2020-07-04 11:38:33 +01:00
Sergio Martins
730af05aa1 Add a failing unit-test 2020-07-04 00:39:55 +01:00
Sergio Martins
4788f41593 tests: don't fail when window is out of bounds on mac
Should be benign. My screen it too small.
2020-07-03 19:36:39 +01:00
Sergio Martins
84b0b8f6ad Fix serializing floating window affinity 2020-07-02 17:44:16 +01:00
Allen Winter
cf1514f8a4 src/private/DebugWindow.cpp - removed unused assignment
compile warnings are errors with MinGW

Change-Id: I03ed6d6fbfbdb07d85582d50a302f09d87d0b32d
2020-07-01 18:36:11 -04:00
Allen Winter
47f0dfd3ae fix MinGW build. the pragmas are for MSVC
Change-Id: I8ec58f136ad02449fdbf5aedca7a1b88583a561f
2020-07-01 18:34:03 -04:00
Allen Winter
183c48696e private/multisplitter/CMakeLists.txt - obey KDDockWidgets_TESTS 2020-06-29 17:51:41 -04:00
Allen Winter
2462f991be buildsystem - consistent formatting 2020-06-25 13:32:59 -04:00
Sergio Martins
d373585e0c get rid of some unneeded qobject_cast<FloatingWindow*> casts 2020-06-25 17:56:21 +01:00
Sergio Martins
7f324dda91 Mention KDDockWidgets instead of KDChart in the readme
was a copy-paste typo
2020-06-25 17:29:00 +01:00
Allen Winter
c5739e8626 examples/dockwidgets/CMakeLists.txt - increase cmake min vers
to make consistent with the top-level project
2020-06-25 10:42:57 -04:00
Allen Winter
5362200d21 CMakeLists.txt - use KDAB installation directory 2020-06-25 10:35:47 -04:00
Sergio Martins
d7f9bf7adc Remove two unneeded connects
Also since DockWidgetBase won't be a QObject soon
2020-06-24 22:33:11 +01:00
Sergio Martins
52c37f28d0 Remove pure-virtual which isn't pure 2020-06-24 16:37:37 +01:00
Sergio Martins
bcfb57f89d Fix aerosnap|alwaysTabs|noTitleBar
DragController would ignore the non-client mouse press
2020-06-24 16:18:58 +01:00
Sergio Martins
16fac61a9d Fix build 2020-06-24 16:10:20 +01:00
Sergio Martins
5203718f93 When not using a title-bar, don't say a tab is HTCAPTION
Otherwise tabs are not clickable
2020-06-24 16:06:35 +01:00
Sergio Martins
d3aee0dabb Add a unit-test 2020-06-24 16:06:35 +01:00
Allen Winter
b6e8703038 CMakeLists.txt - Always build the tests in developer-mode 2020-06-24 10:48:39 -04:00
Allen Winter
153aa65b40 CMakeLists.txt - fail if building bindings in non-release mode 2020-06-24 10:48:39 -04:00
Allen Winter
0701e8aa97 buildsystem - improve how Windows libraries are versioned
Change-Id: Ie6873c1ec8fc53a005d12ef6a0573f61b41fba39
2020-06-24 09:57:28 -04:00
Allen Winter
baed168458 CMakeLists.txt - require Qt5.9 or higher 2020-06-24 09:46:12 -04:00
Allen Winter
6b45f97215 Merge branch 'master' of github.com:KDAB/KDDockWidgets 2020-06-23 18:58:16 -04:00
Allen Winter
1fc1e3abb2 CMakeLists.txt - add option to disable building examples 2020-06-23 18:56:51 -04:00
Allen Winter
b825e0b9ea CMakeLists.txt - add option to disable building tests 2020-06-23 18:52:05 -04:00
Allen Winter
7aa45ebed9 CMakeLists.txt - add option to disable building examples 2020-06-23 18:45:03 -04:00
Allen Winter
c50fe5fa88 CMakeLists.txt - improvements
* add some doc at the top
 * set VERSION strings
 * disable Python bindings in debug build
 * consistent coding style
2020-06-23 18:17:46 -04:00
Sergio Martins
ba2fdfc46c Fix tests with 5.9
There was just 1 failing, which needed higher margins
2020-06-23 22:11:50 +01:00
Sergio Martins
815b496599 Mention in the README that min Qt is 5.12 if Python bindings are enabled 2020-06-23 21:59:18 +01:00
Allen Winter
b2e79d4285 .krazy - skip a file in cmake 2020-06-23 15:41:59 -04:00
Sergio Martins
4c630f6c6a Fix build of python bindings 2020-06-23 20:24:19 +01:00
Allen Winter
bf4ef05d00 CMakeLists.txt - install doc files (LICENSE, README, etc) 2020-06-23 15:14:53 -04:00
Allen Winter
e35fcb02df src/CMakeLists.txt - fix cmake file install destination 2020-06-23 15:09:20 -04:00
Sergio Martins
4fa2be3263 On Windows it's fine to use the FloatingWindow as the draggable
As it supports native dragging
2020-06-23 19:33:33 +01:00
Sergio Martins
7c04cd96c6 Fix dragging on Linux 2020-06-23 19:28:14 +01:00
Sergio Martins
a8bd46155c Fix typo in test 2020-06-23 19:24:00 +01:00
Sergio Martins
5f4d8b515f Fix detaching now allowing to continue a drag
Seen sometimes on Windows.
Also, since aero-snap works fine now, we can re-enable the mouse grab
2020-06-23 19:19:59 +01:00
Sergio Martins
da4b90e373 tests: Use different json filenames
So tests can run in parallel
2020-06-23 19:01:13 +01:00
Allen Winter
7ec2f31a46 buildsystem - generate PRI file for qmake users 2020-06-23 12:55:26 -04:00
Sergio Martins
3217c61713 Help clang-tidy knowing that frame can't be null here 2020-06-23 17:48:40 +01:00
Sergio Martins
2a33599bde Fix range-loop detachements 2020-06-23 17:48:40 +01:00
Sergio Martins
2994046c7b Fix -Wclazy-rule-of-three 2020-06-23 17:48:40 +01:00
Allen Winter
842e72c4c3 Windows: version libs, install pdb files for MSVC builds
Change-Id: I2964e809de20a9cb94d3039c95a1a623fdfd4d40
2020-06-23 12:38:51 -04:00
Sergio Martins
3b5ca4dafb Silence -Wclazy-non-pod-global-static for the example
we don't care about non-lib example code regarding this
2020-06-23 17:12:21 +01:00
Sergio Martins
b76ec9e611 Remove unused trivial variable from linux build 2020-06-23 17:10:06 +01:00
Allen Winter
7a1a2f2c43 python/ - copyright and license headers 2020-06-23 11:50:33 -04:00
Allen Winter
4ffe5e72d8 FindShiboken2.cmake, FindPySide2.cmake - use https 2020-06-23 11:44:51 -04:00
Allen Winter
0275fe441e .vscode/launch.json - add trailing newline 2020-06-23 11:43:21 -04:00
Allen Winter
44bf882a2a various - include own header first 2020-06-23 11:38:41 -04:00
Allen Winter
f9196203e7 .krazy - skip files in fwd_headers 2020-06-23 11:32:35 -04:00
Allen Winter
275e334120 Item_p.h, MultiSplitter.cpp - remove duplicate includes 2020-06-23 11:27:18 -04:00
Allen Winter
f97f920ffb private/multisplitter/Separator_qwidget.h - fix include guard 2020-06-23 11:26:54 -04:00
Allen Winter
7773c3fe27 minor spelling fixes 2020-06-23 11:10:56 -04:00
Sergio Martins
19d5467f4d fuzzer: Also generate max-size constraints 2020-06-21 23:28:35 +01:00
Sergio Martins
4c0e418bc1 Add DropArea::frames()
instead of the FloatingWindow using findChildren on another object's
internals
2020-06-21 22:07:12 +01:00
Sergio Martins
fab4d39f92 Use a dedicated id() property instead of casting pointers to int
Which would be flaky once we have multi-inheritance
2020-06-21 21:17:04 +01:00
Sergio Martins
91b291a1a9 tests: Tests now run 10x faster, with ctest -j10 or so
Introduced an indirection, tests_launcher, which can run a subset
of the 140 tests, this way it's paralelizable by ctest
2020-06-20 15:27:58 +01:00
Sergio Martins
be4a71685a Fix a fuzzer test
When restoring a layout it can happen that the widget has
different size constraints when being restored, so this warning
was benign. There's a chekcSanity() later, so that's what's matters
2020-06-20 14:00:33 +01:00
Sergio Martins
8b862b7843 Honour max-size constraints when moving a separator
The separator will still move, but won't make the item grow
past its max-size, instead, it will grow the item's neighbours
2020-06-20 13:17:26 +01:00
Sergio Martins
b0503cfeb4 checkSanity: Don't honour max-size when checking the constraints
It's not always possible to honour max-size, when there's conflicting
items in the layout with min-sizes which wouldn't allow use to satisfy
max-size constraints. max-size is more of an hint
2020-06-20 13:16:14 +01:00
Sergio Martins
ecb01ff9c3 wip 2020-06-19 19:31:04 +01:00
Sergio Martins
40c816e0c5 Improve README regarding running the python bindings 2020-06-17 22:29:53 +01:00
Sergio Martins
6bbba2bff7 python: install to CMAKE_INSTALL_PREFIX by default
Set PYTHON_BINDINGS_INSTALL_PREFIX to put them in another place
2020-06-17 22:15:27 +01:00
Sergio Martins
36fba5db3d After growing neighbours, also honour the max size
So items with max-size don't grow past their max-size
2020-06-17 19:33:30 +01:00
Sergio Martins
744f351c4e Fix highlight when widget has QSizePolicy::Maximum
Multisplitter::rectForDrop() was only using QWidget::maximumSize(),
which doesn't need to be set. Also fix the case where the dropped widget
be a complete multisplitter
2020-06-17 18:04:59 +01:00
Sergio Martins
b8664c44c7 example: show the use of max-sizes without developer-build
the feature is stable to show
2020-06-17 16:29:45 +01:00
Sergio Martins
e3276411f9 Propagate developer built into the example too 2020-06-17 16:20:21 +01:00
Sergio Martins
84989745b4 Use target_compile_options instead of the hammer
Doing per target ensures that the python stuff won't get -Werror.
We can now build the python bindings and still use the developer build
2020-06-17 14:37:42 +01:00
Sergio Martins
3121b4cf28 Add *pyc to .gitignore 2020-06-17 14:29:52 +01:00
Sergio Martins
da6df47706 Merge pull request #50 from KDAB/python
Python
2020-06-17 11:12:27 +01:00
Sergio Martins
e5c0316ebb Fix the highlight/rubber-band size not matching the size the item gets
Not all code-paths were using FairButFloor. Dropping a single item
used FairButFloor, but not when dropping another multi-splitter (
Layout with nested items)
2020-06-16 22:34:18 +01:00
Renato Araujo Oliveira Filho
c0d8f22049 Use PySide from the system when possible 2020-06-16 17:57:56 -03:00
Renato Araujo Oliveira Filho
c2d8991283 Allow to install python bindings in a custom dir
Added cmake var PYTHON_BINDINGS_INSTALL_PREFIX
2020-06-16 17:57:46 -03:00
Renato Araujo Oliveira Filho
a599736c1b Create Python bidings
Added Cmake files
Ported examples
2020-06-16 15:12:41 -03:00
Sergio Martins
5526022a57 Add another fwd header 2020-06-13 19:09:44 +01:00
Sergio Martins
25dd149475 Add Widget::mapToGlobal() 2020-06-13 19:09:44 +01:00
Sergio Martins
e6b67101fa Make the example customize TitleBarWidget instead of TitleBar
TitleBar will cease to depend on QWidget
2020-06-11 21:26:33 +01:00
Sergio Martins
16c32cea4b Added Widget::update() and mapFromGlobal 2020-06-11 19:33:20 +01:00
Sergio Martins
9f44eb3154 Add Widget::topLevel()
Equivalent to QWidget::window()
2020-06-11 18:18:11 +01:00
Sergio Martins
c7b6a1a654 wip 2020-06-11 18:10:01 +01:00
Sergio Martins
6bbcb8f8f2 Rename LayoutSaver::MultiSplitterLayout to LayoutSaver::MultiSplitter 2020-06-11 17:00:54 +01:00
Sergio Martins
163b194398 Fix clang build, mostly shadowing warnings 2020-06-11 17:00:54 +01:00
Sergio Martins
86e58dd8a7 Merge MultiSplitterLayout into MultiSplitter
No need to have two. It's a leftover from the old layouting engine
2020-06-11 16:34:28 +01:00
Sergio Martins
e54ef787ed Some include cleanup 2020-06-11 11:03:12 +01:00
Sergio Martins
d5957a0dc5 Double-clicking on separator now respects max-size 2020-06-10 23:32:04 +01:00
Sergio Martins
bb79bd12a7 Fix bug in availableToGrowOnSide() and add unit-test 2020-06-10 20:31:03 +01:00
Sergio Martins
47795d0751 min/max pos for separator can honour max-size now 2020-06-10 19:52:20 +01:00
Sergio Martins
e234ad65ab Add ItemContainer::availableToGrowOnSide_recursive() 2020-06-10 19:24:34 +01:00
Sergio Martins
1c3dd93ee3 More renaming, as we add more functions that honour max-size 2020-06-10 19:02:07 +01:00
Sergio Martins
ccf161e139 Add ItemContainer::availableToGrowOnSide() 2020-06-10 18:58:38 +01:00
Sergio Martins
9636054ccc Rename Item::availableOnSide() to availableToSqueezeOnSide() 2020-06-10 18:55:54 +01:00
Sergio Martins
6e77dce573 Add Item::neighboursMaxLengthFor() 2020-06-10 18:54:34 +01:00
Renato Araujo Oliveira Filho
e6a335a3f7 Use enum explicitly constructor as default values
This will avoid problems generating python bindings, shiboken does not
handle well '{}' initialization.
2020-06-10 12:37:46 -03:00
Sergio Martins
a442419db2 Honour max-size constraints when resizing the window
items won't resize past their max-size when resizing the window now
2020-06-10 14:10:41 +01:00
Sergio Martins
479e1acece tests: guest widget can get a max-size now too 2020-06-10 11:42:50 +01:00
Sergio Martins
a7878122ac Only use QT_DISABLE_DEPRECATED_BEFORE in developer-mode
Many projects just add kddw as a sub-folder and might have
QT_DISABLE_DEPRECATED_BEFORE with a different value, then you get
lots of warnings
2020-06-09 12:40:37 +01:00
Sergio Martins
fa32054085 Merge pull request #48 from KDAB/fix-warning
Fix -Wextra-semi
2020-06-08 21:20:26 +01:00
Colin Ogilvie
f3de1ad63d Fix -Wextra-semi 2020-06-08 19:36:18 +01:00
Sergio Martins
8baac15d24 Fix floating window position when dragging with constraints
When the detach starts we might make the window smaller so it
respects the max-size constraint. The quirk was that in that
case the window was no longer under the mouse cursor, so looked
weird while dragging, although it worked
2020-06-08 18:19:46 +01:00
Sergio Martins
4cf1159019 Two more places that should use setSuggestedGeometry()
Now dragging by the tab bar also respects the max-size
2020-06-08 17:40:17 +01:00
Sergio Martins
ee065795b9 Fix Frame max size accounting for the waste twice
Frame::biggestDockWidgetMaxSize() should return only the max size
of the dock widget, and not mix with sizes of the container frame
2020-06-07 23:12:47 +01:00
Sergio Martins
7f9d160658 Also honour QSizePolicy::Maximum
It's yet another way to say you want a max size
2020-06-07 20:14:50 +01:00
Sergio Martins
daa220d513 tests: let the widget receive a size hint 2020-06-07 20:01:37 +01:00
Sergio Martins
d5797a3aea Honour QSizePolicy::Fixed too
Some widgets, for example QPushButton, instead of having an explicit max size,
they communicate the need for a max size through their size policy
2020-06-07 19:53:06 +01:00
Sergio Martins
ab8545e2c2 Bound the item max size just in case 2020-06-06 20:27:36 +01:00
Sergio Martins
5fc16954f5 Fix max-size only working in one orientation
ItemContainer::maxSizeHint() algo was wrong.
Add unit-test too.
2020-06-06 20:11:09 +01:00
Sergio Martins
6610e48cb3 Fix qDebug for child items going out of scope before the parents
Made the child debug lines appear before
2020-06-06 18:12:44 +01:00
Sergio Martins
dabfeeaf3b Honour max-size when floating a window 2020-06-05 15:35:55 +01:00
Sergio Martins
9601f57050 example: Don't show the dock widgets immediately
It's not needed, as they are going to be added to the layout.
Saves us from flicker and also the temporary floating position
being saved
2020-06-05 13:43:35 +01:00
Sergio Martins
7c442dce85 Fix another place that should use setSuggestedGeometry 2020-06-04 21:47:47 +01:00
Sergio Martins
07ea3ff1a6 cleanup: Replace some qobject_casts with a function 2020-06-04 21:37:01 +01:00
Sergio Martins
874fd7d69f Don't set the FloatingWindow geometry directly
Let's have an indirection, so FloatingWindow can do some adjustments
and use a smaller rect incase of max-size.

Since we don't want to enforce max-size, just when showing the window.
2020-06-04 21:21:11 +01:00
Sergio Martins
69a737e286 FloatingWindow: Remove cruft 2020-06-04 21:16:22 +01:00
Sergio Martins
ddc49c9358 Don't warn when restoring and there's no last pos info
We now restore floating windows to their previous position too
when toggling float. If there's no last info it's fine
2020-06-04 18:21:52 +01:00
Sergio Martins
2b3c3b75bf Fix build with older cmake
Error was:
"install TARGETS given target "kddockwidgets_multisplitter" which does not
exist in this directory."

Fixes: #47
2020-06-04 15:29:34 +01:00
Sergio Martins
296889cace Move TabWidget usage to FrameWidget
Frame is abstract and doesn't care about such implementation details.
QQuick will role out their own QTabWidget equivalent. No need to
abstract tab widget too, it's overkill.
2020-06-04 09:57:59 +01:00
Sergio Martins
4ebe8ed631 harden Frame's pure virtuals
Too many paths to control, so protect against calling the pure
virtuals in ctor/dtor
2020-06-03 22:31:03 +01:00
Sergio Martins
ecfa43f801 Decouple TabWidget from Frame
TabWidget is now an implementation detail of FrameWidget.
QQuick will roll their own stuff with similar api, but no need to
abstract QTabWidget and QTabBar
2020-06-03 22:18:44 +01:00
Sergio Martins
f5f39a37a1 Decouple DockWidget from TabWidget
TabWidget will be an implementation detail of FrameWidget, and not
shared by QtQuick
2020-06-03 21:38:47 +01:00
Sergio Martins
0a75d89848 Add Frame::detachTab()
The tab widget will be an implementation detail of FrameWidget and
not accessed by anyone
2020-06-03 21:18:38 +01:00
Sergio Martins
e418725c13 Don't create Frame directly, but FrameWidget, depending on the factory 2020-06-03 21:18:13 +01:00
Sergio Martins
180fb96ecc quick: Implement separator support
you can now drag separators in the QML example
2020-06-01 22:22:33 +01:00
Sergio Martins
83af55a592 quick: Refactor QQuickItem creation
So it can be reused
2020-06-01 20:58:02 +01:00
Sergio Martins
fe6d80ae89 vscode: Add Qt source mapping 2020-06-01 18:13:54 +01:00
Sergio Martins
103a0e514a quick: Use the original kddw indicators instead of yellow rectangles
looks nicer
2020-06-01 15:25:34 +01:00
Sergio Martins
7cc302c977 Rename Config.h to MultiSplitterConfig.h
So it doesn't clash with KDDW's Config.h
2020-06-01 15:14:34 +01:00
Sergio Martins
c2d51bddc8 quick: Some style improvements to the example 2020-06-01 14:53:18 +01:00
Sergio Martins
443f80cdab qtquick: Improve the multisplitter example
you can now drop relative to
2020-06-01 13:42:47 +01:00
Sergio Martins
9af3740d86 fix memory leak 2020-06-01 12:28:35 +01:00
Sergio Martins
567b61c9ec Allow separator to have pos=0
Can happen if widget has min-size 0
2020-06-01 12:16:35 +01:00
Sergio Martins
df8511b3dc Add an example of how to use the multisplitter with QtQuick 2020-06-01 12:16:00 +01:00
Sergio Martins
1dad16bb63 vscode: Build kddockwidgets in developer mode 2020-05-31 23:01:33 +01:00
Sergio Martins
4e88b3742d Honour max-size when docking
Layout will choose a suitable size for the dock widget when
addDockWidget() is called
2020-05-29 09:53:51 +01:00
Sergio Martins
a086713bb6 Implement FrameWidget::maxSizeHint() 2020-05-29 08:11:42 +01:00
Sergio Martins
0c0a232e07 Add vscode launch file for the example 2020-05-28 23:47:48 +01:00
Sergio Martins
a66e750f7d Add Frame::biggestDockWidgetMaxSize() 2020-05-28 23:47:03 +01:00
Sergio Martins
3697814141 Add Frame::dockWidgetsMinSize()
Like Frame::minSize() but smaller due to the tab widget overhead
2020-05-28 20:51:06 +01:00
Sergio Martins
d8af06a7ee Rename Item::maxSize to Item::maxSizeHint
It will more of an hint than really enforced in all cases
2020-05-28 20:20:24 +01:00
Sergio Martins
6797d291b6 Propagate max-size from the guest widget to DockWidget
Next step is propagating from DockWidget->Frame
2020-05-28 18:40:55 +01:00
Sergio Martins
798c808790 example: Set the max-size on the guest widget not on the dock
the size constraint will propagate up
2020-05-28 17:48:10 +01:00
Sergio Martins
4e3197388e Add a failing TestDocks::tst_maxSizePropagates 2020-05-28 17:47:57 +01:00
Sergio Martins
6cd5254779 Add a .vscode directory
Has some presets for debugging launching and configuring intellisense
via cmake
2020-05-26 22:07:22 +01:00
Sergio Martins
f770e768b8 example: Add option to load a layout from file 2020-05-26 21:53:58 +01:00
Sergio Martins
d07f715ed7 updateTitleBarVisibility after deserializing
Fixes floating window having two title bars
2020-05-26 21:53:51 +01:00
Sergio Martins
87c7a8ad65 Add unit-test for the previous commit 2020-05-26 20:17:37 +01:00
Sergio Martins
05f93a98f0 LayoutSaver: Only close dock widgets that would be restored
It can happen that the JSON layout knew about less dock widgets
than there are, as there can be new ones now
2020-05-26 19:49:02 +01:00
Sergio Martins
bab10c8d65 Add overloads to DockRegistry::clear()
So we can specify what to close
2020-05-26 19:13:34 +01:00
Sergio Martins
5e3a305a7c Add some useful DockRegistry overloads 2020-05-26 18:58:04 +01:00
Sergio Martins
c9fa637ae7 Add some helper methods to LayoutSaver::Layout
To retrieve the list of main windows and dock widgets present
in the loaded layout
2020-05-26 18:29:30 +01:00
Sergio Martins
79064b539a Another amalgamation fix 2020-05-26 16:16:31 +01:00
Sergio Martins
aa7107bde2 Silence some warnings on Windows 2020-05-26 16:13:56 +01:00
Sergio Martins
704e6d0182 Fix the amalgamation build a bit
As Config is already in another namespace
2020-05-26 16:12:25 +01:00
Sergio Martins
7634438f6c Add unit-test to previous commit 2020-05-25 23:30:31 +01:00
Sergio Martins
314cd6649d Item: also emit numVisibleItemsChanged when inserting a container
Since it can have items inside too
2020-05-25 23:27:13 +01:00
Sergio Martins
e08a7a6725 Fix tst_lastFloatingPositionIsRestored when there's a frame
Otherwise only passes on offscreen qpa which has no frame
2020-05-25 22:19:05 +01:00
Sergio Martins
45d5d7b519 update .gitignore 2020-05-25 21:47:03 +01:00
Sergio Martins
63c90875aa example: Add example of docking main window into main window 2020-05-25 21:45:21 +01:00
Sergio Martins
ee4ad02722 Fix FloatingWindow::hasSingleFrame()
Use m_dropArea->numFrames() which happens first, otherwise there
can be a moment where the frames() aren't updated yet
2020-05-25 21:43:01 +01:00
Sergio Martins
cd1f52a4bb When looking for drop target honour affinity 2020-05-25 21:29:29 +01:00
Sergio Martins
66a0959ac0 Honour main windows being nested in Frame::floatingWindow()
In such case the Frame is inside the nested main window, not floating.
2020-05-25 20:52:15 +01:00
Sergio Martins
39d70c8186 Fix crash due to recurency in DragController
A drop could cause the events to be processed and trigger
another mouse move

Fixes: #19
2020-05-25 20:48:18 +01:00
Sergio Martins
d541a41536 Minor refactoring, factor some code into a function 2020-05-25 20:40:02 +01:00
Sergio Martins
9761759fee Fix Floating window returning frames from nested main windows
Which we want to support now too
2020-05-25 20:27:08 +01:00
Sergio Martins
d4d83111ff Added DockWidgetBase::isMainWindow() 2020-05-25 20:25:33 +01:00
Sergio Martins
de09d5532f Fix DropArea::numFrames()
Was counting with placeholder items too. This should fix title bars
being wrong in some cases.
2020-05-25 20:12:29 +01:00
Sergio Martins
944138273f Tests: stabilize tst_embeddedMainWindow
Going 50px into the window was too short and didn't reach the embedded
window to show the indicators.

Also, it's the inner indicator we want, the other isn't visible as the
window is single frame
2020-05-25 20:11:01 +01:00
Sergio Martins
d2ca14bf99 DebugWindow: Also print affinities 2020-05-25 14:39:19 +01:00
Sergio Martins
84391c693c DebugWindow: Remove duplicate dump debug button
And the second one was incomplete as it didn't dump for the
floating windows
2020-05-25 14:31:21 +01:00
Sergio Martins
d94263fce5 Allow each dock widget and main window to support multiple affinities 2020-05-25 14:14:17 +01:00
Sergio Martins
2fd9d45525 Link multisplitter as a PUBLIC dependency if kddockwidgets
This way user doesn't need to explicitly link against it
2020-05-25 06:52:25 +01:00
Sergio Martins
8461f1f79e kddockwidgets_multisplitter is now a library of its own 2020-05-25 06:45:13 +01:00
Sergio Martins
d9badf3ffd Fix build 2020-05-25 06:10:18 +01:00
Sergio Martins
1ece0f0fef Add a fwd header for Separator_qwidget.h
Makes QtC happy with editing the example
2020-05-24 20:54:25 +01:00
Sergio Martins
4af582a21f Update .gitignore 2020-05-24 20:53:52 +01:00
Sergio Martins
ab90da3b19 Readability: Rename Item::guest() and Item::widget()
Their name wasn't matching their return value
2020-05-24 20:52:23 +01:00
Sergio Martins
45f4d9f6a8 Item no longer depends on QWidget 2020-05-24 20:47:58 +01:00
Sergio Martins
ba49e1cbe2 Separator no longer inherits from QWidget
Only SeparatorWidget does
2020-05-24 20:29:49 +01:00
Sergio Martins
c67f1c28f6 Fix build 2020-05-24 20:23:07 +01:00
Sergio Martins
de0bcf9ce3 readability: Rename asWidget() to asQWidget() 2020-05-24 20:03:02 +01:00
Sergio Martins
3bbc33d8c4 example: Revive the custom separator example
Pass -p to see a custom painted separator
2020-05-24 19:31:15 +01:00
Sergio Martins
e8abc23f59 Use a dedicated export macro file for multisplitter/
As it's independent from KDDW
2020-05-24 19:24:16 +01:00
Sergio Martins
c63c713bea Move SeparatorWidget into multisplitter/
multisplitter/ is to be a reusable component without needing KDDW
2020-05-24 19:13:39 +01:00
Sergio Martins
c33c7ab450 Don't leak Layouting::Widget
Don't create it directly, instead of multi-inheritance
2020-05-24 18:45:44 +01:00
Sergio Martins
c31edd0cd8 Remove a stray qDebug 2020-05-24 18:30:56 +01:00
Sergio Martins
b395b96234 Fix tst_multisplitter leaks
The Widget wrapper was leaking
2020-05-24 18:30:07 +01:00
Sergio Martins
16aac70510 Make MultiSplitter inherit from Layouting::Widget too
Since it's the host widget.
Fixes the Widget wrapper leaking. And no need for so much boiler-plate
2020-05-24 18:25:19 +01:00
Sergio Martins
7c9ee4f497 Move the mouse handling from Separator to SeparatorWidget
As it's QWidget specific
2020-05-24 17:58:04 +01:00
Sergio Martins
7f49f6e6a4 Move the separator's rubber band into SeparatorWidget
as it's specific to QWidget
2020-05-24 17:49:14 +01:00
Sergio Martins
c477fce1d9 Add Widget::show(), hide() and setGeometry() 2020-05-24 17:43:54 +01:00
Sergio Martins
e28f82dcad Make Item::hostWidget be a Layouting::Widget instead of QWidget
Just an abstraction preparing for QQuickItem support
2020-05-24 17:31:37 +01:00
Sergio Martins
7016656264 Rename GuestInterface to Widget
So we can use it to abstract the host too, not just the guest.
2020-05-24 15:23:10 +01:00
Sergio Martins
7f981a1d1d Item cleanup, moved LengthOnSide to impl 2020-05-24 14:05:04 +01:00
Sergio Martins
94b4051e31 Fix namespace build 2020-05-24 13:57:17 +01:00
Sergio Martins
86a2b14921 Move more code to GuestWidget 2020-05-23 21:14:11 +01:00
Sergio Martins
4fab2cf360 Move more code into GuestWidget 2020-05-23 20:11:27 +01:00
Sergio Martins
0a2fb6ed73 Add GuestWidget.h
The QtWidgets counter-part for GuestInterface.

Removing QWidget from Item
2020-05-23 19:22:01 +01:00
Sergio Martins
3d95263b40 Fix examples build with installed kddw 2020-05-23 19:00:12 +01:00
Sergio Martins
e75b47737c Move GuestInterface into its own file 2020-05-23 18:59:58 +01:00
Sergio Martins
9ad6eefa7a Add Layouting::Config
To host many of the scatered static member variables which
held some settings that rarely change
2020-05-23 18:40:20 +01:00
Sergio Martins
2527b39368 Moved the multisplitter wrapper outside of multisplitter/
As it depends on kddw framework, while multisplitter/ is the
agnostic layouting engine
2020-05-23 17:01:20 +01:00
Sergio Martins
71c7a7c9a9 Move more ItemContainer members to private 2020-05-23 16:46:43 +01:00
Sergio Martins
72c2586e20 Item: move a bunch of members to the private impl 2020-05-22 21:30:24 +01:00
Sergio Martins
7c5ed8bf84 Merge pull request #45 from OlivierJG/master
Fix include path so private header can be used
2020-05-22 20:30:51 +01:00
Olivier JG
70f0c49709 Fix include path so private header can be used 2020-05-22 14:17:02 -05:00
Sergio Martins
986a25971e Also print the widget geometry if it's different from the item 2020-05-22 15:56:02 +01:00
Sergio Martins
0c776b6595 Fix non-developer build 2020-05-22 12:26:21 +01:00
Sergio Martins
7a852f700f Save floating geometry right before starting a drag
so if you drop, then set floating again it goes to the original
floating position
2020-05-22 12:15:24 +01:00
Sergio Martins
bd848d8040 Add Draggable::singleDockWidget()
If the draggable only has a single dock widget, returns it.
Otherwise nullptr.
2020-05-22 12:14:12 +01:00
Sergio Martins
a7013b4cf7 Make DockWidget::setFloating(false) save the last docking position
so we can restore to it when floating again
2020-05-22 11:42:00 +01:00
Sergio Martins
8e39ce2dea When floating via titlebar, restore to correct floating position
If the title bar has a single dock widget and you press the float
button, then use the DockWidget's "last floating position" to
position the new floating window
2020-05-22 11:37:52 +01:00
Sergio Martins
4917da9e7c Minor: factorout some code into DockWidget::saveLastFloatingGeometry() 2020-05-22 11:37:25 +01:00
Sergio Martins
6d44362991 DockWidget::setFloating(true): restore to previous floating position
When floating a dock widget we restore it to the last known floating
position now
2020-05-22 11:12:12 +01:00
Sergio Martins
b3b25ba047 Save the last floating geometry right before docking
Previously it was only saved on close(), which isn't enough
2020-05-22 11:01:31 +01:00
Sergio Martins
76ba261f62 Return LastPositions by reference
Otherwise we're calling setters on a temporary
2020-05-22 10:53:37 +01:00
Sergio Martins
d9184e2396 debug++ 2020-05-21 20:07:09 +01:00
Sergio Martins
ce7c913f8c Move the last floating geometry 1 level up
So it's not overwritten.
Added a unit-test for testing that floating geometry doesn't break
2020-05-21 19:32:18 +01:00
Sergio Martins
b4526b007c Make LastPositions::lastPosition private
Need to control how the setters are messing with it, to add more
of them
2020-05-21 18:56:44 +01:00
Sergio Martins
618ec9fd41 Minor, use the members directly 2020-05-21 18:15:06 +01:00
Sergio Martins
e1c18de48e Remove unused Frame::dumpDebug()
Should be operator<<(QDebug) anyway if we need it
2020-05-21 18:05:24 +01:00
Sergio Martins
9779b8edc3 Deal in terms of LastPositions instead of the individual position
Just a refactoring to add more encapsulation
2020-05-21 17:43:51 +01:00
Sergio Martins
50934ae56d Use a shared_ptr for Position, so we can pass LastPositions by value 2020-05-21 17:19:54 +01:00
Sergio Martins
2da37180b9 Start supporting multiple last positions
Pushing some boilerplate first, so the functional diff is smaller.
Wraps the old position class with one that will have many.
2020-05-21 16:52:03 +01:00
Sergio Martins
7ab1500651 Add a QDebug operator for Position 2020-05-21 15:28:24 +01:00
Sergio Martins
f260a76f8b Rename LastPosition to Position
so we can have a list of them, the dock widget might have been
in several main windows
2020-05-21 14:49:49 +01:00
Sergio Martins
ba740a4934 Do a complete relayout if the loaded json layout isn't valid
The layout can be valid on disk might it might happen that
the guest QWidgets have different min-sizes now (in a different
run of our app), so we need to relayout
2020-05-20 21:30:55 +01:00
Sergio Martins
e0f16ae57e Add a kddockwidgets_linter executable
For linking layout json files. Returns non 0 if invalid, and
probably some warnings too.
2020-05-20 19:19:07 +01:00
Sergio Martins
8a3e784ae2 Make layout saver create the main window if it's missing
and we have a factory. The same way it happens for dock widgets.
2020-05-20 19:19:07 +01:00
Sergio Martins
01112779b0 Add a Config::mainWindowFactoryFunc
Analog to the dock widget factory func.
To be used by the linter.
2020-05-20 19:06:54 +01:00
Sergio Martins
6de5860e9a Don't allow to drop to itself when having mainwindow inside dock widget 2020-05-20 16:33:48 +01:00
Sergio Martins
1061edb3b0 Remove asserts that are already guarded by a warning
that's enough for the tests to fail
2020-05-20 15:30:57 +01:00
Sergio Martins
88b830d297 set the max size on the item too when setting the guest widget
Not honoured yet
2020-05-20 14:33:27 +01:00
Sergio Martins
283d2a80c7 Add Item::maxSizeChanged signal and improve setter 2020-05-20 14:25:42 +01:00
Sergio Martins
215e8cfd24 example: Cleanup some options a bit 2020-05-20 14:25:23 +01:00
Sergio Martins
235018bfae example: Set the max-size before docking 2020-05-20 10:05:11 +01:00
Sergio Martins
dc87c05f04 example: Add an option to text max-sizes
Support not done yet, but useful for testing
2020-05-19 23:22:39 +01:00
Sergio Martins
4a17b04310 Item::dumpDebug: Also print the max-size, if any 2020-05-19 22:48:14 +01:00
Sergio Martins
6001e655fd Fix crash when moving separator
We weren't recurring up the tree to find the next separator
2020-05-19 14:46:30 +01:00
Sergio Martins
af22e3e12d Fix tst_raise on XCB 2020-05-19 13:44:01 +01:00
Sergio Martins
0d3ae48fed Refuse to save invalid layouts
Now layout saver won't save if the root ItemContainer::checkSanity()
is false
2020-05-19 13:15:31 +01:00
Sergio Martins
9e198917f0 Try to recover from loading an invalid layout 2020-05-19 12:35:33 +01:00
Laurent Montel
d2531d48d3 Make it compile against qt < 5.10 QRandomGenerator was created in qt5.10 2020-05-19 11:20:28 +02:00
Sergio Martins
dc0dab6a83 DebugWindow: Add button to show all dock widgets 2020-05-19 10:05:41 +01:00
Laurent Montel
8b81cd12f8 Compile without deprecated method (qrand is deprecated. Replaced by QRandomGenerator) 2020-05-19 11:03:38 +02:00
Sergio Martins
044c590b92 Fix ambiguous enum on Windows
Can happen when using an amalgamation, due to the "using namespace"
clauses
2020-05-18 22:00:52 +01:00
Sergio Martins
6c2a29968a Fix include 2020-05-18 21:51:26 +01:00
Sergio Martins
90fe9be6f6 DebugViewer: Fix crash at shutdown 2020-05-18 18:54:13 +01:00
Sergio Martins
2350f847d7 Item: Dump screen information too 2020-05-18 13:46:06 +01:00
Sergio Martins
8f7df69fa1 Add unit-test for previous commit 2020-05-18 11:48:18 +01:00
Sergio Martins
b687224801 Fix separators not moving when having invisible items
typo...
2020-05-18 11:40:33 +01:00
Sergio Martins
209005478e only build multisplitter test if in developer mode 2020-05-18 09:28:15 +01:00
Sergio Martins
af25af1259 Add MainWindow::layoutEqually()
Distributes the space equally between all dock widgets
2020-05-18 00:05:50 +01:00
Sergio Martins
8b0be3b2ba Add ItemContainer::layoutEqually()
Distributes all the space equally through the container.
Still respects min/max
2020-05-17 23:44:45 +01:00
Sergio Martins
43fafa1f33 Fix -Wextra-semi 2020-05-17 22:32:08 +01:00
Sergio Martins
ea56d20959 Fix clazy warnings about unused trivial variables 2020-05-17 19:15:59 +01:00
Sergio Martins
8477fdc7e1 Fix detachments 2020-05-17 19:14:50 +01:00
Sergio Martins
d613d25ef5 Add missing emit keyword 2020-05-17 19:12:09 +01:00
Sergio Martins
c5d9b38fc2 Disable copy of polymorphic types 2020-05-17 19:11:45 +01:00
Sergio Martins
36061fc6dc Fix detach of temporary 2020-05-17 19:08:07 +01:00
Sergio Martins
2b6b6e2ba5 Disable copy for LayoutSaver, it has a dtor, but no copy-ctor 2020-05-17 19:07:26 +01:00
Sergio Martins
adedcfd6db Use fully qualified types in signals 2020-05-17 19:06:24 +01:00
Sergio Martins
a9e02ccd41 example: Don't leak the dock widgets on shutdown 2020-05-17 18:02:03 +01:00
Sergio Martins
4647814aae Fix tests with Qt 5.9
QTabWidget is a bit flaky and changes min width at unexpected times.
Which is fine but we can't compare against the expected min size
since it changes. So just check sanity of the restored layout
2020-05-17 17:12:31 +01:00
Sergio Martins
5b1b029b80 Fix Item::calculateSqueezes() squeezing too much
Fixes tst_28NestedWidgets:28 with Qt 5.9
2020-05-17 16:28:36 +01:00
Sergio Martins
6fe998d9df Add build* to .gitignore 2020-05-17 15:04:53 +01:00
Sergio Martins
131b43a833 Item: Ignore item changing min size when it's not visible
Fixes tst_crash2 with Qt 5.9. Added a proper test too.
2020-05-17 15:03:54 +01:00
Sergio Martins
a87ab40aad Implement support for double-clicking a separator
Will resize the left and right widget, so they have the same size
2020-05-16 20:18:32 +01:00
Sergio Martins
2fb66c681b Item: Register the location enum for pretty debugging 2020-05-16 19:45:08 +01:00
Sergio Martins
0bd2f8f23a tests: Add sanity checks for the tested rects
Catches the situtions fixed in the two previous commits.
2020-05-16 19:44:35 +01:00
Sergio Martins
0f796da901 Fix suggestedDropRect() not returning in global coords 2020-05-16 19:44:06 +01:00
Sergio Martins
cc5578f8f4 Fix inserting items in the list when there's hidden items 2020-05-16 19:43:18 +01:00
Sergio Martins
f89aa59371 Implement an exact Item::suggestedDropRect()
It will create a temporary, invisible layout, insert a copy of the item,
and see where it landed.
2020-05-16 18:20:48 +01:00
Sergio Martins
3f242a8b59 tests: Test Item::suggestedDropRect() more 2020-05-16 12:37:23 +01:00
Sergio Martins
c4b94f0f21 tests: pain a background in the host and guest widgets
For easier visual debugging
2020-05-16 12:36:44 +01:00
Sergio Martins
582ce6ef31 Item: Add pathFromRoot() and itemFromPath()
An easy way to identify an item within a layout.
2020-05-16 12:35:39 +01:00
Sergio Martins
10b47a8f9c Item: Allow to have items that don't have an host QWidget
So we can create dummy ones, for usage in suggestDropRect()
2020-05-16 12:34:31 +01:00
Sergio Martins
d2716cf1c5 Item: Improve assert, don't dereference nullptr 2020-05-16 12:33:09 +01:00
Sergio Martins
2984b62ca0 Item: Fix warning about setSize() having an empty size
When doing setLength() make sure that the other dimension isn't 0,
as the item the user is trying to insert could have had an empty
size to begin with
2020-05-16 12:32:00 +01:00
Sergio Martins
1f6c49d5ba Fix 5.15 build 2020-05-14 22:39:17 +01:00
Sergio Martins
d0b36cf932 add ctest to tst_multisplitter too
moved up otherwise the multisplitter one was being generated in
a different folder
2020-05-14 22:29:19 +01:00
Sergio Martins
d1d1c983f1 Remove "using namespace Layouting" out of the layouting lib
Fixes windows build due to ambiguous symbols
2020-05-14 22:02:27 +01:00
Sergio Martins
c5d880c124 Fix build on Windows
Location being ambiguous
2020-05-14 21:21:55 +01:00
Sergio Martins
d44a6f78b8 Fix build with older Qt 2020-05-14 21:10:46 +01:00
Sergio Martins
0abb6292c1 Remove a sanity check, it's called from unit tests already 2020-05-14 20:53:54 +01:00
Sergio Martins
2bf977ede7 Fix build on older compilers 2020-05-14 20:42:57 +01:00
Sergio Martins
5bad616c5a Fix some memory leaks 2020-05-14 20:34:54 +01:00
Sergio Martins
e0cd9d95b5 Pass an entire item to Item::suggestedDropRect()
So we can do more powerful calculations in the future
2020-05-13 22:35:02 +01:00
Sergio Martins
b743565ea3 Fix Item::suggestedRect() when the parentContainer() wasn't root 2020-05-13 22:35:02 +01:00
Sergio Martins
be1a2a3878 Fix build on Windows 2020-05-13 20:04:48 +01:00
Sergio Martins
b7cb6afa49 Item: Also position the opposite position, not just the length
Fixes fuzzer test 20.json
2020-05-13 19:39:30 +01:00
Sergio Martins
0db40953ac fuzzer: don't dump invalid operations to the JSON 2020-05-13 19:37:47 +01:00
Sergio Martins
137cf017c4 fuzzer: add a nice place to set a breakpoint 2020-05-13 19:37:47 +01:00
Sergio Martins
68acdaeb9a Fix Items not being connected to their parent after a restore
Missing connectToParent() calls.
2020-05-13 12:24:46 +01:00
Sergio Martins
4dea453e7c fuzzer: Trim failling test 2020-05-11 00:25:09 +01:00
Sergio Martins
ca52d6f760 fuzzer: Add a failing test 2020-05-11 00:05:00 +01:00
Sergio Martins
5eff4f8df8 fuzzer: fix dumping to JSON skipping some operations
Operations that don't have any parameters werent being saved
2020-05-11 00:04:26 +01:00
Sergio Martins
cc2aa13eb7 fuzzer: Fix dockByName() returning nullptr
dockStr() is just for printing purposes
2020-05-10 23:44:48 +01:00
Sergio Martins
c4241b92f1 Item: When restoring, only shrink the immediate neighbours
So it matches the behaviour of closing an item, where only immediate
neighbours grow.

Now, pressing the float button multiple times will always put the
item on the same place, and not disturb non-immediate neighbours
2020-05-10 23:24:18 +01:00
Sergio Martins
1a0299d758 Simplify the NeighbourSqueezeStrategy enum
And make it agnostic to how separators work, so it can shrinkNeighbours()
can be reused in other contexts.
2020-05-10 22:44:53 +01:00
Sergio Martins
550d84ab11 Rename for readability 2020-05-10 22:26:40 +01:00
Sergio Martins
2450f9b39f Minor rename for readability 2020-05-10 22:23:36 +01:00
Sergio Martins
f6f70f26e4 Item: Also pass the neighbour shrink strategy all along
So we can choose another one when restoring a child
2020-05-10 22:17:59 +01:00
Sergio Martins
c4df3600af tst_docks|fuzzer: Use offscreen QPA by default too 2020-05-10 21:26:52 +01:00
Sergio Martins
0f0209ddf3 tst_multisplitter: Use offscreen QPA by default
It's less anoying as it doesn't show a window
2020-05-10 21:21:20 +01:00
Sergio Martins
0dac5eed68 Item: Add DefaultSizeMode enum
To control how we calculate the item's initial size when
we add it
2020-05-10 21:20:31 +01:00
Sergio Martins
11576c5455 ECM: Only set the sanitizers for DEBUG config
ECMEnableSanitizers isn't being friendly of multi generators, like
-G "Ninja Multi-Config" and is messing with global flags which is a no-no.
Instead it should be using a dedicated custom config IMHO.

With this change only debug will get the sanitizers, so you can for instance
build with -DCMAKE_CONFIGURATION_TYPES=Debug;RelWithDebInfo and have Debug
hardeneded with the sanitizers while the RelWithDebInfo without sanitizers,
ideal for profiling.
2020-05-10 17:49:20 +01:00
Sergio Martins
93c471623b Silence -Wmaybe-uninitialized false-positive 2020-05-10 15:20:59 +01:00
Sergio Martins
925df72c0f Fix propagation of resize when dragging a separator
It was ok but was resizing children via the "percentage method",
and we only want to resize the children next to the separator.
2020-05-10 15:07:42 +01:00
Sergio Martins
babed642eb Fix warning saying item size being too small
If the widget's size is smaller than hardcodedMinimumSize then
it would be violating the min-size constraint
2020-05-10 12:45:58 +01:00
Sergio Martins
fd9bcdeabe Fix crash if root() is nullptr when printing a warning 2020-05-09 18:37:35 +01:00
Sergio Martins
2fe1e22076 Remove OPTION_SANITIZER_SUPPORT
We have ECM inside the repo now, so no point in guarding the include
2020-05-09 17:55:22 +01:00
Sergio Martins
a9d0ec3fdd Use a better strategy for size propagation when resizing via separator
Behaves like old kddockwidgets now.
When dragging a separator, only the immediate neighbours are resized.
Only when min-sizes are violated that it propagates.
2020-05-09 17:42:55 +01:00
Sergio Martins
ed6d5134b0 Implement Side1 and Side2 resizing strategies
to be used when dragging separators when mouse, as we don't want
a recursive resize dealing with percentages, as it doesn't need to be fair.
Items near the mouse/separator will suffer/benetif more from there resize.
Resize only propagates further when size-constraints come into action
2020-05-09 13:28:59 +01:00
Sergio Martins
1f2bdaf188 Factor out children resize logic into Item::resizeChildren()
as we'll have other stragies for resizing children
2020-05-09 12:49:03 +01:00
Sergio Martins
a9be454604 Item: Rename resize to setSize_recursive() 2020-05-09 12:14:08 +01:00
Sergio Martins
7c85c1eb0f Resize the layout after restoring
After restoring, we need to put the layout at the same size
as its widget. Most of the times this happens since we also restore
the widget's geometry. But really make sure, as something might happen
to the window geometry, like for example using RestoreOption_RelativeToMainWindow
which doesn't restore the main window geometries
2020-05-09 00:46:30 +01:00
Sergio Martins
addf436fd0 LayoutSaver: Don't load old serialization versions 2020-05-08 19:30:41 +01:00
Sergio Martins
ff6260a4dc tests: Add a failling test tst_invalidLayoutAfterRestore
And a JSON file that makes it fail
2020-05-08 18:40:23 +01:00
Sergio Martins
48f872f696 Remove extra semi 2020-05-08 18:01:28 +01:00
Sergio Martins
e3e31ca5ca Ensure kddockwidgets_layouting is STATIC
Otherwise we get errors as only kddockwidgets is exported. It's
not public API for now
2020-05-08 18:00:42 +01:00
Sergio Martins
4b05d4ddd7 Remove unused Item_p.h include 2020-05-08 17:02:58 +01:00
Sergio Martins
e6e63806f8 MultiSplitterLayout_p.h: Forward declare Frame and Item 2020-05-08 17:01:07 +01:00
Sergio Martins
d267b0e0dd LastPosition: Forward declare Layouting::Item 2020-05-08 16:46:42 +01:00
Sergio Martins
96ee076e9a Add pimpl to Separator 2020-05-08 16:43:03 +01:00
Sergio Martins
7e86a32a23 Readability++
let the reader know position isn't imported at this stage
2020-05-07 23:34:57 +01:00
Sergio Martins
09026fd312 Uncomment assert 2020-05-07 23:05:59 +01:00
Sergio Martins
d2dca56ce6 Implement lazy resize in the new engine
We're almost feature complete
2020-05-07 19:35:05 +01:00
Sergio Martins
3742e5ef9a example: No persistent central frame by default
This is old style, which we don't use anymore by default
2020-05-07 19:32:32 +01:00
Sergio Martins
7ed54631ac Item: unit-tests++ 2020-05-07 18:49:18 +01:00
Sergio Martins
3c1ab0126d Item: Clear and honour a bunch of TODOs 2020-05-07 18:49:00 +01:00
Sergio Martins
0df9943aa5 Fix fuzzer test 11.json and other tests that worked by luck
mapFrom/toRoot were wrong
2020-05-07 16:30:45 +01:00
Sergio Martins
d4cc9e85eb Add more sanity checks to Item
Checks that the parentContainer and hostWidget are correct
for each separator
2020-05-07 12:35:58 +01:00
Sergio Martins
5f7899f265 Item: Remove unused methods 2020-05-07 00:08:04 +01:00
Sergio Martins
61bedce278 Separators now are able to be moved by the user with mouse 2020-05-06 22:52:36 +01:00
Sergio Martins
cd053d0cc4 Unit-tests++ 2020-05-06 00:01:46 +01:00
Sergio Martins
06a7346281 Introduce ItemContainer::availableOnSide_recursive()
and use it for calculating the min/max position of a separator

The min/max position of a separator isn't local to its container,
but is recursive upwards until root
2020-05-05 23:16:57 +01:00
Sergio Martins
535a0c943c Remove some cruft, bunch of unused methods from old layouting engine 2020-05-04 23:37:04 +01:00
Sergio Martins
e298667351 Remove dead code about static separators
Before we had separators on the left,top,bottom,right margins
with 0 width. Now we don't have this concept anymore
2020-05-04 14:28:59 +01:00
Sergio Martins
0595448bba Replace Anchor with Separator
We don't have the concept of Anchors anymore. Code is now simpler
2020-05-04 13:10:38 +01:00
Sergio Martins
97c1ca30fd Layouting engine rewrite
The layouting was becoming too complex to maintain and to introduce
new features. Was even buggy, the fuzzer was constantly finding
bugs, which took hours to workaround.

Problem with the old layout engine is that there was a catch 22, between
Items driving the separators, and separators driving the anchors.

The new layout is much simpler, both in implementation and conceptually.
There's simply a recursive hierarchy of Item elements. An Item can either
have a QWidget to show, or be a ItemContainer, which contains Item children,
and so forth. Each ItemContainer is either vertical or horizontal. That's enough
to represent the "nested multi-splitter" concept which KDDW uses.

After each item insertion/deletion/resize, the separators are regenerated. They
are essentially dumb now.

TODO:
- Separators are drawn, but are not interactive yet
- There's 5 tests failing
- LayoutSaver scalling functionality
2020-05-04 00:02:03 +01:00
Sergio Martins
86d1a52bbf Fix unit-test
Was leaving window leftovers behind.
Delete them.
2020-05-03 16:41:52 +01:00
Sergio Martins
2d007c558a Update .gitignore 2020-05-02 14:18:30 +01:00
Sergio Martins
dc4a1975ab Fix build with cmake < 3.12
3.12 is needed for HOMEPAGE_URL and DESCRIPTION support.

Bumped the minimum to 3.7, older fails.
Fixes: 43
2020-05-02 14:14:04 +01:00
Sergio Martins
144897e831 Fix namespaced build 2020-05-01 15:35:05 +01:00
Sergio Martins
e87f6d001e example: Fix duplicate command line argument switch 2020-05-01 13:09:27 +01:00
Sergio Martins
8cc53ca5bb Also build the example when building KDDW
No need to install the library anymore
Fixes: #42
2020-05-01 13:07:25 +01:00
Sergio Martins
1b337b5391 Merge pull request #41 from KDAB/float_action
Add test for dock floating action
2020-05-01 11:45:43 +01:00
Colin Ogilvie
e383bc797e Run tests with ctest 2020-04-30 18:12:35 +01:00
Colin Ogilvie
43a25ef93b Add test for foating action 2020-04-30 16:56:13 +01:00
Sergio Martins
19e519912b Merge pull request #40 from KDAB/float_action
Float action
2020-04-30 13:45:07 +01:00
Colin Ogilvie
68f0c64954 Add a DockWidgetBase::floatAction()
Helper action to allow docking/detaching
2020-04-30 13:39:02 +01:00
Sergio Martins
e8db004874 Windows: Fix maximized window size when using the maximize
When the maximize is triggered by Qt, we get the WM_GETMINMAXINFO
too soon, as QWindow already says it's maximized, while it's still
in process of being.

Just removed the condition, doesn't seem to have any bad side-effect
2020-04-20 20:55:11 +01:00
Sergio Martins
6ee3cfbb2d Introduce "Maximize/restore" title bar button support
As happens with other docking frameworks:
- Maximized/restore button only visible when window is floating
- floating button is never visible

Available by setting Flag_TitleBarHasMaximizeButton.
Added example too.

Fixes: #37
2020-04-20 19:55:51 +01:00
Sergio Martins
ab0fc1e328 Add DockWidget::Option_NonDockable
A dock widget with this option will always be floating and not be
able to dock into anything. Other widgets can't dock into it either.
2020-04-13 13:23:38 +01:00
305 changed files with 31453 additions and 11733 deletions

2
.clazy
View File

@@ -1 +1 @@
CHECKS level2,detaching-member,heap-allocated-small-trivial-type,isempty-vs-count,qstring-varargs,qvariant-template-instantiation,raw-environment-function,reserve-candidates,signal-with-return-value,thread-with-slots
CHECKS level2,detaching-member,heap-allocated-small-trivial-type,isempty-vs-count,qstring-varargs,qvariant-template-instantiation,raw-environment-function,reserve-candidates,signal-with-return-value,thread-with-slots,no-ctor-missing-parent-argument,no-missing-qobject-macro

22
.gitignore vendored
View File

@@ -6,10 +6,10 @@ Makefile
CMakeFiles
CMakeCache.txt
/examples/example
libdocks.so
tst_docks
CMakeLists.txt.user*
/build
/examples/dockwidgets/build/
moc_*
*.moc
*automoc.cpp
@@ -33,11 +33,29 @@ cmake_install.cmake
latex
html
custom_titlebar
libkddockwidgets.so
libkddockwidgets.so*
libkddockwidgets_multisplitter.so*
*.depends
kddockwidgets_basic_quick
/src/KDDockWidgetsConfig.cmake
/src/KDDockWidgetsConfigVersion.cmake
build-*
/build*
/examples/dockwidgets/kddockwidgets_example
.cmake
CTestTestfile.cmake
mylayout.json
*.cbp
*.pyc
/python/examples/rc_assets.py
*.pri
/docks-w
kddockwidgets_minimal_example
/docs/api/Doxyfile
/docs/api/qch/kddockwidgets-api.qch
/doxygen.log
/kddockwidgets.tag
/CMakeDoxyfile.in
/CMakeDoxygenDefaults.cmake
/Testing
/layout_tst*

7
.krazy
View File

@@ -1,7 +1,7 @@
CHECKSETS qt5,c++
#KDAB-specific checks
EXTRA kdabcopyright
EXTRA kdabcopyright-reuse,kdabcontactus,fosslicense-reuse
#additional checks
#EXTRA defines,null
@@ -11,8 +11,11 @@ EXCLUDE strings,explicit,normalize,passbyvalue,operators,nullstrcompare,nullstra
#exclude more checks
EXCLUDE style
SKIP /fwd_headers/
SKIP Doxyfile.cmake
#skip CMake files
SKIP /KDDockWidgetsConfig.cmake.in
#skip the borrowed code in the cmake subdir
SKIP /cmake/Qt5Portability.cmake|/cmake/ECM/
SKIP /cmake/Qt5Portability.cmake|/cmake/ECM/|/cmake/InstallLocation.cmake

68
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,68 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) QtWidgets example",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/kddockwidgets_example",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "(gdb) QtQuick example",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/kddockwidgets_example_quick",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "(vs) kddockwidgets_example",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/kddockwidgets_example.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"sourceFileMap" : {
"C:\\Users\\qt\\work\\qt\\qtbase\\src" : "D:\\Qt\\5.14.2\\Src\\qtbase\\src"
}
},
{
"name": "(vs) tst_docks",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/tst_docks.exe",
"args": ["tst_moreTitleBarCornerCases", "-platform", "windows"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false
}
]
}

10
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,10 @@
{
"C_Cpp.default.configurationProvider": "vector-of-bool.cmake-tools",
"files.associations": {
"qevent": "cpp"
},
"cmake.configureSettings": {
"KDDockWidgets_DEVELOPER_MODE" : "ON",
"KDDockWidgets_QTQUICK" : true
}
}

View File

@@ -1,52 +1,205 @@
cmake_minimum_required(VERSION 3.3)
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
project(KDDockWidgets
VERSION 0.1
DESCRIPTION "An advanced docking system for Qt"
HOMEPAGE_URL "https://github.com/KDAB/KDDockWidgets"
LANGUAGES CXX)
# Pass the following variables to cmake to control the build:
#
# -DKDDockWidgets_STATIC=[true|false]
# Build static versions of the libraries
# Default=false
#
# -DKDDockWidgets_TESTS=[true|false]
# Build the test harness.
# Default=false
#
# -DKDDockWidgets_EXAMPLES=[true|false]
# Build the examples.
# Default=true
#
# -DKDDockWidgets_DOCS=[true|false]
# Build the API documentation.
# Default=false
#
# -DKDDockWidgets_DEVELOPER_MODE=[true|false]
# Configure the build for a developer setup.
# Enables some features that are not geared towards end-users.
# Forces the test harness to be built.
# Default=false
#
# -DKDDockWidgets_PYTHON_BINDINGS=[true|false]
# Build/Generate python bindings. Always false for Debug builds
# Default=false
#
# -DKDDockWidgets_PYTHON_BINDINGS_INSTALL_PREFIX=[path]
# alternative install path for python bindings
# Default=CMAKE_INSTALL_PREFIX
#
cmake_policy(SET CMP0020 NEW)
cmake_policy(SET CMP0042 NEW)
cmake_minimum_required(VERSION 3.7)
if(POLICY CMP0020)
cmake_policy(SET CMP0020 NEW)
endif()
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
option(OPTION_DEVELOPER_MODE "Developer Mode" OFF)
option(OPTION_SANITIZER_SUPPORT "Activate support for using sanitizers" OFF)
# option(OPTION_QTQUICK "Build for QtQuick instead of QtWidgets" OFF)
set(KDAB_INSTALL True)
if((NOT DEFINED ${USE_DEFAULT_INSTALL_LOCATION}) OR (NOT ${USE_DEFAULT_INSTALL_LOCATION}))
if(NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL "")
set(KDAB_INSTALL False)
endif()
set(USE_DEFAULT_INSTALL_LOCATION ${KDAB_INSTALL} CACHE INTERNAL "Install to default KDAB Location" FORCE)
endif()
find_package(Qt5Widgets)
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
project(KDDockWidgets LANGUAGES CXX)
else()
project(KDDockWidgets
DESCRIPTION "An advanced docking system for Qt"
HOMEPAGE_URL "https://github.com/KDAB/KDDockWidgets"
LANGUAGES CXX)
endif()
set(${PROJECT_NAME}_VERSION_MAJOR 1)
set(${PROJECT_NAME}_VERSION_MINOR 1)
set(${PROJECT_NAME}_VERSION_PATCH 0)
set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH})
set(${PROJECT_NAME}_SOVERSION "1.1")
include(FeatureSummary)
option(${PROJECT_NAME}_DEVELOPER_MODE "Developer Mode" OFF)
option(${PROJECT_NAME}_PYTHON_BINDINGS "Build python bindings" OFF)
if(${PROJECT_NAME}_PYTHON_BINDINGS AND (CMAKE_BUILD_TYPE MATCHES "^[Dd]eb" OR ${PROJECT_NAME}_STATIC))
message(FATAL_ERROR "** Python Bindings are disabled in debug or static builds.")
endif()
option(${PROJECT_NAME}_TESTS "Build the tests" OFF)
option(${PROJECT_NAME}_EXAMPLES "Build the examples" ON)
option(${PROJECT_NAME}_DOCS "Build the API documentation" OFF)
#Always build the test harness in developer-mode
if(${PROJECT_NAME}_DEVELOPER_MODE)
set(${PROJECT_NAME}_TESTS ON)
endif()
find_package(Qt5Widgets 5.9 REQUIRED)
set(CMAKE_AUTOMOC ON)
set(ECM_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ECM/modules/")
set(CMAKE_MODULE_PATH ${ECM_MODULE_DIR})
set(PYTHON_MODULE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake/Python")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake" ${ECM_MODULE_DIR} ${PYTHON_MODULE_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if (OPTION_SANITIZER_SUPPORT)
include(ECMEnableSanitizers)
endif()
# setup default install locations
include(InstallLocation)
include(QtInstallPaths) #to set QT_INSTALL_FOO variables
if (OPTION_DEVELOPER_MODE)
add_definitions(-DDOCKS_DEVELOPER_MODE -DQT_FORCE_ASSERTS)
if (NOT MSVC)
add_compile_options(-Wall -Wextra -Werror)
macro(set_compiler_flags targetName)
if(${PROJECT_NAME}_DEVELOPER_MODE)
target_compile_definitions(${targetName} PRIVATE DOCKS_DEVELOPER_MODE QT_FORCE_ASSERTS)
if(NOT MSVC)
target_compile_options(${targetName} PRIVATE -Wall -Wextra -Werror -Wno-error=deprecated-declarations)
if (APPLE)
target_compile_options(${targetName} PRIVATE -Wweak-vtables)
endif()
endif()
endif()
endmacro()
add_definitions(-DKDDOCKWIDGETS_QTWIDGETS)
if(${PROJECT_NAME}_STATIC)
set(${PROJECT_NAME}_LIBRARY_MODE "STATIC")
else()
set(${PROJECT_NAME}_LIBRARY_MODE "SHARED")
endif()
if (OPTION_QTQUICK)
find_package(Qt5Quick)
add_definitions(-DKDDOCKWIDGETS_QTQUICK)
else()
add_definitions(-DKDDOCKWIDGETS_QTWIDGETS)
if(USE_DEFAULT_INSTALL_LOCATION)
if(UNIX)
set(CMAKE_INSTALL_PREFIX "/usr/local/KDAB/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}")
elseif(WIN32)
set(CMAKE_INSTALL_PREFIX "C:\\KDAB\\${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}")
endif()
endif()
# Generate .pri file for qmake users
include(ECMGeneratePriFile)
set(PROJECT_VERSION_STRING ${${PROJECT_NAME}_VERSION})
ecm_generate_pri_file(BASE_NAME KDDockWidgets
LIB_NAME kddockwidgets
FILENAME_VAR pri_filename
)
install(FILES ${pri_filename} DESTINATION ${ECM_MKSPECS_INSTALL_DIR})
install(FILES LICENSE.txt README.md DESTINATION ${INSTALL_DOC_DIR})
install(DIRECTORY LICENSES DESTINATION ${INSTALL_DOC_DIR})
add_subdirectory(src)
if(${PROJECT_NAME}_PYTHON_BINDINGS)
add_subdirectory(python)
endif()
if (OPTION_DEVELOPER_MODE)
if (NOT OPTION_QTQUICK)
add_subdirectory(tests)
if(${PROJECT_NAME}_EXAMPLES)
if (${PROJECT_NAME}_QTQUICK)
add_subdirectory(examples/qtquick)
set_compiler_flags(kddockwidgets_example_quick)
else()
add_subdirectory(examples/dockwidgets)
add_subdirectory(examples/minimal)
set_compiler_flags(kddockwidgets_example)
set_compiler_flags(kddockwidgets_minimal_example)
endif()
endif()
if(${PROJECT_NAME}_DEVELOPER_MODE)
include(ECMEnableSanitizers)
if(${PROJECT_NAME}_TESTS)
enable_testing()
add_subdirectory(tests)
if (NOT ${PROJECT_NAME}_QTQUICK)
#Require Qt5.15.1 or higher to run the tests_launcher tests on Mac
if(NOT APPLE OR Qt5Widgets_VERSION VERSION_GREATER 5.15.0)
# tst_docks.exe is pretty big (140 tests), so split it in 6 runs so we can use threads.
add_test(NAME tst_docks0 COMMAND tests_launcher 0 5)
add_test(NAME tst_docks1 COMMAND tests_launcher 1 5)
add_test(NAME tst_docks2 COMMAND tests_launcher 2 5)
add_test(NAME tst_docks3 COMMAND tests_launcher 3 5)
add_test(NAME tst_docks4 COMMAND tests_launcher 4 5)
add_test(NAME tst_docks5 COMMAND tests_launcher 5 5)
add_test(NAME tst_docks6 COMMAND tests_launcher 6 5)
add_test(NAME tst_docks7 COMMAND tests_launcher 7 5)
add_test(NAME tst_docks8 COMMAND tests_launcher 8 5)
add_test(NAME tst_docks9 COMMAND tests_launcher 9 5)
add_test(NAME tst_docks10 COMMAND tests_launcher 10 5)
add_test(NAME tst_docks11 COMMAND tests_launcher 10 5)
add_test(NAME tst_docks12 COMMAND tests_launcher 11 5)
add_test(NAME tst_docks13 COMMAND tests_launcher 12 5)
add_test(NAME tst_docks14 COMMAND tests_launcher 13 5)
add_test(NAME tst_docks15 COMMAND tests_launcher 14 5)
add_test(NAME tst_docks16 COMMAND tests_launcher 15 5)
add_test(NAME tst_docks17 COMMAND tests_launcher 16 5)
add_test(NAME tst_docks18 COMMAND tests_launcher 17 5)
add_test(NAME tst_docks19 COMMAND tests_launcher 18 5)
add_test(NAME tst_docks20 COMMAND tests_launcher 19 5)
add_test(NAME tst_docks21 COMMAND tests_launcher 20 5) # one more for rounding leftovers
endif()
endif()
# examples use <kddockwidget/ qualified includes so need to be installed first
# add_subdirectory(examples)
add_test(NAME tst_multisplitter COMMAND tst_multisplitter)
add_test(NAME tst_common COMMAND tst_common)
endif()
endif()
if(${PROJECT_NAME}_DOCS)
add_subdirectory(docs) # needs to go last, in case there are build source files
endif()

View File

@@ -1,10 +1,50 @@
* v1.0 (November 4th, 2019)
- Initial Release
* v1.1.0 (26 October 2020)
- New drop indicator style type: Segmented Indicators
- Windows: Drop Shadow for floating windows
- Added AutoHide / SideBar support
- Added FocusScope support
- Added DockWidget::isFocused() and DockWidgetBase::isFocusedChanged()
- Added Config::Flag_AlwaysTitleBarWhenFloating, which complements Flag_HideTitleBarWhenTabsVisible
- Added Config::Flag_DontUseUtilityWindowsForFloating
- Added Config::Flag_TitleBarHasMinimizeButton
- Added Config::Flag_TitleBarNoFloatButton
- Added Config::Flag_AutoHideSupport
- Added Config::setTabbingAllowedFunc(TabbingAllowedFunc func)
- HDPI improvements, new high-res icons
- Bugfixes:
- Windows: Fixed windows not having proper minimum size.
- Windows: Fixed moving windows across screens with different DPI (#72)
- Don't center floating windows if the user set a custom position (#75)
- Fixed floating window's title not being correct (#74)
- Fixed focus scope not reacting when clicking on current tab (#71)
- Fixed floating window borders not being rendered correctly on HDPI due to rounding errors.
- cmake/Python - don't require pkg-config, only use if available (#68)
* v1.1 (, 2020)
Features:
- Allow tab re-ordering with mouse, via KDDockWidgets::Config::Flag_AllowReorderTabs.
- Allow tabs to have a close button, via KDDockWidgets::Config::Flag_TabsHaveCloseButton.
- Add support for lazy resize, via KDDockWidgets::Config::Flag_LazyResize. Resize is only done when mouse is released.
Fixes:
- Fix dock widgets not filling their complete available space
* v1.0.0 (2 September 2020)
- PySide2 bindings
- Rewrote the layouting engine, resulting in a huge stability gain and makes it easy to add new features
- Honour min/max sizes and some QSizePolicy heuristics
- Lazy resize (resize only when dropping the separator)
- Native Windows dragging (supporting Aero-snap)
- Allow to hide TitleBar and just show tabs. Allow dragging via the tab bar.
- Reordering tabs with mouse
- Partial layout save/restore (affecting only a subset)
- Double-click on title bar to maximize
- Maximize button on the title bar
- HDPI: Relative layouting restore
- Allow to make a dock widget non-closable and non-dockable
- Show close button on tabs
- Multiple Main Window support
- Allowing to dock on different parents
- Support for affinities, making some dock widgets only dockable on certain main windows
- 200 unit-tests
- Fuzzer which found plenty of crashes in the old layouting engine
- ASAN fixes
- Double click on separator to distribute equally
- Hovering over an indicator returns the true size that the dropped widget will get
- Static build support
- Namespaced Qt support
- Dozens of crash fixes, bugs and much more...
* v0.1 (4 November 2019)
- Initial Release and blog

7
LICENSE.txt Normal file
View File

@@ -0,0 +1,7 @@
KDDockWidgets is (C) 2018-2020, Klarälvdalens Datakonsult AB, and is licensed
according to the terms of the:
GNU General Public License version 2.0 (see LICENSES/GPL-2.0-only.txt)
or the
GNU General Public License version 3.0 (see LICENSES/GPL-3.0-only.txt).
Contact KDAB at <info@kdab.com> to inquire about commercial licensing.

319
LICENSES/GPL-2.0-only.txt Normal file
View File

@@ -0,0 +1,319 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public License is intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users. This General Public License applies to
most of the Free Software Foundation's software and to any other program whose
authors commit to using it. (Some other Free Software Foundation software
is covered by the GNU Lesser General Public License instead.) You can apply
it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish), that you receive source code or can get it if you want it, that you
can change the software or use pieces of it in new free programs; and that
you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to
deny you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or
for a fee, you must give the recipients all the rights that you have. You
must make sure that they, too, receive or can get the source code. And you
must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2)
offer you this license which gives you legal permission to copy, distribute
and/or modify the software.
Also, for each author's protection and ours, we want to make certain that
everyone understands that there is no warranty for this free software. If
the software is modified by someone else and passed on, we want its recipients
to know that what they have is not the original, so that any problems introduced
by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that redistributors of a free program will individually
obtain patent licenses, in effect making the program proprietary. To prevent
this, we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification
follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice
placed by the copyright holder saying it may be distributed under the terms
of this General Public License. The "Program", below, refers to any such program
or work, and a "work based on the Program" means either the Program or any
derivative work under copyright law: that is to say, a work containing the
Program or a portion of it, either verbatim or with modifications and/or translated
into another language. (Hereinafter, translation is included without limitation
in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running the Program
is not restricted, and the output from the Program is covered only if its
contents constitute a work based on the Program (independent of having been
made by running the Program). Whether that is true depends on what the Program
does.
1. You may copy and distribute verbatim copies of the Program's source code
as you receive it, in any medium, provided that you conspicuously and appropriately
publish on each copy an appropriate copyright notice and disclaimer of warranty;
keep intact all the notices that refer to this License and to the absence
of any warranty; and give any other recipients of the Program a copy of this
License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it,
thus forming a work based on the Program, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) You must cause the modified files to carry prominent notices stating that
you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or
in part contains or is derived from the Program or any part thereof, to be
licensed as a whole at no charge to all third parties under the terms of this
License.
c) If the modified program normally reads commands interactively when run,
you must cause it, when started running for such interactive use in the most
ordinary way, to print or display an announcement including an appropriate
copyright notice and a notice that there is no warranty (or else, saying that
you provide a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this License.
(Exception: if the Program itself is interactive but does not normally print
such an announcement, your work based on the Program is not required to print
an announcement.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Program, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Program, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Program.
In addition, mere aggregation of another work not based on the Program with
the Program (or with a work based on the Program) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may copy and distribute the Program (or a work based on it, under Section
2) in object code or executable form under the terms of Sections 1 and 2 above
provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code,
which must be distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give
any third party, for a charge no more than your cost of physically performing
source distribution, a complete machine-readable copy of the corresponding
source code, to be distributed under the terms of Sections 1 and 2 above on
a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute
corresponding source code. (This alternative is allowed only for noncommercial
distribution and only if you received the program in object code or executable
form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making
modifications to it. For an executable work, complete source code means all
the source code for all modules it contains, plus any associated interface
definition files, plus the scripts used to control compilation and installation
of the executable. However, as a special exception, the source code distributed
need not include anything that is normally distributed (in either source or
binary form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component itself
accompanies the executable.
If distribution of executable or object code is made by offering access to
copy from a designated place, then offering equivalent access to copy the
source code from the same place counts as distribution of the source code,
even though third parties are not compelled to copy the source along with
the object code.
4. You may not copy, modify, sublicense, or distribute the Program except
as expressly provided under this License. Any attempt otherwise to copy, modify,
sublicense or distribute the Program is void, and will automatically terminate
your rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses terminated
so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Program or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Program
(or any work based on the Program), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program),
the recipient automatically receives a license from the original licensor
to copy, distribute or modify the Program subject to these terms and conditions.
You may not impose any further restrictions on the recipients' exercise of
the rights granted herein. You are not responsible for enforcing compliance
by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Program at all. For example, if a
patent license would not permit royalty-free redistribution of the Program
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply and
the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system, which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Program under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of
the General Public License from time to time. Such new versions will be similar
in spirit to the present version, but may differ in detail to address new
problems or concerns.
Each version is given a distinguishing version number. If the Program specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Program does not specify a version number of this License, you may choose
any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs
whose distribution conditions are different, write to the author to ask for
permission. For software which is copyrighted by the Free Software Foundation,
write to the Free Software Foundation; we sometimes make exceptions for this.
Our decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing and reuse
of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible
use to the public, the best way to achieve this is to make it free software
which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach
them to the start of each source file to most effectively convey the exclusion
of warranty; and each file should have at least the "copyright" line and a
pointer to where the full notice is found.
<one line to give the program's name and an idea of what it does.>
Copyright (C)< yyyy> <name of author>
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02110-1301, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when
it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software,
and you are welcome to redistribute it under certain conditions; type `show
c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may be
called something other than `show w' and `show c'; they could even be mouse-clicks
or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the program, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision'
(which makes passes at compilers) written by James Hacker.
<signature of Ty Coon >, 1 April 1989 Ty Coon, President of Vice This General
Public License does not permit incorporating your program into proprietary
programs. If your program is a subroutine library, you may consider it more
useful to permit linking proprietary applications with the library. If this
is what you want to do, use the GNU Lesser General Public License instead
of this License.

625
LICENSES/GPL-3.0-only.txt Normal file
View File

@@ -0,0 +1,625 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for software and
other kinds of works.
The licenses for most software and other practical works are designed to take
away your freedom to share and change the works. By contrast, the GNU General
Public License is intended to guarantee your freedom to share and change all
versions of a program--to make sure it remains free software for all its users.
We, the Free Software Foundation, use the GNU General Public License for most
of our software; it applies also to any other work released this way by its
authors. You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for them if you wish), that
you receive source code or can get it if you want it, that you can change
the software or use pieces of it in new free programs, and that you know you
can do these things.
To protect your rights, we need to prevent others from denying you these rights
or asking you to surrender the rights. Therefore, you have certain responsibilities
if you distribute copies of the software, or if you modify it: responsibilities
to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or
for a fee, you must pass on to the recipients the same freedoms that you received.
You must make sure that they, too, receive or can get the source code. And
you must show them these terms so they know their rights.
Developers that use the GNU GPL protect your rights with two steps: (1) assert
copyright on the software, and (2) offer you this License giving you legal
permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that
there is no warranty for this free software. For both users' and authors'
sake, the GPL requires that modified versions be marked as changed, so that
their problems will not be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified
versions of the software inside them, although the manufacturer can do so.
This is fundamentally incompatible with the aim of protecting users' freedom
to change the software. The systematic pattern of such abuse occurs in the
area of products for individuals to use, which is precisely where it is most
unacceptable. Therefore, we have designed this version of the GPL to prohibit
the practice for those products. If such problems arise substantially in other
domains, we stand ready to extend this provision to those domains in future
versions of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents. States
should not allow patents to restrict development and use of software on general-purpose
computers, but in those that do, we wish to avoid the special danger that
patents applied to a free program could make it effectively proprietary. To
prevent this, the GPL assures that patents cannot be used to render the program
non-free.
The precise terms and conditions for copying, distribution and modification
follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of works,
such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this License.
Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals
or organizations.
To "modify" a work means to copy from or adapt all or part of the work in
a fashion requiring copyright permission, other than the making of an exact
copy. The resulting work is called a "modified version" of the earlier work
or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based on the
Program.
To "propagate" a work means to do anything with it that, without permission,
would make you directly or secondarily liable for infringement under applicable
copyright law, except executing it on a computer or modifying a private copy.
Propagation includes copying, distribution (with or without modification),
making available to the public, and in some countries other activities as
well.
To "convey" a work means any kind of propagation that enables other parties
to make or receive copies. Mere interaction with a user through a computer
network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices" to the
extent that it includes a convenient and prominently visible feature that
(1) displays an appropriate copyright notice, and (2) tells the user that
there is no warranty for the work (except to the extent that warranties are
provided), that licensees may convey the work under this License, and how
to view a copy of this License. If the interface presents a list of user commands
or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work for making
modifications to it. "Object code" means any non-source form of a work.
A "Standard Interface" means an interface that either is an official standard
defined by a recognized standards body, or, in the case of interfaces specified
for a particular programming language, one that is widely used among developers
working in that language.
The "System Libraries" of an executable work include anything, other than
the work as a whole, that (a) is included in the normal form of packaging
a Major Component, but which is not part of that Major Component, and (b)
serves only to enable use of the work with that Major Component, or to implement
a Standard Interface for which an implementation is available to the public
in source code form. A "Major Component", in this context, means a major essential
component (kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to produce
the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all the source
code needed to generate, install, and (for an executable work) run the object
code and to modify the work, including scripts to control those activities.
However, it does not include the work's System Libraries, or general-purpose
tools or generally available free programs which are used unmodified in performing
those activities but which are not part of the work. For example, Corresponding
Source includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically linked
subprograms that the work is specifically designed to require, such as by
intimate data communication or control flow between those subprograms and
other parts of the work.
The Corresponding Source need not include anything that users can regenerate
automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright
on the Program, and are irrevocable provided the stated conditions are met.
This License explicitly affirms your unlimited permission to run the unmodified
Program. The output from running a covered work is covered by this License
only if the output, given its content, constitutes a covered work. This License
acknowledges your rights of fair use or other equivalent, as provided by copyright
law.
You may make, run and propagate covered works that you do not convey, without
conditions so long as your license otherwise remains in force. You may convey
covered works to others for the sole purpose of having them make modifications
exclusively for you, or provide you with facilities for running those works,
provided that you comply with the terms of this License in conveying all material
for which you do not control copyright. Those thus making or running the covered
works for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of your copyrighted
material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions
stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure
under any applicable law fulfilling obligations under article 11 of the WIPO
copyright treaty adopted on 20 December 1996, or similar laws prohibiting
or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention
of technological measures to the extent such circumvention is effected by
exercising rights under this License with respect to the covered work, and
you disclaim any intention to limit operation or modification of the work
as a means of enforcing, against the work's users, your or third parties'
legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive
it, in any medium, provided that you conspicuously and appropriately publish
on each copy an appropriate copyright notice; keep intact all notices stating
that this License and any non-permissive terms added in accord with section
7 apply to the code; keep intact all notices of the absence of any warranty;
and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you
may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce
it from the Program, in the form of source code under the terms of section
4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and
giving a relevant date.
b) The work must carry prominent notices stating that it is released under
this License and any conditions added under section 7. This requirement modifies
the requirement in section 4 to "keep intact all notices".
c) You must license the entire work, as a whole, under this License to anyone
who comes into possession of a copy. This License will therefore apply, along
with any applicable section 7 additional terms, to the whole of the work,
and all its parts, regardless of how they are packaged. This License gives
no permission to license the work in any other way, but it does not invalidate
such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate
Legal Notices; however, if the Program has interactive interfaces that do
not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works,
which are not by their nature extensions of the covered work, and which are
not combined with it such as to form a larger program, in or on a volume of
a storage or distribution medium, is called an "aggregate" if the compilation
and its resulting copyright are not used to limit the access or legal rights
of the compilation's users beyond what the individual works permit. Inclusion
of a covered work in an aggregate does not cause this License to apply to
the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections
4 and 5, provided that you also convey the machine-readable Corresponding
Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including
a physical distribution medium), accompanied by the Corresponding Source fixed
on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including
a physical distribution medium), accompanied by a written offer, valid for
at least three years and valid for as long as you offer spare parts or customer
support for that product model, to give anyone who possesses the object code
either (1) a copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical medium customarily
used for software interchange, for a price no more than your reasonable cost
of physically performing this conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written
offer to provide the Corresponding Source. This alternative is allowed only
occasionally and noncommercially, and only if you received the object code
with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis
or for a charge), and offer equivalent access to the Corresponding Source
in the same way through the same place at no further charge. You need not
require recipients to copy the Corresponding Source along with the object
code. If the place to copy the object code is a network server, the Corresponding
Source may be on a different server (operated by you or a third party) that
supports equivalent copying facilities, provided you maintain clear directions
next to the object code saying where to find the Corresponding Source. Regardless
of what server hosts the Corresponding Source, you remain obligated to ensure
that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform
other peers where the object code and Corresponding Source of the work are
being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from
the Corresponding Source as a System Library, need not be included in conveying
the object code work.
A "User Product" is either (1) a "consumer product", which means any tangible
personal property which is normally used for personal, family, or household
purposes, or (2) anything designed or sold for incorporation into a dwelling.
In determining whether a product is a consumer product, doubtful cases shall
be resolved in favor of coverage. For a particular product received by a particular
user, "normally used" refers to a typical or common use of that class of product,
regardless of the status of the particular user or of the way in which the
particular user actually uses, or expects or is expected to use, the product.
A product is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent the
only significant mode of use of the product.
"Installation Information" for a User Product means any methods, procedures,
authorization keys, or other information required to install and execute modified
versions of a covered work in that User Product from a modified version of
its Corresponding Source. The information must suffice to ensure that the
continued functioning of the modified object code is in no case prevented
or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically
for use in, a User Product, and the conveying occurs as part of a transaction
in which the right of possession and use of the User Product is transferred
to the recipient in perpetuity or for a fixed term (regardless of how the
transaction is characterized), the Corresponding Source conveyed under this
section must be accompanied by the Installation Information. But this requirement
does not apply if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has been installed
in ROM).
The requirement to provide Installation Information does not include a requirement
to continue to provide support service, warranty, or updates for a work that
has been modified or installed by the recipient, or for the User Product in
which it has been modified or installed. Access to a network may be denied
when the modification itself materially and adversely affects the operation
of the network or violates the rules and protocols for communication across
the network.
Corresponding Source conveyed, and Installation Information provided, in accord
with this section must be in a format that is publicly documented (and with
an implementation available to the public in source code form), and must require
no special password or key for unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this License
by making exceptions from one or more of its conditions. Additional permissions
that are applicable to the entire Program shall be treated as though they
were included in this License, to the extent that they are valid under applicable
law. If additional permissions apply only to part of the Program, that part
may be used separately under those permissions, but the entire Program remains
governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any
additional permissions from that copy, or from any part of it. (Additional
permissions may be written to require their own removal in certain cases when
you modify the work.) You may place additional permissions on material, added
by you to a covered work, for which you have or can give appropriate copyright
permission.
Notwithstanding any other provision of this License, for material you add
to a covered work, you may (if authorized by the copyright holders of that
material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of
sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author
attributions in that material or in the Appropriate Legal Notices displayed
by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring
that modified versions of such material be marked in reasonable ways as different
from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors
of the material; or
e) Declining to grant rights under trademark law for use of some trade names,
trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by
anyone who conveys the material (or modified versions of it) with contractual
assumptions of liability to the recipient, for any liability that these contractual
assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "further restrictions"
within the meaning of section 10. If the Program as you received it, or any
part of it, contains a notice stating that it is governed by this License
along with a term that is a further restriction, you may remove that term.
If a license document contains a further restriction but permits relicensing
or conveying under this License, you may add to a covered work material governed
by the terms of that license document, provided that the further restriction
does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place,
in the relevant source files, a statement of the additional terms that apply
to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form
of a separately written license, or stated as exceptions; the above requirements
apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided
under this License. Any attempt otherwise to propagate or modify it is void,
and will automatically terminate your rights under this License (including
any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from
a particular copyright holder is reinstated (a) provisionally, unless and
until the copyright holder explicitly and finally terminates your license,
and (b) permanently, if the copyright holder fails to notify you of the violation
by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently
if the copyright holder notifies you of the violation by some reasonable means,
this is the first time you have received notice of violation of this License
(for any work) from that copyright holder, and you cure the violation prior
to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses
of parties who have received copies or rights from you under this License.
If your rights have been terminated and not permanently reinstated, you do
not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy
of the Program. Ancillary propagation of a covered work occurring solely as
a consequence of using peer-to-peer transmission to receive a copy likewise
does not require acceptance. However, nothing other than this License grants
you permission to propagate or modify any covered work. These actions infringe
copyright if you do not accept this License. Therefore, by modifying or propagating
a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives
a license from the original licensors, to run, modify and propagate that work,
subject to this License. You are not responsible for enforcing compliance
by third parties with this License.
An "entity transaction" is a transaction transferring control of an organization,
or substantially all assets of one, or subdividing an organization, or merging
organizations. If propagation of a covered work results from an entity transaction,
each party to that transaction who receives a copy of the work also receives
whatever licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the Corresponding
Source of the work from the predecessor in interest, if the predecessor has
it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights
granted or affirmed under this License. For example, you may not impose a
license fee, royalty, or other charge for exercise of rights granted under
this License, and you may not initiate litigation (including a cross-claim
or counterclaim in a lawsuit) alleging that any patent claim is infringed
by making, using, selling, offering for sale, or importing the Program or
any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this License
of the Program or a work on which the Program is based. The work thus licensed
is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned or controlled
by the contributor, whether already acquired or hereafter acquired, that would
be infringed by some manner, permitted by this License, of making, using,
or selling its contributor version, but do not include claims that would be
infringed only as a consequence of further modification of the contributor
version. For purposes of this definition, "control" includes the right to
grant patent sublicenses in a manner consistent with the requirements of this
License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent
license under the contributor's essential patent claims, to make, use, sell,
offer for sale, import and otherwise run, modify and propagate the contents
of its contributor version.
In the following three paragraphs, a "patent license" is any express agreement
or commitment, however denominated, not to enforce a patent (such as an express
permission to practice a patent or covenant not to sue for patent infringement).
To "grant" such a patent license to a party means to make such an agreement
or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the
Corresponding Source of the work is not available for anyone to copy, free
of charge and under the terms of this License, through a publicly available
network server or other readily accessible means, then you must either (1)
cause the Corresponding Source to be so available, or (2) arrange to deprive
yourself of the benefit of the patent license for this particular work, or
(3) arrange, in a manner consistent with the requirements of this License,
to extend the patent license to downstream recipients. "Knowingly relying"
means you have actual knowledge that, but for the patent license, your conveying
the covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that country
that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement,
you convey, or propagate by procuring conveyance of, a covered work, and grant
a patent license to some of the parties receiving the covered work authorizing
them to use, propagate, modify or convey a specific copy of the covered work,
then the patent license you grant is automatically extended to all recipients
of the covered work and works based on it.
A patent license is "discriminatory" if it does not include within the scope
of its coverage, prohibits the exercise of, or is conditioned on the non-exercise
of one or more of the rights that are specifically granted under this License.
You may not convey a covered work if you are a party to an arrangement with
a third party that is in the business of distributing software, under which
you make payment to the third party based on the extent of your activity of
conveying the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory patent
license (a) in connection with copies of the covered work conveyed by you
(or copies made from those copies), or (b) primarily for and in connection
with specific products or compilations that contain the covered work, unless
you entered into that arrangement, or that patent license was granted, prior
to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied
license or other defenses to infringement that may otherwise be available
to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise)
that contradict the conditions of this License, they do not excuse you from
the conditions of this License. If you cannot convey a covered work so as
to satisfy simultaneously your obligations under this License and any other
pertinent obligations, then as a consequence you may not convey it at all.
For example, if you agree to terms that obligate you to collect a royalty
for further conveying from those to whom you convey the Program, the only
way you could satisfy both those terms and this License would be to refrain
entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to
link or combine any covered work with a work licensed under version 3 of the
GNU Affero General Public License into a single combined work, and to convey
the resulting work. The terms of this License will continue to apply to the
part which is the covered work, but the special requirements of the GNU Affero
General Public License, section 13, concerning interaction through a network
will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the
GNU General Public License from time to time. Such new versions will be similar
in spirit to the present version, but may differ in detail to address new
problems or concerns.
Each version is given a distinguishing version number. If the Program specifies
that a certain numbered version of the GNU General Public License "or any
later version" applies to it, you have the option of following the terms and
conditions either of that numbered version or of any later version published
by the Free Software Foundation. If the Program does not specify a version
number of the GNU General Public License, you may choose any version ever
published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of
the GNU General Public License can be used, that proxy's public statement
of acceptance of a version permanently authorizes you to choose that version
for the Program.
Later license versions may give you additional or different permissions. However,
no additional obligations are imposed on any author or copyright holder as
a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM
PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM
AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO
USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot
be given local legal effect according to their terms, reviewing courts shall
apply local law that most closely approximates an absolute waiver of all civil
liability in connection with the Program, unless a warranty or assumption
of liability accompanies a copy of the Program in return for a fee. END OF
TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible
use to the public, the best way to achieve this is to make it free software
which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach
them to the start of each source file to most effectively state the exclusion
of warranty; and each file should have at least the "copyright" line and a
pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like
this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain
conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands might
be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary. For
more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General Public
License instead of this License. But first, please read <https://www.gnu.org/
licenses /why-not-lgpl.html>.

View File

@@ -1,2 +0,0 @@
This software is provided as GPLv2 (read LICENSE.GPL.txt), or, alternatively,
contact KDAB at <info@kdab.com> if you need different licensing.

124
README.md
View File

@@ -1,7 +1,15 @@
KDDockWidgets
==============
`KDDockWidgets` is a KDAB effort to provide an advanced docking system for Qt.
=============
`KDDockWidgets` is a Qt dock widget library written by KDAB, suitable for replacing
`QDockWidget` and implementing advanced functionalities missing in Qt.
Although `KDDockWidgets` is ready to be used out of the box, it can also be seen
as a framework to allow building very tailored custom docking systems. It tries
to expose every internal widget and every knob for the app developer to tune.
Motivation
==========
Throughout the years KDAB contributed and funded bug fixes and features to `QDockWidget`.
Sadly, this was very painful. Each bug fix or feature took many days of implementation,
and an equal number of days just to fix dozens of regressions.
@@ -10,79 +18,144 @@ and an equal number of days just to fix dozens of regressions.
to move forward with new features. Furthermore, our customers were getting more
creative with their requests, so it was clear we needed a better docking framework.
You will find more information in these places:
* [our official home page](https://www.kdab.com/development-resources/qt-tools/kddockwidgets)
* [online detailed browsable API reference](https://docs.kdab.com/kddockwidgets)
* [our example programs](examples/)
Features
========
- Provide advanced docking that QDockWidgets doesn't support
- Native window resize on Windows (allowing for Aero-snap even with custom title bar decorations)
- Arrow drop indicators for great drop precision
- Allow for totally different, user provided, drop indicator types
- Nesting dock widgets in a floating window and docking that group back to main window
- Docking to any main window, not only to the parent main window
- Docking to center of main window, or simply removing the concept of "central widget"
- Main window supporting detachable tabs in center widget
- Detaching arbitrary tabs from a tab bar into a dock area
- Supporting more than 1 main window
- Support for affinities, making some dock widgets only dockable on certain main windows
- Allow to hide TitleBar and just show tabs. Allows dragging via the tab bar.
- Exposing inner helper widgets so the user can customize them or provide his own
- Customize tab widgets
- Customize title bars
- Customize window frames
- Custom widget separators
- Layouting engine honouring min/max size constraints and some size policies
- PySide2 bindings
- Clean codebase
- Not mixing GUI with state with logic with animations
- Unit-test everything, even the GUI and DnD operations (140 tests currently)
- Fuzzer for doing random testing
- Great test coverage, even the gui and DnD operations are tested. 200 tests currently.
- Fuzzer for doing random testing and finding bugs
- Lazy separator resize
- Reordering tabs with mouse
- Partial layout save/restore, affecting only a chosen sub-set
- Double click on title bar to maximize
- Double click on separator to distribute equally
- Show close button on tabs
- Allow to make a dock widget non-closable and/or non-dockable
- Optional minimize and maximize button on the title bar
- FloatingWindows can be utility windows or full native
![Screen capture](./screencap.gif?raw=true "The docking system in action")
![Screen capture](/screencap.gif?raw=true "The docking system in action")
Roadmap
========
- Different forms of docking indicators (through plugins)
- QtQuick support
Trying out the examples
=======================
A full demo lives in `examples/dockwidgets/`, it showcasts most of the features.
A simpler example lives in `examples/minimal/`, which might be more indicated
to learn the API, as it's less overwelming than the full demo.
Trying out the demo
====================
Open a terminal capable of building Qt5 applications (Should have cmake, ninja, compiler, Qt, etc in PATH).
Open a terminal capable of building Qt5 applications.
Make sure you have cmake, ninja, compiler, Qt, etc in PATH.
Feel free to adapt the instructions to suit your cmake generator and operating system.
Adapt the instructions to suit your cmake generator and operating system.
Build and install the KDDockWidgets framework:
```
$ cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/path/where/to/install ../path/to/kddockwidgets
$ make
$ make install
$ cmake --build .
$ cmake --build . --target install
```
Now build and run the example:
```
$ cd path/to/kddockwidgets/examples/dockwidgets/
$ cmake -DCMAKE_PREFIX_PATH=/path/where/to/install
$ make
$ cmake -G Ninja -DCMAKE_PREFIX_PATH=/path/where/to/install
$ cmake --build .
$ ./kddockwidgets_example
```
The installation directory defaults to `c:\KDAB\KDDockWidgets-<version>` on Windows
and `/usr/local/KDAB/KDDockWidgets-<version>` on non-Windows. You can change this
location by passing the option `-DCMAKE_INSTALL_PREFIX=/install/path` to cmake.
Python Bindings
================
Make sure you have pyside2, shiboken2 and shiboken2-generator installed.
As this time, you cannot get shiboken2-generator because the wheels are not on PyPi.
To use the wheels do this:
% pip3 install \
--index-url=http://download.qt.io/official_releases/QtForPython/ \
--trusted-host download.qt.io \
shiboken2 pyside2 shiboken2_generator
For more info visit https://doc.qt.io/qtforpython/shiboken2/gettingstarted.html
Once QtForPython is installed you are ready to generate the PySide bindings
for KDDockwWidgets.
Next pass `-DKDDockWidgets_PYTHON_BINDINGS=ON` to CMake, followed by the
make command.
The bindings will be installed to the passed `-DCMAKE_INSTALL_PREFIX`, which
might require setting the `PYTHONPATH` env variable to point to that path when
running applications. Alternatively, configure the bindings install location
by passing `-DKDDockWidgets_PYTHON_BINDINGS_INSTALL_PREFIX=/usr/lib/python3.8/site-packages`
to CMake (adjust to the python path on your system).
To run the KDDW python example
```
$ export PYTHONPATH=/kddw/install/path # Only if needed
$ cd python/examples/
$ rcc -g python -o rc_assets.py ../../examples/dockwidgets/resources_example.qrc
$ python3 main.py
```
Supported Qt versions
======================
KDDockWidgets requires Qt >= 5.9
KDDockWidgets requires Qt >= 5.9 (or >=5.12 if Python bindings are enabled).
The QtQuick support will require Qt >= 5.15.
Licensing
=========
KDDockWidgets is (C) 2018-2020, Klarälvdalens Datakonsult AB, and is available
under the terms of the GPLv2 (see LICENSE.GPL.txt).
KDDockWidgets is (C) 2018-2020, Klarälvdalens Datakonsult AB, and is licensed according to
the terms of the [GPL 2.0](LICENSES/GPL-2.0-only.txt) or [GPL 3.0](LICENSES/GPL-3.0-only.txt).
Contact KDAB at <info@kdab.com> to inquire about commercial licensing.
Contact KDAB at <info@kdab.com> if you need different licensing options.
Get Involved
============
KDAB will happily accept external contributions; however, **all**
contributions will require a signed Contributor License Agreement
(see docs/KDDockWidgets-CopyrightAssignmentForm.docx).
KDAB will happily accept external contributions; however, **all** contributions require a
signed [Copyright Assignment Agreement](docs/KDDockWidgets-CopyrightAssignmentForm.docx).
Contact info@kdab.com for more information.
Please submit your contributions or issue reports from our GitHub space at
https://github.com/KDAB/KDDockWidgets
About KDAB
==========
KDDockWidgets is supported and maintained by Klarälvdalens Datakonsult AB (KDAB).
@@ -97,3 +170,8 @@ to the Qt Project. We can give advanced or standard trainings anywhere
around the globe on Qt as well as C++, OpenGL, 3D and more.
Please visit https://www.kdab.com to meet the people who write code like this.
Stay up-to-date with KDAB product announcements:
* [KDAB Newsletter](https://news.kdab.com)
* [KDAB Blogs](https://www.kdab.com/category/blogs)

View File

@@ -0,0 +1,28 @@
Copyright (c) <year> <owner>. All rights reserved.
This license applies to the CMake ECM modules only.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -40,6 +40,7 @@
# - thread
# - leak
# - undefined
# - fuzzer
#
# The sanitizers "address", "memory" and "thread" are mutually exclusive. You
# cannot enable two of them in the same build.
@@ -69,30 +70,9 @@
# Since 1.3.0.
#=============================================================================
# Copyright 2014 Mathieu Tarral <mathieu.tarral@gmail.com>
# SPDX-FileCopyrightText: 2014 Mathieu Tarral <mathieu.tarral@gmail.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# SPDX-License-Identifier: BSD-3-Clause
# MACRO check_compiler_version
#-----------------------------
@@ -140,6 +120,9 @@ macro (enable_sanitizer_flags sanitize_option)
elseif (${sanitize_option} MATCHES "undefined")
check_compiler_version("4.9" "3.1")
set(XSAN_COMPILE_FLAGS "-fsanitize=undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls")
elseif (${sanitize_option} MATCHES "fuzzer")
check_compiler_version("99.99" "6.0")
set(XSAN_COMPILE_FLAGS "-fsanitize=fuzzer")
else ()
message(FATAL_ERROR "Compiler sanitizer option \"${sanitize_option}\" not supported.")
endif ()
@@ -161,7 +144,7 @@ if (ECM_ENABLE_SANITIZERS)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
link_libraries(${XSAN_LINKER_FLAGS})
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
string(REPLACE "-Wl,--no-undefined" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
string(REPLACE "-Wl,--no-undefined" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
endif ()

View File

@@ -0,0 +1,199 @@
#.rst:
# ECMGeneratePriFile
# ------------------
#
# Generate a ``.pri`` file for the benefit of qmake-based projects.
#
# As well as the function below, this module creates the cache variable
# ``ECM_MKSPECS_INSTALL_DIR`` and sets the default value to ``mkspecs/modules``.
# This assumes Qt and the current project are both installed to the same
# non-system prefix. Packagers who use ``-DCMAKE_INSTALL_PREFIX=/usr`` will
# certainly want to set ``ECM_MKSPECS_INSTALL_DIR`` to something like
# ``share/qt5/mkspecs/modules``.
#
# The main thing is that this should be the ``modules`` subdirectory of either
# the default qmake ``mkspecs`` directory or of a directory that will be in the
# ``$QMAKEPATH`` environment variable when qmake is run.
#
# ::
#
# ecm_generate_pri_file(BASE_NAME <baseName>
# LIB_NAME <libName>
# [DEPS "<dep> [<dep> [...]]"]
# [FILENAME_VAR <filename_variable>]
# [INCLUDE_INSTALL_DIR <dir>]
# [LIB_INSTALL_DIR <dir>])
#
# If your CMake project produces a Qt-based library, you may expect there to be
# applications that wish to use it that use a qmake-based build system, rather
# than a CMake-based one. Creating a ``.pri`` file will make use of your
# library convenient for them, in much the same way that CMake config files make
# things convenient for CMake-based applications.
#
# ecm_generate_pri_file() generates just such a file. It requires the
# ``PROJECT_VERSION_STRING`` variable to be set. This is typically set by
# :module:`ECMSetupVersion`, although the project() command in CMake 3.0.0 and
# later can also set this.
#
# BASE_NAME specifies the name qmake project (.pro) files should use to refer to
# the library (eg: KArchive). LIB_NAME is the name of the actual library to
# link to (ie: the first argument to add_library()). DEPS is a space-separated
# list of the base names of other libraries (for Qt libraries, use the same
# names you use with the ``QT`` variable in a qmake project file, such as "core"
# for QtCore). FILENAME_VAR specifies the name of a variable to store the path
# to the generated file in.
#
# INCLUDE_INSTALL_DIR is the path (relative to ``CMAKE_INSTALL_PREFIX``) that
# include files will be installed to. It defaults to
# ``${INCLUDE_INSTALL_DIR}/<baseName>`` if the ``INCLUDE_INSTALL_DIR`` variable
# is set. If that variable is not set, the ``CMAKE_INSTALL_INCLUDEDIR`` variable
# is used instead, and if neither are set ``include`` is used. LIB_INSTALL_DIR
# operates similarly for the installation location for libraries; it defaults to
# ``${LIB_INSTALL_DIR}``, ``${CMAKE_INSTALL_LIBDIR}`` or ``lib``, in that order.
#
# Example usage:
#
# .. code-block:: cmake
#
# ecm_generate_pri_file(
# BASE_NAME KArchive
# LIB_NAME KF5KArchive
# DEPS "core"
# FILENAME_VAR pri_filename
# )
# install(FILES ${pri_filename} DESTINATION ${ECM_MKSPECS_INSTALL_DIR})
#
# A qmake-based project that wished to use this would then do::
#
# QT += KArchive
#
# in their ``.pro`` file.
#
# Since pre-1.0.0.
#=============================================================================
# SPDX-FileCopyrightText: 2014 David Faure <faure@kde.org>
#
# SPDX-License-Identifier: BSD-3-Clause
# Replicate the logic from KDEInstallDirs.cmake as we can't depend on it
# Ask qmake if we're using the same prefix as Qt
set(_askqmake OFF)
if(NOT DEFINED KDE_INSTALL_USE_QT_SYS_PATHS)
include(ECMQueryQmake)
query_qmake(qt_install_prefix_dir QT_INSTALL_PREFIX TRY)
if(qt_install_prefix_dir STREQUAL "${CMAKE_INSTALL_PREFIX}")
set(_askqmake ON)
endif()
endif()
if(KDE_INSTALL_USE_QT_SYS_PATHS OR _askqmake)
include(ECMQueryQmake)
query_qmake(qt_host_data_dir QT_HOST_DATA)
set(ECM_MKSPECS_INSTALL_DIR ${qt_host_data_dir}/mkspecs/modules CACHE PATH "The directory where mkspecs will be installed to.")
else()
set(ECM_MKSPECS_INSTALL_DIR mkspecs/modules CACHE PATH "The directory where mkspecs will be installed to.")
endif()
function(ECM_GENERATE_PRI_FILE)
set(options )
set(oneValueArgs BASE_NAME LIB_NAME DEPS FILENAME_VAR INCLUDE_INSTALL_DIR LIB_INSTALL_DIR)
set(multiValueArgs )
cmake_parse_arguments(EGPF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(EGPF_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown keywords given to ECM_GENERATE_PRI_FILE(): \"${EGPF_UNPARSED_ARGUMENTS}\"")
endif()
if(NOT EGPF_BASE_NAME)
message(FATAL_ERROR "Required argument BASE_NAME missing in ECM_GENERATE_PRI_FILE() call")
endif()
if(NOT EGPF_LIB_NAME)
message(FATAL_ERROR "Required argument LIB_NAME missing in ECM_GENERATE_PRI_FILE() call")
endif()
if(NOT PROJECT_VERSION_STRING)
message(FATAL_ERROR "Required variable PROJECT_VERSION_STRING not set before ECM_GENERATE_PRI_FILE() call. Did you call ecm_setup_version?")
endif()
if(NOT EGPF_INCLUDE_INSTALL_DIR)
if(INCLUDE_INSTALL_DIR)
set(EGPF_INCLUDE_INSTALL_DIR "${INCLUDE_INSTALL_DIR}/${EGPF_BASE_NAME}")
elseif(CMAKE_INSTALL_INCLUDEDIR)
set(EGPF_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${EGPF_BASE_NAME}")
else()
set(EGPF_INCLUDE_INSTALL_DIR "include/${EGPF_BASE_NAME}")
endif()
endif()
if(NOT EGPF_LIB_INSTALL_DIR)
if(LIB_INSTALL_DIR)
set(EGPF_LIB_INSTALL_DIR "${LIB_INSTALL_DIR}")
elseif(CMAKE_INSTALL_LIBDIR)
set(EGPF_LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
else()
set(EGPF_LIB_INSTALL_DIR "lib")
endif()
endif()
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" PROJECT_VERSION_MAJOR "${PROJECT_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" PROJECT_VERSION_MINOR "${PROJECT_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PROJECT_VERSION_PATCH "${PROJECT_VERSION_STRING}")
# Prepare the right number of "../.." to go from ECM_MKSPECS_INSTALL_DIR to the install prefix
# This allows to make the generated pri files relocatable (no absolute paths)
if (IS_ABSOLUTE ${ECM_MKSPECS_INSTALL_DIR})
set(BASEPATH ${CMAKE_INSTALL_PREFIX})
else()
string(REGEX REPLACE "[^/]+" ".." PRI_ROOT_RELATIVE_TO_MKSPECS ${ECM_MKSPECS_INSTALL_DIR})
set(BASEPATH "$$PWD/${PRI_ROOT_RELATIVE_TO_MKSPECS}")
endif()
set(PRI_TARGET_BASENAME ${EGPF_BASE_NAME})
set(PRI_TARGET_LIBNAME ${EGPF_LIB_NAME})
set(PRI_TARGET_QTDEPS ${EGPF_DEPS})
if(IS_ABSOLUTE "${EGPF_INCLUDE_INSTALL_DIR}")
set(PRI_TARGET_INCLUDES "${EGPF_INCLUDE_INSTALL_DIR}")
else()
set(PRI_TARGET_INCLUDES "${BASEPATH}/${EGPF_INCLUDE_INSTALL_DIR}")
endif()
if(IS_ABSOLUTE "${EGPF_LIB_INSTALL_DIR}")
set(PRI_TARGET_LIBS "${EGPF_LIB_INSTALL_DIR}")
else()
set(PRI_TARGET_LIBS "${BASEPATH}/${EGPF_LIB_INSTALL_DIR}")
endif()
set(PRI_TARGET_DEFINES "")
set(PRI_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/qt_${PRI_TARGET_BASENAME}.pri)
if (EGPF_FILENAME_VAR)
set(${EGPF_FILENAME_VAR} ${PRI_FILENAME} PARENT_SCOPE)
endif()
set(PRI_TARGET_MODULE_CONFIG "")
# backward compat: it was not obvious LIB_NAME needs to be a target name,
# and some projects where the target name was not the actual library output name
# passed the output name for LIB_NAME, so .name & .module prperties are correctly set.
# TODO: improve API dox, allow control over module name if target name != output name
if(TARGET ${EGPF_LIB_NAME})
get_target_property(target_type ${EGPF_LIB_NAME} TYPE)
if (target_type STREQUAL "STATIC_LIBRARY")
set(PRI_TARGET_MODULE_CONFIG "staticlib")
endif()
endif()
file(GENERATE
OUTPUT ${PRI_FILENAME}
CONTENT
"QT.${PRI_TARGET_BASENAME}.VERSION = ${PROJECT_VERSION_STRING}
QT.${PRI_TARGET_BASENAME}.MAJOR_VERSION = ${PROJECT_VERSION_MAJOR}
QT.${PRI_TARGET_BASENAME}.MINOR_VERSION = ${PROJECT_VERSION_MINOR}
QT.${PRI_TARGET_BASENAME}.PATCH_VERSION = ${PROJECT_VERSION_PATCH}
QT.${PRI_TARGET_BASENAME}.name = ${PRI_TARGET_LIBNAME}
QT.${PRI_TARGET_BASENAME}.module = ${PRI_TARGET_LIBNAME}
QT.${PRI_TARGET_BASENAME}.defines = ${PRI_TARGET_DEFINES}
QT.${PRI_TARGET_BASENAME}.includes = ${PRI_TARGET_INCLUDES}
QT.${PRI_TARGET_BASENAME}.private_includes =
QT.${PRI_TARGET_BASENAME}.libs = ${PRI_TARGET_LIBS}
QT.${PRI_TARGET_BASENAME}.depends = ${PRI_TARGET_QTDEPS}
QT.${PRI_TARGET_BASENAME}.module_config = ${PRI_TARGET_MODULE_CONFIG}
"
)
endfunction()

View File

@@ -0,0 +1,46 @@
find_package(Qt5Core QUIET)
if (Qt5Core_FOUND)
set(_qmake_executable_default "qmake-qt5")
endif ()
if (TARGET Qt5::qmake)
get_target_property(_qmake_executable_default Qt5::qmake LOCATION)
endif()
set(QMAKE_EXECUTABLE ${_qmake_executable_default}
CACHE FILEPATH "Location of the Qt5 qmake executable")
# Helper method
# This is not public API (yet)!
# Usage: query_qmake(<result_variable> <qt_variable> [TRY])
# Passing TRY will result in the method not failing fatal if no qmake executable
# has been found, but instead simply returning an empty string
function(query_qmake result_variable qt_variable)
set(options TRY)
set(oneValueArgs )
set(multiValueArgs )
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT QMAKE_EXECUTABLE)
if(ARGS_TRY)
set(${result_variable} "" PARENT_SCOPE)
message(STATUS "No qmake Qt5 binary found. Can't check ${qt_variable}")
return()
else()
message(FATAL_ERROR "No qmake Qt5 binary found. Can't check ${qt_variable} as required")
endif()
endif()
execute_process(
COMMAND ${QMAKE_EXECUTABLE} -query "${qt_variable}"
RESULT_VARIABLE return_code
OUTPUT_VARIABLE output
)
if(return_code EQUAL 0)
string(STRIP "${output}" output)
file(TO_CMAKE_PATH "${output}" output_path)
set(${result_variable} "${output_path}" PARENT_SCOPE)
else()
message(WARNING "Failed call: ${QMAKE_EXECUTABLE} -query \"${qt_variable}\"")
message(FATAL_ERROR "QMake call failed: ${return_code}")
endif()
endfunction()

View File

@@ -0,0 +1,35 @@
# Some default installation locations. These should be global, with any project
# specific locations added to the end. These paths are all relative to the
# install prefix.
#
# These paths attempt to adhere to the FHS, and are similar to those provided
# by autotools and used in many Linux distributions.
# Use GNU install directories
include(GNUInstallDirs)
if(NOT INSTALL_RUNTIME_DIR)
set(INSTALL_RUNTIME_DIR ${CMAKE_INSTALL_BINDIR})
endif()
if(NOT INSTALL_LIBRARY_DIR)
set(INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR})
endif()
if(NOT INSTALL_ARCHIVE_DIR)
set(INSTALL_ARCHIVE_DIR ${CMAKE_INSTALL_LIBDIR})
endif()
if(NOT INSTALL_INCLUDE_DIR)
set(INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR})
endif()
if(NOT INSTALL_DATADIR)
set(INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR})
endif()
if(NOT INSTALL_DOC_DIR)
set(INSTALL_DOC_DIR ${CMAKE_INSTALL_DOCDIR})
endif()
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if (APPLE)
set(CMAKE_MACOSX_RPATH ON)
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN/../${INSTALL_LIBRARY_DIR}")
endif()

View File

@@ -0,0 +1,160 @@
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
# PYSIDE_BASEDIR - Top of the PySide2 installation
# PYSIDE_INCLUDE_DIR - Directories to include to use PySide2
# PYSIDE_LIBRARY - Files to link against to use PySide2
# PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide2
#
# You can install PySide2 from Qt repository with
# pip3 install --index-url=https://download.qt.io/official_releases/QtForPython --trusted-host download.qt.io pyside2
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PYSIDE2_PRIV QUIET pyside2)
endif()
set(PYSIDE2_FOUND FALSE)
if(PYSIDE2_PRIV_FOUND)
set(PYSIDE2_FOUND TRUE)
message(STATUS "Using PySide2 found in the system!")
pkg_get_variable(SHIBOKEN_BINARY
pyside2
generator_location
)
pkg_get_variable(PYSIDE2_BASEDIR
pyside2
typesystemdir
)
pkg_get_variable(PYSIDE_INCLUDE_DIR
pyside2
includedir
)
set(PYSIDE_TYPESYSTEMS ${PYSIDE2_BASEDIR})
set(PYSIDE2_SO_VERSION ${PYSIDE2_PRIV_VERSION})
set(PYSIDE_LIBRARY ${PYSIDE2_PRIV_LINK_LIBRARIES})
list(GET PYSIDE_LIBRARY 0 PYSIDE_LIBRARY)
else()
# extract python library basename
list(GET Python3_LIBRARIES 0 PYTHON_LIBRARY_FILENAME)
get_filename_component(PYTHON_LIBRARY_FILENAME ${PYTHON_LIBRARY_FILENAME} NAME)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os, sys
try:
import PySide2.QtCore as QtCore
print(os.path.dirname(QtCore.__file__))
except Exception as error:
print(error, file=sys.stderr)
exit()
"
OUTPUT_VARIABLE PYSIDE2_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(PYSIDE2_BASEDIR)
set(PYSIDE_BASEDIR ${PYSIDE2_BASEDIR} CACHE PATH "Top level install of PySide2" FORCE)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
import PySide2.QtCore as QtCore
print(os.path.basename(QtCore.__file__).split('.', 1)[1])
"
OUTPUT_VARIABLE PYSIDE2_SUFFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
import PySide2.QtCore as QtCore
print(';'.join(map(str, QtCore.__version_info__)))
"
OUTPUT_VARIABLE PYSIDE2_SO_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
list(GET PYSIDE2_SO_VERSION 0 PYSIDE2_SO_MACRO_VERSION)
list(GET PYSIDE2_SO_VERSION 1 PYSIDE2_SO_MICRO_VERSION)
list(GET PYSIDE2_SO_VERSION 2 PYSIDE2_SO_MINOR_VERSION)
string(REPLACE ";" "." PYSIDE2_SO_VERSION "${PYSIDE2_SO_VERSION}")
if(NOT APPLE)
set(PYSIDE2_SUFFIX "${PYSIDE2_SUFFIX}.${PYSIDE2_SO_MACRO_VERSION}.${PYSIDE2_SO_MICRO_VERSION}")
else()
string(REPLACE ".so" "" PYSIDE2_SUFFIX ${PYSIDE2_SUFFIX})
set(PYSIDE2_SUFFIX "${PYSIDE2_SUFFIX}.${PYSIDE2_SO_MACRO_VERSION}.${PYSIDE2_SO_MICRO_VERSION}.dylib")
endif()
set(PYSIDE2_FOUND TRUE)
message(STATUS "PySide2 base dir: ${PYSIDE2_BASEDIR}" )
message(STATUS "PySide2 suffix: ${PYSIDE2_SUFFIX}")
endif()
if (PYSIDE2_FOUND)
#PySide
#===============================================================================
find_path(PYSIDE_INCLUDE_DIR
pyside.h
PATHS ${PYSIDE2_BASEDIR}/include ${PYSIDE2_CUSTOM_PREFIX}/include/PySide2
NO_DEFAULT_PATH)
# Platform specific library names
if(MSVC)
SET(PYSIDE_LIBRARY_BASENAMES "pyside2.abi3.lib")
elseif(CYGWIN)
SET(PYSIDE_LIBRARY_BASENAMES "")
elseif(WIN32)
SET(PYSIDE_LIBRARY_BASENAMES "libpyside2.${PYSIDE2_SUFFIX}")
else()
SET(PYSIDE_LIBRARY_BASENAMES "libpyside2.${PYSIDE2_SUFFIX}")
endif()
find_file(PYSIDE_LIBRARY
${PYSIDE_LIBRARY_BASENAMES}
PATHS ${PYSIDE2_BASEDIR} ${PYSIDE2_CUSTOM_PREFIX}/lib
NO_DEFAULT_PATH)
find_path(PYSIDE_TYPESYSTEMS
typesystem_core.xml
PATHS ${PYSIDE2_BASEDIR}/typesystems ${PYSIDE2_CUSTOM_PREFIX}/share/PySide2/typesystems
NO_DEFAULT_PATH)
endif()
endif()
if(PYSIDE2_FOUND)
message(STATUS "PySide include dir: ${PYSIDE_INCLUDE_DIR}")
message(STATUS "PySide library: ${PYSIDE_LIBRARY}")
message(STATUS "PySide typesystems: ${PYSIDE_TYPESYSTEMS}")
message(STATUS "PySide2 version: ${PYSIDE2_SO_VERSION}")
# Create PySide2 target
add_library(PySide2::pyside2 SHARED IMPORTED GLOBAL)
if(MSVC)
set_property(TARGET PySide2::pyside2 PROPERTY
IMPORTED_IMPLIB ${PYSIDE_LIBRARY})
endif()
set_property(TARGET PySide2::pyside2 PROPERTY
IMPORTED_LOCATION ${PYSIDE_LIBRARY})
set_property(TARGET PySide2::pyside2 APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES
${PYSIDE_INCLUDE_DIR}
${PYSIDE_INCLUDE_DIR}/QtCore/
${PYSIDE_INCLUDE_DIR}/QtGui/
${PYSIDE_INCLUDE_DIR}/QtWidgets/
${Python3_INCLUDE_DIRS}
)
endif()
find_package_handle_standard_args(PySide2
REQUIRED_VARS PYSIDE2_BASEDIR PYSIDE_INCLUDE_DIR PYSIDE_LIBRARY PYSIDE_TYPESYSTEMS
VERSION_VAR PYSIDE2_SO_VERSION
)

View File

@@ -0,0 +1,187 @@
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
# SHIBOKEN_INCLUDE_DIR - Directories to include to use SHIBOKEN
# SHIBOKEN_LIBRARY - Files to link against to use SHIBOKEN
# SHIBOKEN_BINARY - Executable name
# SHIBOKEN_BUILD_TYPE - Tells if Shiboken was compiled in Release or Debug mode.
# You can install Shiboken from Qt repository with
# pip3 install --index-url=https://download.qt.io/official_releases/QtForPython --trusted-host download.qt.io shiboken2-generator
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(SHIBOKEN2_PRIV QUIET shiboken2)
endif()
set(SHIBOKEN_FOUND FALSE)
if(SHIBOKEN2_PRIV_FOUND)
set(SHIBOKEN_FOUND TRUE)
message(STATUS "Using shiboken found in the system!")
pkg_get_variable(SHIBOKEN_BINARY
shiboken2
generator_location
)
pkg_get_variable(SHIBOKEN_BASEDIR
shiboken2
libdir
)
pkg_get_variable(SHIBOKEN_INCLUDE_DIR
shiboken2
includedir
)
set(SHIBOKEN_VERSION ${SHIBOKEN2_PRIV_VERSION})
set(SHIBOKEN_LIBRARY ${SHIBOKEN2_PRIV_LINK_LIBRARIES})
else()
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
try:
import shiboken2_generator
print(shiboken2_generator.__path__[0])
except:
exit()
"
OUTPUT_VARIABLE SHIBOKEN_GENERATOR_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
try:
import shiboken2
print(shiboken2.__path__[0])
except:
exit()
"
OUTPUT_VARIABLE SHIBOKEN_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
import shiboken2
print(';'.join(filter(None, map(str, shiboken2.__version_info__))))
"
OUTPUT_VARIABLE SHIBOKEN_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
list(GET SHIBOKEN_VERSION 0 SHIBOKEN_MACRO_VERSION)
list(GET SHIBOKEN_VERSION 1 SHIBOKEN_MICRO_VERSION)
list(GET SHIBOKEN_VERSION 2 SHIBOKEN_MINOR_VERSION)
string(REPLACE ";" "." SHIBOKEN_VERSION "${SHIBOKEN_VERSION}")
message(STATUS "ShibokenGenerator base dir: ${SHIBOKEN_GENERATOR_BASEDIR}")
message(STATUS "Shiboken base dir: ${SHIBOKEN_BASEDIR}")
message(STATUS "Shiboken custom path: ${SHIBOKEN_CUSTOM_PATH}")
if(SHIBOKEN_BASEDIR)
find_path(SHIBOKEN_INCLUDE_DIR
shiboken.h
PATHS ${SHIBOKEN_CUSTOM_PATH} ${SHIBOKEN_GENERATOR_BASEDIR}/include
NO_DEFAULT_PATH)
if(MSVC)
SET(SHIBOKEN_LIBRARY_BASENAMES "shiboken2.abi3.lib")
elseif(CYGWIN)
SET(SHIBOKEN_LIBRARY_BASENAMES "")
elseif(WIN32)
SET(SHIBOKEN_LIBRARY_BASENAMES "libshiboken2.${PYSIDE2_SUFFIX}")
elseif(APPLE)
SET(SHIBOKEN_LIBRARY_BASENAMES
libshiboken2.abi3.dylib
libshiboken2.abi3.${SHIBOKEN_MACRO_VERSION}.dylib
libshiboken2.abi3.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}.dylib
libshiboken2.abi3.${SHIBOKEN_VERSION}.dylib
)
else()
SET(SHIBOKEN_LIBRARY_BASENAMES
libshiboken2.abi3.so
libshiboken2.abi3.so.${SHIBOKEN_MACRO_VERSION}
libshiboken2.abi3.so.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}
libshiboken2.abi3.so.${SHIBOKEN_VERSION}
)
endif()
if (NOT SHIBOKEN_INCLUDE_DIR)
return()
endif()
set(SHIBOKEN_SEARCH_PATHS ${SHIBOKEN_CUSTOM_PATH})
list(APPEND SHIBOKEN_SEARCH_PATHS ${SHIBOKEN_BASEDIR})
list(APPEND SHIBOKEN_SEARCH_PATHS ${SHIBOKEN_GENERATOR_BASEDIR})
find_file(SHIBOKEN_LIBRARY
${SHIBOKEN_LIBRARY_BASENAMES}
PATHS ${SHIBOKEN_SEARCH_PATHS}
NO_DEFAULT_PATH)
find_program(SHIBOKEN_BINARY
shiboken2
PATHS ${SHIBOKEN_SEARCH_PATHS}
NO_DEFAULT_PATH
)
endif()
if (SHIBOKEN_INCLUDE_DIR AND SHIBOKEN_LIBRARY AND SHIBOKEN_BINARY)
set(SHIBOKEN_FOUND TRUE)
endif()
if(SHIBOKEN_FOUND)
endif()
if(MSVC)
# On Windows we must link to python3.dll that is a small library that links against python3x.dll
# that allow us to choose any python3x.dll at runtime
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
for lib in '${Python3_LIBRARIES}'.split(';'):
if '/' in lib:
prefix, py = lib.rsplit('/', 1)
if py.startswith('python3'):
print(prefix + '/python3.lib')
break
"
OUTPUT_VARIABLE PYTHON_LIMITED_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
# On Linux and MacOs our modules should not link with any python library
# that must be handled by the main process
set(PYTHON_LIMITED_LIBRARIES "")
endif()
endif()
if (SHIBOKEN_FOUND)
message(STATUS "Shiboken include dir: ${SHIBOKEN_INCLUDE_DIR}")
message(STATUS "Shiboken library: ${SHIBOKEN_LIBRARY}")
message(STATUS "Shiboken binary: ${SHIBOKEN_BINARY}")
message(STATUS "Shiboken version: ${SHIBOKEN_VERSION}")
# Create shiboke2 target
add_library(Shiboken2::libshiboken SHARED IMPORTED GLOBAL)
if(MSVC)
set_property(TARGET Shiboken2::libshiboken PROPERTY
IMPORTED_IMPLIB ${SHIBOKEN_LIBRARY})
endif()
set_property(TARGET Shiboken2::libshiboken PROPERTY
IMPORTED_LOCATION ${SHIBOKEN_LIBRARY})
set_property(TARGET Shiboken2::libshiboken APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${SHIBOKEN_INCLUDE_DIR} ${Python3_INCLUDE_DIRS})
set_property(TARGET Shiboken2::libshiboken APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${PYTHON_LIMITED_LIBRARIES})
# Generator target
add_executable(Shiboken2::shiboken IMPORTED GLOBAL)
set_property(TARGET Shiboken2::shiboken PROPERTY
IMPORTED_LOCATION ${SHIBOKEN_BINARY})
endif()
find_package_handle_standard_args(Shiboken2
REQUIRED_VARS SHIBOKEN_BASEDIR SHIBOKEN_INCLUDE_DIR SHIBOKEN_LIBRARY SHIBOKEN_BINARY
VERSION_VAR SHIBOKEN_VERSION
)

View File

@@ -0,0 +1,157 @@
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
if (NOT ${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX)
SET(${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE FILEPATH "Custom path to install python bindings.")
endif()
message(STATUS "PYTHON INSTALL PREFIX ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}")
if (WIN32)
set(PATH_SEP "\;")
else()
set(PATH_SEP ":")
endif()
if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
# On macOS, check if Qt is a framework build. This affects how include paths should be handled.
get_target_property(QtCore_is_framework Qt5::Core FRAMEWORK)
if (QtCore_is_framework)
# Get the path to the framework dir.
list(GET Qt5Core_INCLUDE_DIRS 0 QT_INCLUDE_DIR)
get_filename_component(QT_FRAMEWORK_INCLUDE_DIR "${QT_INCLUDE_DIR}/../" ABSOLUTE)
# QT_INCLUDE_DIR points to the QtCore.framework directory, so we need to adjust this to point
# to the actual include directory, which has include files for non-framework parts of Qt.
get_filename_component(QT_INCLUDE_DIR "${QT_INCLUDE_DIR}/../../include" ABSOLUTE)
endif()
# Flags that we will pass to shiboken-generator
# --generator-set=shiboken: tells the generator that we want to use shiboken to generate code,
# a doc generator is also available
# --enable-parent-ctor-heuristic: Enable heuristics to detect parent relationship on constructors,
# this try to guess parent ownership based on the arguments of the constructors
# --enable-pyside-extensionsL: This will generate code for Qt based classes, adding extra attributes,
# like signal, slot;
# --enable-return-value-heuristic: Similar as --enable-parent-ctor-heuristic this use some logic to guess
# parent child relationship based on the returned argument
# --use-isnull-as-nb_nonzero: If a class have an isNull() const method, it will be used to compute
# the value of boolean casts.
# Example, QImage::isNull() will be used when on python side you do `if (myQImage)`
set(GENERATOR_EXTRA_FLAGS --generator-set=shiboken
--enable-parent-ctor-heuristic
--enable-pyside-extensions
--enable-return-value-heuristic
--use-isnull-as-nb_nonzero
-std=c++${CMAKE_CXX_STANDARD})
# 2017-04-24 The protected hack can unfortunately not be disabled, because
# Clang does produce linker errors when we disable the hack.
# But the ugly workaround in Python is replaced by a shiboken change.
if(WIN32 OR DEFINED AVOID_PROTECTED_HACK)
set(GENERATOR_EXTRA_FLAGS ${GENERATOR_EXTRA_FLAGS} --avoid-protected-hack)
add_definitions(-DAVOID_PROTECTED_HACK)
endif()
macro(make_path varname)
# accepts any number of path variables
string(REPLACE ";" "${PATH_SEP}" ${varname} "${ARGN}")
endmacro()
# Creates a PySide module target based on the arguments
# This will:
# 1 - Create a Cmake custom-target that call shiboken-generator passign the correct arguments
# 2 - Create a Cmake library target called "Py${LIBRARY_NAME}" the output name of this target
# will be changed to match PySide template
# Args:
# LIBRARY_NAME - The name of the output module
# TYPESYSTEM_PATHS - A list of paths where shiboken should look for typesystem files
# INCLUDE_PATHS - Include pahts necessary to parse your class. *This is not the same as build*
# OUTPUT_SOURCES - The files that will be generated by shiboken
# TARGET_INCLUDE_DIRS - This will be passed to target_include_directories
# TARGET_LINK_LIBRARIES - This will be passed to target_link_libraries
# GLOBAL_INCLUDE - A header-file that contains alls classes that will be generated
# TYPESYSTEM_XML - The target binding typesystem (that should be the full path)
# DEPENDS - This var will be passed to add_custom_command(DEPENDS) so a new generation will be
# trigger if one of these files changes
# MODULE_OUTPUT_DIR - Where the library file should be stored
macro(CREATE_PYTHON_BINDINGS
LIBRARY_NAME
TYPESYSTEM_PATHS
INCLUDE_PATHS
OUTPUT_SOURCES
TARGET_INCLUDE_DIRS
TARGET_LINK_LIBRARIES
GLOBAL_INCLUDE
TYPESYSTEM_XML
DEPENDS
MODULE_OUTPUT_DIR)
# Transform the path separators into something shiboken understands.
make_path(shiboken_include_dirs ${INCLUDE_PATHS})
make_path(shiboken_typesystem_dirs ${TYPESYSTEM_PATHS})
get_property(raw_python_dir_include_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
make_path(python_dir_include_dirs ${raw_python_dir_include_dirs})
set(shiboken_include_dirs "${shiboken_include_dirs}${PATH_SEP}${python_dir_include_dirs}")
set(shiboken_framework_include_dirs_option "")
if(CMAKE_HOST_APPLE)
set(shiboken_framework_include_dirs "${QT_FRAMEWORK_INCLUDE_DIR}")
make_path(shiboken_framework_include_dirs ${shiboken_framework_include_dirs})
set(shiboken_framework_include_dirs_option "--framework-include-paths=${shiboken_framework_include_dirs}")
endif()
set_property(SOURCE ${OUTPUT_SOURCES} PROPERTY SKIP_AUTOGEN ON)
add_custom_command(OUTPUT ${OUTPUT_SOURCES}
COMMAND $<TARGET_PROPERTY:Shiboken2::shiboken,LOCATION> ${GENERATOR_EXTRA_FLAGS}
${GLOBAL_INCLUDE}
--include-paths=${shiboken_include_dirs}
--typesystem-paths=${shiboken_typesystem_dirs}
${shiboken_framework_include_dirs_option}
--output-directory=${CMAKE_CURRENT_BINARY_DIR}
${TYPESYSTEM_XML}
DEPENDS ${TYPESYSTEM_XML} ${DEPENDS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Running generator for ${LIBRARY_NAME} binding...")
set(TARGET_NAME "Py${LIBRARY_NAME}")
set(MODULE_NAME "${LIBRARY_NAME}")
add_library(${TARGET_NAME} MODULE ${OUTPUT_SOURCES})
set_target_properties(${TARGET_NAME} PROPERTIES
PREFIX ""
OUTPUT_NAME ${MODULE_NAME}
LIBRARY_OUTPUT_DIRECTORY ${MODULE_OUTPUT_DIR}
)
if(WIN32)
set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ".pyd")
endif()
target_include_directories(${TARGET_NAME} PUBLIC
${TARGET_INCLUDE_DIRS}
${PYSIDE_EXTRA_INCLUDES}
)
target_link_libraries(${TARGET_NAME}
${TARGET_LINK_LIBRARIES}
PySide2::pyside2
Shiboken2::libshiboken
)
target_compile_definitions(${TARGET_NAME}
PRIVATE Py_LIMITED_API=0x03050000
)
if(APPLE)
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY
LINK_FLAGS "-undefined dynamic_lookup")
endif()
install(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}/${TARGET_NAME})
endmacro()

View File

@@ -0,0 +1,70 @@
#
# SPDX-FileCopyrightText: 2016-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Allen Winter <allen.winter@kdab.com>
#
# SPDX-License-Identifier: BSD-3-Clause
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Create variables for all the various install paths for the Qt version in use
# Make sure to have found Qt5 before using this.
# sets variables like QT_INSTALL_PREFIX, QT_INSTALL_DATA, QT_INSTALL_DOCS, etc.
# run qmake -query to see a full list
if(TARGET Qt5::qmake)
get_target_property(QT_QMAKE_EXECUTABLE Qt5::qmake LOCATION)
else()
message(FATAL_ERROR "No supported Qt version found. Make sure you find Qt before calling this")
endif()
execute_process(
COMMAND ${QT_QMAKE_EXECUTABLE} -query
RESULT_VARIABLE return_code
OUTPUT_VARIABLE ALL_VARS
)
if(NOT return_code EQUAL 0)
message(WARNING "Failed call: ${QMAKE_EXECUTABLE} -query")
message(FATAL_ERROR "QMake call failed: ${return_code}")
endif()
string(REPLACE "\n" ";" VARS_LIST ${ALL_VARS})
foreach(QVAL ${VARS_LIST})
if(QVAL MATCHES "QT_INSTALL_")
string(REPLACE ":" ";" QVAL_LIST ${QVAL})
list(LENGTH QVAL_LIST listlen)
list(GET QVAL_LIST 0 var)
if(WIN32 AND ${listlen} GREATER 2)
list(GET QVAL_LIST 2 path)
list(GET QVAL_LIST 1 drive)
set(path "${drive}:${path}")
else()
list(GET QVAL_LIST 1 path)
endif()
if(NOT ${var}) #if set aleady on the command line for example
set(${var} ${path} CACHE PATH "Qt install path for ${var}")
endif()
endif()
endforeach()

18
conan/README.txt Normal file
View File

@@ -0,0 +1,18 @@
In the following example we assume you have the kddockwidgets source available in
/path/to/kddockwidgets-source. replace '/path/to/kddockwidgets-source' to fit your needs.
$ conan create -s build_type=Release -o kddockwidgets:build_examples=True -o kddockwidgets:build_tests=True /path/to/kddockwidgets-source/conan kdab/stable
Configuration options:
* build_static
Builds static versions of the libraries. Default=False
* build_tests
Build the test harness. Default=False
* build_examples
Build the examples. Default=True
* builde_python_bindings
Build/Generate python bindings (always false for Debug or static builds). Default=False

65
conan/conanfile.py Normal file
View File

@@ -0,0 +1,65 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
from conans import ConanFile, CMake, tools
class KDDockWidgetsConan(ConanFile):
name = "kddockwidgets"
version = "1.1.0"
default_user = "kdab"
default_channel = "stable"
license = ("https://raw.githubusercontent.com/KDAB/KDDockWidgets/master/LICENSES/GPL-2.0-only.txt",
"https://raw.githubusercontent.com/KDAB/KDDockWidgets/master/LICENSES/GPL-3.0-only.txt")
author = "Klaralvdalens Datakonsult AB (KDAB) info@kdab.com"
url = "https://github.com/KDAB/KDDockWidgets"
description = "Advanced Dock Widget Framework for Qt"
generators = "cmake"
topics = ("qt", "dockwidget" , "kdab")
settings = "os", "compiler", "build_type", "arch"
options = {
"qt_version": "ANY",
"build_static": [True, False],
"build_examples": [True, False],
"build_tests": [True, False],
"build_python_bindings": [True, False],
}
default_options = {
"qt_version": "qt/[>5.9.0]@kdab/stable",
"build_static": False,
"build_examples": True,
"build_tests": False,
"build_python_bindings": False,
}
def requirements(self):
# Check https://docs.conan.io/en/latest/reference/conanfile/attributes.html#version-ranges for more info about versioning
self.requires(str(self.options.qt_version))
def source(self):
git = tools.Git(folder="")
git.clone(self.url)
def build(self, build_type="Release"):
self.cmake = CMake(self, generator='Ninja', build_type=build_type)
self.cmake.definitions["KDDockWidgets_STATIC"] = self.options.build_static
self.cmake.definitions["KDDockWidgets_EXAMPLES"] = self.options.build_examples
self.cmake.definitions["KDDockWidgets_TESTS"] = self.options.build_tests
self.cmake.definitions["KDDockWidgets_PYTHON_BINDINGS"] = self.options.build_python_bindings
self.cmake.configure()
self.cmake.build()
def package(self):
self.cmake.install()
def package_info(self):
self.env_info.CMAKE_PREFIX_PATH.append(self.package_folder)
def package_id(self):
self.info.requires["qt"].minor_mode() # Check only the major and minor version!

17
debian.changelog Normal file
View File

@@ -0,0 +1,17 @@
kddockwidgets (1.1.0) release candidate; urgency=high
* 1.1.0 final
-- Allen Winter <allen.winter@kdab.com> Mon, 26 Oct 2020 12:00:00 -0500
kddockwidgets (1.0.0) release candidate; urgency=high
* 1.0.0 final
-- Allen Winter <allen.winter@kdab.com> Wed, 2 Sep 2020 12:00:00 -0500
kddockwidgets (0.99.9) release candidate; urgency=high
* 1.0.0 release candidate
-- Allen Winter <allen.winter@kdab.com> Thu, 6 Aug 2020 11:00:00 -0500

1
debian.compat Normal file
View File

@@ -0,0 +1 @@
9

12
debian.control Normal file
View File

@@ -0,0 +1,12 @@
Source: kddockwidgets
Section: Miscellaneous
Priority: optional
Maintainer: Allen Winter <allen.winter@kdab.com>
Build-Depends: debhelper (>=9), cdbs, cmake
Standards-Version: 3.9.6
Homepage: https://github.com/KDAB/KDDockWidgets
Package: kddockwidgets
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: KDAB's Dock Widget Framework for Qt

3
debian.rules Normal file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/cmake.mk

40
docs/CMakeLists.txt Normal file
View File

@@ -0,0 +1,40 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Allen Winter <allen.winter@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
# qhelpgenerator
find_program(QHELPGEN_EXECUTABLE qhelpgenerator
HINTS ${QT_INSTALL_BINS}
)
if(QHELPGEN_EXECUTABLE)
set(HAVE_QHELPGEN "YES")
else()
set(HAVE_QHELPGEN "NO")
message(STATUS "Unable to generate the API documentation in qch format. To fix, install the qthelpgenerator program which comes with Qt5.")
endif()
# Doxygen
find_package(Doxygen)
set_package_properties(Doxygen PROPERTIES
TYPE OPTIONAL
DESCRIPTION "API Documentation system"
URL "https://www.doxygen.org"
PURPOSE "Needed to build the API documentation."
)
if(DOXYGEN_DOT_EXECUTABLE)
set(HAVE_DOT "YES")
else()
set(HAVE_DOT "NO")
message(STATUS "Unable to provide inheritance diagrams for the API documentation. To fix, install the graphviz project from https://www.graphviz.org")
endif()
if(DOXYGEN_FOUND)
add_subdirectory(api)
endif()

40
docs/api/CMakeLists.txt Normal file
View File

@@ -0,0 +1,40 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Allen Winter <allen.winter@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
find_file(QDOC_QTCORE_TAG qtcore.tags
HINTS ${QT_INSTALL_DOCS}/qtcore
HINTS ${QT_INSTALL_DATA}/doc/qtcore
)
if(QDOC_QTCORE_TAG)
get_filename_component(QDOC_TAG_DIR ${QDOC_QTCORE_TAG} DIRECTORY)
get_filename_component(QDOC_TAG_DIR ${QDOC_TAG_DIR} DIRECTORY)
endif()
file(GLOB _dox_deps *.dox *.html)
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
#apidox generation using doxygen
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.cmake
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
)
add_custom_command(
OUTPUT ${DOXYGEN_OUTPUT_DIR}/qch/kddockwidgets-api.qch
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
#handle a bug in doxygen where image files referred to in markdown are not copied the output
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/screencap.gif ${DOXYGEN_OUTPUT_DIR}/html
DEPENDS ${_dox_deps} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target(kddockwidgets-api.qch ALL DEPENDS ${DOXYGEN_OUTPUT_DIR}/qch/kddockwidgets-api.qch)
install(FILES ${DOXYGEN_OUTPUT_DIR}/qch/kddockwidgets-api.qch DESTINATION ${INSTALL_DOC_DIR})

2536
docs/api/Doxyfile.cmake Normal file

File diff suppressed because it is too large Load Diff

19
docs/api/footer.html Normal file
View File

@@ -0,0 +1,19 @@
<hr>
<div style="float: left;">
<img src="kdab-logo-16x16.png">
<font style="font-weight: bold;">Klar&auml;lvdalens Datakonsult AB (KDAB)</font>
<br>
"The Qt, C++ and OpenGL Experts"<br>
<a href="https://www.kdab.com/">https://www.kdab.com/</a>
</div>
<div style="text-align: right;">
<img src="kdab-kddockwidgets-logo-16x16.png" />
<font style="font-weight: bold;">KDDockWidgets</font>
<br>
Advanced Dock Widget Framework for Qt<br>
<a href="https://www.kdab.com/development-resources/qt-tools/kddockwidgets/">https://www.kdab.com/development-resources/qt-tools/kddockwidgets/</a>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -1,26 +1,38 @@
cmake_minimum_required(VERSION 3.3)
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.7)
project(kddockwidgets_example)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
# This will look for Qt, do find_package yourself manually before
# if you want to look for a specific version for instance.
find_package(KDDockWidgets REQUIRED)
if(NOT TARGET kddockwidgets)
# This will look for Qt, do find_package yourself manually before
# if you want to look for a specific Qt version for instance.
find_package(KDDockWidgets REQUIRED)
endif()
qt5_add_resources(RESOURCES_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources.qrc)
qt5_add_resources(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources_example.qrc)
add_executable(kddockwidgets_example
main.cpp
MyFrameworkWidgetFactory.cpp
MyMainWindow.cpp
MyWidget.cpp
${RESOURCES_SRC}
${RESOURCES_EXAMPLE_SRC}
)
target_link_libraries(kddockwidgets_example
PRIVATE
KDAB::kddockwidgets
PRIVATE
KDAB::kddockwidgets
)

View File

@@ -1,43 +1,39 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include "MyFrameworkWidgetFactory.h"
#include <kddockwidgets/FrameworkWidgetFactory.h>
//#include <kddockwidgets/widgets/SeparatorWidget_p.h>
#include <kddockwidgets/private/widgets/TitleBarWidget_p.h>
#include <kddockwidgets/private/multisplitter/Separator_qwidget.h>
#include <QApplication>
class MyTitleBar : public KDDockWidgets::TitleBar
class MyTitleBar : public KDDockWidgets::TitleBarWidget
{
public:
explicit MyTitleBar(KDDockWidgets::Frame *frame)
: KDDockWidgets::TitleBar(frame)
: KDDockWidgets::TitleBarWidget(frame)
{
init();
}
explicit MyTitleBar(KDDockWidgets::FloatingWindow *fw)
: KDDockWidgets::TitleBar(fw)
: KDDockWidgets::TitleBarWidget(fw)
{
init();
}
~MyTitleBar() override;
void init()
{
setFixedHeight(60);
@@ -47,7 +43,9 @@ public:
{
QPainter p(this);
QPen pen(Qt::black);
QBrush brush(Qt::yellow);
const QColor focusedBackgroundColor = Qt::yellow;
const QColor backgroundColor = focusedBackgroundColor.darker(115);
QBrush brush(isFocused() ? focusedBackgroundColor : backgroundColor);
pen.setWidth(4);
p.setPen(pen);
p.setBrush(brush);
@@ -60,24 +58,27 @@ public:
}
};
/*
MyTitleBar::~MyTitleBar() = default;
// Inheriting from SeparatorWidget instead of Separator as it handles moving and mouse cursor changing
class MySeparator : public KDDockWidgets::SeparatorWidget
class MySeparator : public Layouting::SeparatorWidget
{
public:
explicit MySeparator(KDDockWidgets::Anchor *anchor,
KDDockWidgets::QWidgetAdapter *parent = nullptr)
: KDDockWidgets::SeparatorWidget(anchor, parent)
explicit MySeparator(Layouting::Widget *parent)
: Layouting::SeparatorWidget(parent)
{
}
~MySeparator() override;
void paintEvent(QPaintEvent *) override
{
QPainter p(this);
p.fillRect(rect(), isStatic() ? Qt::black : Qt::cyan);
p.fillRect(QWidget::rect(), Qt::cyan);
}
};
*/
MySeparator::~MySeparator() = default;
KDDockWidgets::TitleBar * CustomWidgetFactory::createTitleBar(KDDockWidgets::Frame *frame) const
{
@@ -88,10 +89,9 @@ KDDockWidgets::TitleBar * CustomWidgetFactory::createTitleBar(KDDockWidgets::Flo
{
return new MyTitleBar(fw);
}
/*
KDDockWidgets::Separator * CustomWidgetFactory::createSeparator(KDDockWidgets::Anchor *anchor,
KDDockWidgets::QWidgetAdapter *parent) const
Layouting::Separator * CustomWidgetFactory::createSeparator(Layouting::Widget *parent) const
{
return new MySeparator(anchor, parent);
return new MySeparator(parent);
}
*/

View File

@@ -1,27 +1,18 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#pragma once
#include <kddockwidgets/FrameworkWidgetFactory.h>
#include <kddockwidgets/private/TitleBar_p.h>
#include <QPainter>
class CustomWidgetFactory : public KDDockWidgets::DefaultWidgetFactory
@@ -29,6 +20,5 @@ class CustomWidgetFactory : public KDDockWidgets::DefaultWidgetFactory
public:
KDDockWidgets::TitleBar *createTitleBar(KDDockWidgets::Frame *frame) const override;
KDDockWidgets::TitleBar *createTitleBar(KDDockWidgets::FloatingWindow *fw) const override;
/* KDDockWidgets::Separator *createSeparator(KDDockWidgets::Anchor *anchor, // Commented-out as we need to install more headers
KDDockWidgets::QWidgetAdapter *parent = nullptr) const override;*/
Layouting::Separator *createSeparator(Layouting::Widget *parent = nullptr) const override;
};

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include "MyMainWindow.h"
@@ -29,13 +20,22 @@
#include <QDebug>
#include <QString>
#include <QTextEdit>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#include <QRandomGenerator>
#endif
#include <stdlib.h>
#include <time.h>
// clazy:excludeall=qstring-allocations
static MyWidget *newMyWidget()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
const int randomNumber = qrand() % 100 + 1;
#else
const int randomNumber = QRandomGenerator::global()->bounded(0, 100) + 1;
#endif
if (randomNumber < 50) {
if (randomNumber < 33) {
@@ -49,16 +49,20 @@ static MyWidget *newMyWidget()
}
MyMainWindow::MyMainWindow(const QString &uniqueName, KDDockWidgets::MainWindowOptions options,
bool dockWidget0IsNonClosable, bool restoreIsRelative,
bool dockWidget0IsNonClosable, bool nonDockableDockWidget9, bool restoreIsRelative,
bool maxSizeForDockWidget8,
const QString &affinityName, QWidget *parent)
: MainWindow(uniqueName, options, parent)
, m_dockWidget0IsNonClosable(dockWidget0IsNonClosable)
, m_dockWidget9IsNonDockable(nonDockableDockWidget9)
, m_restoreIsRelative(restoreIsRelative)
, m_maxSizeForDockWidget8(maxSizeForDockWidget8)
{
// qApp->installEventFilter(this);
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
qsrand(time(nullptr));
#endif
// qApp->installEventFilter(this);
auto menubar = menuBar();
auto fileMenu = new QMenu(QStringLiteral("File"));
m_toggleMenu = new QMenu(QStringLiteral("Toggle"));
@@ -95,25 +99,36 @@ MyMainWindow::MyMainWindow(const QString &uniqueName, KDDockWidgets::MainWindowO
saver.restoreFromFile(QStringLiteral("mylayout.json"));
});
auto closeAllAction = fileMenu->addAction(QStringLiteral("Close all"));
auto closeAllAction = fileMenu->addAction(QStringLiteral("Close All"));
connect(closeAllAction, &QAction::triggered, this, [this] {
for (auto dw : m_dockwidgets)
for (auto dw : qAsConst(m_dockwidgets))
dw->close();
});
auto layoutEqually = fileMenu->addAction(QStringLiteral("Layout Equally"));
connect(layoutEqually, &QAction::triggered, this, &MainWindow::layoutEqually);
auto quitAction = fileMenu->addAction(QStringLiteral("Quit"));
connect(quitAction, &QAction::triggered, qApp, &QApplication::quit);
setAffinityName(affinityName);
setAffinities({ affinityName });
createDockWidgets();
}
MyMainWindow::~MyMainWindow()
{
qDeleteAll(m_dockwidgets);
}
void MyMainWindow::createDockWidgets()
{
Q_ASSERT(m_dockwidgets.isEmpty());
const int numDockWidgets = m_dockWidget9IsNonDockable ? 10 : 9;
// Create 9 KDDockWidget::DockWidget and the respective widgets they're hosting (MyWidget instances)
for (int i = 0; i < 9; i++)
for (int i = 0; i < numDockWidgets; i++)
m_dockwidgets << newDockWidget();
@@ -127,7 +142,7 @@ void MyMainWindow::createDockWidgets()
addDockWidget(m_dockwidgets[3], KDDockWidgets::Location_OnBottom);
addDockWidget(m_dockwidgets[4], KDDockWidgets::Location_OnBottom);
// Tab two dock widgets toghether
// Tab two dock widgets together
m_dockwidgets[3]->addDockWidgetAsTab(m_dockwidgets[5]);
// 6 is floating, as it wasn't added to the main window via MainWindow::addDockWidget().
@@ -150,16 +165,30 @@ KDDockWidgets::DockWidgetBase *MyMainWindow::newDockWidget()
if (count == 0 && m_dockWidget0IsNonClosable)
options |= KDDockWidgets::DockWidget::Option_NotClosable;
if (count == 9 && m_dockWidget9IsNonDockable)
options |= KDDockWidgets::DockWidget::Option_NotDockable;
auto dock = new KDDockWidgets::DockWidget(QStringLiteral("DockWidget #%1").arg(count), options);
dock->setAffinityName(affinityName()); // optional, just to show the feature. Pass -mi to the example to see incompatible dock widgets
dock->setAffinities(affinities()); // optional, just to show the feature. Pass -mi to the example to see incompatible dock widgets
if (count == 1)
dock->setIcon(QIcon::fromTheme(QStringLiteral("mail-message")));
auto myWidget = newMyWidget();
if (count == 8 && m_maxSizeForDockWidget8) {
// Set a maximum size on dock #8
myWidget->setMaximumSize(200, 200);
}
dock->setWidget(myWidget);
dock->setTitle(QStringLiteral("DockWidget #%1").arg(count));
if (dock->options() & KDDockWidgets::DockWidget::Option_NotDockable) {
dock->setTitle(QStringLiteral("DockWidget #%1 (%2)").arg(count).arg("non dockable"));
} else {
dock->setTitle(QStringLiteral("DockWidget #%1").arg(count));
}
dock->resize(600, 600);
dock->show();
m_toggleMenu->addAction(dock->toggleAction());
count++;

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#pragma once
@@ -28,15 +19,19 @@ class MyMainWindow : public KDDockWidgets::MainWindow
Q_OBJECT
public:
explicit MyMainWindow(const QString &uniqueName, KDDockWidgets::MainWindowOptions options,
bool dockWidget0IsNonClosable, bool restoreIsRelative,
bool dockWidget0IsNonClosable, bool nonDockableDockWidget9, bool restoreIsRelative,
bool maxSizeForDockWidget8,
const QString &affinityName = {}, // Usually not needed. Just here to show the feature.
QWidget *parent = nullptr);
~MyMainWindow() override;
private:
void createDockWidgets();
KDDockWidgets::DockWidgetBase* newDockWidget();
QMenu *m_toggleMenu = nullptr;
const bool m_dockWidget0IsNonClosable;
const bool m_dockWidget9IsNonDockable;
const bool m_restoreIsRelative;
const bool m_maxSizeForDockWidget8;
KDDockWidgets::DockWidget::List m_dockwidgets;
};

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include "MyWidget.h"
@@ -23,8 +14,9 @@
#include <QPainter>
#include <QDebug>
#include <QFile>
#include <QLineEdit>
static QHash<QString, QImage> s_images;
static QHash<QString, QImage> s_images; /// clazy:exclude=non-pod-global-static
MyWidget::MyWidget(const QString &backgroundFile, const QString &logoFile, QWidget *parent)
: QWidget(parent)
@@ -42,6 +34,15 @@ MyWidget::MyWidget(const QString &backgroundFile, const QString &logoFile, QWidg
it = s_images.insert(logoFile, QImage(logoFile));
m_logo = it.value();
}
setFocusPolicy(Qt::StrongFocus);
if (qEnvironmentVariableIsSet("KDDW_DEBUG_FOCUS")) {
// Uncomment to show focus propagation working
new QLineEdit(this);
auto l2 = new QLineEdit(this);
l2->move(0, 100);
setFocusProxy(l2);
}
}
MyWidget::~MyWidget()

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#ifndef EXAMPLEDOCKABLEWIDGET_H
@@ -25,7 +16,9 @@
#include <QWidget>
QT_BEGIN_NAMESPACE
class QPainter;
QT_END_NAMESPACE
class MyWidget : public QWidget
{

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include "MyWidget.h"
@@ -29,6 +20,8 @@
#include <QDebug>
#include <QCommandLineParser>
// clazy:excludeall=qstring-allocations
using namespace KDDockWidgets;
int main(int argc, char **argv)
@@ -44,6 +37,7 @@ int main(int argc, char **argv)
parser.setApplicationDescription("KDDockWidgets example application");
parser.addHelpOption();
// Fusion looks better in general, but feel free to change
qApp->setStyle(QStyleFactory::create(QStringLiteral("Fusion")));
QCommandLineOption customStyle("p", QCoreApplication::translate("main", "Shows how to style framework internals via FrameworkWidgetFactory"));
@@ -52,9 +46,15 @@ int main(int argc, char **argv)
QCommandLineOption reorderTabsOption("r", QCoreApplication::translate("main", "Support re-ordering tabs with mouse"));
parser.addOption(reorderTabsOption);
QCommandLineOption noTitleBars("t", QCoreApplication::translate("main", "Never show titlebars"));
QCommandLineOption noTitleBars("t", QCoreApplication::translate("main", "Hide titlebars when tabs are visible"));
parser.addOption(noTitleBars);
QCommandLineOption alwaysTitleBarWhenFloating("q", QCoreApplication::translate("main", "Don't hide title bars if floating, even if Flag_HideTitleBarWhenTabsVisible is specified."));
parser.addOption(alwaysTitleBarWhenFloating);
QCommandLineOption alwaysTabs("z", QCoreApplication::translate("main", "Show tabs even if there's only one"));
parser.addOption(alwaysTabs);
QCommandLineOption lazyResizeOption("l", QCoreApplication::translate("main", "Use lazy resize"));
parser.addOption(lazyResizeOption);
@@ -76,9 +76,50 @@ int main(int argc, char **argv)
QCommandLineOption doubleClickMaximize("x", QCoreApplication::translate("main", "Double clicking a title bar will maximize a floating window"));
parser.addOption(doubleClickMaximize);
QCommandLineOption nonDockable("d", QCoreApplication::translate("main", "DockWidget #9 will be non-dockable"));
parser.addOption(nonDockable);
QCommandLineOption maximizeButtonOption("b", QCoreApplication::translate("main", "Floating dockWidgets have maximize/restore buttons instead of float/dock button"));
parser.addOption(maximizeButtonOption);
QCommandLineOption minimizeButtonOption("k", QCoreApplication::translate("main", "Floating dockWidgets have a minimize button. Implies not being an utility window (~Qt::Tool)"));
parser.addOption(minimizeButtonOption);
QCommandLineOption segmentedIndicators("y", QCoreApplication::translate("main", "Use segmented indicators instead of classical"));
parser.addOption(segmentedIndicators);
QCommandLineOption noUtilityWindows("u", QCoreApplication::translate("main", "FloatingWindows will be normal windows instead of utility windows"));
parser.addOption(noUtilityWindows);
parser.addPositionalArgument("savedlayout", QCoreApplication::translate("main", "loads the specified json file at startup"));
#ifdef KDDOCKWIDGETS_SUPPORTS_NESTED_MAINWINDOWS
QCommandLineOption dockableMainWindows("j", QCoreApplication::translate("main", "Allow main windows to be docked inside other main windows"));
parser.addOption(dockableMainWindows);
#endif
QCommandLineOption maxSizeOption("g", QCoreApplication::translate("main", "Make dock #8 have a max-size of 200x200."));
parser.addOption(maxSizeOption);
QCommandLineOption centralFrame("f", QCoreApplication::translate("main", "Persistent central frame"));
QCommandLineOption autoHideSupport("w", QCoreApplication::translate("main", "Enables auto-hide/minimization to side-bar support"));
parser.addOption(autoHideSupport);
#if defined(DOCKS_DEVELOPER_MODE)
QCommandLineOption noCentralFrame("c", QCoreApplication::translate("main", "No central frame"));
parser.addOption(noCentralFrame);
parser.addOption(centralFrame);
QCommandLineOption noQtTool("no-qttool", QCoreApplication::translate("main", "(internal) Don't use Qt::Tool"));
QCommandLineOption noParentForFloating("no-parent-for-floating", QCoreApplication::translate("main", "(internal) FloatingWindows won't have a parent"));
parser.addOption(noQtTool);
parser.addOption(noParentForFloating);
# if defined(Q_OS_WIN)
QCommandLineOption noAeroSnap("no-aero-snap", QCoreApplication::translate("main", "(internal) Disable AeroSnap"));
parser.addOption(noAeroSnap);
# endif
#else
Q_UNUSED(centralFrame)
#endif
parser.process(app);
@@ -87,22 +128,63 @@ int main(int argc, char **argv)
Config::self().setFrameworkWidgetFactory(new CustomWidgetFactory()); // Sets our custom factory
// Increase the separator size, just for demo
Config::self().setSeparatorThickness(10, /*static=*/ false);
Config::self().setSeparatorThickness(10);
}
if (parser.isSet(segmentedIndicators))
KDDockWidgets::DefaultWidgetFactory::s_dropIndicatorType = KDDockWidgets::DropIndicatorType::Segmented;
MainWindowOptions options = MainWindowOption_None;
auto flags = KDDockWidgets::Config::self().flags();
#if defined(DOCKS_DEVELOPER_MODE)
options = parser.isSet(noCentralFrame) ? MainWindowOption_None
: MainWindowOption_HasCentralFrame;
options = parser.isSet(centralFrame) ? MainWindowOption_HasCentralFrame
: MainWindowOption_None;
if (parser.isSet(noQtTool))
flags |= KDDockWidgets::Config::Flag_internal_DontUseQtToolWindowsForFloatingWindows;
if (parser.isSet(noParentForFloating))
flags |= KDDockWidgets::Config::Flag_internal_DontUseParentForFloatingWindows;
# if defined(Q_OS_WIN)
if (parser.isSet(noAeroSnap))
flags &= ~KDDockWidgets::Config::Flag_AeroSnapWithClientDecos;
# endif
#endif
auto flags = KDDockWidgets::Config::self().flags();
if (parser.isSet(autoHideSupport))
flags |= Config::Flag_AutoHideSupport;
if (parser.isSet(noTitleBars))
flags |= KDDockWidgets::Config::Flag_HideTitleBarWhenTabsVisible | KDDockWidgets::Config::Flag_AlwaysShowTabs;
flags |= KDDockWidgets::Config::Flag_HideTitleBarWhenTabsVisible;
if (parser.isSet(noUtilityWindows))
flags |= KDDockWidgets::Config::Flag_DontUseUtilityFloatingWindows;
if (parser.isSet(alwaysTabs))
flags |= KDDockWidgets::Config::Flag_AlwaysShowTabs;
if (parser.isSet(alwaysTitleBarWhenFloating)) {
flags |= KDDockWidgets::Config::Flag_AlwaysTitleBarWhenFloating;
if (!(flags & KDDockWidgets::Config::Flag_HideTitleBarWhenTabsVisible)) {
qWarning() << "Flag_AlwaysTitleBarWhenFloating is unneeded if Flag_HideTitleBarWhenTabsVisible isn't used."
<< "As floating windows already have title bars by default.";
}
}
if (parser.isSet(customStyle) || qEnvironmentVariableIsSet("KDDW_DEBUG_FOCUS"))
flags |= KDDockWidgets::Config::Flag_TitleBarIsFocusable; // also showing title bar focus with -p, just to not introduce another switch
if (parser.isSet(reorderTabsOption))
flags |= KDDockWidgets::Config::Flag_AllowReorderTabs;
if (parser.isSet(maximizeButtonOption))
flags |= KDDockWidgets::Config::Flag_TitleBarHasMaximizeButton;
if (parser.isSet(minimizeButtonOption))
flags |= KDDockWidgets::Config::Flag_TitleBarHasMinimizeButton;
if (parser.isSet(lazyResizeOption))
flags |= KDDockWidgets::Config::Flag_LazyResize;
@@ -122,20 +204,36 @@ int main(int argc, char **argv)
const bool nonClosableDockWidget0 = parser.isSet(nonClosableDockWidget);
const bool restoreIsRelative = parser.isSet(relativeRestore);
const bool nonDockableDockWidget9 = parser.isSet(nonDockable);
const bool maxSizeForDockWidget8 = parser.isSet(maxSizeOption);
const bool usesMainWindowsWithAffinity = parser.isSet(multipleMainWindows);
MyMainWindow mainWindow(QStringLiteral("MyMainWindow"), options, nonClosableDockWidget0, restoreIsRelative);
#ifdef KDDOCKWIDGETS_SUPPORTS_NESTED_MAINWINDOWS
const bool usesDockableMainWindows = parser.isSet(dockableMainWindows);
#else
const bool usesDockableMainWindows = false;
#endif
MyMainWindow mainWindow(QStringLiteral("MyMainWindow"), options, nonClosableDockWidget0,
nonDockableDockWidget9, restoreIsRelative, maxSizeForDockWidget8);
mainWindow.setWindowTitle("Main Window 1");
mainWindow.resize(1200, 1200);
mainWindow.show();
if (parser.isSet(multipleMainWindows)) {
if (usesMainWindowsWithAffinity) {
if (usesDockableMainWindows) {
qWarning() << "MainWindows with affinity option is incompatible with Dockable Main Windows option";
return 1;
}
// By default a dock widget can dock into any main window.
// By setting an affinity name we can prevent that. Dock widgets of different affinities are incompatible.
const QString affinity = parser.isSet(incompatibleMainWindows) ? QStringLiteral("affinity1")
: QString();
auto mainWindow2 = new MyMainWindow(QStringLiteral("MyMainWindow-2"), options,
nonClosableDockWidget0, restoreIsRelative, affinity);
nonClosableDockWidget0, nonDockableDockWidget9,
restoreIsRelative, maxSizeForDockWidget8, affinity);
if (affinity.isEmpty())
mainWindow2->setWindowTitle("Main Window 2");
else
@@ -143,7 +241,34 @@ int main(int argc, char **argv)
mainWindow2->resize(1200, 1200);
mainWindow2->show();
} else if (usesDockableMainWindows) {
auto mainWindowDockWidget = new DockWidget(QStringLiteral("MyMainWindow-2-DW"));
const QString affinity = QStringLiteral("Inner-DockWidgets-2");
auto dockableMainWindow = new MyMainWindow(QStringLiteral("MyMainWindow-2"), options,
false, false, restoreIsRelative, false, affinity);
dockableMainWindow->setAffinities({ affinity });
dockableMainWindow->setStyleSheet(QStringLiteral("background: yellow"));
dockableMainWindow->setWindowTitle("Dockable Main Window");
dockableMainWindow->show();
mainWindowDockWidget->setWidget(dockableMainWindow);
mainWindowDockWidget->show();
mainWindowDockWidget->resize(800, 800);
}
const QStringList args = parser.positionalArguments();
if (args.size() >= 1) {
const QString sourceJsonFileName = args[0];
KDDockWidgets::LayoutSaver loader;
if (!loader.restoreFromFile(sourceJsonFileName)) {
qWarning() << Q_FUNC_INFO << "Failed to restore from" << sourceJsonFileName;
return 1;
}
}
return app.exec();
}

View File

@@ -0,0 +1,36 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.7)
project(kddockwidgets_minimal_example)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
if(NOT TARGET kddockwidgets)
# This will look for Qt, do find_package yourself manually before
# if you want to look for a specific Qt version for instance.
find_package(KDDockWidgets REQUIRED)
endif()
qt5_add_resources(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../dockwidgets/resources_example.qrc)
add_executable(kddockwidgets_minimal_example
main.cpp
../dockwidgets/MyWidget.cpp
${RESOURCES_EXAMPLE_SRC}
)
target_link_libraries(kddockwidgets_minimal_example
PRIVATE
KDAB::kddockwidgets
)

View File

@@ -0,0 +1,116 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include "MyWidget.h"
#include <QPainter>
#include <QDebug>
#include <QFile>
#include <QLineEdit>
static QHash<QString, QImage> s_images; /// clazy:exclude=non-pod-global-static
MyWidget::MyWidget(const QString &backgroundFile, const QString &logoFile, QWidget *parent)
: QWidget(parent)
{
if (!backgroundFile.isEmpty()) {
auto it = s_images.find(backgroundFile);
if (it == s_images.end())
it = s_images.insert(backgroundFile, QImage(backgroundFile));
m_background = it.value();
}
if (!logoFile.isEmpty()) {
auto it = s_images.find(logoFile);
if (it == s_images.end())
it = s_images.insert(logoFile, QImage(logoFile));
m_logo = it.value();
}
setFocusPolicy(Qt::StrongFocus);
#if 0
// Uncomment to show focus propagation working
new QLineEdit(this);
auto l2 = new QLineEdit(this);
l2->move(0, 100);
setFocusProxy(l2);
#endif
}
MyWidget::~MyWidget()
{
}
void MyWidget::drawLogo(QPainter &p)
{
if (m_logo.isNull())
return;
const qreal ratio = m_logo.height() / (m_logo.width() * 1.0);
const int maxWidth = int(0.80 * size().width());
const int maxHeight = int(0.80 * size().height());
const int proposedHeight = int(maxWidth * ratio);
const int width = proposedHeight <= maxHeight ? maxWidth
: int(maxHeight / ratio);
const int height = int(width * ratio);
QRect targetLogoRect(0,0, width, height);
targetLogoRect.moveCenter(rect().center() + QPoint(0, -int(size().height() * 0.00)));
p.drawImage(targetLogoRect, m_logo, m_logo.rect());
}
MyWidget1::MyWidget1(MyWidget::QWidget *parent)
: MyWidget(QStringLiteral(":/assets/triangles.png"), QStringLiteral(":/assets/KDAB_bubble_white.png"), parent)
{
}
void MyWidget1::paintEvent(QPaintEvent *)
{
QPainter p(this);
p.fillRect(rect(), QColor(0xCC, 0xCC, 0xCC));
p.drawImage(m_background.rect(), m_background, m_background.rect());
drawLogo(p);
}
MyWidget2::MyWidget2(MyWidget::QWidget *parent)
: MyWidget(QString(), QStringLiteral(":/assets/KDAB_bubble_blue.png"), parent)
{
}
void MyWidget2::paintEvent(QPaintEvent *)
{
QPainter p(this);
p.fillRect(rect(), Qt::white);
drawLogo(p);
}
MyWidget3::MyWidget3(MyWidget::QWidget *parent)
: MyWidget(QStringLiteral(":/assets/base.png"), QStringLiteral(":/assets/KDAB_bubble_fulcolor.png"), parent)
, m_triangle(QImage(QStringLiteral(":/assets/tri.png")))
{
}
void MyWidget3::paintEvent(QPaintEvent *)
{
QPainter p(this);
p.fillRect(rect(), QColor(0xD5, 0xD5, 0xD5));
p.drawImage(m_background.rect(), m_background, m_background.rect());
const QRect targetRect = QRect({ width() - m_triangle.width(), height() - m_triangle.height() }, m_triangle.size());
p.drawImage(targetRect, m_triangle, m_triangle.rect());
drawLogo(p);
}

View File

@@ -0,0 +1,62 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#ifndef EXAMPLEDOCKABLEWIDGET_H
#define EXAMPLEDOCKABLEWIDGET_H
#pragma once
#include <QWidget>
QT_BEGIN_NAMESPACE
class QPainter;
QT_END_NAMESPACE
class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget() = default;
explicit MyWidget(const QString &backgroundFile, const QString &logoFile, QWidget *parent = nullptr);
~MyWidget();
protected:
void drawLogo(QPainter &);
QImage m_background;
QImage m_logo;
};
class MyWidget1 : public MyWidget
{
public:
explicit MyWidget1(QWidget *parent = nullptr);
protected:
void paintEvent(QPaintEvent*) override;
};
class MyWidget2 : public MyWidget
{
public:
explicit MyWidget2(QWidget *parent = nullptr);
protected:
void paintEvent(QPaintEvent*) override;
};
class MyWidget3 : public MyWidget
{
public:
explicit MyWidget3(QWidget *parent = nullptr);
protected:
void paintEvent(QPaintEvent*) override;
QImage m_triangle;
};
#endif

74
examples/minimal/main.cpp Normal file
View File

@@ -0,0 +1,74 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include "MyWidget.h"
#include <kddockwidgets/DockWidget.h>
#include <kddockwidgets/MainWindow.h>
#include <QStyleFactory>
// clazy:excludeall=qstring-allocations
using namespace KDDockWidgets;
int main(int argc, char **argv)
{
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QApplication app(argc, argv);
app.setOrganizationName(QStringLiteral("KDAB"));
app.setApplicationName(QStringLiteral("Test app"));
// Fusion looks better in general, but feel free to change
qApp->setStyle(QStyleFactory::create(QStringLiteral("Fusion")));
// # 1. Create our main window
KDDockWidgets::MainWindow mainWindow(QStringLiteral("MyMainWindow"));
mainWindow.setWindowTitle("Main Window");
mainWindow.resize(1200, 1200);
mainWindow.show();
// # 2. Create a dock widget, it needs a unique name
auto dock1 = new KDDockWidgets::DockWidget(QStringLiteral("MyDock1"));
auto widget1 = new MyWidget();
dock1->setWidget(widget1);
auto dock2 = new KDDockWidgets::DockWidget(QStringLiteral("MyDock2"));
auto widget2 = new MyWidget(QStringLiteral(":/assets/base.png"),
QStringLiteral(":/assets/KDAB_bubble_fulcolor.png"));
dock2->setWidget(widget2);
auto dock3 = new KDDockWidgets::DockWidget(QStringLiteral("MyDock3"));
auto widget3 = new MyWidget(QStringLiteral(":/assets/base.png"),
QStringLiteral(":/assets/KDAB_bubble_fulcolor.png"));
dock3->setWidget(widget3);
auto dock4 = new KDDockWidgets::DockWidget(QStringLiteral("MyDock4"));
auto widget4 = new MyWidget(QStringLiteral(":/assets/base.png"),
QStringLiteral(":/assets/KDAB_bubble_fulcolor.png"));
dock4->setWidget(widget4);
// 3. Add them to the main window
mainWindow.addDockWidget(dock1, KDDockWidgets::Location_OnLeft);
mainWindow.addDockWidget(dock2, KDDockWidgets::Location_OnTop);
// 4. Add dock3 to the right of dock2
mainWindow.addDockWidget(dock3, KDDockWidgets::Location_OnRight, dock2);
// 5. dock4 will be its own top level (floating window)
dock4->show();
return app.exec();
}

View File

@@ -0,0 +1,34 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.7)
project(kddockwidgets_example_quick)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
if(NOT TARGET kddockwidgets)
# This will look for Qt, do find_package yourself manually before
# if you want to look for a specific Qt version for instance.
find_package(KDDockWidgets REQUIRED)
endif()
qt5_add_resources(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources_example.qrc)
add_executable(kddockwidgets_example_quick
main.cpp
${RESOURCES_EXAMPLE_SRC}
)
target_link_libraries(kddockwidgets_example_quick
PRIVATE
KDAB::kddockwidgets
)

View File

@@ -0,0 +1,20 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Rectangle {
color: "blue"
anchors.fill: parent
Text {
text: "Guest Widget!"
}
}

View File

@@ -0,0 +1,20 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Rectangle {
color: "lightblue"
anchors.fill: parent
Text {
text: "Guest Widget #1 !"
}
}

View File

@@ -0,0 +1,20 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Rectangle {
color: "pink"
anchors.fill: parent
Text {
text: "Guest Widget #2!"
}
}

View File

@@ -0,0 +1,20 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Rectangle {
color: "gray"
anchors.fill: parent
Text {
text: "Guest Widget #3!"
}
}

54
examples/qtquick/main.cpp Normal file
View File

@@ -0,0 +1,54 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include "private/DockRegistry_p.h"
#include "private/quick/DockWidgetQuick.h"
#include "Config.h"
#include <QQuickView>
#include <QGuiApplication>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQuickView view;
view.setObjectName("MainWindow QQuickView");
KDDockWidgets::Config::self().setQmlEngine(view.engine());
view.resize(1000, 800);
view.show();
view.setResizeMode(QQuickView::SizeRootObjectToView);
auto dw1 = new KDDockWidgets::DockWidgetQuick("Dock #1");
view.setSource(QUrl("qrc:/main.qml"));
dw1->setWidget(QStringLiteral("qrc:/Guest1.qml"));
dw1->resize(QSize(800, 800));
dw1->show();
auto dw2 = new KDDockWidgets::DockWidgetQuick("Dock #2");
dw2->setWidget(QStringLiteral("qrc:/Guest2.qml"));
dw2->resize(QSize(800, 800));
dw2->show();
auto dw3 = new KDDockWidgets::DockWidgetQuick("Dock #3");
dw3->setWidget(QStringLiteral("qrc:/Guest3.qml"));
dw3->resize(QSize(800, 800));
dw3->show();
dw1->addDockWidgetToContainingWindow(dw3, KDDockWidgets::Location_OnRight);
KDDockWidgets::MainWindowBase *mainWindow = KDDockWidgets::DockRegistry::self()->mainwindows().constFirst();
mainWindow->addDockWidget(dw2, KDDockWidgets::Location_OnTop);
return app.exec();
}

23
examples/qtquick/main.qml Normal file
View File

@@ -0,0 +1,23 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sergio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
import com.kdab.dockwidgets 1.0 as KDDW
KDDW.MainWindow {
id: root
Component.onCompleted: {
root.init("MyWindowName-1");
}
}

View File

@@ -0,0 +1,8 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>Guest1.qml</file>
<file>Guest2.qml</file>
<file>Guest3.qml</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

@@ -0,0 +1,320 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="128"
height="128"
viewBox="0 0 33.866665 33.866667"
version="1.1"
id="svg8"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
sodipodi:docname="128x128.svg"
inkscape:export-filename="/home/pinheiro/media/server/kdab/2017/templates/Marketing/Branding/products/kddockwidgets/icons/256x256.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
<defs
id="defs2">
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4182"
id="linearGradient2204"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.51735502,0,0,0.51741082,-2340.918,-1199.7217)"
x1="4533.3271"
y1="2365.7585"
x2="4573.1943"
y2="2342.7412" />
<linearGradient
inkscape:collect="always"
id="linearGradient4182">
<stop
style="stop-color:#04a5e7;stop-opacity:1;"
offset="0"
id="stop4184" />
<stop
style="stop-color:#2982c4;stop-opacity:1"
offset="1"
id="stop4186" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4733"
id="linearGradient2202"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,0.61581147,-0.61574507,0,3061.0284,-1011.6512)"
x1="1710.802"
y1="4975.228"
x2="1652.1422"
y2="4926.0415" />
<linearGradient
id="linearGradient4733"
inkscape:collect="always">
<stop
id="stop4735"
offset="0"
style="stop-color:#1abafb;stop-opacity:1" />
<stop
style="stop-color:#19aff2;stop-opacity:1;"
offset="0.6658641696"
id="stop4739" />
<stop
id="stop4737"
offset="1"
style="stop-color:#187fcb;stop-opacity:1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4733"
id="linearGradient2200"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-0.61581147,-0.61574507,0,3061.0284,1048.8936)"
x1="1710.802"
y1="4975.228"
x2="1652.1422"
y2="4926.0415" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2198"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.22796197,0,0,0.22798656,-1029.3611,-516.35749)"
x1="4620.3696"
y1="2304.967"
x2="4567.6602"
y2="2342.3162" />
<linearGradient
inkscape:collect="always"
id="linearGradient2009">
<stop
style="stop-color:#f5f5f5;stop-opacity:1;"
offset="0"
id="stop2005" />
<stop
style="stop-color:#f5f5f5;stop-opacity:0;"
offset="1"
id="stop2007" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4733"
id="linearGradient2196"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,0.22945621,-0.22945621,0,1158.704,-373.75425)"
x1="1710.802"
y1="4975.228"
x2="1652.1422"
y2="4926.0415" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4733"
id="linearGradient2194"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-0.097279,0.09727896,0,-449.73978,167.5063)"
x1="1632.0477"
y1="4981.3447"
x2="1693.9222"
y2="4946.9316" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2192"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.22945621,0,0,0.22945621,-1030.9526,-524.92857)"
x1="4620.3696"
y1="2304.967"
x2="4539.2959"
y2="2351.7751" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2190"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.23947392,0,0,0.23947399,-1071.1667,-551.60122)"
x1="4620.3696"
y1="2304.967"
x2="4539.2959"
y2="2351.7751" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2188"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,0.22798656,-0.22796197,0,541.76567,-1033.9073)"
x1="4620.3696"
y1="2304.967"
x2="4567.6602"
y2="2342.3162" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2186"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-0.22798656,-0.22796197,0,541.76567,1071.2141)"
x1="4620.3696"
y1="2304.967"
x2="4567.6602"
y2="2342.3162" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2184"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-0.22798656,0.22796197,0,-511.86527,1071.2141)"
x1="4620.3696"
y1="2304.967"
x2="4567.6602"
y2="2342.3162" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1"
inkscape:cx="107.45186"
inkscape:cy="35.577827"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="true"
units="px"
inkscape:showpageshadow="false"
inkscape:snap-global="true"
inkscape:snap-bbox="true"
inkscape:bbox-paths="true"
inkscape:bbox-nodes="true"
inkscape:snap-bbox-edge-midpoints="false"
inkscape:snap-bbox-midpoints="false"
inkscape:snap-nodes="true"
inkscape:snap-others="false"
inkscape:snap-page="true"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0">
<inkscape:grid
type="xygrid"
id="grid319"
originx="-6.9805273e-15"
originy="-6.980528e-15" />
</sodipodi:namedview>
<metadata
id="metadata5">
<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>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="opacity:0.04470928;fill:#050505;stroke:none;stroke-width:0.192438;stroke-linecap:square;paint-order:stroke fill markers;fill-opacity:0.03451458"
id="rect339"
width="33.866665"
height="33.866665"
x="3.4902638e-15"
y="3.4902638e-15" />
<path
id="path2172"
style="opacity:1;fill:url(#linearGradient2194);fill-opacity:1;stroke:#ffffff;stroke-width:0.189129;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
d="M 29.460396,6.7875213 V 2.72324 l 4.064309,4.0642813 z"
sodipodi:nodetypes="cccc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<g
id="g1175"
transform="matrix(1.0177349,0,0,1.0177349,-0.15056408,-0.31430128)"
style="stroke-width:0.982574">
<path
id="path2170"
style="opacity:1;fill:url(#linearGradient2196);fill-opacity:1;stroke:#ffffff;stroke-width:0.185833;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
d="M 28.393217,5.3400577 V 14.926735 L 18.806543,5.3400577 Z"
sodipodi:nodetypes="cccc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
style="fill:none;stroke:url(#linearGradient2192);stroke-width:0.12682;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 28.393217,5.3400577 23.61143,10.122934"
id="path2174"
sodipodi:nodetypes="cc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
</g>
<path
style="fill:none;stroke:url(#linearGradient2190);stroke-width:0.129069;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 31.506974,4.7404732 29.460396,6.7875213"
id="path2176"
sodipodi:nodetypes="cc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<g
id="g1171"
transform="matrix(1.00156,0,0,1.0014514,0.06599202,-0.11494774)"
style="stroke-width:0.9985">
<path
id="path2162"
style="opacity:1;fill:url(#linearGradient2204);fill-opacity:1;stroke:#ffffff;stroke-width:0.187626;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
d="M 2.1413076,5.7567952 H 18.336441 l 9.506012,9.5070378 V 31.46073 H 2.1413076 Z"
sodipodi:nodetypes="cccccc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
id="path2164"
style="opacity:0.404507;fill:url(#linearGradient2202);fill-opacity:1;stroke:none;stroke-width:0.213405;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="M 27.842495,15.26388 V 31.485416 L 2.1166666,5.7568177 H 18.33646 Z"
sodipodi:nodetypes="ccccc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
id="path2166"
style="opacity:0.404507;fill:url(#linearGradient2200);fill-opacity:1;stroke:none;stroke-width:0.213405;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="M 27.842495,31.485416 V 15.26388 L 23.059402,10.539405 2.1166666,31.485416 Z"
sodipodi:nodetypes="ccccc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
style="fill:none;stroke:url(#linearGradient2198);stroke-width:0.128043;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 23.086067,10.514784 -8.135893,8.138618"
id="path2168"
sodipodi:nodetypes="cc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
style="fill:none;stroke:url(#linearGradient2188);stroke-width:0.128043;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 14.950174,18.653402 6.8124322,10.516629"
id="path2178"
sodipodi:nodetypes="cc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
style="fill:none;stroke:url(#linearGradient2186);stroke-width:0.128043;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 14.950174,18.653402 6.8124322,26.790173"
id="path2180"
sodipodi:nodetypes="cc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
style="fill:none;stroke:url(#linearGradient2184);stroke-width:0.128043;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 14.950174,18.653402 8.137738,8.136771"
id="path2182"
sodipodi:nodetypes="cc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@@ -0,0 +1,862 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="301.11804mm"
height="104.09705mm"
viewBox="0 0 1066.9537 368.84777"
id="svg2"
version="1.1"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
sodipodi:docname="kddw.svg"
inkscape:export-filename="/home/pinheiro/media/server/kdab/2017/templates/Marketing/Branding/products/kddockwidgets/kddw.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs4">
<linearGradient
inkscape:collect="always"
id="linearGradient2009">
<stop
style="stop-color:#f5f5f5;stop-opacity:1;"
offset="0"
id="stop2005" />
<stop
style="stop-color:#f5f5f5;stop-opacity:0;"
offset="1"
id="stop2007" />
</linearGradient>
<inkscape:path-effect
pattern-nodetypes="cscscsscssc"
fuse_tolerance="0"
vertical_pattern="true"
prop_units="true"
tang_offset="0"
normal_offset="0"
spacing="0"
scale_y_rel="false"
prop_scale="0.88207218"
copytype="single_stretched"
pattern="m 4206.4067,1373.8314 c 1.1289,-1.7427 2.2338,-2.9184 2.9093,-4.8116 0.4125,-1.156 -0.031,-16.8273 0.6649,-16.8273 0.6422,0 0.2359,15.574 0.6242,16.7092 0.6713,1.9621 1.7981,3.1516 2.95,4.9297 11.1033,14.807 11.2215,45.5151 0,60.2344 -0.7017,0.9204 -1.6243,2.6721 -2.3634,4.5072 -0.7184,1.7837 -1.2634,-18.8714 -1.2634,-17.6169 0,-1.3447 -0.5565,19.2474 -1.2655,17.457 -0.7387,-1.8651 -1.6429,-3.5838 -2.2561,-4.3473 -11.7524,-14.6327 -11.1808,-45.7893 0,-60.2344 z"
is_visible="true"
id="path-effect12719"
effect="skeletal"
lpeversion="0"
hide_knot="false" />
<inkscape:path-effect
effect="skeletal"
id="path-effect12715"
is_visible="true"
pattern="m 4176.4353,1393.8123 c 1.1289,-1.7427 2.2338,-2.9184 2.9093,-4.8116 0.4125,-1.156 -0.031,-16.8273 0.665,-16.8273 0.6421,0 0.2358,15.574 0.6242,16.7092 0.6713,1.9621 1.7981,3.1516 2.95,4.9297 11.1033,14.807 11.2215,45.5151 0,60.2344 -0.7017,0.9204 -1.6244,2.6721 -2.3635,4.5072 -0.7184,1.7837 -1.2633,-18.8714 -1.2633,-17.6169 0,-1.3448 -0.5565,19.2474 -1.2656,17.457 -0.7386,-1.8651 -1.6429,-3.5839 -2.2561,-4.3473 -11.7523,-14.6327 -11.1808,-45.7893 0,-60.2344 z"
copytype="single_stretched"
prop_scale="0.88207218"
scale_y_rel="false"
spacing="0"
normal_offset="0"
tang_offset="0"
prop_units="true"
vertical_pattern="true"
fuse_tolerance="0"
pattern-nodetypes="cscscsscssc"
lpeversion="0"
hide_knot="false" />
<inkscape:path-effect
pattern-nodetypes="cscscsscssc"
fuse_tolerance="0"
vertical_pattern="true"
prop_units="true"
tang_offset="0"
normal_offset="0"
spacing="0"
scale_y_rel="false"
prop_scale="0.88207218"
copytype="single_stretched"
pattern="m 4176.4353,1398.5578 c 1.1289,-1.7428 2.2338,-2.9184 2.9093,-4.8116 0.4125,-1.1561 -0.031,-16.8273 0.665,-16.8273 0.6421,0 0.2358,15.574 0.6242,16.7092 0.6713,1.9621 1.7981,3.1515 2.95,4.9297 11.1033,14.807 11.2215,45.515 0,60.2343 -0.7017,0.9205 -1.6244,2.6722 -2.3635,4.5073 -0.7184,1.7836 -1.2633,-18.8714 -1.2633,-17.617 0,-1.3447 -0.5565,19.2475 -1.2656,17.4571 -0.7386,-1.8652 -1.6429,-3.5839 -2.2561,-4.3474 -11.7523,-14.6327 -11.1808,-45.7892 0,-60.2343 z"
is_visible="true"
id="path-effect12711"
effect="skeletal"
lpeversion="0"
hide_knot="false" />
<inkscape:path-effect
effect="skeletal"
id="path-effect12616"
is_visible="true"
pattern="m 4231.537,1404.0525 c 1.1289,-1.7427 2.2338,-2.9184 2.9093,-4.8116 0.4125,-1.156 -0.031,-16.8273 0.6649,-16.8273 0.6422,0 0.2359,15.574 0.6242,16.7092 0.6713,1.9621 1.7981,3.1516 2.95,4.9297 11.1033,14.807 11.2215,45.5151 0,60.2344 -0.7017,0.9204 -1.6243,2.6721 -2.3634,4.5072 -0.7184,1.7837 -1.2634,-18.8714 -1.2634,-17.6169 0,-1.3447 -0.5565,19.2474 -1.2655,17.457 -0.7387,-1.8651 -1.6429,-3.5838 -2.2561,-4.3473 -11.7524,-14.6327 -11.1808,-45.7893 0,-60.2344 z"
copytype="single_stretched"
prop_scale="0.88207218"
scale_y_rel="false"
spacing="0"
normal_offset="0"
tang_offset="0"
prop_units="true"
vertical_pattern="true"
fuse_tolerance="0"
pattern-nodetypes="cscscsscssc"
lpeversion="0"
hide_knot="false" />
<inkscape:path-effect
effect="ellipse_5pts"
id="path-effect12614"
is_visible="false"
lpeversion="0" />
<linearGradient
inkscape:collect="always"
id="linearGradient1176">
<stop
style="stop-color:#fdc324;stop-opacity:1"
offset="0"
id="stop1170" />
<stop
id="stop1172"
offset="0.8829243779"
style="stop-color:#fb8510;stop-opacity:1" />
<stop
style="stop-color:#fb410e;stop-opacity:1"
offset="1"
id="stop1174" />
</linearGradient>
<linearGradient
inkscape:collect="always"
id="linearGradient4304">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop4306" />
<stop
style="stop-color:#ffffff;stop-opacity:0;"
offset="1"
id="stop4308" />
</linearGradient>
<linearGradient
id="linearGradient5010"
inkscape:collect="always">
<stop
id="stop5012"
offset="0"
style="stop-color:#fdc324;stop-opacity:1" />
<stop
style="stop-color:#fb5010;stop-opacity:1;"
offset="0.8829243779"
id="stop5016" />
<stop
id="stop5014"
offset="1"
style="stop-color:#fb410e;stop-opacity:1" />
</linearGradient>
<linearGradient
id="linearGradient4733"
inkscape:collect="always">
<stop
id="stop4735"
offset="0"
style="stop-color:#1abafb;stop-opacity:1" />
<stop
style="stop-color:#19aff2;stop-opacity:1;"
offset="0.6658641696"
id="stop4739" />
<stop
id="stop4737"
offset="1"
style="stop-color:#187fcb;stop-opacity:1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
id="linearGradient4182">
<stop
style="stop-color:#04a5e7;stop-opacity:1;"
offset="0"
id="stop4184" />
<stop
style="stop-color:#2982c4;stop-opacity:1"
offset="1"
id="stop4186" />
</linearGradient>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath4715">
<circle
transform="rotate(-7.0121541)"
r="21.990837"
cy="535.98236"
cx="166.16179"
id="circle4717"
style="opacity:1;fill:url(#radialGradient4719);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.8;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</clipPath>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient4182"
id="radialGradient4719"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.90375526,-0.01183805,0.01309761,0.99991422,8.8420044,1.9777154)"
cx="163.26299"
cy="524.61469"
fx="163.26299"
fy="524.61469"
r="21.990837" />
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath4857">
<circle
transform="rotate(-7.0121541)"
r="20.994516"
cy="547.18286"
cx="257.22266"
id="circle4859"
style="opacity:1;fill:url(#radialGradient4861);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.8;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</clipPath>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient4733"
id="radialGradient4861"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.85037313,-0.14640233,0.12774601,0.74200851,47.860692,172.55092)"
cx="164.63748"
cy="531.20685"
fx="164.78966"
fy="519.24323"
r="21.990837" />
<filter
inkscape:collect="always"
style="color-interpolation-filters:sRGB"
id="filter5080"
x="-0.16258018"
width="1.3251604"
y="-0.092115037"
height="1.1842301">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="3.753083949"
id="feGaussianBlur5082" />
</filter>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath5086">
<path
style="opacity:1;fill:url(#radialGradient5090);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.8;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="circle5088"
transform="rotate(-7.0121541)"
r="21.2975940704"
cy="547.763061523"
cx="261.940002441"
d="" />
</clipPath>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient5010"
id="radialGradient5090"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.94081295,-0.13201913,0.11519568,0.82092341,44.333431,128.77695)"
cx="164.63748"
cy="531.20685"
fx="165.19966"
fy="522.50458"
r="21.990837" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4304"
id="linearGradient4818"
gradientUnits="userSpaceOnUse"
x1="538.8783"
y1="1254.7184"
x2="538.8783"
y2="1463.9575"
gradientTransform="translate(0,-2501.2316)" />
<mask
maskUnits="userSpaceOnUse"
id="mask4814">
<rect
style="opacity:0.821;fill:url(#linearGradient4818);fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:0.1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4816"
width="534.79858"
height="279.44431"
x="273.93802"
y="-1314.6536"
transform="scale(1,-1)" />
</mask>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1276">
<circle
style="opacity:1;fill:url(#radialGradient1280);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.8;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="circle1278"
cx="440.63205"
cy="722.66998"
r="85.281738"
transform="rotate(-7.0121541)" />
</clipPath>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient1176"
id="radialGradient1280"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(4.6443382,-1.2687174,1.1434364,4.1857275,-939.86166,-1313.7824)"
cx="163.84512"
cy="535.58044"
fx="164.13194"
fy="524.82343"
r="21.990837" />
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1713">
<path
style="opacity:1;fill:url(#radialGradient1717);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.8;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="m 518.8522,558.0521 c -0.82495,-10e-4 -1.65149,0.008 -2.48033,0.0264 -3.44325,0.0774 -6.88048,0.32689 -10.29881,0.7477 -5.92658,0.72912 -17.20559,3.60819 -17.20559,3.60819 l 6.91055,14.03625 c 0,0 8.00571,-1.85496 12.17321,-2.3677 2.90897,-0.35809 5.83402,-0.57046 8.76419,-0.63629 45.14453,-1.01173 82.94959,34.62 86.4993,76.24601 4.23839,49.70191 -36.47733,87.05581 -73.79756,91.14458 -0.12198,-4.28104 75.73972,20.55263 91.79648,-92.08877 -6.37636,-51.85265 -50.39015,-90.64928 -102.36144,-90.7164 z"
id="path1715"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sccccccsccs" />
</clipPath>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient1176"
id="radialGradient1717"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(6.0139763,-1.6118698,1.4523165,5.4215643,-1286.7694,-2022.8268)"
cx="163.84512"
cy="535.58044"
fx="164.13194"
fy="524.82343"
r="21.990837" />
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1545">
<rect
style="opacity:1;fill:#eff0f1;fill-opacity:1;fill-rule:nonzero;stroke:#fcfcfc;stroke-width:1.84406;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect1547"
width="499.94531"
height="626.17499"
x="1503.0391"
y="115.11468" />
</clipPath>
<style
id="current-color-scheme"
type="text/css">
.ColorScheme-Text {
color:#f2f2f2;
}
</style>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath2129">
<rect
style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.91875;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect2131"
width="90.85743"
height="216.4682"
x="-4259.5063"
y="1335.9559"
ry="0.79583901"
transform="scale(-1,1)" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath3852">
<rect
style="opacity:0.547;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#bb0000;stroke-width:1.10063;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect3854"
width="117.72582"
height="199.94704"
x="-5563.061"
y="1545.0594"
ry="0.52556229"
transform="scale(-1,1)" />
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath2142">
<path
style="opacity:0.892;fill:none;fill-opacity:0;fill-rule:nonzero;stroke:#fffafa;stroke-width:0.344063;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.374332;paint-order:markers fill stroke"
d="m 3696.4014,591.63757 v 219.42444 h 177.3285 V 591.63757 Z m 103.6395,111.05164 c 3.718,0 7.1638,0.70279 10.2319,2.15515 a 2.6924666,2.6924666 0 0 1 1.3074,3.53028 l -0.9723,2.18078 a 2.6924666,2.6924666 0 0 1 -3.6639,1.31104 c -2.1746,-1.08732 -4.3873,-1.61133 -6.7621,-1.61133 -3.7727,0 -6.2834,1.07384 -8.2617,3.27759 -1.9791,2.20458 -3.0579,5.25668 -3.0579,9.62951 0,4.51996 1.0495,7.63935 2.8803,9.76502 1.8165,2.10909 4.2427,3.16772 8.0603,3.16772 2.6784,0 5.0788,-0.34226 7.2271,-0.99792 a 2.6924666,2.6924666 0 0 1 3.4772,2.57446 v 2.13318 a 2.6924666,2.6924666 0 0 1 -1.7981,2.53967 c -2.6875,0.94525 -5.8344,1.36231 -9.4757,1.36231 -5.4481,0 -10.197,-1.89711 -13.5095,-5.62134 -3.3288,-3.74252 -4.8761,-8.88316 -4.8761,-14.9707 0,-3.86297 0.736,-7.40293 2.2705,-10.50843 a 2.6924666,2.6924666 0 0 1 0.01,-0.0128 c 1.5539,-3.10779 3.8721,-5.61989 6.8097,-7.33155 2.9591,-1.73083 6.391,-2.57263 10.1074,-2.57263 z m -48.219,0.35706 h 1.5418 a 2.6924666,2.6924666 0 0 1 2.5067,1.70837 l 13.656,34.80286 a 2.6924666,2.6924666 0 0 1 -2.5067,3.67492 h -2.7265 a 2.6924666,2.6924666 0 0 1 -2.5049,-1.70654 l -4.1418,-10.52673 h -10.4169 l -4.1656,10.53222 a 2.6924666,2.6924666 0 0 1 -2.5031,1.70105 h -2.6788 a 2.6924666,2.6924666 0 0 1 -2.4994,-3.69323 l 13.9398,-34.80286 a 2.6924666,2.6924666 0 0 1 2.4994,-1.69006 z m 77.2083,0.14099 h 2.4188 a 2.6924666,2.6924666 0 0 1 2.6916,2.69165 v 11.48437 l 12.7881,-13.34655 a 2.6924666,2.6924666 0 0 1 1.9446,-0.82947 h 3.0835 a 2.6924666,2.6924666 0 0 1 1.9336,4.56482 l -12.6251,13.02429 13.2458,18.17871 a 2.6924666,2.6924666 0 0 1 -2.1753,4.27734 h -2.9645 a 2.6924666,2.6924666 0 0 1 -2.1771,-1.10962 l -11.5594,-15.9082 -1.4942,1.31653 v 13.00964 a 2.6924666,2.6924666 0 0 1 -2.6916,2.69165 h -2.4188 a 2.6924666,2.6924666 0 0 1 -2.6917,-2.69165 v -34.66186 a 2.6924666,2.6924666 0 0 1 2.6917,-2.69165 z m -76.4942,14.30786 -2.3181,5.93994 h 4.5612 z"
id="path2144"
inkscape:connector-curvature="0" />
</clipPath>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4182"
id="linearGradient1962"
x1="4533.3271"
y1="2365.7585"
x2="4573.1943"
y2="2342.7412"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(3.753257,0,0,3.753257,-16367.842,-8500.4241)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4733"
id="linearGradient1977"
gradientUnits="userSpaceOnUse"
x1="1710.802"
y1="4975.228"
x2="1652.1422"
y2="4926.0415"
gradientTransform="matrix(0,1.6537964,-1.6537964,0,8966.582,-2491.3872)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4733"
id="linearGradient1983"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,4.4670474,-4.4670474,0,22821.673,-7136.1767)"
x1="1710.802"
y1="4975.228"
x2="1652.1422"
y2="4926.0415" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4733"
id="linearGradient1987"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-4.4670474,-4.4670474,0,22821.673,7810.8518)"
x1="1710.802"
y1="4975.228"
x2="1652.1422"
y2="4926.0415" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4733"
id="linearGradient1991"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-0.6718043,0.6718042,0,-2481.8694,1362.3567)"
x1="1632.0477"
y1="4981.3447"
x2="1693.9222"
y2="4946.9316" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2011"
x1="4620.3696"
y1="2304.967"
x2="4567.6602"
y2="2342.3162"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.6537964,0,0,1.6537964,-6852.8864,-3543.355)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2016"
gradientUnits="userSpaceOnUse"
x1="4620.3696"
y1="2304.967"
x2="4539.2959"
y2="2351.7751"
gradientTransform="matrix(1.6537964,0,0,1.6537964,-6815.2795,-3580.97)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2024"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.6537964,0,0,1.6537964,-6773.4163,-3603.767)"
x1="4620.3696"
y1="2304.967"
x2="4539.2959"
y2="2351.7751" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2028"
gradientUnits="userSpaceOnUse"
x1="4620.3696"
y1="2304.967"
x2="4567.6602"
y2="2342.3162"
gradientTransform="matrix(0,1.6537964,-1.6537964,0,4545.1713,-7297.62)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2032"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-1.6537964,-1.6537964,0,4545.1714,7972.7634)"
x1="4620.3696"
y1="2304.967"
x2="4567.6602"
y2="2342.3162" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2036"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-1.6537964,1.6537964,0,-3098.608,7972.7634)"
x1="4620.3696"
y1="2304.967"
x2="4567.6602"
y2="2342.3162" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2184"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-2.6306245,2.6306245,0,-4989.2651,12512.226)"
x1="4620.3696"
y1="2304.967"
x2="4567.6602"
y2="2342.3162" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2186"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-2.6306245,-2.6306245,0,7169.374,12512.226)"
x1="4620.3696"
y1="2304.967"
x2="4567.6602"
y2="2342.3162" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2188"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,2.6306245,-2.6306245,0,7169.3738,-11777.732)"
x1="4620.3696"
y1="2304.967"
x2="4567.6602"
y2="2342.3162" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2190"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(2.6306245,0,0,2.6306245,-10834.629,-5902.075)"
x1="4620.3696"
y1="2304.967"
x2="4539.2959"
y2="2351.7751" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2192"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(2.6306245,0,0,2.6306245,-10901.219,-5865.8128)"
x1="4620.3696"
y1="2304.967"
x2="4539.2959"
y2="2351.7751" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4733"
id="linearGradient2194"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-1.0686109,1.0686107,0,-4008.2449,1997.3295)"
x1="1632.0477"
y1="4981.3447"
x2="1693.9222"
y2="4946.9316" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4733"
id="linearGradient2196"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,2.6306245,-2.6306245,0,14202.326,-4132.6592)"
x1="1710.802"
y1="4975.228"
x2="1652.1422"
y2="4926.0415" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2009"
id="linearGradient2198"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(2.6306245,0,0,2.6306245,-10961.038,-5805.9802)"
x1="4620.3696"
y1="2304.967"
x2="4567.6602"
y2="2342.3162" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4733"
id="linearGradient2200"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-7.1055448,-7.1055448,0,36241.038,12254.68)"
x1="1710.802"
y1="4975.228"
x2="1652.1422"
y2="4926.0415" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4733"
id="linearGradient2202"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,7.1055448,-7.1055448,0,36241.038,-11520.931)"
x1="1710.802"
y1="4975.228"
x2="1652.1422"
y2="4926.0415" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4182"
id="linearGradient2204"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(5.9701483,0,0,5.9701483,-26096.079,-13690.983)"
x1="4533.3271"
y1="2365.7585"
x2="4573.1943"
y2="2342.7412" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1"
inkscape:cx="1020.3148"
inkscape:cy="-114.96383"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
showguides="true"
inkscape:guide-bbox="true"
inkscape:window-width="1714"
inkscape:window-height="1203"
inkscape:window-x="552"
inkscape:window-y="164"
inkscape:window-maximized="0"
inkscape:object-nodes="true"
inkscape:snap-global="true"
inkscape:snap-page="false"
inkscape:lockguides="false"
inkscape:document-rotation="0"
fit-margin-top="30"
fit-margin-left="30"
fit-margin-bottom="30"
fit-margin-right="30">
<inkscape:grid
type="xygrid"
id="grid1761"
originx="151.86636"
originy="-166.49869" />
<sodipodi:guide
position="4396.866,-873.03128"
orientation="0,1"
id="guide12660"
inkscape:locked="false" />
<sodipodi:guide
position="4356.202,-851.11722"
orientation="1,0"
id="guide12666"
inkscape:locked="false" />
<sodipodi:guide
position="4387.784,-904.14456"
orientation="0,1"
id="guide12692"
inkscape:locked="false" />
<sodipodi:guide
position="4386.9051,-921.42972"
orientation="1,0"
id="guide12694"
inkscape:locked="false" />
<sodipodi:guide
position="4372.1395,-876.42972"
orientation="1,0"
id="guide12696"
inkscape:locked="false" />
<sodipodi:guide
position="968.67798,222.36216"
orientation="-0.70710678,-0.70710678"
id="guide2114" />
</sodipodi:namedview>
<metadata
id="metadata7">
<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>
<g
inkscape:label="Camada 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(151.86636,-166.4987)">
<path
clip-path="url(#clipPath5086)"
sodipodi:nodetypes="cscssscscccscc"
inkscape:connector-curvature="0"
id="path5279"
d="m 338.65051,492.26754 6.78652,6.38162 c 3.12988,2.94314 3.15859,8.98109 1.39414,16.79863 -2.23777,8.35146 -8.50357,13.53359 -15.111,15.04217 -6.31742,1.44237 -13.30427,-0.34272 -17.90992,-4.61744 -1.44603,-1.34212 -2.21872,-3.81133 -1.67407,-5.84402 0.60965,-2.27523 0.73619,-5.45316 2.06641,-6.24219 -0.76814,0.26722 -1.70405,0.57479 -2.82422,1.63086 -1.88644,1.77848 -1.96369,4.28221 -4.42969,4.97266 0.25165,-7.08965 -4.15819,-10.96822 -4.46346,-14.11351 -2.9188,16.12091 12.65231,34.52007 31.91417,29.35887 12.41302,-3.09834 19.81219,-12.21234 22.25881,-22.50042 1.41285,-5.94104 0.97674,-12.06732 -0.30664,-17.20899 z"
style="opacity:0.656;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.8;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;filter:url(#filter5080)"
transform="translate(0,171.82695)" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.75px;line-height:125%;font-family:'Helvetica Neue LT Std';-inkscape-font-specification:'Helvetica Neue LT Std, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.9375px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="5413.5938"
y="1750.3309"
id="text3551" />
<flowRoot
xml:space="preserve"
id="flowRoot3585"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:20px;line-height:125%;font-family:'Helvetica Neue LT Std';-inkscape-font-specification:'Helvetica Neue LT Std, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"><flowRegion
id="flowRegion3587"><rect
id="rect3589"
width="638"
height="558"
x="7608"
y="2084.51977539" /></flowRegion><flowPara
id="flowPara3591" /></flowRoot>
<flowRoot
xml:space="preserve"
id="flowRoot3593"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:20px;line-height:125%;font-family:'Helvetica Neue LT Std';-inkscape-font-specification:'Helvetica Neue LT Std, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"><flowRegion
id="flowRegion3595"><rect
id="rect3597"
width="1124"
height="944"
x="6470"
y="1612.51965332" /></flowRegion><flowPara
id="flowPara3599" /></flowRoot>
<path
id="rect1131"
style="opacity:1;fill:url(#linearGradient1962);fill-opacity:1;stroke:#ffffff;stroke-width:0.68156246;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
d="m 630.35714,244.02067 h 117.49083 l 68.9633,68.9633 v 117.491 H 630.35714 Z"
sodipodi:nodetypes="cccccc" />
<path
id="path1981"
style="opacity:0.404507;fill:url(#linearGradient1983);fill-opacity:1;stroke:none;stroke-width:0.775215;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="m 816.8116,312.98431 v 117.66976 l -186.63323,-186.63323 117.66977,0 z"
sodipodi:nodetypes="ccccc" />
<path
id="path1985"
style="opacity:0.404507;fill:url(#linearGradient1987);fill-opacity:1;stroke:none;stroke-width:0.775215;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="M 816.8116,430.65407 V 312.98431 L 782.11165,278.71335 630.17837,430.65407 Z"
sodipodi:nodetypes="ccccc" />
<path
style="fill:none;stroke:url(#linearGradient2011);stroke-width:0.46513;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 782.30514,278.53475 -59.0235,59.03688"
id="path2003"
sodipodi:nodetypes="cc" />
<path
id="path1975"
style="opacity:1;fill:url(#linearGradient1977);fill-opacity:1;stroke:#ffffff;stroke-width:0.68156246;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
d="m 819.91214,240.91981 v 69.0956 l -69.09561,-69.0956 z"
sodipodi:nodetypes="cccc" />
<path
id="path1989"
style="opacity:1;fill:url(#linearGradient1991);fill-opacity:1;stroke:#ffffff;stroke-width:0.68156246;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1;paint-order:stroke fill markers;stroke-miterlimit:4;stroke-dasharray:none"
d="m 827.46585,252.44015 v -28.06774 l 28.06807,28.06774 z"
sodipodi:nodetypes="cccc" />
<path
style="fill:none;stroke:url(#linearGradient2016);stroke-width:0.46513;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 819.91214,240.91981 785.44752,275.3922"
id="path2014"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:url(#linearGradient2024);stroke-width:0.46513;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 841.59952,238.30333 -14.13367,14.13682"
id="path2022"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:url(#linearGradient2028);stroke-width:0.46513;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 723.28164,337.57163 -59.03688,-59.0235"
id="path2026"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:url(#linearGradient2032);stroke-width:0.46513;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 723.28164,337.57163 -59.03688,59.0235"
id="path2030"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:url(#linearGradient2036);stroke-width:0.46513;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 723.28164,337.57163 59.0369,59.0235"
id="path2034"
sodipodi:nodetypes="cc" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:93.0993px;line-height:125%;font-family:'Helvetica Neue LT Std';-inkscape-font-specification:'Helvetica Neue LT Std, Normal';text-align:start;letter-spacing:6.17598px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#292929;fill-opacity:1;stroke:none;stroke-width:8.58756px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="-81.289284"
y="449.83054"
id="text2108"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"><tspan
sodipodi:role="line"
id="tspan2106"
x="-81.289284"
y="449.83054"
style="font-style:normal;font-variant:normal;font-weight:300;font-stretch:normal;font-family:'Open Sans';-inkscape-font-specification:'Open Sans Light';letter-spacing:6.17598px;word-spacing:10.7995px;fill:#292929;fill-opacity:1;stroke-width:8.58756px">KDDockWidgets</tspan></text>
<path
id="path2162"
style="opacity:1;fill:url(#linearGradient2204);fill-opacity:1;stroke:#ffffff;stroke-width:1.08414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
d="M 942.24318,218.43936 H 1129.131 l 109.697,109.69702 v 186.888 H 942.24318 Z"
sodipodi:nodetypes="cccccc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
id="path2164"
style="opacity:0.404507;fill:url(#linearGradient2202);fill-opacity:1;stroke:none;stroke-width:1.2331;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="M 1238.8285,328.13692 V 515.30927 L 941.95882,218.43962 h 187.17238 z"
sodipodi:nodetypes="ccccc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
id="path2166"
style="opacity:0.404507;fill:url(#linearGradient2200);fill-opacity:1;stroke:none;stroke-width:1.2331;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="M 1238.8285,515.30927 V 328.13692 l -55.1957,-54.51338 -241.67398,241.68573 z"
sodipodi:nodetypes="ccccc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
style="fill:none;stroke:url(#linearGradient2198);stroke-width:0.739863;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 1183.9405,273.33945 -93.8862,93.90749"
id="path2168"
sodipodi:nodetypes="cc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
id="path2170"
style="opacity:1;fill:url(#linearGradient2196);fill-opacity:1;stroke:#ffffff;stroke-width:1.08414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
d="M 1243.7603,213.50695 V 323.41441 L 1133.8529,213.50695 Z"
sodipodi:nodetypes="cccc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
id="path2172"
style="opacity:1;fill:url(#linearGradient2194);fill-opacity:1;stroke:#ffffff;stroke-width:1.08414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
d="m 1255.7759,231.83187 v -44.64618 l 44.6465,44.64618 z"
sodipodi:nodetypes="cccc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
style="fill:none;stroke:url(#linearGradient2192);stroke-width:0.739863;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 1243.7603,213.50695 -54.8213,54.83378"
id="path2174"
sodipodi:nodetypes="cc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
style="fill:none;stroke:url(#linearGradient2190);stroke-width:0.739863;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 1278.2576,209.34502 -22.4817,22.48685"
id="path2176"
sodipodi:nodetypes="cc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
style="fill:none;stroke:url(#linearGradient2188);stroke-width:0.739863;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 1090.0543,367.24694 -93.90751,-93.8862"
id="path2178"
sodipodi:nodetypes="cc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
style="fill:none;stroke:url(#linearGradient2186);stroke-width:0.739863;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 1090.0543,367.24694 -93.90751,93.8862"
id="path2180"
sodipodi:nodetypes="cc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<path
style="fill:none;stroke:url(#linearGradient2184);stroke-width:0.739863;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 1090.0543,367.24694 93.9075,93.8862"
id="path2182"
sodipodi:nodetypes="cc"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

10
kddockwidgets.dsc Normal file
View File

@@ -0,0 +1,10 @@
Format: 1.0
Source: kddockwidgets
Version: 1.1.0
Binary: kddockwidgets
Maintainer: Allen Winter <allen.winter@kdab.com>
Architecture: any
Build-Depends: debhelper (>=9), cdbs, cmake, qt5-default, qtbase5-dev, libqt5x11extras5-dev
Files:
00000000000000000000000000000000 00000 kddockwidgets-1.1.0.tar.gz

96
kddockwidgets.spec Normal file
View File

@@ -0,0 +1,96 @@
Name: kddockwidgets
Version: 1.1.0
Release: 1
Summary: KDAB's Dock Widget Framework for Qt
Source0: %{name}-%{version}.tar.gz
Source1: %{name}-%{version}.tar.gz.asc
URL: https://github.com/KDAB/KDDockWidgets
Group: System/Libraries
License: GPL-2.0-only OR GPL-3.0-only
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Vendor: Klaralvdalens Datakonsult AB (KDAB)
Packager: Klaralvdalens Datakonsult AB (KDAB) <info@kdab.com>
BuildRequires: cmake
%if %{defined suse_version}
BuildRequires: libqt5-qtbase-devel libqt5-qtx11extras-devel
%endif
%if %{defined fedora}
BuildRequires: gcc-c++ qt5-qtbase-devel qt5-qtx11extras-devel desktop-file-utils
%endif
%if %{defined rhel}
BuildRequires: gcc-c++ qt5-qtbase-devel qt5-qtx11extras-devel desktop-file-utils
%endif
%description
KDDockWidgets is a Qt dock widget library written by KDAB, suitable for replacing
QDockWidget and implementing advanced functionalities missing in Qt, including:
- Nesting dock widgets in a floating window and docking that group back to main window
- Docking to any main window, not only to the parent main window
- Docking to center of main window, or simply removing the concept of "central widget"
- Main window supporting detachable tabs in center widget
- Detaching arbitrary tabs from a tab bar into a dock area
- Exposing inner helper widgets so the user can customize them or provide his own
- Customize tab widgets
- Customize title bars
- Customize window frames
- Custom widget separators
...and much more
Authors:
--------
Klaralvdalens Datakonsult AB (KDAB) <info@kdab.com>
%define debug_package %{nil}
%global __debug_install_post %{nil}
%package devel
Summary: Development files for %{name}
Group: Development/Libraries/C and C++
Requires: %{name} = %{version}
%description devel
This package contains header files and associated tools and libraries to
develop programs using kddockwidgets.
%prep
%autosetup
%build
cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release
%__make %{?_smp_mflags}
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%install
%make_install
%clean
%__rm -rf "%{buildroot}"
%files
%defattr(-,root,root)
%{_prefix}/share/doc/KDDockWidgets
%{_libdir}/libkddockwidgets.so.*
%{_libdir}/libkddockwidgets_multisplitter.so.*
%files devel
%defattr(-,root,root,-)
%{_libdir}/qt5/mkspecs/modules/*
%dir %{_includedir}/kddockwidgets
%{_includedir}/kddockwidgets/*
%dir %{_libdir}/cmake/KDDockWidgets
%{_libdir}/cmake/KDDockWidgets/*
%{_libdir}/libkddockwidgets.so
%{_libdir}/libkddockwidgets_multisplitter.so
%changelog
* Mon Oct 26 2020 Allen Winter <allen.winter@kdab.com> 1.1.0
1.1.0 final
* Wed Sep 02 2020 Allen Winter <allen.winter@kdab.com> 1.0.0
1.0.0 final
* Thu Aug 06 2020 Allen Winter <allen.winter@kdab.com> 0.99.9
1.0.0 release candidate

18
python/CMakeLists.txt Normal file
View File

@@ -0,0 +1,18 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
set(PYTHON_VERSION "3.7" CACHE STRING "Use specific python version to build the project.")
find_package(Python3 ${PYTHON_VERSION} REQUIRED COMPONENTS Interpreter Development)
find_package(Shiboken2 REQUIRED)
find_package(PySide2 ${Qt5Widgets_VERSION} EXACT REQUIRED)
include(PySide2ModuleBuild)
add_subdirectory(PyKDDockWidgets)

View File

@@ -0,0 +1,81 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
# Auto-Genereate files every class will have his cpp/h files
set(PyKDDockWidgets_SRC
# individual classes
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_dockwidgetbase_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_dockwidgetbase_wrapper.h
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_dockwidget_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_dockwidget_wrapper.h
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_mainwindowbase_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_mainwindowbase_wrapper.h
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_mainwindow_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_mainwindow_wrapper.h
# namespace wrapper
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_wrapper.h
# global module wrapper
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_module_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets/kddockwidgets_python.h
)
# includes necessary to parse and build the classes specified on typesystem
set(PyKDDockWidgets_include_paths
$<JOIN:$<TARGET_PROPERTY:KDAB::kddockwidgets,INTERFACE_INCLUDE_DIRECTORIES>,${PATH_SEP}>
)
# A list of paths where shiboken should look for typesystem
set(PyKDDockWidgets_typesystem_paths
# PySide path, this variable was exposed by FindPySide2.cmake
${PYSIDE_TYPESYSTEMS}
)
# Include flags/path that will be set in 'target_include_directories'
set(PyKDDockWidgets_target_include_directories
${CMAKE_SOURCE_DIR}
)
# Libraries that will be necessary to link the target, this will used in the command 'target_link_libraries'
set(PyKDDockWidgets_target_link_libraries
KDAB::kddockwidgets
Qt5::Core
Qt5::Gui
Qt5::Widgets
)
# changes on these files should trigger a new generation
set(PyKDDockWidgets_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/kddockwidgets_global.h
${CMAKE_SOURCE_DIR}/src/DockWidgetBase.h
${CMAKE_SOURCE_DIR}/src/DockWidget.h
${CMAKE_SOURCE_DIR}/src/MainWindowBase.h
${CMAKE_SOURCE_DIR}/src/MainWindow.h
)
create_python_bindings(
"KDDockWidgets"
"${PyKDDockWidgets_typesystem_paths}"
"${PyKDDockWidgets_include_paths}"
"${PyKDDockWidgets_SRC}"
"${PyKDDockWidgets_target_include_directories}"
"${PyKDDockWidgets_target_link_libraries}"
${CMAKE_CURRENT_SOURCE_DIR}/kddockwidgets_global.h
${CMAKE_CURRENT_SOURCE_DIR}/typesystem_kddockwidgets.xml
"${PyKDDockWidgets_DEPENDS}"
${CMAKE_CURRENT_BINARY_DIR}
)
# Make module import from build dir work
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${CMAKE_CURRENT_BINARY_DIR}/__init__.py)
# install
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py DESTINATION ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}/PyKDDockWidgets)

View File

@@ -0,0 +1,25 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
__all__ = ['KDDockWidgets']
# Preload PySide2 libraries to avoid missing libraries while loading KDDockWidgets
try:
from PySide2 import QtCore
except Exception:
print("Failed to load PySide")
raise
# avoid duplicate namespace, due the PYSIDE-1325 bug I will have my package like this
# PyKDDockWidgets.KDDockWidgets.KDDockWidgets.MainWindow
# To avoid this I add a WORKAROUND to reduce it
from .KDDockWidgets import KDDockWidgets as _priv
KDDockWidgets = _priv

View File

@@ -0,0 +1,24 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#pragma once
// Make "signals:", "slots:" visible as access specifiers
#define QT_ANNOTATE_ACCESS_SPECIFIER(a) __attribute__((annotate(#a)))
// Define PYTHON_BINDINGS this will be used in some part of c++ to skip problematic parts
#define PYTHON_BINDINGS
#include <MainWindowBase.h>
#include <MainWindow.h>
#include <DockWidgetBase.h>
#include <DockWidget.h>

View File

@@ -0,0 +1,44 @@
<?xml version="1.0"?>
<!-- The package name -->
<typesystem package="KDDockWidgets">
<!-- Pre-defined typesystem that contains types used by our class
PySide has one typesystem for each module, here we use only the widgets
typesystem because it already include gui and core typesystem -->
<load-typesystem name="typesystem_widgets.xml" generate="no"/>
<!-- Our classes are declared in a namespace, so we should define this -->
<namespace-type name="KDDockWidgets">
<!-- this is used in a public virtual pure function we need to declare it
otherwise shiboken will ignore the function and will fail to create a wrapper -->
<primitive-type name="DropAreaWithCentralFrame"/>
<primitive-type name="SideBar"/>
<!-- Some plublic enum and flags -->
<enum-type name="Location"/>
<enum-type name="MainWindowOption" flags="MainWindowOptions"/>
<enum-type name="AddingOption"/>
<enum-type name="RestoreOption" flags="RestoreOptions"/>
<enum-type name="DefaultSizeMode"/>
<enum-type name="FrameOption" flags="FrameOptions"/>
<enum-type name="DropIndicatorType"/>
<enum-type name="SideBarLocation"/>
<enum-type name="TitleBarButtonType"/>
<!-- our classes
For class we can use two types:
object-type: class that does not have a copy-contructor and can not be passed as value to functions;
value-type: class that can be passed as value for functions
Here we only use 'object-type' since all our classes are derived from QWidget
-->
<object-type name="MainWindowBase" />
<object-type name="MainWindow" />
<object-type name="DockWidgetBase" >
<!-- this class contains a internal enum, so it should be declared
inside of the object-type -->
<enum-type name="Option" flags="Options" />
<enum-type name="IconPlace" flags="IconPlaces" />
</object-type>
<object-type name="DockWidget" />
</namespace-type>
</typesystem>

View File

@@ -0,0 +1,161 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
from PySide2 import QtCore, QtWidgets, QtGui
from PyKDDockWidgets import KDDockWidgets
from MyWidget1 import MyWidget1
from MyWidget2 import MyWidget2
from MyWidget3 import MyWidget3
def newMyWidget(parent = None):
randomNumber = QtCore.QRandomGenerator.global_().bounded(0, 100) + 1
if (randomNumber < 50):
if (randomNumber < 33):
return MyWidget1(parent)
else:
return MyWidget3(parent)
else:
return MyWidget2(parent)
class MyMainWindow(KDDockWidgets.MainWindow):
s_count = 0
s_menuCount = 0
def __init__(self, uniqueName, options = KDDockWidgets.MainWindowOption_None, dockWidget0IsNonClosable = False, nonDockableDockWidget9 = False, restoreIsRelative = False, maxSizeForDockWidget8 = False, affinityName = "", parent = None):
super().__init__(uniqueName, options, parent)
self.m_dockWidget0IsNonClosable = dockWidget0IsNonClosable
self.m_dockWidget9IsNonDockable = nonDockableDockWidget9
self.m_restoreIsRelative = restoreIsRelative
self.m_maxSizeForDockWidget8 = maxSizeForDockWidget8
self.m_dockwidgets = []
menubar = self.menuBar()
fileMenu = QtWidgets.QMenu("File")
self.m_toggleMenu = QtWidgets.QMenu("Toggle")
menubar.addMenu(fileMenu)
menubar.addMenu(self.m_toggleMenu)
newAction = fileMenu.addAction("New DockWidget")
newAction.triggered.connect(self._newDockWidget)
saveLayoutAction = fileMenu.addAction("Save Layout")
saveLayoutAction.triggered.connect(self._saveLayout)
restoreLayoutAction = fileMenu.addAction("Restore Layout")
restoreLayoutAction.triggered.connect(self._restoreLayout)
closeAllAction = fileMenu.addAction("Close All")
closeAllAction.triggered.connect(self._closeAll)
layoutEqually = fileMenu.addAction("Layout Equally")
layoutEqually.triggered.connect(self.layoutEqually)
quitAction = fileMenu.addAction("Quit")
quitAction.triggered.connect(QtWidgets.QApplication.instance().quit)
self.setAffinities([ affinityName ])
self.createDockWidgets()
def _newDockWidget(self):
MyMainWindow.s_menuCount += 1
w = newMyWidget(self)
w.setGeometry(100, 100, 400, 400)
dock = KDDockWidgets.DockWidget("new dock %d"%(MyMainWindow.s_menuCount))
dock.setWidget(w)
dock.resize(600, 600)
dock.show()
self.m_dockwidgets.append(dock)
def _saveLayout(self):
#saver = KDDockWidgets.LayoutSaver()
#result = saver.saveToFile("mylayout.json")
#print("Saving layout to disk. Result=", result)
print("Not available")
def _restoreLayout(self):
#options = KDDockWidgets.RestoreOption_None
#if self.m_restoreIsRelative:
# options |= KDDockWidgets.RestoreOption_RelativeToMainWindow
#saver = KDDockWidgets.LayoutSaver(options)
#saver.restoreFromFile("mylayout.json")
print("Not available")
def _closeAll(self):
for dw in self.m_dockwidgets:
dw.close()
def createDockWidgets(self):
if self.m_dockWidget9IsNonDockable:
numDockWidgets = 10
else:
numDockWidgets = 9
# numDockWidgets = 2
# Create 9 KDDockWidget::DockWidget and the respective widgets they're hosting (MyWidget instances)
for i in range(numDockWidgets):
self.m_dockwidgets.append(self.newDockWidget())
# MainWindow::addDockWidget() attaches a dock widget to the main window:
self.addDockWidget(self.m_dockwidgets[0], KDDockWidgets.Location_OnTop)
# Here, for finer granularity we specify right of dockwidgets[0]:
self.addDockWidget(self.m_dockwidgets[1], KDDockWidgets.Location_OnRight, self.m_dockwidgets[0])
self.addDockWidget(self.m_dockwidgets[2], KDDockWidgets.Location_OnLeft)
self.addDockWidget(self.m_dockwidgets[3], KDDockWidgets.Location_OnBottom)
self.addDockWidget(self.m_dockwidgets[4], KDDockWidgets.Location_OnBottom)
# Tab two dock widgets together
self.m_dockwidgets[3].addDockWidgetAsTab(self.m_dockwidgets[5])
# 6 is floating, as it wasn't added to the main window via MainWindow::addDockWidget().
# and we tab 7 with it.
self.m_dockwidgets[6].addDockWidgetAsTab(self.m_dockwidgets[7])
# Floating windows also support nesting, here we add 8 to the bottom of the group
self.m_dockwidgets[6].addDockWidgetToContainingWindow(self.m_dockwidgets[8], KDDockWidgets.Location_OnBottom)
floatingWindow = self.m_dockwidgets[6].window()
floatingWindow.move(100, 100)
def newDockWidget(self):
# Passing options is optional, we just want to illustrate Option_NotClosable here
options = KDDockWidgets.DockWidget.Option_None
if (MyMainWindow.s_count == 0) and self.m_dockWidget0IsNonClosable:
options |= KDDockWidgets.DockWidget.Option_NotClosable
if (MyMainWindow.s_count == 9) and self.m_dockWidget9IsNonDockable:
options |= KDDockWidgets.DockWidget.Option_NotDockable
dock = KDDockWidgets.DockWidget("DockWidget #%d"%(MyMainWindow.s_count), options)
dock.setAffinities(self.affinities()); # optional, just to show the feature. Pass -mi to the example to see incompatible dock widgets
if MyMainWindow.s_count == 1:
dock.setIcon(QtGui.QIcon.fromTheme("mail-message"))
myWidget = newMyWidget(self)
if (MyMainWindow.s_count == 8) and self.m_maxSizeForDockWidget8:
# Set a maximum size on dock #8
myWidget.setMaximumSize(200, 200)
dock.setWidget(myWidget)
if dock.options() & KDDockWidgets.DockWidget.Option_NotDockable:
dock.setTitle("DockWidget #%d (%s)" %(MyMainWindow.s_count, "non dockable"))
else:
dock.setTitle("DockWidget #%d"%(MyMainWindow.s_count))
dock.resize(600, 600)
self.m_toggleMenu.addAction(dock.toggleAction())
MyMainWindow.s_count += 1
return dock

View File

@@ -0,0 +1,49 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
from PySide2 import QtWidgets, QtGui, QtCore
class MyWidget(QtWidgets.QWidget):
s_images = {}
def __init__(self, backgroundFile, logoFile, parent = None):
super().__init__(parent)
self.m_background = self._lookupImage(backgroundFile)
self.m_logo = self._lookupImage(logoFile)
def _lookupImage(self, imageName):
if imageName == "":
return None
if imageName not in MyWidget.s_images:
MyWidget.s_images[imageName] = QtGui.QImage(imageName)
return MyWidget.s_images[imageName]
def drawLogo(self, p):
if not self.m_logo:
return
ratio = self.m_logo.height() / (self.m_logo.width() * 1.0)
maxWidth = int(0.80 * self.size().width())
maxHeight = int(0.80 * self.size().height())
proposedHeight = int(maxWidth * ratio)
if (proposedHeight <= maxHeight):
width = maxWidth
else:
width = int(maxHeight / ratio)
height = int(width * ratio)
targetLogoRect = QtCore.QRect(0,0, width, height)
targetLogoRect.moveCenter(self.rect().center() + QtCore.QPoint(0, -int(self.size().height() * 0.00)))
p.drawImage(targetLogoRect, self.m_logo, self.m_logo.rect());

View File

@@ -0,0 +1,27 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
from PySide2 import QtWidgets, QtGui
from MyWidget import MyWidget
class MyWidget1(MyWidget):
def __init__(self, parent = None):
super().__init__(":/assets/triangles.png", ":/assets/KDAB_bubble_white.png", parent)
def paintEvent(self, ev):
p = QtGui.QPainter(self)
p.fillRect(self.rect(), QtGui.QColor(0xCC, 0xCC, 0xCC))
p.drawImage(self.m_background.rect(), self.m_background, self.m_background.rect())
self.drawLogo(p)

View File

@@ -0,0 +1,25 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
from PySide2 import QtWidgets, QtGui, QtCore
from MyWidget import MyWidget
class MyWidget2(MyWidget):
def __init__(self, parent = None):
super().__init__("", ":/assets/KDAB_bubble_blue.png", parent)
def paintEvent(self, ev):
p = QtGui.QPainter(self)
p.fillRect(self.rect(), QtCore.Qt.white);
self.drawLogo(p)

View File

@@ -0,0 +1,30 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
from PySide2 import QtWidgets, QtGui, QtCore
from MyWidget import MyWidget
class MyWidget3(MyWidget):
def __init__(self, parent = None):
super().__init__(":/assets/base.png", ":/assets/KDAB_bubble_fulcolor.png", parent)
self.m_triangle = QtGui.QImage(":/assets/tri.png")
def paintEvent(self, ev):
p = QtGui.QPainter(self)
p.fillRect(self.rect(), QtGui.QColor(0xD5, 0xD5, 0xD5))
p.drawImage(self.m_background.rect(), self.m_background, self.m_background.rect())
targetRect = QtCore.QRect(QtCore.QPoint(self.width() - self.m_triangle.width(), self.height() - self.m_triangle.height()), self.m_triangle.size())
self.drawLogo(p)

View File

@@ -0,0 +1,8 @@
Running python example
======================
Generate resource file with:
~# rcc -g python -o rc_assets.py ../../examples/dockwidgets/resources_example.qrc
Run the app:
~# python3 main.py

35
python/examples/main.py Normal file
View File

@@ -0,0 +1,35 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
from PySide2 import QtWidgets, QtCore
from PyKDDockWidgets import KDDockWidgets
from MyMainWindow import MyMainWindow
import sys
import rc_assets
if __name__ == "__main__":
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
app = QtWidgets.QApplication(sys.argv)
app.setOrganizationName("KDAB")
app.setApplicationName("Test app")
app.setStyle(QtWidgets.QStyleFactory.create("Fusion"))
mainWindow = MyMainWindow("MyMainWindow", )
mainWindow.setWindowTitle("Main Window 1")
mainWindow.resize(1200, 1200)
mainWindow.show()
app.exec_()

View File

@@ -1,43 +1,43 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_policy(SET CMP0043 NEW)
if(POLICY CMP0043)
cmake_policy(SET CMP0043 NEW)
endif()
add_definitions(-DQT_NO_CAST_TO_ASCII
-DQT_NO_CAST_FROM_ASCII
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_CAST_FROM_BYTEARRAY
-DQT_NO_SIGNALS_SLOTS_KEYWORDS
add_definitions(-DQT_NO_SIGNALS_SLOTS_KEYWORDS
-DQT_USE_QSTRINGBUILDER
-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT
-DQT_STRICT_ITERATORS
-DQT_NO_KEYWORDS
-DQT_DISABLE_DEPRECATED_BEFORE=0x060000
-DQT_NO_FOREACH
)
)
set(DOCKSLIBS_SRCS
Config.cpp
Qt5Qt6Compat_p.h
FocusScope.cpp
FrameworkWidgetFactory.cpp
DockWidgetBase.cpp
MainWindow.cpp
MainWindowBase.cpp
LayoutSaver.cpp
private/LastPosition.cpp
private/MultiSplitter.cpp
private/Position.cpp
private/ObjectViewer.cpp
private/DropIndicatorOverlayInterface.cpp
private/indicators/ClassicIndicators.cpp
private/indicators/AnimatedIndicators.cpp
private/DropArea.cpp
private/multisplitter/Item.cpp
private/multisplitter/MultiSplitter.cpp
private/multisplitter/Anchor.cpp
private/multisplitter/AnchorGroup.cpp
private/multisplitter/Separator.cpp
private/multisplitter/MultiSplitterLayout.cpp
private/TabWidget.cpp
private/FloatingWindow.cpp
private/Logging.cpp
private/TitleBar.cpp
private/DebugWindow.cpp
private/SideBar.cpp
private/DockRegistry.cpp
private/Draggable.cpp
private/WindowBeingDragged.cpp
@@ -45,7 +45,9 @@ set(DOCKSLIBS_SRCS
private/Frame.cpp
private/DropAreaWithCentralFrame.cpp
private/WidgetResizeHandler.cpp
)
private/indicators/ClassicIndicators.cpp
private/indicators/ClassicIndicatorsWindow.cpp
)
set(DOCKS_INSTALLABLE_INCLUDES
docks_export.h
@@ -53,130 +55,193 @@ set(DOCKS_INSTALLABLE_INCLUDES
FrameworkWidgetFactory.h
DockWidgetBase.h
KDDockWidgets.h
FocusScope.h
QWidgetAdapter.h
LayoutSaver.h
LayoutSaver_p.h
)
)
set(DOCKS_INSTALLABLE_PRIVATE_INCLUDES
private/DragController_p.h
private/Draggable_p.h
private/DropIndicatorOverlayInterface_p.h
private/FloatingWindow_p.h
private/Frame_p.h
private/TabWidget_p.h
private/SideBar_p.h
private/TitleBar_p.h
)
private/WindowBeingDragged_p.h
)
set(DOCKS_INSTALLABLE_PRIVATE_WIDGET_INCLUDES
private/widgets/QWidgetAdapter_widgets_p.h
private/widgets/TitleBarWidget_p.h
private/widgets/SeparatorWidget_p.h
private/widgets/FloatingWindowWidget_p.h
private/widgets/SideBarWidget_p.h
private/widgets/FloatingWindowWidget_p.h
private/widgets/FrameWidget_p.h
private/widgets/TabBarWidget_p.h
private/widgets/TabWidgetWidget_p.h
private/widgets/TabWidget_p.h
)
if (OPTION_QTQUICK)
set(DOCKSLIBS_SRCS ${DOCKSLIBS_SRCS}
private/quick/DockWidgetQuick.cpp
private/quick/QWidgetAdapter_quick.cpp
private/quick/FloatingWindowQuick.cpp
private/quick/TitleBarQuick.cpp
private/quick/QmlTypes.cpp
private/quick/TabWidgetQuick.cpp
private/quick/FrameQuick.cpp
private/quick/MainWindowQuick.cpp
private/quick/TabBarQuick.cpp
private/quick/SeparatorQuick.cpp
private/quick/LayoutSaverQuick.cpp)
if(${PROJECT_NAME}_QTQUICK)
set(DOCKSLIBS_SRCS ${DOCKSLIBS_SRCS}
private/quick/DockWidgetQuick.cpp
private/quick/QWidgetAdapter_quick.cpp
private/quick/FloatingWindowQuick.cpp
private/quick/TitleBarQuick.cpp
private/quick/QmlTypes.cpp
private/quick/FrameQuick.cpp
private/quick/MainWindowQuick.cpp
private/quick/MainWindowWrapper.cpp
)
qt5_add_resources(RESOURCES_QUICK ${CMAKE_CURRENT_SOURCE_DIR}/qtquick.qrc)
else()
set(DOCKSLIBS_SRCS ${DOCKSLIBS_SRCS}
private/widgets/SeparatorWidget.cpp
private/widgets/TabBarWidget.cpp
private/widgets/FloatingWindowWidget.cpp
private/widgets/FrameWidget.cpp
private/widgets/TabWidgetWidget.cpp
private/widgets/TitleBarWidget.cpp
private/widgets/DockWidget.cpp
private/widgets/QWidgetAdapter_widgets.cpp
)
set(DOCKSLIBS_SRCS ${DOCKSLIBS_SRCS}
private/DebugWindow.cpp
MainWindow.cpp
private/widgets/TabWidget.cpp
private/widgets/TabBarWidget.cpp
private/widgets/FloatingWindowWidget.cpp
private/widgets/FrameWidget.cpp
private/widgets/SideBarWidget.cpp
private/widgets/TabWidgetWidget.cpp
private/widgets/TitleBarWidget.cpp
private/widgets/DockWidget.cpp
private/widgets/QWidgetAdapter_widgets.cpp
private/indicators/SegmentedIndicators.cpp
# private/indicators/AnimatedIndicators.cpp
)
set(DOCKS_INSTALLABLE_INCLUDES
${DOCKS_INSTALLABLE_INCLUDES}
MainWindow.h
MainWindowBase.h
DockWidget.h)
set(DOCKS_INSTALLABLE_INCLUDES
${DOCKS_INSTALLABLE_INCLUDES}
MainWindow.h
MainWindowBase.h
DockWidget.h
)
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(IS_CLANG_BUILD TRUE)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(IS_CLANG_BUILD TRUE)
else()
set(IS_CLANG_BUILD FALSE)
set(IS_CLANG_BUILD FALSE)
endif()
add_subdirectory(private/multisplitter)
qt5_add_resources(RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/resources.qrc)
add_library(kddockwidgets SHARED ${DOCKSLIBS_SRCS} ${DOCKS_INSTALLABLE_INCLUDES} ${RESOURCES} ${RESOURCES_QUICK})
add_library(kddockwidgets ${KDDockWidgets_LIBRARY_MODE} ${DOCKSLIBS_SRCS} ${DOCKS_INSTALLABLE_INCLUDES} ${RESOURCES} ${RESOURCES_QUICK})
add_library(KDAB::kddockwidgets ALIAS kddockwidgets)
set_compiler_flags(kddockwidgets)
target_include_directories(kddockwidgets
PUBLIC
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:include/kddockwidgets>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/private
PUBLIC
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:include/kddockwidgets>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/fwd_headers>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/private
)
target_compile_definitions(kddockwidgets PRIVATE BUILDING_DOCKS_LIBRARY)
if (CMAKE_COMPILER_IS_GNUCXX OR IS_CLANG_BUILD)
target_compile_options(kddockwidgets PRIVATE -Wshadow -Wconversion -fvisibility=hidden)
if (IS_CLANG_BUILD)
target_compile_options(kddockwidgets PRIVATE -Wweak-vtables)
endif()
endif()
if (OPTION_QTQUICK)
target_link_libraries(kddockwidgets Qt5::Widgets Qt5::Quick)
target_compile_definitions(kddockwidgets
PRIVATE
QT_NO_CAST_TO_ASCII
QT_NO_CAST_FROM_ASCII
QT_NO_URL_CAST_FROM_STRING
QT_NO_CAST_FROM_BYTEARRAY
)
if(${PROJECT_NAME}_STATIC)
target_compile_definitions(kddockwidgets PUBLIC KDDOCKWIDGETS_STATICLIB)
else()
target_link_libraries(kddockwidgets Qt5::Widgets)
target_compile_definitions(kddockwidgets PRIVATE BUILDING_DOCKS_LIBRARY)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR IS_CLANG_BUILD)
target_compile_options(kddockwidgets PRIVATE -Wshadow -Wconversion -fvisibility=hidden)
if (NOT WIN32 AND NOT APPLE)
if(IS_CLANG_BUILD)
target_compile_options(kddockwidgets PRIVATE -Wweak-vtables)
endif()
endif()
if(${PROJECT_NAME}_QTQUICK)
target_link_libraries(kddockwidgets PUBLIC Qt5::Widgets Qt5::Quick Qt5::QuickControls2 kddockwidgets_multisplitter)
else()
target_link_libraries(kddockwidgets PUBLIC Qt5::Widgets kddockwidgets_multisplitter)
endif()
if (WIN32)
target_link_libraries(kddockwidgets PRIVATE Qt5::GuiPrivate Dwmapi)
elseif(NOT APPLE)
find_package(Qt5X11Extras)
target_link_libraries(kddockwidgets Qt5::X11Extras)
target_link_libraries(kddockwidgets PUBLIC Qt5::X11Extras)
endif()
install (TARGETS kddockwidgets
EXPORT kddockwidgetsTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install (FILES ${DOCKS_INSTALLABLE_INCLUDES} DESTINATION include/kddockwidgets)
install (FILES ${DOCKS_INSTALLABLE_PRIVATE_INCLUDES} DESTINATION include/kddockwidgets/private)
install (FILES ${DOCKS_INSTALLABLE_PRIVATE_WIDGET_INCLUDES} DESTINATION include/kddockwidgets/private/widgets)
set_target_properties(kddockwidgets PROPERTIES
SOVERSION ${${PROJECT_NAME}_SOVERSION}
VERSION ${${PROJECT_NAME}_VERSION}
)
#version libraries on Windows
if(WIN32)
set(postfix ${${PROJECT_NAME}_VERSION_MAJOR})
set(CMAKE_RELEASE_POSTFIX ${postfix})
set_target_properties(kddockwidgets PROPERTIES RELEASE_POSTFIX ${CMAKE_RELEASE_POSTFIX})
#append 'd' to debug libraries
string(CONCAT postfix ${postfix} "d")
set(CMAKE_DEBUG_POSTFIX ${postfix})
set_target_properties(kddockwidgets PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
endif()
install(TARGETS kddockwidgets
EXPORT kddockwidgetsTargets
RUNTIME DESTINATION ${INSTALL_RUNTIME_DIR}
LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}
ARCHIVE DESTINATION ${INSTALL_ARCHIVE_DIR}
)
if(MSVC AND NOT ${PROJECT_NAME}_STATIC)
install(FILES "$<TARGET_PDB_FILE_DIR:kddockwidgets>/$<TARGET_PDB_FILE_NAME:kddockwidgets>" DESTINATION ${INSTALL_LIBRARY_DIR} CONFIGURATIONS Debug RelWithDebInfo)
endif()
install(FILES ${DOCKS_INSTALLABLE_INCLUDES} DESTINATION include/kddockwidgets)
install(FILES ${DOCKS_INSTALLABLE_PRIVATE_INCLUDES} DESTINATION include/kddockwidgets/private)
install(FILES private/multisplitter/Item_p.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/Widget.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/Widget_qwidget.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/Separator_p.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/Separator_qwidget.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/multisplitter_export.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES ${DOCKS_INSTALLABLE_PRIVATE_WIDGET_INCLUDES} DESTINATION include/kddockwidgets/private/widgets)
install(FILES private/indicators/ClassicIndicators_p.h DESTINATION include/kddockwidgets/private/indicators)
install(FILES private/indicators/SegmentedIndicators_p.h DESTINATION include/kddockwidgets/private/indicators)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
KDDockWidgetsConfigVersion.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion
)
KDDockWidgetsConfigVersion.cmake
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(EXPORT kddockwidgetsTargets
FILE KDDockWidgetsTargets.cmake
NAMESPACE KDAB::
DESTINATION lib/cmake/KDDockWidgets
DESTINATION ${INSTALL_LIBRARY_DIR}/cmake/KDDockWidgets
)
configure_file(KDDockWidgetsConfig.cmake.in KDDockWidgetsConfig.cmake @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgetsConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgetsConfigVersion.cmake"
DESTINATION lib/cmake/KDDockWidgets
DESTINATION ${INSTALL_LIBRARY_DIR}/cmake/KDDockWidgets
)
if(${PROJECT_NAME}_DEVELOPER_MODE)
# Under developer mode since kddw might be a sub-folder of a project setting a different value for QT_DISABLE_DEPRECATED_BEFORE
target_compile_definitions(kddockwidgets PRIVATE QT_DISABLE_DEPRECATED_BEFORE=0x060000)
if (NOT ${PROJECT_NAME}_QTQUICK) # TODO: We can support it
add_executable(kddockwidgets_linter layoutlinter_main.cpp)
target_link_libraries(kddockwidgets_linter kddockwidgets kddockwidgets_multisplitter Qt5::Widgets)
endif()
endif()

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
/**
@@ -26,6 +17,8 @@
*/
#include "Config.h"
#include "multisplitter/MultiSplitterConfig.h"
#include "multisplitter/Widget_qwidget.h"
#include "DockRegistry_p.h"
#include "FrameworkWidgetFactory.h"
@@ -33,7 +26,8 @@
#include <QDebug>
#include <QOperatingSystemVersion>
using namespace KDDockWidgets;
namespace KDDockWidgets
{
class Config::Private
{
@@ -52,21 +46,24 @@ public:
QQmlEngine *m_qmlEngine = nullptr;
DockWidgetFactoryFunc m_dockWidgetFactoryFunc = nullptr;
MainWindowFactoryFunc m_mainWindowFactoryFunc = nullptr;
TabbingAllowedFunc m_tabbingAllowedFunc = nullptr;
FrameworkWidgetFactory *m_frameworkWidgetFactory;
Flags m_flags = Flag_Default;
int m_separatorThickness = 5;
#if defined(Q_OS_WIN)
int m_staticSeparatorThickness = 1; // FIXME: Broken on Windows still.
#else
int m_staticSeparatorThickness = 0;
#endif
qreal m_draggedWindowOpacity = Q_QNAN;
};
Config::Config()
: d(new Private())
{
d->fixFlags();
// stuff in multisplitter/ can't include the framework widget factory, so set it here
auto separatorCreator = [](Layouting::Widget *parent) {
return Config::self().frameworkWidgetFactory()->createSeparator(parent);
};
Layouting::Config::self().setSeparatorFactoryFunc(separatorCreator);
}
Config& Config::self()
@@ -94,6 +91,10 @@ void Config::setFlags(Flags f)
d->m_flags = f;
d->fixFlags();
auto multisplitterFlags = Layouting::Config::self().flags();
multisplitterFlags.setFlag(Layouting::Config::Flag::LazyResize, d->m_flags & Flag_LazyResize);
Layouting::Config::self().setFlags(multisplitterFlags);
}
void Config::setDockWidgetFactoryFunc(DockWidgetFactoryFunc func)
@@ -106,6 +107,16 @@ DockWidgetFactoryFunc Config::dockWidgetFactoryFunc() const
return d->m_dockWidgetFactoryFunc;
}
void Config::setMainWindowFactoryFunc(MainWindowFactoryFunc func)
{
d->m_mainWindowFactoryFunc = func;
}
MainWindowFactoryFunc Config::mainWindowFactoryFunc() const
{
return d->m_mainWindowFactoryFunc;
}
void Config::setFrameworkWidgetFactory(FrameworkWidgetFactory *wf)
{
Q_ASSERT(wf);
@@ -118,28 +129,39 @@ FrameworkWidgetFactory *Config::frameworkWidgetFactory() const
return d->m_frameworkWidgetFactory;
}
int Config::separatorThickness(bool staticSeparator) const
int Config::separatorThickness() const
{
return staticSeparator ? d->m_staticSeparatorThickness
: d->m_separatorThickness;
return Layouting::Config::self().separatorThickness();
}
void Config::setSeparatorThickness(int value, bool staticSeparator)
void Config::setSeparatorThickness(int value)
{
if ((value <= 0 && !staticSeparator) || (value < 0 && staticSeparator) || value >= 100) {
qWarning() << Q_FUNC_INFO << "Invalid value" << value;
return;
}
if (!DockRegistry::self()->isEmpty()) {
qWarning() << Q_FUNC_INFO << "Only use this function at startup before creating any DockWidget or MainWindow";
return;
}
if (staticSeparator)
d->m_staticSeparatorThickness = value;
else
d->m_separatorThickness = value;
Layouting::Config::self().setSeparatorThickness(value);
}
void Config::setDraggedWindowOpacity(qreal opacity)
{
d->m_draggedWindowOpacity = opacity;
}
qreal Config::draggedWindowOpacity() const
{
return d->m_draggedWindowOpacity;
}
void Config::setTabbingAllowedFunc(TabbingAllowedFunc func)
{
d->m_tabbingAllowedFunc = func;
}
TabbingAllowedFunc Config::tabbingAllowedFunc() const
{
return d->m_tabbingAllowedFunc;
}
void Config::setQmlEngine(QQmlEngine *qmlEngine)
@@ -163,6 +185,9 @@ void Config::Private::fixFlags()
if (QOperatingSystemVersion::current().majorVersion() < 10) {
// Aero-snap requires Windows 10
m_flags = m_flags & ~Flag_AeroSnapWithClientDecos;
} else {
// Unconditional now
m_flags |= Flag_AeroSnapWithClientDecos;
}
// These are mutually exclusive:
@@ -184,3 +209,5 @@ void Config::Private::fixFlags()
m_flags = m_flags & ~Flag_AeroSnapWithClientDecos;
#endif
}
}

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
/**
@@ -38,9 +29,19 @@ namespace KDDockWidgets
{
class DockWidgetBase;
class MainWindowBase;
class FrameworkWidgetFactory;
typedef KDDockWidgets::DockWidgetBase* (*DockWidgetFactoryFunc)(const QString &name);
typedef KDDockWidgets::MainWindowBase* (*MainWindowFactoryFunc)(const QString &name);
/// @brief Function to allow the user more granularity to disallow dock widgets to tab together
/// @param source The dock widgets being dragged
/// @param target The dock widgets within an existing docked tab group
/// @return true if the docking is allowed.
/// @sa setTabbingAllowedFunc
typedef bool (*TabbingAllowedFunc)(const QVector<DockWidgetBase*> &source,
const QVector<DockWidgetBase*> &target);
/**
* @brief Singleton to allow to choose certain behaviours of the framework.
@@ -62,13 +63,26 @@ public:
enum Flag {
Flag_None = 0, ///> No option set
Flag_NativeTitleBar = 1, ///> Enables the Native OS title bar on OSes that support it (Windows 10, macOS), ignored otherwise. This is mutually exclusive with Flag_AeroSnap
Flag_AeroSnapWithClientDecos = 2, ///> Enables AeroSnap even if we're not using the native title bar. Only supported on Windows 10.
Flag_AeroSnapWithClientDecos = 2, ///> Deprecated. This is now default and cannot be turned off. Moving a window on Windows 10 uses native moving, as that works well across screens with different HDPI settings. There's no reason to use manual client/Qt window moving.
Flag_AlwaysTitleBarWhenFloating = 4, ///> Floating windows will have a title bar even if Flag_HideTitleBarWhenTabsVisible is specified. Unneeded if Flag_HideTitleBarWhenTabsVisible isn't specified, as that's the default already.
Flag_HideTitleBarWhenTabsVisible = 8, ///> Hides the title bar if there's tabs visible. The empty space in the tab bar becomes draggable.
Flag_AlwaysShowTabs = 16, ///> Always show tabs, even if there's only one,
Flag_AllowReorderTabs = 32, /// Allows user to re-order tabs by dragging them
Flag_LazyResize = 32, /// The dock widgets are resized in a lazy manner. The actual resize only happens when you release the mouse button.
Flag_TabsHaveCloseButton = 64, /// Tabs will have a close button. Equivalent to QTabWidget::setTabsClosable(true).
Flag_DoubleClickMaximizes = 128, /// Double clicking the titlebar will maximize a floating window instead of re-docking it
Flag_TitleBarHasMaximizeButton = 256, /// The title bar will have a maximize/restore button when floating. This is mutually-exclusive with the floating button (since many apps behave that way).
Flag_TitleBarIsFocusable = 512, /// You can click the title bar and it will focus the last focused widget in the focus scope. If no previously focused widget then it focuses the user's dock widget guest, which should accept focus or use a focus proxy.
Flag_LazyResize = 1024, /// The dock widgets are resized in a lazy manner. The actual resize only happens when you release the mouse button.
// These two are internal, for testing purposes across platforms. Use Flag_DontUseUtilityFloatingWindows instead.
Flag_internal_DontUseQtToolWindowsForFloatingWindows = 0x800, ///> FloatingWindows will use Qt::Window instead of Qt::Tool. Internal, use Flag_DontUseUtilityFloatingWindows instead.
Flag_internal_DontUseParentForFloatingWindows = 0x1000, ///> FloatingWindows won't have a parent top-level. Internal, use Flag_DontUseUtilityFloatingWindows instead.
Flag_DontUseUtilityFloatingWindows = Flag_internal_DontUseQtToolWindowsForFloatingWindows | Flag_internal_DontUseParentForFloatingWindows,
Flag_TitleBarHasMinimizeButton = 0x2000 | Flag_DontUseUtilityFloatingWindows, ///> The title bar will have a minimize button when floating. This implies Flag_DontUseUtilityFloatingWindows too, otherwise they wouldn't appear in the task bar.
Flag_TitleBarNoFloatButton = 0x4000, ///> The TitleBar won't show the float button
Flag_AutoHideSupport = 0x8000 | Flag_TitleBarNoFloatButton, ///> Supports minimizing dock widgets to the side-bar.
///> By default it also turns off the float button, but you can remove Flag_TitleBarNoFloatButton to have both.
Flag_Default = Flag_AeroSnapWithClientDecos ///> The defaults
};
Q_DECLARE_FLAGS(Flags, Flag)
@@ -101,6 +115,15 @@ public:
///nullptr by default
DockWidgetFactoryFunc dockWidgetFactoryFunc() const;
///@brief counter-part of DockWidgetFactoryFunc but for the main window.
/// Should be rarely used. It's good practice to have the main window before restoring a layout.
/// It's here so we can use it in the linter executable
void setMainWindowFactoryFunc(MainWindowFactoryFunc);
///@brief Returns the MainWindowFactoryFunc.
///nullptr by default
MainWindowFactoryFunc mainWindowFactoryFunc() const;
/**
* @brief Sets the WidgetFactory.
*
@@ -119,17 +142,48 @@ public:
/**
* @brief Returns the thickness of the separator.
*
* Returns the width if the separator is vertical, otherwise the height.
* If @p staticSeparator is true, then returns for the static separators.
* The static separators are the ones at the edges of the window (top, left, bottom, right).
*
* Default is 0px for static separators and 5px for normal separators.
* Default is 5px.
*/
int separatorThickness(bool staticSeparator) const;
int separatorThickness() const;
///@brief setter for @ref separatorThickness
///Note: Only use this function at startup before creating any DockWidget or MainWindow.
void setSeparatorThickness(int value, bool staticSeparator);
void setSeparatorThickness(int value);
///@brief sets the dragged window opacity
///1.0 is fully opaque while 0.0 is fully transparent
void setDraggedWindowOpacity(qreal opacity);
///@brief returns the opacity to use when dragging dock widgets
///By default it's 1.0, fully opaque
qreal draggedWindowOpacity() const;
/**
* @brief Allows the user to intercept a docking attempt to center (tabbed) and disallow it.
*
* Whenever the user tries to tab two widgets together, the framework will call @ref func. If
* it returns true, then tabbing is allowed, otherwise not.
*
* Example
*
* #include <kddockwidgets/Config.h>
* (...)
*
* auto func = [] (const KDDockWidgets::DockWidgetBase::List &source,
* const KDDockWidgets::DockWidgetBase::List &target)
* {
* // disallows dockFoo to be tabbed with dockBar.
* return !(source.contains(dockFoo) && target.contains(dockBar));
* }
*
* KDDockWidgets::Config::self()->setTabbingAllowedFunc(func);
*/
void setTabbingAllowedFunc(TabbingAllowedFunc func);
///@brief Used internally by the framework. Returns the function which was passed to setTabbingAllowedFunc()
///By default it's nullptr.
///@sa setTabbingAllowedFunc().
TabbingAllowedFunc tabbingAllowedFunc() const;
///@brief Sets the QQmlEngine to use. Applicable only when using QtQuick.
void setQmlEngine(QQmlEngine *);

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
/**
@@ -56,7 +47,7 @@ public:
* when visible, or stays without a parent when hidden. This allows to support docking
* to different main windows.
*/
explicit DockWidget(const QString &uniqueName, Options options = {});
explicit DockWidget(const QString &uniqueName, Options options = DockWidgetBase::Options());
///@brief destructor
~DockWidget() override;

View File

@@ -1,37 +1,28 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include "DockWidgetBase.h"
#include "DragController_p.h"
#include "Frame_p.h"
#include "FloatingWindow_p.h"
#include "Logging_p.h"
#include "TabWidget_p.h"
#include "Utils_p.h"
#include "DockRegistry_p.h"
#include "WidgetResizeHandler_p.h"
#include "DropArea_p.h"
#include "LastPosition_p.h"
#include "multisplitter/Item_p.h"
#include "Config.h"
#include "TitleBar_p.h"
#include "FrameworkWidgetFactory.h"
#include "private/Position_p.h"
#include "WindowBeingDragged_p.h"
#include "SideBar_p.h"
#include <QAction>
#include <QEvent>
@@ -57,10 +48,8 @@ public:
, q(qq)
, options(options_)
, toggleAction(new QAction(q))
, floatAction(new QAction(q))
{
q->connect(q, &DockWidgetBase::shown, q, [this] { onDockWidgetShown(); } );
q->connect(q, &DockWidgetBase::hidden, q, [this] { onDockWidgetHidden(); } );
q->connect(toggleAction, &QAction::toggled, q, [this] (bool enabled) {
if (!m_updatingToggleAction) { // guard against recursiveness
toggleAction->blockSignals(true); // and don't emit spurious toggle. Like when a dock widget is inserted into a tab widget it might get hide events, ignore those. The Dock Widget is open.
@@ -69,7 +58,16 @@ public:
}
});
q->connect(floatAction, &QAction::toggled, q, [this] (bool checked) {
if (!m_updatingFloatAction) { // guard against recursiveness
q->setFloating(checked);
}
Q_EMIT q->isFloatingChanged(checked);
});
toggleAction->setCheckable(true);
floatAction->setCheckable(true);
}
void init()
@@ -77,18 +75,42 @@ public:
updateTitle();
}
FloatingWindow *floatingWindow() const
{
return qobject_cast<FloatingWindow*>(q->window());
}
MainWindowBase *mainWindow() const
{
if (q->isWindow())
return nullptr;
// Note: Don't simply use window(), as the MainWindow might be embedded into something else
QWidgetOrQuick *p = q->parentWidget();
while (p) {
if (auto window = qobject_cast<MainWindowBase*>(p))
return window;
if (p->isWindow())
return nullptr;
p = p->parentWidget();
}
return nullptr;
}
QPoint defaultCenterPosForFloating();
void updateTitle();
void updateIcon();
void toggle(bool enabled);
void updateToggleAction();
void updateFloatAction();
void onDockWidgetShown();
void onDockWidgetHidden();
TabWidget *parentTabWidget() const;
void show();
void close();
void restoreToPreviousPosition();
bool restoreToPreviousPosition();
void maybeRestoreToPreviousPosition();
int currentTabIndex() const;
@@ -99,29 +121,33 @@ public:
void saveTabIndex();
const QString name;
QString affinityName;
QStringList affinities;
QString title;
QIcon icon;
QWidget *widget = nullptr;
QIcon titleBarIcon;
QIcon tabBarIcon;
QWidgetOrQuick *widget = nullptr;
DockWidgetBase *const q;
DockWidgetBase::Options options;
QAction *const toggleAction;
LastPosition m_lastPosition;
QAction *const floatAction;
LastPositions m_lastPositions;
bool m_updatingToggleAction = false;
bool m_updatingFloatAction = false;
bool m_isForceClosing = false;
};
DockWidgetBase::DockWidgetBase(const QString &name, Options options)
: QWidgetOrQuick(nullptr, Qt::Tool)
: QWidgetAdapter(nullptr, Qt::Tool)
, d(new Private(name, options, this))
{
d->init();
DragController::instance();
DockRegistry::self()->registerDockWidget(this);
qCDebug(creation) << "DockWidget" << this;
if (name.isEmpty())
qWarning() << Q_FUNC_INFO << "Name can't be null";
setAttribute(Qt::WA_PendingMoveEvent, false);
}
DockWidgetBase::~DockWidgetBase()
@@ -144,9 +170,15 @@ void DockWidgetBase::addDockWidgetAsTab(DockWidgetBase *other, AddingOption addi
return;
}
if (other->affinityName() != affinityName()) {
if (!DockRegistry::self()->affinitiesMatch(other->affinities(), d->affinities)) {
qWarning() << Q_FUNC_INFO << "Refusing to dock widget with incompatible affinity."
<< other->affinityName() << affinityName();
<< other->affinities() << affinities();
return;
}
if ((other->options() & DockWidgetBase::Option_NotDockable) ||
(options() & DockWidgetBase::Option_NotDockable)) {
qWarning() << Q_FUNC_INFO << "Refusing to dock non-dockable widget" << other;
return;
}
@@ -162,10 +194,13 @@ void DockWidgetBase::addDockWidgetAsTab(DockWidgetBase *other, AddingOption addi
// Doesn't have a frame yet
morphIntoFloatingWindow();
frame = this->frame();
} else {
// Doesn't happen
qWarning() << Q_FUNC_INFO << "null frame";
return;
}
}
Q_ASSERT(frame);
other->setParent(nullptr);
frame->addWidget(other, addingOption);
}
@@ -178,33 +213,49 @@ void DockWidgetBase::addDockWidgetToContainingWindow(DockWidgetBase *other, Loca
return;
}
if (other->affinityName() != affinityName()) {
if (!DockRegistry::self()->affinitiesMatch(other->affinities(), d->affinities)) {
qWarning() << Q_FUNC_INFO << "Refusing to dock widget with incompatible affinity."
<< other->affinityName() << affinityName();
<< other->affinities() << affinities();
return;
}
if ((other->options() & DockWidgetBase::Option_NotDockable) ||
(options() & DockWidgetBase::Option_NotDockable)) {
qWarning() << Q_FUNC_INFO << "Refusing to dock non-dockable widget" << other;
return;
}
if (isWindow())
morphIntoFloatingWindow();
if (auto fw = qobject_cast<FloatingWindow *>(window())) {
if (auto fw = floatingWindow()) {
fw->dropArea()->addDockWidget(other, location, relativeTo);
} else {
qWarning() << Q_FUNC_INFO << "Couldn't find floating nested window";
}
}
void DockWidgetBase::setWidget(QWidget *w)
void DockWidgetBase::setWidget(QWidgetOrQuick *w)
{
Q_ASSERT(w && !d->widget);
Q_ASSERT(w);
qCDebug(addwidget) << Q_FUNC_INFO << w;
if (w == d->widget)
return;
if (d->widget) {
// Unparent the old widget, we're giving back ownership
d->widget->setParent(nullptr);
}
d->widget = w;
if (w)
setSizePolicy(w->sizePolicy());
Q_EMIT widgetChanged(w);
setWindowTitle(uniqueName());
}
QWidget *DockWidgetBase::widget() const
QWidgetOrQuick *DockWidgetBase::widget() const
{
return d->widget;
}
@@ -214,41 +265,42 @@ bool DockWidgetBase::isFloating() const
if (isWindow())
return true;
auto fw = qobject_cast<FloatingWindow *>(window());
auto fw = floatingWindow();
return fw && fw->hasSingleDockWidget();
}
void DockWidgetBase::setFloating(bool floats)
bool DockWidgetBase::setFloating(bool floats)
{
const bool alreadyFloating = isFloating();
qCDebug(docking) << Q_FUNC_INFO << "yes=" << floats
<< "; already floating=" << alreadyFloating;
if ((floats && alreadyFloating) || (!floats && !alreadyFloating))
return; // Nothing to do
return true; // Nothing to do
if (floats) {
d->saveTabIndex();
if (isTabbed()) {
TabWidget *tabWidget= d->parentTabWidget();
if (!tabWidget) {
qWarning() << "DockWidget::setFloating: Tabbed but no tabbar exists"
auto frame = this->frame();
if (!frame) {
qWarning() << "DockWidget::setFloating: Tabbed but no frame exists"
<< this;
Q_ASSERT(false);
return false;
}
tabWidget->detachTab(this);
frame->detachTab(this);
} else {
frame()->titleBar()->makeWindow();
}
} else {
if (d->m_lastPosition.isValid()) {
d->restoreToPreviousPosition();
} else {
qCDebug(placeholder) << Q_FUNC_INFO << "Don't have a place to restore";
// TODO: Restore to preferred place ?
auto lastGeo = lastPositions().lastFloatingGeometry();
if (lastGeo.isValid()) {
if (auto fw = floatingWindow())
fw->setSuggestedGeometry(lastGeo, /*preserveCenter=*/true);
}
return true;
} else {
saveLastFloatingGeometry();
return d->restoreToPreviousPosition();
}
}
@@ -257,6 +309,11 @@ QAction *DockWidgetBase::toggleAction() const
return d->toggleAction;
}
QAction *DockWidgetBase::floatAction() const
{
return d->floatAction;
}
QString DockWidgetBase::uniqueName() const
{
return d->name;
@@ -272,7 +329,7 @@ void DockWidgetBase::setTitle(const QString &title)
if (title != d->title) {
d->title = title;
d->updateTitle();
Q_EMIT titleChanged();
Q_EMIT titleChanged(title);
}
}
@@ -283,6 +340,11 @@ DockWidgetBase::Options DockWidgetBase::options() const
void DockWidgetBase::setOptions(Options options)
{
if ((d->options & Option_NotDockable) != (options & Option_NotDockable)) {
qWarning() << Q_FUNC_INFO << "Option_NotDockable not allowed to change. Pass via ctor only.";
return;
}
if (options != d->options) {
d->options = options;
Q_EMIT optionsChanged(options);
@@ -293,8 +355,8 @@ void DockWidgetBase::setOptions(Options options)
bool DockWidgetBase::isTabbed() const
{
if (TabWidget* tabWidget = d->parentTabWidget()) {
return frame()->alwaysShowsTabs() || tabWidget->numDockWidgets() > 1;
if (Frame *frame = this->frame()) {
return frame->alwaysShowsTabs() || frame->dockWidgetCount() > 1;
} else {
if (!isFloating())
qWarning() << "DockWidget::isTabbed() Couldn't find any tab widget.";
@@ -304,8 +366,8 @@ bool DockWidgetBase::isTabbed() const
bool DockWidgetBase::isCurrentTab() const
{
if (TabWidget* tabWidget = d->parentTabWidget()) {
return tabWidget->currentIndex() == tabWidget->indexOfDockWidget(const_cast<DockWidgetBase*>(this));
if (Frame *frame = this->frame()) {
return frame->currentIndex() == frame->indexOfDockWidget(const_cast<DockWidgetBase*>(this));
} else {
return true;
}
@@ -313,20 +375,30 @@ bool DockWidgetBase::isCurrentTab() const
void DockWidgetBase::setAsCurrentTab()
{
if (TabWidget* tabWidget = d->parentTabWidget())
tabWidget->setCurrentDockWidget(this);
if (Frame *frame = this->frame())
frame->setCurrentDockWidget(this);
}
void DockWidgetBase::setIcon(const QIcon &icon)
void DockWidgetBase::setIcon(const QIcon &icon, IconPlaces places)
{
d->icon = icon;
d->updateIcon();
if (places & IconPlace::TitleBar)
d->titleBarIcon = icon;
if (places & IconPlace::TabBar)
d->tabBarIcon = icon;
Q_EMIT iconChanged();
}
QIcon DockWidgetBase::icon() const
QIcon DockWidgetBase::icon(IconPlace place) const
{
return d->icon;
if (place == IconPlace::TitleBar)
return d->titleBarIcon;
if (place == IconPlace::TabBar)
return d->tabBarIcon;
return {};
}
void DockWidgetBase::forceClose()
@@ -348,19 +420,19 @@ bool DockWidgetBase::isOpen() const
return d->toggleAction->isChecked();
}
QString DockWidgetBase::affinityName() const
QStringList DockWidgetBase::affinities() const
{
return d->affinityName;
return d->affinities;
}
void DockWidgetBase::show()
{
if (isWindow() && (lastPosition()->m_wasFloating || !lastPosition()->isValid())) {
if (isWindow() && (d->m_lastPositions.wasFloating() || !d->m_lastPositions.isValid())) {
// Create the FloatingWindow already, instead of waiting for the show event.
// This reduces flickering on some platforms
morphIntoFloatingWindow();
} else {
QWidget::show();
QWidgetOrQuick::show();
}
}
@@ -371,25 +443,78 @@ void DockWidgetBase::raise()
setAsCurrentTab();
if (auto fw = qobject_cast<FloatingWindow*>(window())) {
if (auto fw = floatingWindow()) {
fw->raise();
fw->activateWindow();
}
}
void DockWidgetBase::setAffinityName(const QString &name)
bool DockWidgetBase::isMainWindow() const
{
if (d->affinityName == name)
return qobject_cast<MainWindowBase*>(widget());
}
bool DockWidgetBase::isInMainWindow() const
{
return d->mainWindow() != nullptr;
}
MainWindowBase* DockWidgetBase::mainWindow() const
{
return d->mainWindow();
}
bool DockWidgetBase::isFocused() const
{
auto f = this->frame();
return f && f->isFocused() && isCurrentTab();
}
void DockWidgetBase::setAffinityName(const QString &affinity)
{
setAffinities({ affinity });
}
void DockWidgetBase::setAffinities(const QStringList &affinityNames)
{
QStringList affinities = affinityNames;
affinities.removeAll(QString());
if (d->affinities == affinities)
return;
if (!d->affinityName.isEmpty()) {
if (!d->affinities.isEmpty()) {
qWarning() << Q_FUNC_INFO
<< "Affinity is already set, refusing to change."
<< "Submit a feature request with a good justification.";
return;
}
d->affinityName = name;
d->affinities = affinities;
}
void DockWidgetBase::moveToSideBar()
{
if (MainWindowBase *m = mainWindow())
m->moveToSideBar(this);
}
bool DockWidgetBase::isOverlayed() const
{
if (MainWindowBase *m = mainWindow())
return m->overlayedDockWidget() == this;
return false;
}
SideBarLocation DockWidgetBase::sideBarLocation() const
{
return DockRegistry::self()->sideBarLocationForDockWidget(this);
}
bool DockWidgetBase::hasPreviousDockedLocation() const
{
return d->m_lastPositions.isValid();
}
FloatingWindow *DockWidgetBase::morphIntoFloatingWindow()
@@ -397,22 +522,25 @@ FloatingWindow *DockWidgetBase::morphIntoFloatingWindow()
qCDebug(creation) << "DockWidget::morphIntoFloatingWindow() this=" << this
<< "; visible=" << isVisible();
if (auto fw = qobject_cast<FloatingWindow*>(window()))
if (auto fw = floatingWindow())
return fw; // Nothing to do
if (isWindow()) {
QRect geo = lastPosition()->lastFloatingGeometry();
QRect geo = d->m_lastPositions.lastFloatingGeometry();
if (geo.isNull()) {
geo = geometry();
const QPoint center = d->defaultCenterPosForFloating();
if (!center.isNull())
geo.moveCenter(center);
if (!testAttribute(Qt::WA_PendingMoveEvent)) { // If user already moved it, we don't interfere
const QPoint center = d->defaultCenterPosForFloating();
if (!center.isNull())
geo.moveCenter(center);
}
}
auto frame = Config::self().frameworkWidgetFactory()->createFrame();
frame->addWidget(this);
auto floatingWindow = Config::self().frameworkWidgetFactory()->createFloatingWindow(frame);
floatingWindow->setGeometry(geo);
floatingWindow->setSuggestedGeometry(geo);
floatingWindow->show();
return floatingWindow;
@@ -440,19 +568,32 @@ Frame *DockWidgetBase::frame() const
FloatingWindow *DockWidgetBase::floatingWindow() const
{
return qobject_cast<FloatingWindow*>(window());
return d->floatingWindow();
}
void DockWidgetBase::addPlaceholderItem(Item *item)
void DockWidgetBase::addPlaceholderItem(Layouting::Item *item)
{
qCDebug(placeholder) << Q_FUNC_INFO << this << item;
Q_ASSERT(item);
d->m_lastPosition.addPlaceholderItem(item);
d->m_lastPositions.addPosition(item);
}
LastPosition *DockWidgetBase::lastPosition() const
LastPositions& DockWidgetBase::lastPositions() const
{
return &d->m_lastPosition;
return d->m_lastPositions;
}
void DockWidgetBase::saveLastFloatingGeometry()
{
if (isFloating() && isVisible()) {
// It's getting docked, save last floating position
lastPositions().setLastFloatingGeometry(window()->geometry());
}
}
void DockWidgetBase::updateFloatAction()
{
d->updateFloatAction();
}
QPoint DockWidgetBase::Private::defaultCenterPosForFloating()
@@ -475,11 +616,6 @@ void DockWidgetBase::Private::updateTitle()
toggleAction->setText(title);
}
void DockWidgetBase::Private::updateIcon()
{
}
void DockWidgetBase::Private::toggle(bool enabled)
{
if (enabled) {
@@ -493,74 +629,94 @@ void DockWidgetBase::Private::updateToggleAction()
{
QScopedValueRollback<bool> recursionGuard(m_updatingToggleAction, true); // Guard against recursiveness
m_updatingToggleAction = true;
if ((q->isVisible() || parentTabWidget()) && !toggleAction->isChecked()) {
if ((q->isVisible() || q->frame()) && !toggleAction->isChecked()) {
toggleAction->setChecked(true);
} else if ((!q->isVisible() && !parentTabWidget()) && toggleAction->isChecked()) {
} else if ((!q->isVisible() && !q->frame()) && toggleAction->isChecked()) {
toggleAction->setChecked(false);
}
}
void DockWidgetBase::Private::updateFloatAction()
{
QScopedValueRollback<bool> recursionGuard(m_updatingFloatAction, true); // Guard against recursiveness
if (q->isFloating()) {
floatAction->setEnabled(m_lastPositions.isValid());
floatAction->setChecked(true);
floatAction->setToolTip(tr("Dock"));
} else {
floatAction->setEnabled(true);
floatAction->setChecked(false);
floatAction->setToolTip(tr("Detach"));
}
}
void DockWidgetBase::Private::onDockWidgetShown()
{
updateToggleAction();
updateFloatAction();
qCDebug(hiding) << Q_FUNC_INFO << "parent=" << q->parentWidget();
}
void DockWidgetBase::Private::onDockWidgetHidden()
{
updateToggleAction();
updateFloatAction();
qCDebug(hiding) << Q_FUNC_INFO << "parent=" << q->parentWidget();
}
TabWidget *DockWidgetBase::Private::parentTabWidget() const
{
if (auto f = q->frame())
return f->tabWidget();
return nullptr;
}
void DockWidgetBase::Private::close()
{
if (!m_isForceClosing && q->isFloating() && q->isVisible()) { // only user-closing is interesting to save the geometry
// We check for isVisible so we don't save geometry if you call close() on an already closed dock widget
m_lastPosition.setLastFloatingGeometry(q->window()->geometry());
m_lastPositions.setLastFloatingGeometry(q->window()->geometry());
}
qCDebug(hiding) << "DockWidget::close" << this;
saveTabIndex();
// Do some cleaning. Widget is hidden, but we must hide the tab containing it.
if (auto tabWidget = parentTabWidget()) {
tabWidget->removeDockWidget(q);
if (Frame *frame = q->frame()) {
frame->removeWidget(q);
q->setParent(nullptr);
if (SideBar *sb = DockRegistry::self()->sideBarForDockWidget(q)) {
sb->removeDockWidget(q);
}
}
}
void DockWidgetBase::Private::restoreToPreviousPosition()
bool DockWidgetBase::Private::restoreToPreviousPosition()
{
if (!m_lastPosition.isValid()) {
qWarning() << Q_FUNC_INFO << "Only restoring to MainWindow supported for now";
return;
}
if (!m_lastPositions.isValid())
return false;
m_lastPosition.layoutItem()->restorePlaceholder(q, m_lastPosition.m_tabIndex);
Layouting::Item *item = m_lastPositions.lastItem();
MultiSplitter *layout = DockRegistry::self()->layoutForItem(item);
Q_ASSERT(layout);
layout->restorePlaceholder(q, item, m_lastPositions.lastTabIndex());
return true;
}
void DockWidgetBase::Private::maybeRestoreToPreviousPosition()
{
// This is called when we get a QEvent::Show. Let's see if we have to restore it to a previous position.
Item *layoutItem = m_lastPosition.layoutItem();
qCDebug(placeholder) << Q_FUNC_INFO << layoutItem << m_lastPosition.m_wasFloating;
if (!m_lastPositions.isValid())
return;
Layouting::Item *layoutItem = m_lastPositions.lastItem();
qCDebug(placeholder) << Q_FUNC_INFO << layoutItem << m_lastPositions;
if (!layoutItem)
return; // nothing to do, no last position
if (m_lastPosition.m_wasFloating)
if (m_lastPositions.wasFloating())
return; // Nothing to do, it was floating before, now it'll just get visible
Frame *frame = q->frame();
if (frame && frame->parentWidget() == layoutItem->parentWidget()) {
if (frame && frame->QWidgetAdapter::parentWidget() == DockRegistry::self()->layoutForItem(layoutItem)) {
// There's a frame already. Means the DockWidget was hidden instead of closed.
// Nothing to do, the dock widget will simply be shown
qCDebug(placeholder) << Q_FUNC_INFO << "Already had frame.";
@@ -581,14 +737,13 @@ void DockWidgetBase::Private::maybeRestoreToPreviousPosition()
int DockWidgetBase::Private::currentTabIndex() const
{
TabWidget *tabWidget = parentTabWidget();
return tabWidget ? tabWidget->indexOfDockWidget(q) : 0;
Frame *frame = q->frame();
return frame ? frame->indexOfDockWidget(q) : 0;
}
void DockWidgetBase::Private::saveTabIndex()
{
m_lastPosition.m_tabIndex = currentTabIndex();
m_lastPosition.m_wasFloating = q->isFloating();
m_lastPositions.saveTabIndex(currentTabIndex(), q->isFloating());
}
void DockWidgetBase::Private::show()
@@ -601,10 +756,12 @@ void DockWidgetBase::onParentChanged()
{
Q_EMIT parentChanged();
d->updateToggleAction();
d->updateFloatAction();
}
void DockWidgetBase::onShown(bool spontaneous)
{
d->onDockWidgetShown();
Q_EMIT shown();
if (Frame *f = frame()) {
@@ -621,6 +778,7 @@ void DockWidgetBase::onShown(bool spontaneous)
void DockWidgetBase::onHidden(bool spontaneous)
{
d->onDockWidgetHidden();
Q_EMIT hidden();
if (Frame *f = frame()) {
@@ -634,7 +792,7 @@ void DockWidgetBase::onClosed(QCloseEvent *e)
{
e->accept(); // By default we accept, means DockWidget closes
if (d->widget)
qApp->sendEvent(d->widget, e); // Give a change for the widget to ignore
qApp->sendEvent(d->widget, e); // Give a chancefor the widget to ignore
if (e->isAccepted())
d->close();
@@ -651,14 +809,14 @@ DockWidgetBase *DockWidgetBase::deserialize(const LayoutSaver::DockWidget::Ptr &
}
if (dw) {
if (QWidget *w = dw->widget())
if (QWidgetOrQuick *w = dw->widget())
w->setVisible(true);
dw->setProperty("kddockwidget_was_restored", true);
if (dw->affinityName() != saved->affinityName) {
qWarning() << Q_FUNC_INFO << "Affinity name changed from" << dw->affinityName()
<< "; to" << saved->affinityName;
dw->d->affinityName = saved->affinityName;
if (dw->affinities() != saved->affinities) {
qWarning() << Q_FUNC_INFO << "Affinity name changed from" << dw->affinities()
<< "; to" << saved->affinities;
dw->d->affinities = saved->affinities;
}
} else {
@@ -671,7 +829,7 @@ DockWidgetBase *DockWidgetBase::deserialize(const LayoutSaver::DockWidget::Ptr &
LayoutSaver::DockWidget::Ptr DockWidgetBase::serialize() const
{
auto ptr = LayoutSaver::DockWidget::dockWidgetForName(uniqueName());
ptr->affinityName = affinityName();
ptr->affinities = affinities();
return ptr;
}

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
/**
@@ -34,24 +25,27 @@
#include "LayoutSaver_p.h"
#include <QVector>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QAction;
QT_END_NAMESPACE
namespace Layouting {
class Item;
}
namespace KDDockWidgets {
struct LastPositions;
class Frame;
class FloatingWindow;
class DragController;
class Item;
class LastPosition;
class DockRegistry;
class LayoutSaver;
class TabWidget;
class TitleBar;
class MainWindowBase;
class StateDragging;
/**
* @brief The DockWidget base-class. DockWidget and DockWidgetBase are only
@@ -60,40 +54,55 @@ class MainWindowBase;
*
* Do not use instantiate directly in user code. Use DockWidget instead.
*/
class DOCKS_EXPORT DockWidgetBase : public QWidgetOrQuick
#ifndef PYTHON_BINDINGS //Pyside bug: https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1327
class DOCKS_EXPORT DockWidgetBase : public QWidgetAdapter
#else
class DOCKS_EXPORT DockWidgetBase : public QWidget
#endif
{
Q_OBJECT
Q_PROPERTY(bool isFocused READ isFocused NOTIFY isFocusedChanged)
Q_PROPERTY(bool isFloating READ isFloating WRITE setFloating NOTIFY isFloatingChanged)
public:
typedef QVector<DockWidgetBase *> List;
///@brief DockWidget options to pass at construction time
enum Option {
Option_None = 0, ///< No option, the default
Option_NotClosable = 1 /// The DockWidget can't be closed on the [x], only programatically
Option_NotClosable = 1, /// The DockWidget can't be closed on the [x], only programatically
Option_NotDockable = 2 ///< The DockWidget can't be docked, it's always floating
};
Q_DECLARE_FLAGS(Options, Option)
enum class IconPlace {
TitleBar = 1,
TabBar = 2,
All = TitleBar | TabBar
};
Q_ENUM(IconPlace)
Q_DECLARE_FLAGS(IconPlaces, IconPlace)
/**
* @brief constructs a new DockWidget
* @param name the name of the dockwidget, should be unique. Use title for user visible text.
* @param uniqueName the name of the dockwidget, should be unique. Use title for user visible text.
* @param options optional options controlling behaviour
*
* There's no parent argument. The DockWidget is either parented to FloatingWindow or MainWindow
* when visible, or stays without a parent when hidden.
*/
explicit DockWidgetBase(const QString &uniqueName, Options options = {});
explicit DockWidgetBase(const QString &uniqueName, Options options = DockWidgetBase::Options());
///@brief destructor
~DockWidgetBase() override;
/**
* @param Constructs a dock widget from its serialized form.
* @brief Constructs a dock widget from its serialized form.
* @internal
*/
static DockWidgetBase *deserialize(const LayoutSaver::DockWidget::Ptr &);
/**
* @param Serializes this dock widget into an intermediate form
* @brief Serializes this dock widget into an intermediate form
*/
LayoutSaver::DockWidget::Ptr serialize() const;
@@ -109,9 +118,9 @@ public:
/**
* @brief docks @p other widget into the window that contains this one.
* Equivalent to @ref MainWindow::addDockWidge() with the difference
* Equivalent to MainWindow::addDockWidget() with the difference
* that it also supports the case where the top-level window is a
* @ref FloatingWindow instead of @ref MainWindow.
* FloatingWindow instead of MainWindow.
*
* @param other The other dock widget to dock into the window.
* @param location The location to dock.
@@ -123,14 +132,19 @@ public:
/**
* @brief sets the widget which this dock widget hosts.
* @param widget to show inside this dock widget
* @param widget the widget to show inside this dock widget. Must not be null.
*
* Ownership for @p widget is transferred to DockWidgetBase.
* Ownsership for any previously existing widget is transferred back to the user. Meaning if you
* call setWidget(A) followed by setWidget(B) then A will have to be deleted by you, while B is
* owned by the dock widget.
*/
void setWidget(QWidget *widget);
virtual void setWidget(QWidgetOrQuick *widget);
/**
* @brief returns the widget which this dock widget hosts
*/
QWidget *widget() const;
QWidgetOrQuick *widget() const;
/**
* @brief Returns whether the dock widget is floating.
@@ -144,8 +158,10 @@ public:
/**
* @brief setter to make the dock widget float or dock.
* @param floats If true makes the dock widget float, otherwise docks it.
*
* Returns true if the request was accomplished
*/
void setFloating(bool floats);
bool setFloating(bool floats);
/**
* @brief Returns the QAction that allows to hide/show the dock widget
@@ -153,6 +169,12 @@ public:
*/
QAction *toggleAction() const;
/**
* @brief Returns the QAction that allows to dock/undock the dock widget
* Useful to put in menus.
*/
QAction *floatAction() const;
/**
* @brief the dock widget's unique name.
* @internal
@@ -180,7 +202,10 @@ public:
Options options() const;
/**
* @brief Setter for the options
* @brief Setter for the options.
* Only Option_NotClosable is allowed to change after construction. For the other options use
* the constructor only.
*
* @sa options(), optionsChanged()
*/
void setOptions(Options);
@@ -210,14 +235,22 @@ public:
/**
* @brief Sets an icon to show on title bars and tab bars.
* By default none is shown.
* @param places Specifies where the icon will be shown (TitleBar, TabBar or both)
*
* By default there's no icon set.
*
* @sa icon()
*/
void setIcon(const QIcon &icon);
void setIcon(const QIcon &icon, IconPlaces places = IconPlace::All);
/**
* @brief Returns the dock widget's icon.
* @brief Returns the dock widget's titlebar or tabbar icon (depending on the passed @p place)
*
* By default it's null.
*
* @sa setIcon()
*/
QIcon icon() const;
QIcon icon(IconPlace place = IconPlace::TitleBar) const;
/**
* @brief Like QWidget::close() but the hosted widget won't be asked if we
@@ -240,12 +273,12 @@ public:
bool isOpen() const;
/**
* @brief Sets the affinity name. Dock widgets can only dock into dock widgets of the same affinity.
* @brief Sets the affinity names. Dock widgets can only dock into dock widgets of the same affinity.
*
* By default the affinity is empty and a dock widget can dock into any main window and into any
* floating window. Usually you won't ever need to call
* this function, unless you have requirements where certain dock widgets can only dock into
* certain other dock widgets and main windows. @sa MainWindowBase::setAffinityName().
* certain other dock widgets and main windows. @sa MainWindowBase::setAffinities().
*
* Note: Call this function right after creating your dock widget, before adding to a main window and
* before restoring any layout.
@@ -254,14 +287,18 @@ public:
* edge cases. This will only be changed if a good use case comes up that requires changing
* affinities multiple times.
*
* @p name The affinity name.
* @p names the affinity names
*/
void setAffinities(const QStringList &);
/// @deprecated @overload
/// @param name the affinity name
void setAffinityName(const QString &name);
/**
* @brief Returns the affinity name. Empty by default.
*/
QString affinityName() const;
QStringList affinities() const;
/// @brief Equivalent to QWidget::show(), but it's optimized to reduce flickering on some platforms
void show();
@@ -275,6 +312,62 @@ public:
/// This only applies if the dock widget is already open. If closed, does nothing.
void raise();
/**
* @brief Returns whether widget() is a KDDockWidget::MainWindow
*
* This function doesn't have anything to do with this dock widget being inside a main window or
* not, but rather the inverse concept. It's not a very popular usage, but some applications
* want to dock a main window into another main window. This is done by putting it into a
* dock widget first.
*
* See also kddockwidgets_example -j
*/
bool isMainWindow() const;
/**
* @brief Returns whether this dock widget is docked into a main window.
*
* Note that isFloating() returning false might either mean the dock widget is docked into a
* main window or into a floating window (groupped/nested with other dock widgets. Use this function
* then if you need to disambiguate
*/
bool isInMainWindow() const;
/// @brief Returns the main window this dock widget is in. nullptr if it's not inside a main window
MainWindowBase *mainWindow() const;
///@brief Returns whether This or any child of this dock widget is focused
///Not to be confused with QWidget::hasFocus(), which just refers to 1 widget. This includes
///variant includes children.
///@sa isFocusedChanged()
bool isFocused() const;
/**
* @brief Minimizes this dock widget to the MainWindow's side-bar.
*
* It will be undocked from current layout. It's previous docked position will be remembered.
*
* This action is only available if the dock widget is docked into a MainWindow.
* The dockwidget will initially be visible and overlayed on top of the current layout (this is
* the auto-hide feature).
*/
void moveToSideBar();
/// @brief Returns whether this dock widget is overlayed on top of the main window, instead of
/// docked into the layout. This is only relevant when using the auto-hide and side-bar feature.
bool isOverlayed() const;
///@brief Returns whether this dock widget is in a side bar, and which.
/// SideBarLocation::None is returned if it's not in a sidebar.
/// This is only relevant when using the auto-hide and side-bar feature.
SideBarLocation sideBarLocation() const;
/// @brief Returns whether this floating dock widget knows its previous docked location
/// Result only makes sense if it's floating.
///
/// When you call dockWidget->setFloating(false) it will only dock if it knows where to.
bool hasPreviousDockedLocation() const;
Q_SIGNALS:
///@brief signal emitted when the parent changed
void parentChanged();
@@ -289,14 +382,30 @@ Q_SIGNALS:
void iconChanged();
///@brief signal emitted when the title changed
void titleChanged();
///@param title the new title
void titleChanged(const QString &title);
///@brief emitted when the hosted widget changed
void widgetChanged(QWidget*);
void widgetChanged(KDDockWidgets::QWidgetOrQuick *);
///@brief emitted when the options change
///@sa setOptions(), options()
void optionsChanged(Options);
void optionsChanged(KDDockWidgets::DockWidgetBase::Options);
///@brief emitted when isFocused changes
///@sa isFocused
void isFocusedChanged(bool);
///@brief emitted when isOverlayed changes
///@sa isOverlayed
void isOverlayedChanged(bool);
///@brief emitted when isFloating changes
bool isFloatingChanged(bool);
///@brief emitted when this dock widget is removed from a side-bar.
///Only relevant for the auto-hide/sidebar feature
void removedFromSideBar();
protected:
void onParentChanged();
@@ -325,17 +434,17 @@ public:
private:
#endif
Q_DISABLE_COPY(DockWidgetBase)
friend class MultiSplitterLayout;
friend class MultiSplitter;
friend class Frame;
friend class DropArea;
friend class TestDocks;
friend class Item;
friend class StateDragging;
friend class KDDockWidgets::TabWidget;
friend class KDDockWidgets::TitleBar;
friend class KDDockWidgets::DragController;
friend class KDDockWidgets::Item;
friend class KDDockWidgets::DockRegistry;
friend class KDDockWidgets::LayoutSaver;
friend class KDDockWidgets::MainWindowBase;
/**
* @brief the Frame which contains this dock widgets.
@@ -356,15 +465,22 @@ private:
FloatingWindow *floatingWindow() const;
///@brief adds the current layout item containing this dock widget
void addPlaceholderItem(Item*);
void addPlaceholderItem(Layouting::Item*);
///@brief returns the last position, just for tests. TODO Make tests just use the d-pointer.
LastPosition *lastPosition() const;
LastPositions &lastPositions() const;
///@brief If this dock widget is floating, then it saves its geometry
void saveLastFloatingGeometry();
///@brief Updates the floatAction state
void updateFloatAction();
class Private;
Private *const d;
};
}
Q_DECLARE_METATYPE(KDDockWidgets::Location)
#endif

135
src/FocusScope.cpp Normal file
View File

@@ -0,0 +1,135 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
/**
* @file
* @brief FocusScope
*
* @author Sérgio Martins \<sergio.martins@kdab.com\>
*/
#include "FocusScope.h"
#include "TitleBar_p.h"
#include <QObject>
#include <QApplication>
#include <QPointer>
using namespace KDDockWidgets;
// Our Private inherits from QObject since FocusScope can't (Since Frame is already QObject)
class FocusScope::Private : public QObject
{
public:
Private(FocusScope *qq, QWidgetAdapter *thisWidget)
: q(qq)
, m_thisWidget(thisWidget)
{
connect(qApp, &QGuiApplication::focusObjectChanged,
this, &Private::onFocusObjectChanged);
onFocusObjectChanged(qApp->focusObject());
m_inCtor = false;
}
~Private() override;
void setIsFocused(bool);
void onFocusObjectChanged(QObject *);
bool isInFocusScope(WidgetType *) const;
FocusScope *const q;
QWidgetAdapter *const m_thisWidget;
bool m_isFocused = false;
bool m_inCtor = true;
QPointer<WidgetType> m_lastFocusedInScope;
};
FocusScope::Private::~Private()
{
}
FocusScope::FocusScope(QWidgetAdapter *thisWidget)
: d(new Private(this, thisWidget))
{
}
FocusScope::~FocusScope()
{
delete d;
}
bool FocusScope::isFocused() const
{
return d->m_isFocused;
}
WidgetType *FocusScope::focusedWidget() const
{
return d->m_lastFocusedInScope;
}
void FocusScope::focus(Qt::FocusReason reason)
{
if (d->m_lastFocusedInScope) {
d->m_lastFocusedInScope->setFocus(reason);
} else {
if (auto frame = qobject_cast<Frame*>(d->m_thisWidget)) {
if (DockWidgetBase *dw = frame->currentDockWidget()) {
if (auto guest = dw->widget()) {
if (guest->focusPolicy() != Qt::NoFocus)
guest->setFocus(reason);
}
}
} else {
// Not a use case right now
d->m_thisWidget->setFocus(reason);
}
}
}
void FocusScope::Private::setIsFocused(bool is)
{
if (is != m_isFocused) {
m_isFocused = is;
if (!m_inCtor) // Hack so we don't call pure-virtual
Q_EMIT q->isFocusedChanged();
}
}
void FocusScope::Private::onFocusObjectChanged(QObject *obj)
{
auto widget = qobject_cast<WidgetType*>(obj);
if (!widget)
return;
const bool is = isInFocusScope(widget);
if (is && m_lastFocusedInScope != widget && !qobject_cast<TitleBar*>(obj)) {
m_lastFocusedInScope = widget;
Q_EMIT q->focusedWidgetChanged();
}
setIsFocused(is);
}
bool FocusScope::Private::isInFocusScope(WidgetType *widget) const
{
WidgetType *p = widget;
while (p) {
if (p == m_thisWidget)
return true;
p = KDDockWidgets::Private::parentWidget(p);
}
return false;
}

61
src/FocusScope.h Normal file
View File

@@ -0,0 +1,61 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
/**
* @file
* @brief FocusScope
*
* @author Sérgio Martins \<sergio.martins@kdab.com\>
*/
#ifndef KD_DOCKWIDGETS_FOCUSSCOPE_H
#define KD_DOCKWIDGETS_FOCUSSCOPE_H
#include "docks_export.h"
#include "QWidgetAdapter.h"
namespace KDDockWidgets
{
///@brief Allows to implement a similar functionality to QtQuick's FocusScope item, in QtWidgets
class FocusScope
{
public:
///@brief constructor
explicit FocusScope(QWidgetAdapter *thisWidget);
virtual ~FocusScope();
///@brief Returns true if this FocusScope is focused.
///This is similar to the QWidget::hasFocus(), except that it counts with the children being focused too.
///i.e: If any child is focused then this FocusScope has focus too.
bool isFocused() const;
///@brief Returns the widget that's focused in this scope
///The widget itself might not have focus as in QWidget::hasFocus(), but will get actual focus
///as soon as this scope is focused.
WidgetType* focusedWidget() const;
///@brief Sets focus on this scope.
///
/// This will call QWidget::focus() on the last QWidget that was focused in this scope.
void focus(Qt::FocusReason = Qt::OtherFocusReason);
/*Q_SIGNALS:*/
///@brief reimplement in the 1st QObject derived class
virtual void isFocusedChanged() = 0;
virtual void focusedWidgetChanged() = 0;
private:
class Private;
Private *const d;
};
}
#endif

View File

@@ -1,51 +1,48 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include "FrameworkWidgetFactory.h"
#include "Frame_p.h"
#include "TitleBar_p.h"
#include "TabWidget_p.h"
#include "multisplitter/Separator_p.h"
#include "FloatingWindow_p.h"
#include "Config.h"
#include "indicators/ClassicIndicators_p.h"
#ifdef KDDOCKWIDGETS_QTWIDGETS
# include "indicators/ClassicIndicators_p.h"
# include "widgets/TabWidget_p.h"
# include "widgets/FrameWidget_p.h"
# include "widgets/TitleBarWidget_p.h"
# include "widgets/TabBarWidget_p.h"
# include "widgets/SideBarWidget_p.h"
# include "widgets/TabWidgetWidget_p.h"
# include "widgets/SeparatorWidget_p.h"
# include "multisplitter/Separator_qwidget.h"
# include "widgets/FloatingWindowWidget_p.h"
# include "indicators/SegmentedIndicators_p.h"
# include <QRubberBand>
# include <QToolButton>
#else
# include "quick/FrameQuick_p.h"
# include "quick/DockWidgetQuick.h"
# include "quick/TitleBarQuick_p.h"
# include "quick/TabBarQuick_p.h"
# include "quick/TabWidgetQuick_p.h"
# include "quick/FloatingWindowQuick_p.h"
# include "quick/SeparatorQuick_p.h"
# include "multisplitter/Separator_quick.h"
#endif
using namespace KDDockWidgets;
DropIndicatorType DefaultWidgetFactory::s_dropIndicatorType = DropIndicatorType::Classic;
FrameworkWidgetFactory::~FrameworkWidgetFactory()
{
}
@@ -76,9 +73,9 @@ TabWidget *DefaultWidgetFactory::createTabWidget(Frame *parent) const
return new TabWidgetWidget(parent);
}
Separator *DefaultWidgetFactory::createSeparator(Anchor *anchor, QWidgetAdapter *parent) const
Layouting::Separator *DefaultWidgetFactory::createSeparator(Layouting::Widget *parent) const
{
return new SeparatorWidget(anchor, parent);
return new Layouting::SeparatorWidget(parent);
}
FloatingWindow *DefaultWidgetFactory::createFloatingWindow(MainWindowBase *parent) const
@@ -93,11 +90,42 @@ FloatingWindow *DefaultWidgetFactory::createFloatingWindow(Frame *frame, MainWin
DropIndicatorOverlayInterface *DefaultWidgetFactory::createDropIndicatorOverlay(DropArea *dropArea) const
{
switch (s_dropIndicatorType) {
case DropIndicatorType::Classic:
return new ClassicIndicators(dropArea);
case DropIndicatorType::Segmented:
return new SegmentedIndicators(dropArea);
}
return new ClassicIndicators(dropArea);
}
QWidgetOrQuick *DefaultWidgetFactory::createRubberBand(QWidgetOrQuick *parent) const
{
return new QRubberBand(QRubberBand::Rectangle, parent);
}
SideBar *DefaultWidgetFactory::createSideBar(SideBarLocation loc, MainWindowBase *parent) const
{
return new SideBarWidget(loc, parent);
}
QAbstractButton* DefaultWidgetFactory::createTitleBarButton(QWidget *parent, TitleBarButtonType type) const
{
if (!parent) {
qWarning() << Q_FUNC_INFO << "Parent not provided";
return nullptr;
}
auto button = new Button(parent);
button->setIcon(iconForButtonType(type, parent->devicePixelRatioF()));
return button;
}
#else
Frame *DefaultWidgetFactory::createFrame(QWidgetOrQuick *parent, Frame::Options options) const
Frame *DefaultWidgetFactory::createFrame(QWidgetOrQuick *parent, FrameOptions options) const
{
return new FrameQuick(parent, options);
}
@@ -112,33 +140,113 @@ TitleBar *DefaultWidgetFactory::createTitleBar(FloatingWindow *fw) const
return new TitleBarQuick(fw);
}
TabBar *DefaultWidgetFactory::createTabBar(TabWidget *tb) const
/*Separator *DefaultWidgetFactory::createSeparator(QWidgetAdapter *parent) const
{
return new TabBarQuick(tb);
}
return new SeparatorQuick(parent);
}*/
TabWidget *DefaultWidgetFactory::createTabWidget(Frame *frame) const
{
return new TabWidgetQuick(frame);
}
Separator *DefaultWidgetFactory::createSeparator(Anchor *anchor, QWidgetAdapter *parent) const
{
return new SeparatorQuick(anchor, parent);
}
FloatingWindow *DefaultWidgetFactory::createFloatingWindow(QWidgetOrQuick *parent) const
FloatingWindow *DefaultWidgetFactory::createFloatingWindow(MainWindowBase *parent) const
{
return new FloatingWindowQuick(parent);
}
FloatingWindow *DefaultWidgetFactory::createFloatingWindow(Frame *frame, QWidgetOrQuick *parent) const
FloatingWindow *DefaultWidgetFactory::createFloatingWindow(Frame *frame, MainWindowBase *parent) const
{
return new FloatingWindowQuick(frame, parent);
}
DropIndicatorOverlayInterface *DefaultWidgetFactory::createDropIndicatorOverlay(DropArea *) const
DropIndicatorOverlayInterface *DefaultWidgetFactory::createDropIndicatorOverlay(DropArea *dropArea) const
{
return new ClassicIndicators(dropArea);
}
TabBar *DefaultWidgetFactory::createTabBar(TabWidget *parent) const
{
Q_UNUSED(parent)
Q_ASSERT(false);
return nullptr;
}
TabWidget *DefaultWidgetFactory::createTabWidget(Frame *parent) const
{
Q_UNUSED(parent)
Q_ASSERT(false);
return nullptr;
}
Layouting::Separator *DefaultWidgetFactory::createSeparator(Layouting::Widget *parent) const
{
return new Layouting::SeparatorQuick(parent);
}
QWidgetOrQuick *DefaultWidgetFactory::createRubberBand(QWidgetOrQuick *parent) const
{
return new QWidgetOrQuick(parent);
}
SideBar *DefaultWidgetFactory::createSideBar(SideBarLocation loc, MainWindowBase *parent) const
{
Q_UNUSED(loc);
Q_UNUSED(parent);
qWarning() << Q_FUNC_INFO << "Not implemented yet";
return nullptr;
}
#endif // QtQuick
// iconForButtonType impl is the same for QtQuick and QtWidgets
QIcon DefaultWidgetFactory::iconForButtonType(TitleBarButtonType type, qreal dpr) const
{
QString iconName;
switch (type) {
case TitleBarButtonType::AutoHide:
iconName = QStringLiteral("auto-hide");
break;
case TitleBarButtonType::UnautoHide:
iconName = QStringLiteral("unauto-hide");
break;
case TitleBarButtonType::Close:
iconName = QStringLiteral("close");
break;
case TitleBarButtonType::Minimize:
iconName = QStringLiteral("min");
break;
case TitleBarButtonType::Maximize:
iconName = QStringLiteral("max");
break;
case TitleBarButtonType::Normal:
// We're using the same icon as dock/float
iconName = QStringLiteral("dock-float");
break;
case TitleBarButtonType::Float:
iconName = QStringLiteral("dock-float");
break;
}
if (iconName.isEmpty())
return {};
QIcon icon(QStringLiteral(":/img/%1.png").arg(iconName));
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
const bool isFractional = int(dpr) != dpr;
if (isFractional) {
// We don't support 1.5x yet.
// Linux is the only one affected as Windows and macOS use integral factors.
// Problem with Linux is that rendering is off due to a rounding bug only fixed in 5.15.2
// Will enable for fractional later.
// QTBUG-86170
return icon;
}
#else
// Not using Qt's sugar syntax, which doesn't support 1.5x anyway when we need it.
// Simply add the high-res files and Qt will pick them when needed
icon.addFile(QStringLiteral(":/img/%1-1.5x.png").arg(iconName));
Q_UNUSED(dpr);
#endif
icon.addFile(QStringLiteral(":/img/%1-2x.png").arg(iconName));
return icon;
}

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#ifndef KDDOCKWIDGETS_FRAMEWORKWIDGETFACTORY_H
@@ -32,17 +23,25 @@
* @author Sérgio Martins \<sergio.martins@kdab.com\>
*/
QT_BEGIN_NAMESPACE
class QAbstractButton;
QT_END_NAMESPACE
namespace Layouting {
class Separator;
class Widget;
}
namespace KDDockWidgets {
class MainWindowBase;
class DropIndicatorOverlayInterface;
class Separator;
class FloatingWindow;
class TabWidget;
class TitleBar;
class Frame;
class DropArea;
class Anchor;
class SideBar;
class TabBar;
/**
@@ -64,17 +63,19 @@ class TabBar;
*/
class DOCKS_EXPORT FrameworkWidgetFactory {
public:
FrameworkWidgetFactory() = default;
///@brief Destructor.Don't delete FrameworkWidgetFactory directly, it's owned
/// by the framework.
virtual ~FrameworkWidgetFactory();
///@brief Called internally by the framework to create a Frame class
//// Override to provide your own Frame sub-class. A frame is the
/// Override to provide your own Frame sub-class. A frame is the
/// widget that holds the titlebar and tab-widget which holds the
/// DockWidgets.
///@param parent just forward to Frame's constructor
///@param options just forward to Frame's constructor
virtual Frame* createFrame(QWidgetOrQuick *parent = nullptr, FrameOptions = FrameOption_None) const = 0;
virtual Frame* createFrame(QWidgetOrQuick *parent = nullptr, FrameOptions options = FrameOption_None) const = 0;
///@brief Called internally by the framework to create a TitleBar
/// Override to provide your own TitleBar sub-class. If overridden then
@@ -101,9 +102,8 @@ public:
///@brief Called internally by the framework to create a Separator
/// Override to provide your own Separator sub-class. The Separator allows
/// the user to resize nested dock widgets.
///@param anchor Just forward to Sepataror's constructor.
///@param parent Just forward to Separator's constructor.
virtual Separator* createSeparator(Anchor *anchor, QWidgetAdapter *parent = nullptr) const = 0;
virtual Layouting::Separator* createSeparator(Layouting::Widget *parent = nullptr) const = 0;
///@brief Called internally by the framework to create a FloatingWindow
/// Override to provide your own FloatingWindow sub-class. If overridden then
@@ -122,6 +122,29 @@ public:
/// Override to provide your own DropIndicatorOverlayInterface sub-class.
///@param dropArea Just forward to DropIndicatorOverlayInterface's constructor.
virtual DropIndicatorOverlayInterface *createDropIndicatorOverlay(DropArea *dropArea) const = 0;
///@brief Called internally by the framework to create a RubberBand to show as drop zone
///Returns a rubber band
virtual QWidgetOrQuick *createRubberBand(QWidgetOrQuick *parent) const = 0;
///@brief Called internally by the framework to create a SideBar
///@param loc The side-bar location without the main window. Just forward into your SideBar sub-class ctor.
///@param parent The MainWindow. Just forward into your SideBar sub-class ctor.
virtual SideBar *createSideBar(SideBarLocation loc, MainWindowBase *parent) const = 0;
#ifdef KDDOCKWIDGETS_QTWIDGETS
///@brief Called internally by the framework to create a title bar button
///@parent the button's parent
virtual QAbstractButton* createTitleBarButton(QWidget *parent, TitleBarButtonType) const = 0;
#else
// QtQuick will have some other base class for buttons
#endif
/// @brief Returns the icon to be used with the specified @p type
/// @param dpr the device pixel ratio of the button
virtual QIcon iconForButtonType(TitleBarButtonType type, qreal dpr) const = 0;
private:
Q_DISABLE_COPY(FrameworkWidgetFactory)
};
/**
@@ -130,15 +153,28 @@ public:
class DOCKS_EXPORT DefaultWidgetFactory : public FrameworkWidgetFactory
{
public:
DefaultWidgetFactory() = default;
Frame *createFrame(QWidgetOrQuick *parent, FrameOptions) const override;
TitleBar *createTitleBar(Frame *) const override;
TitleBar *createTitleBar(FloatingWindow *) const override;
TabBar *createTabBar(TabWidget *parent) const override;
TabWidget *createTabWidget(Frame *parent) const override;
Separator *createSeparator(Anchor *anchor, QWidgetAdapter *parent = nullptr) const override;
Layouting::Separator *createSeparator(Layouting::Widget *parent = nullptr) const override;
FloatingWindow *createFloatingWindow(MainWindowBase *parent = nullptr) const override;
FloatingWindow *createFloatingWindow(Frame *frame, MainWindowBase *parent = nullptr) const override;
DropIndicatorOverlayInterface *createDropIndicatorOverlay(DropArea*) const override;
QWidgetOrQuick *createRubberBand(QWidgetOrQuick *parent) const override;
SideBar *createSideBar(SideBarLocation loc, MainWindowBase *parent) const override;
#ifdef KDDOCKWIDGETS_QTWIDGETS
QAbstractButton* createTitleBarButton(QWidget *parent, TitleBarButtonType) const override;
#endif
QIcon iconForButtonType(TitleBarButtonType type, qreal dpr) const override;
static DropIndicatorType s_dropIndicatorType;
private:
Q_DISABLE_COPY(DefaultWidgetFactory)
};
}

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
/**
@@ -30,6 +21,13 @@
#include <QObject>
#ifdef Q_OS_WIN
// Only on Windows, where this is popular. On linux it the Qt::Tool windows need reparenting. Untested on macOS.
# define KDDOCKWIDGETS_SUPPORTS_NESTED_MAINWINDOWS
#endif
namespace KDDockWidgets
{
enum Location {
@@ -55,7 +53,8 @@ namespace KDDockWidgets
enum FrameOption {
FrameOption_None = 0,
FrameOption_AlwaysShowsTabs = 1,
FrameOption_IsCentralFrame = 2
FrameOption_IsCentralFrame = 2,
FrameOption_IsOverlayed = 4
};
Q_DECLARE_FLAGS(FrameOptions, FrameOption)
@@ -66,63 +65,66 @@ namespace KDDockWidgets
};
Q_DECLARE_FLAGS(RestoreOptions, RestoreOption)
///@internal
inline Location oppositeLocation(Location loc)
{
switch (loc) {
case Location_OnLeft:
return Location_OnRight;
case Location_OnTop:
return Location_OnBottom;
case Location_OnRight:
return Location_OnLeft;
case Location_OnBottom:
return Location_OnTop;
default:
Q_ASSERT(false);
return Location_None;
}
}
///@brief When a widget is added we need to figure out what's a decent size for it
///This enum specifies the different ways to calculate it
enum class DefaultSizeMode {
ItemSize, ///< Simply uses the Item::size() of the item being added. Actual used size might be smaller if our window isn't big enough.
Fair, ///< Gives an equal relative size as the items that are already in the layout
FairButFloor, ///< Equal to fair, but if the item is smaller than the fair suggestion, then that small size is used.
SizePolicy, ///< Uses the item's sizeHint() and sizePolicy()
};
///@internal
inline Location adjacentLocation(Location loc)
{
switch (loc) {
case Location_OnLeft:
return Location_OnTop;
case Location_OnTop:
return Location_OnRight;
case Location_OnRight:
return Location_OnBottom;
case Location_OnBottom:
return Location_OnLeft;
default:
Q_ASSERT(false);
return Location_None;
}
}
enum class DropIndicatorType {
Classic, ///< The default
Segmented
};
///@internal
inline QString locationStr(Location loc)
{
switch (loc) {
case KDDockWidgets::Location_None:
return QStringLiteral("none");
case KDDockWidgets::Location_OnLeft:
return QStringLiteral("left");
case KDDockWidgets::Location_OnTop:
return QStringLiteral("top");
case KDDockWidgets::Location_OnRight:
return QStringLiteral("right");
case KDDockWidgets::Location_OnBottom:
return QStringLiteral("bottom");
}
///@internal
inline QString locationStr(Location loc)
{
switch (loc) {
case KDDockWidgets::Location_None:
return QStringLiteral("none");
case KDDockWidgets::Location_OnLeft:
return QStringLiteral("left");
case KDDockWidgets::Location_OnTop:
return QStringLiteral("top");
case KDDockWidgets::Location_OnRight:
return QStringLiteral("right");
case KDDockWidgets::Location_OnBottom:
return QStringLiteral("bottom");
}
return QString();
}
return QString();
}
/// @brief Each main window supports 4 sidebars
enum class SideBarLocation {
None,
North,
East,
West,
South
};
///@brief describes a type of button you can have in the title bar
enum class TitleBarButtonType {
Close,
Float,
Minimize,
Maximize,
Normal, // Restore from maximized state
AutoHide,
UnautoHide
};
///@internal
inline uint qHash(SideBarLocation loc, uint seed)
{
return ::qHash(static_cast<uint>(loc), seed);
}
}
Q_DECLARE_METATYPE(KDDockWidgets::Location)
Q_DECLARE_OPERATORS_FOR_FLAGS(KDDockWidgets::FrameOptions)
#endif

View File

@@ -1,7 +1,18 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Jean-Michaël Celerier <jean-michael.celerier@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
include(CMakeFindDependencyMacro)
find_dependency(Qt5Widgets REQUIRED)
if (@OPTION_QTQUICK@)
if (@KDDockWidgets_QTQUICK@)
find_dependency(Qt5Quick REQUIRED)
endif()

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
/**
@@ -33,10 +24,10 @@
#include "DropArea_p.h"
#include "Logging_p.h"
#include "Frame_p.h"
#include "LastPosition_p.h"
#include "multisplitter/Anchor_p.h"
#include "Position_p.h"
#include "multisplitter/Item_p.h"
#include "FrameworkWidgetFactory.h"
#include "MainWindowBase.h"
#include <qmath.h>
#include <QDebug>
@@ -51,40 +42,6 @@ using namespace KDDockWidgets;
QHash<QString, LayoutSaver::DockWidget::Ptr> LayoutSaver::DockWidget::s_dockWidgets;
LayoutSaver::Layout* LayoutSaver::Layout::s_currentLayoutBeingRestored = nullptr;
static QVariantMap sizeToMap(QSize sz)
{
QVariantMap map;
map.insert(QStringLiteral("width"), sz.width());
map.insert(QStringLiteral("height"), sz.height());
return map;
}
static QVariantMap rectToMap(QRect rect)
{
QVariantMap map;
map.insert(QStringLiteral("x"), rect.x());
map.insert(QStringLiteral("y"), rect.y());
map.insert(QStringLiteral("width"), rect.width());
map.insert(QStringLiteral("height"), rect.height());
return map;
}
static QSize mapToSize(const QVariantMap &map)
{
return { map.value(QStringLiteral("width")).toInt(),
map.value(QStringLiteral("height")).toInt() };
}
static QRect mapToRect(const QVariantMap &map)
{
return QRect(map.value(QStringLiteral("x")).toInt(),
map.value(QStringLiteral("y")).toInt(),
map.value(QStringLiteral("width")).toInt(),
map.value(QStringLiteral("height")).toInt());
}
class KDDockWidgets::LayoutSaver::Private
{
public:
@@ -109,8 +66,8 @@ public:
{
}
bool matchesAffinity(const QString &affinityName) const {
return m_affinityNames.isEmpty() || affinityName.isEmpty() || m_affinityNames.contains(affinityName);
bool matchesAffinity(const QStringList &affinities) const {
return m_affinityNames.isEmpty() || affinities.isEmpty() || DockRegistry::self()->affinitiesMatch(m_affinityNames, affinities);
}
template <typename T>
@@ -122,11 +79,33 @@ public:
DockRegistry *const m_dockRegistry;
const RestoreOptions m_restoreOptions;
QStringList m_affinityNames;
static bool s_restoreInProgress;
};
bool LayoutSaver::Private::s_restoreInProgress = false;
static QVariantList stringListToVariant(const QStringList &strs)
{
QVariantList variantList;
variantList.reserve(strs.size());
for (const QString &str : strs)
variantList.push_back(str);
return variantList;
}
static QStringList variantToStringList(const QVariantList &variantList)
{
QStringList stringList;
stringList.reserve(variantList.size());
for (const QVariant &variant : variantList)
stringList.push_back(variant.toString());
return stringList;
}
LayoutSaver::LayoutSaver(RestoreOptions options)
: d(new Private(options))
{
@@ -180,14 +159,14 @@ QByteArray LayoutSaver::serializeLayout() const
const MainWindowBase::List mainWindows = d->m_dockRegistry->mainwindows();
layout.mainWindows.reserve(mainWindows.size());
for (MainWindowBase *mainWindow : mainWindows) {
if (d->matchesAffinity(mainWindow->affinityName()))
if (d->matchesAffinity(mainWindow->affinities()))
layout.mainWindows.push_back(mainWindow->serialize());
}
const QVector<KDDockWidgets::FloatingWindow*> floatingWindows = d->m_dockRegistry->nestedwindows();
layout.floatingWindows.reserve(floatingWindows.size());
for (KDDockWidgets::FloatingWindow *floatingWindow : floatingWindows) {
if (d->matchesAffinity(floatingWindow->affinityName()))
if (d->matchesAffinity(floatingWindow->affinities()))
layout.floatingWindows.push_back(floatingWindow->serialize());
}
@@ -195,7 +174,7 @@ QByteArray LayoutSaver::serializeLayout() const
const DockWidgetBase::List closedDockWidgets = d->m_dockRegistry->closedDockwidgets();
layout.closedDockWidgets.reserve(closedDockWidgets.size());
for (DockWidgetBase *dockWidget : closedDockWidgets) {
if (d->matchesAffinity(dockWidget->affinityName()))
if (d->matchesAffinity(dockWidget->affinities()))
layout.closedDockWidgets.push_back(dockWidget->serialize());
}
@@ -205,9 +184,9 @@ QByteArray LayoutSaver::serializeLayout() const
const DockWidgetBase::List dockWidgets = d->m_dockRegistry->dockwidgets();
layout.allDockWidgets.reserve(dockWidgets.size());
for (DockWidgetBase *dockWidget : dockWidgets) {
if (d->matchesAffinity(dockWidget->affinityName())) {
if (d->matchesAffinity(dockWidget->affinities())) {
auto dw = dockWidget->serialize();
dw->lastPosition = dockWidget->lastPosition()->serialize();
dw->lastPosition = dockWidget->lastPositions().serialize();
layout.allDockWidgets.push_back(dw);
}
}
@@ -221,31 +200,6 @@ bool LayoutSaver::restoreLayout(const QByteArray &data)
if (data.isEmpty())
return true;
struct EnsureItemsAtCorrectPlace {
EnsureItemsAtCorrectPlace(LayoutSaver *ls)
: layoutSaver(ls)
{
}
~EnsureItemsAtCorrectPlace()
{
// When using RestoreOption_RelativeToMainWindow we'll have many rounding errors so the layout won't be exact.
// Make sure to run a relayout at the end
// (Using RAII to make sure it runs after Private::RAIIIsRestoring went out of scope, since "isRestoring= true" inhibits relayout
if (ensure) {
for (auto layout : DockRegistry::self()->layouts()) {
if (layoutSaver->d->matchesAffinity(layout->affinityName()))
layout->redistributeSpace();
}
}
}
bool ensure = false;
LayoutSaver *const layoutSaver;
};
EnsureItemsAtCorrectPlace ensureItemsAtCorrectPlace(this);
Private::RAIIIsRestoring isRestoring;
struct FrameCleanup {
@@ -269,21 +223,32 @@ bool LayoutSaver::restoreLayout(const QByteArray &data)
return false;
}
if (!layout.isValid()) {
return false;
}
if (d->m_restoreOptions & RestoreOption_RelativeToMainWindow)
layout.scaleSizes();
// Hide all dockwidgets and unparent them from any layout before starting restore
d->m_dockRegistry->clear(d->m_affinityNames, /*deleteStaticAnchors=*/true);
// We only close the stuff that the loaded JSON knows about. Unknown widgets might be newer.
d->m_dockRegistry->clear(d->m_dockRegistry->dockWidgets(layout.dockWidgetNames()),
d->m_dockRegistry->mainWindows(layout.mainWindowNames()),
d->m_affinityNames);
// 1. Restore main windows
for (const LayoutSaver::MainWindow &mw : qAsConst(layout.mainWindows)) {
MainWindowBase *mainWindow = d->m_dockRegistry->mainWindowByName(mw.uniqueName);
if (!mainWindow) {
qWarning() << "Failed to restore layout create MainWindow with name" << mw.uniqueName << "first";
return false;
if (!mainWindow ) {
if (auto mwFunc = Config::self().mainWindowFactoryFunc()) {
mainWindow = mwFunc(mw.uniqueName);
} else {
qWarning() << "Failed to restore layout create MainWindow with name" << mw.uniqueName << "first";
return false;
}
}
if (!d->matchesAffinity(mainWindow->affinityName()))
if (!d->matchesAffinity(mainWindow->affinities()))
continue;
if (!(d->m_restoreOptions & RestoreOption_RelativeToMainWindow))
@@ -295,7 +260,7 @@ bool LayoutSaver::restoreLayout(const QByteArray &data)
// 2. Restore FloatingWindows
for (const LayoutSaver::FloatingWindow &fw : qAsConst(layout.floatingWindows)) {
if (!d->matchesAffinity(fw.affinityName))
if (!d->matchesAffinity(fw.affinities))
continue;
MainWindowBase *parent = fw.parentIndex == -1 ? nullptr
@@ -304,32 +269,30 @@ bool LayoutSaver::restoreLayout(const QByteArray &data)
auto floatingWindow = Config::self().frameworkWidgetFactory()->createFloatingWindow(parent);
d->deserializeWindowGeometry(fw, floatingWindow);
if (!floatingWindow->deserialize(fw)) {
qWarning() << Q_FUNC_INFO << "Failed to deserialize floating window";
return false;
}
}
// 3. Restore closed dock widgets. They remain closed but acquire geometry and placeholder properties
for (const auto &dw : qAsConst(layout.closedDockWidgets)) {
if (d->matchesAffinity(dw->affinityName)) {
if (d->matchesAffinity(dw->affinities)) {
DockWidgetBase::deserialize(dw);
}
}
// 4. Restore the placeholder info, now that the Items have been created
for (const auto &dw : qAsConst(layout.allDockWidgets)) {
if (!d->matchesAffinity(dw->affinityName))
if (!d->matchesAffinity(dw->affinities))
continue;
if (DockWidgetBase *dockWidget = d->m_dockRegistry->dockByName(dw->uniqueName)) {
dockWidget->lastPosition()->deserialize(dw->lastPosition);
dockWidget->lastPositions().deserialize(dw->lastPosition);
} else {
qWarning() << Q_FUNC_INFO << "Couldn't find dock widget" << dw->uniqueName;
}
}
// our raii class will run when
ensureItemsAtCorrectPlace.ensure = d->m_restoreOptions & RestoreOption_RelativeToMainWindow;
return true;
}
@@ -353,7 +316,6 @@ DockWidgetBase::List LayoutSaver::restoredDockWidgets() const
}
return result;
}
void LayoutSaver::Private::clearRestoredProperty()
@@ -398,6 +360,12 @@ bool LayoutSaver::restoreInProgress()
bool LayoutSaver::Layout::isValid() const
{
if (serializationVersion != KDDOCKWIDGETS_SERIALIZATION_VERSION) {
qWarning() << Q_FUNC_INFO << "Serialization format is too old"
<< serializationVersion << "current=" << KDDOCKWIDGETS_SERIALIZATION_VERSION;
return false;
}
for (auto &m : mainWindows) {
if (!m.isValid())
return false;
@@ -416,20 +384,6 @@ bool LayoutSaver::Layout::isValid() const
return true;
}
bool LayoutSaver::Layout::fillFrom(const QByteArray &serialized)
{
QDataStream ds(serialized);
ds >> this;
if (serializationVersion > KDDOCKWIDGETS_SERIALIZATION_VERSION) {
qWarning() << "Unsupported serialization version. Got=" << serializationVersion
<< "; expected equal or less than" << KDDOCKWIDGETS_SERIALIZATION_VERSION;
return false;
}
return true;
}
QByteArray LayoutSaver::Layout::toJson() const
{
QJsonDocument doc = QJsonDocument::fromVariant(toVariantMap());
@@ -454,7 +408,7 @@ QVariantMap LayoutSaver::Layout::toVariantMap() const
map.insert(QStringLiteral("serializationVersion"), serializationVersion);
map.insert(QStringLiteral("mainWindows"), toVariantList<LayoutSaver::MainWindow>(mainWindows));
map.insert(QStringLiteral("floatingWindows"), toVariantList<LayoutSaver::FloatingWindow>(floatingWindows));
map.insert(QStringLiteral("closedDockWidgets"), dockWidgetNames(closedDockWidgets));
map.insert(QStringLiteral("closedDockWidgets"), ::dockWidgetNames(closedDockWidgets));
map.insert(QStringLiteral("allDockWidgets"), toVariantList(allDockWidgets));
map.insert(QStringLiteral("screenInfo"), toVariantList<LayoutSaver::ScreenInfo>(screenInfo));
@@ -518,66 +472,31 @@ LayoutSaver::MainWindow LayoutSaver::Layout::mainWindowForIndex(int index) const
return mainWindows.at(index);
}
bool LayoutSaver::Item::isValid(const LayoutSaver::MultiSplitterLayout &layout) const
QStringList LayoutSaver::Layout::mainWindowNames() const
{
if (!frame.isValid())
return false;
const int numAnchors = layout.anchors.size();
if (indexOfLeftAnchor < 0 || indexOfTopAnchor < 0 ||
indexOfBottomAnchor < 0 || indexOfRightAnchor < 0 ||
indexOfLeftAnchor >= numAnchors || indexOfTopAnchor >= numAnchors ||
indexOfBottomAnchor >= numAnchors || indexOfRightAnchor >= numAnchors) {
qWarning() << Q_FUNC_INFO << "Invalid anchor indexes"
<< indexOfLeftAnchor << indexOfTopAnchor
<< indexOfBottomAnchor << indexOfRightAnchor;
return false;
QStringList names;
names.reserve(mainWindows.size());
for (const auto &mw : mainWindows) {
names << mw.uniqueName;
}
return true;
return names;
}
void LayoutSaver::Item::scaleSizes(const ScalingInfo &scalingInfo)
QStringList LayoutSaver::Layout::dockWidgetNames() const
{
scalingInfo.applyFactorsTo(geometry);
if (!frame.isNull)
frame.scaleSizes(scalingInfo);
}
QStringList names;
names.reserve(allDockWidgets.size());
for (const auto &dw : allDockWidgets) {
names << dw->uniqueName;
}
QVariantMap LayoutSaver::Item::toVariantMap() const
{
QVariantMap map;
map.insert(QStringLiteral("objectName"), objectName);
map.insert(QStringLiteral("isPlaceholder"), isPlaceholder);
map.insert(QStringLiteral("geometry"), rectToMap(geometry));
map.insert(QStringLiteral("minSize"), sizeToMap(minSize));
map.insert(QStringLiteral("indexOfLeftAnchor"), indexOfLeftAnchor);
map.insert(QStringLiteral("indexOfTopAnchor"), indexOfTopAnchor);
map.insert(QStringLiteral("indexOfRightAnchor"), indexOfRightAnchor);
map.insert(QStringLiteral("indexOfBottomAnchor"), indexOfBottomAnchor);
if (!frame.isNull)
map.insert(QStringLiteral("frame"), frame.toVariantMap());
return map;
}
void LayoutSaver::Item::fromVariantMap(const QVariantMap &map)
{
objectName = map.value(QStringLiteral("objectName")).toString();
isPlaceholder = map.value(QStringLiteral("isPlaceholder")).toBool();
geometry = mapToRect(map.value(QStringLiteral("geometry")).toMap());
minSize = mapToSize(map.value(QStringLiteral("minSize")).toMap());
indexOfLeftAnchor = map.value(QStringLiteral("indexOfLeftAnchor")).toInt();
indexOfTopAnchor = map.value(QStringLiteral("indexOfTopAnchor")).toInt();
indexOfRightAnchor = map.value(QStringLiteral("indexOfRightAnchor")).toInt();
indexOfBottomAnchor = map.value(QStringLiteral("indexOfBottomAnchor")).toInt();
frame.fromVariantMap(map.value(QStringLiteral("frame"), QVariantMap()).toMap());
return names;
}
bool LayoutSaver::Frame::isValid() const
{
if (!isNull)
if (isNull)
return true;
if (!geometry.isValid()) {
@@ -585,14 +504,21 @@ bool LayoutSaver::Frame::isValid() const
return false;
}
if (id.isEmpty()) {
qWarning() << Q_FUNC_INFO << "Invalid id";
return false;
}
if (options > 3) {
qWarning() << Q_FUNC_INFO << "Invalid options" << options;
return false;
}
if (currentTabIndex >= dockWidgets.size() || currentTabIndex < 0) {
qWarning() << Q_FUNC_INFO << "Invalid tab index" << currentTabIndex << dockWidgets.size();
return false;
if (!dockWidgets.isEmpty()) {
if (currentTabIndex >= dockWidgets.size() || currentTabIndex < 0) {
qWarning() << Q_FUNC_INFO << "Invalid tab index" << currentTabIndex << dockWidgets.size();
return false;
}
}
for (auto &dw : dockWidgets) {
@@ -611,9 +537,10 @@ void LayoutSaver::Frame::scaleSizes(const ScalingInfo &scalingInfo)
QVariantMap LayoutSaver::Frame::toVariantMap() const
{
QVariantMap map;
map.insert(QStringLiteral("id"), id);
map.insert(QStringLiteral("isNull"), isNull);
map.insert(QStringLiteral("objectName"), objectName);
map.insert(QStringLiteral("geometry"), rectToMap(geometry));
map.insert(QStringLiteral("geometry"), Layouting::rectToMap(geometry));
map.insert(QStringLiteral("options"), options);
map.insert(QStringLiteral("currentTabIndex"), currentTabIndex);
@@ -630,13 +557,14 @@ void LayoutSaver::Frame::fromVariantMap(const QVariantMap &map)
return;
}
id = map.value(QStringLiteral("id")).toString();
isNull = map.value(QStringLiteral("isNull")).toBool();
objectName = map.value(QStringLiteral("objectName")).toString();
geometry = mapToRect(map.value(QStringLiteral("geometry")).toMap());
geometry = Layouting::mapToRect(map.value(QStringLiteral("geometry")).toMap());
options = map.value(QStringLiteral("options")).toUInt();
currentTabIndex = map.value(QStringLiteral("currentTabIndex")).toInt();
QVariantList dockWidgetsV = map.value(QStringLiteral("dockWidgets")).toList();
const QVariantList dockWidgetsV = map.value(QStringLiteral("dockWidgets")).toList();
dockWidgets.clear();
dockWidgets.reserve(dockWidgetsV.size());
@@ -659,8 +587,8 @@ void LayoutSaver::DockWidget::scaleSizes(const ScalingInfo &scalingInfo)
QVariantMap LayoutSaver::DockWidget::toVariantMap() const
{
QVariantMap map;
if (!affinityName.isEmpty())
map.insert(QStringLiteral("affinityName"), affinityName);
if (!affinities.isEmpty())
map.insert(QStringLiteral("affinities"), stringListToVariant(affinities));
map.insert(QStringLiteral("uniqueName"), uniqueName);
map.insert(QStringLiteral("lastPosition"), lastPosition.toVariantMap());
@@ -669,125 +597,18 @@ QVariantMap LayoutSaver::DockWidget::toVariantMap() const
void LayoutSaver::DockWidget::fromVariantMap(const QVariantMap &map)
{
affinityName = map.value(QStringLiteral("affinityName")).toString();
affinities = variantToStringList(map.value(QStringLiteral("affinities")).toList());
// Compatibility hack. Old json format had a single "affinityName" instead of an "affinities" list:
const QString affinityName = map.value(QStringLiteral("affinityName")).toString();
if (!affinityName.isEmpty() && !affinities.contains(affinityName)) {
affinities.push_back(affinityName);
}
uniqueName = map.value(QStringLiteral("uniqueName")).toString();
lastPosition.fromVariantMap(map.value(QStringLiteral("lastPosition")).toMap());
}
bool LayoutSaver::Anchor::isValid(const LayoutSaver::MultiSplitterLayout &layout) const
{
const bool isStatic = type != KDDockWidgets::Anchor::Type_None;
const bool isFollowing = indexOfFollowee != -1;
const int numAnchors = layout.anchors.size();
if (!geometry.isValid() && !isStatic && !isFollowing) {
qWarning() << Q_FUNC_INFO << "Invalid geometry" << geometry;
return false;
}
if (indexOfFrom < 0 || indexOfTo < 0 || indexOfFrom == indexOfTo ||
indexOfTo >= numAnchors || indexOfFrom >= numAnchors) {
qWarning() << Q_FUNC_INFO << "Invalid indexes" << indexOfFrom << indexOfTo;
return false;
}
auto &anchorTo = layout.anchors[indexOfTo];
auto &anchorFrom = layout.anchors[indexOfFrom];
if (anchorTo.orientation != anchorFrom.orientation || anchorTo.orientation == orientation) {
qWarning() << Q_FUNC_INFO << "Invalid orientation" << anchorTo.orientation << anchorFrom.orientation
<< orientation;
return false;
}
if (orientation != Qt::Vertical && orientation != Qt::Horizontal) {
qWarning() << Q_FUNC_INFO << "Invalid orientation" << orientation;
return false;
}
if (type != KDDockWidgets::Anchor::Type_None &&
type != KDDockWidgets::Anchor::Type_LeftStatic &&
type != KDDockWidgets::Anchor::Type_RightStatic &&
type != KDDockWidgets::Anchor::Type_TopStatic &&
type != KDDockWidgets::Anchor::Type_BottomStatic) {
qWarning() << Q_FUNC_INFO << "Invalid type" << type;
return false;
}
if (!isStatic && !isFollowing && (side1Items.isEmpty() || side2Items.isEmpty())) {
qWarning() << Q_FUNC_INFO << "Anchor should have items on both sides";
return false;
}
return true;
}
QVariantMap LayoutSaver::Anchor::toVariantMap() const
{
QVariantMap map;
map.insert(QStringLiteral("objectName"), objectName);
map.insert(QStringLiteral("geometry"), rectToMap(geometry));
map.insert(QStringLiteral("orientation"), orientation);
map.insert(QStringLiteral("type"), type);
map.insert(QStringLiteral("indexOfFrom"), indexOfFrom);
map.insert(QStringLiteral("indexOfTo"), indexOfTo);
map.insert(QStringLiteral("indexOfFollowee"), indexOfFollowee);
map.insert(QStringLiteral("positionPercentage"), positionPercentage);
QVariantList side1ItemsV;
QVariantList side2ItemsV;
side1ItemsV.reserve(side1Items.size());
side2ItemsV.reserve(side2Items.size());
for (int index : qAsConst(side1Items))
side1ItemsV.push_back(index);
for (int index : qAsConst(side2Items))
side2ItemsV.push_back(index);
map.insert(QStringLiteral("side1Items"), side1ItemsV);
map.insert(QStringLiteral("side2Items"), side2ItemsV);
return map;
}
void LayoutSaver::Anchor::fromVariantMap(const QVariantMap &map)
{
objectName = map.value(QStringLiteral("objectName")).toString();
geometry = mapToRect(map.value(QStringLiteral("geometry")).toMap());
orientation = map.value(QStringLiteral("orientation")).toInt();
type = map.value(QStringLiteral("type")).toInt();
indexOfFrom = map.value(QStringLiteral("indexOfFrom")).toInt();
indexOfTo = map.value(QStringLiteral("indexOfTo")).toInt();
indexOfFollowee = map.value(QStringLiteral("indexOfFollowee")).toInt();
positionPercentage = map.value(QStringLiteral("positionPercentage")).toDouble();
side1Items.clear();
side2Items.clear();
const QVariantList side1ItemsV = map.value(QStringLiteral("side1Items")).toList();
const QVariantList side2ItemsV = map.value(QStringLiteral("side2Items")).toList();
side1Items.reserve(side1ItemsV.size());
side2Items.reserve(side2ItemsV.size());
for (const QVariant &v : side1ItemsV)
side1Items.push_back(v.toInt());
for (const QVariant &v : side2ItemsV)
side2Items.push_back(v.toInt());
}
void LayoutSaver::Anchor::scaleSizes(const ScalingInfo &scalingInfo)
{
const QPoint pos = geometry.topLeft();
if (isVertical()) {
geometry.moveLeft(int(pos.x() * scalingInfo.widthFactor));
} else {
geometry.moveTop(int(pos.y() * scalingInfo.heightFactor));
}
}
bool LayoutSaver::Anchor::isVertical() const
{
return orientation == Qt::Vertical;
}
bool LayoutSaver::FloatingWindow::isValid() const
{
if (!multiSplitterLayout.isValid())
@@ -812,13 +633,13 @@ QVariantMap LayoutSaver::FloatingWindow::toVariantMap() const
QVariantMap map;
map.insert(QStringLiteral("multiSplitterLayout"), multiSplitterLayout.toVariantMap());
map.insert(QStringLiteral("parentIndex"), parentIndex);
map.insert(QStringLiteral("geometry"), rectToMap(geometry));
map.insert(QStringLiteral("geometry"), Layouting::rectToMap(geometry));
map.insert(QStringLiteral("screenIndex"), screenIndex);
map.insert(QStringLiteral("screenSize"), sizeToMap(screenSize));
map.insert(QStringLiteral("screenSize"), Layouting::sizeToMap(screenSize));
map.insert(QStringLiteral("isVisible"), isVisible);
if (!affinityName.isEmpty())
map.insert(QStringLiteral("affinityName"), affinityName);
if (!affinities.isEmpty())
map.insert(QStringLiteral("affinities"), stringListToVariant(affinities));
return map;
}
@@ -827,11 +648,17 @@ void LayoutSaver::FloatingWindow::fromVariantMap(const QVariantMap &map)
{
multiSplitterLayout.fromVariantMap(map.value(QStringLiteral("multiSplitterLayout")).toMap());
parentIndex = map.value(QStringLiteral("parentIndex")).toInt();
geometry = mapToRect(map.value(QStringLiteral("geometry")).toMap());
geometry = Layouting::mapToRect(map.value(QStringLiteral("geometry")).toMap());
screenIndex = map.value(QStringLiteral("screenIndex")).toInt();
screenSize = mapToSize(map.value(QStringLiteral("screenSize")).toMap());
screenSize = Layouting::mapToSize(map.value(QStringLiteral("screenSize")).toMap());
isVisible = map.value(QStringLiteral("isVisible")).toBool();
affinityName = map.value(QStringLiteral("affinityName")).toString();
affinities = variantToStringList(map.value(QStringLiteral("affinities")).toList());
// Compatibility hack. Old json format had a single "affinityName" instead of an "affinities" list:
const QString affinityName = map.value(QStringLiteral("affinityName")).toString();
if (!affinityName.isEmpty() && !affinities.contains(affinityName)) {
affinities.push_back(affinityName);
}
}
bool LayoutSaver::MainWindow::isValid() const
@@ -867,13 +694,11 @@ QVariantMap LayoutSaver::MainWindow::toVariantMap() const
map.insert(QStringLiteral("options"), int(options));
map.insert(QStringLiteral("multiSplitterLayout"), multiSplitterLayout.toVariantMap());
map.insert(QStringLiteral("uniqueName"), uniqueName);
map.insert(QStringLiteral("geometry"), rectToMap(geometry));
map.insert(QStringLiteral("geometry"), Layouting::rectToMap(geometry));
map.insert(QStringLiteral("screenIndex"), screenIndex);
map.insert(QStringLiteral("screenSize"), sizeToMap(screenSize));
map.insert(QStringLiteral("screenSize"), Layouting::sizeToMap(screenSize));
map.insert(QStringLiteral("isVisible"), isVisible);
if (!affinityName.isEmpty())
map.insert(QStringLiteral("affinityName"), affinityName);
map.insert(QStringLiteral("affinities"), stringListToVariant(affinities));
return map;
}
@@ -883,72 +708,74 @@ void LayoutSaver::MainWindow::fromVariantMap(const QVariantMap &map)
options = KDDockWidgets::MainWindowOptions(map.value(QStringLiteral("options")).toInt());
multiSplitterLayout.fromVariantMap(map.value(QStringLiteral("multiSplitterLayout")).toMap());
uniqueName = map.value(QStringLiteral("uniqueName")).toString();
affinityName = map.value(QStringLiteral("affinityName")).toString();
geometry = mapToRect(map.value(QStringLiteral("geometry")).toMap());
geometry = Layouting::mapToRect(map.value(QStringLiteral("geometry")).toMap());
screenIndex = map.value(QStringLiteral("screenIndex")).toInt();
screenSize = mapToSize(map.value(QStringLiteral("screenSize")).toMap());
screenSize = Layouting::mapToSize(map.value(QStringLiteral("screenSize")).toMap());
isVisible = map.value(QStringLiteral("isVisible")).toBool();
affinities = variantToStringList(map.value(QStringLiteral("affinities")).toList());
// Compatibility hack. Old json format had a single "affinityName" instead of an "affinities" list:
const QString affinityName = map.value(QStringLiteral("affinityName")).toString();
if (!affinityName.isEmpty() && !affinities.contains(affinityName)) {
affinities.push_back(affinityName);
}
}
bool LayoutSaver::MultiSplitterLayout::isValid() const
bool LayoutSaver::MultiSplitter::isValid() const
{
for (auto &item : items) {
if (!item.isValid(*this))
return false;
}
if (layout.isEmpty())
return false;
for (auto &anchor : anchors) {
if (!anchor.isValid(*this))
return false;
}
if (!size.isValid()) {
/*if (!size.isValid()) {
qWarning() << Q_FUNC_INFO << "Invalid size";
return false;
}
}*/
return true;
}
void LayoutSaver::MultiSplitterLayout::scaleSizes(const ScalingInfo &scalingInfo)
void LayoutSaver::MultiSplitter::scaleSizes(const ScalingInfo &)
{
scalingInfo.applyFactorsTo(/*by-ref*/size);
for (LayoutSaver::Anchor &anchor : anchors)
anchor.scaleSizes(scalingInfo);
for (LayoutSaver::Item &item : items)
item.scaleSizes(scalingInfo);
// scalingInfo.applyFactorsTo(/*by-ref*/size);
//for (LayoutSaver::Item &item : items) TODO
// item.scaleSizes(scalingInfo);
}
QVariantMap LayoutSaver::MultiSplitterLayout::toVariantMap() const
QVariantMap LayoutSaver::MultiSplitter::toVariantMap() const
{
QVariantMap map;
QVariantMap result;
result.insert(QStringLiteral("layout"), layout);
map.insert(QStringLiteral("anchors"), toVariantList<LayoutSaver::Anchor>(anchors));
map.insert(QStringLiteral("items"), toVariantList<LayoutSaver::Item>(items));
map.insert(QStringLiteral("minSize"), sizeToMap(minSize));
map.insert(QStringLiteral("size"), sizeToMap(size));
QVariantMap framesV;
for (auto &frame : frames)
framesV.insert(frame.id, frame.toVariantMap());
return map;
result.insert(QStringLiteral("frames"), framesV);
return result;
}
void LayoutSaver::MultiSplitterLayout::fromVariantMap(const QVariantMap &map)
void LayoutSaver::MultiSplitter::fromVariantMap(const QVariantMap &map)
{
anchors = fromVariantList<LayoutSaver::Anchor>(map.value(QStringLiteral("anchors")).toList());
items = fromVariantList<LayoutSaver::Item>(map.value(QStringLiteral("items")).toList());
minSize = mapToSize(map.value(QStringLiteral("minSize")).toMap());
size = mapToSize(map.value(QStringLiteral("size")).toMap());
layout = map.value(QStringLiteral("layout")).toMap();
const QVariantMap framesV = map.value(QStringLiteral("frames")).toMap();
frames.clear();
for (const QVariant &frameV : framesV) {
LayoutSaver::Frame frame;
frame.fromVariantMap(frameV.toMap());
frames.insert(frame.id, frame);
}
}
void LayoutSaver::LastPosition::scaleSizes(const ScalingInfo &scalingInfo)
void LayoutSaver::Position::scaleSizes(const ScalingInfo &scalingInfo)
{
scalingInfo.applyFactorsTo(/*by-ref*/lastFloatingGeometry);
}
QVariantMap LayoutSaver::LastPosition::toVariantMap() const
QVariantMap LayoutSaver::Position::toVariantMap() const
{
QVariantMap map;
map.insert(QStringLiteral("lastFloatingGeometry"), rectToMap(lastFloatingGeometry));
map.insert(QStringLiteral("lastFloatingGeometry"), Layouting::rectToMap(lastFloatingGeometry));
map.insert(QStringLiteral("tabIndex"), tabIndex);
map.insert(QStringLiteral("wasFloating"), wasFloating);
map.insert(QStringLiteral("placeholders"), toVariantList<LayoutSaver::Placeholder>(placeholders));
@@ -956,9 +783,9 @@ QVariantMap LayoutSaver::LastPosition::toVariantMap() const
return map;
}
void LayoutSaver::LastPosition::fromVariantMap(const QVariantMap &map)
void LayoutSaver::Position::fromVariantMap(const QVariantMap &map)
{
lastFloatingGeometry = mapToRect(map.value(QStringLiteral("lastFloatingGeometry")).toMap());
lastFloatingGeometry = Layouting::mapToRect(map.value(QStringLiteral("lastFloatingGeometry")).toMap());
tabIndex = map.value(QStringLiteral("tabIndex")).toInt();
wasFloating = map.value(QStringLiteral("wasFloating")).toBool();
placeholders = fromVariantList<LayoutSaver::Placeholder>(map.value(QStringLiteral("placeholders")).toList());
@@ -968,7 +795,7 @@ QVariantMap LayoutSaver::ScreenInfo::toVariantMap() const
{
QVariantMap map;
map.insert(QStringLiteral("index"), index);
map.insert(QStringLiteral("geometry"), rectToMap(geometry));
map.insert(QStringLiteral("geometry"), Layouting::rectToMap(geometry));
map.insert(QStringLiteral("name"), name);
map.insert(QStringLiteral("devicePixelRatio"), devicePixelRatio);
@@ -978,7 +805,7 @@ QVariantMap LayoutSaver::ScreenInfo::toVariantMap() const
void LayoutSaver::ScreenInfo::fromVariantMap(const QVariantMap &map)
{
index = map.value(QStringLiteral("index")).toInt();
geometry = mapToRect(map.value(QStringLiteral("geometry")).toMap());
geometry = Layouting::mapToRect(map.value(QStringLiteral("geometry")).toMap());
name = map.value(QStringLiteral("name")).toString();
devicePixelRatio = map.value(QStringLiteral("devicePixelRatio")).toDouble();
}

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#ifndef KD_LAYOUTSAVER_H
@@ -54,14 +45,14 @@ public:
/**
* @brief saves the layout to JSON file
* @brief jsonFilename the filename where the layout will be saved to
* @param jsonFilename the filename where the layout will be saved to
* @return true on success
*/
bool saveToFile(const QString &jsonFilename);
/**
* @brief restores the layout from a JSON file
* @brief jsonFilename the filename containing a saved layout
* @param jsonFilename the filename containing a saved layout
* @return true on success
*/
bool restoreFromFile(const QString &jsonFilename);
@@ -87,7 +78,7 @@ public:
/**
* @brief returns a list of dock widgets which were restored since the last
* @ref restoreLayout() or @ref restoreFromDisk()
* @ref restoreLayout() or @ref restoreFromFile()
*
* Useful since some dock widgets can be new, and hence not be included in the last saved layout.
*/
@@ -106,16 +97,14 @@ public:
struct MainWindow;
struct FloatingWindow;
struct DockWidget;
struct LastPosition;
struct MultiSplitterLayout;
struct Item;
struct Anchor;
struct Position;
struct MultiSplitter;
struct Frame;
struct Placeholder;
struct ScalingInfo;
struct ScreenInfo;
private:
Q_DISABLE_COPY(LayoutSaver)
friend class TestDocks;
class Private;

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#ifndef KD_LAYOUTSAVER_P_H
@@ -25,7 +16,6 @@
#include "KDDockWidgets.h"
#include <QRect>
#include <QDataStream>
#include <QDebug>
#include <QScreen>
#include <QApplication>
@@ -33,15 +23,15 @@
#include <memory>
#define ANCHOR_MAGIC_MARKER "e520c60e-cf5d-4a30-b1a7-588d2c569851"
#define MULTISPLITTER_LAYOUT_MAGIC_MARKER "bac9948e-5f1b-4271-acc5-07f1708e2611"
/**
* Bump whenever the format changes, so we can still load old layouts.
* version 1: Initial version
* version 2: Introduced MainWindow::screenSize and FloatingWindow::screenSize
* version 3: New layouting engine
*/
#define KDDOCKWIDGETS_SERIALIZATION_VERSION 2
#define KDDOCKWIDGETS_SERIALIZATION_VERSION 3
namespace KDDockWidgets {
@@ -108,14 +98,14 @@ struct LayoutSaver::ScalingInfo
double widthFactor = -1;
};
struct LayoutSaver::LastPosition
struct LayoutSaver::Position
{
QRect lastFloatingGeometry;
int tabIndex;
bool wasFloating;
LayoutSaver::Placeholder::List placeholders;
/// Iterates throught the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
/// Iterates through the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
void scaleSizes(const ScalingInfo &scalingInfo);
QVariantMap toVariantMap() const;
@@ -131,7 +121,7 @@ struct DOCKS_EXPORT LayoutSaver::DockWidget
bool isValid() const;
/// Iterates throught the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
/// Iterates through the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
void scaleSizes(const ScalingInfo &scalingInfo);
static Ptr dockWidgetForName(const QString &name)
@@ -151,8 +141,8 @@ struct DOCKS_EXPORT LayoutSaver::DockWidget
void fromVariantMap(const QVariantMap &map);
QString uniqueName;
QString affinityName;
LayoutSaver::LastPosition lastPosition;
QStringList affinities;
LayoutSaver::Position lastPosition;
private:
DockWidget() {}
@@ -183,7 +173,7 @@ struct LayoutSaver::Frame
{
bool isValid() const;
/// Iterates throught the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
/// Iterates through the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
void scaleSizes(const ScalingInfo &scalingInfo);
QVariantMap toVariantMap() const;
@@ -194,69 +184,22 @@ struct LayoutSaver::Frame
QRect geometry;
unsigned int options;
int currentTabIndex;
QString id; // for coorelation purposes
LayoutSaver::DockWidget::List dockWidgets;
};
struct LayoutSaver::Item
{
typedef QVector<LayoutSaver::Item> List;
bool isValid(const MultiSplitterLayout &) const;
/// Iterates throught the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
void scaleSizes(const ScalingInfo &scalingInfo);
QVariantMap toVariantMap() const;
void fromVariantMap(const QVariantMap &map);
QString objectName;
bool isPlaceholder;
QRect geometry;
QSize minSize;
int indexOfLeftAnchor;
int indexOfTopAnchor;
int indexOfRightAnchor;
int indexOfBottomAnchor;
LayoutSaver::Frame frame;
};
struct LayoutSaver::Anchor
{
typedef QVector<LayoutSaver::Anchor> List;
bool isValid(const LayoutSaver::MultiSplitterLayout &layout) const;
QVariantMap toVariantMap() const;
void fromVariantMap(const QVariantMap &map);
void scaleSizes(const ScalingInfo &);
bool isVertical() const;
QString objectName;
QRect geometry;
double positionPercentage;
int orientation;
int type;
int indexOfFrom;
int indexOfTo;
int indexOfFollowee;
QVector<int> side1Items;
QVector<int> side2Items;
};
struct LayoutSaver::MultiSplitterLayout
struct LayoutSaver::MultiSplitter
{
bool isValid() const;
/// Iterates throught the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
/// Iterates through the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
void scaleSizes(const ScalingInfo &scalingInfo);
QVariantMap toVariantMap() const;
void fromVariantMap(const QVariantMap &map);
LayoutSaver::Anchor::List anchors;
LayoutSaver::Item::List items;
QSize minSize;
QSize size;
QVariantMap layout;
QHash<QString, LayoutSaver::Frame> frames;
};
struct LayoutSaver::FloatingWindow
@@ -265,14 +208,14 @@ struct LayoutSaver::FloatingWindow
bool isValid() const;
/// Iterates throught the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
/// Iterates through the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
void scaleSizes(const ScalingInfo &);
QVariantMap toVariantMap() const;
void fromVariantMap(const QVariantMap &map);
LayoutSaver::MultiSplitterLayout multiSplitterLayout;
QString affinityName;
LayoutSaver::MultiSplitter multiSplitterLayout;
QStringList affinities;
int parentIndex = -1;
QRect geometry;
int screenIndex;
@@ -287,16 +230,16 @@ public:
bool isValid() const;
/// Iterates throught the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
/// Iterates through the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
void scaleSizes();
QVariantMap toVariantMap() const;
void fromVariantMap(const QVariantMap &map);
KDDockWidgets::MainWindowOptions options;
LayoutSaver::MultiSplitterLayout multiSplitterLayout;
LayoutSaver::MultiSplitter multiSplitterLayout;
QString uniqueName;
QString affinityName;
QStringList affinities;
QRect geometry;
int screenIndex;
QSize screenSize; // for relative-size restoring
@@ -344,266 +287,31 @@ public:
bool isValid() const;
bool fillFrom(const QByteArray &serialized);
QByteArray toJson() const;
bool fromJson(const QByteArray &jsonData);
QVariantMap toVariantMap() const;
void fromVariantMap(const QVariantMap &map);
/// Iterates throught the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
/// Iterates through the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
void scaleSizes();
friend QDataStream &operator>>(QDataStream &ds, LayoutSaver::Frame *frame);
static LayoutSaver::Layout* s_currentLayoutBeingRestored;
LayoutSaver::MainWindow mainWindowForIndex(int index) const;
QStringList mainWindowNames() const;
QStringList dockWidgetNames() const;
int serializationVersion = KDDOCKWIDGETS_SERIALIZATION_VERSION;
LayoutSaver::MainWindow::List mainWindows;
LayoutSaver::FloatingWindow::List floatingWindows;
LayoutSaver::DockWidget::List closedDockWidgets;
LayoutSaver::DockWidget::List allDockWidgets;
ScreenInfo::List screenInfo;
private:
Q_DISABLE_COPY(Layout)
};
inline QDataStream &operator>>(QDataStream &ds, LayoutSaver::ScreenInfo *info)
{
ds >> info->index;
ds >> info->geometry;
ds >> info->name;
ds >> info->devicePixelRatio;
return ds;
}
inline QDataStream &operator>>(QDataStream &ds, LayoutSaver::Placeholder *p)
{
ds >> p->isFloatingWindow;
if (p->isFloatingWindow)
ds >> p->indexOfFloatingWindow;
else
ds >> p->mainWindowUniqueName;
ds >> p->itemIndex;
return ds;
}
inline QDataStream &operator>>(QDataStream &ds, LayoutSaver::Anchor *a)
{
QString marker;
ds >> marker;
if (marker != QLatin1String(ANCHOR_MAGIC_MARKER))
qWarning() << Q_FUNC_INFO << "Corrupt stream";
ds >> a->objectName;
ds >> a->geometry;
ds >> a->orientation;
ds >> a->type;
ds >> a->indexOfFrom;
ds >> a->indexOfTo;
ds >> a->indexOfFollowee;
ds >> a->side1Items;
ds >> a->side2Items;
return ds;
}
inline QDataStream &operator>>(QDataStream &ds, LayoutSaver::Frame *frame)
{
int numDockWidgets;
frame->dockWidgets.clear();
frame->isNull = false;
ds >> frame->objectName;
ds >> frame->geometry;
if (LayoutSaver::Layout::s_currentLayoutBeingRestored->serializationVersion >= 2) {
QSize sz;
ds >> sz; // deprecated field, just discard
}
ds >> frame->options;
ds >> frame->currentTabIndex;
ds >> numDockWidgets;
for (int i = 0; i < numDockWidgets; ++i) {
QString name;
ds >> name;
auto dw = LayoutSaver::DockWidget::dockWidgetForName(name);
frame->dockWidgets.push_back(dw);
}
return ds;
}
inline QDataStream &operator>>(QDataStream &ds, LayoutSaver::Item *item)
{
ds >> item->objectName;
ds >> item->isPlaceholder;
ds >> item->geometry;
ds >> item->minSize;
ds >> item->indexOfLeftAnchor;
ds >> item->indexOfTopAnchor;
ds >> item->indexOfRightAnchor;
ds >> item->indexOfBottomAnchor;
bool hasFrame;
ds >> hasFrame;
if (hasFrame) {
ds >> &item->frame;
item->frame.isNull = false;
} else {
item->frame.isNull = true;
}
return ds;
}
inline QDataStream &operator>>(QDataStream &ds, LayoutSaver::MultiSplitterLayout *l)
{
int numItems;
int numAnchors;
QString marker;
ds >> marker;
if (marker != QLatin1String(MULTISPLITTER_LAYOUT_MAGIC_MARKER))
qWarning() << Q_FUNC_INFO << "Corrupt stream, invalid magic";
ds >> l->size;
ds >> l->minSize;
ds >> numItems;
ds >> numAnchors;
l->items.clear();
l->anchors.clear();
for (int i = 0 ; i < numItems; ++i) {
LayoutSaver::Item item;
ds >> &item;
l->items.push_back(item);
}
for (int i = 0 ; i < numAnchors; ++i) {
LayoutSaver::Anchor a;
ds >> &a;
l->anchors.push_back(a);
}
return ds;
}
inline QDataStream &operator>>(QDataStream &ds, LayoutSaver::LastPosition *lp)
{
int numPlaceholders;
ds >> numPlaceholders;
lp->placeholders.clear();
for (int i = 0 ; i < numPlaceholders; ++i) {
LayoutSaver::Placeholder p;
ds >> &p;
lp->placeholders.push_back(p);
}
ds >> lp->lastFloatingGeometry;
ds >> lp->tabIndex;
ds >> lp->wasFloating;
return ds;
}
inline QDataStream &operator>>(QDataStream &ds, LayoutSaver::FloatingWindow *fw)
{
ds >> fw->parentIndex;
ds >> fw->geometry;
if (LayoutSaver::Layout::s_currentLayoutBeingRestored->serializationVersion >= 2) {
ds >> fw->screenIndex;
ds >> fw->screenSize;
}
ds >> fw->isVisible;
ds >> &fw->multiSplitterLayout;
return ds;
}
inline QDataStream &operator>>(QDataStream &ds, LayoutSaver::MainWindow *m)
{
ds >> m->uniqueName;
ds >> m->geometry;
if (LayoutSaver::Layout::s_currentLayoutBeingRestored->serializationVersion >= 2) {
ds >> m->screenIndex;
ds >> m->screenSize;
}
ds >> m->isVisible;
ds >> m->options;
ds >> &m->multiSplitterLayout;
return ds;
}
inline QDataStream &operator>>(QDataStream &ds, LayoutSaver::Layout *l)
{
LayoutSaver::DockWidget::s_dockWidgets.clear();
int numMainWindows;
int numFloatingWindows;
int numClosedDockWidgets;
int numAllDockWidgets;
int numScreenInfo;
ds >> l->serializationVersion;
ds >> numMainWindows;
l->mainWindows.clear();
for (int i = 0; i < numMainWindows; ++i) {
LayoutSaver::MainWindow m;
ds >> &m;
l->mainWindows.push_back(m);
}
ds >> numFloatingWindows;
l->floatingWindows.clear();
for (int i = 0; i < numFloatingWindows; ++i) {
LayoutSaver::FloatingWindow m;
ds >> &m;
l->floatingWindows.push_back(m);
}
ds >> numClosedDockWidgets;
l->closedDockWidgets.clear();
for (int i = 0; i < numClosedDockWidgets; ++i) {
QString name;
ds >> name;
auto dw = LayoutSaver::DockWidget::dockWidgetForName(name);
l->closedDockWidgets.push_back(dw);
}
ds >> numAllDockWidgets;
l->allDockWidgets.clear();
for (int i = 0; i < numAllDockWidgets; ++i) {
QString name;
ds >> name;
auto dw = LayoutSaver::DockWidget::dockWidgetForName(name);
ds >> &dw->lastPosition;
l->allDockWidgets.push_back(dw);
}
if (LayoutSaver::Layout::s_currentLayoutBeingRestored->serializationVersion >= 2) {
ds >> numScreenInfo;
l->screenInfo.clear();
l->screenInfo.reserve(numScreenInfo);
for (int i = 0; i < numScreenInfo; ++i) {
LayoutSaver::ScreenInfo info;
ds >> &info;
l->screenInfo.push_back(info);
}
}
return ds;
}
}
#endif

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
/**
@@ -26,12 +17,13 @@
*/
#include "MainWindow.h"
#include "Config.h"
#include "DropArea_p.h"
#include "Frame_p.h"
#include "Logging_p.h"
#include "SideBar_p.h"
#include "DropAreaWithCentralFrame_p.h"
#include "multisplitter/MultiSplitterLayout_p.h"
#include "multisplitter/MultiSplitter_p.h"
#include "FrameworkWidgetFactory.h"
#include <QApplication>
#include <QVBoxLayout>
@@ -42,15 +34,22 @@ using namespace KDDockWidgets;
class MainWindow::Private
{
public:
explicit Private(MainWindowOptions options, MainWindowBase *mainWindow)
: m_dropArea(new DropAreaWithCentralFrame(mainWindow, options))
explicit Private(MainWindowOptions, MainWindowBase *mainWindow)
: m_supportsAutoHide(Config::self().flags() & Config::Flag_AutoHideSupport)
{
if (m_supportsAutoHide) {
for (auto location : { SideBarLocation::North, SideBarLocation::East,
SideBarLocation::West, SideBarLocation::South}) {
m_sideBars.insert(location, Config::self().frameworkWidgetFactory()->createSideBar(location, mainWindow) );
}
}
}
DropAreaWithCentralFrame *const m_dropArea;
const bool m_supportsAutoHide;
QHash<SideBarLocation, SideBar*> m_sideBars;
};
namespace KDDockWidgets {
class MyCentralWidget : public QWidget
{
@@ -81,9 +80,24 @@ MainWindow::MainWindow(const QString &name, MainWindowOptions options,
, d(new Private(options, this))
{
auto centralWidget = new MyCentralWidget(this);
auto layout = new QVBoxLayout(centralWidget);
layout->setContentsMargins(1, 5, 1, 1);
layout->addWidget(dropArea()); // 1 level of indirection so we can add some margins
auto layout = new QHBoxLayout(centralWidget); // 1 level of indirection so we can add some margins
layout->setSpacing(0);
layout->setContentsMargins(centerWidgetMargins());
if (d->m_supportsAutoHide) {
layout->addWidget(sideBar(SideBarLocation::West));
auto innerVLayout = new QVBoxLayout();
innerVLayout->setSpacing(0);
innerVLayout->setContentsMargins(0, 0, 0, 0);
innerVLayout->addWidget(sideBar(SideBarLocation::North));
innerVLayout->addWidget(dropArea());
innerVLayout->addWidget(sideBar(SideBarLocation::South));
layout->addLayout(innerVLayout);
layout->addWidget(sideBar(SideBarLocation::East));
} else {
layout->addWidget(dropArea());
}
setCentralWidget(centralWidget);
// qApp->installEventFilter(this);
@@ -94,7 +108,28 @@ MainWindow::~MainWindow()
delete d;
}
DropAreaWithCentralFrame *MainWindow::dropArea() const
void MainWindow::setCentralWidget(QWidget *w)
{
return d->m_dropArea;
QMainWindow::setCentralWidget(w);
}
SideBar *MainWindow::sideBar(SideBarLocation location) const
{
return d->m_sideBars.value(location);
}
void MainWindow::resizeEvent(QResizeEvent *ev)
{
MainWindowBase::resizeEvent(ev);
onResized(ev); // Also call our own handler, since QtQuick doesn't have resizeEvent()
}
QMargins MainWindow::centerWidgetMargins() const
{
return { 1, 5, 1, 1};
}
QRect MainWindow::centralAreaGeometry() const
{
return centralWidget()->geometry();
}

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
/**
@@ -32,6 +23,8 @@
namespace KDDockWidgets {
class SideBar;
/**
* @brief The QMainwindow sub-class that the application should use to be able
* to dock KDDockWidget::DockWidget instances.
@@ -49,15 +42,21 @@ public:
///@param parent QObject *parent to pass to QMainWindow constructor.
///@param flags Window flags to pass to QMainWindow constructor.
explicit MainWindow(const QString &uniqueName, MainWindowOptions options = MainWindowOption_None,
QWidget *parent = nullptr, Qt::WindowFlags flags = {});
QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
///@brief Destructor
~MainWindow() override;
///@internal
DropAreaWithCentralFrame *dropArea() const override;
///@brief returns the sidebar for the specified location
SideBar *sideBar(SideBarLocation) const override;
protected:
void resizeEvent(QResizeEvent *) override;
QMargins centerWidgetMargins() const override;
QRect centralAreaGeometry() const override;
private:
using QMainWindow::setCentralWidget;
void setCentralWidget(QWidget *); // overridden just to make it private
class Private;
Private *const d;
};

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
@@ -31,18 +22,21 @@
#include "DropArea_p.h"
#include "Frame_p.h"
#include "Utils_p.h"
#include "SideBar_p.h"
#include "Logging_p.h"
#include "Item_p.h"
#include "FrameworkWidgetFactory.h"
#include "DropAreaWithCentralFrame_p.h"
#include "multisplitter/MultiSplitterLayout_p.h"
#include "multisplitter/MultiSplitter_p.h"
using namespace KDDockWidgets;
class MainWindowBase::Private
{
public:
explicit Private(MainWindowOptions options)
explicit Private(MainWindowBase *mainWindow, MainWindowOptions options)
: m_options(options)
, q(mainWindow)
, m_dropArea(new DropAreaWithCentralFrame(mainWindow, options))
{
}
@@ -51,15 +45,22 @@ public:
return m_options & MainWindowOption_HasCentralFrame;
}
QRect rectForOverlay(Frame *, SideBarLocation) const;
SideBarLocation preferredSideBar(DockWidgetBase *) const;
void updateOverlayGeometry();
QString name;
QString affinityName;
QStringList affinities;
const MainWindowOptions m_options;
MainWindowBase *const q;
QPointer<DockWidgetBase> m_overlayedDockWidget;
DropAreaWithCentralFrame *const m_dropArea;
};
MainWindowBase::MainWindowBase(const QString &uniqueName, KDDockWidgets::MainWindowOptions options,
QWidgetOrQuick *parent, Qt::WindowFlags flags)
WidgetType *parent, Qt::WindowFlags flags)
: QMainWindowOrQuick(parent, flags)
, d(new Private(options))
, d(new Private(this, options))
{
setUniqueName(uniqueName);
}
@@ -75,9 +76,14 @@ void MainWindowBase::addDockWidgetAsTab(DockWidgetBase *widget)
Q_ASSERT(widget);
qCDebug(addwidget) << Q_FUNC_INFO << widget;
if (widget->affinityName() != affinityName()) {
if (!DockRegistry::self()->affinitiesMatch(d->affinities, widget->affinities())) {
qWarning() << Q_FUNC_INFO << "Refusing to dock widget with incompatible affinity."
<< widget->affinityName() << affinityName();
<< widget->affinities() << affinities();
return;
}
if (widget->options() & DockWidgetBase::Option_NotDockable) {
qWarning() << Q_FUNC_INFO << "Refusing to dock non-dockable widget" << widget;
return;
}
@@ -90,6 +96,11 @@ void MainWindowBase::addDockWidgetAsTab(DockWidgetBase *widget)
void MainWindowBase::addDockWidget(DockWidgetBase *dw, Location location, DockWidgetBase *relativeTo, AddingOption option)
{
if (dw->options() & DockWidgetBase::Option_NotDockable) {
qWarning() << Q_FUNC_INFO << "Refusing to dock non-dockable widget" << dw;
return;
}
dropArea()->addDockWidget(dw, location, relativeTo, option);
}
@@ -103,29 +114,336 @@ MainWindowOptions MainWindowBase::options() const
return d->m_options;
}
MultiSplitterLayout *MainWindowBase::multiSplitterLayout() const
DropAreaWithCentralFrame *MainWindowBase::dropArea() const
{
return dropArea()->multiSplitterLayout();
return d->m_dropArea;
}
void MainWindowBase::setAffinityName(const QString &name)
MultiSplitter *MainWindowBase::multiSplitter() const
{
if (d->affinityName == name)
return dropArea();
}
void MainWindowBase::setAffinities(const QStringList &affinityNames)
{
QStringList affinities = affinityNames;
affinities.removeAll(QString());
if (d->affinities == affinities)
return;
if (!d->affinityName.isEmpty()) {
if (!d->affinities.isEmpty()) {
qWarning() << Q_FUNC_INFO
<< "Affinity is already set, refusing to change."
<< "Submit a feature request with a good justification.";
return;
}
d->affinityName = name;
d->affinities = affinities;
}
QString MainWindowBase::affinityName() const
QStringList MainWindowBase::affinities() const
{
return d->affinityName;
return d->affinities;
}
void MainWindowBase::layoutEqually()
{
dropArea()->layoutEqually();
}
void MainWindowBase::layoutParentContainerEqually(DockWidgetBase *dockWidget)
{
dropArea()->layoutParentContainerEqually(dockWidget);
}
QRect MainWindowBase::Private::rectForOverlay(Frame *frame, SideBarLocation location) const
{
SideBar *sb = q->sideBar(location);
if (!sb)
return {};
const QRect centralAreaGeo = q->centralAreaGeometry();
const QMargins centerWidgetMargins = q->centerWidgetMargins();
QRect rect;
const int margin = 1;
switch (location) {
case SideBarLocation::North:
case SideBarLocation::South: {
SideBar *leftSideBar = q->sideBar(SideBarLocation::West);
SideBar *rightSideBar = q->sideBar(SideBarLocation::East);
const int leftSideBarWidth = (leftSideBar && leftSideBar->isVisible()) ? leftSideBar->width()
: 0;
const int rightSideBarWidth = (rightSideBar && rightSideBar->isVisible()) ? rightSideBar->width()
: 0;
rect.setHeight(qMax(300, frame->minSize().height()));
rect.setWidth(centralAreaGeo.width() - margin * 2 - leftSideBarWidth - rightSideBarWidth);
rect.moveLeft(margin + leftSideBarWidth);
if (location == SideBarLocation::South) {
rect.moveTop(centralAreaGeo.bottom() - centerWidgetMargins.bottom() - rect.height() - sb->height());
} else {
rect.moveTop(centralAreaGeo.y() + sb->height() + centerWidgetMargins.top());
}
break;
}
case SideBarLocation::West:
case SideBarLocation::East: {
SideBar *topSideBar = q->sideBar(SideBarLocation::North);
SideBar *bottomSideBar = q->sideBar(SideBarLocation::South);
const int topSideBarHeight = (topSideBar && topSideBar->isVisible()) ? topSideBar->height()
: 0;
const int bottomSideBarHeight = (bottomSideBar && bottomSideBar->isVisible()) ? bottomSideBar->height()
: 0;
rect.setWidth(qMax(300, frame->minSize().width()));
rect.setHeight(centralAreaGeo.height() - topSideBarHeight - bottomSideBarHeight - centerWidgetMargins.top() - centerWidgetMargins.bottom());
rect.moveTop(sb->mapTo(q, QPoint(0, 0)).y() + topSideBarHeight - 1);
if (location == SideBarLocation::East) {
rect.moveLeft(centralAreaGeo.width() - rect.width() - sb->width() - centerWidgetMargins.right() - margin);
} else {
rect.moveLeft(margin + centralAreaGeo.x() + centerWidgetMargins.left() + sb->width());
}
break;
}
case SideBarLocation::None:
break;
}
return rect;
}
static SideBarLocation opposedSideBarLocationForBorder(Layouting::Item::LayoutBorderLocation loc)
{
switch (loc) {
case Layouting::Item::LayoutBorderLocation_North:
return SideBarLocation::South;
case Layouting::Item::LayoutBorderLocation_East:
return SideBarLocation::West;
case Layouting::Item::LayoutBorderLocation_West:
return SideBarLocation::East;
case Layouting::Item::LayoutBorderLocation_South:
return SideBarLocation::North;
case Layouting::Item::LayoutBorderLocation_All:
case Layouting::Item::LayoutBorderLocation_Verticals:
case Layouting::Item::LayoutBorderLocation_Horizontals:
case Layouting::Item::LayoutBorderLocation_None:
break;
}
qWarning() << Q_FUNC_INFO << "Unknown loc" << loc;
return SideBarLocation::None;
}
static SideBarLocation sideBarLocationForBorder(Layouting::Item::LayoutBorderLocations loc)
{
switch (loc) {
case Layouting::Item::LayoutBorderLocation_North:
return SideBarLocation::North;
case Layouting::Item::LayoutBorderLocation_East:
return SideBarLocation::East;
case Layouting::Item::LayoutBorderLocation_West:
return SideBarLocation::West;
case Layouting::Item::LayoutBorderLocation_South:
return SideBarLocation::South;
case Layouting::Item::LayoutBorderLocation_All:
case Layouting::Item::LayoutBorderLocation_Verticals:
case Layouting::Item::LayoutBorderLocation_Horizontals:
case Layouting::Item::LayoutBorderLocation_None:
break;
}
return SideBarLocation::None;
}
SideBarLocation MainWindowBase::Private::preferredSideBar(DockWidgetBase *dw) const
{
// TODO: Algorithm can still be made smarter
Layouting::Item *item = q->multiSplitter()->itemForFrame(dw->frame());
if (!item) {
qWarning() << Q_FUNC_INFO << "No item for dock widget";
return SideBarLocation::None;
}
const Layouting::Item::LayoutBorderLocations borders = item->adjacentLayoutBorders();
const qreal aspectRatio = dw->width() / (dw->height() * 1.0);
/// 1. It's touching all borders
if (borders == Layouting::Item::LayoutBorderLocation_All) {
return aspectRatio > 1.0 ? SideBarLocation::South
: SideBarLocation::East;
}
/// 2. It's touching 3 borders
for (auto borderLoc : { Layouting::Item::LayoutBorderLocation_North, Layouting::Item::LayoutBorderLocation_East,
Layouting::Item::LayoutBorderLocation_West, Layouting::Item::LayoutBorderLocation_South }) {
if (borders == (Layouting::Item::LayoutBorderLocation_All & ~borderLoc))
return opposedSideBarLocationForBorder(borderLoc);
}
/// 3. It's touching left and right borders
if ((borders & Layouting::Item::LayoutBorderLocation_Verticals) == Layouting::Item::LayoutBorderLocation_Verticals) {
// We could measure the distance to the top though.
return SideBarLocation::South;
}
/// 4. It's touching top and bottom borders
if ((borders & Layouting::Item::LayoutBorderLocation_Horizontals) == Layouting::Item::LayoutBorderLocation_Horizontals) {
// We could measure the distance to the left though.
return SideBarLocation::East;
}
// 5. It's in a corner
if (borders == (Layouting::Item::LayoutBorderLocation_West | Layouting::Item::LayoutBorderLocation_South)) {
return aspectRatio > 1.0 ? SideBarLocation::South
: SideBarLocation::West;
} else if (borders == (Layouting::Item::LayoutBorderLocation_East | Layouting::Item::LayoutBorderLocation_South)) {
return aspectRatio > 1.0 ? SideBarLocation::South
: SideBarLocation::East;
} else if (borders == (Layouting::Item::LayoutBorderLocation_West | Layouting::Item::LayoutBorderLocation_North)) {
return aspectRatio > 1.0 ? SideBarLocation::North
: SideBarLocation::West;
} else if (borders == (Layouting::Item::LayoutBorderLocation_East | Layouting::Item::LayoutBorderLocation_North)) {
return aspectRatio > 1.0 ? SideBarLocation::North
: SideBarLocation::East;
}
{
// 6. It's only touching 1 border
SideBarLocation loc = sideBarLocationForBorder(borders);
if (loc != SideBarLocation::None)
return loc;
}
// It's not touching any border, use aspect ratio.
return aspectRatio > 1.0 ? SideBarLocation::South
: SideBarLocation::West;
}
void MainWindowBase::Private::updateOverlayGeometry()
{
if (!m_overlayedDockWidget)
return;
SideBar *sb = q->sideBarForDockWidget(m_overlayedDockWidget);
if (!sb) {
qWarning() << Q_FUNC_INFO << "Expected a sidebar";
return;
}
m_overlayedDockWidget->frame()->QWidgetAdapter::setGeometry(rectForOverlay(m_overlayedDockWidget->frame(), sb->location()));
}
void MainWindowBase::moveToSideBar(DockWidgetBase *dw)
{
moveToSideBar(dw, d->preferredSideBar(dw));
}
void MainWindowBase::moveToSideBar(DockWidgetBase *dw, SideBarLocation location)
{
if (SideBar *sb = sideBar(location)) {
dw->forceClose();
sb->addDockWidget(dw);
} else {
// Shouldn't happen
qWarning() << Q_FUNC_INFO << "Minimization supported, probably disabled in Config::self().flags()";
}
}
void MainWindowBase::restoreFromSideBar(DockWidgetBase *dw)
{
// First un-overlay it, if it's overlayed
if (dw == d->m_overlayedDockWidget)
clearSideBarOverlay();
SideBar *sb = sideBarForDockWidget(dw);
if (!sb) {
// Doesn't happen
qWarning() << Q_FUNC_INFO << "Dock widget isn't in any sidebar";
return;
}
sb->removeDockWidget(dw);
dw->setFloating(false); // dock it
}
void MainWindowBase::overlayOnSideBar(DockWidgetBase *dw)
{
if (!dw)
return;
const SideBar *sb = sideBarForDockWidget(dw);
if (sb == nullptr) {
qWarning() << Q_FUNC_INFO << "You need to add the dock widget to the sidebar before you can overlay it";
return;
}
if (d->m_overlayedDockWidget == dw) {
// Already overlayed
return;
}
// We only support one overlay at a time, remove any existing overlay
clearSideBarOverlay();
auto frame = Config::self().frameworkWidgetFactory()->createFrame(this, FrameOption_IsOverlayed);
d->m_overlayedDockWidget = dw;
frame->addWidget(dw);
d->updateOverlayGeometry();
frame->QWidgetAdapter::show();
Q_EMIT dw->isOverlayedChanged(true);
}
void MainWindowBase::toggleOverlayOnSideBar(DockWidgetBase *dw)
{
const bool wasOverlayed = d->m_overlayedDockWidget == dw;
clearSideBarOverlay();
if (!wasOverlayed) {
overlayOnSideBar(dw);
}
}
void MainWindowBase::clearSideBarOverlay()
{
if (!d->m_overlayedDockWidget)
return;
Frame *frame = d->m_overlayedDockWidget->frame();
d->m_overlayedDockWidget->setParent(nullptr);
Q_EMIT d->m_overlayedDockWidget->isOverlayedChanged(false);
d->m_overlayedDockWidget = nullptr;
delete frame;
}
SideBar *MainWindowBase::sideBarForDockWidget(const DockWidgetBase *dw) const
{
for (auto loc : { SideBarLocation::North, SideBarLocation::South,
SideBarLocation::East, SideBarLocation::West }) {
if (SideBar *sb = sideBar(loc)) {
if (sb->contains(const_cast<DockWidgetBase *>(dw)))
return sb;
}
}
return nullptr;
}
DockWidgetBase *MainWindowBase::overlayedDockWidget() const
{
return d->m_overlayedDockWidget;
}
bool MainWindowBase::sideBarIsVisible(SideBarLocation loc) const
{
if (SideBar *sb = sideBar(loc))
return sb->isVisible();
return false;
}
void MainWindowBase::setUniqueName(const QString &uniqueName)
@@ -142,6 +460,12 @@ void MainWindowBase::setUniqueName(const QString &uniqueName)
}
}
void MainWindowBase::onResized(QResizeEvent *)
{
if (d->m_overlayedDockWidget)
d->updateOverlayGeometry();
}
bool MainWindowBase::deserialize(const LayoutSaver::MainWindow &mw)
{
if (mw.options != options()) {
@@ -150,14 +474,14 @@ bool MainWindowBase::deserialize(const LayoutSaver::MainWindow &mw)
return false;
}
if (d->affinityName != mw.affinityName) {
qWarning() << Q_FUNC_INFO << "Affinty name changed from" << d->affinityName
<< "; to" << mw.affinityName;
if (d->affinities != mw.affinities) {
qWarning() << Q_FUNC_INFO << "Affinty name changed from" << d->affinities
<< "; to" << mw.affinities;
d->affinityName = mw.affinityName;
d->affinities = mw.affinities;
}
return dropArea()->multiSplitterLayout()->deserialize(mw.multiSplitterLayout);
return dropArea()->deserialize(mw.multiSplitterLayout);
}
LayoutSaver::MainWindow MainWindowBase::serialize() const
@@ -170,8 +494,8 @@ LayoutSaver::MainWindow MainWindowBase::serialize() const
m.uniqueName = uniqueName();
m.screenIndex = screenNumberForWidget(this);
m.screenSize = screenSizeForWidget(this);
m.multiSplitterLayout = dropArea()->multiSplitterLayout()->serialize();
m.affinityName = d->affinityName;
m.multiSplitterLayout = dropArea()->serialize();
m.affinities = d->affinities;
return m;
}

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
@@ -35,14 +26,16 @@
#include "LayoutSaver_p.h"
#include <QVector>
#include <QMargins>
namespace KDDockWidgets {
class DockWidgetBase;
class Frame;
class DropArea;
class MultiSplitterLayout;
class MultiSplitter;
class DropAreaWithCentralFrame;
class SideBar;
/**
* @brief The MainWindow base-class. MainWindow and MainWindowBase are only
@@ -51,20 +44,24 @@ class DropAreaWithCentralFrame;
*
* Do not use instantiate directly in user code. Use MainWindow instead.
*/
#ifndef PYTHON_BINDINGS //Pyside bug: https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1327
class DOCKS_EXPORT MainWindowBase : public QMainWindowOrQuick
#else
class DOCKS_EXPORT MainWindowBase : public QMainWindow
#endif
{
Q_OBJECT
public:
typedef QVector<MainWindowBase*> List;
explicit MainWindowBase(const QString &uniqueName, MainWindowOptions options = MainWindowOption_HasCentralFrame,
QWidgetOrQuick *parent = nullptr, Qt::WindowFlags flags = {});
WidgetType *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
~MainWindowBase() override;
/**
* @brief Docks a DockWidget into the central frame, tabbed.
* @warning Requires that the MainWindow was constructed with MainWindowOption_HasCentralFrame option.
* @param The DockWidget to dock.
* @param dockwidget The dockwidget to dock.
*
* @sa DockWidgetBase::addDockWidgetAsTab()
*/
@@ -79,7 +76,7 @@ public:
*/
void addDockWidget(DockWidgetBase *dockWidget,
KDDockWidgets::Location location,
DockWidgetBase *relativeTo = nullptr, AddingOption option = {});
DockWidgetBase *relativeTo = nullptr, AddingOption option = KDDockWidgets::AddingOption());
/**
* @brief Returns the unique name that was passed via constructor.
@@ -94,18 +91,18 @@ public:
///@internal
///@brief returns the drop area.
virtual DropAreaWithCentralFrame *dropArea() const = 0;
DropAreaWithCentralFrame *dropArea() const;
///@internal
///@brief returns the MultiSplitterLayout.
MultiSplitterLayout* multiSplitterLayout() const;
///@brief returns the MultiSplitter.
MultiSplitter* multiSplitter() const;
/**
* @brief Sets the affinity name. Dock widgets can only dock into main windows of the same affinity.
* @brief Sets the affinities names. Dock widgets can only dock into main windows of the same affinity.
*
* By default the affinity is empty and a dock widget can dock into any main window. Usually you
* won't ever need to call this function, unless you have requirements where certain dock widgets
* can only dock into certain main windows. @sa DockWidgetBase::setAffinityName().
* can only dock into certain main windows. @sa DockWidgetBase::setAffinities().
*
* Note: Call this function right after creating your main window, before docking any dock widgets
* into a main window and before restoring any layout.
@@ -114,17 +111,67 @@ public:
* edge cases. This will only be changed if a good use case comes up that requires changing
* affinities multiple times.
*
* @p name The affinity name.
* @p name The affinity names.
*/
void setAffinityName(const QString &name);
void setAffinities(const QStringList &names);
/**
* @brief Returns the affinity name. Empty by default.
* @brief Returns the list of affinity names. Empty by default.
*/
QString affinityName() const;
QStringList affinities() const;
/// @brief layouts all the widgets so they have an equal size within their parent container
///
/// Note that the layout is a tree of nested horizontal and vertical container layouts. The
/// nodes closer to the root will have more space.
///
/// min/max constraints will still be honoured.
void layoutEqually();
/// @brief like layoutEqually() but starts with the container that has @p dockWidget.
/// While layoutEqually() starts from the root of the layout tree this function starts on a
/// sub-tree.
void layoutParentContainerEqually(DockWidgetBase *dockWidget);
///@brief Moves the dock widget into one of the MainWindow's sidebar.
/// Means the dock widget is removed from the layout, and the sidebar shows a button that if pressed
/// will toggle the dock widget's visibility as an overlay over the layout. This is the auto-hide
/// functionality.
///
/// The chosen side bar will depend on some heuristics, mostly proximity.
void moveToSideBar(DockWidgetBase *);
/// @brief overload that allows to specify which sidebar to use, instead of using heuristics.
void moveToSideBar(DockWidgetBase *, SideBarLocation);
/// @brief Removes the dock widget from the sidebar and docks it into the main window again
void restoreFromSideBar(DockWidgetBase *);
///@brief Shows the dock widget overlayed on top of the main window, placed next to the sidebar
void overlayOnSideBar(DockWidgetBase *);
///@brief Shows or hides an overlay. It's assumed the dock widget is already in a side-bar.
void toggleOverlayOnSideBar(DockWidgetBase *);
/// @brief closes any overlayed dock widget. The sidebar still displays them as button.
void clearSideBarOverlay();
/// @brief Returns the sidebar this dockwidget is in. nullptr if not in any.
SideBar *sideBarForDockWidget(const DockWidgetBase *) const;
/// @brief returns the dock widget which is currently overlayed. nullptr if none.
/// This is only relevant when using the auto-hide and side-bar feature.
DockWidgetBase *overlayedDockWidget() const;
/// @brief Returns whether the specified sidebar is visible
bool sideBarIsVisible(SideBarLocation) const;
protected:
void setUniqueName(const QString &uniqueName);
void onResized(QResizeEvent *); // Because QtQuick doesn't have resizeEvent()
virtual QMargins centerWidgetMargins() const = 0;
virtual SideBar* sideBar(SideBarLocation) const = 0;
virtual QRect centralAreaGeometry() const { return {}; }
Q_SIGNALS:
void uniqueNameChanged();

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#ifndef KDDOCKWIDGETS_QWIDGETADAPTER_H
@@ -25,6 +16,8 @@
# define KDDOCKWIDGETS_QTWIDGETS
#endif
#include <QWindow>
/**
* @file
* @brief Abstraction for supporting both QtWidgets and QtQuick.
@@ -32,15 +25,63 @@
* @author Sérgio Martins \<sergio.martins@kdab.com\>
*/
#ifdef KDDOCKWIDGETS_QTWIDGETS
# include "private/widgets/QWidgetAdapter_widgets_p.h"
#include <QMainWindow>
typedef QWidget QWidgetOrQuick;
typedef QMainWindow QMainWindowOrQuick;
namespace KDDockWidgets {
namespace Private {
inline bool isMinimized(QWindow *window)
{
// QWindow::windowStates() was introduced in 5.10
#if QT_VERSION < 0x051000
return window && window->windowState() == Qt::WindowMinimized;
#else
# include "quick/QWidgetAdapter_quick_p.h"
typedef KDDockWidgets::QWidgetAdapter QWidgetOrQuick;
typedef QWidgetOrQuick QMainWindowOrQuick;
return window && window->windowStates() & Qt::WindowMinimized;
#endif
}
}}
#ifdef KDDOCKWIDGETS_QTWIDGETS
# include "private/multisplitter/Widget_qwidget.h"
# include "private/widgets/QWidgetAdapter_widgets_p.h"
# include <QMainWindow>
namespace KDDockWidgets {
class MainWindow;
class DockWidget;
typedef QWidget QWidgetOrQuick;
typedef QMainWindow QMainWindowOrQuick;
typedef Layouting::Widget_qwidget LayoutGuestWidgetBase;
typedef KDDockWidgets::MainWindow MainWindowType;
typedef KDDockWidgets::DockWidget DockWidgetType;
typedef QWidget WidgetType;
}
#else
# include "private/multisplitter/Widget_quick.h"
# include "private/quick/QWidgetAdapter_quick_p.h"
namespace KDDockWidgets {
class MainWindowQuick;
class DockWidgetQuick;
typedef KDDockWidgets::QWidgetAdapter QWidgetOrQuick;
typedef QWidgetOrQuick QMainWindowOrQuick;
typedef Layouting::Widget_quick LayoutGuestWidgetBase;
typedef KDDockWidgets::MainWindowQuick MainWindowType;
typedef KDDockWidgets::DockWidgetQuick DockWidgetType;
typedef QQuickItem WidgetType;
}
#endif
namespace KDDockWidgets {
class LayoutGuestWidget : public KDDockWidgets::QWidgetAdapter
, public LayoutGuestWidgetBase
{
public:
explicit LayoutGuestWidget(QWidgetOrQuick *parent)
: QWidgetAdapter(parent)
, LayoutGuestWidgetBase(this)
{
}
~LayoutGuestWidget() override;
};
}
#endif

40
src/Qt5Qt6Compat_p.h Normal file
View File

@@ -0,0 +1,40 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#ifndef KDDOCKWIDGETS_QT5QT6_COMPAT_P_H
#define KDDOCKWIDGETS_QT5QT6_COMPAT_P_H
#include <QMouseEvent>
namespace KDDockWidgets {
namespace Qt5Qt6Compat {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
inline QPoint eventGlobalPos(QMouseEvent *ev)
{
return ev->globalPosition().toPoint();
}
#else
// Qt 5:
inline QPoint eventGlobalPos(QMouseEvent *ev)
{
return ev->globalPos();
}
#endif
}
}
#endif

View File

@@ -1,21 +1,12 @@
/*
This file is part of KDDockWidgets.
Copyright (C) 2018-2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#ifndef KD_DOCKS_EXPORT_H
@@ -23,20 +14,25 @@
#include <QtCore/QtGlobal>
#if defined(BUILDING_DOCKS_LIBRARY)
# define DOCKS_EXPORT Q_DECL_EXPORT
# if defined(DOCKS_DEVELOPER_MODE)
# define DOCKS_EXPORT_FOR_UNIT_TESTS Q_DECL_EXPORT
# else
# define DOCKS_EXPORT_FOR_UNIT_TESTS
# endif
#if defined(KDDOCKWIDGETS_STATICLIB)
# define DOCKS_EXPORT
# define DOCKS_EXPORT_FOR_UNIT_TESTS
#else
# define DOCKS_EXPORT Q_DECL_IMPORT
# if defined(DOCKS_DEVELOPER_MODE)
# define DOCKS_EXPORT_FOR_UNIT_TESTS Q_DECL_IMPORT
# else
# define DOCKS_EXPORT_FOR_UNIT_TESTS Q_DECL_IMPORT
# endif
# if defined(BUILDING_DOCKS_LIBRARY)
# define DOCKS_EXPORT Q_DECL_EXPORT
# if defined(DOCKS_DEVELOPER_MODE)
# define DOCKS_EXPORT_FOR_UNIT_TESTS Q_DECL_EXPORT
# else
# define DOCKS_EXPORT_FOR_UNIT_TESTS
# endif
# else
# define DOCKS_EXPORT Q_DECL_IMPORT
# if defined(DOCKS_DEVELOPER_MODE)
# define DOCKS_EXPORT_FOR_UNIT_TESTS Q_DECL_IMPORT
# else
# define DOCKS_EXPORT_FOR_UNIT_TESTS Q_DECL_IMPORT
# endif
# endif
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More