Skip to content

Commit 2009a6b

Browse files
committed
Dropped support for Qt < 5 (remaining things)
1 parent dc7b0e4 commit 2009a6b

File tree

5 files changed

+28
-60
lines changed

5 files changed

+28
-60
lines changed

qwt/painter.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
from qwt.color_map import QwtColorMap
3333
from qwt.scale_map import QwtScaleMap
3434

35-
QT_MAJOR_VERSION = int(QC.__version__.split(".")[0])
36-
3735
QWIDGETSIZE_MAX = (1 << 24) - 1
3836

3937

@@ -443,25 +441,19 @@ def backingStore(self, widget, size):
443441
:param QSize size: Size of the pixmap
444442
:return: A pixmap that can be used as backing store
445443
"""
446-
if QT_MAJOR_VERSION >= 5:
447-
pixelRatio = 1.0
448-
if widget and widget.windowHandle():
449-
pixelRatio = widget.windowHandle().devicePixelRatio()
450-
else:
451-
from qtpy.QtGui import qApp
452-
453-
if qApp is not None:
454-
try:
455-
pixelRatio = qApp.devicePixelRatio()
456-
except RuntimeError:
457-
pass
458-
pm = QPixmap(size * pixelRatio)
459-
pm.setDevicePixelRatio(pixelRatio)
444+
pixelRatio = 1.0
445+
if widget and widget.windowHandle():
446+
pixelRatio = widget.windowHandle().devicePixelRatio()
460447
else:
461-
pm = QPixmap(size)
462-
if QT_MAJOR_VERSION < 5 and widget and isX11GraphicsSystem():
463-
if pm.x11Info().screen() != widget.x11Info().screen():
464-
pm.x11SetScreen(widget.x11Info().screen())
448+
from qtpy.QtGui import qApp
449+
450+
if qApp is not None:
451+
try:
452+
pixelRatio = qApp.devicePixelRatio()
453+
except RuntimeError:
454+
pass
455+
pm = QPixmap(size * pixelRatio)
456+
pm.setDevicePixelRatio(pixelRatio)
465457
return pm
466458

467459

qwt/plot_canvas.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import os
1717

18-
from qtpy import QtCore as QC
1918
from qtpy.QtCore import QEvent, QPointF, QRect, QRectF, QSizeF, Qt
2019
from qtpy.QtGui import (
2120
QBrush,
@@ -35,7 +34,6 @@
3534
from qwt.null_paintdevice import QwtNullPaintDevice
3635
from qwt.painter import QwtPainter
3736

38-
QT_MAJOR_VERSION = int(QC.__version__.split(".")[0])
3937
QT_API = os.environ["QT_API"]
4038

4139

@@ -491,10 +489,7 @@ def setPaintAttribute(self, attribute, on=True):
491489
if self.__data.backingStore is None:
492490
self.__data.backingStore = QPixmap()
493491
if self.isVisible():
494-
if QT_MAJOR_VERSION >= 5:
495-
self.__data.backingStore = self.grab(self.rect())
496-
else:
497-
self.__data.backingStore = QPixmap.grabWidget(self, self.rect())
492+
self.__data.backingStore = self.grab(self.rect())
498493
else:
499494
self.__data.backingStore = None
500495
elif attribute == self.Opaque:
@@ -593,10 +588,7 @@ def paintEvent(self, event):
593588
and self.__data.backingStore is not None
594589
):
595590
bs = self.__data.backingStore
596-
if QT_MAJOR_VERSION >= 5:
597-
pixelRatio = bs.devicePixelRatio()
598-
else:
599-
pixelRatio = 1.0
591+
pixelRatio = bs.devicePixelRatio()
600592
if bs.size() != self.size() * pixelRatio:
601593
bs = QwtPainter.backingStore(self, self.size())
602594
if self.testAttribute(Qt.WA_StyledBackground):

qwt/plot_directpainter.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@
1313
:members:
1414
"""
1515

16+
from qtpy.QtCore import QEvent, QObject, Qt
1617
from qtpy.QtGui import QPainter, QRegion
17-
from qtpy.QtCore import QObject, Qt, QEvent
18-
from qtpy import QtCore as QC
19-
20-
QT_MAJOR_VERSION = int(QC.__version__.split(".")[0])
2118

2219
from qwt.plot import QwtPlotItem
2320
from qwt.plot_canvas import QwtPlotCanvas
@@ -222,13 +219,7 @@ def drawSeries(self, seriesItem, from_, to):
222219
if self.testAttribute(self.FullRepaint):
223220
plotCanvas.repaint()
224221
return
225-
immediatePaint = True
226-
if not canvas.testAttribute(Qt.WA_WState_InPaintEvent):
227-
if QT_MAJOR_VERSION >= 5 or not canvas.testAttribute(
228-
Qt.WA_PaintOutsidePaintEvent
229-
):
230-
immediatePaint = False
231-
if immediatePaint:
222+
if canvas.testAttribute(Qt.WA_WState_InPaintEvent):
232223
if not self.__data.painter.isActive():
233224
self.reset()
234225
self.__data.painter.begin(canvas)

qwt/qthelpers.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66

77
"""Qt helpers"""
88

9-
import os.path as osp
109
import os
10+
import os.path as osp
1111

12+
from qtpy import QtCore as QC
1213
from qtpy import QtGui as QG
1314
from qtpy import QtWidgets as QW
14-
from qtpy import QtCore as QC
15-
1615

1716
QT_API = os.environ["QT_API"]
1817

@@ -48,10 +47,7 @@ def take_screenshot(widget, path, size=None, quit=True):
4847
widget.resize(*size)
4948
widget.show()
5049
QW.QApplication.processEvents()
51-
if QT_API in ("pyqt4", "pyside2"):
52-
pixmap = QG.QPixmap.grabWidget(widget)
53-
else:
54-
pixmap = widget.grab()
50+
pixmap = widget.grab()
5551
pixmap.save(path)
5652
if quit:
5753
QC.QTimer.singleShot(0, QW.QApplication.instance().quit)

qwt/tests/test_eventfilter.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
SHOW = True # Show test in GUI-based test launcher
1010

1111
import os
12-
import numpy as np
1312

14-
from qtpy.QtWidgets import QApplication, QWidget, QMainWindow, QToolBar, QWhatsThis
15-
from qtpy.QtGui import QPen, QBrush, QColor, QPainter, QPixmap
16-
from qtpy.QtCore import QSize, QEvent, Signal, QRect, QObject, Qt, QPoint
13+
import numpy as np
14+
from qtpy.QtCore import QEvent, QObject, QPoint, QRect, QSize, Qt, Signal
15+
from qtpy.QtGui import QBrush, QColor, QPainter, QPen, QPixmap
16+
from qtpy.QtWidgets import QApplication, QMainWindow, QToolBar, QWhatsThis, QWidget
1717

1818
from qwt import (
1919
QwtPlot,
20-
QwtScaleDraw,
21-
QwtSymbol,
22-
QwtPlotGrid,
23-
QwtPlotCurve,
2420
QwtPlotCanvas,
21+
QwtPlotCurve,
22+
QwtPlotGrid,
2523
QwtScaleDiv,
24+
QwtScaleDraw,
25+
QwtSymbol,
2626
)
2727
from qwt.tests import utils
2828

@@ -67,10 +67,7 @@ def dark(self):
6767

6868
def mousePressEvent(self, event):
6969
if event.button() == Qt.LeftButton:
70-
if QT_API in ("pyqt4", "pyside2"):
71-
pm = QPixmap.grabWidget(self)
72-
else:
73-
pm = self.grab()
70+
pm = self.grab()
7471
color = QColor()
7572
color.setRgb(pm.toImage().pixel(event.x(), event.y()))
7673
self.colorSelected.emit(color)

0 commit comments

Comments
 (0)