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
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