Skip to content

Commit

Permalink
Merge pull request #3304 from ales-erjavec/fixes/first-show
Browse files Browse the repository at this point in the history
[FIX] OWWidget: Preserve widget geometry between hide/show events
  • Loading branch information
janezd authored Oct 19, 2018
2 parents 73971d7 + e529f57 commit a5e63e9
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions Orange/widgets/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class OWWidget(QDialog, OWComponent, Report, ProgressBarMixin,
contextOpened = Signal()
contextClosed = Signal()

# pylint: disable=protected-access
# pylint: disable=protected-access, access-member-before-definition
def __new__(cls, *args, captionTitle=None, **kwargs):
self = super().__new__(cls, None, cls.get_flags())
QDialog.__init__(self, None, self.get_flags())
Expand Down Expand Up @@ -207,6 +207,8 @@ def __new__(cls, *args, captionTitle=None, **kwargs):

# flag indicating if the widget's position was already restored
self.__was_restored = False
# flag indicating the widget is still expecting the first show event.
self.__was_shown = False

self.__statusMessage = ""

Expand Down Expand Up @@ -577,16 +579,6 @@ def _fullscreen_to_maximized(geometry):
y = max(0, space.height() / 2 - height / 2)

self.move(x, y)

# Mark as explicitly moved/resized if not already. QDialog would
# otherwise adjust position/size on subsequent hide/show
# (move/resize events coming from the window manager do not set
# these flags).
if not self.testAttribute(Qt.WA_Moved):
self.setAttribute(Qt.WA_Moved)
if not self.testAttribute(Qt.WA_Resized):
self.setAttribute(Qt.WA_Resized)

return restored

def __updateSavedGeometry(self):
Expand Down Expand Up @@ -658,6 +650,15 @@ def showEvent(self, event):
if self.savedWidgetGeometry is not None:
self.__restoreWidgetGeometry(bytes(self.savedWidgetGeometry))
self.__was_restored = True

if not self.__was_shown:
# Mark as explicitly moved/resized if not already. QDialog would
# otherwise adjust position/size on subsequent hide/show
# (move/resize events coming from the window manager do not set
# these flags).
self.setAttribute(Qt.WA_Moved, True)
self.setAttribute(Qt.WA_Resized, True)
self.__was_shown = True
self.__quicktipOnce()

def wheelEvent(self, event):
Expand Down

0 comments on commit a5e63e9

Please sign in to comment.