mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
a467d5ef07
@ -38,11 +38,9 @@ series_index_auto_increment = 'next'
|
|||||||
use_series_auto_increment_tweak_when_importing = False
|
use_series_auto_increment_tweak_when_importing = False
|
||||||
|
|
||||||
#: Add separator after completing an author name
|
#: Add separator after completing an author name
|
||||||
# Should the completion separator be append
|
# Set this if the completion separator should be appended to the end of the
|
||||||
# to the end of the completed text to
|
# completed text to automatically begin a new completion operation for authors.
|
||||||
# automatically begin a new completion operation
|
# It can be either True or False
|
||||||
# for authors.
|
|
||||||
# Can be either True or False
|
|
||||||
authors_completer_append_separator = False
|
authors_completer_append_separator = False
|
||||||
|
|
||||||
#: Author sort name algorithm
|
#: Author sort name algorithm
|
||||||
@ -502,7 +500,14 @@ default_tweak_format = None
|
|||||||
# completions you will now have to press Tab to select one before pressing
|
# completions you will now have to press Tab to select one before pressing
|
||||||
# Enter. Which technique you prefer will depend on the state of metadata in
|
# Enter. Which technique you prefer will depend on the state of metadata in
|
||||||
# your library and your personal editing style.
|
# your library and your personal editing style.
|
||||||
|
#
|
||||||
|
# If preselect_first_completion is False and you want Tab to accept what you
|
||||||
|
# typed instead of the first completion then set tab_accepts_uncompleted_text
|
||||||
|
# to True. If you do this then to select from the completions you must press
|
||||||
|
# the Down or Up arrow keys. The tweak tab_accepts_uncompleted_text is ignored
|
||||||
|
# if preselect_first_completion is True
|
||||||
preselect_first_completion = False
|
preselect_first_completion = False
|
||||||
|
tab_accepts_uncompleted_text = False
|
||||||
|
|
||||||
#: Completion mode when editing authors/tags/series/etc.
|
#: Completion mode when editing authors/tags/series/etc.
|
||||||
# By default, when completing items, calibre will show you all the candidates
|
# By default, when completing items, calibre will show you all the candidates
|
||||||
|
@ -82,6 +82,7 @@ class CompleteModel(QAbstractListModel): # {{{
|
|||||||
class Completer(QListView): # {{{
|
class Completer(QListView): # {{{
|
||||||
|
|
||||||
item_selected = pyqtSignal(object)
|
item_selected = pyqtSignal(object)
|
||||||
|
apply_current_text = pyqtSignal()
|
||||||
relayout_needed = pyqtSignal()
|
relayout_needed = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, completer_widget, max_visible_items=7, sort_func=sort_key, strip_completion_entries=True):
|
def __init__(self, completer_widget, max_visible_items=7, sort_func=sort_key, strip_completion_entries=True):
|
||||||
@ -101,6 +102,8 @@ class Completer(QListView): # {{{
|
|||||||
self.pressed.connect(self.item_chosen)
|
self.pressed.connect(self.item_chosen)
|
||||||
self.installEventFilter(self)
|
self.installEventFilter(self)
|
||||||
self.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
self.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
||||||
|
self.tab_accepts_uncompleted_text = (tweaks['tab_accepts_uncompleted_text'] and
|
||||||
|
not tweaks['preselect_first_completion'])
|
||||||
|
|
||||||
def hide(self):
|
def hide(self):
|
||||||
self.setCurrentIndex(QModelIndex())
|
self.setCurrentIndex(QModelIndex())
|
||||||
@ -232,6 +235,9 @@ class Completer(QListView): # {{{
|
|||||||
if idx.isValid():
|
if idx.isValid():
|
||||||
self.item_chosen(idx)
|
self.item_chosen(idx)
|
||||||
self.hide()
|
self.hide()
|
||||||
|
elif self.tab_accepts_uncompleted_text:
|
||||||
|
self.hide()
|
||||||
|
self.apply_current_text.emit()
|
||||||
elif self.model().rowCount() > 0:
|
elif self.model().rowCount() > 0:
|
||||||
self.next_match()
|
self.next_match()
|
||||||
e.accept()
|
e.accept()
|
||||||
@ -306,6 +312,8 @@ class LineEdit(QLineEdit, LineEditECM):
|
|||||||
self.mcompleter = Completer(completer_widget, sort_func=sort_func, strip_completion_entries=strip_completion_entries)
|
self.mcompleter = Completer(completer_widget, sort_func=sort_func, strip_completion_entries=strip_completion_entries)
|
||||||
self.mcompleter.item_selected.connect(self.completion_selected,
|
self.mcompleter.item_selected.connect(self.completion_selected,
|
||||||
type=Qt.ConnectionType.QueuedConnection)
|
type=Qt.ConnectionType.QueuedConnection)
|
||||||
|
self.mcompleter.apply_current_text.connect(self.apply_current_text,
|
||||||
|
type=Qt.ConnectionType.QueuedConnection)
|
||||||
self.mcompleter.relayout_needed.connect(self.relayout)
|
self.mcompleter.relayout_needed.connect(self.relayout)
|
||||||
self.mcompleter.setFocusProxy(completer_widget)
|
self.mcompleter.setFocusProxy(completer_widget)
|
||||||
self.textEdited.connect(self.text_edited)
|
self.textEdited.connect(self.text_edited)
|
||||||
@ -425,6 +433,14 @@ class LineEdit(QLineEdit, LineEditECM):
|
|||||||
self.setCursorPosition(len(before_text))
|
self.setCursorPosition(len(before_text))
|
||||||
self.item_selected.emit(text)
|
self.item_selected.emit(text)
|
||||||
|
|
||||||
|
def apply_current_text(self):
|
||||||
|
if self.sep is not None:
|
||||||
|
txt = str(self.text())
|
||||||
|
sep_pos = txt.rfind(self.sep)
|
||||||
|
if sep_pos:
|
||||||
|
ntxt = txt[sep_pos+1:].strip()
|
||||||
|
self.completion_selected(ntxt)
|
||||||
|
|
||||||
|
|
||||||
class EditWithComplete(EnComboBox):
|
class EditWithComplete(EnComboBox):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user