-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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: Add Shortcuts Summary Window #3331
Conversation
@spyder-ide/core-developers should we create a 3.x branch so we don't leave opened PRs without supervision for weeks or months until 3.0 is released? |
@Nodd comments? |
@jitseniesen, it would be nice to hear from you here too :-) |
Looks quite decent to me. Well done @rlaverde ! But I do have a couple of points ...
|
I haven't implemented this, I'm not sure where I should register this shortcut (gui? editor?), and which should be the shortcut (Ctrl+H maybe?)
hmm yes, font and windows size should be calculated from screen size (I'm working on this)
Yes, I added a commit that replace underscores by spaces
Yes ,I also think this should be in another PR, maybe modify iter_shourtcuts() function in spyderlib/config/gui.py
Fixed shortcuts aren't save anywhere, I think this will be another PR too, that add a function iter_fixed_shortcuts() and modify fixed_shortcut to save it in a global variable maybe.
I just add another commit, I deleted LABELS and special case '_' as you advised |
I would make it a global shortcut because the info is about the whole application. Ctrl+H sounds good (I don't think it conflicts with anything), but maybe we want to prefer double modifiers for global shortcuts and keep the single modifier shortcuts as much as possible available for local use. In which case, what about Alt-Shift-H or Ctrl-Shift-K (for keyboard shortcuts)? Ctrl-Shift-H is already taken. I would also add an item in the help menu, otherwise people will never discover this new feature. |
@rlaverde, please merge with master to update your work :-) |
28db7af
to
7e76ab9
Compare
…umn using screen size
I rebase it and also squash some commits
I added a new element as you suggested, and define Meta+F1 as the shortcut |
@rlaverde, thanks a lot! The error on Appveyor is cause by errors with conda, don't worry about it :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried out the code and looked at it in more detail and left some more comments. The one about size is the most important.
@@ -931,6 +931,10 @@ def create_edit_action(text, tr_text, icon): | |||
else: | |||
tut_action = None | |||
|
|||
shortcuts_action = create_action(self, _("Shortcuts Sumary"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix spelling of 'Summary'
def show_shortcuts_dialog(self): | ||
from spyder.widgets.shortcuts import ShortCutsSummaryDialog | ||
dlg = ShortCutsSummaryDialog(None) | ||
dlg.show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think dlg.show() is not necessary because dlg.exec_() already shows the dialog, no?
MAX_FONT_SIZE = 16 | ||
MIN_FONT_SIZE = 8 | ||
|
||
class ShortCutsSummaryDialog(QDialog): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a docstring with some information about the dialog, what it contains and what it looks like.
MIN_FONT_SIZE = 8 | ||
|
||
class ShortCutsSummaryDialog(QDialog): | ||
def __init__(self, parent=None, offset=0, force_float=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last two arguments are not used; can they be deleted?
width, height = self.get_screen_resolution() | ||
font_size = height / 80 | ||
font_size = max(min(font_size, MAX_FONT_SIZE), MIN_FONT_SIZE) | ||
shortcuts_column = (height - 8 * font_size) / (font_size +16) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This computation results in a window that is too tall on my laptop screen, which has:
width = 1366
height = 737
font_size = 9.2125
shortcuts_column = 26.30837878036688
The resulting window has height 771 (and width 1157).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how I could fix this, my laptop have similar dimensions, and the resulting height is 703, there's another way to add elements and avoid oversizing the window?
width = 1366
height = 738
font_size = 9.225
shortcuts_column = 26.3310
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I don't understand where you got the formula for shortcuts_column
from. Maybe I have different fonts installed and the font I end up with has a different size?
Perhaps it's best not to be too smart. Pack all items in four columns of (rougly) equal size, and add a scroll bar if it ends up bigger than the screen.
Alternatively, add the items to the column one-by-one and measure the height of the resulting column; hopefully there is a field .height
in Qt, but I don't know whether this is possible without displaying it on the screen, and it may be too much effort for the first iteration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try the second approach, if that doesn't work I'll implement the other one
"""Shortcut Summary dialog""" | ||
|
||
# TODO: | ||
# calculate windows size from screen size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this TODO comment out of date?
# | ||
# Copyright © 2009- The Spyder Development Team | ||
# Licensed under the terms of the MIT License | ||
# (see spyderlib/__init__.py for details) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace spyderlib by spyder
I forgot to say the most important thing: It does work, and it seems almost ready. By the way, I wonder whether we need to include a close button or something like that. At the moment, the user needs to press |
@jitseniesen For advise of @ccordoba12 I open a new PR to the 3.x branch, I will fix the things that you commented in the new PR |
Fixes #3275
Summary shortcuts implementation
I'm still working on it, there is some things missing: