Skip to content

Commit

Permalink
Merge pull request #3068 from ales-erjavec/fixes/always-on-top
Browse files Browse the repository at this point in the history
[FIX] Canvas: Fix 'Widgest on top'
  • Loading branch information
astaric authored Jun 15, 2018
2 parents c93ff97 + d4cdf78 commit bbf355d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
3 changes: 3 additions & 0 deletions Orange/canvas/application/canvasmain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,9 @@ def set_new_scheme(self, new_scheme):
if self.freeze_action.isChecked():
manager.pause()

new_scheme.widget_manager.set_float_widgets_on_top(
self.float_widgets_on_top_action.isChecked()
)
scheme_doc.setScheme(new_scheme)

# Send a close event to the Scheme, it is responsible for
Expand Down
17 changes: 3 additions & 14 deletions Orange/canvas/scheme/widgetsscheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import sip

from AnyQt.QtWidgets import QWidget, QShortcut, QLabel, QSizePolicy, QAction, qApp
from AnyQt.QtWidgets import QWidget, QShortcut, QLabel, QSizePolicy, QAction
from AnyQt.QtGui import QKeySequence, QWhatsThisClickedEvent

from AnyQt.QtCore import Qt, QObject, QCoreApplication, QTimer, QEvent
Expand Down Expand Up @@ -260,12 +260,6 @@ def __init__(self, parent=None):

# Widgets float above other windows
self.__float_widgets_on_top = False
if hasattr(qApp, "applicationStateChanged"):
# disables/enables widget floating when app (de)activates
# available in Qt >= 5.2
def reapply_float_on_top():
self.set_float_widgets_on_top(self.__float_widgets_on_top)
qApp.applicationStateChanged.connect(reapply_float_on_top)

def set_scheme(self, scheme):
"""
Expand Down Expand Up @@ -644,7 +638,6 @@ def set_float_widgets_on_top(self, float_on_top):
Set `Float Widgets on Top` flag on all widgets.
"""
self.__float_widgets_on_top = float_on_top

for widget in self.__widget_for_node.values():
self.__set_float_on_top_flag(widget)

Expand Down Expand Up @@ -814,18 +807,14 @@ def __on_env_changed(self, key, newvalue, oldvalue):
def __set_float_on_top_flag(self, widget):
"""Set or unset widget's float on top flag"""
should_float_on_top = self.__float_widgets_on_top
if hasattr(qApp, "applicationState"):
# only float on top when the application is active
# available in Qt >= 5.2
should_float_on_top &= qApp.applicationState() == Qt.ApplicationActive
float_on_top = widget.windowFlags() & Qt.WindowStaysOnTopHint
float_on_top = bool(widget.windowFlags() & Qt.WindowStaysOnTopHint)

if float_on_top == should_float_on_top:
return

widget_was_visible = widget.isVisible()
if should_float_on_top:
widget.setWindowFlags(Qt.WindowStaysOnTopHint)
widget.setWindowFlags(widget.windowFlags() | Qt.WindowStaysOnTopHint)
else:
widget.setWindowFlags(widget.windowFlags() & ~Qt.WindowStaysOnTopHint)

Expand Down

0 comments on commit bbf355d

Please sign in to comment.