From b1eafd9c8c9ab5319a54fbfb4a7469531feca01f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 3 Oct 2014 18:42:28 +0530 Subject: [PATCH] Workaround for Qt 5 behavior change that caused the "Proceed with updating metadata" dialog box to progressively creep across the screen. Fixes #1371532 [dialog windows creeping down the screen](https://bugs.launchpad.net/calibre/+bug/1371532) --- src/calibre/gui2/proceed.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/proceed.py b/src/calibre/gui2/proceed.py index ae1228995f..bf51483bd1 100644 --- a/src/calibre/gui2/proceed.py +++ b/src/calibre/gui2/proceed.py @@ -11,7 +11,7 @@ from collections import namedtuple from PyQt5.Qt import (QDialog, Qt, QLabel, QGridLayout, QPixmap, QDialogButtonBox, QApplication, QSize, pyqtSignal, QIcon, - QPlainTextEdit, QCheckBox) + QPlainTextEdit, QCheckBox, QDesktopWidget) from calibre.constants import __version__ from calibre.gui2.dialogs.message_box import ViewLog @@ -178,6 +178,17 @@ class ProceedQuestion(QDialog): button.setDefault(True) button.setFocus(Qt.OtherFocusReason) + def show(self): + QDialog.show(self) + if self.geom_pref is None: + if self.parent() is None: + geom = QDesktopWidget.screenGeometry(self) + else: + geom = self.parent().geometry() + x = max(50, geom.x() + geom.width() // 2 - self.width() // 2) + y = max(50, geom.y() + geom.height() // 2 - self.height() // 2) + self.move(x, y) + def __call__(self, callback, payload, html_log, log_viewer_title, title, msg, det_msg='', show_copy_button=False, cancel_callback=None, log_is_file=False, checkbox_msg=None, checkbox_checked=False, @@ -243,7 +254,7 @@ def main(): app = Application([]) w = QMainWindow() w.show() - p = ProceedQuestion(None) + p = ProceedQuestion(w) p(lambda p,q:None, None, 'ass', 'ass', 'testing', 'testing', checkbox_msg='testing the ruddy checkbox', det_msg='details') p(lambda p:None, None, 'ass2', 'ass2', 'testing2', 'testing2',