1.1 --- a/OpenSecurity/bin/ui/keyfile_dialog.py Tue Apr 29 13:00:46 2014 +0200
1.2 +++ b/OpenSecurity/bin/ui/keyfile_dialog.py Thu Oct 02 13:18:22 2014 +0200
1.3 @@ -35,6 +35,11 @@
1.4 import base64
1.5 import sys
1.6
1.7 +if sys.platform == 'win32' or sys.platform == 'cygwin':
1.8 + import win32api
1.9 + import win32con
1.10 + import win32gui
1.11 +
1.12 from PyQt4 import QtCore
1.13 from PyQt4 import QtGui
1.14
1.15 @@ -76,6 +81,12 @@
1.16 size = self.geometry()
1.17 self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)
1.18
1.19 + t = QtCore.QTimer(self)
1.20 + t.timeout.connect(self.force_foreground)
1.21 + t.setInterval(0)
1.22 + t.setSingleShot(True)
1.23 + t.start()
1.24 +
1.25
1.26 def clicked_about(self):
1.27
1.28 @@ -118,6 +129,17 @@
1.29 self.accept()
1.30
1.31
1.32 + def force_foreground(self):
1.33 +
1.34 + """Force ourselves into foreground"""
1.35 + if sys.platform == 'win32' or sys.platform == 'cygwin':
1.36 + w = self
1.37 + while not w.nativeParentWidget() is None:
1.38 + w = w.nativeParentWidget()
1.39 + win32gui.BringWindowToTop(int(w.effectiveWinId()))
1.40 + win32gui.SetForegroundWindow(int(w.effectiveWinId()))
1.41 +
1.42 +
1.43 def set_user_text(user_text):
1.44
1.45 """Set a text to explain which password we need."""
1.46 @@ -125,6 +147,8 @@
1.47
1.48
1.49 if __name__ == "__main__":
1.50 + if sys.platform == 'win32' or sys.platform == 'cygwin':
1.51 + win32gui.SystemParametersInfo(win32con.SPI_SETFOREGROUNDLOCKTIMEOUT, 0, win32con.SPIF_SENDWININICHANGE | win32con.SPIF_UPDATEINIFILE)
1.52 a = QtGui.QApplication(sys.argv)
1.53 d = KeyfileDialog()
1.54 d.show()