コード例 #1
0
 def _register_actions(self):
     CTRL, ALT, SHIFT = KeyMap.CONTROL, KeyMap.ALT, KeyMap.SHIFT
     routine = actions.Routine
     # These actions are best bound separately to avoid interference with text entry widgets
     actions.add(
         routine(self.cut, 'STUDIO_CUT', 'Cut selected widget', 'studio', CTRL + CharKey('x')),
         routine(self.copy, 'STUDIO_COPY', 'Copy selected widget', 'studio', CTRL + CharKey('c')),
         routine(self.paste, 'STUDIO_PASTE', 'Paste selected widget', 'studio', CTRL + CharKey('v')),
         routine(self.delete, 'STUDIO_DELETE', 'Delete selected widget', 'studio', KeyMap.DELETE),
         routine(self.duplicate, 'STUDIO_DUPLICATE', 'Duplicate selected widget', 'studio', CTRL + CharKey('d')),
     )
     self.shortcuts.add_routines(
         routine(self.undo, 'STUDIO_UNDO', 'Undo last action', 'studio', CTRL + CharKey('Z')),
         routine(self.redo, 'STUDIO_REDO', 'Redo action', 'studio', CTRL + CharKey('Y')),
         # -----------------------------
         routine(self.open_new, 'STUDIO_NEW', 'Open new design', 'studio', CTRL + CharKey('n')),
         routine(self.open_file, 'STUDIO_OPEN', 'Open design from file', 'studio', CTRL + CharKey('o')),
         routine(self.save, 'STUDIO_SAVE', 'Save current design', 'studio', CTRL + CharKey('s')),
         routine(self.save_as, 'STUDIO_SAVE_AS', 'Save current design under a new file', 'studio',
                 CTRL + SHIFT + CharKey('s')),
         routine(self.save_all, 'STUDIO_SAVE_ALL', 'Save all open designs', 'studio', CTRL + ALT + CharKey('s')),
         routine(self.get_help, 'STUDIO_HELP', 'Show studio help', 'studio', KeyMap.F(12)),
         routine(self.settings, 'STUDIO_SETTINGS', 'Open studio settings', 'studio', ALT + CharKey('s')),
         routine(restart, 'STUDIO_RESTART', 'Restart application', 'studio', BlankKey),
         routine(self._on_close, 'STUDIO_EXIT', 'Exit application', 'studio', CTRL + CharKey('q')),
         # ------------------------------
         routine(self.show_all_windows, 'FEATURE_SHOW_ALL', 'Show all feature windows', 'studio',
                 ALT + CharKey('a')),
         routine(self.close_all, 'FEATURE_CLOSE_ALL', 'Close all feature windows', 'studio', ALT + CharKey('x')),
         routine(lambda: self.close_all_on_side('right'),
                 'FEATURE_CLOSE_RIGHT', 'Close feature windows to the right', 'studio', ALT + CharKey('R')),
         routine(lambda: self.close_all_on_side('left'),
                 'FEATURE_CLOSE_LEFT', 'Close feature windows to the left', 'studio', ALT + CharKey('L')),
         routine(self.features_as_docked, 'FEATURE_DOCK_ALL', 'Dock all feature windows', 'studio',
                 ALT + CharKey('d')),
         routine(self.features_as_windows, 'FEATURE_UNDOCK_ALL', 'Undock all feature windows', 'studio',
                 ALT + CharKey('u')),
         routine(self.save_window_positions, 'FEATURE_SAVE_POS', 'Save window positions', 'studio',
                 ALT + SHIFT + CharKey('s')),
         # -----------------------------
         routine(self.close_context, 'CONTEXT_CLOSE', 'Close tab', 'studio', CTRL + CharKey('T')),
         routine(self.close_all_contexts, 'CONTEXT_CLOSE_ALL', 'Close all tabs', 'studio',
                 CTRL + ALT + CharKey('T')),
         routine(self.close_other_contexts, 'CONTEXT_CLOSE_OTHER', 'Close other tabs', 'studio', BlankKey),
         routine(self.close_other_contexts_right, 'CONTEXT_CLOSE_OTHER_RIGHT', 'Close all tabs on the right',
                 'studio', BlankKey),
         # -----------------------------
         routine(self.preview, 'STUDIO_PREVIEW', 'Show preview', 'studio', KeyMap.F(5)),
         routine(self.close_preview, 'STUDIO_PREVIEW_CLOSE', 'Close any preview', 'studio', ALT + KeyMap.F(5)),
         routine(self.reload, 'STUDIO_RELOAD', 'Reload current design', 'studio', CTRL + CharKey('R'))
     )
コード例 #2
0
ファイル: keymap.py プロジェクト: mardukbp/Formation
 def add_routines(self, *routines):
     """
     Utility method that adds the routine to action manager for you
     and then binds the shortcut
     :param routines: a Routine object with the shortcut attribute set
     :return: None
     """
     for routine in routines:
         actions.add(routine)
         if routine.shortcut is None:
             continue
         if routine.key in self.reversed_bindings:
             # if shortcut is already set in bindings just ignore
             # setting shortcuts at this point is only important as defaults
             # just in case we have never bound that shortcut
             routine.shortcut = self.reversed_bindings.get(routine.key)
             continue
         self.bindings[routine.shortcut] = routine.key
         self.reversed_bindings[routine.key] = routine.shortcut