diff --git a/src/calibre/gui2/comments_editor.py b/src/calibre/gui2/comments_editor.py index d768c0caa7..9942056f8b 100644 --- a/src/calibre/gui2/comments_editor.py +++ b/src/calibre/gui2/comments_editor.py @@ -730,6 +730,14 @@ class Editor(QWidget): # {{{ self.editor.html = unicode(self.code_edit.toPlainText()) self.source_dirty = False + @dynamic_property + def tab(self): + def fget(self): + return 'code' if self.tabs.currentWidget() is self.code_edit else 'wyswyg' + def fset(self, val): + self.tabs.setCurrentWidget(self.code_edit if val == 'code' else self.wyswyg) + return property(fget=fget, fset=fset) + def wyswyg_dirtied(self, *args): self.wyswyg_dirty = True diff --git a/src/calibre/gui2/metadata/single.py b/src/calibre/gui2/metadata/single.py index 75bacc0b1a..7f312f2bef 100644 --- a/src/calibre/gui2/metadata/single.py +++ b/src/calibre/gui2/metadata/single.py @@ -527,6 +527,7 @@ class MetadataSingleDialogBase(ResizableDialog): # break_cycles has already been called, don't know why this should # happen but a user reported it return True + self.comments_tab_at_apply = self.comments.tab for widget in self.basic_metadata_widgets: try: if hasattr(widget, 'validate_for_commit'): @@ -634,6 +635,8 @@ class MetadataSingleDialogBase(ResizableDialog): self.button_box.button(self.button_box.Ok).setDefault(True) self.button_box.button(self.button_box.Ok).setFocus(Qt.OtherFocusReason) self(self.db.id(self.row_list[self.current_row])) + if getattr(self, 'comments_tab_at_apply', None) == 'code': + self.comments.tab = 'code' def break_cycles(self): # Break any reference cycles that could prevent python