When this is done, it will resolve #780, based on @glenn-sorrentino's work (it doesn't copy it exactly because that was difficult, but I think it gets all of the important stuff).
I think it's nearly there, but there are a few UX things to workout. I decided to tackle the window resizing problem head-on and I think it's nearly solved!
Here's what share mode looks like when you first open it:
And when you click the toggle downloads button:
Now let's hide the history and share some files.
Now I download these files in Tor Browser. (Note, stop sharing after first download is disabled.) See the history indicator?
When I click it, the indicator disappears and the count goes back down to zero.
One change I made here is that, in order to always allow the the user to toggle the history on and off, the info widget is always showing now. But in share mode, it just hides the label from it when it isn't useful.
If the share mode history is visible but receive mode history is hidden, when you flip between the two modes the window now automatically resizes to a reasonable size. In order to make this possible, OnionShareGui now has a adjust_size
slot, that can get triggered by the modes emitting their adjust_size
signals. This will recursively run .adjustSize()
on every widget, while running self.qtapp.processEvents()
at specific times, which seems to give Qt enough information to actually resize properly.
This took some figuring out, and it's still not perfect. Basically, without the processEvents()
calls, the final window didn't get resized to be smaller, even though it's sizeHint said it was supposed to be smaller. But there are still a few situations where things get their size adjusted to be way too small. I actually think carefully placing a processEvents()
call in the right places might fix this, but it would be helpful to be able to consistently reproduce the sizing issues, which I haven't spent time on yet.
Finally, all of the tests pass, including Tor tests. I did a little bit of refactoring of tests, too. I made it so tests_gui_tor.CommonTests
inherits from tests_gui_local.CommonTests
, so now we can avoid a swath of duplicated code. (However, there is still a lot of duplicated code in the tests, and I have some ideas for house to reduce that duplication, but I'm going to do that in a separate PR.) I only actually test the new history indicator in local tests right now, not in Tor tests.
@mig5 this is ready to review. I expect to have to fix a few problems before merging, but I think it's ready to have a second set of eyes on it.
Also, here's what it looks like with several downloads:
Here's a receive mode screenshot with the history indicator:
And here it is again with the history showing:
ux