mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 10:13:15 +02:00
Shortcuts config, commit open editor if user clicks OK
This commit is contained in:
parent
eabb3078e8
commit
5ad0ce80c9
1 changed files with 7 additions and 0 deletions
|
|
@ -538,9 +538,13 @@ def createEditor(self, parent, option, index):
|
|||
w = Editor(parent=parent)
|
||||
w.editing_done.connect(self.editor_done)
|
||||
self.editing_index = index
|
||||
self.current_editor = w
|
||||
self.sizeHintChanged.emit(index)
|
||||
return w
|
||||
|
||||
def accept_changes(self):
|
||||
self.editor_done(self.current_editor)
|
||||
|
||||
def editor_done(self, editor):
|
||||
self.commitData.emit(editor)
|
||||
|
||||
|
|
@ -579,6 +583,7 @@ def updateEditorGeometry(self, editor, option, index):
|
|||
editor.setGeometry(option.rect)
|
||||
|
||||
def editing_done(self, *args):
|
||||
self.current_editor = None
|
||||
idx = self.editing_index
|
||||
self.editing_index = None
|
||||
if idx is not None:
|
||||
|
|
@ -625,6 +630,8 @@ def restore_defaults(self):
|
|||
self.changed_signal.emit()
|
||||
|
||||
def commit(self):
|
||||
if self.view.state() == self.view.EditingState:
|
||||
self.delegate.accept_changes()
|
||||
self._model.commit()
|
||||
|
||||
def initialize(self, keyboard):
|
||||
|
|
|
|||
Loading…
Reference in a new issue