raise last focused window if requested

This commit is contained in:
Anton S 2017-10-09 03:10:13 +03:00
parent 6b7cecc840
commit 5301a42495

View File

@ -51,7 +51,7 @@ import tokenize
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QDesktopServices, QPixmap, QIcon, QWindow
from PyQt5.QtCore import (pyqtSlot, qInstallMessageHandler, QTimer, QUrl,
QObject, QEvent, pyqtSignal)
QObject, QEvent, pyqtSignal, Qt)
try:
import hunter
except ImportError:
@ -805,6 +805,15 @@ class Application(QApplication):
self.launch_time = datetime.datetime.now()
self.focusObjectChanged.connect(self.on_focus_object_changed)
self.applicationStateChanged.connect(self.on_app_state_changed)
@pyqtSlot(Qt.ApplicationState)
def on_app_state_changed(self, state):
if state != Qt.ApplicationActive:
return
window = objreg.last_focused_window()
mainwindow.raise_window(window)
def event(self, e):
if e.type() != QEvent.FileOpen: