-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor disable/enable logic for statusbar widgets #7407
Comments
I'm not available for ~2 weeks from now. If nobody gets this done in the meantime I'd gladly take a stab at it. |
Couple more notes:
|
Maybe #4894 can be also included in statusbar refactoring? Or at least lay the groundwork. |
In the initial implementation the widget had `show()` and `hide()` called on it and we used `isVisible()` to tell whether we should update the widget on events. Since the widget showing in the statubar got refactored in https://github.com/qutebrowser/qutebrowser/pull/6448/files the only other widgets that have an `on_tab_changed()` method don't get get `.show()` called on them anymore, than handle that themselves with the help of a `.enabled` attribute. Not 100% sure if it's the right thing to do to lump this settings widget in with them just because it also takes a tab (eg do the history and progress widgets handle showing themselves because they hide when they aren't needed? The setting widget is always visible when configured) but it's not big deal. In general I want to refactor the statusbar to not have explicit knowledge of the widgets it can show (eg have a common abstract class for them with same defaults and helpers). In the meantime this is all pretty self contained. More words on that eventual refactoring here: qutebrowser#7407
In the initial implementation the widget had `show()` and `hide()` called on it and we used `isVisible()` to tell whether we should update the widget on events. Since the widget showing in the statubar got refactored in https://github.com/qutebrowser/qutebrowser/pull/6448/files the only other widgets that have an `on_tab_changed()` method don't get get `.show()` called on them anymore, than handle that themselves with the help of a `.enabled` attribute. Not 100% sure if it's the right thing to do to lump this settings widget in with them just because it also takes a tab (eg do the history and progress widgets handle showing themselves because they hide when they aren't needed? The setting widget is always visible when configured) but it's not big deal. In general I want to refactor the statusbar to not have explicit knowledge of the widgets it can show (eg have a common abstract class for them with same defaults and helpers). In the meantime this is all pretty self contained. More words on that eventual refactoring here: qutebrowser#7407
I am going to take a stab at this. |
I did some spiking over the past weeks and now have a somewhat clear implementation idea. @toofar, as you predicted, writing an integration test for the |
@pylbrecht that's great to hear! I'm looking forward to the sketch. |
Here you go: #8203 Feedback is very much appreciated! |
# DISCLAIMER Super duper WIP changes ahead. --- I just want to see what problems arise when using composition over inheritance, as suggested by @The-Compiler in qutebrowser#7407 (comment). There is a lot of unaddressed ugliness (e.g. `widget.widget` everywhere) in this commit. I just started with moving `QLabel` into `TextBase.widget`. Then fixing failing tests one by one with the *easiest* solution (e.g. `widget.widget`); I even marked one test with `xfail` because I could not quickly figure out why it was failing. My hope is to get a better feel for what belongs to `QWidget` and what belongs to `TextBase` (or its subclasses).
# DISCLAIMER Super duper WIP changes ahead. --- I just want to see what problems arise when using composition over inheritance, as suggested by @The-Compiler in qutebrowser#7407 (comment). There is a lot of unaddressed ugliness (e.g. `widget.widget` everywhere) in this commit. I just started with moving `QLabel` into `TextBase.widget`. Then fixing failing tests one by one with the *easiest* solution (e.g. `widget.widget`); I even marked one test with `xfail` because I could not quickly figure out why it was failing. My hope is to get a better feel for what belongs to `QWidget` and what belongs to `TextBase` (or its subclasses).
# DISCLAIMER Super duper WIP changes ahead. --- I just want to see what problems arise when using composition over inheritance, as suggested by @The-Compiler in qutebrowser#7407 (comment). There is a lot of unaddressed ugliness (e.g. `widget.widget` everywhere) in this commit. I just started with moving `QLabel` into `TextBase.widget`. Then fixing failing tests one by one with the *easiest* solution (e.g. `widget.widget`); I even marked one test with `xfail` because I could not quickly figure out why it was failing. My hope is to get a better feel for what belongs to `QWidget` and what belongs to `TextBase` (or its subclasses).
# DISCLAIMER Super duper WIP changes ahead. --- I just want to see what problems arise when using composition over inheritance, as suggested by @The-Compiler in qutebrowser#7407 (comment). There is a lot of unaddressed ugliness (e.g. `widget.widget` everywhere) in this commit. I just started with moving `QLabel` into `TextBase.widget`. Then fixing failing tests one by one with the *easiest* solution (e.g. `widget.widget`); I even marked one test with `xfail` because I could not quickly figure out why it was failing. My hope is to get a better feel for what belongs to `QWidget` and what belongs to `TextBase` (or its subclasses).
# DISCLAIMER Super duper WIP changes ahead. --- I just want to see what problems arise when using composition over inheritance, as suggested by @The-Compiler in qutebrowser#7407 (comment). There is a lot of unaddressed ugliness (e.g. `widget.widget` everywhere) in this commit. I just started with moving `QLabel` into `TextBase.widget`. Then fixing failing tests one by one with the *easiest* solution (e.g. `widget.widget`); I even marked one test with `xfail` because I could not quickly figure out why it was failing. My hope is to get a better feel for what belongs to `QWidget` and what belongs to `TextBase` (or its subclasses).
# DISCLAIMER Super duper WIP changes ahead. --- I just want to see what problems arise when using composition over inheritance, as suggested by @The-Compiler in qutebrowser#7407 (comment). There is a lot of unaddressed ugliness (e.g. `widget.widget` everywhere) in this commit. I just started with moving `QLabel` into `TextBase.widget`. Then fixing failing tests one by one with the *easiest* solution (e.g. `widget.widget`); I even marked one test with `xfail` because I could not quickly figure out why it was failing. My hope is to get a better feel for what belongs to `QWidget` and what belongs to `TextBase` (or its subclasses).
As evident in #7389, handling of enabling/disabling statusbar widgets is rather error-prone at the moment:
bar.py
needs to have special handling for some widgets which handle their visibility themselves (progress.py
andbackforward.py
).We should instead unify this somehow in the API a statusbar item exposes. One possibility would be to give them a
.enable()
and.disable()
method, which then either just callself.hide()
andself.show()
, or instead setself._enabled
accordingly.First draft:
but the main problem with that approach is that we have a lot of copy-paste-code.
Would be nice to have a common base class for statusbar widgets, but they also inherit from whatever widget they want to display... Possible solutions:
StatusbarItem
subclasses, and have the widget as.widget
instead of inheriting from it directly - somewhat similar to what we did forTabbedBrowser
in e169e21 essentially. Seems like the cleanest option to me.typing.Protocol
to statically check that they are there inbar.py
somehowmiscwidgets.WrapperLayout
like we do for browser tabs, so that statusbar items are widgets, but with our own API instead of theQWidget
one.cc @tomiesz @Nicholas42 in case you're interested!
The text was updated successfully, but these errors were encountered: