From 393610c18aa46ff91da734e26aa1a08534bc5550 Mon Sep 17 00:00:00 2001 From: Mika Fischer Date: Wed, 29 Jun 2011 08:54:13 +0200 Subject: [PATCH] Move MyVBoxLayout into sloth.gui.utils --- sloth/gui/propertyeditor.py | 30 +----------------------------- sloth/gui/utils.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 29 deletions(-) create mode 100644 sloth/gui/utils.py diff --git a/sloth/gui/propertyeditor.py b/sloth/gui/propertyeditor.py index 36c29d6..be8c754 100644 --- a/sloth/gui/propertyeditor.py +++ b/sloth/gui/propertyeditor.py @@ -1,6 +1,7 @@ from sloth.core.exceptions import ImproperlyConfigured from sloth.annotations.model import AnnotationModelItem from sloth.gui.floatinglayout import FloatingLayout +from sloth.gui.utils import MyVBoxLayout from sloth.utils.bind import bind import sys from PyQt4.QtCore import pyqtSignal, QSize, Qt @@ -8,35 +9,6 @@ from PyQt4.QtGui import QApplication, QWidget, QGroupBox, QVBoxLayout, QPushButt import logging LOG = logging.getLogger(__name__) -# This is really really ugly, but the QDockWidget for some reason does not notice when -# its child widget becomes smaller... -# Therefore we manually set its minimum size when our own minimum size changes -class MyVBoxLayout(QVBoxLayout): - def __init__(self, parent=None): - QVBoxLayout.__init__(self, parent) - self._last_size = QSize(0, 0) - - def setGeometry(self, r): - QVBoxLayout.setGeometry(self, r) - try: - wid = self.parentWidget().parentWidget() - - new_size = self.minimumSize() - if new_size == self._last_size: return - self._last_size = new_size - - twid = wid.titleBarWidget() - if twid is not None: - theight = twid.sizeHint().height() - else: - theight = 0 - - new_size += QSize(0, theight) - wid.setMinimumSize(new_size) - - except Exception: - pass - class AbstractAttributeHandler: def defaults(self): pass diff --git a/sloth/gui/utils.py b/sloth/gui/utils.py new file mode 100644 index 0000000..766a4b5 --- /dev/null +++ b/sloth/gui/utils.py @@ -0,0 +1,31 @@ +from PyQt4.QtCore import QSize +from PyQt4.QtGui import QVBoxLayout + +# This is really really ugly, but the QDockWidget for some reason does not notice when +# its child widget becomes smaller... +# Therefore we manually set its minimum size when our own minimum size changes +class MyVBoxLayout(QVBoxLayout): + def __init__(self, parent=None): + QVBoxLayout.__init__(self, parent) + self._last_size = QSize(0, 0) + + def setGeometry(self, r): + QVBoxLayout.setGeometry(self, r) + try: + wid = self.parentWidget().parentWidget() + + new_size = self.minimumSize() + if new_size == self._last_size: return + self._last_size = new_size + + twid = wid.titleBarWidget() + if twid is not None: + theight = twid.sizeHint().height() + else: + theight = 0 + + new_size += QSize(0, theight) + wid.setMinimumSize(new_size) + + except Exception: + pass