66 self.layout.addWidget(self.__stackedWidget) |
66 self.layout.addWidget(self.__stackedWidget) |
67 self.setLayout(self.layout) |
67 self.setLayout(self.layout) |
68 |
68 |
69 self.__minimized = False |
69 self.__minimized = False |
70 self.__minSize = 0 |
70 self.__minSize = 0 |
71 self.__maxSize = 0 |
|
72 self.__bigSize = QSize() |
71 self.__bigSize = QSize() |
73 |
72 |
74 self.__hasFocus = False |
73 self.__hasFocus = False |
75 # flag storing if this widget or any child has the focus |
74 # flag storing if this widget or any child has the focus |
76 self.__autoHide = False |
75 self.__autoHide = False |
91 """ |
90 """ |
92 self.__minimized = True |
91 self.__minimized = True |
93 self.__bigSize = self.size() |
92 self.__bigSize = self.size() |
94 if self.__orientation in (EricSideBarSide.NORTH, EricSideBarSide.SOUTH): |
93 if self.__orientation in (EricSideBarSide.NORTH, EricSideBarSide.SOUTH): |
95 self.__minSize = self.minimumSizeHint().height() |
94 self.__minSize = self.minimumSizeHint().height() |
96 self.__maxSize = self.maximumHeight() |
|
97 else: |
95 else: |
98 self.__minSize = self.minimumSizeHint().width() |
96 self.__minSize = self.minimumSizeHint().width() |
99 self.__maxSize = self.maximumWidth() |
|
100 |
97 |
101 self.__stackedWidget.hide() |
98 self.__stackedWidget.hide() |
102 |
99 |
103 if self.__orientation in (EricSideBarSide.NORTH, EricSideBarSide.SOUTH): |
100 if self.__orientation in (EricSideBarSide.NORTH, EricSideBarSide.SOUTH): |
104 self.setFixedHeight(self.__iconBar.minimumSizeHint().height()) |
101 self.setFixedHeight(self.__iconBar.minimumSizeHint().height()) |
113 self.__stackedWidget.show() |
110 self.__stackedWidget.show() |
114 self.resize(self.__bigSize) |
111 self.resize(self.__bigSize) |
115 if self.__orientation in (EricSideBarSide.NORTH, EricSideBarSide.SOUTH): |
112 if self.__orientation in (EricSideBarSide.NORTH, EricSideBarSide.SOUTH): |
116 minSize = max(self.__minSize, self.minimumSizeHint().height()) |
113 minSize = max(self.__minSize, self.minimumSizeHint().height()) |
117 self.setMinimumHeight(minSize) |
114 self.setMinimumHeight(minSize) |
118 self.setMaximumHeight(self.__maxSize) |
115 self.setMaximumHeight(16777215) |
119 else: |
116 else: |
120 minSize = max(self.__minSize, self.minimumSizeHint().width()) |
117 minSize = max(self.__minSize, self.minimumSizeHint().width()) |
121 self.setMinimumWidth(minSize) |
118 self.setMinimumWidth(minSize) |
122 self.setMaximumWidth(self.__maxSize) |
119 self.setMaximumWidth(16777215) |
123 |
120 |
124 @pyqtSlot() |
121 @pyqtSlot() |
125 def __shrinkOrExpandIt(self): |
122 def __shrinkOrExpandIt(self): |
126 """ |
123 """ |
127 Private slot to shrink or expand the widget stack. |
124 Private slot to shrink or expand the widget stack. |
373 """ |
370 """ |
374 Public method to save the state of the sidebar. |
371 Public method to save the state of the sidebar. |
375 |
372 |
376 @return saved state as a byte array (QByteArray) |
373 @return saved state as a byte array (QByteArray) |
377 """ |
374 """ |
378 self.__bigSize = self.size() |
375 if not self.__bigSize.isValid(): |
|
376 self.__bigSize = self.size() |
379 if self.__orientation in (EricSideBarSide.NORTH, EricSideBarSide.SOUTH): |
377 if self.__orientation in (EricSideBarSide.NORTH, EricSideBarSide.SOUTH): |
380 self.__minSize = self.minimumSizeHint().height() |
378 self.__minSize = self.minimumSizeHint().height() |
381 self.__maxSize = self.maximumHeight() |
|
382 else: |
379 else: |
383 self.__minSize = self.minimumSizeHint().width() |
380 self.__minSize = self.minimumSizeHint().width() |
384 self.__maxSize = self.maximumWidth() |
|
385 |
381 |
386 dataDict = { |
382 dataDict = { |
387 "version": self.Version, |
383 "version": self.Version, |
388 "minimized": self.__minimized, |
384 "minimized": self.__minimized, |
389 "big_size": [self.__bigSize.width(), self.__bigSize.height()], |
385 "big_size": [self.__bigSize.width(), self.__bigSize.height()], |
390 "min_size": self.__minSize, |
386 "min_size": self.__minSize, |
391 "max_size": self.__maxSize, |
387 "max_size": 16777215, # maximum size for sizable widgets |
392 } |
388 } |
393 data = json.dumps(dataDict) |
389 data = json.dumps(dataDict) |
394 |
390 |
395 return data |
391 return data |
396 |
392 |
412 if not stateDict: |
408 if not stateDict: |
413 return False |
409 return False |
414 |
410 |
415 if self.__orientation in (EricSideBarSide.NORTH, EricSideBarSide.SOUTH): |
411 if self.__orientation in (EricSideBarSide.NORTH, EricSideBarSide.SOUTH): |
416 minSize = self.layout.minimumSize().height() |
412 minSize = self.layout.minimumSize().height() |
417 maxSize = self.maximumHeight() |
|
418 else: |
413 else: |
419 minSize = self.layout.minimumSize().width() |
414 minSize = self.layout.minimumSize().width() |
420 maxSize = self.maximumWidth() |
|
421 |
415 |
422 if stateDict["version"] in (2, 3, 4): |
416 if stateDict["version"] in (2, 3, 4): |
423 if stateDict["minimized"] and not self.__minimized: |
417 if stateDict["minimized"] and not self.__minimized: |
424 self.__shrinkIt() |
418 self.__shrinkIt() |
425 |
419 |
426 self.__bigSize = QSize(*stateDict["big_size"]) |
420 self.__bigSize = QSize(*stateDict["big_size"]) |
427 self.__minSize = max(stateDict["min_size"], minSize) |
421 self.__minSize = max(stateDict["min_size"], minSize) |
428 self.__maxSize = max(stateDict["max_size"], maxSize) |
|
429 |
422 |
430 if not stateDict["minimized"]: |
423 if not stateDict["minimized"]: |
431 self.__expandIt() |
424 self.__expandIt() |
432 |
425 |
433 return True |
426 return True |