Commit Graph

1157 Commits

Author SHA1 Message Date
Sergio Martins
e298667351 Remove dead code about static separators
Before we had separators on the left,top,bottom,right margins
with 0 width. Now we don't have this concept anymore
2020-05-04 14:28:59 +01:00
Sergio Martins
0595448bba Replace Anchor with Separator
We don't have the concept of Anchors anymore. Code is now simpler
2020-05-04 13:10:38 +01:00
Sergio Martins
97c1ca30fd Layouting engine rewrite
The layouting was becoming too complex to maintain and to introduce
new features. Was even buggy, the fuzzer was constantly finding
bugs, which took hours to workaround.

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

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

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

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

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

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

Available by setting Flag_TitleBarHasMaximizeButton.
Added example too.

Fixes: #37
2020-04-20 19:55:51 +01:00
Sergio Martins
ab0fc1e328 Add DockWidget::Option_NonDockable
A dock widget with this option will always be floating and not be
able to dock into anything. Other widgets can't dock into it either.
2020-04-13 13:23:38 +01:00
Sergio Martins
899ca6af6a Merge pull request #34 from jcelerier/master
Add an include needed from Qt 5.15
2020-03-27 12:31:56 +00:00
Jean-Michaël Celerier
c8c56d293c Add an include needed from Qt 5.15 2020-03-26 23:27:23 +01:00
Sergio Martins
b236d744e3 Fix calculating main window scale 2020-03-25 15:56:19 +00:00
Sergio Martins
425d859f5b Merge pull request #33 from KDAB/fix_tabbarwidget_leak
Don't leak TabBarWidget's proxy style
2020-03-25 13:35:04 +00:00
Milian Wolff
d58abf170f Don't leak TabBarWidget's proxy style
Fixes leak reported by LSAN:

```
    #0 0x7f7b5687e968 in operator new(unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x7f7b2e5b1096 in KDDockWidgets::TabBarWidget::TabBarWidget(KDDockWidgets::TabWidget*) ../3rdParty/kddockwidgets/src/private/widgets/TabBarWidget.cpp:71
    #2 0x7f7b2e295ba4 in KDDockWidgets::DefaultWidgetFactory::createTabBar(KDDockWidgets::TabWidget*) const ../3rdParty/kddockwidgets/src/FrameworkWidgetFactory.cpp:71
    #3 0x7f7b2e5b8f54 in KDDockWidgets::TabWidgetWidget::TabWidgetWidget(KDDockWidgets::Frame*) ../3rdParty/kddockwidgets/src/private/widgets/TabWidgetWidget.cpp:38
```

The owernship rules for QProxyStyle <-> QStyle are pure madness.
We do not want to delete the proxy we use as a base. And we must
not ever create multiple proxy styles for the same style either.
So add a static singleton for the proxy style and set its parent
to the qApp. This seems to work fine, at least the leak is gone
and we also don't get a crash at shutdown...
2020-03-25 14:03:24 +01:00
Sergio Martins
225aa6a098 Add unit-test for DockWidget::raise()
and make it pass on offscreen platform too, as that QPA plugin
fails to keep z-order between order.
2020-03-24 22:36:21 +00:00
Sergio Martins
b0665cd003 When raising, also set current tab if it's floating
If the dock widget is in a FloatingWindow, but hidden by some
other tab, we not only need to raise the FloatingWindow but also
set our tab current
2020-03-24 22:12:28 +00:00
Sergio Martins
3a501d1b5c DebugWindow: Add test to DockWidget::raise() 2020-03-24 22:06:53 +00:00
Sergio Martins
acfd53672c Add DockWidget::raise()
Mostly like QWindow::raise(), but if in a tab widget, makes the tab
widget current too.
2020-03-24 22:06:13 +00:00
Sergio Martins
afb3edfd1d unit-tests++ 2020-03-24 13:33:51 +00:00
Sergio Martins
b2c3442233 example: Move the floating window away from the top-border
Fixes on Windows the its titlebar being hidden
2020-03-24 11:16:27 +00:00
Sergio Martins
fc63f843b7 Workaround QTBUG-83030
Fixes a case where the floating window wouldn't disappear.
This is deep in Qt. Got it down to a minimal test-case and reported it.

Probably won't get fixed ever.
2020-03-24 10:58:31 +00:00
Sergio Martins
f77d052dbb Allow to change NonClosable mid game
Before it was immutable, now you can change it
2020-03-23 16:28:16 +00:00
Sergio Martins
cc1e1eaa51 Don't flicker when showing a floating dock widget
Create the FloatingWindow directly, instead of creating the DockWidget
then reparenting it
2020-03-07 21:15:44 +00:00
Sergio Martins
ca4d63ed2e Don't override the users tab bar QProxyStyle 2020-03-05 18:02:23 +00:00
Sergio Martins
6564be122f Workaround Qt QWidget::showMaximized() bug on windows
When we cover the native title bar and maximize the window, it won't
appear at 0,0, but at -5, -5 or so.

Use Windows native maximize instead, which works fine
2020-03-02 12:15:37 +00:00
Sergio Martins
eabcdfb945 Add unit-test for affinity 2020-03-01 15:03:29 +00:00
Sergio Martins
5b91021745 LayoutSaver: insert the DockWidget ptr into the cash 2020-03-01 15:03:07 +00:00
Sergio Martins
dbd90b8a02 LayoutSaver: Clear by affinity too
When restoring windows of the specified affinity clear only
the ones of that affinity
2020-03-01 15:02:22 +00:00
Sergio Martins
9904d847f2 LayoutSaver now can save/restore a sub-set of windows
Each subset is identified by its "affinity name".
See DockWidget/MainWindow setAffinityName property.

Patch contributed by Andras Mantia, I've changed it to deal in
terms of affinity names instead of unique names.
2020-03-01 14:25:31 +00:00
Sergio Martins
dedda6cb14 LayoutSaver: Also store the affinity in the JSON 2020-03-01 14:13:02 +00:00
Sergio Martins
2143b09206 DockRegistry: Minor refactoring
- affinitiesForMainWindowNames() pulled to a separate method
- By appending QString() (empty affinity) to the affinity list it
simplifies the ifs, which reduces the lambdas to a single comparison.
- Remove the lambdas as they're used only once now and only have 1 comparison,
put the check directly in the if
2020-03-01 12:45:17 +00:00
Andras Mantia
947d638cb5 Added a DockRegistry::clear() overload to close a subset
(Part of pull/31)
2020-03-01 12:34:44 +00:00
Sergio Martins
63e662323f Added unit-test for Flag_DoubleClickMaximizes 2020-02-27 15:13:01 +00:00
Sergio Martins
90b893e46a Introduce Flag_DoubleClickMaximizes
Double clicking on the title bar of a floating window will maximize it.
2020-02-27 15:00:31 +00:00
Sergio Martins
802c6206ce Added comment, so we don't remove this warning 2020-02-26 23:36:08 +00:00
Sergio Martins
ce6fd20efd LayoutSaver: Also restore position percentage
Fixes anchors going to weird places when the window is resized.
Calculated percentage was wrong because layout hadn't been deserialized
yet.
2020-02-26 23:31:59 +00:00
Sergio Martins
af5bb4a3e4 Also store the percentage position in the json
just for checking that the restore is sane, even though
that property is calculated at runtime
2020-02-26 22:45:40 +00:00
Sergio Martins
ee786f57c5 LayoutSaver: Fix rounding errors when doing a relative restore
After a restore with relative sizes the items might not be on a pixel
perfect position regarding to their anchors. Make sure they are after
the restore is complete.
2020-02-25 23:24:39 +00:00
Sergio Martins
170f4efbb2 example: Add a menu action to close all dock widgets 2020-02-25 23:23:36 +00:00
Sergio Martins
d97b001ec8 DebugWindow: Make the actions apply to all layouts
even the ones in floating windows
2020-02-25 23:23:10 +00:00
Sergio Martins
043b481ddd Example: Add a quit action 2020-02-25 23:19:10 +00:00
Sergio Martins
2155e11bd7 Debug++ 2020-02-25 23:13:41 +00:00