Commit Graph

60 Commits

Author SHA1 Message Date
Sergio Martins
d5797a3aea Honour QSizePolicy::Fixed too
Some widgets, for example QPushButton, instead of having an explicit max size,
they communicate the need for a max size through their size policy
2020-06-07 19:53:06 +01:00
Sergio Martins
7c442dce85 Fix another place that should use setSuggestedGeometry 2020-06-04 21:47:47 +01:00
Sergio Martins
07ea3ff1a6 cleanup: Replace some qobject_casts with a function 2020-06-04 21:37:01 +01:00
Sergio Martins
874fd7d69f Don't set the FloatingWindow geometry directly
Let's have an indirection, so FloatingWindow can do some adjustments
and use a smaller rect incase of max-size.

Since we don't want to enforce max-size, just when showing the window.
2020-06-04 21:21:11 +01:00
Sergio Martins
ddc49c9358 Don't warn when restoring and there's no last pos info
We now restore floating windows to their previous position too
when toggling float. If there's no last info it's fine
2020-06-04 18:21:52 +01:00
Sergio Martins
f5f39a37a1 Decouple DockWidget from TabWidget
TabWidget will be an implementation detail of FrameWidget, and not
shared by QtQuick
2020-06-03 21:38:47 +01:00
Sergio Martins
0a75d89848 Add Frame::detachTab()
The tab widget will be an implementation detail of FrameWidget and
not accessed by anyone
2020-06-03 21:18:38 +01:00
Sergio Martins
d4d83111ff Added DockWidgetBase::isMainWindow() 2020-05-25 20:25:33 +01:00
Sergio Martins
d94263fce5 Allow each dock widget and main window to support multiple affinities 2020-05-25 14:14:17 +01:00
Sergio Martins
e28f82dcad Make Item::hostWidget be a Layouting::Widget instead of QWidget
Just an abstraction preparing for QQuickItem support
2020-05-24 17:31:37 +01:00
Sergio Martins
3d95263b40 Fix examples build with installed kddw 2020-05-23 19:00:12 +01:00
Sergio Martins
a7013b4cf7 Make DockWidget::setFloating(false) save the last docking position
so we can restore to it when floating again
2020-05-22 11:42:00 +01:00
Sergio Martins
4917da9e7c Minor: factorout some code into DockWidget::saveLastFloatingGeometry() 2020-05-22 11:37:25 +01:00
Sergio Martins
6d44362991 DockWidget::setFloating(true): restore to previous floating position
When floating a dock widget we restore it to the last known floating
position now
2020-05-22 11:12:12 +01:00
Sergio Martins
76ba261f62 Return LastPositions by reference
Otherwise we're calling setters on a temporary
2020-05-22 10:53:37 +01:00
Sergio Martins
b4526b007c Make LastPositions::lastPosition private
Need to control how the setters are messing with it, to add more
of them
2020-05-21 18:56:44 +01:00
Sergio Martins
618ec9fd41 Minor, use the members directly 2020-05-21 18:15:06 +01:00
Sergio Martins
9779b8edc3 Deal in terms of LastPositions instead of the individual position
Just a refactoring to add more encapsulation
2020-05-21 17:43:51 +01:00
Sergio Martins
50934ae56d Use a shared_ptr for Position, so we can pass LastPositions by value 2020-05-21 17:19:54 +01:00
Sergio Martins
2da37180b9 Start supporting multiple last positions
Pushing some boilerplate first, so the functional diff is smaller.
Wraps the old position class with one that will have many.
2020-05-21 16:52:03 +01:00
Sergio Martins
f260a76f8b Rename LastPosition to Position
so we can have a list of them, the dock widget might have been
in several main windows
2020-05-21 14:49:49 +01:00
Sergio Martins
d1d1c983f1 Remove "using namespace Layouting" out of the layouting lib
Fixes windows build due to ambiguous symbols
2020-05-14 22:02:27 +01:00
Sergio Martins
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
Colin Ogilvie
68f0c64954 Add a DockWidgetBase::floatAction()
Helper action to allow docking/detaching
2020-04-30 13:39:02 +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
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
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
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
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
dedda6cb14 LayoutSaver: Also store the affinity in the JSON 2020-03-01 14:13:02 +00:00
Sergio Martins
579b222418 Make AddingOption_StartHidden also work for tabs
You can now pass that option to DockWidget::addDockWidgetAsTab().
2020-02-19 16:36:50 +00:00
Sergio Martins
d6997eaf7f Introduce main window affinity
By default a dock widget can dock into any main window.
With affinities, we can now have a dock widget "belong" to a main window
and only be able to dock into it (or into other floating dock widgets
with the same affinity).

See DockWidgetBase::setAffinity() and MainWindowBase::setAffinity().
2020-02-09 21:02:21 +00:00
Sergio Martins
aded290573 Don't save last position if the window was hidden already
Bug was happening when calling close() an closed dock widget, it
would then save the position of the invisible window. Next time it
was open it would appear in a bogus location. 0,0 in my case.
2020-02-06 15:01:58 +00:00
Sergio Martins
fca010ce2a Center floating dock widgets within their main window
In case they don't have any previous position.
This is better than showing them at 0,0
2020-02-06 14:30:01 +00:00
Sergio Martins
3771aa7a40 Fix toggleAction() emitting spurious toggle events
When showing a dockwidget it's inserted into a tab widget, which
will generate a hide event, which will toggle the action to off
even though the dock widget is opened for our purposes
2020-02-05 13:06:53 +00:00
Sergio Martins
1cac350547 Add convenience method DockWidget::isOpen() 2020-02-01 19:47:16 +00:00
Allen Winter
df692686e7 various - update copyright year 2020-01-07 11:36:56 -05:00
Sergio Martins
92bbe4d4f7 Remove a dock widget from the layout before adding as tab
So the layout can grow first and not complain there's not enough
space.

Fixes fuzzer test-case 3.json.
The warning was: "Constraints not honoured" in Item::onLayoutRequest()
2019-10-15 12:51:49 +01:00
Sergio Martins
ac313c5a24 Don't save floating geometry on clear()
clear() shouldn't save anything.
Fixes floating dockwidgets not having proper geometry when shown
after clear() was called.
2019-10-08 14:59:31 +01:00
Sergio Martins
21579f2743 Minor method renames 2019-10-07 00:16:16 +01:00
Sergio Martins
b5fad9a601 docs++ 2019-10-05 12:54:25 +01:00
Albert Astals Cid
262d57b890 Add a few const &
as suggested by clang-tidy
2019-09-30 15:57:03 +02:00
Sergio Martins
cf90980094 Fix toggleAction() not emitting its signals
User might connect to it.
Use a less violent way of guarding against recursion
2019-09-24 22:08:57 +01:00
Sergio Martins
68a536bb67 Minor renaming, deserialize() no matches serialized() 2019-09-21 16:18:19 +01:00
Sergio Martins
c80a16d2c1 Also use the intermediate representation when serializing 2019-09-21 15:15:44 +01:00
Sergio Martins
65c9693a62 Restoring now reads from the intermediate representation
Only the intermediate representation is filled in from the stream
now. TODO: GUI->intermediate.
2019-09-20 17:24:22 +01:00
Allen Winter
29c41cade3 various - minor spelling, include guard fixes
also clean duplicate includes

Change-Id: I3fdd02fd1d07e7061003dd5fbed9e04b7b9ca928
Reviewed-on: https://codereview.kdab.com/70210
Reviewed-by: Sérgio Martins <sergio@kdab.com>
2019-09-09 17:10:36 +01:00
Sergio Martins
cad7486907 Introduce MainWindowBase
MainWindow is widgets only. MainWindowBase will be used by QtQuick too.
2019-09-04 15:31:55 +01:00
Sergio Martins
46a5a580bc Add LayoutSaver::restoredDockWidgets()
Implemented as a property it's better that the LayoutSaver
doesn't carry state about this. Then we would need to remove dock
widgets from the list if they are deleted. Also not a important
enough feature to be on the DockWidget public interface.
2019-08-28 17:56:18 +01:00