Changeset 11548:635226cda157 in orange


Ignore:
Timestamp:
05/24/13 15:21:28 (11 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Do not overwrite saved geometry in closeEvent if the widget was already hidden.

On some platforms (GNOME) the widget's position is reset to the default after
being hidden.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeWidgets/OWBaseWidget.py

    r11539 r11548  
    334334            self.show() 
    335335 
    336     # when widget is resized, save new width and height into widgetWidth and widgetHeight. some widgets can put this two 
    337     # variables into settings and last widget shape is restored after restart 
    338336    def resizeEvent(self, ev): 
    339337        QDialog.resizeEvent(self, ev) 
     
    344342            self.savedWidgetGeometry = str(self.saveGeometry()) 
    345343 
    346  
    347     # when widget is moved, save new x and y position into widgetXPosition and widgetYPosition. some widgets can put this two 
    348     # variables into settings and last widget position is restored after restart 
    349     # Commented out because of Ubuntu (on call to restoreGeometry calls move event saving pos (0, 0) 
    350 #    def moveEvent(self, ev): 
    351 #        QDialog.moveEvent(self, ev) 
    352 #        if self.savePosition: 
    353 #            self.widgetXPosition = self.frameGeometry().x() 
    354 #            self.widgetYPosition = self.frameGeometry().y() 
    355 #            self.savedWidgetGeometry = str(self.saveGeometry()) 
    356  
    357     # set widget state to hidden 
     344    def showEvent(self, ev): 
     345        QDialog.showEvent(self, ev) 
     346        if self.savePosition: 
     347            self.widgetShown = 1 
     348 
     349            if not self.__wasShown: 
     350                self.__wasShown = True 
     351                self.restoreWidgetPosition() 
     352 
    358353    def hideEvent(self, ev): 
    359354        if self.savePosition: 
     
    362357        QDialog.hideEvent(self, ev) 
    363358 
    364     def showEvent(self, ev): 
    365         QDialog.showEvent(self, ev) 
    366         if self.savePosition: 
    367             self.widgetShown = 1 
    368  
    369         self.__wasShown = True 
    370         self.restoreWidgetPosition() 
    371  
    372359    def closeEvent(self, ev): 
    373         if self.savePosition and self.__wasShown: 
     360        if self.savePosition and self.isVisible() and self.__wasShown: 
    374361            # self.geometry() is 'invalid' (not yet resized/layout) until the 
    375             # widget is made explicitly visible. 
     362            # widget is made explicitly visible or it might be invalid if 
     363            # widget was hidden (in this case hideEvent already saved a valid 
     364            # geometry). 
    376365            self.savedWidgetGeometry = str(self.saveGeometry()) 
    377366        QDialog.closeEvent(self, ev) 
Note: See TracChangeset for help on using the changeset viewer.