-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR: Update pixmap height calculation #4738
Conversation
@@ -1179,7 +1179,8 @@ def linenumberarea_paint_event(self, event): | |||
active_line_number = active_block.blockNumber() + 1 | |||
|
|||
def draw_pixmap(ytop, pixmap): | |||
painter.drawPixmap(0, ytop + (font_height-pixmap.height()) / 2, | |||
pixmap_height = pixmap.height() / pixmap.devicePixelRatio() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
devicePixelRatio
was introduced in Qt5.5, that is making tests in Qt4 fail, maybe you could add a try.. except and leave the old behavior for Qt4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have variables for checking Qt4 or Qt5 let's use those!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the logic to use the existing is_pyqt46 flag and restored the original behavior for PyQt4. It's as of yet untested on PyQt4, as I don't have that installed right now. Let me know if it works, or I can test it later.
@@ -1179,7 +1179,12 @@ def linenumberarea_paint_event(self, event): | |||
active_line_number = active_block.blockNumber() + 1 | |||
|
|||
def draw_pixmap(ytop, pixmap): | |||
painter.drawPixmap(0, ytop + (font_height-pixmap.height()) / 2, | |||
if is_pyqt46: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need
from qtpy import PYQT4, PYQT5
if PYQT4:
https://github.com/spyder-ide/qtpy/blob/master/qtpy/__init__.py#L94
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nop, it needs to be more fine-grained because we support PyQt >=5.2. So the solution is something along the lines
from qtpy import QT_VERSION
QT55_VERSION = programs.check_version(QT_VERSION, "5.5", ">=")
if not QT55_VERSION:
pixmap_height = pixmap.height()
else:
....
Of course, you need to add the imports and constants in the right places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, the more fine grained option is now in there. Thanks for the help in knowing what to import.
Fixes #4734
The font height and pixmap height were in incompatible units when DPI scaling is on. Dividing the qpixmap height by self.devicePixelRatio() converts it into device independent units. See http://doc.qt.io/qt-5/qpixmap.html#devicePixelRatio