Skip to content

Commit

Permalink
Merge pull request #119 from nebukadhezer/fix-hdpi-in-wrapped-window
Browse files Browse the repository at this point in the history
get the windowHandle from window,
  • Loading branch information
mottosso authored Jan 18, 2021
2 parents ffd8df1 + cf7735a commit f0db29d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyblish_lite/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

VERSION_MAJOR = 0
VERSION_MINOR = 8
VERSION_PATCH = 10
VERSION_PATCH = 11

version_info = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
version = '%i.%i.%i' % version_info
Expand Down
43 changes: 36 additions & 7 deletions pyblish_lite/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
reset
'
'
'
'F
___v__
| | reset
| Idle |--------------------.
Expand Down Expand Up @@ -1068,12 +1068,41 @@ def heads_up(self, title, message, command=None):
# TODO(marcus): Implement this.
self.info(message)

def paintEvent(self, event):
def _find_scale(self):
if Qt.__qt_version__.startswith("5") and os.name == "nt":
# Only tested with Windows DPI scaling
scale = self.windowHandle().screen().logicalDotsPerInch() / 96.0
else:
scale = 1.0
window = self.window()

# Fail graciously
if not window:
print("WARNING: No window associated with Lite")
return 1.0

handle = window.windowHandle()

if not handle:
print(
"WARNING: No handle found, could be an "
"unsupported version of Qt"
)
return 1.0

screen = handle.screen()

if not screen:
print(
"WARNING: No QScreen instance found, "
"are you using Qt 5 or above?"
)
return 1.0

return screen.logicalDotsPerInch() / 96.0
return 1.0

def paintEvent(self, event):
# Compute this only once
self._dpi_scale = getattr(self, "_dpi_scale", self._find_scale())

for delegate in self._delegates:
delegate.set_dpi_scale(scale)
delegate.set_dpi_scale(self._dpi_scale)

super(Window, self).paintEvent(event)

0 comments on commit f0db29d

Please sign in to comment.