Merge pull request #525 from arsenetar/521

Update qt/result_window.py to fix off-screen issue.
This commit is contained in:
Andrew Senetar 2018-10-10 20:03:03 -05:00 committed by GitHub
commit 10ac536c3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -9,7 +9,8 @@
from PyQt5.QtCore import Qt, QRect
from PyQt5.QtWidgets import (
QMainWindow, QMenu, QLabel, QFileDialog, QMenuBar, QWidget,
QVBoxLayout, QAbstractItemView, QStatusBar, QDialog, QPushButton, QCheckBox
QVBoxLayout, QAbstractItemView, QStatusBar, QDialog, QPushButton, QCheckBox,
QDesktopWidget
)
from hscommon.trans import trget
@ -225,6 +226,14 @@ class ResultWindow(QMainWindow):
else:
if self.app.prefs.resultWindowRect is not None:
self.setGeometry(self.app.prefs.resultWindowRect)
# if not on any screen move to center of default screen
# moves to center of closest screen if partially off screen
frame = self.frameGeometry()
if QDesktopWidget().screenNumber(self) == -1:
moveToScreenCenter(self)
elif QDesktopWidget().availableGeometry(self).contains(frame) is False:
frame.moveCenter(QDesktopWidget().availableGeometry(self).center())
self.move(frame.topLeft())
else:
moveToScreenCenter(self)
@ -343,3 +352,6 @@ class ResultWindow(QMainWindow):
def searchChanged(self):
self.app.model.apply_filter(self.searchEdit.text())
def closeEvent(self, event):
# this saves the location of the results window when it is closed
self.appWillSavePrefs()