mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-30 16:23:57 +02:00
Change the trigger shortcut for snippets to Ctrl+J and Ctrl+Tab is often used by the OS
This commit is contained in:
parent
96856c14e1
commit
35f9614f19
3 changed files with 7 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
|||
Snippets
|
||||
========================
|
||||
|
||||
.. |ct| replace:: ``Ctrl+Tab``
|
||||
.. |ct| replace:: ``Control+J``
|
||||
|
||||
The calibre editor supports *snippets*. A snippet is a
|
||||
piece of text that is either re-used often or contains a lot of redundant
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
QToolButton, QIcon, QHBoxLayout, QPushButton, QListWidget, QListWidgetItem,
|
||||
QGridLayout, QPlainTextEdit, QLabel, QFrame, QDialog, QDialogButtonBox)
|
||||
|
||||
from calibre.constants import isosx
|
||||
from calibre.gui2 import error_dialog
|
||||
from calibre.gui2.tweak_book.editor import all_text_syntaxes
|
||||
from calibre.gui2.tweak_book.editor.smarts.utils import get_text_before_cursor
|
||||
|
|
@ -25,6 +26,8 @@
|
|||
from calibre.utils.localization import localize_user_manual_link
|
||||
|
||||
string_length = lambda x: strlen(unicode(x)) # Needed on narrow python builds, as subclasses of unicode dont work
|
||||
KEY = Qt.Key_J
|
||||
MODIFIER = Qt.META if isosx else Qt.CTRL
|
||||
|
||||
SnipKey = namedtuple('SnipKey', 'trigger syntaxes')
|
||||
def snip_key(trigger, *syntaxes):
|
||||
|
|
@ -382,7 +385,7 @@ def get_active_template(self, cursor):
|
|||
|
||||
def handle_key_press(self, ev):
|
||||
editor = self.parent()
|
||||
if ev.key() == Qt.Key_Tab and ev.modifiers() & Qt.CTRL:
|
||||
if ev.key() == KEY and ev.modifiers() & MODIFIER:
|
||||
at = self.get_active_template(editor.textCursor())
|
||||
if at is not None:
|
||||
if at.jump_to_next(editor) is None:
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
from calibre.gui2.tweak_book.function_replace import (
|
||||
FunctionBox, functions as replace_functions, FunctionEditor, remove_function, Function)
|
||||
from calibre.gui2.tweak_book.widgets import BusyCursor
|
||||
from calibre.gui2.tweak_book.editor.snippets import find_matching_snip, parse_template, string_length, SnippetTextEdit
|
||||
from calibre.gui2.tweak_book.editor.snippets import find_matching_snip, parse_template, string_length, SnippetTextEdit, MODIFIER, KEY
|
||||
|
||||
from calibre.utils.icu import primary_contains
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ def __init__(self, parent, clear_msg):
|
|||
self.ignore_snip_expansion = False
|
||||
|
||||
def event(self, ev):
|
||||
if ev.type() in (ev.ShortcutOverride, ev.KeyPress) and ev.key() == Qt.Key_Tab and ev.modifiers() & Qt.CTRL:
|
||||
if ev.type() in (ev.ShortcutOverride, ev.KeyPress) and ev.key() == KEY and ev.modifiers() & MODIFIER:
|
||||
if not self.ignore_snip_expansion:
|
||||
self.ignore_snip_expansion = True
|
||||
expand_template(self.lineEdit())
|
||||
|
|
|
|||
Loading…
Reference in a new issue