Skip to content

Commit

Permalink
Merge pull request #284 from ales-erjavec/action-shortcuts-hidden-men…
Browse files Browse the repository at this point in the history
…ubar

[FIX] Widget shortcuts now work even if menu bar is not visible
  • Loading branch information
markotoplak authored Feb 14, 2025
2 parents 6de8d8f + e882983 commit 950fc29
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions orangewidget/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ def __new__(cls, *args, captionTitle=None, **kwargs):
self.__statusbar_action = None # type: Optional[QAction]
self.__menubar_action = None
self.__menubar_visible_timer = None
self.__toggle_control_area_action = None

# this action is enabled by the canvas framework
self.__help_action = QAction(
Expand Down Expand Up @@ -402,8 +403,6 @@ def __new__(cls, *args, captionTitle=None, **kwargs):
self.__visual_settings_action.setEnabled(True)
self.__visual_settings_action.setVisible(True)

self.addAction(self.__help_action)

self.__copy_action = QAction(
"Copy to Clipboard", self, objectName="action-copy-to-clipboard",
shortcut=QKeySequence.Copy, enabled=False, visible=False
Expand Down Expand Up @@ -530,7 +529,7 @@ def __new__(cls, *args, captionTitle=None, **kwargs):
helpaction.menu().addAction(self.__quick_help_action)

if self.__splitter is not None and self.__splitter.count() > 1:
action = QAction(
self.__toggle_control_area_action = action = QAction(
"Show Control Area", self,
objectName="action-show-control-area",
shortcut=QKeySequence("Ctrl+Shift+D"),
Expand All @@ -545,6 +544,21 @@ def __new__(cls, *args, captionTitle=None, **kwargs):
if self.__menubar_action is not None:
viewaction.menu().addAction(self.__menubar_action)

actions = (
self.__help_action,
self.__report_action,
self.__save_image_action,
self.__reset_action,
self.__visual_settings_action,
self.__copy_action,
self.__minimize_action,
self.__close_action,
self.__menubar_action,
self.__quick_help_action,
self.__toggle_control_area_action,
)
self.addActions(list(filter(None, actions)))

if self.controlArea is not None:
# Otherwise, the first control has focus
self.controlArea.setFocus(Qt.OtherFocusReason)
Expand Down

0 comments on commit 950fc29

Please sign in to comment.