From 869f556365c7f5e40ad6f16c07a2a7531a9c351e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 4 Dec 2021 13:27:22 +0530 Subject: [PATCH] Fix comments editor toolbars not appearing after a hide/show toggle Also, move the initial creation update geometry call into the comments edit widget itself --- src/calibre/gui2/comments_editor.py | 4 +++- src/calibre/gui2/dialogs/comments_dialog.py | 6 +----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/calibre/gui2/comments_editor.py b/src/calibre/gui2/comments_editor.py index 5cd87636ec..3525ca2d54 100644 --- a/src/calibre/gui2/comments_editor.py +++ b/src/calibre/gui2/comments_editor.py @@ -15,7 +15,7 @@ from qt.core import ( QDialog, QDialogButtonBox, QFont, QFontInfo, QFontMetrics, QFormLayout, QIcon, QKeySequence, QLabel, QLineEdit, QMenu, QPalette, QPlainTextEdit, QPushButton, QSize, QSyntaxHighlighter, Qt, QTabWidget, QTextBlockFormat, QTextCharFormat, - QTextCursor, QTextEdit, QTextFormat, QTextListFormat, QToolButton, QUrl, + QTextCursor, QTextEdit, QTextFormat, QTextListFormat, QTimer, QToolButton, QUrl, QVBoxLayout, QWidget, pyqtSignal, pyqtSlot ) @@ -1139,6 +1139,7 @@ class Editor(QWidget): # {{{ ac = getattr(self.editor, 'action_align_'+x) self.toolbar.add_action(ac) self.toolbar.add_separator() + QTimer.singleShot(0, self.toolbar.updateGeometry) self.code_edit.textChanged.connect(self.code_dirtied) self.editor.data_changed.connect(self.wyswyg_dirtied) @@ -1186,6 +1187,7 @@ class Editor(QWidget): # {{{ def show_toolbars(self): self.toolbar.setVisible(True) + QTimer.singleShot(0, self.toolbar.updateGeometry) def toggle_toolbars(self): visible = self.toolbars_visible diff --git a/src/calibre/gui2/dialogs/comments_dialog.py b/src/calibre/gui2/dialogs/comments_dialog.py index 090025c957..6ff8275e0b 100644 --- a/src/calibre/gui2/dialogs/comments_dialog.py +++ b/src/calibre/gui2/dialogs/comments_dialog.py @@ -7,7 +7,7 @@ __license__ = 'GPL v3' from qt.core import ( QApplication, QDialog, QDialogButtonBox, QPlainTextEdit, QSize, Qt, - QVBoxLayout, QTimer + QVBoxLayout ) from calibre.gui2 import Application, gprefs @@ -46,10 +46,6 @@ class CommentsDialog(QDialog): QApplication.instance().safe_restore_geometry(self, geom) else: self.resize(self.sizeHint()) - QTimer.singleShot(0, self.update_geometry) - - def update_geometry(self): - self.textbox.toolbar.updateGeometry() def sizeHint(self): return QSize(650, 600)