mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Shortcuts config, commit open editor if user clicks OK
This commit is contained in:
parent
eabb3078e8
commit
5ad0ce80c9
@ -538,9 +538,13 @@ class Delegate(QStyledItemDelegate): # {{{
|
|||||||
w = Editor(parent=parent)
|
w = Editor(parent=parent)
|
||||||
w.editing_done.connect(self.editor_done)
|
w.editing_done.connect(self.editor_done)
|
||||||
self.editing_index = index
|
self.editing_index = index
|
||||||
|
self.current_editor = w
|
||||||
self.sizeHintChanged.emit(index)
|
self.sizeHintChanged.emit(index)
|
||||||
return w
|
return w
|
||||||
|
|
||||||
|
def accept_changes(self):
|
||||||
|
self.editor_done(self.current_editor)
|
||||||
|
|
||||||
def editor_done(self, editor):
|
def editor_done(self, editor):
|
||||||
self.commitData.emit(editor)
|
self.commitData.emit(editor)
|
||||||
|
|
||||||
@ -579,6 +583,7 @@ class Delegate(QStyledItemDelegate): # {{{
|
|||||||
editor.setGeometry(option.rect)
|
editor.setGeometry(option.rect)
|
||||||
|
|
||||||
def editing_done(self, *args):
|
def editing_done(self, *args):
|
||||||
|
self.current_editor = None
|
||||||
idx = self.editing_index
|
idx = self.editing_index
|
||||||
self.editing_index = None
|
self.editing_index = None
|
||||||
if idx is not None:
|
if idx is not None:
|
||||||
@ -625,6 +630,8 @@ class ShortcutConfig(QWidget): # {{{
|
|||||||
self.changed_signal.emit()
|
self.changed_signal.emit()
|
||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
|
if self.view.state() == self.view.EditingState:
|
||||||
|
self.delegate.accept_changes()
|
||||||
self._model.commit()
|
self._model.commit()
|
||||||
|
|
||||||
def initialize(self, keyboard):
|
def initialize(self, keyboard):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user