mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Fix for viewer window going off screen even when not restoring window geometry
This commit is contained in:
parent
1ba8e64468
commit
e9a899a9fa
@ -978,13 +978,15 @@ class Application(QApplication):
|
||||
if not geom:
|
||||
return
|
||||
restored = widget.restoreGeometry(geom)
|
||||
return restored
|
||||
|
||||
def ensure_window_on_screen(self, widget):
|
||||
screen_rect = self.desktop().availableGeometry(widget)
|
||||
if not widget.geometry().intersects(screen_rect):
|
||||
w = min(widget.width(), screen_rect.width() - 10)
|
||||
h = min(widget.height(), screen_rect.height() - 10)
|
||||
widget.resize(w, h)
|
||||
widget.move((screen_rect.width() - w) // 2, (screen_rect.height() - h) // 2)
|
||||
return restored
|
||||
|
||||
def setup_ui_font(self):
|
||||
f = QFont(QApplication.font())
|
||||
|
@ -537,6 +537,8 @@ class EbookViewer(MainWindow):
|
||||
geom = vprefs['main_window_geometry']
|
||||
if geom and get_session_pref('remember_window_geometry', default=False):
|
||||
QApplication.instance().safe_restore_geometry(self, geom)
|
||||
else:
|
||||
QApplication.instance().ensure_window_on_screen(self)
|
||||
if state:
|
||||
self.restoreState(state, self.MAIN_WINDOW_STATE_VERSION)
|
||||
self.inspector_dock.setVisible(False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user