|
28 | 28 | from AnyQt.QtWidgets import QWidget, QShortcut, QLabel, QSizePolicy, QAction |
29 | 29 | from AnyQt.QtGui import QKeySequence, QWhatsThisClickedEvent |
30 | 30 |
|
31 | | -from AnyQt.QtCore import Qt, QObject, QCoreApplication, QTimer, QEvent |
| 31 | +from AnyQt.QtCore import Qt, QObject, QCoreApplication, QTimer, QEvent, QSettings |
32 | 32 | from AnyQt.QtCore import pyqtSignal as Signal |
33 | 33 |
|
34 | 34 | from .signalmanager import SignalManager, compress_signals, can_enable_dynamic |
@@ -597,6 +597,9 @@ def create_widget_instance(self, node): |
597 | 597 | widget.setCaption(node.title) |
598 | 598 | # befriend class Report |
599 | 599 | widget._Report__report_view = self.scheme().report_view |
| 600 | + |
| 601 | + self.__set_float_on_top(widget) |
| 602 | + |
600 | 603 | # Schedule an update with the signal manager, due to the cleared |
601 | 604 | # implicit Initializing flag |
602 | 605 | self.signal_manager()._update() |
@@ -627,6 +630,15 @@ def widget_processing_state(self, widget): |
627 | 630 | """ |
628 | 631 | return self.__widget_processing_state[widget] |
629 | 632 |
|
| 633 | + def show_widgets_on_top_changed(self): |
| 634 | + """ |
| 635 | + `Float Widgets on Top` menu option has changed. |
| 636 | +
|
| 637 | + Update the flag on existing widgets. |
| 638 | + """ |
| 639 | + for widget in self.__widget_for_node.values(): |
| 640 | + self.__set_float_on_top(widget) |
| 641 | + |
630 | 642 | def __create_delayed(self): |
631 | 643 | if self.__init_queue: |
632 | 644 | state = self.__init_queue.popleft() |
@@ -790,6 +802,25 @@ def __on_env_changed(self, key, newvalue, oldvalue): |
790 | 802 | for widget in self.__widget_for_node.values(): |
791 | 803 | widget.workflowEnvChanged(key, newvalue, oldvalue) |
792 | 804 |
|
| 805 | + def __set_float_on_top(self, widget): |
| 806 | + """Set or unset widget's float on top flag""" |
| 807 | + settings = QSettings() |
| 808 | + should_float_on_top = settings.value("mainwindow/widgets-float-on-top", False, type=bool) |
| 809 | + float_on_top = widget.windowFlags() & Qt.WindowStaysOnTopHint |
| 810 | + |
| 811 | + if float_on_top == should_float_on_top: |
| 812 | + return |
| 813 | + |
| 814 | + widget_was_visible = widget.isVisible() |
| 815 | + if should_float_on_top: |
| 816 | + widget.setWindowFlags(Qt.WindowStaysOnTopHint) |
| 817 | + else: |
| 818 | + widget.setWindowFlags(widget.windowFlags() & ~Qt.WindowStaysOnTopHint) |
| 819 | + |
| 820 | + # Changing window flags hid the widget |
| 821 | + if widget_was_visible: |
| 822 | + widget.show() |
| 823 | + |
793 | 824 |
|
794 | 825 | def user_message_from_state(message_group): |
795 | 826 | return UserMessage( |
|
0 commit comments