Exemplo n.º 1
0
    def activate(self):
        self._dock = None
        self._find_results_widget = None
        self._replace = False
        mnu_edit = window.get_menu(_('&Edit'))
        action_before = mnu_edit.actions()[-1]
        sep = QtWidgets.QAction(mnu_edit)
        sep.setSeparator(True)
        mnu_edit.insertAction(action_before, sep)

        # find
        self.afind = QtWidgets.QAction(mnu_edit)
        self.afind.setText(_('Find in path'))
        self.afind.setToolTip(_('Find in path'))
        self.afind.setIcon(QtGui.QIcon.fromTheme('edit-find'))
        self.afind.setShortcut(shortcuts.get(
            'Find in path', _('Find in path'), 'Ctrl+Shift+F'))
        self.afind.triggered.connect(self._on_find_triggered)
        mnu_edit.insertAction(action_before, self.afind)

        # replace
        self.areplace = QtWidgets.QAction(mnu_edit)
        self.areplace.setIcon(QtGui.QIcon.fromTheme('edit-find-replace'))
        self.areplace.setText(_('Replace in path'))
        self.areplace.setToolTip(_('Replace in path'))
        self.areplace.setShortcut(shortcuts.get(
            'Replace in path', _('Replace in path'), 'Ctrl+Shift+H'))
        self.areplace.triggered.connect(self._on_replace_triggered)
        mnu_edit.insertAction(action_before, self.areplace)

        sep = QtWidgets.QAction(mnu_edit)
        sep.setSeparator(True)
        mnu_edit.insertAction(action_before, sep)

        api.window.add_actions(mnu_edit.actions())
Exemplo n.º 2
0
 def apply_preferences(self):
     new_patterns = ';'.join(utils.get_ignored_patterns())
     if self._last_ignore_patterns != new_patterns:
         self._last_ignore_patterns = new_patterns
         self.view.clear_ignore_patterns()
         self.view.add_ignore_patterns(self.get_ignored_patterns())
         self.view.set_root_path(api.project.get_current_project())
     self.view.context_menu.update_show_in_explorer_action()
     self._tab_bar_action_show_in_explorer.setText(
         _('Show in %s') % FileSystemContextMenu.get_file_explorer_name())
     self._update_workspaces_menu()
     self.action_goto_anything.setShortcut(shortcuts.get(
         'Goto anything', _('Goto anything'), 'Ctrl+P'))
     self.action_goto_symbol.setShortcut(shortcuts.get(
         'Goto symbol', _('Goto symbol'), 'Ctrl+R'))
     self.action_goto_symbol_in_project.setShortcut(shortcuts.get(
         'Goto symbol in project', _('Goto symbol in project'),
         'Ctrl+Shift+R'))
     self.action_goto_line.setShortcut(shortcuts.get(
         'Goto line', _('Goto line'), 'Ctrl+G'))
     self._update_templates_menu()
     menu = api.window.get_menu(_('&Goto'))
     for action in menu.actions():
         action.setEnabled(settings.indexing_enabled())
     tab = api.editor.get_current_editor()
     self.action_goto_line.setEnabled(tab is not None)
     if self.main_window.app.flg_force_indexing:
         self._reindex_all_projects()
     if not settings.indexing_enabled():
         for indexor in self._indexors:
             indexor.cancel()
Exemplo n.º 3
0
def test_get_all_texts():
    assert len(shortcuts.get_all_texts()) == 0
    assert shortcuts.get('My action', 'My action',
                         'Ctrl+Alt+Delete') == 'Ctrl+Alt+Delete'
    assert shortcuts.get('My action2', 'My action',
                         'Ctrl+Alt+Return') == 'Ctrl+Alt+Return'
    assert len(shortcuts.get_all_texts()) == 2
Exemplo n.º 4
0
 def apply_preferences(self):
     new_patterns = ';'.join(utils.get_ignored_patterns())
     if self._last_ignore_patterns != new_patterns:
         self._last_ignore_patterns = new_patterns
         self.view.clear_ignore_patterns()
         self.view.add_ignore_patterns(self.get_ignored_patterns())
         self.view.set_root_path(api.project.get_current_project())
     self.view.context_menu.update_show_in_explorer_action()
     self._tab_bar_action_show_in_explorer.setText(
         _('Show in %s') % FileSystemContextMenu.get_file_explorer_name())
     self._update_workspaces_menu()
     self.action_goto_file.setShortcut(
         shortcuts.get('Goto file', _('Goto file'), 'Ctrl+T'))
     self.action_goto_symbol.setShortcut(
         shortcuts.get('Goto symbol', _('Goto symbol'), 'Ctrl+R'))
     self.action_goto_symbol_in_project.setShortcut(
         shortcuts.get('Goto symbol in project',
                       _('Goto symbol in project'), 'Ctrl+Shift+R'))
     self.action_goto_line.setShortcut(
         shortcuts.get('Goto line', _('Goto line'), 'Ctrl+G'))
     self._update_templates_menu()
     menu = api.window.get_menu(_('&Goto'))
     for action in menu.actions():
         action.setEnabled(settings.indexing_enabled())
     tab = api.editor.get_current_editor()
     self.action_goto_line.setEnabled(tab is not None)
     if self.main_window.app.flg_force_indexing:
         self._reindex_all_projects()
     if not settings.indexing_enabled():
         for indexor in self._indexors:
             indexor.cancel()
Exemplo n.º 5
0
def test_restore_defaults():
    shortcuts.get('My action', 'My action', 'Ctrl+Alt+Delete')
    shortcuts.update('My action', 'My action', 'Ctrl+Backspace')
    shortcuts.save()
    assert shortcuts.get('My action', 'My action',
                         'Ctrl+Alt+Delete') == 'Ctrl+Backspace'
    shortcuts.restore_defaults()
    assert shortcuts.get('My action', 'My action',
                         'Ctrl+Alt+Delete') == 'Ctrl+Alt+Delete'
Exemplo n.º 6
0
def test_load_save():
    assert shortcuts.get('My action', 'My action',
                         'Ctrl+Alt+Delete') == 'Ctrl+Alt+Delete'
    shortcuts.update('My action', 'My action', 'Ctrl+Backspace')
    assert shortcuts.get('My action', 'My action',
                         'Ctrl+Alt+Delete') == 'Ctrl+Backspace'
    shortcuts.load()
    assert shortcuts.get('My action', 'My action',
                         'Ctrl+Alt+Delete') == 'Ctrl+Alt+Delete'
    shortcuts.update('My action', 'My action', 'Ctrl+Backspace')
    assert shortcuts.get('My action', 'My action',
                         'Ctrl+Alt+Delete') == 'Ctrl+Backspace'
    shortcuts.save()
    assert shortcuts.get('My action', 'My action',
                         'Ctrl+Alt+Delete') == 'Ctrl+Backspace'
Exemplo n.º 7
0
    def _setup_locator(self):
        menu = api.window.get_menu(_('&Goto'))
        self.action_goto_anything = menu.addAction(_('Goto anything...'))
        self.action_goto_anything.setShortcut(shortcuts.get(
            'Goto anything', _('Goto anything'), 'Ctrl+P'))
        self.main_window.addAction(self.action_goto_anything)
        self.action_goto_anything.triggered.connect(self._goto_anything)

        menu.addSeparator()

        self.action_goto_symbol = menu.addAction(_('Goto symbol...'))
        self.action_goto_symbol.setShortcut(shortcuts.get(
            'Goto symbol', _('Goto symbol'), 'Ctrl+R'))
        self.main_window.addAction(self.action_goto_symbol)
        self.action_goto_symbol.triggered.connect(self._goto_symbol)

        self.action_goto_symbol_in_project = menu.addAction(
            _('Goto symbol in project...'))
        self.action_goto_symbol_in_project.setShortcut(shortcuts.get(
            'Goto symbol in project', _('Goto symbol in project'),
            'Ctrl+Shift+R'))
        self.main_window.addAction(self.action_goto_symbol_in_project)
        self.action_goto_symbol_in_project.triggered.connect(
            self._goto_symbol_in_project)

        self.action_goto_line = menu.addAction(_('Goto line'))
        self.action_goto_line.setShortcut(shortcuts.get(
            'Goto line', _('Goto line'), 'Ctrl+G'))
        self.main_window.addAction(self.action_goto_line)
        self.action_goto_line.triggered.connect(self._goto_line)

        menu.addSeparator()

        indexing_menu = menu.addMenu('Indexing')
        action = indexing_menu.addAction('Update project(s) index')
        action.setToolTip('Update project index database...')
        action.triggered.connect(self._reindex_all_projects)
        action = indexing_menu.addAction('Force full project(s) indexation')
        action.setToolTip('Invalidate project index and force a full '
                          'reindexation...')
        action.triggered.connect(self._force_reindex_all_projects)
Exemplo n.º 8
0
    def _setup_locator(self):
        menu = api.window.get_menu(_('&Goto'))
        self.action_goto_file = menu.addAction(_('Goto file...'))
        self.action_goto_file.setShortcut(
            shortcuts.get('Goto file', _('Goto file'), 'Ctrl+T'))
        self.main_window.addAction(self.action_goto_file)
        self.action_goto_file.triggered.connect(self._goto_anything)

        menu.addSeparator()

        self.action_goto_symbol = menu.addAction(_('Goto symbol...'))
        self.action_goto_symbol.setShortcut(
            shortcuts.get('Goto symbol', _('Goto symbol'), 'Ctrl+R'))
        self.main_window.addAction(self.action_goto_symbol)
        self.action_goto_symbol.triggered.connect(self._goto_symbol)

        self.action_goto_symbol_in_project = menu.addAction(
            _('Goto symbol in project...'))
        self.action_goto_symbol_in_project.setShortcut(
            shortcuts.get('Goto symbol in project',
                          _('Goto symbol in project'), 'Ctrl+Shift+R'))
        self.main_window.addAction(self.action_goto_symbol_in_project)
        self.action_goto_symbol_in_project.triggered.connect(
            self._goto_symbol_in_project)

        self.action_goto_line = menu.addAction(_('Goto line'))
        self.action_goto_line.setShortcut(
            shortcuts.get('Goto line', _('Goto line'), 'Ctrl+G'))
        self.main_window.addAction(self.action_goto_line)
        self.action_goto_line.triggered.connect(self._goto_line)

        menu.addSeparator()

        indexing_menu = menu.addMenu('Indexing')
        action = indexing_menu.addAction('Update project(s) index')
        action.setToolTip('Update project index database...')
        action.triggered.connect(self._reindex_all_projects)
        action = indexing_menu.addAction('Force full project(s) indexation')
        action.setToolTip('Invalidate project index and force a full '
                          'reindexation...')
        action.triggered.connect(self._force_reindex_all_projects)
Exemplo n.º 9
0
    def activate(self):
        self._dock = None
        self._find_results_widget = None
        self._replace = False
        mnu_edit = window.get_menu(_('&Edit'))
        action_before = mnu_edit.actions()[-1]
        sep = QtWidgets.QAction(mnu_edit)
        sep.setSeparator(True)
        mnu_edit.insertAction(action_before, sep)

        # find
        self.afind = QtWidgets.QAction(mnu_edit)
        self.afind.setText(_('Find in path'))
        self.afind.setToolTip(_('Find in path'))
        self.afind.setIcon(QtGui.QIcon.fromTheme('edit-find'))
        self.afind.setShortcut(
            shortcuts.get('Find in path', _('Find in path'), 'Ctrl+Shift+F'))
        self.afind.triggered.connect(self._on_find_triggered)
        mnu_edit.insertAction(action_before, self.afind)

        # replace
        self.areplace = QtWidgets.QAction(mnu_edit)
        self.areplace.setIcon(QtGui.QIcon.fromTheme('edit-find-replace'))
        self.areplace.setText(_('Replace in path'))
        self.areplace.setToolTip(_('Replace in path'))
        self.areplace.setShortcut(
            shortcuts.get('Replace in path', _('Replace in path'),
                          'Ctrl+Shift+H'))
        self.areplace.triggered.connect(self._on_replace_triggered)
        mnu_edit.insertAction(action_before, self.areplace)

        sep = QtWidgets.QAction(mnu_edit)
        sep.setSeparator(True)
        mnu_edit.insertAction(action_before, sep)

        api.window.add_actions(mnu_edit.actions())
Exemplo n.º 10
0
 def reset(self):
     # force refresh
     shortcuts.load()
     names = shortcuts.get_all_names()
     texts = shortcuts.get_all_texts()
     self._ui.table.clearContents()
     self._ui.table.setRowCount(len(names))
     for row, (action, text) in enumerate(zip(names, texts)):
         name_item = QtWidgets.QTableWidgetItem()
         name_item.setText(text)
         name_item.setData(QtCore.Qt.UserRole, action)
         self._ui.table.setItem(row, 0, name_item)
         edit = QtWidgets.QKeySequenceEdit()
         edit.setKeySequence(QtGui.QKeySequence(
             shortcuts.get(action, text, None)))
         edit.keySequenceChanged.connect(self.check_for_conflicts)
         edit.setObjectName(action)
         self._ui.table.setCellWidget(row, 1, edit)
Exemplo n.º 11
0
    def _apply_editor_shortcuts(editor):
        editor.action_undo.setShortcut(shortcuts.get(
            'Undo', _('Undo'), 'Ctrl+Z'))
        editor.action_redo.setShortcut(shortcuts.get(
            'Redo', _('Redo'), 'Ctrl+Y'))
        editor.action_copy.setShortcut(shortcuts.get(
            'Copy', _('Copy'), 'Ctrl+C'))
        editor.action_cut.setShortcut(shortcuts.get(
            'Cut', _('Cut'), 'Ctrl+X'))
        editor.action_paste.setShortcut(shortcuts.get(
            'Paste', _('Paste'), 'Ctrl+V'))
        editor.action_duplicate_line.setShortcut(shortcuts.get(
            'Duplicate line', _('Duplicate line'), 'Ctrl+D'))
        editor.action_goto_line.setShortcut(shortcuts.get(
            'Goto line', _('Goto line'), 'Ctrl+G'))
        try:
            p = editor.panels.get('SearchAndReplacePanel')
        except KeyError:
            _logger().debug('no SearchAndReplacePanel on widget %r', editor)
        else:
            p.actionSearch.setShortcut(shortcuts.get(
                'Find', _('Find'), 'Ctrl+F'))
            p.actionActionSearchAndReplace.setShortcut(
                shortcuts.get('Replace', _('Replace'), 'Ctrl+H'))
            p.actionFindNext.setShortcut(shortcuts.get(
                'Find next', _('Find next'), 'F3'))
            p.actionFindPrevious.setShortcut(shortcuts.get(
                'Find previous', _('Find previous'), 'Shift+F3'))
        try:
            p = editor.panels.get('FoldingPanel')
        except KeyError:
            _logger().debug('no FoldingPanel on widget %r', editor)
        else:
            p.action_collapse.setShortcut(shortcuts.get(
                'Folding: collapse', _('Folding: collapse'), 'Shift+-'))
            p.action_expand.setShortcut(shortcuts.get(
                'Folding: expand', _('Folding: expand'), 'Shift++'))
            p.action_collapse_all.setShortcut(shortcuts.get(
                'Folding: collapse all', _('Folding: collapse all'),
                'Ctrl+Shift+-'))
            p.action_expand_all.setShortcut(shortcuts.get(
                'Folding: expand all', _('Folding: expand all'),
                'Ctrl+Shift++'))

        try:
            m = editor.modes.get('ExtendedSelectionMode')
        except KeyError:
            _logger().debug('no ExtendedSelectionMode on widget %r', editor)
        else:
            m.action_select_word.setShortcut(shortcuts.get(
                'Select word', _('Select word'), 'Ctrl+Alt+J'))
            m.action_select_extended_word.setShortcut(shortcuts.get(
                'Select extended word', _('Select extended word'),
                'Ctrl+Shift+J'))
            m.action_select_matched.setShortcut(shortcuts.get(
                'Matched select', _('Matched select'), 'Ctrl+E'))
            m.action_select_line.setShortcut(shortcuts.get(
                'Select line', _('Select line'), 'Ctrl+Shift+L'))

        try:
            m = editor.modes.get('CaseConverterMode')
        except KeyError:
            _logger().debug('no CaseConverterMode on widget %r', editor)
        else:
            m.action_to_lower.setShortcut(shortcuts.get(
                'Convert to lower case', _('Convert to lower case'), 'Ctrl+U'))
            m.action_to_upper.setShortcut(shortcuts.get(
                'Convert to UPPER CASE', _('Convert to UPPER CASE'),
                'Ctrl+Shift+U'))
Exemplo n.º 12
0
    def _apply_shortcuts(self):
        # File
        self._ui.action_new.setShortcut(shortcuts.get(
            'New', _('New'), 'Ctrl+N'))
        self._ui.action_open.setShortcut(shortcuts.get(
            'Open directory', _('Open directory'), 'Ctrl+O'))
        self._ui.action_save.setShortcut(shortcuts.get(
            'Save', _('Save'), 'Ctrl+S'))
        self._ui.action_save_as.setShortcut(shortcuts.get(
            'Save as', _('Save as'), 'Ctrl+Shift+S'))
        self._ui.action_save_all.setShortcut(shortcuts.get(
            'Save all', _('Save all'), 'Ctrl+Alt+S'))
        self._ui.action_open_file.setShortcut(shortcuts.get(
            'Open file', _('Open file'), 'Ctrl+Shift+O'))
        self._ui.action_close.setShortcut(shortcuts.get(
            'Close window', _('Close window'), 'Ctrl+Shift+Q'))
        self._ui.action_quit.setShortcut(shortcuts.get(
            'Quit', _('Quit'), 'Ctrl+Q'))
        # Edit
        self._ui.action_preferences.setShortcut(shortcuts.get(
            'Preferences', _('Preferences'), 'Ctrl+,'))

        for editor in self.tab_widget.widgets(True):
            if not isinstance(editor, CodeEdit):
                continue
            self._apply_editor_shortcuts(editor)

        # View
        self._ui.a_fullscreen.setShortcut(shortcuts.get(
            'Toggle fullscreen', _('Toggle fullscreen'), 'Ctrl+F11'))
        self._ui.a_menu.setShortcut(shortcuts.get(
            'Toggle menu', _('Toggle menu'), 'Ctrl+M'))
Exemplo n.º 13
0
 def apply_preferences(self):
     self.areplace.setShortcut(shortcuts.get(
         'Replace in path', _('Replace in path'), 'Ctrl+Shift+H'))
     self.afind.setShortcut(shortcuts.get(
         'Find in path', _('Find in path'), 'Ctrl+Shift+F'))
Exemplo n.º 14
0
def test_update_shortcut():
    assert shortcuts.get('My action', 'My action',
                         'Ctrl+Alt+Delete') == 'Ctrl+Alt+Delete'
    shortcuts.update('My action', 'My action', 'Ctrl+Backspace')
    assert shortcuts.get('My action', 'My action',
                         'Ctrl+Alt+Delete') == 'Ctrl+Backspace'
Exemplo n.º 15
0
def test_get_shortcut():
    assert shortcuts.get('My action', 'My action',
                         'Ctrl+Alt+Delete') == 'Ctrl+Alt+Delete'
    shortcuts.update('My action', 'My action', '')
    assert shortcuts.get('My action', 'My action',
                         'Ctrl+Alt+Delete') == 'Ctrl+Alt+Delete'
Exemplo n.º 16
0
 def apply_preferences(self):
     self.areplace.setShortcut(
         shortcuts.get('Replace in path', _('Replace in path'),
                       'Ctrl+Shift+H'))
     self.afind.setShortcut(
         shortcuts.get('Find in path', _('Find in path'), 'Ctrl+Shift+F'))