Coder Social home page Coder Social logo

Comments (2)

iamsergio avatar iamsergio commented on September 19, 2024

I don't have a better answer than those workarounds, the use case is a bit exotic.

If you have access to DockWidget_p.h you can change d->affinities yourself, if you are aware of possible edge cases (I listed a few).

I'm tempted to allow changing affinities if the dock widget is currently closed.

from kddockwidgets.

bbc131 avatar bbc131 commented on September 19, 2024

Actually, my first idea cannot work. I cannot make the LayoutSaver save the layout of a dockwidget with unique-name "A" and restore it on another dockwidget with unique-name "B". Changing the affinites doesn't help here, forget this idea.

So currently, I have only the second idea, where I replace the unique names (and affinities) within the serialized layout.
This works, I tested it.
But I really don't like to rely on the fact, that I can get the layout in plain-text and find and replace unique names therein.

Generally speaking, the layout is transferred from one set of dockwidgets to another set of dockwidgets, simply using a mapping between the unique names.
The mapping can be applied on the serialized plain-text layout, as already said, but it could also be done right before serialization and restoration.
In any case, the responsibility that there are no conflicts etc. would lie on the user.

I think this could be a feature of the LayoutSaver. It would be a single function which sets a mapping. And if a mapping is set, right after serialization or right before restoration, the unique-names of all dock-widgets and main-windows in LayoutSaver::Layout would then be changed.

layout_saver = LayoutSaver()
# Generalize the layout; Could also use this final names if they are known at this point of time
layout_saver.use_mapping( { "MW_0"  : "MW_x", 
                            "DW_0_A": "DW_x_A", 
                            "DW_0_B": "DW_x_B" } )
generalized_layout = layout_saver.serializeLayout()

...

layout_saver = LayoutSaver()
layout_saver.use_mapping( { "MW_x"  : "MW_1", 
                            "DW_x_A": "DW_1_A", 
                            "DW_x_B": "DW_1_B" } )
layout = layout_saver.restoreLayout(generalized_layout)

This would need to be extended, to have one mapping for the unique-names and one for the affinities.

from kddockwidgets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.