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] OWWidget: Preserve widget geometry between hide/show events #3304

Merged
merged 1 commit into from
Oct 19, 2018
Merged
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
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 @@ -573,16 +575,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 @@ -654,6 +646,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