understanding minimum/maximum/preferredSize in plasma context
Marco Martin
notmart at gmail.com
Sat Dec 27 11:12:00 CET 2008
On Saturday 27 December 2008, Marcos Dione wrote:
> hi all. I'm set to get the panel spacer to its previous behaviour
> when set to auto stretch, that is, to use as much space as possible.
>
> now, the code is simple: it takes the size of the container (if it's
> an horizontal panel, it takes the width), then loops through all the
> applets/plasmoids on it and substracts its preferred size. whatever is
> left is used as a reference maximumSize (in this case, width).
eeew, this thing shouldn't be needed at all, only thing needed should be an
expanding horizontal size policy (see the QGraphicsWidget::setSizePolicy() Qt
docs)
> actually, what it really does is this: it sets the minimumSize to
> the min between this and the previous minSize (begins at 16 or so). if
> it's not auto stretching, is sets the maxSize to the same value,
> obiously forcing it to be of that size. if it is, it sets the maxSize to
> -1. I guess this value means something special, but QGraphicsWidget API
> (actually QGraphicslayoutitem[1]) says nothing about it.
>
> with this code and in my config the spacer takes some 130px, while
> the systray takes 490px having only 190px of icons inside, and the 3
> digital clocks arte wider that needed[2]. if I turn off that auto
> stretching, it goes down to the original 16px, but if I use the slider
> to effectively increase the minSize, it goes up to 710px.
>
> suspecting those -1, I modified the code to set the maxSize to the
> reference maxSize calculated as above, and it still is doesn't stretch.
> seems like the only way to get some space in the panel is asking in some
> forced way (by setting the minSize), instead of setting a min and a max
> and letting the panel to guess the right one... maybe is it because the
> other applets also ask for as much space as possible? I think plasma is
> either reinventing the layout code that already exists in QT or the
> applets are not behaving as they should.
>
> also, and finishind this longish mail, wehre does the preferredSize
> come from? is it calculated? and last but not least, is there really
> pretty pretty please some docs about this, including how
> constraintsEvent() works/should work? I loked in plasmas' site and wiki
> to no avail. sebas sent me to read the API but didn't find anything
> conclusive.
eeeh, not much documentation actually :/ yes, the most complete is from the
api, in applet.h and plasma.h, where constraints are enumerated
for the preferred/minimum/max sizes doc, look at qt documentation, in
qgraphicslayoutitem and qgraphicswidget classes docs
cheers,
Marco Martin
>
> cheers,
>
> Marcos.
>
> --
> [1] http://doc.trolltech.com/4.4/qgraphicslayoutitem.html#setMinimumWidth
>
> [2]
> http://grulicueva.homelinux.net/~mdione/gallerpy/index.py/pictures/sshots/p
>lasma_panel-spacer_does_not_grow.png --
> (Not so) Random fortune:
> - The human psyche is an odd and contradictory thing, isn't it Bob...
> - Well... being a lawyer, I pretty much bunk on it.
> -- http://www.ucomics.com/nonsequitur/viewnq.htm
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel at kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
More information about the Plasma-devel
mailing list