# HG changeset patch # User Oliver Maurhart # Date 1412248702 -7200 # Node ID 56120b285fc8e01e66cbe1c560a42fe51e218858 # Parent cab995223c76332e912909940dbc4f1b83893eac Bring Password, KeyFile and Credentials-Dialog to Windows front diff -r cab995223c76 -r 56120b285fc8 OpenSecurity/bin/ui/credentials_dialog.py --- a/OpenSecurity/bin/ui/credentials_dialog.py Tue Sep 30 13:06:37 2014 +0200 +++ b/OpenSecurity/bin/ui/credentials_dialog.py Thu Oct 02 13:18:22 2014 +0200 @@ -34,6 +34,11 @@ import sys +if sys.platform == 'win32' or sys.platform == 'cygwin': + import win32api + import win32con + import win32gui + from PyQt4 import QtCore from PyQt4 import QtGui @@ -71,6 +76,12 @@ size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) + t = QtCore.QTimer(self) + t.timeout.connect(self.force_foreground) + t.setInterval(0) + t.setSingleShot(True) + t.start() + def clicked_about(self): @@ -92,6 +103,17 @@ self.accept() + def force_foreground(self): + + """Force ourselves into foreground""" + if sys.platform == 'win32' or sys.platform == 'cygwin': + w = self + while not w.nativeParentWidget() is None: + w = w.nativeParentWidget() + win32gui.BringWindowToTop(int(w.effectiveWinId())) + win32gui.SetForegroundWindow(int(w.effectiveWinId())) + + def set_user_text(user_text): """Set a text to explain which credentials we need.""" @@ -99,6 +121,8 @@ if __name__ == "__main__": + if sys.platform == 'win32' or sys.platform == 'cygwin': + win32gui.SystemParametersInfo(win32con.SPI_SETFOREGROUNDLOCKTIMEOUT, 0, win32con.SPIF_SENDWININICHANGE | win32con.SPIF_UPDATEINIFILE) a = QtGui.QApplication(sys.argv) d = CredentialsDialog() d.show() diff -r cab995223c76 -r 56120b285fc8 OpenSecurity/bin/ui/keyfile_dialog.py --- a/OpenSecurity/bin/ui/keyfile_dialog.py Tue Sep 30 13:06:37 2014 +0200 +++ b/OpenSecurity/bin/ui/keyfile_dialog.py Thu Oct 02 13:18:22 2014 +0200 @@ -35,6 +35,11 @@ import base64 import sys +if sys.platform == 'win32' or sys.platform == 'cygwin': + import win32api + import win32con + import win32gui + from PyQt4 import QtCore from PyQt4 import QtGui @@ -76,6 +81,12 @@ size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) + t = QtCore.QTimer(self) + t.timeout.connect(self.force_foreground) + t.setInterval(0) + t.setSingleShot(True) + t.start() + def clicked_about(self): @@ -118,6 +129,17 @@ self.accept() + def force_foreground(self): + + """Force ourselves into foreground""" + if sys.platform == 'win32' or sys.platform == 'cygwin': + w = self + while not w.nativeParentWidget() is None: + w = w.nativeParentWidget() + win32gui.BringWindowToTop(int(w.effectiveWinId())) + win32gui.SetForegroundWindow(int(w.effectiveWinId())) + + def set_user_text(user_text): """Set a text to explain which password we need.""" @@ -125,6 +147,8 @@ if __name__ == "__main__": + if sys.platform == 'win32' or sys.platform == 'cygwin': + win32gui.SystemParametersInfo(win32con.SPI_SETFOREGROUNDLOCKTIMEOUT, 0, win32con.SPIF_SENDWININICHANGE | win32con.SPIF_UPDATEINIFILE) a = QtGui.QApplication(sys.argv) d = KeyfileDialog() d.show() diff -r cab995223c76 -r 56120b285fc8 OpenSecurity/bin/ui/password_dialog.py --- a/OpenSecurity/bin/ui/password_dialog.py Tue Sep 30 13:06:37 2014 +0200 +++ b/OpenSecurity/bin/ui/password_dialog.py Thu Oct 02 13:18:22 2014 +0200 @@ -34,6 +34,11 @@ import sys +if sys.platform == 'win32' or sys.platform == 'cygwin': + import win32api + import win32con + import win32gui + from PyQt4 import QtCore from PyQt4 import QtGui @@ -70,6 +75,12 @@ screen = QtGui.QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) + + t = QtCore.QTimer(self) + t.timeout.connect(self.force_foreground) + t.setInterval(0) + t.setSingleShot(True) + t.start() def clicked_about(self): @@ -89,6 +100,17 @@ self.accept() + def force_foreground(self): + + """Force ourselves into foreground""" + if sys.platform == 'win32' or sys.platform == 'cygwin': + w = self + while not w.nativeParentWidget() is None: + w = w.nativeParentWidget() + win32gui.BringWindowToTop(int(w.effectiveWinId())) + win32gui.SetForegroundWindow(int(w.effectiveWinId())) + + def set_user_text(user_text): """Set a text to explain which password we need.""" @@ -96,8 +118,11 @@ if __name__ == "__main__": + if sys.platform == 'win32' or sys.platform == 'cygwin': + win32gui.SystemParametersInfo(win32con.SPI_SETFOREGROUNDLOCKTIMEOUT, 0, win32con.SPIF_SENDWININICHANGE | win32con.SPIF_UPDATEINIFILE) a = QtGui.QApplication(sys.argv) d = PasswordDialog() + d.setWindowModality(QtCore.Qt.ApplicationModal) d.show() sys.exit(a.exec_())