mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use QStylePainter for drawing hover raised frames
This is needed for correct styling with Qt6 and is nicer code anyway
This commit is contained in:
parent
b29a8f8afa
commit
57d67d9deb
@ -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)
|
||||
# }}}
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user