Commit Graph

1157 Commits

Author SHA1 Message Date
Sergio Martins
670da82164 DebugWindow: Add an option to resize the window by QSize(1, 1)
For debug purposes. Resizing the window fixes some layouting issues
in FloatingWindows when restoring a layout with relative sizes,
need to find out why
2020-02-25 23:08:16 +00:00
Sergio Martins
3f732e91a7 Minor refactoring 2020-02-25 22:53:28 +00:00
Sergio Martins
a286432176 DebugWindow: Add option to invoke "redistributeSpace"
for testing purposes
2020-02-25 22:41:11 +00:00
Sergio Martins
1d7c0316ab LayoutSaver: Fix applying factor to position
Was adding instead of multiplying, typo...
2020-02-25 21:18:36 +00:00
Sergio Martins
564a7091e1 LayoutSaver: Fix off-by-ones case with relative-restoring
If the window didn't change size nothing should happen
2020-02-25 20:00:46 +00:00
Sergio Martins
ca211f2494 LayoutSaver: Add an option to restore in relative sizes
and not touching the main window geometry.

The option is not exposed yet, there's a layouting bug to fix first.
2020-02-25 19:06:43 +00:00
Sergio Martins
435e61288e LayoutSaver: Remove the QDataStream serializer
Keep only the deserializer, for now, so we can convert old layouts
to json.
2020-02-24 15:22:44 +00:00
Sergio Martins
822f48ccdd DebugWindow: Add a way to update from old layouts to json 2020-02-24 15:20:13 +00:00
Sergio Martins
6fb0694aab LayoutSaver: Replace saveToDisk() with saveToFile(jsonFilename)
Same for restore.
This is better API as LayoutSaver shouldn't be concerned about
QSettings. It also assumed the user only had a single layout, which
is normally not the case.

And finally, storing escaped json in .ini files is not very elegant.
2020-02-24 15:10:12 +00:00
Sergio Martins
bab0ff085e LayoutSaver now saves/loads in JSON format
This makes it easier to extend the format without being worried
about adding version checks all over the code
2020-02-24 14:57:03 +00:00
Sergio Martins
5b0eb93cda LayoutSaver: Add a json to/from methods
Still not being used by public api though.
2020-02-24 14:45:06 +00:00
Sergio Martins
758b4de5cc LayoutSaver: Fix serializing QSize and QRect to json
Failed silently to null instead
2020-02-24 14:40:38 +00:00
Sergio Martins
b78becfc01 Fix typo in json serialization 2020-02-24 13:39:48 +00:00
Sergio Martins
15d9f074fa Fix converting Item to json 2020-02-24 13:38:54 +00:00
Sergio Martins
fdb95e344a Fix converting Placeholder to json
Only dump the floating window index if we're in a floating window
2020-02-24 13:31:38 +00:00
Sergio Martins
69ada1bdad LayoutSaver: Add to/from variant map methods
To make it easy to use json instead of QDataStream
2020-02-23 22:55:30 +00:00
Sergio Martins
950ef943b7 LayoutSaver: Save the top-levels screen number
So we can be smarter when restoring layouts with different screen
setups
2020-02-20 18:39:06 +00:00
Sergio Martins
21660d9fc5 Remove unused method 2020-02-20 18:19:41 +00:00
Sergio Martins
b0525ed1f1 LayoutSaver: Save the list of screens and their properties
So we can be smarter when restoring on different screen setups
2020-02-20 17:50:28 +00:00
Sergio Martins
e7661cca91 LayoutSaver: serialize/deserialize the screenSize and layoutSize too 2020-02-20 15:41:00 +00:00
Sergio Martins
2458b1c0f8 Add a way for the intermediate format to know it's version
It's a pain to pass the Layout or the version all the way
down the chain, so just add a static method
2020-02-20 14:56:51 +00:00
Sergio Martins
efdd8f9f81 LayoutSaver: Also store the screen and layout size
So when restoring we can restore relative to that
2020-02-20 14:14:06 +00:00
Sergio Martins
27e53ca68d Add missing reserve 2020-02-20 13:39:25 +00:00
Sergio Martins
63da84e343 LayoutSaver: Accept serialization formats with lower version 2020-02-20 13:36:10 +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
61303b14a7 Prophylaxis against a widget resizing itself while we're restoring
During a layout restore we should ignore a widget wanting to resize
itself by its initiative, as we don't have the anchors to push yet

Layouting is adjusted at the end of the restore.
2020-02-19 14:28:22 +00:00
Sergio Martins
7a2aa43b2d Fuzzer: Add SaveLayout and RestoreLayout operations too 2020-02-19 14:12:44 +00:00
Sergio Martins
cf0b8fd029 Fix build with Qt 5.9, SH_Widget_Animation_Duration is too new 2020-02-18 11:16:49 +00:00
Sergio Martins
a35e088988 Only allow to re-order tabs if we have more than 1
Otherwise it's confusing

Fixes: #27
2020-02-18 11:06:04 +00:00
Sergio Martins
232e96ee0e Fix crash when detaching tabs and the move animation is still enabled
Qt bug, but workaround here.
2020-02-18 10:36:16 +00:00
Sergio Martins
b43081851f example: Add an option to show a non-closable dock widget
Passing -n to the example will make the dock widget #0 non-closable
2020-02-17 21:20:43 +00:00
Sergio Martins
10621f3b4a Allow tabs to have a close button
Can be tested with kddockwidgets_example -c

Disabled by default, as I'm not 100% happy with it:
A dock widget with the "non closable" attribute will still show
the x button on the tab bar. Clicking on it won't do anything but
doesn't look so nice. Qt doesn't allow to have the close buttons only
in some tabs.

Fixes #26
2020-02-17 20:45:54 +00:00
Sergio Martins
723491d9b6 Fix app not quiting whent here's a floating NonClosable window
Since 5.14, after closing the main window, qApp sends a close
event to all top-levels, and only closes app if the event
is not ignored.
2020-02-15 18:06:21 +00:00
Sergio Martins
7d56860325 Don't allow to close NonClosable dock widgets via Alt+F4 2020-02-11 17:56:32 +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
59bb0d8e71 FloatingWindow now receives MainWindow as argument
Instead of a generic QWidget. Only works with main window so
let's just use the right type
2020-02-09 18:24:37 +00:00
Sergio Martins
37fe065bcf FloatingWindow: Receive MainWindow as the parent
Better for readability
2020-02-09 18:14:36 +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
Sergio Martins
4c15335339 Don't access MultiSplitter methods after its dtor ran
~MultiSplitter dtor eventually triggers Frame::setDropArea()
which dereferences the MultiSplitter. Instead, keep the connection
in a QMetaObject::Connection, so we can disconnect without needing
the MultiSplitter
2020-01-29 16:07:52 +00:00
Sergio Martins
6da1a65591 Fix build with gcc -Werror=type-limits 2020-01-29 15:27:11 +00:00
Sergio Martins
6338e6b03e Fix my Werror clang build 2020-01-29 15:17:01 +00:00
Sergio Martins
48ef73d6d3 cmake: Rename OPTION_ASAN_SUPPORT to OPTION_SANITIZER_SUPPORT
As it can work with any type of sanitizers
2020-01-29 15:04:51 +00:00
Sergio Martins
52e53c4fd9 fuzzer: Trim the failing test 2020-01-29 15:04:51 +00:00
Sergio Martins
81c180fbfd Debug++ 2020-01-27 22:12:28 +00:00
Sergio Martins
07f9e9a0df Fix fuzzer testcase failing/2.json
And renamed it to 17.json, as we already have an unrelated 2.json.

The removed check isn't needed, as we'll check again when we
finish restoring the placeholder. It was also a false-positive
warning sometimes because boundPositionForAnchor() would fail
since the "anchors following" wasnt initialized yet, as we do
a clearAnchorsFollowing while restoring the placeholder
2020-01-27 18:47:37 +00:00
Sergio Martins
6dd8a0cda1 Debug++ 2020-01-27 18:35:01 +00:00
Sergio Martins
25f3e83fc3 Debug++ 2020-01-27 18:30:13 +00:00