Compare commits

...

206 Commits

Author SHA1 Message Date
Renato Araujo Oliveira Filho
1e7a2110b1 Fix python bindings build
Task-Id: KDABCI-692
2021-01-18 11:58:42 -03:00
Sergio Martins
243146fe49 Update ChangeLog 2021-01-17 23:24:58 +00:00
Sergio Martins
370d139dfc Fix Flag_NativeTitleBar
It shouldn't use the FloatingWindow::isInDragArea() code path
2021-01-17 23:11:41 +00:00
Sergio Martins
c4e7db34a4 Minor readability improvement 2021-01-17 22:51:37 +00:00
Sergio Martins
a4f6b72157 Fix FloatingWindow::isInDragArea() returning false even with HTCAPTION
If the last clicked position is HTCAPTION then we're sure we're
dragging. Problem with comparing the rect is that mouse events are
async, and by the time we use the mouse event pos the window is already
somewhere else. So just use HTCAPTION, which is 100% correct.

Fixes #103
2021-01-17 16:28:11 +00:00
Sergio Martins
de3ca6dba5 vscode: Remove launch.json
We'll do this per workspace file instead
2021-01-17 14:10:19 +00:00
Sergio Martins
bdfcfdd0fe Update ChangeLog 2021-01-16 22:39:11 +00:00
Sergio Martins
dbf357ce66 Fix restoring window maximized state
Fixes #81
2021-01-16 22:37:30 +00:00
Sergio Martins
e950cf7fc3 tests: Add a test for issue #81 2021-01-16 21:38:36 +00:00
Sergio Martins
8dfad1c910 vscode: Update the workspace files
Now autogenerated from CMakePresets.json.
Added the Qt6 one too.
2021-01-16 19:40:36 +00:00
Sergio Martins
107d4e973c Remove a script I'm no longer using 2021-01-16 15:50:27 +00:00
Sergio Martins
e33766a4fa examples: Illustrate Config::Flag_CloseOnlyCurrentTab 2021-01-16 13:19:37 +00:00
Sergio Martins
6a550c6c4a Added Config::Flag_CloseOnlyCurrentTab
When clicking on the TitleBar's close button it closes all the
dock widgets in the tab, by default. With the new option it will
close only the current tab
2021-01-16 13:06:29 +00:00
Sergio Martins
a0fc2a8ce7 Minor logic readability fix
They are mutually exclusive
2021-01-16 12:00:43 +00:00
Sergio Martins
ab257b3468 float docked widgets that have LayoutSaverOption::Skip before restore 2021-01-15 21:30:38 +00:00
Sergio Martins
e6bdb28484 Added convenience DockWidgetBase::skipsRestore() 2021-01-15 20:17:45 +00:00
Sergio Martins
c52446f3b0 Merge branch '1.2' 2021-01-15 09:27:17 +00:00
Sergio Martins
9cadfb26d9 Fix toggleAction() when dock widget is in the sidebar
It should toggle the overlay, not dock the widget

Fixes #139
2021-01-15 09:24:11 +00:00
Sergio Martins
7d5ea8f908 tests++ 2021-01-15 09:20:58 +00:00
Sergio Martins
161b33370e Add more tests 2021-01-15 09:04:05 +00:00
Sergio Martins
8dd7a90b34 Add convenience DockWidgetBase::isInSideBar() 2021-01-15 08:52:17 +00:00
Sergio Martins
7ff865a36f tests: Add test for #139 2021-01-15 08:44:21 +00:00
Sergio Martins
d0b8ee606a Honour LayoutSaverOption::Skip for floating windows with many dock widgets
If all dock widgets in the floating window have the Skip flag then the
FloatingWindow can too
2021-01-14 18:33:29 +00:00
Sergio Martins
c6c3b16fd2 LayoutSaver: Add some utility functions 2021-01-14 18:11:29 +00:00
Sergio Martins
64a6cbb2e4 Add all|anyDockWidgetsHave overloads taking a LayoutSaverOption 2021-01-14 18:01:54 +00:00
Sergio Martins
e1cf532437 tests: Add an XFAIL for a LayoutSaverOption::Skip case 2021-01-14 17:57:37 +00:00
Sergio Martins
67f2127710 Add one more unit-test regarding DeleteOnClose 2021-01-14 17:51:02 +00:00
Sergio Martins
9111b424a1 TitleBar: Also update the auto/hide button
For completeness, doesn't mean it's actually needed.
For issue #137.
2021-01-14 11:39:15 +00:00
Sergio Martins
772b51216f Merge branch '1.2' 2021-01-13 23:15:03 +00:00
Sergio Martins
a79a2f5ecb Fix restoring non-closable state
For issue #137

A simpler solution than on master, doesn't include the refactoring.
2021-01-13 23:13:39 +00:00
Sergio Martins
585c0d64ed Fix close button enable state not being restored with LayoutSaver
Fixes #137
2021-01-13 23:07:49 +00:00
Sergio Martins
7ddb95a417 Add a single TitleBar::updateButtons()
updateCloseButton() can now be private
2021-01-13 23:07:49 +00:00
Sergio Martins
02648eb54e Update ChangeLog re PySide6 2021-01-13 22:51:18 +00:00
Sergio Martins
54a1050fbb Add unit-test for issue #137 2021-01-13 22:23:44 +00:00
Sergio Martins
f997b2d2f0 qtquick: Fix build 2021-01-13 13:31:33 +00:00
Sergio Martins
8f61e57b57 Add DockWidget::Option::Option_DeleteOnClose 2021-01-13 12:54:18 +00:00
Sergio Martins
cfcff6f2d7 Minor rename 2021-01-12 22:49:07 +00:00
Sergio Martins
44d7cc0588 Add FloatingWindow::allDockWidgetsHave(option) and the any* variant 2021-01-12 22:42:38 +00:00
Sergio Martins
c91275d091 vscode: Use workspace files instead of project settings
So we can build for QtQuick too with different settings
2021-01-12 15:20:29 +00:00
Sergio Martins
69c88919c0 cmake: Export a compile_commands.json which helps vscode
Need to disable unity build otherwise intellisense can't find
our source files in the compile_commands.json. Only for the dev-*
presets anyway
2021-01-12 14:25:11 +00:00
Sergio Martins
e0e6f55868 Introduce DockWidgetBase::LayoutSaverOptions enum
The first enumerator is "Skip", meaning the dock widget won't
be affected by save/restore. It won't disappear while restoring,
and won't be shown if already hidden. (only applies to floating widgets)
2021-01-11 23:33:32 +00:00
Sergio Martins
7698584ee0 Fix potential invalid index when restoring layout
We save the index of each FloatingWindow when saving a layout,
but when restoring we might not want to restore all FloatingWindows,
for example, if we use a LayoutSaver with another affinity.

So, the index in Position::deserialize() should be a index to
LayoutSaver::Layout::floatingWindows, and not to DockRegistry::self()->floatingWindows()
since the later might be smaller.
2021-01-11 21:55:47 +00:00
Sergio Martins
d034722ba9 LayoutSaver: Add some utilities 2021-01-11 21:16:02 +00:00
Sergio Martins
e1e07c95ba Merge pull request #134 from KDAB/python6
Added PySide6 support
2021-01-11 19:35:53 +00:00
Renato Araujo Oliveira Filho
4e79c68a7d Added PySide6 support
Task-Id: KDDW-27
2021-01-11 16:31:49 -03:00
Sergio Martins
d80325ec8f Merge branch '1.2' into master 2021-01-10 23:11:17 +00:00
Sergio Martins
e9925785ab Cancel the drag if the draggable is destroyed
Can be destroyed for reasons we can't control or simply destroyed
because the draggable was docked/undocked

Fixes #120
2021-01-10 23:07:57 +00:00
Sergio Martins
81efda2d11 Add a QPointer guard for the draggable
So we can detect if it was deleted meanwhile
2021-01-10 23:00:19 +00:00
Sergio Martins
36eef80192 Also pass InitialOption to addDockWidgetToContainingWindow()
So you can control initial size and such
2021-01-09 13:58:56 +00:00
Sergio Martins
306bf26f66 Remove some qCDebug I never needed 2021-01-09 13:27:30 +00:00
Sergio Martins
e07fb7f121 DockWidget::addDockWidgetToContainingWindow() now accepts docking to main window
Was already stated in the docs that it would work with a main window but implementation
only allowed floating window.

Fixes #132
2021-01-09 13:24:06 +00:00
Sergio Martins
bc86cfcb1f Move Item::insertItem() to the derived class
Item itself doesn't know how to insert into the layout.
We'll soon have a new derived class which will do things differently
2021-01-09 00:11:59 +00:00
Sergio Martins
63bb7e31cd Remove unused method 2021-01-08 22:32:42 +00:00
Sergio Martins
1840d50fc0 Move LayoutBorderLocation out of Item
It only affect the box layout
2021-01-08 22:24:53 +00:00
Sergio Martins
c6fd4e4bc4 Remove duplicate Location enum
No longer needed
2021-01-08 22:11:03 +00:00
Sergio Martins
46210203f7 Rename ItemContainer to ItemBoxContainer 2021-01-08 22:02:02 +00:00
Sergio Martins
5a2d000ddd qtquick: Fix weak vtable 2021-01-08 18:25:14 +00:00
Sergio Martins
c73c26e5cb tests: Fix overloaded signal "parentChanged()" 2021-01-08 18:24:51 +00:00
Sérgio Martins
39c3e4fd13 Fix flags being compared against internal flag enum 2021-01-08 17:09:49 +00:00
Sergio Martins
011d83b7d9 tests: Also restore the internal flags 2021-01-08 09:03:24 -08:00
Sergio Martins
26f1b75976 tests: delete the dockwidgets when each test ends
Will save us from doing manual cleanup.
2021-01-08 08:45:28 -08:00
Sergio Martins
309a90d3a6 tests: Fix a test on windows 2021-01-08 08:28:41 -08:00
Sérgio Martins
946e1e977e tests: Make sure our own stuff is deleted
but don't care about other stuff.
Other QWindows might be deleted delayed. We care more about
DockWidget and MainWindow due to their unique names. They need to
be deleted before the next test starts.
2021-01-08 15:43:04 +00:00
Sergio Martins
7f1347f15d Overload DragRegistry::floatingWindows() to return windows being deleted too 2021-01-08 15:38:18 +00:00
Sergio Martins
2e498f644b Remove unneeded multisplitter examples
We use the top-level examples instead
2021-01-07 16:45:29 +00:00
Sergio Martins
ee0272e036 Merge pull request #129 from mateoconlechuga/master
Add support for setting toggle action icon
2021-01-07 16:09:34 +00:00
Sergio Martins
4aa87c1758 Merge branch '1.2' 2021-01-07 11:15:29 +00:00
Sergio Martins
3b1158b82f Fix potential crash uncovered by UBSAN
m_inCtor might be read before being initialized since when
the earlier members are initialized they can call back into
Frame.
2021-01-07 11:13:56 +00:00
Sergio Martins
1aee98bebd README-WASM: Minor correction, library is static 2021-01-07 11:13:56 +00:00
Allen Winter
b5a6433950 Merge branch '1.2' 2021-01-06 10:55:54 -05:00
Allen Winter
077264fd54 CopyrightAssignmentForm.docx - update email address 2021-01-06 10:55:26 -05:00
Kevin Funk
bee653cf80 Streamline README.md a bit 2021-01-06 16:04:14 +01:00
Sergio Martins
e1363aadaa Remove inclusion of moc from .cpp file
doesn't play nice with cmake unity build on older cmake
2021-01-06 14:40:40 +00:00
Sergio Martins
43877ca712 README: Added url of our WASM demo 2021-01-06 14:35:46 +00:00
Sergio Martins
f7cc54ad38 Merge branch '1.2' 2021-01-06 12:00:13 +00:00
Sergio Martins
538f318fac README-WASM: Minor correction, library is static 2021-01-06 11:07:52 +00:00
Sergio Martins
f0376fa7a2 Disable unity build on the stable branch
Fixes a build failure on ubuntu.
Will probably only enabled for development.
2021-01-06 10:59:13 +00:00
Sergio Martins
0d2bccc15e Deprecate AddingOption
Will probably be removed in v1.5
2021-01-05 20:32:14 +00:00
Sergio Martins
842b89c36d Restore source-compat with 1.2
It's not very hard. Just added the old enum and an implicit ctor.
2021-01-05 19:09:11 +00:00
Sergio Martins
1d74c67bd4 Merge pull request #130 from dangelog/more-build-fixups
More build fixups
2021-01-04 15:23:55 +00:00
Sergio Martins
ea0dd04bd9 Fix build with installed KDDW 2021-01-04 14:48:26 +00:00
Giuseppe D'Angelo
a5dbab096b More build fixups 2021-01-04 15:17:47 +01:00
mateoconlechuga
f1f555d5ab Add support for setting toggle action icon
This adds support for a custom icon to be displayed in a QMenu.
2021-01-03 19:36:56 -07:00
Sergio Martins
5b60a929ab Merge branch '1.2' 2021-01-04 00:20:56 +00:00
Sergio Martins
f4404dcbe0 qt6: disable -Wconversion
the long long int to int conversions due to the Qt6 containers
are harmless
2021-01-04 00:12:55 +00:00
Sergio Martins
dd81e02d94 Fix Qt6 build 2021-01-03 22:17:25 +00:00
Sergio Martins
f4643aeefd Merge branch '1.2' 2021-01-03 22:15:33 +00:00
Sergio Martins
e563ffb673 Add presets for Qt6 dev build 2021-01-03 22:12:56 +00:00
Sergio Martins
4cceec82ac Remove unused variable
Should fix MingW build with -Werror
2021-01-03 21:24:21 +00:00
Sergio Martins
4b868e2078 README: Mention that Qt6 is supported and MSVC 2013 won't be 2021-01-03 21:22:41 +00:00
Allen Winter
875544a449 Merge branch '1.2' 2021-01-02 09:32:20 -05:00
Allen Winter
a2f4c972a6 update copyright year 2021-01-02 09:27:50 -05:00
Sergio Martins
2b0a6e5d06 README: Mention VS 2013 isn't supported anymore
We're getting an ICE
2020-12-28 22:42:24 +00:00
Sergio Martins
5f7e645ed6 Merge branch '1.2' 2020-12-28 22:28:15 +00:00
Sergio Martins
59c90c01f9 README: Mention that Qt6 is supported and MSVC 2013 won't be 2020-12-28 22:27:38 +00:00
Sergio Martins
92063ab61b Remove some duplicate code, Qt does the same already
Recently Qt implemented something similar. Since we only support
aero snap with Qt 5.15 we dont need KDDW's native win32 code anymore

cc issue #121
2020-12-28 13:06:37 -08:00
Sergio Martins
003ec5aa5b Probably fix namespaced build 2020-12-28 19:35:03 +00:00
Sergio Martins
02bf43b468 Add InternalFlag_DontShowWhenUnfloatingHiddenWindow
It's an internal knob you can turn so that setFloating(false)
doesn't show the dockwidget. Only adding this flag in case you need
to support both KDDW and QDW at the same time, or during porting/evaluation.

Fixes #125
2020-12-28 19:19:46 +00:00
Sergio Martins
50e1285839 Move more internal enumerators into the internal enum
the public enum is now clean
2020-12-28 14:36:42 +00:00
Sergio Martins
3fb6574322 Move Flag_internal_NoAeroSnap into its own enum
Enumerators not intended for the public shouldn't be in the
public enum. Move it to a private enum.
2020-12-28 14:01:16 +00:00
Sergio Martins
fa2501d5e4 Merge branch '1.2' 2020-12-28 12:35:04 +00:00
Jacob Young
0fe58fd160 Fix filename case so that it will build on a case-sensitive filesystem. 2020-12-28 12:34:03 +00:00
Sergio Martins
01f3042f48 Merge pull request #127 from CE-Programming/fix/case
Fix filename case so that it will build on a case-sensitive filesystem.
2020-12-28 12:24:23 +00:00
Sergio Martins
6719dd2b9e Allow to pass a preferred initial size to MainWindow::addDockWidget()
fixes #95
2020-12-28 11:59:09 +00:00
Sergio Martins
08c058b214 Remove unimplemented DefaultSizeMode::SizePolicy
It's public API so don't expose enumerators that don't work
2020-12-28 10:58:37 +00:00
Jacob Young
e4502d4f64 Fix filename case so that it will build on a case-sensitive filesystem. 2020-12-28 03:07:30 -05:00
Sergio Martins
db928a0fca refactor: Move the DefaultSizingMode enum into InitialSizingOption
It's another enum that affects the initial sizing.
No behaviour was change in this commit.

Needed for issue #95
2020-12-28 00:17:13 +00:00
Sergio Martins
5582f37a18 Introduce InitialOption struct
addDockWidget() received a AddingOption enumerator. But that
enum isn't enough, as we also want to be able to specify an initial
QSize.

So, instead of adding yet another parameter to addDockWidget(), we
create a struct to old those "initial settings".

Implies a minor source break, but trivial to fix in user code,
just rename the enumerator.

Honouring preferredSize will be a followup.

Needed for issue #95
2020-12-27 20:22:02 +00:00
Sergio Martins
a28e152a37 Remove duplicate DefaultSizeMode enum
It's already in Item_p.h
2020-12-27 13:56:58 +00:00
Sergio Martins
d6dea6f426 TabWidget: Remove paint event hack
Origin unknown, came from "initial commit".
Can't notice any difference without it. Users can do such hacks
by overriding it
2020-12-27 12:58:12 +00:00
Sergio Martins
d29f9fdd0d Fix install location of TabWidget_p.h
It moved location in the repo recently
2020-12-27 12:39:08 +00:00
Sergio Martins
a2a80df5df Add static function DockWidgetBase::byName()
So users don't have to use private API.

Fixes issue #126
2020-12-27 11:41:16 +00:00
Sergio Martins
48ce3a972f DockWidget: Move some clutter to the end of the file
So users not using doxygen can quickly see the API
2020-12-27 11:34:44 +00:00
Sergio Martins
9fae250897 DockWidget: Make the serialization methods private
They are not for the public
2020-12-27 11:32:38 +00:00
Sergio Martins
4dd703dcb2 Remove another unneeded qWait 2020-12-24 11:57:18 +00:00
Sergio Martins
e46b5b2edf tests: Remove a few unneeded qWaits regarding QStateMachine
We don't use QStateMachine anymore
2020-12-24 11:55:45 +00:00
Sergio Martins
7febcf2170 qtquick: Uncomment another TabBar that passes now 2020-12-24 11:53:13 +00:00
Sergio Martins
012ed4cf1d qtquick: Uncomment another test regarding tab widget 2020-12-24 11:43:13 +00:00
Sergio Martins
18283c4d1a qtquick: Enable another QTabBar test 2020-12-23 23:37:37 +00:00
Sergio Martins
2bb46b1cdf Uncomment another tab test 2020-12-23 23:11:09 +00:00
Sergio Martins
113263a4a1 qtquick: Enable one more QTabBar test 2020-12-23 22:47:36 +00:00
Sergio Martins
a6ca44cde6 qtquick: double-clicking a tab will detach it now 2020-12-23 20:37:59 +00:00
Sergio Martins
894be60a75 tests: Add pressOn/doubleClickOn that receives a QWindow
Easier as we don't need to know the actual QWidget/QQuickItem
receiver. The QWindow will deliver it.
2020-12-23 20:36:50 +00:00
Sergio Martins
244a1bec24 Merge branch '1.2' 2020-12-23 14:34:39 +00:00
Sergio Martins
51d78ba20b cmake: Allow to not build the fuzzer
Slight build improvement locally.
Still build by the CI anyway.

Did the same for the linter.
2020-12-23 13:36:43 +00:00
Sérgio Martins
8291025dfa tests: Make the tests run much faster
tst_docks is already run in parallel. Then it was running
again sequentially!
2020-12-23 13:32:15 +00:00
Sergio Martins
6ea1d4ca58 Minor coding style 2020-12-22 18:58:51 +00:00
Sergio Martins
771bf10951 Merge branch '1.2' 2020-12-22 18:48:22 +00:00
Sergio Martins
67a3270324 cmake: Add a setting to enable -Werror without developer build
Enabled for clazy, for example
2020-12-22 18:16:35 +00:00
Sergio Martins
cd859d6725 Fix a bunch of clazy warnings 2020-12-22 17:01:50 +00:00
Sergio Martins
092b4afe4a Add a clazy preset 2020-12-22 16:05:10 +00:00
Sergio Martins
f8d0ffe7ba Fix a few clazy warnings 2020-12-22 16:02:55 +00:00
Sergio Martins
10f47a701f Fix -Wclazy-copyable-polymorphic 2020-12-22 15:38:50 +00:00
Sergio Martins
d3224ed266 Fix -Wclazy-qstring-arg 2020-12-22 15:28:29 +00:00
Sergio Martins
2ccb5391bb Fix -Wclazy-detaching-temporary 2020-12-22 15:14:28 +00:00
Sergio Martins
5c0c9799a4 Fix build with clang -Wsigness 2020-12-22 15:14:13 +00:00
Sergio Martins
5ccbb5b056 build-all.dart: no need to pass the cmake variables
they are already in the preset
2020-12-22 12:28:32 +00:00
Sergio Martins
fc04455e93 build-all.dart: Update the usage comment 2020-12-22 12:15:15 +00:00
Sergio Martins
4ae8f461cb Merge branch '1.2' 2020-12-22 11:56:45 +00:00
Giuseppe D'Angelo
17539e5b88 Frame: stop using "virtual" signals
They don't work as expected across DLL boundaries on MSVC: connecting
to Frame::isFocusedChanged using the PMF syntax fails.

The reason has to do with how MSVC implements pointers to virtual
function members: they are "regular" function pointers to a DLL-local
stub that implements the virtual call. For that reason, a connect()
happening in client code would generate a pointer for the signal that
doesn't compare equal to the same pointer generated from inside KDDW;
and moc-generated code relies on this comparison to find the index of
the signal.

Just avoid the whole thing: rename the non-signal virtual call into a
"callback", and reimplement it in the first QObject subclass to turn it
into a proper signal.
2020-12-22 11:54:44 +00:00
Sergio Martins
e53b9c71da Update build-all.dart with the contents from master
Adding the --tests option should have been done in 1.2 branch
2020-12-21 20:19:59 +00:00
Sergio Martins
9275f852d6 CMakePresets: Enable sanitizers for our developer builds 2020-12-21 20:06:40 +00:00
Sergio Martins
dd8f46880f qtquick: Implement TabBarQuick::tabAt()
Also redirect the mouse press event to our C++ counterpart.
2020-12-21 17:09:55 +00:00
Sergio Martins
e9159a08bd Fix build when usign installed TabWidget_p.h 2020-12-21 13:31:10 +00:00
Sergio Martins
cf89891e4f Merge branch '1.2' 2020-12-21 12:43:31 +00:00
Sergio Martins
1cc8824f84 Workaround shiboken crash, found by Milian 2020-12-21 12:41:09 +00:00
Sergio Martins
b73c526c57 qtquick: Move the event redirector to the base class
Instead of having it in TitleBarQuick.
It will be needed by the TabWidget too
2020-12-20 17:12:44 +00:00
Sergio Martins
add577c46f qtquick: Fix title not changing when we changed current tab
added unit-test too
2020-12-20 16:30:25 +00:00
Sergio Martins
9ddd65ea71 qtquick: tidy some connects 2020-12-20 15:37:17 +00:00
Sergio Martins
b15afa9231 Move TabWidget instantiation to base class Frame
Instead of being instantiated by both FrameQuick and FrameWidget
2020-12-20 14:21:39 +00:00
Allen Winter
f8dfde2784 README.md - add a "Using" section 2020-12-20 08:27:00 -05:00
Sergio Martins
6e0898a31e Remove some methods from TabWidgetQuick
Reuse more from base class.
2020-12-20 13:19:07 +00:00
Sergio Martins
8b98dafba2 TabBar::numDockWidgets() doesn't need to be virtual 2020-12-20 12:32:50 +00:00
Sergio Martins
a123437d03 qtquick: Implement the TabWidget backend
Not yet connected to the GUI.
2020-12-20 12:06:29 +00:00
Sergio Martins
616c871da7 qtquick: initialize the tab widget via the factory 2020-12-20 11:25:50 +00:00
Sergio Martins
925c9725b3 qtquick: Build TabBarQuick too 2020-12-20 01:09:02 +00:00
Sergio Martins
1a173a7c72 Add a TabWidgetQuick.cpp
Doesn't do much yet
2020-12-20 01:02:55 +00:00
Sergio Martins
a959da46db qtquick: Build TabWidget.cpp too
Not being used yet though.
2020-12-20 01:01:20 +00:00
Sergio Martins
a9c70d086c qtquick: Move TabWidget_p.h out of widgets/
To be shared with qtquick
2020-12-20 00:07:07 +00:00
Sergio Martins
48bacb2811 build-all: Add option to run the tests 2020-12-19 23:30:09 +00:00
Sergio Martins
6b846fcdff qt6: Use more 'auto' to fix some Wconversion errors 2020-12-19 22:54:06 +00:00
Sergio Martins
fdc97fecaf build-all: Don't test the unity variations by default 2020-12-19 22:16:29 +00:00
Sergio Martins
86983d58f5 Merge branch '1.2' 2020-12-19 20:05:19 +00:00
Sergio Martins
58f7edb0bc build-all: Build with unity turned off too
As it often finds builds failures to do missing includes
2020-12-19 20:00:05 +00:00
Sergio Martins
302bbeceb0 Merge branch '1.2' 2020-12-19 19:02:46 +00:00
Sergio Martins
cd9e16398c qtquick: Fix the build for Qt6
And added cmake presets for Qt6
2020-12-19 18:59:33 +00:00
Sergio Martins
1e1ea8db34 qtquick: fix build 2020-12-19 18:04:54 +00:00
Sergio Martins
7ac3ea1fcf Merge branch '1.2' 2020-12-19 17:52:52 +00:00
Sergio Martins
3f661d0322 Add dev-scripts/build-all.dart
This script builds all our supported configurations.
Useful if you don't have access to KDAB CI, or if you don't want
to wait for the results.
2020-12-19 17:51:29 +00:00
Sergio Martins
8dad079df5 Add a CMakePresets.json
Contains the configrations we support:
    QtWidgets, QtQuick, static, Python and developer-build
2020-12-19 16:07:49 +00:00
Sergio Martins
1727e50489 Merge branch '1.2' 2020-12-19 15:44:59 +00:00
Sergio Martins
1ab9688f58 Fix Python build 2020-12-19 15:44:44 +00:00
Sergio Martins
613b1b8524 Allow the user to change the absolute min and max widget sizes.
It's not hardcoded anymore
2020-12-19 15:34:37 +00:00
Sergio Martins
ae5edc9ebf Added README-troubleshooting
Fixes issue #114
2020-12-19 14:59:40 +00:00
Sergio Martins
d0c15b5da2 Add missing include 2020-12-19 14:59:04 +00:00
Sergio Martins
ccbd15c922 Merge branch '1.2' 2020-12-19 14:12:10 +00:00
Sergio Martins
7b9673e4e2 Shrink the overlay popup when we shrink the main window
Should be enough for issue #118
2020-12-19 14:10:01 +00:00
Sergio Martins
7fbcbbacdf Preserve overlay size when resizing main window
For issue #118
2020-12-19 14:09:27 +00:00
Sergio Martins
d1f48b0685 Save the last overlayed size
We might want to restore it
2020-12-19 14:09:27 +00:00
Allen Winter
9ee6b91f61 Merge branch '1.2' 2020-12-18 13:04:02 -05:00
Allen Winter
e6c89c0564 setup for 1.2.1 2020-12-18 13:02:49 -05:00
Sergio Martins
8b97088c70 Fix QtQuick build 2020-12-18 17:39:24 +00:00
Sergio Martins
e5809c06c7 Enable resizing the overlayed dock widgets
Fixed WidgetResizeHandler to not allow it to resize the overlay
bigger than its parent

For issue #116

The size isn't remembered though. Next time you open the overlay
it will have the previous size.
2020-12-18 17:15:54 +00:00
Sergio Martins
23b69d4e9e Fix overlay disappearing when we were resizing
We allow the user to click 4px outside of the overlay for better
resizing. But we also had code that would hide the overlay if we
clicked elsewhere. So these two requirements were in conflict.

So, before hidding, check if the frame accepted the press.

Also for issue #118
2020-12-18 16:02:35 +00:00
Sergio Martins
0f468033fb Commit the code needed for resizing overlays/popups
Still not happy with it, so the actual part that enables it
is commented out

Also for issue #118
2020-12-18 15:35:43 +00:00
Sergio Martins
468074cda8 Fix min/max not being respected when resizing overlay popup
While the min size wasn't set the min size hint was.
Use our wrapper which honours the size hint.

Also for isssue #118
2020-12-18 15:32:43 +00:00
Sergio Martins
7acbe0c62e Make the WidgetResizeHandler margin public 2020-12-18 15:23:52 +00:00
Sergio Martins
2c1a70280a WidgetResizeHandler: Fix the geometry calculation for non-toplevels 2020-12-18 15:20:58 +00:00
Sergio Martins
d2fa5efafe Add Utils::globalGeometry() 2020-12-18 14:29:44 +00:00
Sergio Martins
a437bc5d07 Minor WidgetResizeHandler cleanups 2020-12-18 12:11:28 +00:00
Sergio Martins
2447bb12c8 WidgetResizeHandler: Dont' accept the release if we're not resizing 2020-12-18 11:58:08 +00:00
Sergio Martins
1082d5e8e1 Added WidgetResizeHandler::setAllowedResizeSides() 2020-12-18 10:43:36 +00:00
Sergio Martins
3b1ac9a2d0 Merge branch '1.2' 2020-12-17 20:38:49 +00:00
Sergio Martins
4635405fb5 Allow WidgetResizeHandler to act on global event filter
Needed for widgets which are not top-levels
2020-12-17 19:47:19 +00:00
Sergio Martins
c481875e55 Fix WidgetResizeHandler::cursorPosition() for negative positions
Usually we don't get negative relative positions, since we're
tracking top-level widgets which wouldn't receive exterior mouse
events to begin with.
But we want the WidgetResizeHandler to work for embedded widgets
too, for example for the sidebar overlays.
2020-12-17 19:47:19 +00:00
Sergio Martins
62f50f9458 Minor coding style 2020-12-17 19:47:19 +00:00
Sergio Martins
c86252665c Make WidgetResizeHandler::mouseMoveEvent() return bool
Returns true if it consumed the event
2020-12-17 19:47:19 +00:00
Sergio Martins
d141863ffb Make a method private 2020-12-17 19:47:19 +00:00
Sergio Martins
e99b9678e4 Add WidgetResizeHandler::restoreMouseCursor() 2020-12-17 19:47:19 +00:00
Sergio Martins
e0a034748d Factor out setting the mouse cursor
We'll soon also need to call qApp's set cursor
2020-12-17 19:47:19 +00:00
Sergio Martins
c3377431cc docs++ 2020-12-17 19:47:19 +00:00
Sergio Martins
be0f72ca25 Remove unneeded method 2020-12-17 17:05:55 +00:00
Sergio Martins
31598d8334 Make a variable private 2020-12-17 16:59:21 +00:00
Sergio Martins
5e64463a8c Remove some Item_p.h/multisplitter includes
that's private API for the layouts, don't want them exposed higher
in the stack
2020-12-17 13:48:50 +00:00
Sergio Martins
27ffb64eb4 Merge branch '1.2' 2020-12-17 12:45:33 +00:00
Sergio Martins
c7dc7bdb3d Bump so version on master 2020-12-17 11:15:42 +00:00
257 changed files with 4956 additions and 2842 deletions

68
.vscode/launch.json vendored
View File

@@ -1,68 +0,0 @@
{
"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
View File

@@ -1,10 +0,0 @@
{
"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,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2019-2021 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
@@ -82,9 +82,9 @@ endif()
set(${PROJECT_NAME}_VERSION_MAJOR 1)
set(${PROJECT_NAME}_VERSION_MINOR 2)
set(${PROJECT_NAME}_VERSION_PATCH 0)
set(${PROJECT_NAME}_VERSION_PATCH 1)
set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH})
set(${PROJECT_NAME}_SOVERSION "1.2")
set(${PROJECT_NAME}_SOVERSION "1.3")
include(FeatureSummary)
@@ -104,10 +104,12 @@ 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)
option(${PROJECT_NAME}_WERROR "Use -Werror (will be true for developer-mode unconditionally)" OFF)
#Always build the test harness in developer-mode
if(${PROJECT_NAME}_DEVELOPER_MODE)
set(${PROJECT_NAME}_TESTS ON)
set(${PROJECT_NAME}_WERROR ON)
endif()
#option(${PROJECT_NAME}_QTQUICK "Build for QtQuick instead of QtWidgets" OFF)
@@ -137,18 +139,26 @@ include(QtInstallPaths) #to set QT_INSTALL_FOO variables
macro(set_compiler_flags targetName)
if(${PROJECT_NAME}_DEVELOPER_MODE)
target_compile_definitions(${targetName} PUBLIC DOCKS_DEVELOPER_MODE PRIVATE QT_FORCE_ASSERTS)
if(NOT MSVC AND NOT ${PROJECT_NAME}_QT6) # We're not warnings clean with Qt6 yet
target_compile_options(${targetName} PRIVATE -Wall -Wextra -Werror -Wno-error=deprecated-declarations)
if (APPLE)
target_compile_options(${targetName} PRIVATE -Wweak-vtables)
endif()
if(NOT MSVC)
target_compile_options(${targetName} PRIVATE -Wall -Wextra)
endif()
if(APPLE)
target_compile_options(${targetName} PRIVATE -Wweak-vtables)
endif()
endif()
# Enable -Werror
if(NOT MSVC AND ${PROJECT_NAME}_WERROR)
target_compile_options(${targetName} PRIVATE -Werror -Wno-error=deprecated-declarations)
endif()
endmacro()
if(${PROJECT_NAME}_QTQUICK)
find_package(Qt5Quick)
find_package(Qt5QuickControls2)
find_package(Qt${QT_MAJOR_VERSION}Quick)
find_package(Qt${QT_MAJOR_VERSION}QuickControls2)
add_definitions(-DKDDOCKWIDGETS_QTQUICK)
else()
add_definitions(-DKDDOCKWIDGETS_QTWIDGETS)
@@ -233,7 +243,6 @@ if(${PROJECT_NAME}_DEVELOPER_MODE)
add_test(NAME tst_multisplitter COMMAND tst_multisplitter)
endif()
add_test(NAME tst_docks COMMAND tst_docks)
endif()
endif()

139
CMakePresets.json Normal file
View File

@@ -0,0 +1,139 @@
{
"version": 1,
"configurePresets": [
{
"name": "dev-qtwidgets",
"displayName": "dev-qtwidgets",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-dev-qtwidgets",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"KDDockWidgets_DEVELOPER_MODE": "ON",
"ECM_ENABLE_SANITIZERS" : "'address;undefined'",
"CMAKE_EXPORT_COMPILE_COMMANDS" : "ON",
"KDDockWidgets_UNITY_BUILD" : "OFF"
}
},
{
"name": "clazy-qtwidgets",
"displayName": "clazy-qtwidgets",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-clazy-qtwidgets",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"KDDockWidgets_WERROR": "ON"
},
"environment": {
"CXX": "clazy"
}
},
{
"name": "qtwidgets",
"displayName": "qtwidgets",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-qtwidgets",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "qtquick",
"displayName": "qtquick",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-qtquick",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"KDDockWidgets_QTQUICK": "ON"
}
},
{
"name": "dev-qtquick",
"displayName": "dev-qtquick",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-dev-qtquick",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"KDDockWidgets_QTQUICK": "ON",
"KDDockWidgets_DEVELOPER_MODE": "ON",
"ECM_ENABLE_SANITIZERS" : "'address;undefined'",
"CMAKE_EXPORT_COMPILE_COMMANDS" : "ON",
"KDDockWidgets_UNITY_BUILD" : "OFF"
}
},
{
"name": "python",
"displayName": "python",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-python",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"KDDockWidgets_PYTHON_BINDINGS": "ON"
}
},
{
"name": "static-qtwidgets",
"displayName": "static-qtwidgets",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-static-qtwidgets",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"KDDockWidgets_STATIC": "ON"
}
},
{
"name": "static-qtquick",
"displayName": "static-qtquick",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-static-qtquick",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"KDDockWidgets_STATIC": "ON",
"KDDockWidgets_QTQUICK": "ON"
}
},
{
"name": "qtwidgets6",
"displayName": "qtwidgets6",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-qtwidgets6",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"KDDockWidgets_QT6": "ON"
},
"environment": {
"PATH": "$env{HOME}/Qt/6.0.0/gcc_64/bin:$penv{PATH}"
}
},
{
"name": "dev-qtwidgets6",
"displayName": "dev-qtwidgets6",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-dev-qtwidgets6",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"KDDockWidgets_QT6": "ON",
"KDDockWidgets_DEVELOPER_MODE": "ON",
"CMAKE_EXPORT_COMPILE_COMMANDS" : "ON",
"KDDockWidgets_UNITY_BUILD" : "OFF",
"ECM_ENABLE_SANITIZERS" : "'address;undefined'"
},
"environment": {
"PATH": "$env{HOME}/Qt/6.0.0/gcc_64/bin:$penv{PATH}"
}
},
{
"name": "qtquick6",
"displayName": "qtquick6",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-qtquick6",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"KDDockWidgets_QTQUICK": "ON",
"KDDockWidgets_QT6": "ON"
},
"environment": {
"PATH": "$env{HOME}/Qt/6.0.0/gcc_64/bin:$penv{PATH}"
}
}
]
}

View File

@@ -1,5 +1,19 @@
* v1.3.0 (unreleased)
- [TODO] QtQuick support
- Added static DockWidgetBase::byName() (#126)
- The enum KDDockWidgets::AddingOption has been deprecated, use
KDDockWidgets::InitialVisibilityOption instead
- You can now pass a preferred initial size to MainWindow::addDockWidget() (#95)
- Added DockWidgetBase::Option_DeleteOnClose
- Added Config::Flag_CloseOnlyCurrentTab
- PySide6 support
- Layout restorer now restores maximzied/minimized state too (#81)
- Fixed dock indicators sometimes not appearing on Windows (#103)
- Fixed Flag_NativeTitleBar not working
* v1.2.1 (unreleased)
- Support for resizing dock widgets when they are in overlay/popup mode (autohide/sidebar feature)
- Fixed title bar close button enabled state not being restored with Layout saver (#137)
* v1.2.0 (17 December 2020)
- Wayland support

View File

@@ -1,4 +1,4 @@
The KDDockWidgets software is Copyright (C) 2018-2020 Klaralvdalens Datakonsult AB.
The KDDockWidgets software is Copyright (C) 2018-2021 Klaralvdalens Datakonsult AB.
You may use, distribute and copy the KDDockWidgets software under the terms of
the GNU General Public License version 2 or under the terms of GNU General

View File

@@ -1,4 +1,4 @@
KDDockWidgets is (C) 2018-2020, Klarälvdalens Datakonsult AB, and is licensed
KDDockWidgets is (C) 2018-2021, 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

View File

@@ -6,9 +6,13 @@ KDDockWidgets works with WebAssembly with the following known limitations:
- Classic drop indicators are not supported, only the segmented ones. This is because
WASM doesn't support windows with translucency.
- It's slow while dragging Windows and resizing.
- Might be slow on Linux, depending on your browser, while dragging or resizing windows.
Please file a bug with Qt, as it's out of scope for KDDW to fix.
Demo:
=====
A demo is available at https://demos.kdab.com/wasm/kddockwidgets/dockwidgets.html
Build tips for KDDW:
====================
@@ -20,7 +24,7 @@ Build tips for KDDW:
Builds tips for your own app:
=============================
- Link to KDDW (libkddockwidgets.so, or similar)
- Link to KDDW (libkddockwidgets.a, or similar)
- As the build is static, don't forget to initialize KDDW's resources:
```
#ifdef QT_STATIC

3
README-troubleshooting Normal file
View File

@@ -0,0 +1,3 @@
# PySide: `ImportError: DLL load failed while importing KDDockWidgets`
If you're getting this error with Python see issue #114 and the proposed solution there.

View File

@@ -24,6 +24,9 @@ You will find more information in these places:
* [online detailed browsable API reference](https://docs.kdab.com/kddockwidgets)
* [our example programs](examples/)
We also have an [in browser demo](https://demos.kdab.com/wasm/kddockwidgets/dockwidgets.html). Note
however that this demo isn't fully featured, as it's running on Qt for WebAssembly.
Features
========
- Provide advanced docking that QDockWidgets doesn't support
@@ -61,6 +64,8 @@ Features
- Optional minimize and maximize button on the title bar
- FloatingWindows can be utility windows or full native
Screen capture
==============
![Screen capture](./screencap.gif?raw=true "The docking system in action")
@@ -100,16 +105,31 @@ The installation directory defaults to `c:\KDAB\KDDockWidgets-<version>` on Wind
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.
Using
=====
From your CMake project, add
find_package(KDDockWidgets CONFIG)
and link to the imported target `KDAB::kddockwidgets`.
That's all you need to do (the imported target also brings in the include directories)
You may also need to modify the `CMAKE_MODULE_PATH` environment variable depending
on where you installed KDDockWidgets.
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
```
% 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
@@ -134,15 +154,19 @@ $ python3 main.py
```
Supported Qt versions
======================
Supported Qt versions and toolchains
=====================================
KDDockWidgets requires Qt >= 5.9 (or >=5.12 if Python bindings are enabled).
The QtQuick support will require Qt >= 5.15.
Qt 6 will be support as long as QTBUG-88611 is finished, most likely for 6.1.
Qt 6 is supported.
Regarding compilers, whatever toolchain is able to build Qt 5.9 should also be
fine. Note however that MSVC 2013 isn't supported anymore due to compiler crashes.
Licensing
=========
KDDockWidgets is (C) 2018-2020, Klarälvdalens Datakonsult AB, and is licensed according to
KDDockWidgets is (C) 2018-2021, 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.
@@ -178,3 +202,4 @@ Stay up-to-date with KDAB product announcements:
* [KDAB Newsletter](https://news.kdab.com)
* [KDAB Blogs](https://www.kdab.com/category/blogs)
* [KDAB on Twitter](https://twitter.com/KDABQt)

View File

@@ -1,5 +1,5 @@
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -0,0 +1,134 @@
#
# SPDX-FileCopyrightText: 2020-2021 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 PySide6 installation
# PYSIDE_INCLUDE_DIR - Directories to include to use PySide6
# PYSIDE_LIBRARY - Files to link against to use PySide6
# PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide6
#
# You can install PySide6 from Qt repository with
# pip3 install --index-url=https://download.qt.io/official_releases/QtForPython --trusted-host download.qt.io pyside6
set(PYSIDE6_FOUND FALSE)
# 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 PySide6.QtCore as QtCore
print(os.path.dirname(QtCore.__file__))
except Exception as error:
print(error, file=sys.stderr)
exit()
"
OUTPUT_VARIABLE PYSIDE6_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(PYSIDE6_BASEDIR)
set(PYSIDE_BASEDIR ${PYSIDE6_BASEDIR} CACHE PATH "Top level install of PySide6" FORCE)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
import PySide6.QtCore as QtCore
print(os.path.basename(QtCore.__file__).split('.', 1)[1])
"
OUTPUT_VARIABLE PYSIDE6_SUFFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
import PySide6.QtCore as QtCore
print(';'.join(map(str, QtCore.__version_info__)))
"
OUTPUT_VARIABLE PYSIDE6_SO_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
list(GET PYSIDE6_SO_VERSION 0 PYSIDE6_SO_MACRO_VERSION)
list(GET PYSIDE6_SO_VERSION 1 PYSIDE6_SO_MICRO_VERSION)
list(GET PYSIDE6_SO_VERSION 2 PYSIDE6_SO_MINOR_VERSION)
string(REPLACE ";" "." PYSIDE6_SO_VERSION "${PYSIDE6_SO_VERSION}")
if(NOT APPLE)
set(PYSIDE6_SUFFIX "${PYSIDE6_SUFFIX}.${PYSIDE6_SO_MACRO_VERSION}.${PYSIDE6_SO_MICRO_VERSION}")
else()
string(REPLACE ".so" "" PYSIDE6_SUFFIX ${PYSIDE6_SUFFIX})
set(PYSIDE6_SUFFIX "${PYSIDE6_SUFFIX}.${PYSIDE6_SO_MACRO_VERSION}.${PYSIDE6_SO_MICRO_VERSION}.dylib")
endif()
set(PYSIDE6_FOUND TRUE)
message(STATUS "PySide6 base dir: ${PYSIDE6_BASEDIR}" )
message(STATUS "PySide6 suffix: ${PYSIDE6_SUFFIX}")
endif()
if (PYSIDE6_FOUND)
#PySide
#===============================================================================
find_path(PYSIDE_INCLUDE_DIR
pyside.h
PATHS ${PYSIDE6_BASEDIR}/include ${PYSIDE6_CUSTOM_PREFIX}/include/PySide6
NO_DEFAULT_PATH)
# Platform specific library names
if(MSVC)
SET(PYSIDE_LIBRARY_BASENAMES "pyside6.abi3.lib")
elseif(CYGWIN)
SET(PYSIDE_LIBRARY_BASENAMES "")
elseif(WIN32)
SET(PYSIDE_LIBRARY_BASENAMES "libpyside6.${PYSIDE6_SUFFIX}")
else()
SET(PYSIDE_LIBRARY_BASENAMES "libpyside6.${PYSIDE6_SUFFIX}")
endif()
find_file(PYSIDE_LIBRARY
${PYSIDE_LIBRARY_BASENAMES}
PATHS ${PYSIDE6_BASEDIR} ${PYSIDE6_CUSTOM_PREFIX}/lib
NO_DEFAULT_PATH)
find_path(PYSIDE_TYPESYSTEMS
typesystem_core.xml
PATHS ${PYSIDE6_BASEDIR}/typesystems ${PYSIDE6_CUSTOM_PREFIX}/share/PySide6/typesystems
NO_DEFAULT_PATH)
endif()
if(PYSIDE6_FOUND)
message(STATUS "PySide include dir: ${PYSIDE_INCLUDE_DIR}")
message(STATUS "PySide library: ${PYSIDE_LIBRARY}")
message(STATUS "PySide typesystems: ${PYSIDE_TYPESYSTEMS}")
message(STATUS "PySide6 version: ${PYSIDE6_SO_VERSION}")
# Create PySide6 target
add_library(PySide6::pyside6 SHARED IMPORTED GLOBAL)
if(MSVC)
set_property(TARGET PySide6::pyside6 PROPERTY
IMPORTED_IMPLIB ${PYSIDE_LIBRARY})
endif()
set_property(TARGET PySide6::pyside6 PROPERTY
IMPORTED_LOCATION ${PYSIDE_LIBRARY})
set_property(TARGET PySide6::pyside6 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(PySide6
REQUIRED_VARS PYSIDE6_BASEDIR PYSIDE_INCLUDE_DIR PYSIDE_LIBRARY PYSIDE_TYPESYSTEMS
VERSION_VAR PYSIDE6_SO_VERSION
)

View File

@@ -1,5 +1,5 @@
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -0,0 +1,165 @@
#
# SPDX-FileCopyrightText: 2020-2021 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 shiboken6-generator
set(SHIBOKEN_FOUND FALSE)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
try:
import shiboken6_generator
print(shiboken6_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 shiboken6
print(shiboken6.__path__[0])
except:
exit()
"
OUTPUT_VARIABLE SHIBOKEN_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
import shiboken6
print(';'.join(filter(None, map(str, shiboken6.__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 "shiboken6.abi3.lib")
elseif(CYGWIN)
SET(SHIBOKEN_LIBRARY_BASENAMES "")
elseif(WIN32)
SET(SHIBOKEN_LIBRARY_BASENAMES "libshiboken6.${PYSIDE2_SUFFIX}")
elseif(APPLE)
SET(SHIBOKEN_LIBRARY_BASENAMES
libshiboken6.abi3.dylib
libshiboken6.abi3.${SHIBOKEN_MACRO_VERSION}.dylib
libshiboken6.abi3.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}.dylib
libshiboken6.abi3.${SHIBOKEN_VERSION}.dylib
)
else()
SET(SHIBOKEN_LIBRARY_BASENAMES
libshiboken6.abi3.so
libshiboken6.abi3.so.${SHIBOKEN_MACRO_VERSION}
libshiboken6.abi3.so.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}
libshiboken6.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
shiboken6
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()
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(Shiboken6::libshiboken SHARED IMPORTED GLOBAL)
if(MSVC)
set_property(TARGET Shiboken6::libshiboken PROPERTY
IMPORTED_IMPLIB ${SHIBOKEN_LIBRARY})
endif()
set_property(TARGET Shiboken6::libshiboken PROPERTY
IMPORTED_LOCATION ${SHIBOKEN_LIBRARY})
set_property(TARGET Shiboken6::libshiboken APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${SHIBOKEN_INCLUDE_DIR} ${Python3_INCLUDE_DIRS})
set_property(TARGET Shiboken6::libshiboken APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${PYTHON_LIMITED_LIBRARIES})
# Generator target
add_executable(Shiboken6::shiboken IMPORTED GLOBAL)
set_property(TARGET Shiboken6::shiboken PROPERTY
IMPORTED_LOCATION ${SHIBOKEN_BINARY})
endif()
find_package_handle_standard_args(Shiboken6
REQUIRED_VARS SHIBOKEN_BASEDIR SHIBOKEN_INCLUDE_DIR SHIBOKEN_LIBRARY SHIBOKEN_BINARY
VERSION_VAR SHIBOKEN_VERSION
)

View File

@@ -1,5 +1,5 @@
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -0,0 +1,157 @@
#
# SPDX-FileCopyrightText: 2020-2021 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 Qt6::Core FRAMEWORK)
if (QtCore_is_framework)
# Get the path to the framework dir.
list(GET Qt6Core_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:Shiboken6::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}
PySide6::pyside6
Shiboken6::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

@@ -1,5 +1,5 @@
#
# SPDX-FileCopyrightText: 2016-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2016-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Allen Winter <allen.winter@kdab.com>
#
# SPDX-License-Identifier: BSD-3-Clause

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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.

View File

@@ -0,0 +1,42 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"C_Cpp.default.compileCommands": "${workspaceFolder}/build-dev-qtquick/compile_commands.json",
"C_Cpp.default.cStandard": "c17",
"files.trimTrailingWhitespace": true
},
"tasks": {
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "cmake",
"command": "cmake",
"args": [
"--preset=dev-qtquick"
],
"options": {
"cwd": "${workspaceFolder}/"
},
"group": "build"
},
{
"type": "shell",
"label": "make",
"command": "cmake",
"args": [
"--build",
"${workspaceFolder}/build-dev-qtquick"
],
"options": {
"cwd": "${workspaceFolder}/"
},
"group": "build"
}
]
}
}

View File

@@ -0,0 +1,42 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"C_Cpp.default.compileCommands": "${workspaceFolder}/build-dev-qtwidgets/compile_commands.json",
"C_Cpp.default.cStandard": "c17",
"files.trimTrailingWhitespace": true
},
"tasks": {
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "cmake",
"command": "cmake",
"args": [
"--preset=dev-qtwidgets"
],
"options": {
"cwd": "${workspaceFolder}/"
},
"group": "build"
},
{
"type": "shell",
"label": "make",
"command": "cmake",
"args": [
"--build",
"${workspaceFolder}/build-dev-qtwidgets"
],
"options": {
"cwd": "${workspaceFolder}/"
},
"group": "build"
}
]
}
}

View File

@@ -0,0 +1,48 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"C_Cpp.default.compileCommands": "${workspaceFolder}/build-dev-qtwidgets6/compile_commands.json",
"C_Cpp.default.cStandard": "c17",
"files.trimTrailingWhitespace": true
},
"tasks": {
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "cmake",
"command": "cmake",
"args": [
"--preset=dev-qtwidgets6"
],
"options": {
"cwd": "${workspaceFolder}/"
},
"group": "build",
"problemMatcher": [
"$gcc"
]
},
{
"type": "shell",
"label": "make",
"command": "cmake",
"args": [
"--build",
"${workspaceFolder}/build-dev-qtwidgets6"
],
"options": {
"cwd": "${workspaceFolder}/"
},
"group": "build",
"problemMatcher": [
"$gcc"
]
}
]
}
}

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2019-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -17,6 +17,8 @@
#include <QApplication>
// clazy:excludeall=missing-qobject-macro,ctor-missing-parent-argument
class MyTitleBar : public KDDockWidgets::TitleBarWidget
{
public:

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -15,8 +15,11 @@
#include <QPainter>
// clazy:excludeall=ctor-missing-parent-argument
class CustomWidgetFactory : public KDDockWidgets::DefaultWidgetFactory
{
Q_OBJECT
public:
KDDockWidgets::TitleBar *createTitleBar(KDDockWidgets::Frame *frame) const override;
KDDockWidgets::TitleBar *createTitleBar(KDDockWidgets::FloatingWindow *fw) const override;

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <time.h>
// clazy:excludeall=qstring-allocations
// clazy:excludeall=qstring-allocations,ctor-missing-parent-argument,detaching-member
static MyWidget *newMyWidget()
{
@@ -52,13 +52,14 @@ static MyWidget *newMyWidget()
MyMainWindow::MyMainWindow(const QString &uniqueName, KDDockWidgets::MainWindowOptions options,
bool dockWidget0IsNonClosable, bool nonDockableDockWidget9, bool restoreIsRelative,
bool maxSizeForDockWidget8,
bool maxSizeForDockWidget8, bool dockwidget5DoesntCloseBeforeRestore,
const QString &affinityName, QWidget *parent)
: MainWindow(uniqueName, options, parent)
, m_dockWidget0IsNonClosable(dockWidget0IsNonClosable)
, m_dockWidget9IsNonDockable(nonDockableDockWidget9)
, m_restoreIsRelative(restoreIsRelative)
, m_maxSizeForDockWidget8(maxSizeForDockWidget8)
, m_dockwidget5DoesntCloseBeforeRestore(dockwidget5DoesntCloseBeforeRestore)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
qsrand(time(nullptr));
@@ -135,26 +136,26 @@ void MyMainWindow::createDockWidgets()
// MainWindow::addDockWidget() attaches a dock widget to the main window:
addDockWidget(m_dockwidgets[0], KDDockWidgets::Location_OnTop);
addDockWidget(m_dockwidgets.at(0), KDDockWidgets::Location_OnTop);
// Here, for finer granularity we specify right of dockwidgets[0]:
addDockWidget(m_dockwidgets[1], KDDockWidgets::Location_OnRight, m_dockwidgets[0]);
addDockWidget(m_dockwidgets.at(1), KDDockWidgets::Location_OnRight, m_dockwidgets.at(0));
addDockWidget(m_dockwidgets[2], KDDockWidgets::Location_OnLeft);
addDockWidget(m_dockwidgets[3], KDDockWidgets::Location_OnBottom);
addDockWidget(m_dockwidgets[4], KDDockWidgets::Location_OnBottom);
addDockWidget(m_dockwidgets.at(2), KDDockWidgets::Location_OnLeft);
addDockWidget(m_dockwidgets.at(3), KDDockWidgets::Location_OnBottom);
addDockWidget(m_dockwidgets.at(4), KDDockWidgets::Location_OnBottom);
// Tab two dock widgets together
m_dockwidgets[3]->addDockWidgetAsTab(m_dockwidgets[5]);
m_dockwidgets[3]->addDockWidgetAsTab(m_dockwidgets.at(5));
// 6 is floating, as it wasn't added to the main window via MainWindow::addDockWidget().
// and we tab 7 with it.
m_dockwidgets[6]->addDockWidgetAsTab(m_dockwidgets[7]);
m_dockwidgets[6]->addDockWidgetAsTab(m_dockwidgets.at(7));
// Floating windows also support nesting, here we add 8 to the bottom of the group
m_dockwidgets[6]->addDockWidgetToContainingWindow(m_dockwidgets[8], KDDockWidgets::Location_OnBottom);
m_dockwidgets[6]->addDockWidgetToContainingWindow(m_dockwidgets.at(8), KDDockWidgets::Location_OnBottom);
auto floatingWindow = m_dockwidgets[6]->window();
auto floatingWindow = m_dockwidgets.at(6)->window();
floatingWindow->move(100, 100);
}
@@ -164,13 +165,18 @@ KDDockWidgets::DockWidgetBase *MyMainWindow::newDockWidget()
// Passing options is optional, we just want to illustrate Option_NotClosable here
KDDockWidgets::DockWidget::Options options = KDDockWidgets::DockWidget::Option_None;
KDDockWidgets::DockWidget::LayoutSaverOptions layoutSaverOptions = KDDockWidgets::DockWidget::LayoutSaverOption::None;
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);
if (count == 5 && m_dockwidget5DoesntCloseBeforeRestore)
layoutSaverOptions |= KDDockWidgets::DockWidget::LayoutSaverOption::Skip;
auto dock = new KDDockWidgets::DockWidget(QStringLiteral("DockWidget #%1").arg(count), options, layoutSaverOptions);
dock->setAffinities(affinities()); // optional, just to show the feature. Pass -mi to the example to see incompatible dock widgets
if (count == 1)

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -20,7 +20,7 @@ class MyMainWindow : public KDDockWidgets::MainWindow
public:
explicit MyMainWindow(const QString &uniqueName, KDDockWidgets::MainWindowOptions options,
bool dockWidget0IsNonClosable, bool nonDockableDockWidget9, bool restoreIsRelative,
bool maxSizeForDockWidget8,
bool maxSizeForDockWidget8, bool dockwidget5DoesntCloseBeforeRestore,
const QString &affinityName = {}, // Usually not needed. Just here to show the feature.
QWidget *parent = nullptr);
~MyMainWindow() override;
@@ -33,5 +33,6 @@ private:
const bool m_dockWidget9IsNonDockable;
const bool m_restoreIsRelative;
const bool m_maxSizeForDockWidget8;
const bool m_dockwidget5DoesntCloseBeforeRestore;
KDDockWidgets::DockWidget::List m_dockwidgets;
};

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -34,6 +34,7 @@ protected:
class MyWidget1 : public MyWidget
{
Q_OBJECT
public:
explicit MyWidget1(QWidget *parent = nullptr);
protected:
@@ -42,6 +43,7 @@ protected:
class MyWidget2 : public MyWidget
{
Q_OBJECT
public:
explicit MyWidget2(QWidget *parent = nullptr);
protected:
@@ -50,6 +52,7 @@ protected:
class MyWidget3 : public MyWidget
{
Q_OBJECT
public:
explicit MyWidget3(QWidget *parent = nullptr);
protected:

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -111,6 +111,14 @@ int main(int argc, char **argv)
QCommandLineOption autoHideSupport("w", QCoreApplication::translate("main", "Enables auto-hide/minimization to side-bar support"));
parser.addOption(autoHideSupport);
QCommandLineOption closeOnlyCurrentTab("close-only-current-tab",
QCoreApplication::translate("main", "The title bar's close button will only close the current tab instead of all. Illustrates using Config::Flag_CloseOnlyCurrentTab"));
parser.addOption(closeOnlyCurrentTab);
QCommandLineOption dontCloseBeforeRestore("dont-close-widget-before-restore",
QCoreApplication::translate("main", "DockWidget #5 wont be closed before a restore. Illustrates LayoutSaverOption::DontCloseBeforeRestore"));
parser.addOption(dontCloseBeforeRestore);
#if defined(DOCKS_DEVELOPER_MODE)
parser.addOption(centralFrame);
@@ -147,17 +155,19 @@ int main(int argc, char **argv)
MainWindowOptions options = MainWindowOption_None;
auto flags = KDDockWidgets::Config::self().flags();
#if defined(DOCKS_DEVELOPER_MODE)
auto internalFlags = KDDockWidgets::Config::self().internalFlags();
options = parser.isSet(centralFrame) ? MainWindowOption_HasCentralFrame
: MainWindowOption_None;
if (parser.isSet(noQtTool))
flags |= KDDockWidgets::Config::Flag_internal_DontUseQtToolWindowsForFloatingWindows;
internalFlags |= KDDockWidgets::Config::InternalFlag_DontUseQtToolWindowsForFloatingWindows;
if (parser.isSet(keepAbove))
flags |= KDDockWidgets::Config::Flag_KeepAboveIfNotUtilityWindow;
if (parser.isSet(noParentForFloating))
flags |= KDDockWidgets::Config::Flag_internal_DontUseParentForFloatingWindows;
internalFlags |= KDDockWidgets::Config::InternalFlag_DontUseParentForFloatingWindows;
if (parser.isSet(nativeTitleBar))
flags |= KDDockWidgets::Config::Flag_NativeTitleBar;
@@ -167,14 +177,17 @@ int main(int argc, char **argv)
# if defined(Q_OS_WIN)
if (parser.isSet(noAeroSnap))
flags |= KDDockWidgets::Config::Flag_internal_NoAeroSnap;
internalFlags |= KDDockWidgets::Config::InternalFlag_NoAeroSnap;
# endif
Config::self().setInternalFlags(internalFlags);
#endif
if (parser.isSet(autoHideSupport))
flags |= Config::Flag_AutoHideSupport;
if (parser.isSet(closeOnlyCurrentTab))
flags |= Config::Flag_CloseOnlyCurrentTab;
if (parser.isSet(noTitleBars))
flags |= KDDockWidgets::Config::Flag_HideTitleBarWhenTabsVisible;
@@ -225,6 +238,7 @@ int main(int argc, char **argv)
const bool restoreIsRelative = parser.isSet(relativeRestore);
const bool nonDockableDockWidget9 = parser.isSet(nonDockable);
const bool maxSizeForDockWidget8 = parser.isSet(maxSizeOption);
const bool dontCloseDockWidget5BeforeRestore = parser.isSet(dontCloseBeforeRestore);
const bool usesMainWindowsWithAffinity = parser.isSet(multipleMainWindows);
#ifdef KDDOCKWIDGETS_SUPPORTS_NESTED_MAINWINDOWS
@@ -234,7 +248,8 @@ int main(int argc, char **argv)
#endif
MyMainWindow mainWindow(QStringLiteral("MyMainWindow"), options, nonClosableDockWidget0,
nonDockableDockWidget9, restoreIsRelative, maxSizeForDockWidget8);
nonDockableDockWidget9, restoreIsRelative, maxSizeForDockWidget8,
dontCloseDockWidget5BeforeRestore);
mainWindow.setWindowTitle("Main Window 1");
mainWindow.resize(1200, 1200);
mainWindow.show();
@@ -252,7 +267,8 @@ int main(int argc, char **argv)
auto mainWindow2 = new MyMainWindow(QStringLiteral("MyMainWindow-2"), options,
nonClosableDockWidget0, nonDockableDockWidget9,
restoreIsRelative, maxSizeForDockWidget8, affinity);
restoreIsRelative, maxSizeForDockWidget8,
dontCloseDockWidget5BeforeRestore, affinity);
if (affinity.isEmpty())
mainWindow2->setWindowTitle("Main Window 2");
else
@@ -265,7 +281,8 @@ int main(int argc, char **argv)
const QString affinity = QStringLiteral("Inner-DockWidgets-2");
auto dockableMainWindow = new MyMainWindow(QStringLiteral("MyMainWindow-2"), options,
false, false, restoreIsRelative, false, affinity);
false, false, restoreIsRelative, false,
false, affinity);
dockableMainWindow->setAffinities({ affinity });

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2019-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -35,6 +35,7 @@ protected:
class MyWidget1 : public MyWidget
{
Q_OBJECT
public:
explicit MyWidget1(QWidget *parent = nullptr);
protected:
@@ -43,6 +44,7 @@ protected:
class MyWidget2 : public MyWidget
{
Q_OBJECT
public:
explicit MyWidget2(QWidget *parent = nullptr);
protected:
@@ -51,6 +53,7 @@ protected:
class MyWidget3 : public MyWidget
{
Q_OBJECT
public:
explicit MyWidget3(QWidget *parent = nullptr);
protected:

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -62,6 +62,10 @@ int main(int argc, char **argv)
QStringLiteral(":/assets/KDAB_bubble_fulcolor.png"));
dock4->setWidget(widget4);
auto dock5 = new KDDockWidgets::DockWidget(QStringLiteral("MyDock5"));
auto widget5 = new MyWidget(QStringLiteral(":/assets/base.png"),
QStringLiteral(":/assets/KDAB_bubble_fulcolor.png"));
dock5->setWidget(widget5);
// 3. Add them to the main window
mainWindow.addDockWidget(dock1, KDDockWidgets::Location_OnLeft);
@@ -70,8 +74,13 @@ int main(int argc, char **argv)
// 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();
// 5. dock4 is docked at the bottom, with 200px height
const QSize preferredSize(QSize(/*ignored*/0, 200));
mainWindow.addDockWidget(dock4, KDDockWidgets::Location_OnBottom, nullptr, preferredSize);
// 5. dock5 will be its own top level (floating window)
dock5->show();
return app.exec();
}

View File

@@ -1,6 +1,6 @@
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2019-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2019-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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
@@ -50,13 +50,14 @@ int main(int argc, char *argv[])
auto flags = KDDockWidgets::Config::self().flags();
#if defined(DOCKS_DEVELOPER_MODE)
auto internalFlags = KDDockWidgets::Config::self().internalFlags();
parser.process(app);
if (parser.isSet(noQtTool))
flags |= KDDockWidgets::Config::Flag_internal_DontUseQtToolWindowsForFloatingWindows;
internalFlags |= KDDockWidgets::Config::InternalFlag_DontUseQtToolWindowsForFloatingWindows;
if (parser.isSet(noParentForFloating))
flags |= KDDockWidgets::Config::Flag_internal_DontUseParentForFloatingWindows;
internalFlags |= KDDockWidgets::Config::InternalFlag_DontUseParentForFloatingWindows;
if (parser.isSet(nativeTitleBar))
flags |= KDDockWidgets::Config::Flag_NativeTitleBar;
@@ -65,9 +66,10 @@ int main(int argc, char *argv[])
# if defined(Q_OS_WIN)
if (parser.isSet(noAeroSnap))
flags |= KDDockWidgets::Config::Flag_internal_NoAeroSnap;
internalFlags |= KDDockWidgets::Config::InternalFlag_NoAeroSnap;
# endif
KDDockWidgets::Config::self().setInternalFlags(internalFlags);
#endif
KDDockWidgets::Config::self().setFlags(flags);

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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
@@ -11,8 +11,17 @@
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)
if (${PROJECT_NAME}_QT6)
find_package(Shiboken6 REQUIRED)
find_package(PySide6 ${Qt5Widgets_VERSION} EXACT REQUIRED)
include(PySide6ModuleBuild)
set(PYSIDE_MAJOR_VERSION "6")
else()
find_package(Shiboken2 REQUIRED)
find_package(PySide2 ${Qt5Widgets_VERSION} EXACT REQUIRED)
include(PySide2ModuleBuild)
set(PYSIDE_MAJOR_VERSION "2")
endif()
add_subdirectory(PyKDDockWidgets)

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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
@@ -20,9 +20,6 @@ set(PyKDDockWidgets_SRC
${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
@@ -47,9 +44,9 @@ set(PyKDDockWidgets_target_include_directories
# 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
Qt${QT_MAJOR_VERSION}::Core
Qt${QT_MAJOR_VERSION}::Gui
Qt${QT_MAJOR_VERSION}::Widgets
)
# changes on these files should trigger a new generation
@@ -75,7 +72,7 @@ create_python_bindings(
)
# Make module import from build dir work
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${CMAKE_CURRENT_BINARY_DIR}/__init__.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.cmake ${CMAKE_CURRENT_BINARY_DIR}/__init__.py @ONLY)
# install
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py DESTINATION ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}/PyKDDockWidgets)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/__init__.py DESTINATION ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}/PyKDDockWidgets)

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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
@@ -9,17 +9,16 @@
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
import sys
__all__ = ['KDDockWidgets']
# Preload PySide2 libraries to avoid missing libraries while loading KDDockWidgets
try:
from PySide2 import QtCore
from PySide@PYSIDE_MAJOR_VERSION@ import QtCore
# Create a alias for PySide module so we can use a single import in source files
import PySide@PYSIDE_MAJOR_VERSION@
sys.modules["PySide"] = PySide@PYSIDE_MAJOR_VERSION@
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

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -6,17 +6,22 @@
typesystem because it already include gui and core typesystem -->
<load-typesystem name="typesystem_widgets.xml" generate="no"/>
<rejection class="KDDockWidgets" function-name="qt_getEnumName"/>
<rejection class="KDDockWidgets" function-name="qt_getEnumMetaObject"/>
<!-- Our classes are declared in a namespace, so we should define this -->
<namespace-type name="KDDockWidgets">
<namespace-type name="KDDockWidgets" visible="no">
<!-- 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"/>
<primitive-type name="InitialOption"/>
<!-- Some plublic enum and flags -->
<enum-type name="Location"/>
<enum-type name="MainWindowOption" flags="MainWindowOptions"/>
<enum-type name="AddingOption"/>
<enum-type name="InitialVisibilityOption"/>
<enum-type name="RestoreOption" flags="RestoreOptions"/>
<enum-type name="DefaultSizeMode"/>
<enum-type name="FrameOption" flags="FrameOptions"/>

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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
@@ -9,9 +9,10 @@
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
from PySide2 import QtCore, QtWidgets, QtGui
from PyKDDockWidgets import KDDockWidgets
from PySide import QtCore, QtWidgets, QtGui
from MyWidget1 import MyWidget1
from MyWidget2 import MyWidget2
from MyWidget3 import MyWidget3

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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
@@ -9,7 +9,9 @@
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
from PySide2 import QtWidgets, QtGui, QtCore
import PyKDDockWidgets
from PySide import QtWidgets, QtGui, QtCore
class MyWidget(QtWidgets.QWidget):
s_images = {}

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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
@@ -9,7 +9,9 @@
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
from PySide2 import QtWidgets, QtGui
import PyKDDockWidgets
from PySide import QtWidgets, QtGui
from MyWidget import MyWidget

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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
@@ -9,8 +9,10 @@
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
from PySide2 import QtWidgets, QtGui, QtCore
import PyKDDockWidgets
from PySide import QtWidgets, QtGui, QtCore
from MyWidget import MyWidget
class MyWidget2(MyWidget):

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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
@@ -9,7 +9,9 @@
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
from PySide2 import QtWidgets, QtGui, QtCore
import PyKDDockWidgets
from PySide import QtWidgets, QtGui, QtCore
from MyWidget import MyWidget

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2020-2021 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
@@ -9,11 +9,11 @@
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
from PySide2 import QtWidgets, QtCore
from PyKDDockWidgets import KDDockWidgets
from MyMainWindow import MyMainWindow
from PySide import QtWidgets, QtCore
import sys
import rc_assets

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2019-2021 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
@@ -48,6 +48,8 @@ set(DOCKSLIBS_SRCS
private/FloatingWindow_p.h
private/Logging.cpp
private/Logging_p.h
private/TabWidget.cpp
private/TabWidget_p.h
private/TitleBar.cpp
private/TitleBar_p.h
private/SideBar.cpp
@@ -108,6 +110,7 @@ set(DOCKS_INSTALLABLE_PRIVATE_INCLUDES
private/TitleBar_p.h
private/WindowBeingDragged_p.h
private/DockRegistry_p.h
private/TabWidget_p.h
)
set(DOCKS_INSTALLABLE_PRIVATE_WIDGET_INCLUDES
@@ -118,7 +121,6 @@ set(DOCKS_INSTALLABLE_PRIVATE_WIDGET_INCLUDES
private/widgets/FrameWidget_p.h
private/widgets/TabBarWidget_p.h
private/widgets/TabWidgetWidget_p.h
private/widgets/TabWidget_p.h
)
if(${PROJECT_NAME}_QTQUICK)
@@ -131,6 +133,10 @@ if(${PROJECT_NAME}_QTQUICK)
private/quick/QWidgetAdapter_quick_p.h
private/quick/FloatingWindowQuick.cpp
private/quick/FloatingWindowQuick_p.h
private/quick/TabWidgetQuick.cpp
private/quick/TabWidgetQuick_p.h
private/quick/TabBarQuick.cpp
private/quick/TabBarQuick_p.h
private/quick/TitleBarQuick.cpp
private/quick/TitleBarQuick_p.h
private/quick/QmlTypes.cpp
@@ -163,8 +169,6 @@ else()
private/multisplitter/Widget_qwidget.h
private/multisplitter/Separator_qwidget.cpp
private/multisplitter/Separator_qwidget.h
private/widgets/TabWidget.cpp
private/widgets/TabWidget_p.h
private/widgets/TabBarWidget.cpp
private/widgets/TabBarWidget_p.h
private/widgets/FloatingWindowWidget.cpp
@@ -229,7 +233,12 @@ else()
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR IS_CLANG_BUILD)
target_compile_options(kddockwidgets PRIVATE -Wshadow -Wconversion -fvisibility=hidden)
target_compile_options(kddockwidgets PRIVATE -Wshadow -fvisibility=hidden)
# Disable -Wconversion for Qt6. The qsizetype to int conversions are harmless
if (NOT ${PROJECT_NAME}_QT6)
target_compile_options(kddockwidgets PRIVATE -Wconversion)
endif()
if(IS_CLANG_BUILD)
target_compile_options(kddockwidgets PRIVATE -Wweak-vtables)
@@ -243,7 +252,7 @@ else()
endif()
if (WIN32)
target_link_libraries(kddockwidgets PRIVATE Qt${QT_MAJOR_VERSION}::GuiPrivate Dwmapi)
target_link_libraries(kddockwidgets PRIVATE Qt${QT_MAJOR_VERSION}::GuiPrivate dwmapi)
elseif(NOT APPLE AND NOT EMSCRIPTEN AND NOT ${PROJECT_NAME}_QT6)
find_package(Qt${QT_MAJOR_VERSION}X11Extras)
target_link_libraries(kddockwidgets PUBLIC Qt${QT_MAJOR_VERSION}::X11Extras)
@@ -308,7 +317,9 @@ 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
option(KDDockWidgets_LINTER "Build the layout linter" ON)
if (NOT ${PROJECT_NAME}_QTQUICK AND KDDockWidgets_LINTER) # TODO: We can support it
add_executable(kddockwidgets_linter layoutlinter_main.cpp)
target_link_libraries(kddockwidgets_linter kddockwidgets Qt${QT_MAJOR_VERSION}::Widgets)
endif()

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -55,6 +55,7 @@ public:
TabbingAllowedFunc m_tabbingAllowedFunc = nullptr;
FrameworkWidgetFactory *m_frameworkWidgetFactory = nullptr;
Flags m_flags = Flag_Default;
InternalFlags m_internalFlags = InternalFlag_None;
qreal m_draggedWindowOpacity = Q_QNAN;
};
@@ -172,6 +173,46 @@ TabbingAllowedFunc Config::tabbingAllowedFunc() const
return d->m_tabbingAllowedFunc;
}
void Config::setAbsoluteWidgetMinSize(QSize size)
{
if (!DockRegistry::self()->isEmpty(/*excludeBeingDeleted=*/ false)) {
qWarning() << Q_FUNC_INFO << "Only use this function at startup before creating any DockWidget or MainWindow";
return;
}
Layouting::Item::hardcodedMinimumSize = size;
}
QSize Config::absoluteWidgetMinSize() const
{
return Layouting::Item::hardcodedMinimumSize;
}
void Config::setAbsoluteWidgetMaxSize(QSize size)
{
if (!DockRegistry::self()->isEmpty(/*excludeBeingDeleted=*/ false)) {
qWarning() << Q_FUNC_INFO << "Only use this function at startup before creating any DockWidget or MainWindow";
return;
}
Layouting::Item::hardcodedMaximumSize = size;
}
QSize Config::absoluteWidgetMaxSize() const
{
return Layouting::Item::hardcodedMaximumSize;
}
Config::InternalFlags Config::internalFlags() const
{
return d->m_internalFlags;
}
void Config::setInternalFlags(InternalFlags flags)
{
d->m_internalFlags = flags;
}
#ifdef KDDOCKWIDGETS_QTQUICK
void Config::setQmlEngine(QQmlEngine *qmlEngine)
{
@@ -239,11 +280,16 @@ void Config::Private::fixFlags()
#if defined(DOCKS_DEVELOPER_MODE)
// We allow to disable aero-snap during development
if (m_flags & Flag_internal_NoAeroSnap) {
if (m_internalFlags & InternalFlag_NoAeroSnap) {
// The only way to disable AeroSnap
m_flags = m_flags & ~Flag_AeroSnapWithClientDecos;
}
#endif
if (m_flags & Flag_DontUseUtilityFloatingWindows) {
m_internalFlags |= InternalFlag_DontUseParentForFloatingWindows;
m_internalFlags |= InternalFlag_DontUseQtToolWindowsForFloatingWindows;
}
}
}

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -23,6 +23,7 @@
QT_BEGIN_NAMESPACE
class QQmlEngine;
class QSize;
QT_END_NAMESPACE
namespace KDDockWidgets
@@ -73,22 +74,29 @@ public:
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_DontUseUtilityFloatingWindows = 0x1000,
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_KeepAboveIfNotUtilityWindow = 0x10000, ///< Only meaningful if Flag_DontUseUtilityFloatingWindows is set. If floating windows are normal windows, you might still want them to keep above and not minimize when you focus the main window.
Flag_internal_NoAeroSnap = 0x20000, ///< Internal flag, only for development. Disables Aero-snap.
Flag_CloseOnlyCurrentTab = 0x20000, ///< The TitleBar's close button will only close the current tab, instead of all of them
Flag_Default = Flag_AeroSnapWithClientDecos ///< The defaults
};
Q_DECLARE_FLAGS(Flags, Flag)
///@internal
///Internal flags for addtional tunning.
///@warning Not for public consumption, support will be limited.
enum InternalFlag {
InternalFlag_None = 0, ///< The default
InternalFlag_NoAeroSnap = 1, ///< Only for development. Disables Aero-snap.
InternalFlag_DontUseParentForFloatingWindows = 2, ///< FloatingWindows won't have a parent top-level.
InternalFlag_DontUseQtToolWindowsForFloatingWindows = 4, ///< FloatingWindows will use Qt::Window instead of Qt::Tool.
InternalFlag_DontShowWhenUnfloatingHiddenWindow = 8 ///< DockWidget::setFloating(false) won't do anything if the window is hidden.
};
Q_DECLARE_FLAGS(InternalFlags, InternalFlag)
///@brief returns the chosen flags
Flags flags() const;
@@ -187,6 +195,28 @@ public:
///@sa setTabbingAllowedFunc().
TabbingAllowedFunc tabbingAllowedFunc() const;
///@brief Sets the minimum size a dock widget can have.
/// Widgets can still provide their own min-size and it will be respected, however it can never be
/// smaller than this one.
void setAbsoluteWidgetMinSize(QSize size);
QSize absoluteWidgetMinSize() const;
///@brief Sets the maximum size a dock widget can have.
/// Widgets can still provide their own max-size and it will be respected, however it can never be
/// bigger than this one.
void setAbsoluteWidgetMaxSize(QSize size);
QSize absoluteWidgetMaxSize() const;
///@internal
///@brief returns the internal flags.
///@warning Not for public consumption, support will be limited.
InternalFlags internalFlags() const;
///@internal
///@brief setter for the internal flags
///@warning Not for public consumption, support will be limited.
void setInternalFlags(InternalFlags flags);
#ifdef KDDOCKWIDGETS_QTQUICK
///@brief Sets the QQmlEngine to use. Applicable only when using QtQuick.
void setQmlEngine(QQmlEngine *);

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -25,6 +25,8 @@ QT_BEGIN_NAMESPACE
class QCloseEvent;
QT_END_NAMESPACE
// clazy:excludeall=ctor-missing-parent-argument
namespace KDDockWidgets {
/**
@@ -47,7 +49,8 @@ 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 = DockWidgetBase::Options());
explicit DockWidget(const QString &uniqueName, Options options = DockWidgetBase::Options(),
LayoutSaverOptions layoutSaverOptions = LayoutSaverOptions());
///@brief destructor
~DockWidget() override;

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -16,7 +16,6 @@
#include "Utils_p.h"
#include "DockRegistry_p.h"
#include "DropArea_p.h"
#include "multisplitter/Item_p.h"
#include "Config.h"
#include "TitleBar_p.h"
#include "FrameworkWidgetFactory.h"
@@ -41,11 +40,13 @@ using namespace KDDockWidgets;
class DockWidgetBase::Private
{
public:
Private(const QString &dockName, DockWidgetBase::Options options_, DockWidgetBase *qq)
Private(const QString &dockName, DockWidgetBase::Options options_,
LayoutSaverOptions layoutSaverOptions_, DockWidgetBase *qq)
: name(dockName)
, title(dockName)
, q(qq)
, options(options_)
, layoutSaverOptions(layoutSaverOptions_)
, toggleAction(new QAction(q))
, floatAction(new QAction(q))
{
@@ -99,6 +100,11 @@ public:
return nullptr;
}
SideBar* sideBar() const
{
return DockRegistry::self()->sideBarForDockWidget(q);
}
QPoint defaultCenterPosForFloating();
void updateTitle();
@@ -127,21 +133,23 @@ public:
QWidgetOrQuick *widget = nullptr;
DockWidgetBase *const q;
DockWidgetBase::Options options;
const LayoutSaverOptions layoutSaverOptions;
QAction *const toggleAction;
QAction *const floatAction;
LastPositions m_lastPositions;
bool m_updatingToggleAction = false;
bool m_updatingFloatAction = false;
bool m_isForceClosing = false;
QSize m_lastOverlayedSize = QSize(0, 0);
};
DockWidgetBase::DockWidgetBase(const QString &name, Options options)
DockWidgetBase::DockWidgetBase(const QString &name, Options options,
LayoutSaverOptions layoutSaverOptions)
: QWidgetAdapter(nullptr, Qt::Tool)
, d(new Private(name, options, this))
, d(new Private(name, options, layoutSaverOptions, this))
{
d->init();
DockRegistry::self()->registerDockWidget(this);
qCDebug(creation) << "DockWidget" << this;
if (name.isEmpty())
qWarning() << Q_FUNC_INFO << "Name can't be null";
@@ -153,13 +161,11 @@ DockWidgetBase::DockWidgetBase(const QString &name, Options options)
DockWidgetBase::~DockWidgetBase()
{
DockRegistry::self()->unregisterDockWidget(this);
qCDebug(creation) << "~DockWidget" << this;
delete d;
}
void DockWidgetBase::addDockWidgetAsTab(DockWidgetBase *other, AddingOption addingOption)
void DockWidgetBase::addDockWidgetAsTab(DockWidgetBase *other, InitialOption option)
{
qCDebug(addwidget) << Q_FUNC_INFO << other;
if (other == this) {
qWarning() << Q_FUNC_INFO << "Refusing to add dock widget into itself" << other;
return;
@@ -202,14 +208,17 @@ void DockWidgetBase::addDockWidgetAsTab(DockWidgetBase *other, AddingOption addi
}
other->setParent(nullptr);
frame->addWidget(other, addingOption);
frame->addWidget(other, option);
}
void DockWidgetBase::addDockWidgetToContainingWindow(DockWidgetBase *other, Location location, DockWidgetBase *relativeTo)
void DockWidgetBase::addDockWidgetToContainingWindow(DockWidgetBase *other,
Location location,
DockWidgetBase *relativeTo,
InitialOption initialOption)
{
qCDebug(addwidget) << Q_FUNC_INFO << other << location << relativeTo;
if (qobject_cast<MainWindowBase*>(window())) {
qWarning() << Q_FUNC_INFO << "Just use MainWindow::addWidget() directly. This function is for floating nested windows only.";
if (auto mainWindow = qobject_cast<MainWindowBase*>(window())) {
// It's inside a main window. Simply use the main window API.
mainWindow->addDockWidget(other, location, relativeTo, initialOption);
return;
}
@@ -229,7 +238,7 @@ void DockWidgetBase::addDockWidgetToContainingWindow(DockWidgetBase *other, Loca
morphIntoFloatingWindow();
if (auto fw = floatingWindow()) {
fw->dropArea()->addDockWidget(other, location, relativeTo);
fw->dropArea()->addDockWidget(other, location, relativeTo, initialOption);
} else {
qWarning() << Q_FUNC_INFO << "Couldn't find floating nested window";
}
@@ -238,7 +247,6 @@ void DockWidgetBase::addDockWidgetToContainingWindow(DockWidgetBase *other, Loca
void DockWidgetBase::setWidget(QWidgetOrQuick *w)
{
Q_ASSERT(w);
qCDebug(addwidget) << Q_FUNC_INFO << w;
if (w == d->widget)
return;
@@ -276,6 +284,12 @@ bool DockWidgetBase::setFloating(bool floats)
if ((floats && alreadyFloating) || (!floats && !alreadyFloating))
return true; // Nothing to do
if (!floats && (Config::self().internalFlags() & Config::InternalFlag_DontShowWhenUnfloatingHiddenWindow) && !isVisible()) {
// Mimics behaviour of QDockWidget, which you might need during porting.
// Not something we suggest though. For KDDW, setFloating(false) means dock, and that implies showing.
return false;
}
if (floats) {
d->saveTabIndex();
if (isTabbed()) {
@@ -338,6 +352,11 @@ DockWidgetBase::Options DockWidgetBase::options() const
return d->options;
}
DockWidgetBase::LayoutSaverOptions DockWidgetBase::layoutSaverOptions() const
{
return d->layoutSaverOptions;
}
void DockWidgetBase::setOptions(Options options)
{
if ((d->options & Option_NotDockable) != (options & Option_NotDockable)) {
@@ -349,7 +368,7 @@ void DockWidgetBase::setOptions(Options options)
d->options = options;
Q_EMIT optionsChanged(options);
if (auto tb = titleBar())
tb->updateCloseButton();
tb->updateButtons();
}
}
@@ -387,6 +406,9 @@ void DockWidgetBase::setIcon(const QIcon &icon, IconPlaces places)
if (places & IconPlace::TabBar)
d->tabBarIcon = icon;
if (places & IconPlace::ToggleAction)
d->toggleAction->setIcon(icon);
Q_EMIT iconChanged();
}
@@ -398,6 +420,9 @@ QIcon DockWidgetBase::icon(IconPlace place) const
if (place == IconPlace::TabBar)
return d->tabBarIcon;
if (place == IconPlace::ToggleAction)
return d->toggleAction->icon();
return {};
}
@@ -512,16 +537,33 @@ SideBarLocation DockWidgetBase::sideBarLocation() const
return DockRegistry::self()->sideBarLocationForDockWidget(this);
}
bool DockWidgetBase::isInSideBar() const
{
return sideBarLocation() != SideBarLocation::None;
}
bool DockWidgetBase::hasPreviousDockedLocation() const
{
return d->m_lastPositions.isValid();
}
QSize DockWidgetBase::lastOverlayedSize() const
{
return d->m_lastOverlayedSize;
}
DockWidgetBase *DockWidgetBase::byName(const QString &uniqueName)
{
return DockRegistry::self()->dockByName(uniqueName);
}
bool DockWidgetBase::skipsRestore() const
{
return d->layoutSaverOptions & LayoutSaverOption::Skip;
}
FloatingWindow *DockWidgetBase::morphIntoFloatingWindow()
{
qCDebug(creation) << "DockWidget::morphIntoFloatingWindow() this=" << this
<< "; visible=" << isVisible();
if (auto fw = floatingWindow())
return fw; // Nothing to do
@@ -573,7 +615,6 @@ FloatingWindow *DockWidgetBase::floatingWindow() const
void DockWidgetBase::addPlaceholderItem(Layouting::Item *item)
{
qCDebug(placeholder) << Q_FUNC_INFO << this << item;
Q_ASSERT(item);
d->m_lastPositions.addPosition(item);
}
@@ -628,10 +669,16 @@ void DockWidgetBase::Private::updateTitle()
void DockWidgetBase::Private::toggle(bool enabled)
{
if (enabled) {
show();
if (SideBar *sb = sideBar()) {
// The widget is in the sidebar, let's toggle its overlayed state
sb->toggleOverlay(q);
} else {
q->close();
// The most common case. The dock widget is not in the sidebar. just close or open it.
if (enabled) {
show();
} else {
q->close();
}
}
}
@@ -680,7 +727,6 @@ void DockWidgetBase::Private::close()
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.
@@ -692,6 +738,9 @@ void DockWidgetBase::Private::close()
sb->removeDockWidget(q);
}
}
if (options & DockWidgetBase::Option_DeleteOnClose)
q->deleteLater();
}
bool DockWidgetBase::Private::restoreToPreviousPosition()
@@ -715,7 +764,6 @@ void DockWidgetBase::Private::maybeRestoreToPreviousPosition()
return;
Layouting::Item *layoutItem = m_lastPositions.lastItem();
qCDebug(placeholder) << Q_FUNC_INFO << layoutItem << m_lastPositions;
if (!layoutItem)
return; // nothing to do, no last position
@@ -727,7 +775,6 @@ void DockWidgetBase::Private::maybeRestoreToPreviousPosition()
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.";
return;
}
@@ -735,7 +782,6 @@ void DockWidgetBase::Private::maybeRestoreToPreviousPosition()
if (q->parentWidget()) {
// The QEvent::Show is due to it being made floating. Nothing to restore.
qCDebug(placeholder) << Q_FUNC_INFO << "Already had parentWidget";
return;
}
@@ -762,7 +808,12 @@ void DockWidgetBase::Private::show()
void DockWidgetBase::onParentChanged()
{
#ifdef KDDOCKWIDGETS_QTWIDGETS
// TODO: In v1.4, remove this part and use the signal emitting the arg
Q_EMIT parentChanged();
#else
Q_EMIT parentChanged(this);
#endif
d->updateToggleAction();
d->updateFloatAction();
}
@@ -796,6 +847,19 @@ void DockWidgetBase::onHidden(bool spontaneous)
}
}
bool DockWidgetBase::onResize(QSize newSize)
{
if (isOverlayed()) {
if (auto frame = this->frame()) {
d->m_lastOverlayedSize = frame->QWidgetAdapter::size();
} else {
qWarning() << Q_FUNC_INFO << "Overlayed dock widget without frame shouldn't happen";
}
}
return QWidgetAdapter::onResize(newSize);
}
void DockWidgetBase::onCloseEvent(QCloseEvent *e)
{
e->accept(); // By default we accept, means DockWidget closes

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -26,6 +26,8 @@
#include <QVector>
// clazy:excludeall=ctor-missing-parent-argument
QT_BEGIN_NAMESPACE
class QAction;
QT_END_NAMESPACE
@@ -36,75 +38,6 @@ namespace Layouting {
class Item;
}
#if defined(QT_WIDGETS_LIB)
# include <QAction>
#else
// A QAction for QtQuick. Just so it compiles, for now
class QAction : public QObject
{
Q_OBJECT
public:
using QObject::QObject;
bool isChecked() const {
return m_isChecked ;
}
void setCheckable(bool is) {
m_isCheckable = is;
}
void setText(const QString &text) {
m_text = text;
}
void setToolTip(const QString &text) {
m_toolTip = text;
}
QString toolTip() const {
returm m_toolTip;
}
bool enabled() const {
return m_enabled;
}
void setEnabled(bool enabled) {
m_enabled = enabled;
}
bool checked() const {
return m_checked;
}
void setChecked(bool checked) {
m_checked = checked;
}
bool isEnabled() const {
return m_enabled;
}
void toggle() {
m_enabled = !m_enabled;
Q_EMIT toggled(m_enabled);
}
Q_SIGNALS:
bool toggled(bool);
private:
QString m_text;
QString m_toolTip;
bool m_isChecked = false;
bool m_isCheckable = false;
bool m_enabled = false;
bool m_checked = false;
};
#endif
namespace KDDockWidgets {
struct LastPositions;
@@ -141,15 +74,25 @@ public:
///@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_NotDockable = 2 ///< The DockWidget can't be docked, it's always floating
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
Option_DeleteOnClose = 4 ///< Deletes the DockWidget when closed
};
Q_DECLARE_FLAGS(Options, Option)
/// @brief Options which will affect LayoutSaver save/restore
enum class LayoutSaverOption {
None = 0, ///< Just use the defaults
Skip = 1, ///< The dock widget won't participate in save/restore. Currently only available for floating windows.
};
Q_DECLARE_FLAGS(LayoutSaverOptions, LayoutSaverOption)
enum class IconPlace {
TitleBar = 1,
TabBar = 2,
All = TitleBar | TabBar
ToggleAction = 4,
All = ToggleAction | TitleBar | TabBar
};
Q_ENUM(IconPlace)
Q_DECLARE_FLAGS(IconPlaces, IconPlace)
@@ -157,36 +100,28 @@ public:
/**
* @brief constructs a new DockWidget
* @param uniqueName the name of the dockwidget, should be unique. Use title for user visible text.
* @param options optional options controlling behaviour
* @param options options controlling certain behaviours
* @param layoutSaverOptions options to control save/restore
*
* 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 = DockWidgetBase::Options());
explicit DockWidgetBase(const QString &uniqueName,
Options options = DockWidgetBase::Options(),
LayoutSaverOptions layoutSaverOptions = LayoutSaverOptions());
///@brief destructor
~DockWidgetBase() override;
/**
* @brief Constructs a dock widget from its serialized form.
* @internal
*/
static DockWidgetBase *deserialize(const LayoutSaver::DockWidget::Ptr &);
/**
* @brief Serializes this dock widget into an intermediate form
*/
LayoutSaver::DockWidget::Ptr serialize() const;
/**
* @brief docks @p other widget into this one. Tabs will be shown if not already.
* @param other The other dock widget to dock into this one.
* @param addingOption Allows to specify an AddingOption. Which is useful to add the dock widget
* @param initialOption Allows to specify an InitialOption. Which is useful to add the dock widget
* as hidden, recording only a placeholder in the tab. So it's restored to tabbed when eventually
* shown.
* @sa MainWindow::addDockWidget(), DockWidget::addDockWidgetToContainingWindow()
*/
void addDockWidgetAsTab(DockWidgetBase *other, AddingOption addingOption = AddingOption_None);
void addDockWidgetAsTab(DockWidgetBase *other, InitialOption initialOption = {});
/**
* @brief docks @p other widget into the window that contains this one.
@@ -196,11 +131,13 @@ public:
*
* @param other The other dock widget to dock into the window.
* @param location The location to dock.
* @param relativeTo The dock widget that the @p location is relative to. If null then the window is considered.
* @param relativeTo The dock widget that the @p location is relative to. If null then the window is considered
* @param initialOption Allows to specify some extra options that are used while docking.
* @sa MainWindow::addDockWidget(), DockWidget::addDockWidgetAsTab()
*/
void addDockWidgetToContainingWindow(DockWidgetBase *other, KDDockWidgets::Location location,
DockWidgetBase *relativeTo = nullptr);
DockWidgetBase *relativeTo = nullptr,
InitialOption initialOption = {});
/**
* @brief sets the widget which this dock widget hosts.
@@ -273,6 +210,10 @@ public:
*/
Options options() const;
/// @brief returns the per-dockwidget options which will affect LayoutSaver
/// These are the options which were passed to the constructor
KDDockWidgets::DockWidgetBase::LayoutSaverOptions layoutSaverOptions() const;
/**
* @brief Setter for the options.
* Only Option_NotClosable is allowed to change after construction. For the other options use
@@ -307,7 +248,7 @@ public:
/**
* @brief Sets an icon to show on title bars and tab bars.
* @param places Specifies where the icon will be shown (TitleBar, TabBar or both)
* @param places Specifies where the icon will be shown (TitleBar, TabBar, ToggleAction, or All)
*
* By default there's no icon set.
*
@@ -316,7 +257,7 @@ public:
void setIcon(const QIcon &icon, IconPlaces places = IconPlace::All);
/**
* @brief Returns the dock widget's titlebar or tabbar icon (depending on the passed @p place)
* @brief Returns the dock widget's titlebar, tabbar, or toggle action icon (depending on the passed @p place)
*
* By default it's null.
*
@@ -397,7 +338,7 @@ public:
bool isMainWindow() const;
/**
* @brief Returns whether this dock widget is docked into a main window.
* @brief Returns whether this dock widget is docked into a main window (as opposed to floating)
*
* 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
@@ -406,6 +347,7 @@ public:
bool isInMainWindow() const;
/// @brief Returns the main window this dock widget is in. nullptr if it's not inside a main window
/// Also returns nullptr if it's minimized to a sidebar
MainWindowBase *mainWindow() const;
///@brief Returns whether This or any child of this dock widget is focused
@@ -425,24 +367,46 @@ public:
*/
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.
/// @brief Returns whether this dock widget is overlayed from the side-bar.
///
/// This is only relevant when using the auto-hide and side-bar feature.
/// Not to be confused with "floating", which means top-level window.
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.
/// @sa isInSideBar
SideBarLocation sideBarLocation() const;
/// @brief Returns where this dockwidget is in a sidebar
/// Similar to sideBarLocation(), but returns a bool
bool isInSideBar() 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;
/// @brief returns the last size the widget has when overlayed
/// Empty otherwise
QSize lastOverlayedSize() const;
/// @brief Returns a dock widget by its name
/// This is the same name you passed to DockWidget CTOR.
/// nullptr is returned if the dock widget isn't found.
static DockWidgetBase* byName(const QString &uniqueName);
/// @brief Returns whether this widget has the LayoutSaverOption::Skip flag
bool skipsRestore() const;
Q_SIGNALS:
#ifdef KDDOCKWIDGETS_QTWIDGETS
///@brief signal emitted when the parent changed
void parentChanged();
#endif
///@brief signal emitted when the DockWidget is shown. As in QEvent::Show.
void shown();
@@ -473,7 +437,7 @@ Q_SIGNALS:
void isOverlayedChanged(bool);
///@brief emitted when isFloating changes
bool isFloatingChanged(bool);
void isFloatingChanged(bool);
///@brief emitted when this dock widget is removed from a side-bar.
///Only relevant for the auto-hide/sidebar feature
@@ -491,8 +455,10 @@ protected:
void onParentChanged();
void onShown(bool spontaneous);
void onHidden(bool spontaneous);
#ifndef PYTHON_BINDINGS //Pyside bug: https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1327
void onCloseEvent(QCloseEvent *e) override;
bool onResize(QSize newSize) override;
#endif
#if defined(DOCKS_DEVELOPER_MODE)
@@ -529,6 +495,17 @@ private:
friend class KDDockWidgets::MainWindowBase;
friend class KDDockWidgets::FrameQuick;
/**
* @brief Constructs a dock widget from its serialized form.
* @internal
*/
static DockWidgetBase *deserialize(const LayoutSaver::DockWidget::Ptr &);
/**
* @brief Serializes this dock widget into an intermediate form
*/
LayoutSaver::DockWidget::Ptr serialize() const;
/**
* @brief the Frame which contains this dock widgets.
*
@@ -569,4 +546,73 @@ private:
}
Q_DECLARE_METATYPE(KDDockWidgets::Location)
#if defined(QT_WIDGETS_LIB)
# include <QAction>
#else
// A QAction for QtQuick. Just so it compiles, for now
class QAction : public QObject
{
Q_OBJECT
public:
using QObject::QObject;
bool isChecked() const {
return m_isChecked ;
}
void setCheckable(bool is) {
m_isCheckable = is;
}
void setText(const QString &text) {
m_text = text;
}
void setToolTip(const QString &text) {
m_toolTip = text;
}
QString toolTip() const {
returm m_toolTip;
}
bool enabled() const {
return m_enabled;
}
void setEnabled(bool enabled) {
m_enabled = enabled;
}
bool checked() const {
return m_checked;
}
void setChecked(bool checked) {
m_checked = checked;
}
bool isEnabled() const {
return m_enabled;
}
void toggle() {
m_enabled = !m_enabled;
Q_EMIT toggled(m_enabled);
}
Q_SIGNALS:
bool toggled(bool);
private:
QString m_text;
QString m_toolTip;
bool m_isChecked = false;
bool m_isCheckable = false;
bool m_enabled = false;
bool m_checked = false;
};
#endif
#endif

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -40,8 +40,8 @@ public:
QQuickItem *const m_visualItem;
};
DockWidgetQuick::DockWidgetQuick(const QString &name, Options options)
: DockWidgetBase(name, options)
DockWidgetQuick::DockWidgetQuick(const QString &name, Options options, LayoutSaverOptions layoutSaverOptions)
: DockWidgetBase(name, options, layoutSaverOptions)
, d(new Private(this))
{
// To mimic what QtWidgets does when creating a new QWidget.

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -45,7 +45,8 @@ public:
* There's no parent argument. The DockWidget is either parented to FloatingWindow or MainWindow
* when visible, or stays without a parent when hidden.
*/
explicit DockWidgetQuick(const QString &uniqueName, Options options = {});
explicit DockWidgetQuick(const QString &uniqueName, Options options = {},
LayoutSaverOptions layoutSaverOptions = LayoutSaverOptions());
///@brief destructor
~DockWidgetQuick() override;

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -29,7 +29,7 @@
using namespace KDDockWidgets;
// Our Private inherits from QObject since FocusScope can't (Since Frame is already QObject)
class FocusScope::Private : public QObject
class FocusScope::Private : public QObject //clazy:exclude=missing-qobject-macro (breaks unity build with earlier cmake due to including .moc here.)
{
public:
Private(FocusScope *qq, QWidgetAdapter *thisWidget)
@@ -109,7 +109,7 @@ void FocusScope::Private::setIsFocused(bool is)
emitDockWidgetFocusChanged();
if (!m_inCtor) // Hack so we don't call pure-virtual
Q_EMIT q->isFocusedChanged();
/* Q_EMIT */ q->isFocusedChangedCallback();
}
}
@@ -125,7 +125,7 @@ void FocusScope::Private::onFocusObjectChanged(QObject *obj)
if (is && m_lastFocusedInScope != widget && !qobject_cast<TitleBar*>(obj)) {
m_lastFocusedInScope = widget;
setIsFocused(is);
Q_EMIT q->focusedWidgetChanged();
/* Q_EMIT */ q->focusedWidgetChangedCallback();
} else {
setIsFocused(is);
}

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -27,6 +27,7 @@ namespace KDDockWidgets
///@brief Allows to implement a similar functionality to QtQuick's FocusScope item, in QtWidgets
class DOCKS_EXPORT FocusScope
{
Q_DISABLE_COPY(FocusScope)
public:
///@brief constructor
explicit FocusScope(QWidgetAdapter *thisWidget);
@@ -48,9 +49,10 @@ public:
void focus(Qt::FocusReason = Qt::OtherFocusReason);
/*Q_SIGNALS:*/
protected:
///@brief reimplement in the 1st QObject derived class
virtual void isFocusedChanged() = 0;
virtual void focusedWidgetChanged() = 0;
virtual void isFocusedChangedCallback() = 0;
virtual void focusedWidgetChangedCallback() = 0;
private:
class Private;

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -18,9 +18,9 @@
#include "indicators/ClassicIndicators_p.h"
#include "indicators/NullIndicators_p.h"
#include "Utils_p.h"
#include "TabWidget_p.h"
#ifdef KDDOCKWIDGETS_QTWIDGETS
# include "widgets/TabWidget_p.h"
# include "widgets/FrameWidget_p.h"
# include "widgets/TitleBarWidget_p.h"
# include "widgets/TabBarWidget_p.h"
@@ -36,11 +36,15 @@
# include "DockWidgetQuick.h"
# include "quick/FrameQuick_p.h"
# include "quick/TitleBarQuick_p.h"
# include "quick/TabWidgetQuick_p.h"
# include "quick/TabBarQuick_p.h"
# include "quick/FloatingWindowQuick_p.h"
# include "quick/RubberBandQuick.h"
# include "multisplitter/Separator_quick.h"
#endif
// clazy:excludeall=ctor-missing-parent-argument
using namespace KDDockWidgets;
DropIndicatorType DefaultWidgetFactory::s_dropIndicatorType = DropIndicatorType::Classic;
@@ -181,16 +185,12 @@ DropIndicatorOverlayInterface *DefaultWidgetFactory::createDropIndicatorOverlay(
TabBar *DefaultWidgetFactory::createTabBar(TabWidget *parent) const
{
Q_UNUSED(parent)
Q_ASSERT(false);
return nullptr;
return new TabBarQuick(parent);
}
TabWidget *DefaultWidgetFactory::createTabWidget(Frame *parent) const
{
Q_UNUSED(parent)
Q_ASSERT(false);
return nullptr;
return new TabWidgetQuick(parent);
}
Layouting::Separator *DefaultWidgetFactory::createSeparator(Layouting::Widget *parent) const

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -16,6 +16,8 @@
#include "KDDockWidgets.h"
#include "QWidgetAdapter.h"
// clazy:excludeall=ctor-missing-parent-argument
/**
* @file
* @brief A factory class for allowing the user to customize some internal widgets.
@@ -43,6 +45,7 @@ class Frame;
class DropArea;
class SideBar;
class TabBar;
class TabWidgetQuick;
/**
* @brief A factory class for allowing the user to customize some internal widgets.
@@ -94,16 +97,16 @@ public:
///@param floatingWindow Just forward to TitleBar's constructor.
virtual TitleBar* createTitleBar(FloatingWindow *floatingWindow) const = 0;
///@brief Called internally by the framework to create a TabBar
/// Override to provide your own TabBar sub-class.
///@param parent Just forward to TabBar's's constructor.
virtual TabBar* createTabBar(TabWidget *parent = nullptr) const = 0;
///@brief Called internally by the framework to create a TabWidget
/// Override to provide your own TabWidget sub-class.
///@param parent Just forward to TabWidget's constructor.
virtual TabWidget* createTabWidget(Frame *parent) const = 0;
///@brief Called internally by the framework to create a TabBar
/// Override to provide your own TabBar sub-class.
///@param parent Just forward to TabBar's's constructor.
virtual TabBar* createTabBar(TabWidget *parent = nullptr) const = 0;
///@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.
@@ -157,13 +160,14 @@ private:
*/
class DOCKS_EXPORT DefaultWidgetFactory : public FrameworkWidgetFactory
{
Q_OBJECT
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;
TabBar *createTabBar(TabWidget *parent) 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;

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -22,14 +22,23 @@
#include "Qt5Qt6Compat_p.h"
#include <QObject>
#include <QDebug>
#ifdef Q_OS_WIN
// Only on Windows, where this is popular. On linux the Qt::Tool windows need reparenting. Untested on macOS.
# define KDDOCKWIDGETS_SUPPORTS_NESTED_MAINWINDOWS
#endif
namespace Layouting {
class Item;
class ItemBoxContainer;
}
namespace KDDockWidgets
{
class MultiSplitter;
class DropArea;
enum Location {
Location_None,
Location_OnLeft, ///> Left docking location
@@ -44,9 +53,105 @@ namespace KDDockWidgets
};
Q_DECLARE_FLAGS(MainWindowOptions, MainWindowOption)
///@internal
///@brief Describes some sizing strategies for the layouting engine.
///This is internal. The public API for dealing with sizing is InitialOption.
///@sa InitialOption
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 we're adding is smaller than the fair suggestion, then that small size is used.
None, ///< Don't do any sizing
};
///@brief Only here for source-compat with v1.2. Do not use.
///Use InitialVisibilityOption instead.
enum AddingOption {
AddingOption_None = 0, ///> No option set
AddingOption_StartHidden ///< Don't show the dock widget when adding it
AddingOption_None = 0,
AddingOption_StartHidden
};
enum class InitialVisibilityOption {
StartVisible = 0, ///< The dock widget is made visible when docked
StartHidden ///< Don't show the dock widget when adding it
};
/**
* @brief Struct describing the preferred dock widget size and visibility when adding it to a layout
*
* You can pass this to MainWindowBase::addDockWidget() to give an hint of your preferred size
* and visibility.
*
* See bellow the documentation for InitialOption::visibility and InitialOption::preferredSize.
*
* @sa MainWindowBase::addDockWidget()
*/
struct InitialOption
{
// Implicit ctors for convenience:
InitialOption() = default;
InitialOption(InitialVisibilityOption v)
: visibility(v) {}
InitialOption(QSize size)
: preferredSize(size) {}
InitialOption(InitialVisibilityOption v, QSize size)
: visibility(v)
, preferredSize(size)
{}
QT_DEPRECATED_X("AddingOption is deprecated and will be removed in v1.5. Use InitialVisibilityOption instead.")
InitialOption(AddingOption opt)
: visibility(opt == AddingOption_StartHidden ? InitialVisibilityOption::StartHidden
: InitialVisibilityOption::StartVisible)
{
}
bool startsHidden() const {
return visibility == InitialVisibilityOption::StartHidden;
}
int preferredLength(Qt::Orientation o) const {
return o == Qt::Horizontal ? preferredSize.width()
: preferredSize.height();
}
bool hasPreferredLength(Qt::Orientation o) const {
return preferredLength(o) > 0;
}
/**
* @brief Allows a dock widget to be docked as hidden.
*
* Next time you call DockWidget::show() it will be shown at that place. This avoids
* flickering, as no show()/hide() workarounds are needed.
*/
const InitialVisibilityOption visibility = InitialVisibilityOption::StartVisible;
/**
* @brief Allows to control the size a dock widget should get when docked.
*
* If an invalid or empty size is passed then KDDW's default heuristics are applied.
*
* Note that usually only the width or the height will be honoured: For example, when adding a
* dock widget to the left then only the preferred width will be taken into account, as the
* height will simply fill the whole layout.
*/
const QSize preferredSize;
private:
friend class Layouting::Item;
friend class Layouting::ItemBoxContainer;
friend class KDDockWidgets::MultiSplitter;
friend class KDDockWidgets::DropArea;
InitialOption(DefaultSizeMode mode)
: sizeMode(mode) {}
const DefaultSizeMode sizeMode = DefaultSizeMode::Fair;
};
///@internal
@@ -65,15 +170,6 @@ namespace KDDockWidgets
};
Q_DECLARE_FLAGS(RestoreOptions, RestoreOption)
///@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()
};
enum class DropIndicatorType {
Classic, ///< The default
Segmented, ///< Segmented indicators
@@ -126,6 +222,16 @@ namespace KDDockWidgets
}
}
QT_BEGIN_NAMESPACE
///@internal
inline QDebug operator<<(QDebug d, KDDockWidgets::InitialOption o)
{
d << o.startsHidden();
return d;
}
QT_END_NAMESPACE
Q_DECLARE_OPERATORS_FOR_FLAGS(KDDockWidgets::FrameOptions)
Q_DECLARE_METATYPE(KDDockWidgets::InitialVisibilityOption)
#endif

View File

@@ -1,7 +1,7 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2019-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -25,7 +25,6 @@
#include "Logging_p.h"
#include "Frame_p.h"
#include "Position_p.h"
#include "multisplitter/Item_p.h"
#include "FrameworkWidgetFactory.h"
#include "MainWindowBase.h"
#include "FloatingWindow_p.h"
@@ -70,6 +69,9 @@ public:
return m_affinityNames.isEmpty() || affinities.isEmpty() || DockRegistry::self()->affinitiesMatch(m_affinityNames, affinities);
}
void floatWidgetsWhichSkipRestore(const QStringList &mainWindowNames);
template <typename T>
void deserializeWindowGeometry(const T &saved, QWidgetOrQuick *topLevel);
void deleteEmptyFrames();
@@ -230,9 +232,12 @@ bool LayoutSaver::restoreLayout(const QByteArray &data)
if (d->m_restoreOptions & RestoreOption_RelativeToMainWindow)
layout.scaleSizes();
d->floatWidgetsWhichSkipRestore(layout.mainWindowNames());
// Hide all dockwidgets and unparent them from any layout before starting restore
// 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->clear(d->m_dockRegistry->dockWidgets(layout.dockWidgetsToClose()),
d->m_dockRegistry->mainWindows(layout.mainWindowNames()),
d->m_affinityNames);
@@ -259,14 +264,15 @@ bool LayoutSaver::restoreLayout(const QByteArray &data)
}
// 2. Restore FloatingWindows
for (const LayoutSaver::FloatingWindow &fw : qAsConst(layout.floatingWindows)) {
if (!d->matchesAffinity(fw.affinities))
for (LayoutSaver::FloatingWindow &fw : layout.floatingWindows) {
if (!d->matchesAffinity(fw.affinities) || fw.skipsRestore())
continue;
MainWindowBase *parent = fw.parentIndex == -1 ? nullptr
: DockRegistry::self()->mainwindows().at(fw.parentIndex);
auto floatingWindow = Config::self().frameworkWidgetFactory()->createFloatingWindow(parent);
fw.floatingWindowInstance = floatingWindow;
d->deserializeWindowGeometry(fw, floatingWindow);
if (!floatingWindow->deserialize(fw)) {
qWarning() << Q_FUNC_INFO << "Failed to deserialize floating window";
@@ -333,6 +339,24 @@ void LayoutSaver::Private::deserializeWindowGeometry(const T &saved, QWidgetOrQu
topLevel->setVisible(saved.isVisible);
}
void LayoutSaver::Private::floatWidgetsWhichSkipRestore(const QStringList &mainWindowNames)
{
// Widgets with the DockWidget::LayoutSaverOption::Skip flag skip restore completely.
// If they were visible before they need to remain visible now.
// If they were previously docked we need to float them, as the main window they were on will
// be loading a new layout.
for (MainWindowBase *mw : DockRegistry::self()->mainWindows(mainWindowNames)) {
const KDDockWidgets::DockWidgetBase::List docks = mw->multiSplitter()->dockWidgets();
for (auto dw : docks) {
if (dw->skipsRestore()) {
dw->setFloating(true);
}
}
}
}
void LayoutSaver::Private::deleteEmptyFrames()
{
// After a restore it can happen that some DockWidgets didn't exist, so weren't restored.
@@ -472,6 +496,14 @@ LayoutSaver::MainWindow LayoutSaver::Layout::mainWindowForIndex(int index) const
return mainWindows.at(index);
}
LayoutSaver::FloatingWindow LayoutSaver::Layout::floatingWindowForIndex(int index) const
{
if (index < 0 || index >= floatingWindows.size())
return {};
return floatingWindows.at(index);
}
QStringList LayoutSaver::Layout::mainWindowNames() const
{
QStringList names;
@@ -494,6 +526,35 @@ QStringList LayoutSaver::Layout::dockWidgetNames() const
return names;
}
QStringList LayoutSaver::Layout::dockWidgetsToClose() const
{
// Before restoring a layout we close all dock widgets, unless they're a floating window with the DontCloseBeforeRestore flag
QStringList names;
names.reserve(allDockWidgets.size());
auto registry = DockRegistry::self();
for (const auto &dw : allDockWidgets) {
if (DockWidgetBase *dockWidget = registry->dockByName(dw->uniqueName)) {
bool doClose = true;
if (dockWidget->skipsRestore()) {
if (auto fw = dockWidget->floatingWindow()) {
if (fw->allDockWidgetsHave(DockWidgetBase::LayoutSaverOption::Skip)) {
// All dock widgets in this floating window skips float, so we can honour it for all.
doClose = false;
}
}
}
if (doClose)
names << dw->uniqueName;
}
}
return names;
}
bool LayoutSaver::Frame::isValid() const
{
if (isNull)
@@ -529,6 +590,26 @@ bool LayoutSaver::Frame::isValid() const
return true;
}
bool LayoutSaver::Frame::hasSingleDockWidget() const
{
return dockWidgets.size() == 1;
}
bool LayoutSaver::Frame::skipsRestore() const
{
return std::all_of(dockWidgets.cbegin(), dockWidgets.cend(), [] (LayoutSaver::DockWidget::Ptr dw) {
return dw->skipsRestore();
});
}
LayoutSaver::DockWidget::Ptr LayoutSaver::Frame::singleDockWidget() const
{
if (!hasSingleDockWidget())
return {};
return dockWidgets.first();
}
void LayoutSaver::Frame::scaleSizes(const ScalingInfo &scalingInfo)
{
scalingInfo.applyFactorsTo(geometry);
@@ -584,6 +665,14 @@ void LayoutSaver::DockWidget::scaleSizes(const ScalingInfo &scalingInfo)
lastPosition.scaleSizes(scalingInfo);
}
bool LayoutSaver::DockWidget::skipsRestore() const
{
if (DockWidgetBase *dw = DockRegistry::self()->dockByName(uniqueName))
return dw->skipsRestore();
return false;
}
QVariantMap LayoutSaver::DockWidget::toVariantMap() const
{
QVariantMap map;
@@ -622,6 +711,21 @@ bool LayoutSaver::FloatingWindow::isValid() const
return true;
}
bool LayoutSaver::FloatingWindow::hasSingleDockWidget() const
{
return multiSplitterLayout.hasSingleDockWidget();
}
LayoutSaver::DockWidget::Ptr LayoutSaver::FloatingWindow::singleDockWidget() const
{
return multiSplitterLayout.singleDockWidget();
}
bool LayoutSaver::FloatingWindow::skipsRestore() const
{
return multiSplitterLayout.skipsRestore();
}
void LayoutSaver::FloatingWindow::scaleSizes(const ScalingInfo &scalingInfo)
{
scalingInfo.applyFactorsTo(/*by-ref*/geometry);
@@ -699,6 +803,7 @@ QVariantMap LayoutSaver::MainWindow::toVariantMap() const
map.insert(QStringLiteral("screenSize"), Layouting::sizeToMap(screenSize));
map.insert(QStringLiteral("isVisible"), isVisible);
map.insert(QStringLiteral("affinities"), stringListToVariant(affinities));
map.insert(QStringLiteral("windowState"), windowState);
for (SideBarLocation loc : { SideBarLocation::North, SideBarLocation::East, SideBarLocation::West, SideBarLocation::South }) {
const QStringList dockWidgets = dockWidgetsPerSideBar.value(loc);
@@ -719,6 +824,7 @@ void LayoutSaver::MainWindow::fromVariantMap(const QVariantMap &map)
screenSize = Layouting::mapToSize(map.value(QStringLiteral("screenSize")).toMap());
isVisible = map.value(QStringLiteral("isVisible")).toBool();
affinities = variantToStringList(map.value(QStringLiteral("affinities")).toList());
windowState = Qt::WindowState(map.value(QStringLiteral("windowState"), Qt::WindowNoState).toInt());
// Compatibility hack. Old json format had a single "affinityName" instead of an "affinities" list:
const QString affinityName = map.value(QStringLiteral("affinityName")).toString();
@@ -748,6 +854,26 @@ bool LayoutSaver::MultiSplitter::isValid() const
return true;
}
bool LayoutSaver::MultiSplitter::hasSingleDockWidget() const
{
return frames.size() == 1 && frames.cbegin()->hasSingleDockWidget();
}
LayoutSaver::DockWidget::Ptr LayoutSaver::MultiSplitter::singleDockWidget() const
{
if (!hasSingleDockWidget())
return {};
return frames.cbegin()->singleDockWidget();
}
bool LayoutSaver::MultiSplitter::skipsRestore() const
{
return std::all_of(frames.cbegin(), frames.cend(), [] (const LayoutSaver::Frame &frame) {
return frame.skipsRestore();
});
}
void LayoutSaver::MultiSplitter::scaleSizes(const ScalingInfo &)
{
// scalingInfo.applyFactorsTo(/*by-ref*/size);

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -36,6 +36,8 @@
namespace KDDockWidgets {
class FloatingWindow;
template <typename T>
typename T::List fromVariantList(const QVariantList &listV)
{
@@ -137,6 +139,8 @@ struct DOCKS_EXPORT LayoutSaver::DockWidget
return dw;
}
bool skipsRestore() const;
QVariantMap toVariantMap() const;
void fromVariantMap(const QVariantMap &map);
@@ -173,6 +177,12 @@ struct LayoutSaver::Frame
{
bool isValid() const;
bool hasSingleDockWidget() const;
bool skipsRestore() const;
/// @brief in case this frame only has one frame, returns the name of that dock widget
LayoutSaver::DockWidget::Ptr singleDockWidget() const;
/// Iterates through the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
void scaleSizes(const ScalingInfo &scalingInfo);
@@ -192,6 +202,11 @@ struct LayoutSaver::Frame
struct LayoutSaver::MultiSplitter
{
bool isValid() const;
bool hasSingleDockWidget() const;
LayoutSaver::DockWidget::Ptr singleDockWidget() const;
bool skipsRestore() const;
/// Iterates through the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
void scaleSizes(const ScalingInfo &scalingInfo);
@@ -208,6 +223,10 @@ struct LayoutSaver::FloatingWindow
bool isValid() const;
bool hasSingleDockWidget() const;
LayoutSaver::DockWidget::Ptr singleDockWidget() const;
bool skipsRestore() const;
/// Iterates through the layout and patches all absolute sizes. See RestoreOption_RelativeToMainWindow.
void scaleSizes(const ScalingInfo &);
@@ -221,6 +240,9 @@ struct LayoutSaver::FloatingWindow
int screenIndex;
QSize screenSize; // for relative-size restoring
bool isVisible = true;
// The instance that was created during a restore:
KDDockWidgets::FloatingWindow *floatingWindowInstance = nullptr;
};
struct LayoutSaver::MainWindow
@@ -245,6 +267,7 @@ public:
int screenIndex;
QSize screenSize; // for relative-size restoring
bool isVisible;
Qt::WindowState windowState = Qt::WindowNoState;
ScalingInfo scalingInfo;
};
@@ -272,7 +295,9 @@ public:
s_currentLayoutBeingRestored = this;
const QList<QScreen*> screens = qApp->screens();
for (int i = 0; i < screens.size(); ++i) {
const int numScreens = screens.size();
screenInfo.reserve(numScreens);
for (int i = 0; i < numScreens; ++i) {
ScreenInfo info;
info.index = i;
info.geometry = screens[i]->geometry();
@@ -299,9 +324,11 @@ public:
static LayoutSaver::Layout* s_currentLayoutBeingRestored;
LayoutSaver::MainWindow mainWindowForIndex(int index) const;
LayoutSaver::FloatingWindow floatingWindowForIndex(int index) const;
QStringList mainWindowNames() const;
QStringList dockWidgetNames() const;
QStringList dockWidgetsToClose() const;
int serializationVersion = KDDOCKWIDGETS_SERIALIZATION_VERSION;
LayoutSaver::MainWindow::List mainWindows;

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -28,6 +28,8 @@
#include <QVBoxLayout>
#include <QPainter>
// clazy:excludeall=ctor-missing-parent-argument,missing-qobject-macro
using namespace KDDockWidgets;
class MainWindow::Private

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -24,7 +24,7 @@
#include "Utils_p.h"
#include "SideBar_p.h"
#include "Logging_p.h"
#include "Item_p.h"
#include "WidgetResizeHandler_p.h"
#include "FrameworkWidgetFactory.h"
#include "DropAreaWithCentralFrame_p.h"
@@ -45,9 +45,11 @@ public:
return m_options & MainWindowOption_HasCentralFrame;
}
WidgetResizeHandler::CursorPositions allowedResizeSides(SideBarLocation loc) const;
QRect rectForOverlay(Frame *, SideBarLocation) const;
SideBarLocation preferredSideBar(DockWidgetBase *) const;
void updateOverlayGeometry();
void updateOverlayGeometry(bool reusePreviousSize = false);
void clearSideBars();
QString name;
@@ -95,7 +97,8 @@ void MainWindowBase::addDockWidgetAsTab(DockWidgetBase *widget)
}
}
void MainWindowBase::addDockWidget(DockWidgetBase *dw, Location location, DockWidgetBase *relativeTo, AddingOption option)
void MainWindowBase::addDockWidget(DockWidgetBase *dw, Location location,
DockWidgetBase *relativeTo, InitialOption option)
{
if (dw->options() & DockWidgetBase::Option_NotDockable) {
qWarning() << Q_FUNC_INFO << "Refusing to dock non-dockable widget" << dw;
@@ -158,6 +161,27 @@ void MainWindowBase::layoutParentContainerEqually(DockWidgetBase *dockWidget)
dropArea()->layoutParentContainerEqually(dockWidget);
}
WidgetResizeHandler::CursorPositions MainWindowBase::Private::allowedResizeSides(SideBarLocation loc) const
{
// When a sidebar is on top, you can only resize its bottom.
// and so forth...
switch (loc) {
case SideBarLocation::North:
return WidgetResizeHandler::CursorPosition_Bottom;
case SideBarLocation::East:
return WidgetResizeHandler::CursorPosition_Left;
case SideBarLocation::West:
return WidgetResizeHandler::CursorPosition_Right;
case SideBarLocation::South:
return WidgetResizeHandler::CursorPosition_Top;
case SideBarLocation::None:
return WidgetResizeHandler::CursorPosition_Undefined;
}
return WidgetResizeHandler::CursorPosition_Undefined;
}
QRect MainWindowBase::Private::rectForOverlay(Frame *frame, SideBarLocation location) const
{
SideBar *sb = q->sideBar(location);
@@ -215,21 +239,21 @@ QRect MainWindowBase::Private::rectForOverlay(Frame *frame, SideBarLocation loca
return rect;
}
static SideBarLocation opposedSideBarLocationForBorder(Layouting::Item::LayoutBorderLocation loc)
static SideBarLocation opposedSideBarLocationForBorder(Layouting::LayoutBorderLocation loc)
{
switch (loc) {
case Layouting::Item::LayoutBorderLocation_North:
case Layouting::LayoutBorderLocation_North:
return SideBarLocation::South;
case Layouting::Item::LayoutBorderLocation_East:
case Layouting::LayoutBorderLocation_East:
return SideBarLocation::West;
case Layouting::Item::LayoutBorderLocation_West:
case Layouting::LayoutBorderLocation_West:
return SideBarLocation::East;
case Layouting::Item::LayoutBorderLocation_South:
case Layouting::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:
case Layouting::LayoutBorderLocation_All:
case Layouting::LayoutBorderLocation_Verticals:
case Layouting::LayoutBorderLocation_Horizontals:
case Layouting::LayoutBorderLocation_None:
break;
}
@@ -237,21 +261,21 @@ static SideBarLocation opposedSideBarLocationForBorder(Layouting::Item::LayoutBo
return SideBarLocation::None;
}
static SideBarLocation sideBarLocationForBorder(Layouting::Item::LayoutBorderLocations loc)
static SideBarLocation sideBarLocationForBorder(Layouting::LayoutBorderLocations loc)
{
switch (loc) {
case Layouting::Item::LayoutBorderLocation_North:
case Layouting::LayoutBorderLocation_North:
return SideBarLocation::North;
case Layouting::Item::LayoutBorderLocation_East:
case Layouting::LayoutBorderLocation_East:
return SideBarLocation::East;
case Layouting::Item::LayoutBorderLocation_West:
case Layouting::LayoutBorderLocation_West:
return SideBarLocation::West;
case Layouting::Item::LayoutBorderLocation_South:
case Layouting::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:
case Layouting::LayoutBorderLocation_All:
case Layouting::LayoutBorderLocation_Verticals:
case Layouting::LayoutBorderLocation_Horizontals:
case Layouting::LayoutBorderLocation_None:
break;
}
@@ -268,45 +292,45 @@ SideBarLocation MainWindowBase::Private::preferredSideBar(DockWidgetBase *dw) co
return SideBarLocation::None;
}
const Layouting::Item::LayoutBorderLocations borders = item->adjacentLayoutBorders();
const Layouting::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) {
if (borders == Layouting::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))
for (auto borderLoc : { Layouting::LayoutBorderLocation_North, Layouting::LayoutBorderLocation_East,
Layouting::LayoutBorderLocation_West, Layouting::LayoutBorderLocation_South }) {
if (borders == (Layouting::LayoutBorderLocation_All & ~borderLoc))
return opposedSideBarLocationForBorder(borderLoc);
}
/// 3. It's touching left and right borders
if ((borders & Layouting::Item::LayoutBorderLocation_Verticals) == Layouting::Item::LayoutBorderLocation_Verticals) {
if ((borders & Layouting::LayoutBorderLocation_Verticals) == Layouting::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) {
if ((borders & Layouting::LayoutBorderLocation_Horizontals) == Layouting::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)) {
if (borders == (Layouting::LayoutBorderLocation_West | Layouting::LayoutBorderLocation_South)) {
return aspectRatio > 1.0 ? SideBarLocation::South
: SideBarLocation::West;
} else if (borders == (Layouting::Item::LayoutBorderLocation_East | Layouting::Item::LayoutBorderLocation_South)) {
} else if (borders == (Layouting::LayoutBorderLocation_East | Layouting::LayoutBorderLocation_South)) {
return aspectRatio > 1.0 ? SideBarLocation::South
: SideBarLocation::East;
} else if (borders == (Layouting::Item::LayoutBorderLocation_West | Layouting::Item::LayoutBorderLocation_North)) {
} else if (borders == (Layouting::LayoutBorderLocation_West | Layouting::LayoutBorderLocation_North)) {
return aspectRatio > 1.0 ? SideBarLocation::North
: SideBarLocation::West;
} else if (borders == (Layouting::Item::LayoutBorderLocation_East | Layouting::Item::LayoutBorderLocation_North)) {
} else if (borders == (Layouting::LayoutBorderLocation_East | Layouting::LayoutBorderLocation_North)) {
return aspectRatio > 1.0 ? SideBarLocation::North
: SideBarLocation::East;
}
@@ -324,7 +348,7 @@ SideBarLocation MainWindowBase::Private::preferredSideBar(DockWidgetBase *dw) co
: SideBarLocation::West;
}
void MainWindowBase::Private::updateOverlayGeometry()
void MainWindowBase::Private::updateOverlayGeometry(bool reusePreviousSize)
{
if (!m_overlayedDockWidget)
return;
@@ -335,7 +359,46 @@ void MainWindowBase::Private::updateOverlayGeometry()
return;
}
m_overlayedDockWidget->frame()->QWidgetAdapter::setGeometry(rectForOverlay(m_overlayedDockWidget->frame(), sb->location()));
const QRect defaultGeometry = rectForOverlay(m_overlayedDockWidget->frame(), sb->location());
QRect newGeometry = defaultGeometry;
Frame *frame = m_overlayedDockWidget->frame();
if (reusePreviousSize) {
// Let's try to honour the previous overlay size
switch (sb->location()) {
case SideBarLocation::North: {
const int maxHeight = q->height() - frame->pos().y() - 10; // gap
newGeometry.setHeight(qMin(frame->height(), maxHeight));
break;
}
case SideBarLocation::South: {
const int maxHeight = sb->pos().y() - m_dropArea->pos().y() - 10; // gap
const int bottom = newGeometry.bottom();
newGeometry.setHeight(qMin(frame->height(), maxHeight));
newGeometry.moveBottom(bottom);
break;
}
case SideBarLocation::East: {
const int maxWidth = sb->pos().x() - m_dropArea->pos().x() - 10; // gap
const int right = newGeometry.right();
newGeometry.setWidth(qMin(frame->width(), maxWidth));
newGeometry.moveRight(right);
break;
}
case SideBarLocation::West: {
const int maxWidth = q->width() - frame->pos().x() - 10; // gap
newGeometry.setWidth(qMin(frame->height(), maxWidth));
break;
}
case SideBarLocation::None:
qWarning() << Q_FUNC_INFO << "Unexpected sidebar value";
break;
}
}
m_overlayedDockWidget->frame()->QWidgetAdapter::setGeometry(newGeometry);
}
void MainWindowBase::Private::clearSideBars()
@@ -386,7 +449,7 @@ void MainWindowBase::overlayOnSideBar(DockWidgetBase *dw)
return;
const SideBar *sb = sideBarForDockWidget(dw);
if (sb == nullptr) {
if (!sb) {
qWarning() << Q_FUNC_INFO << "You need to add the dock widget to the sidebar before you can overlay it";
return;
}
@@ -402,7 +465,12 @@ void MainWindowBase::overlayOnSideBar(DockWidgetBase *dw)
auto frame = Config::self().frameworkWidgetFactory()->createFrame(this, FrameOption_IsOverlayed);
d->m_overlayedDockWidget = dw;
frame->addWidget(dw);
d->updateOverlayGeometry();
d->updateOverlayGeometry(/*reusePreviousSize=*/ false);
// Uncomment once I'm happy with the resizing
auto resizeHandler = new WidgetResizeHandler(true, frame);
resizeHandler->setAllowedResizeSides(d->allowedResizeSides(sb->location()));
frame->QWidgetAdapter::show();
Q_EMIT dw->isOverlayedChanged(true);
@@ -485,7 +553,7 @@ void MainWindowBase::setUniqueName(const QString &uniqueName)
void MainWindowBase::onResized(QResizeEvent *)
{
if (d->m_overlayedDockWidget)
d->updateOverlayGeometry();
d->updateOverlayGeometry(/*reusePreviousSize=*/ true);
}
bool MainWindowBase::deserialize(const LayoutSaver::MainWindow &mw)
@@ -526,6 +594,12 @@ bool MainWindowBase::deserialize(const LayoutSaver::MainWindow &mw)
}
}
if (mw.windowState != Qt::WindowNoState) {
if (auto w = windowHandle()) {
w->setWindowState(mw.windowState);
}
}
// Commented-out for now, we dont' want to restore the popup/overlay. popups are perishable
//if (!mw.overlayedDockWidget.isEmpty())
// overlayOnSideBar(DockRegistry::self()->dockByName(mw.overlayedDockWidget));
@@ -545,6 +619,8 @@ LayoutSaver::MainWindow MainWindowBase::serialize() const
m.screenSize = screenSizeForWidget(this);
m.multiSplitterLayout = dropArea()->serialize();
m.affinities = d->affinities;
m.windowState = windowHandle() ? windowHandle()->windowState()
: Qt::WindowNoState;
for (SideBarLocation loc : { SideBarLocation::North, SideBarLocation::East, SideBarLocation::West, SideBarLocation::South }) {
if (SideBar *sb = sideBar(loc)) {

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -74,11 +74,14 @@ public:
* @param dockWidget The dock widget to add into this MainWindow
* @param location the location where to dock
* @param relativeTo In case we're docking in relation to another dock widget
* @param option AddingOptions
* @param initialOption Allows to specify an InitialOption. Which is useful to add the dock widget
* as hidden, recording only a placeholder in the tab. So it's restored to tabbed when eventually
* shown.
*/
void addDockWidget(DockWidgetBase *dockWidget,
KDDockWidgets::Location location,
DockWidgetBase *relativeTo = nullptr, AddingOption option = KDDockWidgets::AddingOption());
DockWidgetBase *relativeTo = nullptr,
InitialOption initialOption = {});
/**
* @brief Returns the unique name that was passed via constructor.

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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
@@ -73,6 +73,7 @@ namespace KDDockWidgets {
class LayoutGuestWidget : public KDDockWidgets::QWidgetAdapter
, public LayoutGuestWidgetBase
{
Q_OBJECT
public:
explicit LayoutGuestWidget(QWidgetOrQuick *parent)
: QWidgetAdapter(parent)

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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
@@ -20,6 +20,8 @@ namespace Qt5Qt6Compat {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#define QQUICKITEMgeometryChanged geometryChange
using QEnterEvent = QEnterEvent;
using qintptr = ::qintptr;
using qhashtype = size_t;
@@ -34,8 +36,9 @@ inline QPoint eventGlobalPos(QMouseEvent *ev)
return ev->globalPosition().toPoint();
}
#else
// Qt 5:
#else // Qt 5:
#define QQUICKITEMgeometryChanged geometryChanged
using QEnterEvent = QEvent;
using qintptr = long;

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2019-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -9,4 +9,4 @@
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include "../../../../private/widgets/TabWidget_p.h"
#include "../../KDDockWidgets.h"

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

View File

@@ -1,7 +1,7 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-FileCopyrightText: 2020-2021 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

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