When safe restoring geometry ensure widget fits on screen as well

This commit is contained in:
Kovid Goyal 2021-04-26 20:12:26 +05:30
parent 6df2d79f4a
commit 69c8b3eddb
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -996,6 +996,11 @@ class Application(QApplication):
def ensure_window_on_screen(self, widget):
screen_rect = self.desktop().availableGeometry(widget)
g = widget.geometry()
w = min(screen_rect.width(), g.width())
h = min(screen_rect.height(), g.height())
if w != g.width() or h != g.height():
widget.resize(w, h)
if not widget.geometry().intersects(screen_rect):
w = min(widget.width(), screen_rect.width() - 10)
h = min(widget.height(), screen_rect.height() - 10)