diff --git a/src/calibre/gui2/init.py b/src/calibre/gui2/init.py index 2dc911c4a8..36e761ca79 100644 --- a/src/calibre/gui2/init.py +++ b/src/calibre/gui2/init.py @@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en' import functools from qt.core import ( - QAction, QApplication, QDialog, QEvent, QIcon, QLabel, QMenu, QPainter, + QAction, QApplication, QDialog, QEvent, QIcon, QLabel, QMenu, QStylePainter, QSizePolicy, QSplitter, QStackedWidget, QStatusBar, QStyle, QStyleOption, Qt, QTabBar, QTimer, QToolButton, QVBoxLayout, QWidget ) @@ -248,12 +248,12 @@ class VersionLabel(QLabel): # {{{ def paintEvent(self, ev): if self.mouse_over: - p = QPainter(self) + p = QStylePainter(self) tool = QStyleOption() + tool.initFrom(self) tool.rect = self.rect() tool.state = QStyle.StateFlag.State_Raised | QStyle.StateFlag.State_Active | QStyle.StateFlag.State_MouseOver - s = self.style() - s.drawPrimitive(QStyle.PrimitiveElement.PE_PanelButtonTool, tool, p, self) + p.drawPrimitive(QStyle.PrimitiveElement.PE_PanelButtonTool, tool) p.end() return QLabel.paintEvent(self, ev) # }}} diff --git a/src/calibre/gui2/jobs.py b/src/calibre/gui2/jobs.py index 7b48c4cfe8..9f462ab70e 100644 --- a/src/calibre/gui2/jobs.py +++ b/src/calibre/gui2/jobs.py @@ -11,7 +11,7 @@ Job management. import time -from qt.core import (QAbstractTableModel, QModelIndex, Qt, QPainter, +from qt.core import (QAbstractTableModel, QModelIndex, Qt, QStylePainter, QTimer, pyqtSignal, QIcon, QDialog, QAbstractItemDelegate, QApplication, QEvent, QSize, QStyleOptionProgressBar, QStyle, QToolTip, QWidget, QStyleOption, QHBoxLayout, QVBoxLayout, QSizePolicy, QLabel, QCoreApplication, QAction, QItemSelectionModel, @@ -602,12 +602,12 @@ class JobsButton(QWidget): # {{{ def paintEvent(self, ev): if self.mouse_over: - p = QPainter(self) + p = QStylePainter(self) tool = QStyleOption() + tool.initFrom(self) tool.rect = self.rect() tool.state = QStyle.StateFlag.State_Raised | QStyle.StateFlag.State_Active | QStyle.StateFlag.State_MouseOver - s = self.style() - s.drawPrimitive(QStyle.PrimitiveElement.PE_PanelButtonTool, tool, p, self) + p.drawPrimitive(QStyle.PrimitiveElement.PE_PanelButtonTool, tool) p.end() QWidget.paintEvent(self, ev) diff --git a/src/calibre/gui2/layout_menu.py b/src/calibre/gui2/layout_menu.py index 7942dba4c0..3f5a2ea7db 100644 --- a/src/calibre/gui2/layout_menu.py +++ b/src/calibre/gui2/layout_menu.py @@ -3,7 +3,7 @@ from qt.core import ( - QFontMetrics, QHBoxLayout, QIcon, QMenu, QPainter, QPushButton, QSize, + QFontMetrics, QHBoxLayout, QIcon, QMenu, QStylePainter, QPushButton, QSize, QSizePolicy, Qt, QWidget, QStyleOption, QStyle, QEvent) @@ -55,13 +55,13 @@ class LayoutItem(QWidget): def paintEvent(self, ev): shown = self.button.isChecked() ls = self.fm.lineSpacing() - painter = QPainter(self) + painter = QStylePainter(self) if self.mouse_over: tool = QStyleOption() + tool.initFrom(self) tool.rect = self.rect() tool.state = QStyle.StateFlag.State_Raised | QStyle.StateFlag.State_Active | QStyle.StateFlag.State_MouseOver - s = self.style() - s.drawPrimitive(QStyle.PrimitiveElement.PE_PanelButtonTool, tool, painter, self) + painter.drawPrimitive(QStyle.PrimitiveElement.PE_PanelButtonTool, tool) painter.drawText( 0, 0, self.width(),