nucleic / enaml

Declarative User Interfaces for Python
http://enaml.readthedocs.io/en/latest/
Other
1.53k stars 130 forks source link

Add dock tab corner buttons #433

Closed frmdstryr closed 3 years ago

frmdstryr commented 3 years ago

For #432

This adds the QDockTitleBar as the corner widget to the QDockTabWidget with a new tabs button.

image

When the button is clicked it opens a context menu that lists all the tabs. When an action is clicked it sets that as the current tab.

image

It also keeps the close, maximize, and restore buttons.

The styling was messed up a little and I added some changes fix that. I'm not sure if that is specfic to my os.. Any help would be appreciated.

MatthieuDartiailh commented 3 years ago

This looks good. I will test locally in the coming days and comment again. One small question though since I am not extremely familiar with that part of the codebase: it looks like you had to add code to handle maximize/restore and close in the custom corner widget which was previously handled by the framework. Is there a way to avoid this by inheriting from the right Qt class that is used as default corner widget ?

frmdstryr commented 3 years ago

I don't think so... the tab widget seems to be treated like a layout similar to a splitter. I think the code was designed to only support maximizing a single dock item per area/window. Maximizing a tab widget is more like maximizing a set of items.

Don't merge this yet as I think the way I'm restoring the layout needs changed.

Antother possible issue, I think this will not properly save and restore if maximized (I'm not using that so I didn't test it).

MatthieuDartiailh commented 3 years ago

I did give this a quick run and indeed the save/restore functionality appear to be broken in your branch, otherwise this seems pretty neat. Let me know if you need help with anything.

codecov-io commented 3 years ago

Codecov Report

Merging #433 (dbf5c57) into master (3e58a3c) will decrease coverage by 0.27%. The diff coverage is 36.36%.

@@            Coverage Diff             @@
##           master     #433      +/-   ##
==========================================
- Coverage   73.72%   73.44%   -0.28%     
==========================================
  Files         312      313       +1     
  Lines       23823    23976     +153     
==========================================
+ Hits        17563    17609      +46     
- Misses       6260     6367     +107     
frmdstryr commented 3 years ago

Alright I think it's working properly now. The problem was when the tab widget was set to the maximize widget it was then no longer in the layout thus the layout saver wasn't including it. The "normal" way it works is the QDockContainer just passes the underlying QDockItem frame around (I think).

The workaround I used was to add a QDockPlaceholder that swaps itself with the tab widget and "saves it's place" in the dock layout when it's maximized and swaps back when restoring. Upon saving and building the layout it delegates to the widget it's holding the place for.

There might be a cleaner way to do this, such as adding a QDockWidgetContainer which behaves similarly to the dock container. or something...

frmdstryr commented 3 years ago

Thanks!