Skip to content
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

PR: Generate widgets' toolbars from the actions in their context menu & make toolbars toggleable #2706

Closed
wants to merge 16 commits into from

Conversation

d1manson
Copy link
Contributor

the below description has been updated several times...

This is one of the things discussed in issue #2353.
Also relevant is: pending pull #2288 and merged pull #2426.

TODO:

  • basic class/factory methods to make the context-menu => togglable-toolbar possible
  • refactor File Explorer widget with new system
  • refactor Outline Explorer widget with new system
  • refactor Help (previously known as "Object Inspector") widget with new system - requires support for multiple toolbar "modes" (qtstacked) and combo boxes (custom ComboAction, subclassed from QWidgetAction)...there are a few bugs still with the OI.
  • refactor Variable Explorer widget with new system - a more difficult job, lets leave it for now
    apply to other widgets?

I have created a helper widget called WidgetInnerToolbar and a utility function for constructing instances of that widget from a context menu - context_menu_to_toolbar. For the Object Inspector I had to add some more features, such as support for switching between multiple toolbar "modes" and supporting arbitrary subclasses of QWidgetAction, such as the custom made ComboAction.

The idea is that WidgetInnerToolbar can be registered as a nearly-proper toolbar using the new register_toolbar method of SpyderPluginMixin. It then takes part in the global toggling on/off of toolbars. It also seems a lot neater to collect together all the actions in one place (the context-menu) and then use that to populate other places (the toolbar). I decided to do it this way round because in all cases the widgets seemed to have a "main child" widget that already had its own context-menu, so it seemed easier to add to that and then build the toolbar from the amalgamated context-menu.

This is what the file explorer's context-menu and toolbar look like (note the name|size|type bit is not actually part of the toolbar -I should probably have cropped it out here):
image

This is what the outline explorer looks like (with toolbar hidden/showing):

image

And this is the help widget's toolbar and context menu. Note there are two modes: source/plain-text and rich-text.
image

@ccordoba12
Copy link
Member

@goanpeca, would you mind to review this one?

@d1manson
Copy link
Contributor Author

Since this PR is already touching quite a few files I'd prefer to stop here if possible and leave the other widgets for later - both the variable explorer and object inspector are more messy to deal with, but should be reasonably self-contained projects.

@goanpeca
Copy link
Member

I will, but on the weekend!

@goanpeca goanpeca self-assigned this Sep 22, 2015
@d1manson
Copy link
Contributor Author

d1manson commented Oct 2, 2015

I got a bit carried away and decided to tackle the object inspector. It basically works now, with a few minor bugs in the history-combo interations. I have updated the original post with a new description and more screenshots to explain the state of this PR.

In terms of fixing the remaining OI bugs, I guess I will aim to do that in the near future, but I should say that I never quite understood all the expected behaviors of the original widget...both the code itself and the UX were a bit all-over-the-place...which is to say that maybe a more general refactor of the OI is merited (but not something I want to do here if possible).

@goanpeca, @ccordoba12 - if you have a chance to try this out and give me some feedback that would be good...As I said before, this PR touches quite a lot of files (11 currently), a few in fairly major ways (the three widgets) so it would be a great to get it processed quickly-ish..although that never ends up being easy I guess.

@d1manson d1manson force-pushed the context-menu-meets-toolbar branch 3 times, most recently from b3615a4 to ab5be14 Compare October 12, 2015 10:24
@ccordoba12
Copy link
Member

@d1manson, tests are failing for this one, please review the Travis log :-)

@d1manson
Copy link
Contributor Author

@ccordoba12 travis is happier now, although fix was a bit hacky.

Note that I'm not expecting you guys to be 100% happy with the code as it is, there are a couple of hacky aspects to it (e.g. import statements within functions, where global import wasn't working..not a big deal performance-wise because the functions should only be called a handful of times at startup, but still rather ugly code).

Mostly I was hoping for feedback on the functionality and possibly some suggestions on improving the way I've structured the code.

@goanpeca
Copy link
Member

goanpeca commented Dec 6, 2015

@d1manson can you rebase this?

@d1manson
Copy link
Contributor Author

d1manson commented Dec 7, 2015

@goanpeca I've rebased.
Travis is passing but AppVeyor is giving a meaningless Command exited with code 1 error.

@goanpeca
Copy link
Member

goanpeca commented Dec 7, 2015

Thanks, @ccordoba12 can you take a look?

@ccordoba12
Copy link
Member

The error is real (I rebuilt the PR to verify that! :-)

The error code means that codeeditor just crashes when running its test. So you need to run the test locally to see what's happening.

@d1manson
Copy link
Contributor Author

d1manson commented Dec 8, 2015

@ccordoba12 I've installed 64 bit conda and setup a python 3.5 environment. When I run the command:
python "spyderlib\widgets\sourcecode\codeeditor.py"
It just launches a standalone instance of an editor widget. This is the same whether I am on master branch or my PR branch. Other tests (such as ...\base.py) run and terminate within a second or two (without complaint).

What am I doing wrong?
P.S. I'm a bit of a noob when it comes to CI testing.

@d1manson
Copy link
Contributor Author

I dunno what was wrong, but following the latest rebase it's now working again.

@goanpeca goanpeca changed the title Generate widgets' toolbars from the actions in their context menu & make toolbars toggleable PR: Generate widgets' toolbars from the actions in their context menu & make toolbars toggleable Jan 27, 2016
@goanpeca
Copy link
Member

@d1manson again can you merge with master (or rebase..) there seem to be some conflicts...

Also what is the status of this PR?

@ccordoba12 ccordoba12 modified the milestones: v3.1, v3.0 Jan 27, 2016
@ccordoba12 ccordoba12 removed this from the todo milestone Sep 21, 2017
@ccordoba12
Copy link
Member

Closing because (although interesting) we don't plan to go for this.

@ccordoba12 ccordoba12 closed this Sep 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants