Skip to content

Commit

Permalink
#39097: Uses an always-on-top behavior for sgtk dialogs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Beeland committed Jan 21, 2017
1 parent 86364c6 commit c066511
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class PhotoshopCCEngine(sgtk.platform.Engine):
_CONTEXT_CACHE = dict()
_CHECK_CONNECTION_TIMER = None
_CONTEXT_CHANGES_DISABLED = False
_DIALOG_PARENT = None

############################################################################
# context changing
Expand Down Expand Up @@ -500,8 +501,17 @@ def _get_dialog_parent(self):
Get the QWidget parent for all dialogs created through
show_dialog & show_modal.
"""
from sgtk.platform.qt import QtGui
return QtGui.QApplication.activeWindow()
from sgtk.platform.qt import QtGui, QtCore

if not self._DIALOG_PARENT:
self._DIALOG_PARENT = QtGui.QWidget(
parent=QtGui.QApplication.activeWindow(),
)
self._DIALOG_PARENT.setWindowFlags(
self._DIALOG_PARENT.windowFlags() | QtCore.Qt.WindowStaysOnTopHint,
)

return self._DIALOG_PARENT

def show_dialog(self, title, bundle, widget_class, *args, **kwargs):
"""
Expand All @@ -527,6 +537,8 @@ def show_dialog(self, title, bundle, widget_class, *args, **kwargs):
)
return None

from tank.platform.qt import QtGui, QtCore

# create the dialog:
dialog, widget = self._create_dialog_with_widget(
title,
Expand Down Expand Up @@ -574,9 +586,16 @@ def show_modal(self, title, bundle, widget_class, *args, **kwargs):
"show the requested window '%s'." % title)
return

from tank.platform.qt import QtGui, QtCore

# create the dialog:
dialog, widget = self._create_dialog_with_widget(
title, bundle, widget_class, *args, **kwargs)
title,
bundle,
widget_class,
*args,
**kwargs
)

# Note - the base engine implementation will try to clean up
# dialogs and widgets after they've been closed. However this
Expand All @@ -585,12 +604,10 @@ def show_modal(self, title, bundle, widget_class, *args, **kwargs):
# Keeping track of all dialogs will ensure this doesn't happen
self.__qt_dialogs.append(dialog)

# make sure the window raised so it doesn't
# appear behind the main Photoshop window
dialog.raise_()
dialog.activateWindow()

status = dialog.exec_()

return status, widget

############################################################################
Expand Down

0 comments on commit c066511

Please sign in to comment.