ijgnd / anki__browser_side_by_side__horizontal_split

2 stars 1 forks source link

Causes wrong positioning of card/note switch in 2.1.45 #5

Closed kleinerpirat closed 3 years ago

kleinerpirat commented 3 years ago

Hi ijgnd!

Just a little heads-up about a layout issue that will take effect with Anki 2.1.45. As @RumovZ pointed out on the forum, the side-by-side view of your add-on causes the new card/note switch (qt/aqt/switch.py) to be positioned on top of the search bar instead of to the left of it.

With side-by-side view:

image

What it should look like:

image

I can only guess it stems from Anki using a grid layout instead of a QHBoxLayout for that upper part. Do you think this has to be solved within Anki itself or can you work around it?

Thank you for this great add-on and all the best!

RumovZ commented 3 years ago

Wouldn't be a big deal to use a QHBoxLayout instead. I wasn't aware that using a grid would complicate things for add-ons.

ijgnd commented 3 years ago

Thanks for your posts.

The searchbar has always been in a gridlayout in 2.1 afaik. Some of my add-ons - including this one and e.g. my BetterSearch rearrange the contents of the gridlayout based on the default layout of older anki versions. Adding the new c/n switch breaks my assumptions and thus my add-ons. I think I need to adjust my add-ons.

I wonder if there's anything that could be done to make such modifications more future-proof. But if you as an add-on author want to force a layout of elements in a qgridlayout you'll always try to set them exactly which means that you'll have to handle all existing elements which will break once a new element like a c/n switch is introduced? I think a gui_hook that passed/collected elements for the qgridlayout would only solve some cases?

@kleinerpirat: If for the side-by-side add-on you change the setting when narrow move search bar to extra line to false the problem should disappear? At least it does for me. If this also fixes it for you I'll just remove the effect of this setting for .45+

@rumovz: The c/n switch is a great addition to Anki - It's very useful and makes the card-note distinction much more prominent which I think should also help beginners. Thank you very much for it.

kleinerpirat commented 3 years ago

If for the side-by-side add-on you change the setting when narrow move search bar to extra line to false the problem should disappear?

This fixed the issue for me too. Thank you!