Esempio n. 1
0
 def minimumSize(self):
     size = QSize()
     for item in self._items:
         size = size.expandedTo(item.minimumSize())
     left, top, right, bottom = self.getContentsMargins()
     size += QSize(left + right, top + bottom)
     return size
Esempio n. 2
0
 def _sizeHint_helper(self, minimum=False):
     self.ensurePolished()
     # code from widgets/qabstractspinbox.cpp
     fm = self.fontMetrics()  # migth need a copy
     try:
         fmw = fm.horizontalAdvance
     except AttributeError:
         fmw = fm.width
     h = self.lineEdit().sizeHint().height()
     w = 0
     if minimum:
         fixedContent = self.prefix() + " "
     else:
         fixedContent = self.prefix() + self.suffix() + " "
     val = -988.888e-99
     if self.fixed_exponent != 9999:
         if self.maximum() != np.inf:
             val = self.maximum()
         else:
             val = -999888. * 10.**self.fixed_exponent
     s = self.textFromValue(val, tmp=True)
     s += fixedContent
     w = fmw(s)
     special = self.specialValueText()
     if special:
         w = max(w, fmw(special))
     w += 2  # cursor blinking space
     hint = QSize(w, h)
     opt = QStyleOptionSpinBox()
     self.initStyleOption(opt)
     style = self.style()
     hint = style.sizeFromContents(style.CT_SpinBox, opt, QSize(w, h), self)
     qapp = QApplication.instance()
     hint = hint.expandedTo(qapp.globalStrut())
     return hint
Esempio n. 3
0
    def minimumSize(self) -> QSize:
        size = QSize()
        for item in self.items:
            size = size.expandedTo(item.minimumSize())

        size += QSize(2 * self.margin, 2 * self.margin)
        return size
Esempio n. 4
0
 def minimumSize(self):
     size = QSize()
     for item in self.itemList:
         size = size.expandedTo(item.minimumSize())
     margin, _, _, _ = self.getContentsMargins()
     size += QSize(2 * margin, 2 * margin)
     return size
Esempio n. 5
0
    def minimumsize(self):
        size = QSize()
        for item in self._item_list:
            size = size.expandedTo(item.minimumSize())

        margins = self.contentsMargins()
        size += QSize(margins.left() + margins.right(),
                      margins.top() + margins.bottom())
        return size
Esempio n. 6
0
    def minimumSize(self):

        # Return the largest "minimum size" of the items
        size = QSize()
        for item in self.items:
            size = size.expandedTo(item.minimumSize())
        margin, _, _, _ = self.getContentsMargins()
        size += QSize(2 * margin, 2 * margin)
        # self._logger.debug('size {} {}'.format(size.width(), size.height()))
        return size
Esempio n. 7
0
    def minimumSize(self):
        # Returns minimum size of the layout.
        # Implement to ensure your layout isn't resized to zero size if there is too little space
        size = QSize()

        for item in self.itemList:
            size = size.expandedTo(item.minimumSize())

        size += QSize(2 * self.margin, 2 * self.margin)
        return size
    def minimumSize(self):

        # Return the largest "minimum size" of the items
        size = QSize()
        for item in self.items:
            size = size.expandedTo(item.minimumSize())
        margin, _, _, _ = self.getContentsMargins()
        size += QSize(2 * margin, 2 * margin)
        # self._logger.debug('size {} {}'.format(size.width(), size.height()))
        return size
Esempio n. 9
0
    def minimumSize(self):
        size = QSize()

        for item in self.itemList:
            size = size.expandedTo(item.minimumSize())

        margin, _, _, _ = self.getContentsMargins()

        size += QSize(2 * margin, 2 * margin)
        return size
Esempio n. 10
0
	def getMinimumSizeForOrientation ( self, orientation ) -> QSize:
		isDefaultOrientation = orientation == self.editor.GetDefaultOrientation ()
		contentMinSize = self.content.layout ().minimumSize ()

		topArea = self.toolBarAreaManager.getWidget ( CToolBarAreaManagerArea.Top )
		bottomArea = self.toolBarAreaManager.getWidget ( CToolBarAreaManagerArea.Bottom )
		leftArea = self.toolBarAreaManager.getWidget ( CToolBarAreaManagerArea.Left )
		rightArea = self.toolBarAreaManager.getWidget ( CToolBarAreaManagerArea.Right )

		result = QSize ( 0, 0 )
		if isDefaultOrientation:
			# Take width from left and right areas if we're switching to the editor's default orientation
			result.setWidth ( result.width () + leftArea.getLargestItemMinimumSize ().width () )
			result.setWidth ( result.width () + rightArea.getLargestItemMinimumSize ().width () )

			# Use top and bottom area to calculate min height
			result.setHeight ( result.height () + leftArea.getLargestItemMinimumSize ().height () )
			result.setHeight ( result.height () + rightArea.getLargestItemMinimumSize ().height () )

			# Add content min size
			result += contentMinSize

			# Take the area layout size hints into account. Expand the current result with the toolbar area layout's size hint.
			# We use size hint rather than minimum size since toolbar area item's size policy is set to preferred.
			result = result.expandedTo ( QSize ( topArea.layout ().sizeHint ().height (), leftArea.layout ().sizeHint ().width () ) )
			result = result.expandedTo ( QSize ( bottomArea.layout ().sizeHint ().height (), rightArea.layout ().sizeHint ().width () ) )
		else:
			# If we're not switching to the default orientation, then we need to use the top and bottom toolbar areas' width
			# since these areas will be placed at the left and right of the editor content in this case of adaptive layouts
			result.setWidth ( result.width () + topArea.getLargestItemMinimumSize ().width () )
			result.setWidth ( result.width () + bottomArea.getLargestItemMinimumSize ().width () )

			# We must also flip where we get toolbar area min height from
			result.setHeight ( result.height () + leftArea.getLargestItemMinimumSize ().height () )
			result.setHeight ( result.height () + rightArea.getLargestItemMinimumSize ().height () )

			# Add flipped content min size
			result += QSize ( contentMinSize.height (), contentMinSize.width () )

			result = result.expandedTo ( QSize ( leftArea.layout ().sizeHint ().height (), topArea.layout ().sizeHint ().width () ) )
			result = result.expandedTo ( QSize ( rightArea.layout ().sizeHint ().height (), bottomArea.layout ().sizeHint ().width () ) )

		return result
Esempio n. 11
0
    def minimumSize(self):
        size = QSize()

        for item in self._item_list:
            minsize = item.minimumSize()
            extent = item.geometry().bottomRight()
            size = size.expandedTo(QSize(minsize.width(), extent.y()))

        margin = self.contentsMargins().left()
        size += QSize(2 * margin, 2 * margin)
        return size
Esempio n. 12
0
    def minimumSize(self):
        # calucalate minimum possible size below which, resize is impossible
        size = QSize()

        for item in self.itemList:
            size = size.expandedTo(item.minimumSize())

        margin, _, _, _ = self.getContentsMargins()

        size += QSize(2 * margin, 2 * margin)
        return size
Esempio n. 13
0
    def minimumSize(self):
        size = QSize()
        for item in self.itemList:
            size = size.expandedTo(item.sizeHint())

        margin, _, _, _ = self.getContentsMargins()

        size += QSize(2 * margin, 2 * margin)

        layoutSize = self.contentsRect()
        if self.hasHeightForWidth():
            size.setHeight(self.heightForWidth(layoutSize.width()))
        return size
Esempio n. 14
0
    def minimumSize(self):
        # Returns the minimum size of the layout

        # Initialize a QSize object
        size = QSize()

        # For each item, expand the QSize object to each one's minimum size
        for item in self.items:

            size = size.expandedTo(item.minimumSize())

        # Get the margins
        left, top, right, bottom = self.getContentsMargins()

        # Add another QSize object to acknowledge  the margins, and return it
        size += QSize(left + right, top + bottom)
        return size
Esempio n. 15
0
 def cellSize(self, leafIndex: QModelIndex, hv: QHeaderView,
              styleOptions: QStyleOptionHeader) -> QSize:
     res = QSize()
     variant = leafIndex.data(Qt.SizeHintRole)
     if variant:
         res = variant
     fnt = QFont(hv.font())
     var = leafIndex.data(Qt.FontRole)
     if var:
         fnt = var
     fnt.setBold(True)
     fm = QFontMetrics(fnt)
     size = QSize(
         fm.size(0, leafIndex.data(Qt.DisplayRole)) +
         QSize(4, 0))  # WA: add more horizontal size (4px)
     if leafIndex.data(Qt.UserRole):
         size.transpose()
     decorationsSize = QSize(hv.style().sizeFromContents(
         QStyle.CT_HeaderSection, styleOptions, QSize(), hv))
     emptyTextSize = QSize(fm.size(0, ""))
     return res.expandedTo(size + decorationsSize - emptyTextSize)
Esempio n. 16
0
 def minimumSize(self) -> QSize:
     result = QSize()
     for item in self.items:
         result = result.expandedTo(item.minimumSize())
     return self._get_contents_margins_size() + result
Esempio n. 17
0
    def sizeHint(self):
        size = QSize(0, 0)
        for item in self.items():
            size = size.expandedTo(item.sizeHint())

        return size + self.count() * QSize(self.spacing(), self.spacing())
Esempio n. 18
0
    def sizeHint(self):
        size = QSize(0, 0)
        for entry in self.entries():
            size = size.expandedTo(entry.item.sizeHint())

        return size + self.count() * QSize(self.spacing(), self.spacing())
Esempio n. 19
0
 def minimumSize(self) -> QSize:
     size = QSize()
     for item in self._items:
         size = size.expandedTo(item.minimumSize())
     size += QSize(2*self._margin, 2*self._margin)
     return size
Esempio n. 20
0
 def minimumSize(self):
     size = QSize()
     for item in self.items:
         size = size.expandedTo(item.minimumSize())
     return size
Esempio n. 21
0
 def sizeHint(self) -> QSize:
     size = QSize(100,100)
     for item in self._items:
         size.expandedTo(item.minimumSize())
     return QSize(size.width() * 3, size.height() * 2)