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: Changes for handling/customizing shortcuts via traitlet variables and a coverage upload fix #621

Open
wants to merge 61 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
b8e75a3
Changes for handling Shortcuts with traitlets in consoleWidget
jsbautista Sep 2, 2024
e200cae
Changes for handling Shortcuts with traitlets in consoleWidget
jsbautista Sep 2, 2024
92549cb
Changes for handling Shortcuts with traitlets in consoleWidget
jsbautista Sep 2, 2024
fce7517
Changes for handling Shortcuts with traitlets in consoleWidget
jsbautista Sep 2, 2024
52ea153
Changes for handling Shortcuts with traitlets in consoleWidget
jsbautista Sep 9, 2024
cfe85aa
Changes for handling Shortcuts with traitlets in consoleWidget
jsbautista Sep 9, 2024
43524ac
Changes for handling Shortcuts with traitlets in consoleWidget
jsbautista Sep 9, 2024
881374a
Apply suggestions from code review
jsbautista Sep 14, 2024
a989ba7
add shortcut save console Widget
jsbautista Sep 16, 2024
5d8cb80
shortcuts frontend
jsbautista Sep 16, 2024
f999c97
add shortcut save console Widget
jsbautista Sep 16, 2024
213eedc
shortcuts frontend
jsbautista Sep 16, 2024
83c5a6a
Fix observe
jsbautista Sep 16, 2024
6f12aa5
Changes for handling Shortcuts with traitlets in consoleWidget
jsbautista Sep 23, 2024
c21cc13
Changes for handling Shortcuts with traitlets in consoleWidget
jsbautista Sep 23, 2024
6410fdc
Changes for handling Shortcuts with traitlets in consoleWidget
jsbautista Sep 29, 2024
6f70a04
shortcuts frontend
jsbautista Sep 29, 2024
5d3c768
Clean code
jsbautista Sep 29, 2024
4152b0f
Clean code
jsbautista Sep 29, 2024
38bfe95
shortcuts for mainWindow
jsbautista Sep 30, 2024
3e28103
shortcuts for mainWindow
jsbautista Sep 30, 2024
1591daf
shortcuts for mainWindow
jsbautista Sep 30, 2024
28465a1
shortcuts for mainWindow
jsbautista Oct 1, 2024
ffaece1
shortcuts for mainWindow
jsbautista Oct 2, 2024
3f74b2e
shortcuts console widget
jsbautista Oct 2, 2024
d1cd581
Delete update shortcut
jsbautista Oct 8, 2024
e027971
Apply suggestions
jsbautista Oct 17, 2024
97fcb75
Merge branch 'jupyter:main' into shortcutTraitlets
jsbautista Oct 17, 2024
6b0bef1
Apply suggestions
jsbautista Oct 17, 2024
891f3a9
Merge branch 'shortcutTraitlets' of https://github.com/jsbautista/qtc…
jsbautista Oct 17, 2024
1b8afd2
add test shortcuts
jsbautista Oct 21, 2024
709ccc6
add test shortcuts
jsbautista Oct 28, 2024
f0ad735
Clean Code
jsbautista Nov 5, 2024
c117dfb
Merge branch 'jupyter:main' into shortcutTraitlets
jsbautista Nov 5, 2024
fb73b90
Clean Code
jsbautista Nov 5, 2024
535130a
Merge branch 'shortcutTraitlets' of https://github.com/jsbautista/qtc…
jsbautista Nov 5, 2024
449c6c7
Clean Code
jsbautista Nov 5, 2024
4a28546
Add linux shortcut
jsbautista Nov 5, 2024
d87bc52
Add linux shortcuts
jsbautista Nov 5, 2024
8e1672e
Add linux shortcuts
jsbautista Nov 5, 2024
b1da48e
Add linux shortcuts
jsbautista Nov 5, 2024
6c0b2f6
Add linux shortcuts
jsbautista Nov 5, 2024
b8f348c
Add linux shortcuts
jsbautista Nov 5, 2024
1c68f9e
Add linux shortcuts
jsbautista Nov 5, 2024
3ce3707
Add linux shortcuts
jsbautista Nov 5, 2024
48ab8e8
Add linux shortcuts
jsbautista Nov 5, 2024
de5a9b7
Add linux shortcuts
jsbautista Nov 5, 2024
18fe59f
Add linux shortcuts
jsbautista Nov 5, 2024
e9fc85e
fix matches mainwindow
jsbautista Nov 5, 2024
0d90363
fix matches mainwindow
jsbautista Nov 5, 2024
4e14958
add test shortcuts
jsbautista Nov 12, 2024
10a4a4e
add test shortcuts
jsbautista Nov 12, 2024
f72bdf4
Fix test shortcuts
jsbautista Nov 12, 2024
4ceaea4
Some code style and imports cleaning
dalthviz Jan 28, 2025
0621ddf
Remove unnecessary shortcut_actions dict attribute
dalthviz Jan 29, 2025
d964d8f
Testing
dalthviz Jan 29, 2025
a1cba1c
CI code coverage step check
dalthviz Jan 29, 2025
689832f
Merge branch 'main' into shortcutTraitlets
dalthviz Jan 29, 2025
d3035e4
Testing
dalthviz Jan 29, 2025
35128e8
Merge branch 'shortcutTraitlets' of https://github.com/jsbautista/qtc…
dalthviz Jan 29, 2025
0a08b7c
Unify test files and add more parametrization
dalthviz Jan 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/linux-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }}
RUNNER_OS: 'ubuntu'
COVERALLS_REPO_TOKEN: XWVhJf2AsO7iouBLuCsh0pPhwHy81Uz1v
COVERALLS_SERVICE_NAME: 'github-actions'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -81,4 +80,4 @@ jobs:
- name: Upload coverage to coveralls
if: matrix.PYTHON_VERSION == '3.8'
shell: bash -el {0}
run: coveralls
run: coveralls --service=github-actions
48 changes: 35 additions & 13 deletions qtconsole/console_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,28 @@ def _font_family_default(self):
# priority (when it has focus) over, e.g., window-level menu shortcuts.
override_shortcuts = Bool(False)

shortcut_print = Unicode('Ctrl+P').tag(config=True)
shortcut_select_all = Unicode('Ctrl+A').tag(config=True)
shortcut_cut = Unicode().tag(config=True)
def _shortcut_cut_default(self):
return QtGui.QKeySequence(QtGui.QKeySequence.Cut).toString()
shortcut_copy = Unicode().tag(config=True)
def _shortcut_copy_default(self):
return QtGui.QKeySequence(QtGui.QKeySequence.Copy).toString()
shortcut_paste = Unicode().tag(config=True)
def _shortcut_paste_default(self):
return QtGui.QKeySequence(QtGui.QKeySequence.Paste).toString()
shortcut_save = Unicode().tag(config=True)
def _shortcut_save_default(self):
return QtGui.QKeySequence(QtGui.QKeySequence.Save).toString()
shortcut_zoom_in = Unicode().tag(config=True)
def _shortcut_zoom_in_default(self):
return QtGui.QKeySequence(QtGui.QKeySequence.ZoomIn).toString()
shortcut_zoom_out = Unicode().tag(config=True)
def _shortcut_zoom_out_default(self):
return QtGui.QKeySequence(QtGui.QKeySequence.ZoomOut).toString()
shortcut_reset_font_size = Unicode('Ctrl+0').tag(config=True)

# ------ Custom Qt Widgets -------------------------------------------------

# For other projects to easily override the Qt widgets used by the console
Expand Down Expand Up @@ -322,56 +344,56 @@ def __init__(self, parent=None, **kw):
# Configure actions.
action = QtWidgets.QAction('Print', None)
action.setEnabled(True)
printkey = QtGui.QKeySequence(QtGui.QKeySequence.Print)
printkey = QtGui.QKeySequence(self.shortcut_print)
if printkey.matches("Ctrl+P") and sys.platform != 'darwin':
# Only override the default if there is a collision.
# Qt ctrl = cmd on OSX, so the match gets a false positive on OSX.
printkey = "Ctrl+Shift+P"
action.setShortcut(printkey)
self.shortcut_print = "Ctrl+Shift+P"
action.setShortcut(self.shortcut_print)
action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
action.triggered.connect(self.print_)
self.addAction(action)
self.print_action = action

action = QtWidgets.QAction('Save as HTML/XML', None)
action.setShortcut(QtGui.QKeySequence.Save)
action.setShortcut(self.shortcut_save)
action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
action.triggered.connect(self.export_html)
self.addAction(action)
self.export_action = action

action = QtWidgets.QAction('Select All', None)
action.setEnabled(True)
selectall = QtGui.QKeySequence(QtGui.QKeySequence.SelectAll)
selectall = QtGui.QKeySequence(self.shortcut_select_all)
if selectall.matches("Ctrl+A") and sys.platform != 'darwin':
# Only override the default if there is a collision.
# Qt ctrl = cmd on OSX, so the match gets a false positive on OSX.
selectall = "Ctrl+Shift+A"
action.setShortcut(selectall)
self.shortcut_select_all = "Ctrl+Shift+A"
action.setShortcut(self.shortcut_select_all)
action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
action.triggered.connect(self.select_all_smart)
self.addAction(action)
self.select_all_action = action

self.increase_font_size = QtWidgets.QAction("Bigger Font",
self,
shortcut=QtGui.QKeySequence.ZoomIn,
shortcut=self.shortcut_zoom_in,
shortcutContext=QtCore.Qt.WidgetWithChildrenShortcut,
statusTip="Increase the font size by one point",
triggered=self._increase_font_size)
self.addAction(self.increase_font_size)

self.decrease_font_size = QtWidgets.QAction("Smaller Font",
self,
shortcut=QtGui.QKeySequence.ZoomOut,
shortcut=self.shortcut_zoom_out,
shortcutContext=QtCore.Qt.WidgetWithChildrenShortcut,
statusTip="Decrease the font size by one point",
triggered=self._decrease_font_size)
self.addAction(self.decrease_font_size)

self.reset_font_size = QtWidgets.QAction("Normal Font",
self,
shortcut="Ctrl+0",
shortcut=self.shortcut_reset_font_size,
shortcutContext=QtCore.Qt.WidgetWithChildrenShortcut,
statusTip="Restore the Normal font size",
triggered=self.reset_font)
Expand Down Expand Up @@ -1146,15 +1168,15 @@ def _context_menu_make(self, pos):

self.cut_action = menu.addAction('Cut', self.cut)
self.cut_action.setEnabled(self.can_cut())
self.cut_action.setShortcut(QtGui.QKeySequence.Cut)
self.cut_action.setShortcut(self.shortcut_cut)

self.copy_action = menu.addAction('Copy', self.copy)
self.copy_action.setEnabled(self.can_copy())
self.copy_action.setShortcut(QtGui.QKeySequence.Copy)
self.copy_action.setShortcut(self.shortcut_copy)

self.paste_action = menu.addAction('Paste', self.paste)
self.paste_action.setEnabled(self.can_paste())
self.paste_action.setShortcut(QtGui.QKeySequence.Paste)
self.paste_action.setShortcut(self.shortcut_paste)

anchor = self._control.anchorAt(pos)
if anchor:
Expand Down
5 changes: 4 additions & 1 deletion qtconsole/frontend_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def _lexer_default(self):
lexer_class = import_item(self.lexer_class)
return lexer_class()

shortcut_copy_raw = Unicode('Ctrl+Shift+C').tag(config=True)

# Emitted when a user visible 'execute_request' has been submitted to the
# kernel from the FrontendWidget. Contains the code to be executed.
executing = QtCore.Signal(object)
Expand Down Expand Up @@ -190,11 +192,12 @@ def __init__(self, local_kernel=_local_kernel, *args, **kw):
# Configure actions.
action = self._copy_raw_action
action.setEnabled(False)
action.setShortcut(QtGui.QKeySequence("Ctrl+Shift+C"))
action.setShortcut(self.shortcut_copy_raw)
action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
action.triggered.connect(self.copy_raw)
self.copy_available.connect(action.setEnabled)
self.addAction(action)
self.copy_raw_action = action

# Connect signal handlers.
document = self._control.document()
Expand Down
Loading
Loading