Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Canvas: Fix 'Widgest on top' #3068

Merged
merged 4 commits into from
Jun 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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