mirror of
https://github.com/wassname/sloth.git
synced 2026-07-09 11:28:06 +08:00
Move MyVBoxLayout into sloth.gui.utils
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user