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
This commit is contained in:
Kovid Goyal 2021-12-04 13:27:22 +05:30
parent 08792b74df
commit 869f556365
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 6 deletions

View File

@ -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

View File

@ -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)