Compare commits

...

542 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
Allen Winter
2fb70009cc OBS - updates 2020-12-17 14:40:16 -05:00
Allen Winter
289ddffbe2 prep for 1.2.0 release 2020-12-17 14:40:16 -05:00
Sergio Martins
54738bbea2 Simplify WidgetResizeHandler::cursorPosition() impl 2020-12-17 18:51:40 +00:00
Sergio Martins
5c6eb352d6 Use the CursorPosition enum as flags 2020-12-17 18:46:31 +00:00
Sergio Martins
f657399ef8 Make enum public so we can use Q_ENUM 2020-12-17 18:44:48 +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
c4ffe10e12 Fix non unity build 2020-12-17 12:24:12 +00:00
Sergio Martins
efcad6d2be Update ChangeLog 2020-12-17 11:53:12 +00:00
Sergio Martins
c7dc7bdb3d Bump so version on master 2020-12-17 11:15:42 +00:00
Sergio Martins
b6925c928a Clear sidebars before restoring them
If restoring a state without a sidebar, the existing sidebars
should hide

Fixes issue #116
2020-12-17 10:51:16 +00:00
Sergio Martins
75368d334a Don't restore the popup/overlay state
popups are perishable
2020-12-17 10:15:39 +00:00
Allen Winter
d39ce8f66e tests/Testing.cpp - include <QTest>, not <QtTest> 2020-12-16 17:10:07 -05:00
Allen Winter
805ea41d8a Rubberband_quick.h, RubberBandQuick.h - adjust include guard 2020-12-16 17:04:06 -05:00
Allen Winter
d7ed2494be CMakeLists.txt - add documentation for the new options 2020-12-16 17:01:47 -05:00
Allen Winter
0990337cdc examples/qtquick/CMakeLists.txt - add license+copyright header 2020-12-16 16:51:03 -05:00
Allen Winter
e41cdb6f78 various - fix misspellings 2020-12-16 16:49:22 -05:00
Sergio Martins
666673a251 Added a comment 2020-12-16 18:46:56 +00:00
Sergio Martins
34cb2ae5f0 Restore the SideBars when restoring a layout
For issue #116
2020-12-16 18:27:29 +00:00
Sergio Martins
51d8c2ff3e tests: Group the "Save/restore" tests together 2020-12-16 18:15:06 +00:00
Sergio Martins
aa9f50d0f4 Serialize the SideBar to JSON too
Part 1 of 2 for issue #116
2020-12-16 17:58:05 +00:00
Sergio Martins
b7c36a2ec9 Stabilize a test with 5.9
Minor differences in the frame's min-sizes, no point in spending
more time on such old Qt version just so tests pass.
2020-12-16 17:24:33 +00:00
Sergio Martins
e18fb7ffd8 Remove unneeded private moc include
Doesn't play nice with unity builds
2020-12-16 15:48:32 +00:00
Sergio Martins
96439339c7 cmake: Add a missing QtQuick header to the source list 2020-12-16 15:46:31 +00:00
Sergio Martins
04d418b2e9 same for QtQuick 2020-12-16 15:42:48 +00:00
Sergio Martins
c04d856322 cmake: Add the header files to the source list too
So they are automoced with unity build
2020-12-16 15:40:25 +00:00
Sergio Martins
1c41c33f33 Merge the two qrc files that are only for QtQuick 2020-12-16 11:53:36 +00:00
Sergio Martins
1dae128511 Fix the static build
The other library qrc is only needed for QtQuick
2020-12-16 11:41:15 +00:00
Sergio Martins
eab80c0545 Fix a -Wmismatched-tag warning 2020-12-16 10:54:47 +00:00
Sergio Martins
288c3df30b Add missing include 2020-12-15 23:11:52 +00:00
Sergio Martins
e8728e8a35 qtquick: Fix the qrc not being included 2020-12-15 23:07:11 +00:00
Sergio Martins
94bfc4f2d1 qtquick: Fix build 2020-12-15 23:02:13 +00:00
Sergio Martins
d2da07508a Replaced an include with a fwd decl 2020-12-15 22:58:10 +00:00
Sergio Martins
7082e40cd5 Fix non-developer build
These exports are needed
2020-12-15 21:56:22 +00:00
Sergio Martins
2c8bbd10f7 Remove the export macros from the old library
We now use only 1 library, so use the same export macros
2020-12-15 21:41:10 +00:00
Sergio Martins
ed8a401fe8 Meld kddockwidgets__multisplitter into kddockwidgets lib
It's overkill to have it in a separate library.
Simplifies deployment.
Speeds up build, as it was breaking paralellism.
2020-12-15 21:00:41 +00:00
Sergio Martins
72428075f0 Fix -Wshadow warnings 2020-12-15 20:38:20 +00:00
Sergio Martins
562db7c812 qtquick: Fix build
Missing include guards
2020-12-15 13:38:35 +00:00
Sergio Martins
3ee15d1307 Give python a bit of help building KDDW 2020-12-15 12:15:23 +00:00
Sergio Martins
cf232dda34 Enable Unity Builds unconditionally
Projects using KDDW won't need to modify KDDW, so there's no impact
on incremental builds
2020-12-15 11:13:41 +00:00
Sergio Martins
bfeac02a45 cmake: Make KDDW build faster with a unity build 2020-12-12 15:18:39 +00:00
Sergio Martins
22f4c36eb0 cmake: remove duplicate set of qtquick/qtwidget cmake options
Let's simply things and only use one set. If the top-level requires
QtQuick then so will multisplitter. It's not mix-and-match.
2020-12-12 14:11:26 +00:00
Allen Winter
3dc56ea4ef Merge branch '1.1' 2020-12-12 08:20:10 -05:00
Allen Winter
cbedc06e97 various - prep for 1.1.1 release 2020-12-11 16:56:04 -05:00
Sergio Martins
8f85f28ed4 Merge branch '1.1' 2020-12-11 16:44:07 +00:00
Sergio Martins
b5c2757874 Updated Changelog with v1.1.1 2020-12-11 16:36:37 +00:00
Sergio Martins
46f57ffbbc Merge branch '1.1' 2020-12-10 21:39:54 +00:00
Sergio Martins
fb6e2afd7b Windows: Don't start a drag when it's a resize
There were a few pixels where you could click where, very near the
border where it would start a drag while it shouldn't.

The drag state machine then was in an invalid state which could lead to
a crash.

Fixes issue #110
2020-12-10 21:16:42 +00:00
Sergio Martins
f74eb73326 qt6: Use only one CMake option for Qt6
We still had OPTION_QT6 leftovers
2020-12-09 14:09:20 +00:00
Sergio Martins
ceb796d807 qt6: Don't set the HDPI attributes
They don't do anything on Qt6, but warn.
2020-12-09 12:23:17 +00:00
Sergio Martins
9a9488117c Add a State dtor, fixes a -Wweak-vtables warning 2020-12-09 11:13:55 +00:00
Sergio Martins
e55d75ba98 qt6: Fix build on Windows 2020-12-08 23:21:51 +00:00
Sergio Martins
742763e6e5 qt6: Remove unneeded Qt5Test find
It's already found in the root CMakeLists.txt
2020-12-08 22:56:59 +00:00
Sergio Martins
d7242f17b7 examples: Add AUTORCC
Fixes standalone examples not showing images
2020-12-08 22:36:23 +00:00
Sergio Martins
eba395dc4c Fix build 2020-12-08 22:31:21 +00:00
Sergio Martins
89635d8b98 qt6: build is fixed now 2020-12-08 21:47:35 +00:00
Sergio Martins
f475312f11 qt6: Port away from QStateMachine
QStateMachine was moved to qtsxml module, which is not ported to
Qt6 yet.

We use QStateMachine for the semantics it gives us, not because of
its implementation. The implementation is trivial, so do it outselves.
We used very little from QStateMachine.
2020-12-08 19:55:52 +00:00
Sergio Martins
9f604829dd qt6: Use AUTORCC instead of qt5_add_resources
As this works with both Qt5 and Qt6
2020-12-08 18:11:34 +00:00
Sergio Martins
85f829f97a qt6: Remove an hardcoded Qt5 lib 2020-12-08 16:38:08 +00:00
Sergio Martins
e3bb0b3d48 qt6: Link to StateMachine 2020-12-08 16:36:00 +00:00
Sergio Martins
22c0b6f9b6 qt6: Fix build of FloatingWindow.cpp
QWidget::nativeEvent() changed signature
2020-12-08 16:33:35 +00:00
Sergio Martins
200cb7aded qtquick: Fix build with gcc 2020-12-08 15:06:21 +00:00
Sergio Martins
4999fdd819 qtquick: Remove the native child widget case
This can only happen for QtWidgets. With QtQuick all items are
alien, never native
2020-12-06 15:48:31 +00:00
Sergio Martins
76aca4139a Minor cleanup 2020-12-05 23:37:56 +00:00
Sergio Martins
64276cb872 qtquick: Fix clicking on close button of floating window
Since we're using native events on windows we were using the whole
title bar for dragging, but obviously the buttons don't serve for
window dragging
2020-12-05 23:28:04 +00:00
Sergio Martins
aad63d117b qtquick: Enable aero-snap on Windows
The events simply need to be forward from QWindow to the FloatingWindow.
That happens automatically for QWindow/QWidget, but not with
QWindow/QQuickItem, so add this behaviour to QtQuick too, so it behaves
the same as QtWidgets and we have a single code path for aero snap
2020-12-05 15:20:26 +00:00
Sergio Martins
bd66af0a9f Remove unused logging categories 2020-12-05 14:29:13 +00:00
Sergio Martins
a21d80279e qtquick: Fix background of indicator being black on macOS 2020-12-03 19:15:34 +00:00
Sergio Martins
4347aefc8f Fix a -Wweak-vtable warning on macOS 2020-12-03 18:45:08 +00:00
Sergio Martins
b6341154fb qtquick: Fix a test
The tests are not prepared for the min-size of the floating window
to change (QLayout helped with that). We need to write some kind
of constraint propagation first, until then we use a static
size for the non-contents
2020-12-03 18:24:26 +00:00
Sergio Martins
16f6692b79 qtquick: Add an example of how to instantiate a dock widget from QML
Instead of using C++
2020-12-03 14:58:59 +00:00
Sergio Martins
6c1026956a qtquick: titlebar's height is reduced to 0 when invisible
otherwise we see an empty space when it's not visible
2020-12-02 23:33:04 +00:00
Sergio Martins
97679abb02 qtquick: silence warning
not worth it
2020-12-02 23:29:15 +00:00
Sergio Martins
e173a4cfff qtquick: Also allow for custom titlebar for the Frame 2020-12-02 23:24:28 +00:00
Sergio Martins
26971ef1e2 qtquick: Add an example of a custom title bar 2020-12-02 23:20:44 +00:00
Sergio Martins
d7bde47105 qtquick: Don't hardcode the title bar height in C++
It's now in QML and the user is allowed to change it
2020-12-02 22:58:11 +00:00
Sergio Martins
143c82291d qtquick: The user can now choose another titlebar file 2020-12-02 22:43:01 +00:00
Sergio Martins
979b2fdd40 qtquick: Set the frameworkwidget factory as a context prop 2020-12-02 22:38:17 +00:00
Sergio Martins
46337d900b qtquick: Load the titlebars with a loader
in followup commit the source will be user configurable
2020-12-02 21:43:57 +00:00
Sergio Martins
ec1f1bea9a qtquick: Move some style code to TitleBar.qml
Doesn't belong in the base component
2020-12-02 21:30:55 +00:00
Sergio Martins
d207028d60 qtquick: Document and add proper interface to TitleBarBase.qml 2020-12-02 16:17:46 +00:00
Sergio Martins
a237eae508 qtuick: Add a customtitlebar example stub
Not custom yet.
2020-12-02 15:48:51 +00:00
Sergio Martins
243396f22b qtquick: Move the example into a sub-directory
We'll have other qtquick examples
2020-12-02 14:52:10 +00:00
Sergio Martins
f240bf5d40 Disable Aero-snap for QtQuick, for now 2020-12-01 20:33:52 +00:00
Sergio Martins
785db1b50c qtquick: Fix detaching windows not working smoothly
Use the global event filter, as grabing isn't reliable in QtQuick.

Either not the same item is getting the mouse moves and release, or
it's because QtQuick internally is also setting/unsetting grabbers,
as seen in the source code
2020-12-01 20:14:46 +00:00
Sergio Martins
b6a7048a4f Fwd declare QWidget, no need to include in the header 2020-12-01 19:48:41 +00:00
Sergio Martins
52bff59024 Remove duplicated logic regarding mouse events 2020-11-30 23:14:00 +00:00
Sergio Martins
bba0195196 Move "mouseEvent()" function to Utils_p.h
So it can be reused
2020-11-30 23:00:30 +00:00
Sergio Martins
41fdb9c7df qtquick: Fix non-developer build 2020-11-30 18:37:39 +00:00
Sergio Martins
c1c1da25a8 Fix build with vs2013 2020-11-30 14:11:21 +00:00
Sergio Martins
b4e7b97646 examples: Fix non-developer build 2020-11-30 12:25:29 +00:00
Sergio Martins
2c687fe469 qtquick: Implement the rubber band
When hovering a drop indicator we now see the blue rubberband
2020-11-29 22:31:11 +00:00
Sergio Martins
10e0402afa Fix build 2020-11-29 19:51:37 +00:00
Sergio Martins
ebb1179167 fix namespace 2020-11-29 19:41:30 +00:00
Sergio Martins
15c196d865 qtquick: Move Rubberband to its own file 2020-11-29 19:23:10 +00:00
Sergio Martins
e897ce6e8e qtquick: Add a replacement for QAction
So we don't depend on QtWidgets lib
2020-11-29 18:44:00 +00:00
Sergio Martins
83d9db1b64 qtquick: multisplitter lib no longer depends on QtWidgets
Added a QSizePolicy replacement.
KDDW for QtQuick still needs to link to QtWidgets, but it's a
step forward
2020-11-29 18:08:49 +00:00
Sergio Martins
60331fc654 qtquick: Remove some unneeded QtWidget includes 2020-11-29 17:57:14 +00:00
Sergio Martins
e8f16dd172 qtquick: Don't build ObjectViewer 2020-11-29 17:50:51 +00:00
Sergio Martins
44bd451362 qtquick: stabilize tests with offscreen QPA 2020-11-29 15:17:29 +00:00
Sergio Martins
1d2a791dfc qtquick: Fix DND operation never ending
When double-clicking a title bar we're getting: Press, Release,
Press and never the Release. We get the MouseDblClickEvent instead,
so handle that
2020-11-29 14:40:03 +00:00
Sergio Martins
a4ba45b423 qtquick: Fix flickering the first time we drag over 2020-11-28 19:27:18 +00:00
Sergio Martins
12576970c6 qtquick: Fix dragged window being behind in Z order
For QtWidgets, when we raise something that's not a top-level
it won't raise. So do the same thing for QtQuick
2020-11-28 18:28:43 +00:00
Sergio Martins
e0ee7d14b0 qtquick: Remove warning about we not implementing keyboard ungrab
I don't see it in QQuickItem API, so we also don't grab it to
begin with
2020-11-28 17:53:39 +00:00
Sergio Martins
66f447ad3f qtquick: Fix crash when hovering over titlebar
It would think we were over a drag indicator, because during an instant
the overlay window has 0x0 size but the indicators are still visible.

Fix by only showing the overlay window (visible property) when it has
the correct size
2020-11-28 17:11:46 +00:00
Sergio Martins
75db599142 tests: Make DropArea::hover() return the chosen drop location
Just for tests.
2020-11-28 16:47:19 +00:00
Sergio Martins
a5c65ae039 Introduce NullIndicators and a Config option for it
Mostly for debugging purposes, but also useful if anyone doesn't
want to display indicators
2020-11-28 14:11:39 +00:00
Sergio Martins
5c055e0b8d examples: Add a flag to disable aero-snap
For development/debugging purposes only
2020-11-28 00:39:30 +00:00
Sergio Martins
090483f04e qtquick: Add some flags to the example
Mostly for debugging at this point
2020-11-28 00:18:41 +00:00
Sergio Martins
953219f6f3 qtquick: Minor refactoring
Removed some hardcoded QLineEdit casts, that code is now generic.
2020-11-27 18:47:03 +00:00
Sergio Martins
8356bb0c3c Introduce KDDockWidgets::widgetAt()
Only repro for QtWidgets for now, but already useful to remove some
QApplication includes
2020-11-27 18:29:46 +00:00
Sergio Martins
758548f7a2 qtquick: Only Windows needs Angle 2020-11-27 17:11:45 +00:00
Sergio Martins
2aa16eb6d9 examples: comment out the old multisplitter example
It's not for end users. Might even delete it
2020-11-27 17:07:44 +00:00
Sergio Martins
9d6cef24c1 qtquick: Use Angle on Windows
It's aero-snap friendly. Otherwise shows black artifacts.
We can however use normal GL and use FramelessWindowhint instead
2020-11-27 16:46:21 +00:00
Sergio Martins
52999d4cc9 qtquick: Don't process native events when being deleted 2020-11-27 15:03:55 +00:00
Sergio Martins
bc2fff2c04 qtquick: Window resizing works on Linux/mac now 2020-11-27 13:59:27 +00:00
Sergio Martins
40fa4e98f8 qtquick: Fix tests
Mouse tracking isn't implemented, so warns
2020-11-27 11:06:47 +00:00
Sergio Martins
a07f63a2c7 qtquick: Fix build on Windows 2020-11-26 23:30:55 +00:00
Sergio Martins
39c9a4da9b qtquick: Enable native event handling for the floating windows
Same as done with QtWidgets, now hopefully we have native window
resize
2020-11-26 23:26:15 +00:00
Sergio Martins
e0aa547393 qtquick: Start using the WidgetResizeHandler
It's no longer commented out in FloatingWindow.
Doesn't do much for QtQuick, but at least we don't have different
code paths

Making it work is next.
2020-11-26 23:13:46 +00:00
Sergio Martins
08eab8882f qtquick: Call FloatingWindow::setupWindow() at the correct time
We need a QWindow. While that's done very early, and automatically
for QtWidgets, for QtQuick it's done later, by us, manually
2020-11-26 22:52:23 +00:00
Sergio Martins
04723ac3a9 Minor refactoring, moved code into a function 2020-11-26 22:46:14 +00:00
Sergio Martins
c25043fa00 qtquick: Enable more QtWidget paths that compile fine
Just needed a dummy create() function
2020-11-26 22:28:57 +00:00
Sergio Martins
5372920cd0 qtquick: Port NCHITTESTEventFilter 2020-11-26 21:53:48 +00:00
Sergio Martins
28ae4c3b8c Add helper to get FloatingWindow by its WId 2020-11-26 21:42:45 +00:00
Sergio Martins
6158ebd520 qtquick: Fix our QtQuick QLineEdit clashing with the QWidgets one
Some indirect include is making it clash. Cleaner to use a different
name anyway
2020-11-26 21:28:01 +00:00
Sergio Martins
b77430e574 Remove two more unneeded QApplication includes 2020-11-26 19:35:46 +00:00
Sergio Martins
fad81d595a qtquick: Remove some dependencies to QApplication 2020-11-26 19:31:32 +00:00
Sergio Martins
0980a7f601 qtquick: Port qtTopLevelForHWND() to Windows
Deals in QWindow instead of QWidget
2020-11-26 18:54:58 +00:00
Sergio Martins
46830713e0 stabilize test on Windows 2020-11-26 18:27:17 +00:00
Sergio Martins
cd796db0ff Add helper topLevelForHandle() 2020-11-26 17:53:28 +00:00
Sergio Martins
29da5f4a8a qtquick: Fix another include
Fixes the multisplitter build on Windows, which has a more picky
linker
2020-11-26 17:18:55 +00:00
Sergio Martins
315bdc71e5 qtquick: Include the correct include
Not the widget one
2020-11-26 17:17:18 +00:00
Sergio Martins
a8965bea91 Fix a unit-test
Broke it by mistake
2020-11-26 17:00:10 +00:00
Sergio Martins
bf259c7ffc qtquick: Fix build on mac
Mostly due to -Werror and clang having more warnings
2020-11-26 16:45:12 +00:00
Sergio Martins
8a990451d7 Fix casting -1 to WId on mac 2020-11-26 15:59:32 +00:00
Sergio Martins
974bdbd637 Fix a -Wweak-vtable warning 2020-11-26 15:55:52 +00:00
Sergio Martins
cb9d77cd18 Fix more -Woverloaded-virtual 2020-11-26 15:17:33 +00:00
Sergio Martins
af10efa587 Fix more -Woverloaded-virtual 2020-11-26 15:15:37 +00:00
Sergio Martins
a0fb47af58 Fix -Woverloaded-virtual 2020-11-26 14:52:04 +00:00
Sergio Martins
598fbdc51b qtquick: Fix build on mac
RubberBand was being compiled twice. We shouldn't compile the
_widget* multisplitter files when using QtQuick.

Also implies tst_multisplitter shouldn't be run when compiling
for QtQuick.
2020-11-26 14:29:17 +00:00
Sergio Martins
81c3f3f0c6 Fix a -Wweak-vtables warning 2020-11-26 13:28:15 +00:00
Sergio Martins
b9962b3df0 qtquick: Make the QWinWidget case specific to QtWidgets
With QtQuick we don't have QWinWidget
2020-11-26 13:23:06 +00:00
Sergio Martins
a71386e62a Fix using qAbs(bool)
detected by msvc
2020-11-26 12:59:51 +00:00
Sergio Martins
812ce1c08b qtquick: Fix floating dock #3 in the example
It would go to its previous place (0,0), so don't show it at
start.

Added a unit-test as thought it was a bug, but code is correct.
2020-11-26 12:31:50 +00:00
Sergio Martins
189e82450b qtquick: Add 2px margin for the the tab widget
Mimics QtWidgets
2020-11-26 12:06:52 +00:00
Sergio Martins
a3dbc3739c qtquick: Make title bar look nicer 2020-11-26 12:02:58 +00:00
Sergio Martins
c8d34375af qtquick: Add margin to Frame 2020-11-26 11:43:30 +00:00
Sergio Martins
6c3775ea45 qtquick: floating window now has a border and 4px margin
Just like the QtWidget one
2020-11-26 11:36:36 +00:00
Sergio Martins
5a72e1adab qtquick: Fix some colors 2020-11-25 23:52:56 +00:00
Sergio Martins
0f7f310734 qtquick|example: Use the KDAB logs, as we have for QtWidgets 2020-11-25 23:09:53 +00:00
Sergio Martins
e8bf2a5222 qtquick: Remove dummy background color 2020-11-25 22:59:30 +00:00
Sergio Martins
468f545c9a qtquick: Enable more tests
these pass now, too
2020-11-25 22:15:52 +00:00
Sergio Martins
a59ff6dfee qtquick: Build tests with ctest too 2020-11-25 21:41:46 +00:00
Sergio Martins
4fa415ba05 qtquick: Comment out a few tests
We don't support max-size yet
2020-11-25 21:01:37 +00:00
Sergio Martins
d851c60b2f qtquick: Don't allow the initial window size to be smaller than its min
Fixes a test
2020-11-25 20:52:29 +00:00
Sergio Martins
bf097098e5 qtquick: Fix pointer comparison in test 2020-11-25 20:10:32 +00:00
Sergio Martins
8c93b85a24 qtquick: Remove unneeded code 2020-11-25 20:10:13 +00:00
Sergio Martins
f87d67dd59 qtquick: Remove unneeded code 2020-11-25 20:07:08 +00:00
Sergio Martins
bc3278b218 qtquick: tst_positionWhenShown 2020-11-25 17:01:37 +00:00
Sergio Martins
d2c55a67df qtquick: Fix more tests 2020-11-25 16:28:54 +00:00
Sergio Martins
a3414fd92b qtquick: Fix tst_addToSmallMainWindow1 2020-11-25 16:10:04 +00:00
Sergio Martins
12f3ba9074 qtquick: Fix some tests 2020-11-25 16:02:42 +00:00
Sergio Martins
034d2c8aee README: Mention Qt6 2020-11-25 12:31:29 +00:00
Sergio Martins
ad3f4141c8 qtquick|tests: Fix main window QWindow not being resized 2020-11-24 18:40:22 +00:00
Sergio Martins
cde2e4e571 qtquick: Fix tst_constraintsAfterPlaceholder
The resize happens sync for QtQuick, so that wait isn't needed
2020-11-24 13:36:10 +00:00
Sergio Martins
e0775467b2 qtquick|tests: Fix verifying frame min size 2020-11-24 13:12:53 +00:00
Sergio Martins
b20ffcde61 tst_negativeAnchorPosition: Fix typo
we need to subtract from height(), not width()
2020-11-24 12:44:00 +00:00
Sergio Martins
43bdb6a4c2 qtquick: Bunch of fixes for min-size support 2020-11-24 11:38:13 +00:00
Sergio Martins
929aabdc0d example: Add --native-title-bar
Behind developer mode for now
2020-11-23 21:37:59 +00:00
Sergio Martins
6a90a5125f TitleBar: these 4 getters are only for development mode 2020-11-23 20:22:45 +00:00
David Faure
77016a619f Fixes for being used as a subproject
* Don't use CMAKE_SOURCE_DIR, always use CMAKE_CURRENT_SOURCE_DIR
* -Werror=undef found that #if was used instead of #ifdef
2020-11-23 21:16:40 +01:00
Sergio Martins
dc328ff7c4 Fix developer mode build on Windows
developer mode will make some 'private' in headers be 'public', this
affects name mangling on MSVC.

kddockwidgets_linter didn't have the developer mode macro enabled,
so there was a mangling mismatch when linking
2020-11-23 17:40:06 +00:00
Sergio Martins
dc13665566 Fix forward declaration 2020-11-23 16:53:52 +00:00
Sergio Martins
d1279ab119 Merge branch '1.1' 2020-11-23 15:57:42 +00:00
Sergio Martins
80bf6032f3 Fix FloatingWindow's title when shown in the taskbar
The window title isn't only important when using native title bar,
it's also important for showing the correct title in the taskbar
or alt-tab.

For example, if using "minimize support", they'll show in the task bar

Fixes issue #101
2020-11-23 15:52:50 +00:00
Sergio Martins
22437e75c6 qtquick: Override min size for FrameQuick
Fixes constriants not propagating from dock widget to frame
2020-11-23 15:45:06 +00:00
Sergio Martins
801e49de9d Make DockWidgetQuick::minimumSize()/max virtual
While for QtWidgets we have layouts which propagate the constraints
up, for QtQuick we don't, so we need to override minimumSize instead
2020-11-23 15:45:06 +00:00
Sergio Martins
a847a574ed qtquick: Delete the frame visual item delayed
If we're in a QML event handler we can't delete the QML item,
it's a QML limitation. We still want to delete the dockwidgets now though
since all tests depend on that.
2020-11-23 15:45:06 +00:00
Sergio Martins
ef8807bc09 Minor style 2020-11-23 15:45:06 +00:00
Allen Winter
d441477fa9 Merge branch '1.1' 2020-11-22 12:25:28 -05:00
Allen Winter
ece7b22bec apidox - fix doc for enum KDDockWidgets::Config::Flag
doxygen likes "///<"  (not "///>")

Issue#106
2020-11-22 12:17:38 -05:00
Sergio Martins
97d8e4f18b qtquick|tests: Be able to deliver a double-click event to a titlebar
Needed for tests
2020-11-20 21:44:06 +00:00
Sergio Martins
9937f5d789 qtquick: Fix floating windows having a parentItem
they are top-level windows, so shouldn't have a parent item.
Only a QObject::parent()
2020-11-20 16:55:00 +00:00
Sergio Martins
675edfe6db qtquick: Move the floating button logic one level up, to the base class
So QtQuick can use the same logic.

Fixes tst_nonDockable too.
2020-11-20 15:35:46 +00:00
Sérgio Martins
c23d179385 Add support for Qt6
Adds the -DKDDockWidgets_QT6=ON option
Also you'll need to port any required Qt6 module first (For example QStateMachine).
2020-11-20 12:36:11 +00:00
Sergio Martins
36af020505 Fix two scoped value rollback being temporaries 2020-11-20 09:55:31 +00:00
Sergio Martins
7b2d195139 qtquick: Put the failing QtQuick tests at the end
So they don't corrupt the passing ones.
Approx 40 need to pass now.
2020-11-19 22:59:00 +00:00
Sergio Martins
984ab3bb13 qtquick: Add support for disabling close button
For when dockwidget isnt' closable.
Fixes tst_nonClosable() too
2020-11-19 22:12:49 +00:00
Sergio Martins
0331f90791 Move title bar logic regarding close button to base class
So QtQuick can use it too
2020-11-19 22:09:40 +00:00
Sergio Martins
b19c53d650 qtquick: Implement some title bar helpers for tests
Mostly getters that return the title button state
2020-11-19 21:45:29 +00:00
Sergio Martins
3670cf2377 qtquick: Comment the embedded main window test
We don't support that yet
2020-11-19 17:49:27 +00:00
Sergio Martins
864670b0a1 qtquick: Fix some cases where floating windows didn't have parent
Happened because floatingWindow->parentWidget() was null. On QtWidgets
this works because QWidget::parentWidget() will return the transient parent
without a problem.
2020-11-19 17:47:02 +00:00
Sergio Martins
0cf148b389 tests: Check for the existence of QWindow at exit, not QWidget
So we're clean for QtQuick too
2020-11-19 16:34:30 +00:00
Sergio Martins
921d0892a0 qtquick: Fix tst_setVisibleFalseWhenSideBySide
Was also broken (but passed) for QtWidgets.
We don't support hidding widgets with setVisible(false).
2020-11-19 11:59:09 +00:00
Sergio Martins
beb2d9e659 qtquick: Add support for non-closable windows
fixes tst_preventClose
2020-11-18 18:13:35 +00:00
Sergio Martins
59168da231 qtquick: Fix crash at exit
Don't delete our QWindow if the QWindow is currently deleting us
2020-11-18 18:10:32 +00:00
Sergio Martins
3dbf699c49 qtquick: Fix QtQuick parenting
Mimic QtWidgets so we have similar behaviour:

- When a MainWindow is deleted, its associated QWindow is deleted
too.
- When a MainWindow is deleted, it deletes any FloatingWindows
which have it as a transient parent
2020-11-18 16:18:42 +00:00
Sergio Martins
baa7561b13 qtquick: Fix tst_addAndReadd
Wasn't even correct for QtWidgets and just passing because the
widget wasn't getting dropped QtWidgets, since the indicator was hidden.

For QtQuick the indicator is also hidden but it's accepting it. To fix.
2020-11-18 14:42:34 +00:00
Sergio Martins
ac5f4b871c qtquick: Fix tst_honourGeometryOfHiddenWindow
We want the geometry of the QWindow
2020-11-18 14:30:08 +00:00
Sergio Martins
52bf449366 qtquick: Fixes for focusing
Fixes tst_focus too, and  maybe a few other tests
2020-11-18 14:01:55 +00:00
Sergio Martins
08a1c4e6df qtquick: Implement focus policy
fixes tst_dockWidgetGetsFocusWhenDocked
2020-11-18 12:35:46 +00:00
Sergio Martins
156dad6e03 qtquick: Fix IndicatorWindow::posForIndicator()
Wasn't even implemented. Should make some tests pass.
2020-11-18 12:06:20 +00:00
Sergio Martins
b642d2df2f qtquick: Fix dropped widget not being the current tab 2020-11-18 11:44:55 +00:00
Sergio Martins
5cedfab82c Make DropIndicatorOverlay::posForIndicator() pure virtual 2020-11-18 11:44:02 +00:00
Sergio Martins
af9d62a58c qtquick: Fix FloatingWindows not being destroyed when empty
Also fixes tst_createFloatingWindow
2020-11-17 23:15:33 +00:00
Sergio Martins
0758496b0d Fix QtQuick build without developer mode 2020-11-17 21:15:07 +00:00
Sergio Martins
a452723919 Fix tests running with a nullptr state machine 2020-11-17 21:08:05 +00:00
Sergio Martins
774e66ba6f Minor: add an assert
Provides a nicer backtrace when it happens.
Currently repro on QtQuick only
2020-11-17 21:04:32 +00:00
Sergio Martins
f13de89db5 tests. Fix utils.h draggableFor() for QtQuick 2020-11-17 20:44:04 +00:00
Sergio Martins
1393ae224f Fix DockWidget::windowActiveAboutToChange() being emitted too much
Was being emitted even when it didn't affect our window.
This caused an explosion of signals when we had many dock widgets.
2020-11-17 18:52:54 +00:00
Sergio Martins
d92d7c258c tests: Remove stray qDebug 2020-11-17 18:15:38 +00:00
Sergio Martins
619ca74051 Use QFAIL instead of qFatal
more elegant, and test can continue, so we see the whole result
2020-11-17 18:15:03 +00:00
Sergio Martins
aa39a71ae5 Rename tst_common to tst_docks
Now that tst_docks was all ported let's have the old name again.
Also cmake -jN now works, as tst_docks is called by the tests_launcher
while tst_common was not
2020-11-17 15:44:49 +00:00
Sergio Martins
f4e33c1409 tests: Port the remaining tests to QtQuick
Tests now build with QtQuick too.
2020-11-17 15:26:14 +00:00
Sergio Martins
ad96336a36 Also init resources if QT_STATIC is defined
Should help with WASM, so you don't need to manually call
Q_INIT_RESOURCE
2020-11-17 11:35:37 +00:00
Sergio Martins
50d1e75709 Fully scope the qrc resource files
So they don't clash when KDDW is a static library
2020-11-17 11:33:22 +00:00
Sergio Martins
793c4e509b Fix crash regarding edge case of dragging window to itself
If we're not showing a title bar, then the draggable is the tabbar,
not the floating window.
2020-11-16 22:55:45 +00:00
Sergio Martins
e4a33ad8b7 Added README for wasm
Fixes issue #100
2020-11-13 18:45:58 +00:00
Sergio Martins
52cf53ce5c example: init resources if static
Fixes title bar not having icons on WASM
For issue #100
2020-11-13 18:33:13 +00:00
Sergio Martins
8791870efb Blacklist classical indicators on WASM
Use segmented indicators.
Wasm doesn't support top-level windows with translucency, which
is required for the classical indicators

For issue #100
2020-11-13 18:18:25 +00:00
Sergio Martins
4f8c47bfa4 Don't require Qt5X11Extras for web assembly
For issue #100
2020-11-13 17:43:38 +00:00
Sergio Martins
ad141df6b1 Merge branch '1.1' 2020-11-13 16:00:49 +00:00
Sergio Martins
72605292b7 Don't show dock/undock icon when dockwidget is not dockable
Fixes issue #99
2020-11-13 15:51:26 +00:00
Sergio Martins
1443eff1d9 tests: Port some tests to QtQuick
15 to go
2020-11-10 18:00:19 +00:00
Sergio Martins
22d5db32ce FocusScope: Remove focus when nothing is focused 2020-11-09 15:25:32 +00:00
Sergio Martins
e9a321039f Renamed signal to windowActiveAboutToChange()
Added the 'aboutTo', as the event hasn't been caught by the top-level
window yet
2020-11-09 13:46:16 +00:00
Sergio Martins
b93f115b53 Added DockWidget::windowActiveChanged() signal
Tracking the top-level window's 'isActiveWindow' property is difficult
since the dock widget's top-level window is changing all the time
when docking and undocking. So added a convenience signal
2020-11-09 13:35:05 +00:00
Sergio Martins
7faaf2cc69 tests: Port more tests to QtQuick
18 to go before we start fixing them
2020-11-08 15:18:16 +00:00
Sergio Martins
978f9d3a5e tests: Port another test to QtQuick
29 to go
2020-11-06 23:52:48 +00:00
Sergio Martins
09793b3481 tests: Port more tests to QtQuick
31 to go
2020-11-06 23:33:02 +00:00
Sergio Martins
f4d9a96ddb Added Config::Flag_KeepAboveIfNotUtilityWindow
Which sets Qt::WindowStaysOnTopHint for floating windows.
Usually unneeded, as floating windows are Qt::Tool with a transient
parent, but in case you're using Flag_DontUseUtilityFloatingWindows
then you might want (or not) to keep them above.
2020-11-05 12:11:48 +00:00
Sergio Martins
4ac892038f Fix QtQuick build 2020-11-04 11:34:35 +00:00
Colin Ogilvie
387ba291be export FocusScope 2020-11-04 11:32:42 +00:00
Sergio Martins
5d3d189774 tests: Port 1 test to QtQuick 2020-11-03 17:22:50 +00:00
Sergio Martins
a6a1047f75 FocusScope: Also honour widgets embedded in the tab bar
A widget embedded in a tab bar (like a line edit) lives outside
the DockWidget but inside the Frame. It should still focus the
current dockwidget.
2020-11-03 17:12:21 +00:00
Sergio Martins
3e70b846e8 FocusScope: Modify the member variable before emitting signal 2020-11-03 16:19:47 +00:00
Sergio Martins
0a2aebd78d FocusScope: Also focus when the user clicks on tab widget background
Relevant when you don't have a title bar
2020-11-03 15:29:13 +00:00
Sergio Martins
ddad0feaf3 tests: Additional 5 tests build for QtQuick now
37 to go
2020-11-02 20:04:14 +00:00
Sergio Martins
aba1cce1f6 Merge branch '1.1' into master 2020-11-02 11:37:56 +00:00
Sergio Martins
7318675e84 Clarify comment about fractionaly scalling factors
The problem can happen on Windows too.

Fixes issue #94

Nothing more we can do here, it's fixed for Qt 5.15.2.
2020-11-02 11:36:24 +00:00
Sergio Martins
cf700f8eb6 tests: port more tests to QtQuick
43 to go
2020-10-30 18:29:59 +00:00
Sergio Martins
2c1d099c83 Fix include here too 2020-10-30 12:27:50 +00:00
Sergio Martins
91ff29ae64 Fix build when KDDW is embedded within a project 2020-10-30 12:21:25 +00:00
Renato Araujo Oliveira Filho
523dfb0d12 Fix python bindings build 2020-10-30 08:36:15 -03:00
Sergio Martins
b84e0f3605 tests: More tests are now building with QtQuick
56 to go
2020-10-29 18:11:24 +00:00
Sergio Martins
f72e8e6a1c tests: Port 5 more tests 2020-10-28 22:57:28 +00:00
Sergio Martins
c6c1fe79c3 Fix QtQuick build
src/ is no longer in the include path
2020-10-28 22:15:32 +00:00
Sergio Martins
ea382dcc17 cmake: Install DockRegistry_p.h
It's available as private API if anyone wants to use it
2020-10-28 21:55:02 +00:00
Sergio Martins
c142eb8ecd trying to fix the python build
after the include paths changes
2020-10-27 21:40:51 +00:00
Sergio Martins
46c039153e cmake: Don't export src/ to include path
Otherwise applications can't have files named MainWindow.h or
DockWidget.h.

Now all kddockwidgets includes need to be scoped, example:
2020-10-27 17:01:18 +00:00
Sergio Martins
473f03360c tests: Fix Wweak-vtables warnings 2020-10-26 18:59:21 +00:00
Sergio Martins
3fb3984a72 Merge branch '1.1' 2020-10-26 18:23:17 +00:00
Sergio Martins
9c5e3cf5af tests: Port another test to QtQuick 2020-10-26 18:22:01 +00:00
Sergio Martins
7419ca806d tests: Port 2 more tests to QtQuick 2020-10-26 17:32:13 +00:00
Allen Winter
8a51c31663 OBS - update for 1.1.0 release 2020-10-26 12:14:46 -04:00
Sergio Martins
a586a7894b cmake: Qt5::GuiPrivate is only needed on Windows 2020-10-26 16:14:07 +00:00
Sergio Martins
31fcbebaff ChangeLog: Add the date of 1.1 release 2020-10-26 15:29:47 +00:00
Sergio Martins
c4cc6b3e6e tests: Port more tests to QtQuick 2020-10-25 22:39:10 +00:00
Sergio Martins
420ac9044e Merge branch '1.1' into master 2020-10-23 17:11:45 +01:00
Sergio Martins
392dac5691 Use Qt::WA_PendingMoveEvent instead of Qt::WA_Moved
We check if the user provided position before putting a floating
window in a default position. Qt::WA_Moved however has the problem
that it's not cleared, so second time you show a window, it will
have it, even if user didn't set geometry.

Use Qt::WA_PendingMoveEvent instead, which was made for tracking
moves made before the first show.
2020-10-23 17:07:14 +01:00
Sergio Martins
29744c01c6 ChangeLog: Added Config::setTabbingAllowedFunc 2020-10-23 10:33:37 +01:00
Sergio Martins
a16adb9578 Merge branch '1.1' 2020-10-23 10:32:10 +01:00
Sergio Martins
49e488df24 remove roadmap from 1.1 ChangeLog
We only have it for master
2020-10-23 10:29:57 +01:00
Sergio Martins
1a3f00eac8 ChangeLog: Added HDPI improvements 2020-10-23 10:29:00 +01:00
Sérgio Martins
c6ea8d5525 ChangeLog: Remove mention to 1.0.1 release
We're releasing 1.1 asap
2020-10-23 10:23:52 +01:00
Sergio Martins
7738585d01 tests: Enabled another batch of tests for QtQuick
83 of 175 are now building with QtQuick
2020-10-22 20:54:39 +01:00
Sergio Martins
61bc24c6ea tests: A bunch of drag/mouse functions are not compatible with qtquick
In the sense that they build.
2020-10-21 22:43:08 +01:00
Sergio Martins
ae90001d7a tests: Remove some QWidget ifdefs
Works fine for QtQuick too
2020-10-21 21:08:03 +01:00
Sergio Martins
c0ea3a097c tests: Port a test to qtquick 2020-10-21 21:05:03 +01:00
Sergio Martins
abca57be11 qtquick: Fix tst_stealFrame
Now has the same behaviour as with QWidgets
2020-10-20 22:36:45 +01:00
Sergio Martins
645201480c qtquick: Port two tests 2020-10-20 22:05:29 +01:00
Sergio Martins
8cffba3e22 Merge branch '1.1' into master 2020-10-19 21:25:39 +01:00
Sergio Martins
8f62004f5b cmake: Remove QTQUICK option for 1.1
Leave it in master only.
2020-10-19 21:23:44 +01:00
Sergio Martins
4fff6edb7b qtquick: Port another test 2020-10-19 21:03:47 +01:00
Sergio Martins
64cff4ba49 qtquick|tests: use auto instead of QPointer<QWidget> 2020-10-19 21:00:18 +01:00
Sergio Martins
ce3c4d5661 qtquick|tests: pass parent to main window
Those tests pass now
2020-10-19 20:58:00 +01:00
Sergio Martins
5f333f0934 qtquick: port more tests 2020-10-19 20:53:40 +01:00
Sergio Martins
f70722934c qtquick: Port more tests 2020-10-19 20:47:09 +01:00
Sergio Martins
b9eb9f10d4 qtquick: Port more tests 2020-10-19 20:26:09 +01:00
Sergio Martins
6f89d94eef qtquick: Emit Frame::layoutInvalidated() when needed
When min/max size changes it needs to be emitted, so layout
notices
2020-10-19 20:06:29 +01:00
Sergio Martins
3a494d706a qtquick: Implement missing QWidgetAdapter::floatingWindow() 2020-10-19 19:05:10 +01:00
Sergio Martins
2ffbe07bcf Updated README-Wayland.md 2020-10-19 11:46:22 +01:00
Sergio Martins
371fd361a8 Detach when double-click on tab bar background, if no title bar
When a title bar isn't visible, we need a way to detach an entire
group of tabs by double clicking, required for wayland.

Implemented for all platforms, as it makes sense
2020-10-19 11:42:39 +01:00
Sergio Martins
97416607e5 qtquick: Allow to set min-sizes on items 2020-10-18 23:27:10 +01:00
Sergio Martins
51ccbe7c7c Move TabBar::detachTab() to Frame
As the code doesn't have anything specific to QTabBar.
Means QtQuick can reuse it without needing a TabBarQuick.

tst_crash now passes for QtQuick too
2020-10-18 23:07:13 +01:00
Sergio Martins
65599399c7 qtquick: port a bunch of tests 2020-10-18 22:23:51 +01:00
Sergio Martins
c0816d4924 qtquick: Fix tst_negativeAnchorPosition5
min sizes weren't bounded
2020-10-18 21:58:46 +01:00
Sergio Martins
2988e97e14 qtquick: Fix build 2020-10-18 20:29:44 +01:00
Sergio Martins
046ceae500 Remove unneeded null check from DropArea::drop() 2020-10-18 12:31:04 +01:00
Sergio Martins
33c0cda582 Minor readability, just call setWindowBeingDragged(true)
It's always true here.
2020-10-18 12:28:10 +01:00
Sergio Martins
df7acc1075 Added README-Wayland.md to explain some differences
Fixes issue #10
2020-10-17 12:30:57 +01:00
Sergio Martins
3859e4b277 Added Wayland to the README 2020-10-17 12:18:05 +01:00
Sergio Martins
26253b65c7 wayland: Silence warning about qpa not supporting activating
"qt.qpa.wayland: Wayland does not support QWindow::requestActivate()"
2020-10-17 12:13:58 +01:00
Sergio Martins
424453ab57 Double clicking on a tab will make it float
Also really required for Wayland, where we don't another way to
float a single tab, as the float button affects all of them.
2020-10-17 12:09:47 +01:00
Sergio Martins
d7de0ebd20 Updated ChangeLog
- Added wayland for 1.2, it's done. Might need more polishing.
- Removed 1.0.1, let's release 1.1 instead
- Moved QtQuick to 1.3. The december target is still there, but I want
to release 1.2 sooner, since the wayland support is done.
2020-10-17 11:44:45 +01:00
Sergio Martins
bf1c5140cd Wayland: Fix another missing mapToGlobal
Hovering indicators was fine, but dropping was off by a few pixels
vertically due to the menu bar
2020-10-17 11:41:19 +01:00
Sergio Martins
fb7a35db5b Wayland: Fix indicator hover being off
Drag events are in local coords, while DropArea wants it in
global
2020-10-17 11:05:56 +01:00
Sergio Martins
5872c2fbe3 Wayland: Support classical indicators too
The Indicator Window is top-level, but on Wayland that can't do,
as we have no way to position it. So parent it. The indicators
are now under the window being dragged, but that's no so bad, as it's
smi-transparent, so you still see the indicator.
2020-10-17 11:02:49 +01:00
Sergio Martins
ba04c70d5a Minor code re-ordering 2020-10-17 10:30:26 +01:00
Sergio Martins
de1e2d301f wayland: Support affinities too 2020-10-17 10:27:43 +01:00
Sergio Martins
b67bdf779e Don't dereference windowBeingDragged->floatingWindow()
Add a level of indirection instead, and support for the wayland case
2020-10-16 23:06:30 +01:00
Sergio Martins
78a3221395 Merge branch '1.1' into master 2020-10-16 22:05:14 +01:00
Sergio Martins
f698b56dad relax test
Seems to happen with 5.15 static. It's benign anyway
2020-10-16 22:02:45 +01:00
Sergio Martins
4ed18fdf1d Introduce Config::setTabbingAllowedFunc(<lambda>)
This gives a lot of power to the user to disallow tabbing two dock
widgets, while still allowing them to be docked side by side. As
this can't be achieved with affinities.

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

Fixes #91
2020-10-16 21:56:33 +01:00
Sergio Martins
6e05f13c77 Added FloatingWindow::dockWidgets() 2020-10-16 21:48:47 +01:00
Sergio Martins
cb51d0af11 Merge branch '1.1' into master 2020-10-16 20:53:17 +01:00
Sergio Martins
a146cd81b2 Fix mac tests build 2020-10-16 20:52:22 +01:00
Sergio Martins
8dbd6df456 Merge branch '1.1' into master 2020-10-16 20:35:56 +01:00
Sergio Martins
ac6d845c8d Skip tests on macOS+offscreen if Qt <= 5.15.0
There's a bug in Qt qpa only fixed in 5.15.1
2020-10-16 20:35:04 +01:00
Sergio Martins
cfc9d1abcd cmake: Fix indentation 2020-10-16 19:43:50 +01:00
Sergio Martins
a66748f6ca relax test
Seems to happen with 5.15 static. It's benign anyway
2020-10-16 17:10:40 +01:00
Sergio Martins
e5f46ead3b qtquick: Fix build 2020-10-16 17:08:36 +01:00
Sergio Martins
171023558e Introduce WindowBeingDraggedWayland
This is just a cleanup. Instead of having WindowBeingDragged
having both code paths, let's keep the non-wayland platforms code
small and clean.
2020-10-16 17:08:36 +01:00
Allen Winter
059a424b88 Merge branch '1.1' 2020-10-16 08:39:26 -04:00
Sergio Martins
307b22deaf Wayland: Also allow to drag by tab widget
For when we don't have title bar
2020-10-16 13:30:20 +01:00
Sergio Martins
e405688f67 Fixing build with msvc 2013
error C2876: 'QMimeData' : not all overloads are accessible
2020-10-16 13:16:13 +01:00
Sergio Martins
68554119f4 Fix -Werror build on mac 2020-10-16 11:46:02 +01:00
Sergio Martins
86a4a740ef wayland: dropping a single tab or frame now works too 2020-10-16 11:33:09 +01:00
Sergio Martins
0a004b83ca Add WindowBeingDragged::draggable() getter 2020-10-16 11:16:49 +01:00
Sergio Martins
4fa47403c5 Make DragArea::drop() deal in WindowBeingDragged()
Preparing for wayland case.
2020-10-16 10:49:42 +01:00
Sergio Martins
9e418ced53 wayland: Finish WindowBeingDragged::maxSize() and minSize
Supports now single dock widgets or single frames
2020-10-16 10:40:34 +01:00
Sergio Martins
bc04863439 Wayland: Dragging a tab or a nested dock widget now shows pixmap
TODO: Supporting a drop for those two cases
2020-10-16 10:33:01 +01:00
Allen Winter
77f259a435 README.md - contact info 2020-10-15 16:06:26 -04:00
Sergio Martins
16bcace663 Add some transparency to the QDrag pixmap
Looks better
2020-10-15 19:15:40 +01:00
Sergio Martins
52fddaa1cd wayland: Set a pixmap while DND
Since our source window isn't moving, let's at least show a copy
of it on the pixmap

A bunch of tearing going on kwin_wayland/nvidia though.
Weston/nvidia is fine.
Haven't tried kwin_wayland/Intel yet
2020-10-15 19:11:12 +01:00
Sergio Martins
f3d7400c15 wayland: End the drag properly when user cancels the drag 2020-10-15 19:02:46 +01:00
Allen Winter
7ebc3f3533 src/DockWidgetBase.h - fix compile after merge from master 2020-10-15 12:43:29 -04:00
Renato Araujo Oliveira Filho
0ee94b425e Fixed python bindings generation 2020-10-15 12:38:32 -04:00
Sergio Martins
d44a173945 Wayland: Really end the drag after dropping
Fixes a crash on shutdown
2020-10-15 17:27:12 +01:00
Sergio Martins
ac001d6f32 wayland: Don't allow to drop onto itself
It was showing the drop indicators in the window being dragged
2020-10-15 16:50:46 +01:00
Sergio Martins
e3de2df69c wayland: Add initial drag and drop support
You can drag a floating window and drop it somewhere

- Only works with segmented indicator style. Classical indicators
require us being able to positioning an overlay, which wayland
doesn't allow us to.
- Detaching inner tabs and dock widgets not implemented yet.
- polishing needed
2020-10-15 16:50:46 +01:00
Sergio Martins
39d3c90b2f Minor variable rename for readability 2020-10-15 16:50:46 +01:00
Sergio Martins
bca21defa5 wayland: Don't grab mouse or set window opacity
Not supported by the QPA and not needed for wayland anyway
2020-10-15 16:50:46 +01:00
Sergio Martins
dd3116ae7f Minor: remove const, need to pass it somewhere else 2020-10-15 16:50:46 +01:00
Allen Winter
49b3765eae Merge branch '1.1' 2020-10-15 10:53:41 -04:00
Allen Winter
1f5dd35bec Merge pull request #93 from KDAB/fix-python-binding
Fixed python bindings generation
2020-10-15 10:52:44 -04:00
Allen Winter
e57b46979d buildsystem - fix installation path for Python bindings 2020-10-14 16:27:18 -04:00
Allen Winter
683b67abb0 buildsystem - install libs with symlinks for the major vers 2020-10-14 15:59:53 -04:00
272 changed files with 13685 additions and 8481 deletions

1
.gitignore vendored
View File

@@ -34,7 +34,6 @@ latex
html
custom_titlebar
libkddockwidgets.so*
libkddockwidgets_multisplitter.so*
*.depends
kddockwidgets_basic_quick
/src/KDDockWidgetsConfig.cmake

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
@@ -11,12 +11,17 @@
# Pass the following variables to cmake to control the build:
#
# -DKDDockWidgets_QT6=[true|false]
# Build against Qt6 rather than Qt5
# Default=false (Qt5 will be used even if Qt6 is available)
#
# -DKDDockWidgets_STATIC=[true|false]
# Build static versions of the libraries
# Default=false
#
# -DKDDockWidgets_TESTS=[true|false]
# Build the test harness.
# Currently does nothing unless you also set KDDockWidgets_DEVELOPER_MODE=True
# Default=false
#
# -DKDDockWidgets_EXAMPLES=[true|false]
@@ -42,9 +47,13 @@
# Default=false
#
# -DKDDockWidgets_PYTHON_BINDINGS_INSTALL_PREFIX=[path]
# alternative install path for python bindings
# Set an alternative install path for Python bindings
# Default=CMAKE_INSTALL_PREFIX
#
# -DKDDockWidgets_UNITY_BUILD=[true|false]
# Build with CMake's UNITY_BUILD (requires CMake version 3.16 or higher)
# Default=true
#
cmake_minimum_required(VERSION 3.7)
if(POLICY CMP0020)
@@ -72,33 +81,51 @@ else()
endif()
set(${PROJECT_NAME}_VERSION_MAJOR 1)
set(${PROJECT_NAME}_VERSION_MINOR 1)
set(${PROJECT_NAME}_VERSION_PATCH 95)
set(${PROJECT_NAME}_VERSION_MINOR 2)
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)
option(${PROJECT_NAME}_QT6 "Build against Qt 6" OFF)
option(${PROJECT_NAME}_DEVELOPER_MODE "Developer Mode" OFF)
option(${PROJECT_NAME}_PYTHON_BINDINGS "Build python bindings" OFF)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
option(${PROJECT_NAME}_UNITY_BUILD "Build with CMake's UNITY_BUILD" ON)
endif()
if(${PROJECT_NAME}_PYTHON_BINDINGS AND (CMAKE_BUILD_TYPE MATCHES "^[Dd]eb" OR ${PROJECT_NAME}_STATIC))
message(FATAL_ERROR "** Python Bindings are disabled in debug or static builds.")
endif()
option(${PROJECT_NAME}_TESTS "Build the tests" OFF)
option(${PROJECT_NAME}_EXAMPLES "Build the examples" ON)
option(${PROJECT_NAME}_DOCS "Build the API documentation" OFF)
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)
if (${PROJECT_NAME}_QT6)
find_package(Qt6Widgets REQUIRED)
find_package(Qt6Test REQUIRED)
set(QT_MAJOR_VERSION 6)
else()
find_package(Qt5Widgets 5.9 REQUIRED)
find_package(Qt5Test 5.9 REQUIRED)
set(QT_MAJOR_VERSION 5)
endif()
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(ECM_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ECM/modules/")
set(PYTHON_MODULE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake/Python")
@@ -111,19 +138,27 @@ include(QtInstallPaths) #to set QT_INSTALL_FOO variables
macro(set_compiler_flags targetName)
if(${PROJECT_NAME}_DEVELOPER_MODE)
target_compile_definitions(${targetName} PRIVATE DOCKS_DEVELOPER_MODE QT_FORCE_ASSERTS)
target_compile_definitions(${targetName} PUBLIC DOCKS_DEVELOPER_MODE PRIVATE QT_FORCE_ASSERTS)
if(NOT MSVC)
target_compile_options(${targetName} PRIVATE -Wall -Wextra -Werror -Wno-error=deprecated-declarations)
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)
@@ -163,7 +198,6 @@ endif()
if(${PROJECT_NAME}_EXAMPLES)
if (${PROJECT_NAME}_QTQUICK)
add_subdirectory(examples/qtquick)
set_compiler_flags(kddockwidgets_example_quick)
else()
add_subdirectory(examples/dockwidgets)
add_subdirectory(examples/minimal)
@@ -178,10 +212,9 @@ if(${PROJECT_NAME}_DEVELOPER_MODE)
enable_testing()
add_subdirectory(tests)
if (NOT ${PROJECT_NAME}_QTQUICK)
# Require Qt5.15.1 or higher to run the tests_launcher tests on Mac
if (NOT APPLE OR Qt5Widgets_VERSION VERSION_GREATER 5.15.0)
# tst_docks.exe is pretty big (140 tests), so split it in 6 runs so we can use threads.
# tst_docks.exe is pretty big (160 tests), so split it in more runs so we can use threads.
add_test(NAME tst_docks0 COMMAND tests_launcher 0 5)
add_test(NAME tst_docks1 COMMAND tests_launcher 1 5)
add_test(NAME tst_docks2 COMMAND tests_launcher 2 5)
@@ -205,10 +238,10 @@ if(${PROJECT_NAME}_DEVELOPER_MODE)
add_test(NAME tst_docks20 COMMAND tests_launcher 19 5)
add_test(NAME tst_docks21 COMMAND tests_launcher 20 5) # one more for rounding leftovers
endif()
endif()
if (NOT ${PROJECT_NAME}_QTQUICK)
# tst_multisplitter depends on QWidget
add_test(NAME tst_multisplitter COMMAND tst_multisplitter)
add_test(NAME tst_common COMMAND tst_common)
endif()
endif()
endif()
@@ -216,3 +249,7 @@ endif()
if(${PROJECT_NAME}_DOCS)
add_subdirectory(docs) # needs to go last, in case there are build source files
endif()
if (${PROJECT_NAME}_UNITY_BUILD)
set_target_properties(kddockwidgets PROPERTIES UNITY_BUILD ON)
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,7 +1,33 @@
* v1.2.0 (unreleased)
- QtQuick support
* 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.1.0 (unreleased)
* 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
- Added Flag_KeepAboveIfNotUtilityWindow, so you can have keep above even if
floating window is shown in the task-bar.
- Added DockWidget::windowActiveAboutToChange() signal
- Added support for Qt6 (PySide6 support is lacking)
- Added WASM support
* v1.1.1 (11 December 2020)
- Windows: Fixed a crash when clicking on the close button for floating windows in some situations (#110)
- Don't show dock/undock icon when dockwidget is not dockable (#99)
* v1.1.0 (26 October 2020)
- New drop indicator style type: Segmented Indicators
- Windows: Drop Shadow for floating windows
- Added AutoHide / SideBar support
@@ -12,6 +38,8 @@
- Added Config::Flag_TitleBarHasMinimizeButton
- Added Config::Flag_TitleBarNoFloatButton
- Added Config::Flag_AutoHideSupport
- Added Config::setTabbingAllowedFunc(TabbingAllowedFunc func)
- HDPI improvements, new high-res icons
- Bugfixes:
- Windows: Fixed windows not having proper minimum size.
- Windows: Fixed moving windows across screens with different DPI (#72)
@@ -19,8 +47,6 @@
- Fixed floating window's title not being correct (#74)
- Fixed focus scope not reacting when clicking on current tab (#71)
- Fixed floating window borders not being rendered correctly on HDPI due to rounding errors.
* v1.0.1 (unreleased)
- cmake/Python - don't require pkg-config, only use if available (#68)
* v1.0.0 (2 September 2020)

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

33
README-WASM.md Normal file
View File

@@ -0,0 +1,33 @@
WebAssembly
===========
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.
- 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:
====================
- Visit https://doc.qt.io/qt-5/wasm.html if you haven't yet
- Open a terminal suitable for WASM development (with the correct Qt and toolchain in PATH, etc)
- KDDockWidgets can be built with `cmake -DCMAKE_TOOLCHAIN_FILE=/usr/local/emsdk-1.39.8/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_FIND_ROOT_PATH=~/Qt/5.15.1/wasm_32/ -DKDDockWidgets_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release`
(Adapt the paths to your own situation)
Builds tips for your own app:
=============================
- Link to KDDW (libkddockwidgets.a, or similar)
- As the build is static, don't forget to initialize KDDW's resources:
```
#ifdef QT_STATIC
Q_INIT_RESOURCE(kddockwidgets_resources);
#endif
```

34
README-Wayland.md Normal file
View File

@@ -0,0 +1,34 @@
Wayland support is done and has been tested on KDE (Kwin) and weston.
Limitations
============
Wayland works very differently than traditional desktops and imposes us some,
limitations. Here's a list of different behaviours which KDDockWidgets will have
when running on Wayland:
- A title bar can either be used for drag&dock or for moving the window around.
- For this reason, floating windows now have two title bars.
The native one, drawn by the server and the client one, drawn by KDDockWidgets.
The native one allows you to drag the window around but not drop/dock.
The client title bar allows you to perform a drag and drop/dock but not move the window around.
- You can detach a window by:
- Clicking the title-bar's float button
- Double-clicking the title bar of a docked widget
- Double-clicking a tab
- If no title bar is shown, double-clicking the empty space of the tab bar will detach
the entire group of tabbed dock widgets
- Layout save/restore won't restore the position of floating windows, as wayland
doesn't allow us to set geometry.
- Kwin specific:
- The pixmap that's shown during a drag can't be bigger than 250x250. Might be a bug.
All in all it's pretty decent and usable. Any further improvements should be done at the server or
protocol level now.

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
@@ -43,6 +46,8 @@ Features
- Customize title bars
- Customize window frames
- Custom widget separators
- Crossplatform (macOS, Linux, Windows, WebAssembly, Wayland, X11/XCB, EGLFS are working)
See README-Wayland.md and README-WASM.md for platform specific information.
- Layouting engine honouring min/max size constraints and some size policies
- PySide2 bindings
- Clean codebase
@@ -59,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")
@@ -98,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
```
For more info visit https://doc.qt.io/qtforpython/shiboken2/gettingstarted.html
@@ -132,14 +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 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.
@@ -170,3 +197,9 @@ to the Qt Project. We can give advanced or standard trainings anywhere
around the globe on Qt as well as C++, OpenGL, 3D and more.
Please visit https://www.kdab.com to meet the people who write code like this.
Stay up-to-date with KDAB product announcements:
* [KDAB Newsletter](https://news.kdab.com)
* [KDAB Blogs](https://www.kdab.com/category/blogs)
* [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
@@ -11,7 +11,7 @@ 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}")
message(STATUS "PYTHON INSTALL PREFIX ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}")
if (WIN32)
set(PATH_SEP "\;")
@@ -153,5 +153,5 @@ macro(CREATE_PYTHON_BINDINGS
LINK_FLAGS "-undefined dynamic_lookup")
endif()
install(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION ${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}/${TARGET_NAME})
LIBRARY DESTINATION ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}/${TARGET_NAME})
endmacro()

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
@@ -30,12 +30,12 @@
#
# Create variables for all the various install paths for the Qt version in use
# Make sure to have found Qt5 before using this.
# Make sure to have found Qt before using this.
# sets variables like QT_INSTALL_PREFIX, QT_INSTALL_DATA, QT_INSTALL_DOCS, etc.
# run qmake -query to see a full list
if(TARGET Qt5::qmake)
get_target_property(QT_QMAKE_EXECUTABLE Qt5::qmake LOCATION)
if(TARGET Qt${QT_MAJOR_VERSION}::qmake)
get_target_property(QT_QMAKE_EXECUTABLE Qt${QT_MAJOR_VERSION}::qmake LOCATION)
else()
message(FATAL_ERROR "No supported Qt version found. Make sure you find Qt before calling this")
endif()

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.
@@ -11,7 +11,7 @@ from conans import ConanFile, CMake, tools
class KDDockWidgetsConan(ConanFile):
name = "kddockwidgets"
version = "1.1.95"
version = "1.2.0"
default_user = "kdab"
default_channel = "stable"
license = ("https://raw.githubusercontent.com/KDAB/KDDockWidgets/master/LICENSES/GPL-2.0-only.txt",

View File

@@ -1,3 +1,21 @@
kddockwidgets (1.2.0) release candidate; urgency=high
* 1.2.0 final
-- Allen Winter <allen.winter@kdab.com> Thu, 17 Dec 2020 12:00:00 -0500
kddockwidgets (1.1.1) release candidate; urgency=high
* 1.1.1 final
-- Allen Winter <allen.winter@kdab.com> Fri, 11 Dec 2020 12:00:00 -0500
kddockwidgets (1.1.0) release candidate; urgency=high
* 1.1.0 final
-- Allen Winter <allen.winter@kdab.com> Mon, 26 Oct 2020 12:00:00 -0500
kddockwidgets (1.0.0) release candidate; urgency=high
* 1.0.0 final

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
@@ -31,7 +31,7 @@ add_custom_command(
OUTPUT ${DOXYGEN_OUTPUT_DIR}/qch/kddockwidgets-api.qch
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
#handle a bug in doxygen where image files referred to in markdown are not copied the output
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/screencap.gif ${DOXYGEN_OUTPUT_DIR}/html
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../../screencap.gif ${DOXYGEN_OUTPUT_DIR}/html
DEPENDS ${_dox_deps} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)

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
@@ -13,6 +13,7 @@ cmake_minimum_required(VERSION 3.7)
project(kddockwidgets_example)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
if(NOT TARGET kddockwidgets)
@@ -21,7 +22,7 @@ if(NOT TARGET kddockwidgets)
find_package(KDDockWidgets REQUIRED)
endif()
qt5_add_resources(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources_example.qrc)
set(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources_example.qrc)
add_executable(kddockwidgets_example
main.cpp

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
@@ -24,10 +24,12 @@
#include <QRandomGenerator>
#endif
#include <QApplication>
#include <stdlib.h>
#include <time.h>
// clazy:excludeall=qstring-allocations
// clazy:excludeall=qstring-allocations,ctor-missing-parent-argument,detaching-member
static MyWidget *newMyWidget()
{
@@ -50,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));
@@ -133,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);
}
@@ -162,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
@@ -26,8 +26,10 @@ using namespace KDDockWidgets;
int main(int argc, char **argv)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
QApplication app(argc, argv);
app.setOrganizationName(QStringLiteral("KDAB"));
@@ -91,6 +93,9 @@ int main(int argc, char **argv)
QCommandLineOption noUtilityWindows("u", QCoreApplication::translate("main", "FloatingWindows will be normal windows instead of utility windows"));
parser.addOption(noUtilityWindows);
QCommandLineOption keepAbove("o", QCoreApplication::translate("main", "FloatingWindows will have Qt::WindowStaysOnTopHint. Implies not being an utility window (try it with -u too)"));
parser.addOption(keepAbove);
parser.addPositionalArgument("savedlayout", QCoreApplication::translate("main", "loads the specified json file at startup"));
#ifdef KDDOCKWIDGETS_SUPPORTS_NESTED_MAINWINDOWS
@@ -106,13 +111,26 @@ 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);
QCommandLineOption noQtTool("no-qttool", QCoreApplication::translate("main", "(internal) Don't use Qt::Tool"));
QCommandLineOption noParentForFloating("no-parent-for-floating", QCoreApplication::translate("main", "(internal) FloatingWindows won't have a parent"));
QCommandLineOption nativeTitleBar("native-title-bar", QCoreApplication::translate("main", "(internal) FloatingWindows a native title bar"));
QCommandLineOption noDropIndicators("no-drop-indicators", QCoreApplication::translate("main", "(internal) Don't use any drop indicators"));
parser.addOption(noQtTool);
parser.addOption(noParentForFloating);
parser.addOption(nativeTitleBar);
parser.addOption(noDropIndicators);
# if defined(Q_OS_WIN)
QCommandLineOption noAeroSnap("no-aero-snap", QCoreApplication::translate("main", "(internal) Disable AeroSnap"));
@@ -137,25 +155,39 @@ 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;
if (parser.isSet(noDropIndicators))
KDDockWidgets::DefaultWidgetFactory::s_dropIndicatorType = KDDockWidgets::DropIndicatorType::None;
# if defined(Q_OS_WIN)
if (parser.isSet(noAeroSnap))
flags &= ~KDDockWidgets::Config::Flag_AeroSnapWithClientDecos;
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;
@@ -206,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
@@ -215,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();
@@ -233,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
@@ -246,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
@@ -13,6 +13,7 @@ cmake_minimum_required(VERSION 3.7)
project(kddockwidgets_minimal_example)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
if(NOT TARGET kddockwidgets)
@@ -21,7 +22,7 @@ if(NOT TARGET kddockwidgets)
find_package(KDDockWidgets REQUIRED)
endif()
qt5_add_resources(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../dockwidgets/resources_example.qrc)
set(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../dockwidgets/resources_example.qrc)
add_executable(kddockwidgets_minimal_example
main.cpp

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
@@ -15,6 +15,7 @@
#include <kddockwidgets/MainWindow.h>
#include <QStyleFactory>
#include <QApplication>
// clazy:excludeall=qstring-allocations
@@ -22,8 +23,10 @@ using namespace KDDockWidgets;
int main(int argc, char **argv)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
QApplication app(argc, argv);
app.setOrganizationName(QStringLiteral("KDAB"));
@@ -59,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);
@@ -67,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,7 +1,6 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2019-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
@@ -9,26 +8,8 @@
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.7)
project(kddockwidgets_example_quick)
add_subdirectory(customtitlebar)
add_subdirectory(dockwidgets)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
if(NOT TARGET kddockwidgets)
# This will look for Qt, do find_package yourself manually before
# if you want to look for a specific Qt version for instance.
find_package(KDDockWidgets REQUIRED)
endif()
qt5_add_resources(RESOURCES_EXAMPLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources_example.qrc)
add_executable(kddockwidgets_example_quick
main.cpp
${RESOURCES_EXAMPLE_SRC}
)
target_link_libraries(kddockwidgets_example_quick
PRIVATE
KDAB::kddockwidgets
)
set_compiler_flags(kddockwidgets_example_quick)
set_compiler_flags(kddockwidgets_customtitlebar_quick)

View File

@@ -0,0 +1,37 @@
#
# This file is part of KDDockWidgets.
#
# 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
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.7)
project(kddockwidgets_customtitlebar_quick)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
if(NOT TARGET kddockwidgets)
# This will look for Qt, do find_package yourself manually before
# if you want to look for a specific Qt version for instance.
find_package(KDDockWidgets REQUIRED)
endif()
set(RESOURCES_EXAMPLE_SRC
${CMAKE_CURRENT_SOURCE_DIR}/resources_qtquick_example.qrc
${CMAKE_CURRENT_SOURCE_DIR}/../../dockwidgets/resources_example.qrc)
add_executable(kddockwidgets_customtitlebar_quick
main.cpp
${RESOURCES_EXAMPLE_SRC}
)
target_link_libraries(kddockwidgets_customtitlebar_quick
PRIVATE
KDAB::kddockwidgets
)

View File

@@ -0,0 +1,36 @@
/*
This file is part of KDDockWidgets.
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
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Item {
anchors.fill: parent
property alias background: background.source
property alias logo: logo.source
Image {
id: background
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
Image {
id: logo
fillMode: Image.PreserveAspectFit
anchors {
fill: parent
margins: 50
}
}
}
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
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
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/triangles.png"
logo: "qrc:/assets/KDAB_bubble_white.png"
}

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
@@ -11,10 +11,7 @@
import QtQuick 2.9
Rectangle {
color: "pink"
Guest {
anchors.fill: parent
Text {
text: "Guest Widget #2!"
}
logo: "qrc:/assets/KDAB_bubble_blue.png"
}

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
@@ -11,10 +11,8 @@
import QtQuick 2.9
Rectangle {
color: "lightblue"
Guest {
anchors.fill: parent
Text {
text: "Guest Widget #1 !"
}
background: "qrc:/assets/base.png"
logo: "qrc:/assets/KDAB_bubble_fulcolor.png"
}

View File

@@ -0,0 +1,54 @@
/*
This file is part of KDDockWidgets.
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
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
// Will be moved to a plugin in the future
import "qrc:/kddockwidgets/private/quick/qml/" as KDDW
KDDW.TitleBarBase {
id: root
color: "black"
border.color: "orange"
border.width: 2
heightWhenVisible: 50
Text {
color: "orange"
font.bold: true
text: root.title
anchors {
left: parent.left
leftMargin: 10
verticalCenter: root.verticalCenter
}
}
Rectangle {
id: closeButton
enabled: root.closeButtonEnabled
radius: 5
color: "green"
height: root.height - 20
width: height
anchors {
right: root.right
rightMargin: 10
verticalCenter: root.verticalCenter
}
MouseArea {
anchors.fill: parent
onClicked: {
root.closeButtonClicked();
}
}
}
}

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
@@ -10,17 +10,41 @@
*/
#include "private/DockRegistry_p.h"
#include "private/quick/DockWidgetQuick.h"
#include "Config.h"
#include <kddockwidgets/Config.h>
#include <kddockwidgets/DockWidgetQuick.h>
#include <kddockwidgets/private/DockRegistry_p.h>
#include <kddockwidgets/FrameworkWidgetFactory.h>
#include <QQuickView>
#include <QGuiApplication>
class CustomFrameworkWidgetFactory : public KDDockWidgets::DefaultWidgetFactory
{
public:
~CustomFrameworkWidgetFactory() override;
QUrl titleBarFilename() const override
{
return QUrl("qrc:/MyTitleBar.qml");
}
};
CustomFrameworkWidgetFactory::~CustomFrameworkWidgetFactory() = default;
int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
QGuiApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
QGuiApplication app(argc, argv);
auto &config = KDDockWidgets::Config::self();
auto flags = config.flags();
config.setFlags(flags);
config.setFrameworkWidgetFactory(new CustomFrameworkWidgetFactory());
QQuickView view;
view.setObjectName("MainWindow QQuickView");
KDDockWidgets::Config::self().setQmlEngine(view.engine());
@@ -42,13 +66,10 @@ int main(int argc, char *argv[])
auto dw3 = new KDDockWidgets::DockWidgetQuick("Dock #3");
dw3->setWidget(QStringLiteral("qrc:/Guest3.qml"));
dw3->resize(QSize(800, 800));
dw3->show();
dw1->addDockWidgetToContainingWindow(dw3, KDDockWidgets::Location_OnRight);
KDDockWidgets::MainWindowBase *mainWindow = KDDockWidgets::DockRegistry::self()->mainwindows().constFirst();
mainWindow->addDockWidget(dw2, KDDockWidgets::Location_OnTop);
return app.exec();
}

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

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

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
@@ -12,9 +12,7 @@
import QtQuick 2.9
Rectangle {
color: "blue"
id: root
color: "green"
anchors.fill: parent
Text {
text: "Guest Widget!"
}
}

View File

@@ -0,0 +1,37 @@
#
# This file is part of KDDockWidgets.
#
# 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
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.7)
project(kddockwidgets_example_quick)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIRS ON)
if(NOT TARGET kddockwidgets)
# This will look for Qt, do find_package yourself manually before
# if you want to look for a specific Qt version for instance.
find_package(KDDockWidgets REQUIRED)
endif()
set(RESOURCES_EXAMPLE_SRC
${CMAKE_CURRENT_SOURCE_DIR}/resources_qtquick_example.qrc
${CMAKE_CURRENT_SOURCE_DIR}/../../dockwidgets/resources_example.qrc)
add_executable(kddockwidgets_example_quick
main.cpp
${RESOURCES_EXAMPLE_SRC}
)
target_link_libraries(kddockwidgets_example_quick
PRIVATE
KDAB::kddockwidgets
)

View File

@@ -0,0 +1,36 @@
/*
This file is part of KDDockWidgets.
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
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Item {
anchors.fill: parent
property alias background: background.source
property alias logo: logo.source
Image {
id: background
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
Image {
id: logo
fillMode: Image.PreserveAspectFit
anchors {
fill: parent
margins: 50
}
}
}
}

View File

@@ -0,0 +1,47 @@
/*
This file is part of KDDockWidgets.
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
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
import QtQuick.Controls 2.12
import com.kdab.dockwidgets 1.0 as KDDW
Guest {
anchors.fill: parent
background: "qrc:/assets/triangles.png"
logo: "qrc:/assets/KDAB_bubble_white.png"
KDDW.DockWidget {
id: another
uniqueName: "another1"
source: ":/Another.qml"
}
Button {
text: "Toggle Another"
anchors {
bottom: parent.bottom
left: parent.left
margins: 5
}
onClicked: {
if (another.dockWidget.visible) {
another.dockWidget.close();
} else {
another.dockWidget.show();
}
}
}
}

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
@@ -11,10 +11,7 @@
import QtQuick 2.9
Rectangle {
color: "gray"
Guest {
anchors.fill: parent
Text {
text: "Guest Widget #3!"
}
logo: "qrc:/assets/KDAB_bubble_blue.png"
}

View File

@@ -0,0 +1,18 @@
/*
This file is part of KDDockWidgets.
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
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.9
Guest {
anchors.fill: parent
background: "qrc:/assets/base.png"
logo: "qrc:/assets/KDAB_bubble_fulcolor.png"
}

View File

@@ -0,0 +1,105 @@
/*
This file is part of KDDockWidgets.
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
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include <kddockwidgets/Config.h>
#include <kddockwidgets/DockWidgetQuick.h>
#include <kddockwidgets/private/DockRegistry_p.h>
#include <kddockwidgets/FrameworkWidgetFactory.h>
#include <QQuickView>
#include <QGuiApplication>
#include <QCommandLineParser>
int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
QGuiApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
QGuiApplication app(argc, argv);
QCommandLineParser parser;
parser.setApplicationDescription("KDDockWidgets example application");
parser.addHelpOption();
#if defined(DOCKS_DEVELOPER_MODE)
QCommandLineOption noQtTool("no-qttool", QCoreApplication::translate("main", "(internal) Don't use Qt::Tool"));
QCommandLineOption noParentForFloating("no-parent-for-floating", QCoreApplication::translate("main", "(internal) FloatingWindows won't have a parent"));
QCommandLineOption nativeTitleBar("native-title-bar", QCoreApplication::translate("main", "(internal) FloatingWindows a native title bar"));
QCommandLineOption noDropIndicators("no-drop-indicators", QCoreApplication::translate("main", "(internal) Don't use any drop indicators"));
parser.addOption(noQtTool);
parser.addOption(noParentForFloating);
parser.addOption(nativeTitleBar);
parser.addOption(noDropIndicators);
# if defined(Q_OS_WIN)
QCommandLineOption noAeroSnap("no-aero-snap", QCoreApplication::translate("main", "(internal) Disable AeroSnap"));
parser.addOption(noAeroSnap);
# endif
#endif
auto flags = KDDockWidgets::Config::self().flags();
#if defined(DOCKS_DEVELOPER_MODE)
auto internalFlags = KDDockWidgets::Config::self().internalFlags();
parser.process(app);
if (parser.isSet(noQtTool))
internalFlags |= KDDockWidgets::Config::InternalFlag_DontUseQtToolWindowsForFloatingWindows;
if (parser.isSet(noParentForFloating))
internalFlags |= KDDockWidgets::Config::InternalFlag_DontUseParentForFloatingWindows;
if (parser.isSet(nativeTitleBar))
flags |= KDDockWidgets::Config::Flag_NativeTitleBar;
else if (parser.isSet(noDropIndicators))
KDDockWidgets::DefaultWidgetFactory::s_dropIndicatorType = KDDockWidgets::DropIndicatorType::None;
# if defined(Q_OS_WIN)
if (parser.isSet(noAeroSnap))
internalFlags |= KDDockWidgets::Config::InternalFlag_NoAeroSnap;
# endif
KDDockWidgets::Config::self().setInternalFlags(internalFlags);
#endif
KDDockWidgets::Config::self().setFlags(flags);
QQuickView view;
view.setObjectName("MainWindow QQuickView");
KDDockWidgets::Config::self().setQmlEngine(view.engine());
view.resize(1000, 800);
view.show();
view.setResizeMode(QQuickView::SizeRootObjectToView);
auto dw1 = new KDDockWidgets::DockWidgetQuick("Dock #1");
view.setSource(QUrl("qrc:/main.qml"));
dw1->setWidget(QStringLiteral("qrc:/Guest1.qml"));
dw1->resize(QSize(800, 800));
dw1->show();
auto dw2 = new KDDockWidgets::DockWidgetQuick("Dock #2");
dw2->setWidget(QStringLiteral("qrc:/Guest2.qml"));
dw2->resize(QSize(800, 800));
dw2->show();
auto dw3 = new KDDockWidgets::DockWidgetQuick("Dock #3");
dw3->setWidget(QStringLiteral("qrc:/Guest3.qml"));
dw1->addDockWidgetToContainingWindow(dw3, KDDockWidgets::Location_OnRight);
KDDockWidgets::MainWindowBase *mainWindow = KDDockWidgets::DockRegistry::self()->mainwindows().constFirst();
mainWindow->addDockWidget(dw2, KDDockWidgets::Location_OnTop);
return app.exec();
}

View File

@@ -0,0 +1,23 @@
/*
This file is part of KDDockWidgets.
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
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
import QtQuick 2.6
import com.kdab.dockwidgets 1.0 as KDDW
KDDW.MainWindow {
id: root
Component.onCompleted: {
root.init("MyWindowName-1");
}
}

View File

@@ -4,5 +4,7 @@
<file>Guest1.qml</file>
<file>Guest2.qml</file>
<file>Guest3.qml</file>
<file>Guest.qml</file>
<file>Another.qml</file>
</qresource>
</RCC>

1
kddockwidgets-rpmlintrc Normal file
View File

@@ -0,0 +1 @@
addFilter("E: shlib-policy-name-error")

View File

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

View File

@@ -1,9 +1,10 @@
Name: kddockwidgets
Version: 1.0.0
Version: 1.2.0
Release: 1
Summary: KDAB's Dock Widget Framework for Qt
Source0: %{name}-%{version}.tar.gz
Source1: %{name}-%{version}.tar.gz.asc
Source2: %{name}-rpmlintrc
URL: https://github.com/KDAB/KDDockWidgets
Group: System/Libraries
License: GPL-2.0-only OR GPL-3.0-only
@@ -75,7 +76,6 @@ cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release
%defattr(-,root,root)
%{_prefix}/share/doc/KDDockWidgets
%{_libdir}/libkddockwidgets.so.*
%{_libdir}/libkddockwidgets_multisplitter.so.*
%files devel
%defattr(-,root,root,-)
@@ -85,10 +85,15 @@ cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release
%dir %{_libdir}/cmake/KDDockWidgets
%{_libdir}/cmake/KDDockWidgets/*
%{_libdir}/libkddockwidgets.so
%{_libdir}/libkddockwidgets_multisplitter.so
%changelog
* Wed Sep 02 2020 Allen Winter <allen.winter@kdb.com> 1.0.0
* Thu Dec 17 2020 Allen Winter <allen.winter@kdab.com> 1.2.0
1.2.0 final
* Fri Dec 11 2020 Allen Winter <allen.winter@kdab.com> 1.1.1
1.1.1 final
* Mon Oct 26 2020 Allen Winter <allen.winter@kdab.com> 1.1.0
1.1.0 final
* Wed Sep 02 2020 Allen Winter <allen.winter@kdab.com> 1.0.0
1.0.0 final
* Thu Aug 06 2020 Allen Winter <allen.winter@kdb.com> 0.99.9
* Thu Aug 06 2020 Allen Winter <allen.winter@kdab.com> 0.99.9
1.0.0 release candidate

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)
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
@@ -41,15 +38,15 @@ set(PyKDDockWidgets_typesystem_paths
# Include flags/path that will be set in 'target_include_directories'
set(PyKDDockWidgets_target_include_directories
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src
)
# 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
@@ -74,8 +71,8 @@ create_python_bindings(
${CMAKE_CURRENT_BINARY_DIR}
)
# Make moduled import from build dir works
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${CMAKE_CURRENT_BINARY_DIR}/__init__.py)
# Make module import from build dir work
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
@@ -17,8 +17,11 @@
// Define PYTHON_BINDINGS this will be used in some part of c++ to skip problematic parts
#define PYTHON_BINDINGS
#include <MainWindowBase.h>
#include <MainWindow.h>
#include <DockWidgetBase.h>
#include <DockWidget.h>
#ifndef QT_WIDGETS_LIB
# define QT_WIDGETS_LIB
#endif
#include <kddockwidgets/MainWindowBase.h>
#include <kddockwidgets/MainWindow.h>
#include <kddockwidgets/DockWidgetBase.h>
#include <kddockwidgets/DockWidget.h>

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,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,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
@@ -23,30 +23,68 @@ add_definitions(-DQT_NO_SIGNALS_SLOTS_KEYWORDS
set(DOCKSLIBS_SRCS
Config.cpp
Config.h
Qt5Qt6Compat_p.h
FocusScope.cpp
FocusScope.h
FrameworkWidgetFactory.cpp
FrameworkWidgetFactory.h
DockWidgetBase.cpp
DockWidgetBase.h
MainWindowBase.cpp
MainWindowBase.h
LayoutSaver.cpp
LayoutSaver.h
LayoutSaver_p.h
private/MultiSplitter.cpp
private/MultiSplitter_p.h
private/Position.cpp
private/ObjectViewer.cpp
private/Position_p.h
private/DropIndicatorOverlayInterface.cpp
private/DropIndicatorOverlayInterface_p.h
private/DropArea.cpp
private/DropArea_p.h
private/FloatingWindow.cpp
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
private/SideBar_p.h
private/DockRegistry.cpp
private/DockRegistry_p.h
private/Draggable.cpp
private/Draggable_p.h
private/WindowBeingDragged.cpp
private/WindowBeingDragged_p.h
private/DragController.cpp
private/DragController_p.h
private/Frame.cpp
private/Frame_p.h
private/DropAreaWithCentralFrame.cpp
private/DropAreaWithCentralFrame_p.h
private/WidgetResizeHandler.cpp
private/WidgetResizeHandler_p.h
private/indicators/NullIndicators.cpp
private/indicators/NullIndicators_p.h
private/indicators/ClassicIndicators.cpp
private/indicators/ClassicIndicators_p.h
private/indicators/ClassicIndicatorsWindow.cpp
private/indicators/ClassicIndicatorsWindow_p.h
private/multisplitter/Item.cpp
private/multisplitter/Item_p.h
private/multisplitter/Logging.cpp
private/multisplitter/Logging_p.h
private/multisplitter/MultiSplitterConfig.cpp
private/multisplitter/MultiSplitterConfig.h
private/multisplitter/Separator.cpp
private/multisplitter/Separator_p.h
private/multisplitter/Widget.cpp
private/multisplitter/Widget.h
)
set(DOCKS_INSTALLABLE_INCLUDES
@@ -55,6 +93,7 @@ set(DOCKS_INSTALLABLE_INCLUDES
FrameworkWidgetFactory.h
DockWidgetBase.h
KDDockWidgets.h
Qt5Qt6Compat_p.h
FocusScope.h
QWidgetAdapter.h
LayoutSaver.h
@@ -70,6 +109,8 @@ set(DOCKS_INSTALLABLE_PRIVATE_INCLUDES
private/SideBar_p.h
private/TitleBar_p.h
private/WindowBeingDragged_p.h
private/DockRegistry_p.h
private/TabWidget_p.h
)
set(DOCKS_INSTALLABLE_PRIVATE_WIDGET_INCLUDES
@@ -80,36 +121,71 @@ 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)
set(DOCKSLIBS_SRCS ${DOCKSLIBS_SRCS}
private/quick/DockWidgetQuick.cpp
DockWidgetQuick.cpp
DockWidgetQuick.h
private/quick/DockWidgetInstantiator.cpp
private/quick/DockWidgetInstantiator_p.h
private/quick/QWidgetAdapter_quick.cpp
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
private/quick/QmlTypes.h
private/quick/FrameQuick.cpp
private/quick/FrameQuick_p.h
private/quick/RubberBandQuick.cpp
private/quick/RubberBandQuick.h
private/quick/MainWindowQuick.cpp
private/quick/MainWindowQuick_p.h
private/quick/MainWindowWrapper.cpp
)
qt5_add_resources(RESOURCES_QUICK ${CMAKE_CURRENT_SOURCE_DIR}/qtquick.qrc)
private/quick/MainWindowWrapper_p.h
private/multisplitter/Widget_quick.cpp
private/multisplitter/Widget_quick.h
private/multisplitter/Separator_quick.cpp
private/multisplitter/Separator_quick.h
private/multisplitter/Rubberband_quick.cpp
private/multisplitter/Rubberband_quick.h
kddockwidgets_qtquick.qrc)
else()
set(DOCKSLIBS_SRCS ${DOCKSLIBS_SRCS}
private/DebugWindow.cpp
private/DebugWindow_p.h
private/ObjectViewer.cpp
private/ObjectViewer_p.h
MainWindow.cpp
private/widgets/TabWidget.cpp
MainWindow.h
DockWidget.h
private/multisplitter/Widget_qwidget.cpp
private/multisplitter/Widget_qwidget.h
private/multisplitter/Separator_qwidget.cpp
private/multisplitter/Separator_qwidget.h
private/widgets/TabBarWidget.cpp
private/widgets/TabBarWidget_p.h
private/widgets/FloatingWindowWidget.cpp
private/widgets/FloatingWindowWidget_p.h
private/widgets/FrameWidget.cpp
private/widgets/FrameWidget_p.h
private/widgets/SideBarWidget.cpp
private/widgets/SideBarWidget_p.h
private/widgets/TabWidgetWidget.cpp
private/widgets/TabWidgetWidget_p.h
private/widgets/TitleBarWidget.cpp
private/widgets/TitleBarWidget_p.h
private/widgets/DockWidget.cpp
private/widgets/QWidgetAdapter_widgets.cpp
private/widgets/QWidgetAdapter_widgets_p.h
private/indicators/SegmentedIndicators.cpp
private/indicators/SegmentedIndicators_p.h
# private/indicators/AnimatedIndicators.cpp
)
@@ -127,9 +203,7 @@ else()
set(IS_CLANG_BUILD FALSE)
endif()
add_subdirectory(private/multisplitter)
qt5_add_resources(RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/resources.qrc)
set(RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/kddockwidgets_resources.qrc)
add_library(kddockwidgets ${KDDockWidgets_LIBRARY_MODE} ${DOCKSLIBS_SRCS} ${DOCKS_INSTALLABLE_INCLUDES} ${RESOURCES} ${RESOURCES_QUICK})
add_library(KDAB::kddockwidgets ALIAS kddockwidgets)
@@ -138,12 +212,11 @@ set_compiler_flags(kddockwidgets)
target_include_directories(kddockwidgets
PUBLIC
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:include/kddockwidgets>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/fwd_headers>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/private
${CMAKE_CURRENT_SOURCE_DIR}/private/multisplitter/
)
target_compile_definitions(kddockwidgets
@@ -160,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)
@@ -168,19 +246,23 @@ if(CMAKE_COMPILER_IS_GNUCXX OR IS_CLANG_BUILD)
endif()
if(${PROJECT_NAME}_QTQUICK)
target_link_libraries(kddockwidgets PUBLIC Qt5::Widgets Qt5::Quick Qt5::QuickControls2 kddockwidgets_multisplitter PRIVATE Qt5::GuiPrivate)
target_link_libraries(kddockwidgets PUBLIC Qt${QT_MAJOR_VERSION}::Widgets Qt${QT_MAJOR_VERSION}::Quick Qt${QT_MAJOR_VERSION}::QuickControls2)
else()
target_link_libraries(kddockwidgets PUBLIC Qt5::Widgets kddockwidgets_multisplitter PRIVATE Qt5::GuiPrivate)
target_link_libraries(kddockwidgets PUBLIC Qt${QT_MAJOR_VERSION}::Widgets)
endif()
if (WIN32)
target_link_libraries(kddockwidgets PRIVATE Dwmapi)
elseif(NOT APPLE)
find_package(Qt5X11Extras)
target_link_libraries(kddockwidgets PUBLIC Qt5::X11Extras)
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)
endif()
set_target_properties(kddockwidgets PROPERTIES VERSION ${${PROJECT_NAME}_SOVERSION})
set_target_properties(kddockwidgets PROPERTIES
SOVERSION ${${PROJECT_NAME}_SOVERSION}
VERSION ${${PROJECT_NAME}_VERSION}
)
#version libraries on Windows
if(WIN32)
set(postfix ${${PROJECT_NAME}_VERSION_MAJOR})
@@ -208,7 +290,6 @@ install(FILES private/multisplitter/Widget.h DESTINATION include/kddockwidgets/p
install(FILES private/multisplitter/Widget_qwidget.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/Separator_p.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/Separator_qwidget.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/multisplitter_export.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES ${DOCKS_INSTALLABLE_PRIVATE_WIDGET_INCLUDES} DESTINATION include/kddockwidgets/private/widgets)
install(FILES private/indicators/ClassicIndicators_p.h DESTINATION include/kddockwidgets/private/indicators)
@@ -236,8 +317,11 @@ 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 kddockwidgets_multisplitter Qt5::Widgets)
target_link_libraries(kddockwidgets_linter kddockwidgets Qt${QT_MAJOR_VERSION}::Widgets)
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
@@ -18,15 +18,19 @@
#include "Config.h"
#include "multisplitter/MultiSplitterConfig.h"
#include "multisplitter/Widget_qwidget.h"
#include "multisplitter/Widget.h"
#include "DockRegistry_p.h"
#include "FrameworkWidgetFactory.h"
#include "Utils_p.h"
#include <QApplication>
#include <QDebug>
#include <QOperatingSystemVersion>
#ifdef KDDOCKWIDGETS_QTQUICK
# include <QQmlEngine>
# include <QQmlContext>
#endif
namespace KDDockWidgets
{
@@ -48,8 +52,10 @@ public:
QQmlEngine *m_qmlEngine = nullptr;
DockWidgetFactoryFunc m_dockWidgetFactoryFunc = nullptr;
MainWindowFactoryFunc m_mainWindowFactoryFunc = nullptr;
FrameworkWidgetFactory *m_frameworkWidgetFactory;
TabbingAllowedFunc m_tabbingAllowedFunc = nullptr;
FrameworkWidgetFactory *m_frameworkWidgetFactory = nullptr;
Flags m_flags = Flag_Default;
InternalFlags m_internalFlags = InternalFlag_None;
qreal m_draggedWindowOpacity = Q_QNAN;
};
@@ -157,6 +163,57 @@ qreal Config::draggedWindowOpacity() const
return d->m_draggedWindowOpacity;
}
void Config::setTabbingAllowedFunc(TabbingAllowedFunc func)
{
d->m_tabbingAllowedFunc = func;
}
TabbingAllowedFunc Config::tabbingAllowedFunc() const
{
return d->m_tabbingAllowedFunc;
}
void Config::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)
{
if (d->m_qmlEngine) {
@@ -164,13 +221,22 @@ void Config::setQmlEngine(QQmlEngine *qmlEngine)
return;
}
if (!qmlEngine) {
qWarning() << Q_FUNC_INFO << "Null QML engine";
return;
}
d->m_qmlEngine = qmlEngine;
QQmlContext *context = qmlEngine->rootContext();
context->setContextProperty(QStringLiteral("_kddw_widgetFactory"), d->m_frameworkWidgetFactory);
}
QQmlEngine *Config::qmlEngine() const
{
return d->m_qmlEngine;
}
#endif
void Config::Private::fixFlags()
{
@@ -206,9 +272,24 @@ void Config::Private::fixFlags()
}
#endif
#if !defined(Q_OS_WIN) && !defined(Q_OS_MACOS)
#if (!defined(Q_OS_WIN) && !defined(Q_OS_MACOS))
// QtQuick doesn't support AeroSnap yet. Some problem with the native events not being received...
m_flags = m_flags & ~Flag_AeroSnapWithClientDecos;
#endif
#if defined(DOCKS_DEVELOPER_MODE)
// We allow to disable aero-snap during development
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
@@ -35,6 +36,14 @@ class FrameworkWidgetFactory;
typedef KDDockWidgets::DockWidgetBase* (*DockWidgetFactoryFunc)(const QString &name);
typedef KDDockWidgets::MainWindowBase* (*MainWindowFactoryFunc)(const QString &name);
/// @brief Function to allow the user more granularity to disallow dock widgets to tab together
/// @param source The dock widgets being dragged
/// @param target The dock widgets within an existing docked tab group
/// @return true if the docking is allowed.
/// @sa setTabbingAllowedFunc
typedef bool (*TabbingAllowedFunc)(const QVector<DockWidgetBase*> &source,
const QVector<DockWidgetBase*> &target);
/**
* @brief Singleton to allow to choose certain behaviours of the framework.
*
@@ -53,32 +62,41 @@ public:
///@brief Flag enum to tune certain behaviours, the defaults are Flag_Default
enum Flag {
Flag_None = 0, ///> No option set
Flag_NativeTitleBar = 1, ///> Enables the Native OS title bar on OSes that support it (Windows 10, macOS), ignored otherwise. This is mutually exclusive with Flag_AeroSnap
Flag_AeroSnapWithClientDecos = 2, ///> Deprecated. This is now default and cannot be turned off. Moving a window on Windows 10 uses native moving, as that works well across screens with different HDPI settings. There's no reason to use manual client/Qt window moving.
Flag_AlwaysTitleBarWhenFloating = 4, ///> Floating windows will have a title bar even if Flag_HideTitleBarWhenTabsVisible is specified. Unneeded if Flag_HideTitleBarWhenTabsVisible isn't specified, as that's the default already.
Flag_HideTitleBarWhenTabsVisible = 8, ///> Hides the title bar if there's tabs visible. The empty space in the tab bar becomes draggable.
Flag_AlwaysShowTabs = 16, ///> Always show tabs, even if there's only one,
Flag_AllowReorderTabs = 32, /// Allows user to re-order tabs by dragging them
Flag_TabsHaveCloseButton = 64, /// Tabs will have a close button. Equivalent to QTabWidget::setTabsClosable(true).
Flag_DoubleClickMaximizes = 128, /// Double clicking the titlebar will maximize a floating window instead of re-docking it
Flag_TitleBarHasMaximizeButton = 256, /// The title bar will have a maximize/restore button when floating. This is mutually-exclusive with the floating button (since many apps behave that way).
Flag_TitleBarIsFocusable = 512, /// You can click the title bar and it will focus the last focused widget in the focus scope. If no previously focused widget then it focuses the user's dock widget guest, which should accept focus or use a focus proxy.
Flag_LazyResize = 1024, /// The dock widgets are resized in a lazy manner. The actual resize only happens when you release the mouse button.
// These two are internal, for testing purposes across platforms. Use Flag_DontUseUtilityFloatingWindows instead.
Flag_internal_DontUseQtToolWindowsForFloatingWindows = 0x800, ///> FloatingWindows will use Qt::Window instead of Qt::Tool. Internal, use Flag_DontUseUtilityFloatingWindows instead.
Flag_internal_DontUseParentForFloatingWindows = 0x1000, ///> FloatingWindows won't have a parent top-level. Internal, use Flag_DontUseUtilityFloatingWindows instead.
Flag_DontUseUtilityFloatingWindows = Flag_internal_DontUseQtToolWindowsForFloatingWindows | Flag_internal_DontUseParentForFloatingWindows,
Flag_TitleBarHasMinimizeButton = 0x2000 | Flag_DontUseUtilityFloatingWindows, ///> The title bar will have a minimize button when floating. This implies Flag_DontUseUtilityFloatingWindows too, otherwise they wouldn't appear in the task bar.
Flag_TitleBarNoFloatButton = 0x4000, ///> The TitleBar won't show the float button
Flag_AutoHideSupport = 0x8000 | Flag_TitleBarNoFloatButton, ///> Supports minimizing dock widgets to the side-bar.
///> By default it also turns off the float button, but you can remove Flag_TitleBarNoFloatButton to have both.
Flag_Default = Flag_AeroSnapWithClientDecos ///> The defaults
Flag_None = 0, ///< No option set
Flag_NativeTitleBar = 1, ///< Enables the Native OS title bar on OSes that support it (Windows 10, macOS), ignored otherwise. This is mutually exclusive with Flag_AeroSnap
Flag_AeroSnapWithClientDecos = 2, ///< Deprecated. This is now default and cannot be turned off. Moving a window on Windows 10 uses native moving, as that works well across screens with different HDPI settings. There's no reason to use manual client/Qt window moving.
Flag_AlwaysTitleBarWhenFloating = 4, ///< Floating windows will have a title bar even if Flag_HideTitleBarWhenTabsVisible is specified. Unneeded if Flag_HideTitleBarWhenTabsVisible isn't specified, as that's the default already.
Flag_HideTitleBarWhenTabsVisible = 8, ///< Hides the title bar if there's tabs visible. The empty space in the tab bar becomes draggable.
Flag_AlwaysShowTabs = 16, ///< Always show tabs, even if there's only one,
Flag_AllowReorderTabs = 32, ///< Allows user to re-order tabs by dragging them
Flag_TabsHaveCloseButton = 64, ///< Tabs will have a close button. Equivalent to QTabWidget::setTabsClosable(true).
Flag_DoubleClickMaximizes = 128, ///< Double clicking the titlebar will maximize a floating window instead of re-docking it
Flag_TitleBarHasMaximizeButton = 256, ///< The title bar will have a maximize/restore button when floating. This is mutually-exclusive with the floating button (since many apps behave that way).
Flag_TitleBarIsFocusable = 512, ///< You can click the title bar and it will focus the last focused widget in the focus scope. If no previously focused widget then it focuses the user's dock widget guest, which should accept focus or use a focus proxy.
Flag_LazyResize = 1024, ///< The dock widgets are resized in a lazy manner. The actual resize only happens when you release the mouse button.
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_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;
@@ -150,9 +168,60 @@ public:
///By default it's 1.0, fully opaque
qreal draggedWindowOpacity() const;
/**
* @brief Allows the user to intercept a docking attempt to center (tabbed) and disallow it.
*
* Whenever the user tries to tab two widgets together, the framework will call @p func. If
* it returns true, then tabbing is allowed, otherwise not.
*
* Example:
* @code
* #include <kddockwidgets/Config.h>
* (...)
*
* auto func = [] (const KDDockWidgets::DockWidgetBase::List &source,
* const KDDockWidgets::DockWidgetBase::List &target)
* {
* // disallows dockFoo to be tabbed with dockBar.
* return !(source.contains(dockFoo) && target.contains(dockBar));
* }
* @endcode
* KDDockWidgets::Config::self()->setTabbingAllowedFunc(func);
*/
void setTabbingAllowedFunc(TabbingAllowedFunc func);
///@brief Used internally by the framework. Returns the function which was passed to setTabbingAllowedFunc()
///By default it's nullptr.
///@sa setTabbingAllowedFunc().
TabbingAllowedFunc tabbingAllowedFunc() const;
///@brief Sets the 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 *);
QQmlEngine* qmlEngine() const;
#endif
private:
Q_DISABLE_COPY(Config)

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"
@@ -24,7 +23,6 @@
#include "WindowBeingDragged_p.h"
#include "SideBar_p.h"
#include <QAction>
#include <QEvent>
#include <QCloseEvent>
#include <QTimer>
@@ -42,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))
{
@@ -100,6 +100,11 @@ public:
return nullptr;
}
SideBar* sideBar() const
{
return DockRegistry::self()->sideBarForDockWidget(q);
}
QPoint defaultCenterPosForFloating();
void updateTitle();
@@ -128,36 +133,39 @@ 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";
setAttribute(Qt::WA_PendingMoveEvent, false);
qApp->installEventFilter(this);
}
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;
@@ -183,7 +191,7 @@ void DockWidgetBase::addDockWidgetAsTab(DockWidgetBase *other, AddingOption addi
Frame *frame = this->frame();
if (frame) {
if (frame->contains(other)) {
if (frame->containsDockWidget(other)) {
qWarning() << Q_FUNC_INFO << "Already contains" << other;
return;
}
@@ -200,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;
}
@@ -227,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";
}
@@ -236,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;
@@ -274,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()) {
@@ -336,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)) {
@@ -347,7 +368,7 @@ void DockWidgetBase::setOptions(Options options)
d->options = options;
Q_EMIT optionsChanged(options);
if (auto tb = titleBar())
tb->updateCloseButton();
tb->updateButtons();
}
}
@@ -385,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();
}
@@ -396,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 {};
}
@@ -510,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
@@ -528,7 +572,7 @@ FloatingWindow *DockWidgetBase::morphIntoFloatingWindow()
if (geo.isNull()) {
geo = geometry();
if (!testAttribute(Qt::WA_Moved)) { // If user already moved it, we don't interfere
if (!testAttribute(Qt::WA_PendingMoveEvent)) { // If user already moved it, we don't interfere
const QPoint center = d->defaultCenterPosForFloating();
if (!center.isNull())
geo.moveCenter(center);
@@ -571,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);
}
@@ -594,6 +637,16 @@ void DockWidgetBase::updateFloatAction()
d->updateFloatAction();
}
bool DockWidgetBase::eventFilter(QObject *watched, QEvent *event)
{
const bool isWindowActivate = event->type() == QEvent::WindowActivate;
const bool isWindowDeactivate = event->type() == QEvent::WindowDeactivate;
if ((isWindowActivate || isWindowDeactivate) && watched == window())
Q_EMIT windowActiveAboutToChange(isWindowActivate);
return QWidgetAdapter::eventFilter(watched, event);
}
QPoint DockWidgetBase::Private::defaultCenterPosForFloating()
{
MainWindowBase::List mainWindows = DockRegistry::self()->mainwindows();
@@ -616,12 +669,18 @@ void DockWidgetBase::Private::updateTitle()
void DockWidgetBase::Private::toggle(bool enabled)
{
if (SideBar *sb = sideBar()) {
// The widget is in the sidebar, let's toggle its overlayed state
sb->toggleOverlay(q);
} else {
// The most common case. The dock widget is not in the sidebar. just close or open it.
if (enabled) {
show();
} else {
q->close();
}
}
}
void DockWidgetBase::Private::updateToggleAction()
{
@@ -653,14 +712,12 @@ void DockWidgetBase::Private::onDockWidgetShown()
{
updateToggleAction();
updateFloatAction();
qCDebug(hiding) << Q_FUNC_INFO << "parent=" << q->parentWidget();
}
void DockWidgetBase::Private::onDockWidgetHidden()
{
updateToggleAction();
updateFloatAction();
qCDebug(hiding) << Q_FUNC_INFO << "parent=" << q->parentWidget();
}
void DockWidgetBase::Private::close()
@@ -670,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.
@@ -682,6 +738,9 @@ void DockWidgetBase::Private::close()
sb->removeDockWidget(q);
}
}
if (options & DockWidgetBase::Option_DeleteOnClose)
q->deleteLater();
}
bool DockWidgetBase::Private::restoreToPreviousPosition()
@@ -705,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
@@ -717,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;
}
@@ -725,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;
}
@@ -752,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();
}
@@ -786,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,10 +26,14 @@
#include <QVector>
// clazy:excludeall=ctor-missing-parent-argument
QT_BEGIN_NAMESPACE
class QAction;
QT_END_NAMESPACE
class TestDocks;
namespace Layouting {
class Item;
}
@@ -46,6 +50,7 @@ class TabWidget;
class TitleBar;
class MainWindowBase;
class StateDragging;
class FrameQuick;
/**
* @brief The DockWidget base-class. DockWidget and DockWidgetBase are only
@@ -69,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)
@@ -85,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.
@@ -124,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.
@@ -201,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
@@ -235,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.
*
@@ -244,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.
*
@@ -256,7 +269,7 @@ public:
* @brief Like QWidget::close() but the hosted widget won't be asked if we
* should close.
*/
void forceClose();
Q_INVOKABLE void forceClose();
/**
* @brief Returns this dock widget's title bar.
@@ -301,7 +314,7 @@ public:
QStringList affinities() const;
/// @brief Equivalent to QWidget::show(), but it's optimized to reduce flickering on some platforms
void show();
Q_INVOKABLE void show();
/// @brief Brings the dock widget to the front.
///
@@ -310,7 +323,7 @@ public:
/// - If the dock widget is floating, QWindow::raise() is called.
///
/// This only applies if the dock widget is already open. If closed, does nothing.
void raise();
Q_INVOKABLE void raise();
/**
* @brief Returns whether widget() is a KDDockWidget::MainWindow
@@ -325,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
@@ -334,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
@@ -353,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();
@@ -401,18 +437,28 @@ 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
void removedFromSideBar();
///@brief Emitted when the top-level window this dock widget is in is activated or deactivated
///This is convenience to replace tracking dockWidget->window(), since the window changes when
///docking and undocking
///
/// It's called 'aboutTo' because it's done in an event filter and the target window doesn't
/// have it's 'activeWindow' property updated yet at this point.
void windowActiveAboutToChange(bool activated);
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)
@@ -439,7 +485,7 @@ private:
friend class MultiSplitter;
friend class Frame;
friend class DropArea;
friend class TestDocks;
friend class ::TestDocks;
friend class StateDragging;
friend class KDDockWidgets::TabWidget;
friend class KDDockWidgets::TitleBar;
@@ -447,6 +493,18 @@ private:
friend class KDDockWidgets::DockRegistry;
friend class KDDockWidgets::LayoutSaver;
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.
@@ -478,6 +536,9 @@ private:
///@brief Updates the floatAction state
void updateFloatAction();
///@reimp
bool eventFilter(QObject *, QEvent *) override;
class Private;
Private *const d;
};
@@ -485,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.
@@ -66,7 +66,7 @@ void DockWidgetQuick::setWidget(const QString &qmlFilename)
setWidget(adapter);
}
void DockWidgetQuick::setWidget(QWidgetOrQuick *widget)
void DockWidgetQuick::setWidget(QWidgetAdapter *widget)
{
widget->QWidgetAdapter::setParent(this);
QWidgetAdapter::makeItemFillParent(widget);
@@ -87,3 +87,23 @@ bool DockWidgetQuick::event(QEvent *e)
return DockWidgetBase::event(e);
}
QSize DockWidgetQuick::minimumSize() const
{
if (QWidgetAdapter *guestWidget = widget()) {
// The guests min-size is the same as the widget's, there's no spacing or margins.
return guestWidget->minimumSize();
}
return DockWidgetBase::minimumSize();
}
QSize DockWidgetQuick::maximumSize() const
{
if (QWidgetAdapter *guestWidget = widget()) {
// The guests max-size is the same as the widget's, there's no spacing or margins.
return guestWidget->maximumSize();
}
return DockWidgetBase::maximumSize();
}

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;
@@ -55,7 +56,13 @@ public:
void setWidget(const QString &qmlFilename);
/// @reimp
void setWidget(QWidgetOrQuick *widget) override;
void setWidget(QWidgetAdapter *widget) override;
/// @reimp
QSize minimumSize() const override;
/// @reimp
QSize maximumSize() const override;
protected:
bool event(QEvent *e) 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
@@ -18,15 +18,18 @@
#include "FocusScope.h"
#include "TitleBar_p.h"
#include "Frame_p.h"
#include "DockWidgetBase.h"
#include "DockRegistry_p.h"
#include <QObject>
#include <QApplication>
#include <QGuiApplication>
#include <QPointer>
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)
@@ -45,6 +48,7 @@ public:
void setIsFocused(bool);
void onFocusObjectChanged(QObject *);
bool isInFocusScope(WidgetType *) const;
void emitDockWidgetFocusChanged();
FocusScope *const q;
QWidgetAdapter *const m_thisWidget;
@@ -101,24 +105,30 @@ void FocusScope::Private::setIsFocused(bool is)
if (is != m_isFocused) {
m_isFocused = is;
if (is)
emitDockWidgetFocusChanged();
if (!m_inCtor) // Hack so we don't call pure-virtual
Q_EMIT q->isFocusedChanged();
/* Q_EMIT */ q->isFocusedChangedCallback();
}
}
void FocusScope::Private::onFocusObjectChanged(QObject *obj)
{
auto widget = qobject_cast<WidgetType*>(obj);
if (!widget)
if (!widget) {
setIsFocused(false);
return;
}
const bool is = isInFocusScope(widget);
if (is && m_lastFocusedInScope != widget && !qobject_cast<TitleBar*>(obj)) {
m_lastFocusedInScope = widget;
Q_EMIT q->focusedWidgetChanged();
}
setIsFocused(is);
/* Q_EMIT */ q->focusedWidgetChangedCallback();
} else {
setIsFocused(is);
}
}
bool FocusScope::Private::isInFocusScope(WidgetType *widget) const
@@ -133,3 +143,33 @@ bool FocusScope::Private::isInFocusScope(WidgetType *widget) const
return false;
}
void FocusScope::Private::emitDockWidgetFocusChanged()
{
auto p = qobject_cast<WidgetType*>(qApp->focusObject());
if (!p) return;
// Find the nearest DockWidget and send the focusChangedSignal
while (p) {
if (auto frame = qobject_cast<Frame*>(p)) {
// Special case: The focused widget is inside the frame but not inside the dockwidget.
// For example, it's a line edit in the QTabBar. We still need to send the signal for
// the current dw in the tab group
if (auto dw = frame->currentDockWidget()) {
DockRegistry::self()->setFocusedDockWidget(dw);
}
break;
}
if (p == m_thisWidget)
break;
if (auto dw = qobject_cast<DockWidgetBase*>(p)) {
DockRegistry::self()->setFocusedDockWidget(dw);
break;
}
p = KDDockWidgets::Private::parentWidget(p);
}
}

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,8 +25,9 @@
namespace KDDockWidgets
{
///@brief Allows to implement a similar functionality to QtQuick's FocusScope item, in QtWidgets
class FocusScope
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
@@ -16,10 +16,11 @@
#include "FloatingWindow_p.h"
#include "Config.h"
#include "indicators/ClassicIndicators_p.h"
#include "indicators/NullIndicators_p.h"
#include "Utils_p.h"
#include "TabWidget_p.h"
#ifdef KDDOCKWIDGETS_QTWIDGETS
# include "indicators/ClassicIndicators_p.h"
# include "widgets/TabWidget_p.h"
# include "widgets/FrameWidget_p.h"
# include "widgets/TitleBarWidget_p.h"
# include "widgets/TabBarWidget_p.h"
@@ -32,13 +33,18 @@
# include <QRubberBand>
# include <QToolButton>
#else
# include "DockWidgetQuick.h"
# include "quick/FrameQuick_p.h"
# include "quick/DockWidgetQuick.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;
@@ -90,11 +96,18 @@ FloatingWindow *DefaultWidgetFactory::createFloatingWindow(Frame *frame, MainWin
DropIndicatorOverlayInterface *DefaultWidgetFactory::createDropIndicatorOverlay(DropArea *dropArea) const
{
#ifdef Q_OS_WASM
// On WASM windows don't support translucency, which is required for the classic indicators.
return new SegmentedIndicators(dropArea);
#endif
switch (s_dropIndicatorType) {
case DropIndicatorType::Classic:
return new ClassicIndicators(dropArea);
case DropIndicatorType::Segmented:
return new SegmentedIndicators(dropArea);
case DropIndicatorType::None:
return new NullIndicators(dropArea);
}
return new ClassicIndicators(dropArea);
@@ -157,21 +170,27 @@ FloatingWindow *DefaultWidgetFactory::createFloatingWindow(Frame *frame, MainWin
DropIndicatorOverlayInterface *DefaultWidgetFactory::createDropIndicatorOverlay(DropArea *dropArea) const
{
switch (s_dropIndicatorType) {
case DropIndicatorType::Classic:
return new ClassicIndicators(dropArea);
case DropIndicatorType::Segmented:
qWarning() << "Segmented indicators not supported for QtQuick yet";
return new NullIndicators(dropArea);
case DropIndicatorType::None:
return new NullIndicators(dropArea);
}
return new ClassicIndicators(dropArea);
}
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
@@ -181,7 +200,7 @@ Layouting::Separator *DefaultWidgetFactory::createSeparator(Layouting::Widget *p
QWidgetOrQuick *DefaultWidgetFactory::createRubberBand(QWidgetOrQuick *parent) const
{
return new QWidgetOrQuick(parent);
return new RubberBandQuick(parent);
}
SideBar *DefaultWidgetFactory::createSideBar(SideBarLocation loc, MainWindowBase *parent) const
@@ -193,6 +212,11 @@ SideBar *DefaultWidgetFactory::createSideBar(SideBarLocation loc, MainWindowBase
return nullptr;
}
QUrl DefaultWidgetFactory::titleBarFilename() const
{
return QUrl(QStringLiteral("qrc:/kddockwidgets/private/quick/qml/TitleBar.qml"));
}
#endif // QtQuick
// iconForButtonType impl is the same for QtQuick and QtWidgets
@@ -233,10 +257,11 @@ QIcon DefaultWidgetFactory::iconForButtonType(TitleBarButtonType type, qreal dpr
const bool isFractional = int(dpr) != dpr;
if (isFractional) {
// We don't support 1.5x yet.
// Linux is the only one affected as Windows and macOS use integral factors.
// Problem with Linux is that rendering is off due to a rounding bug only fixed in 5.15.2
// Will enable for fractional later.
// QTBUG-86170
// Mostly affects Linux. Unless you're using Qt::HighDpiScaleFactorRoundingPolicy::PassThrough, in which case it will
// affect other OSes too.
return icon;
}
#else

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.
@@ -61,7 +64,12 @@ class TabBar;
*
* @sa Config::setFrameworkWidgetFactory()
*/
class DOCKS_EXPORT FrameworkWidgetFactory {
class DOCKS_EXPORT FrameworkWidgetFactory : public QObject
{
#ifdef KDDOCKWIDGETS_QTQUICK
Q_PROPERTY(QUrl titleBarFilename READ titleBarFilename CONSTANT)
#endif
Q_OBJECT
public:
FrameworkWidgetFactory() = default;
@@ -89,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.
@@ -134,10 +142,10 @@ public:
#ifdef KDDOCKWIDGETS_QTWIDGETS
///@brief Called internally by the framework to create a title bar button
///@parent the button's parent
///@p parent the button's parent
virtual QAbstractButton* createTitleBarButton(QWidget *parent, TitleBarButtonType) const = 0;
#else
// QtQuick will have some other base class for buttons
virtual QUrl titleBarFilename() const = 0;
#endif
/// @brief Returns the icon to be used with the specified @p type
@@ -152,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;
@@ -168,6 +177,8 @@ public:
#ifdef KDDOCKWIDGETS_QTWIDGETS
QAbstractButton* createTitleBarButton(QWidget *parent, TitleBarButtonType) const override;
#else
QUrl titleBarFilename() const override;
#endif
QIcon iconForButtonType(TitleBarButtonType type, qreal dpr) 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
@@ -19,17 +19,26 @@
#ifndef KD_KDDOCKWIDGETS_H
#define KD_KDDOCKWIDGETS_H
#include "Qt5Qt6Compat_p.h"
#include <QObject>
#include <QDebug>
#ifdef Q_OS_WIN
// Only on Windows, where this is popular. On linux it the Qt::Tool windows need reparenting. Untested on macOS.
// 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,18 +170,10 @@ 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, ///< Segmented indicators
None ///< Don't show any drop indicators while dragging
};
///@internal
@@ -119,12 +216,22 @@ namespace KDDockWidgets
};
///@internal
inline uint qHash(SideBarLocation loc, uint seed)
inline Qt5Qt6Compat::qhashtype qHash(SideBarLocation loc, Qt5Qt6Compat::qhashtype seed)
{
return ::qHash(static_cast<uint>(loc), seed);
}
}
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,14 +25,13 @@
#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"
#include <qmath.h>
#include <QDebug>
#include <QSettings>
#include <QApplication>
#include <QFile>
#include <memory>
@@ -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,13 @@ 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);
if (!dockWidgets.isEmpty())
map.insert(QStringLiteral("sidebar-%1").arg(int(loc)), stringListToVariant(dockWidgets));
}
return map;
}
@@ -713,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();
@@ -720,6 +832,13 @@ void LayoutSaver::MainWindow::fromVariantMap(const QVariantMap &map)
affinities.push_back(affinityName);
}
// Load the SideBars:
dockWidgetsPerSideBar.clear();
for (SideBarLocation loc : { SideBarLocation::North, SideBarLocation::East, SideBarLocation::West, SideBarLocation::South }) {
const QVariantList dockWidgets = map.value(QStringLiteral("sidebar-%1").arg(int(loc))).toList();
if (!dockWidgets.isEmpty())
dockWidgetsPerSideBar.insert(loc, variantToStringList(dockWidgets));
}
}
bool LayoutSaver::MultiSplitter::isValid() const
@@ -735,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
@@ -27,6 +27,8 @@ QT_BEGIN_NAMESPACE
class QByteArray;
QT_END_NAMESPACE
class TestDocks;
namespace KDDockWidgets {
class DockWidgetBase;
@@ -105,7 +107,7 @@ public:
struct ScreenInfo;
private:
Q_DISABLE_COPY(LayoutSaver)
friend class TestDocks;
friend class ::TestDocks;
class Private;
Private *const d;

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,7 +18,7 @@
#include <QRect>
#include <QDebug>
#include <QScreen>
#include <QApplication>
#include <QGuiApplication>
#include <QJsonDocument>
#include <memory>
@@ -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
@@ -236,6 +258,7 @@ public:
QVariantMap toVariantMap() const;
void fromVariantMap(const QVariantMap &map);
QHash<SideBarLocation, QStringList> dockWidgetsPerSideBar;
KDDockWidgets::MainWindowOptions options;
LayoutSaver::MultiSplitter multiSplitterLayout;
QString uniqueName;
@@ -244,6 +267,7 @@ public:
int screenIndex;
QSize screenSize; // for relative-size restoring
bool isVisible;
Qt::WindowState windowState = Qt::WindowNoState;
ScalingInfo scalingInfo;
};
@@ -271,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();
@@ -298,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
@@ -25,10 +25,11 @@
#include "DropAreaWithCentralFrame_p.h"
#include "FrameworkWidgetFactory.h"
#include <QApplication>
#include <QVBoxLayout>
#include <QPainter>
// clazy:excludeall=ctor-missing-parent-argument,missing-qobject-macro
using namespace KDDockWidgets;
class MainWindow::Private
@@ -99,8 +100,6 @@ MainWindow::MainWindow(const QString &name, MainWindowOptions options,
}
setCentralWidget(centralWidget);
// qApp->installEventFilter(this);
}
MainWindow::~MainWindow()

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,12 @@ 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;
QStringList affinities;
@@ -94,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;
@@ -157,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);
@@ -214,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;
}
@@ -236,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;
}
@@ -267,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;
}
@@ -323,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;
@@ -334,7 +359,55 @@ 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()
{
for (auto loc : { SideBarLocation::North, SideBarLocation::South,
SideBarLocation::East, SideBarLocation::West }) {
if (SideBar *sb = q->sideBar(loc))
sb->clear();
}
}
void MainWindowBase::moveToSideBar(DockWidgetBase *dw)
@@ -376,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;
}
@@ -392,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);
@@ -401,7 +479,7 @@ void MainWindowBase::overlayOnSideBar(DockWidgetBase *dw)
void MainWindowBase::toggleOverlayOnSideBar(DockWidgetBase *dw)
{
const bool wasOverlayed = d->m_overlayedDockWidget == dw;
clearSideBarOverlay();
clearSideBarOverlay(); // Because only 1 dock widget can be overlayed each time
if (!wasOverlayed) {
overlayOnSideBar(dw);
}
@@ -425,7 +503,7 @@ SideBar *MainWindowBase::sideBarForDockWidget(const DockWidgetBase *dw) const
SideBarLocation::East, SideBarLocation::West }) {
if (SideBar *sb = sideBar(loc)) {
if (sb->contains(const_cast<DockWidgetBase *>(dw)))
if (sb->containsDockWidget(const_cast<DockWidgetBase *>(dw)))
return sb;
}
}
@@ -440,8 +518,20 @@ DockWidgetBase *MainWindowBase::overlayedDockWidget() const
bool MainWindowBase::sideBarIsVisible(SideBarLocation loc) const
{
if (SideBar *sb = sideBar(loc))
return sb->isVisible();
if (SideBar *sb = sideBar(loc)) {
return !sb->isEmpty(); // isVisible() is always true, but its height is 0 when empty.
}
return false;
}
bool MainWindowBase::anySideBarIsVisible() const
{
for (auto loc : { SideBarLocation::North, SideBarLocation::South,
SideBarLocation::East, SideBarLocation::West }) {
if (sideBarIsVisible(loc))
return true;
}
return false;
}
@@ -463,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)
@@ -481,7 +571,40 @@ bool MainWindowBase::deserialize(const LayoutSaver::MainWindow &mw)
d->affinities = mw.affinities;
}
return dropArea()->deserialize(mw.multiSplitterLayout);
const bool success = dropArea()->deserialize(mw.multiSplitterLayout);
// Restore the SideBars
d->clearSideBars();
for (SideBarLocation loc : { SideBarLocation::North, SideBarLocation::East, SideBarLocation::West, SideBarLocation::South }) {
SideBar *sb = sideBar(loc);
if (!sb)
continue;
const QStringList dockWidgets = mw.dockWidgetsPerSideBar.value(loc);
for (const QString &uniqueName : dockWidgets) {
DockWidgetBase *dw = DockRegistry::self()->dockByName(uniqueName);
if (!dw) {
qWarning() << Q_FUNC_INFO << "Could not find dock widget" << uniqueName
<< ". Won't restore it to sidebar";
continue;
}
sb->addDockWidget(dw);
}
}
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));
return success;
}
LayoutSaver::MainWindow MainWindowBase::serialize() const
@@ -496,6 +619,16 @@ 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)) {
const QStringList dockwidgets = sb->serialize();
if (!dockwidgets.isEmpty())
m.dockWidgetsPerSideBar.insert(loc, dockwidgets);
}
}
return m;
}

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 <QVector>
#include <QMargins>
class TestDocks;
namespace KDDockWidgets {
class DockWidgetBase;
@@ -72,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.
@@ -166,6 +171,9 @@ public:
/// @brief Returns whether the specified sidebar is visible
bool sideBarIsVisible(SideBarLocation) const;
/// @brief Returns whether any side bar is visible
bool anySideBarIsVisible() const;
protected:
void setUniqueName(const QString &uniqueName);
void onResized(QResizeEvent *); // Because QtQuick doesn't have resizeEvent()
@@ -180,6 +188,7 @@ private:
class Private;
Private *const d;
friend class ::TestDocks;
friend class LayoutSaver;
bool deserialize(const LayoutSaver::MainWindow &);
LayoutSaver::MainWindow serialize() 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
@@ -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
@@ -13,20 +13,42 @@
#define KDDOCKWIDGETS_QT5QT6_COMPAT_P_H
#include <QMouseEvent>
#include <QDropEvent>
namespace KDDockWidgets {
namespace Qt5Qt6Compat {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#define QQUICKITEMgeometryChanged geometryChange
using QEnterEvent = QEnterEvent;
using qintptr = ::qintptr;
using qhashtype = size_t;
inline QPoint eventPos(QDropEvent *ev)
{
return ev->position().toPoint();
}
inline QPoint eventGlobalPos(QMouseEvent *ev)
{
return ev->globalPosition().toPoint();
}
#else
#else // Qt 5:
#define QQUICKITEMgeometryChanged geometryChanged
using QEnterEvent = QEvent;
using qintptr = long;
using qhashtype = uint;
inline QPoint eventPos(QDropEvent *ev)
{
return ev->pos();
}
// Qt 5:
inline QPoint eventGlobalPos(QMouseEvent *ev)
{
return ev->globalPos();

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

@@ -0,0 +1,12 @@
/*
This file is part of KDDockWidgets.
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
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include "../../DockWidgetBase.h"

View File

@@ -0,0 +1,12 @@
/*
This file is part of KDDockWidgets.
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
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include "../../DockWidgetQuick.h"

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