Skip to content

Commit

Permalink
Plots: Add shortcut for the auto-fit action
Browse files Browse the repository at this point in the history
- Also, change shortcuts for save/close all plots to avoid issues in
Eastern European languages.
- Add clarifying comment the usage of timers to set the scrollbar values
after a figure is loaded.
  • Loading branch information
ccordoba12 committed May 14, 2024
1 parent 5a95c07 commit 0f68022
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions spyder/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,12 @@
'plots/previous figure': 'Ctrl+PgUp',
'plots/next figure': 'Ctrl+PgDown',
'plots/save': 'Ctrl+S',
'plots/save all': 'Ctrl+Alt+S',
'plots/save all': 'Alt+Shift+S',
'plots/close': 'Ctrl+W',
'plots/close all': 'Ctrl+Shift+W',
'plots/close all': 'Alt+Shift+W',
'plots/zoom in': "Ctrl++",
'plots/zoom out': "Ctrl+-",
'plots/auto fit': "Ctrl+0",
# -- Files --
'explorer/copy file': 'Ctrl+C',
'explorer/paste file': 'Ctrl+V',
Expand Down
6 changes: 4 additions & 2 deletions spyder/plugins/plots/widgets/figurebrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,9 @@ def load_figure(self, fig, fmt):
if self.current_thumbnail.scalefactor is None:
self.current_thumbnail.scalefactor = self.scalefactor

# Restore scrollbar values
# Restore scrollbar values.
# We need to use timers for this because trying to set those values
# immediately after the figure is loaded doesn't work.
QTimer.singleShot(
20,
lambda: self.verticalScrollBar().setValue(
Expand Down Expand Up @@ -545,7 +547,7 @@ def eventFilter(self, widget, event):
scrollBarV = self.verticalScrollBar()
scrollBarV.setValue(scrollBarV.value() + dy)

# Show in full size or restore the previous one
# Show in full size
elif (
event.type() == QEvent.MouseButtonDblClick
and self.scalefactor != 0
Expand Down
3 changes: 2 additions & 1 deletion spyder/plugins/plots/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PlotsWidgetActions:
# Toggles
ToggleMuteInlinePlotting = 'toggle_mute_inline_plotting_action'
ToggleShowPlotOutline = 'toggle_show_plot_outline_action'
ToggleAutoFitPlotting = 'toggle_auto_fit_plotting_action'
ToggleAutoFitPlotting = 'auto fit'


class PlotsWidgetMainToolbarSections:
Expand Down Expand Up @@ -117,6 +117,7 @@ def setup(self):
icon=self.create_icon("plot.fit_to_pane"),
toggled=self.fit_to_pane,
initial=False,
register_shortcut=True,
)

# Toolbar actions
Expand Down

0 comments on commit 0f68022

Please sign in to comment.