|
25 | 25 |
|
26 | 26 | import sip |
27 | 27 |
|
28 | | -from AnyQt.QtWidgets import QWidget, QShortcut, QLabel, QSizePolicy, QAction, qApp |
| 28 | +from AnyQt.QtWidgets import QWidget, QShortcut, QLabel, QSizePolicy, QAction |
29 | 29 | from AnyQt.QtGui import QKeySequence, QWhatsThisClickedEvent |
30 | 30 |
|
31 | 31 | from AnyQt.QtCore import Qt, QObject, QCoreApplication, QTimer, QEvent |
@@ -260,12 +260,6 @@ def __init__(self, parent=None): |
260 | 260 |
|
261 | 261 | # Widgets float above other windows |
262 | 262 | self.__float_widgets_on_top = False |
263 | | - if hasattr(qApp, "applicationStateChanged"): |
264 | | - # disables/enables widget floating when app (de)activates |
265 | | - # available in Qt >= 5.2 |
266 | | - def reapply_float_on_top(): |
267 | | - self.set_float_widgets_on_top(self.__float_widgets_on_top) |
268 | | - qApp.applicationStateChanged.connect(reapply_float_on_top) |
269 | 263 |
|
270 | 264 | def set_scheme(self, scheme): |
271 | 265 | """ |
@@ -644,7 +638,6 @@ def set_float_widgets_on_top(self, float_on_top): |
644 | 638 | Set `Float Widgets on Top` flag on all widgets. |
645 | 639 | """ |
646 | 640 | self.__float_widgets_on_top = float_on_top |
647 | | - |
648 | 641 | for widget in self.__widget_for_node.values(): |
649 | 642 | self.__set_float_on_top_flag(widget) |
650 | 643 |
|
@@ -814,18 +807,14 @@ def __on_env_changed(self, key, newvalue, oldvalue): |
814 | 807 | def __set_float_on_top_flag(self, widget): |
815 | 808 | """Set or unset widget's float on top flag""" |
816 | 809 | should_float_on_top = self.__float_widgets_on_top |
817 | | - if hasattr(qApp, "applicationState"): |
818 | | - # only float on top when the application is active |
819 | | - # available in Qt >= 5.2 |
820 | | - should_float_on_top &= qApp.applicationState() == Qt.ApplicationActive |
821 | | - float_on_top = widget.windowFlags() & Qt.WindowStaysOnTopHint |
| 810 | + float_on_top = bool(widget.windowFlags() & Qt.WindowStaysOnTopHint) |
822 | 811 |
|
823 | 812 | if float_on_top == should_float_on_top: |
824 | 813 | return |
825 | 814 |
|
826 | 815 | widget_was_visible = widget.isVisible() |
827 | 816 | if should_float_on_top: |
828 | | - widget.setWindowFlags(Qt.WindowStaysOnTopHint) |
| 817 | + widget.setWindowFlags(widget.windowFlags() | Qt.WindowStaysOnTopHint) |
829 | 818 | else: |
830 | 819 | widget.setWindowFlags(widget.windowFlags() & ~Qt.WindowStaysOnTopHint) |
831 | 820 |
|
|
0 commit comments