We should no longer need blank painting for cover browser on startup

This commit is contained in:
Kovid Goyal 2023-12-22 13:19:12 +05:30
parent 4c753c6f63
commit 95a7fec616
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -14,8 +14,7 @@ import sys
import time
from qt.core import (
QAction, QApplication, QDialog, QFont, QImage, QItemSelectionModel, QKeySequence,
QLabel, QPainter, QPalette, QSize, QSizePolicy, QStackedLayout, Qt, QTimer,
pyqtSignal,
QLabel, QSize, QSizePolicy, QStackedLayout, Qt, QTimer, pyqtSignal,
)
from calibre.constants import islinux
@ -23,7 +22,6 @@ from calibre.ebooks.metadata import authors_to_string, rating_to_stars
from calibre.gui2 import config, gprefs, rating_font
from calibre_extensions import pictureflow
MIN_SIZE = QSize(300, 150)
@ -190,32 +188,6 @@ class CoverFlow(pictureflow.PictureFlow):
dc_signal = pyqtSignal()
context_menu_requested = pyqtSignal()
_ignore_paint_events = False
@property
def ignore_paint_events(self):
return self._ignore_paint_events
@ignore_paint_events.setter
def ignore_paint_events(self, val):
if val != self._ignore_paint_events:
self._ignore_paint_events = val
if not val:
self.update()
def paintEvent(self, ev):
if self.ignore_paint_events and time.monotonic() - self.created_at < 1:
# Paint blank during startup to avoid flashing
p = QPainter(self)
p.fillRect(self.rect(), self.palette().color(QPalette.ColorRole.Window))
p.end()
else:
super().paintEvent(ev)
def resizeEvent(self, ev):
if ev.oldSize() == QSize(-1, -1):
self.created_at = time.monotonic()
super().resizeEvent(ev)
def __init__(self, parent=None):
pictureflow.PictureFlow.__init__(self, parent,