cache formFactor(), simplify the min size check branch
This commit is contained in:
parent
bc439cd616
commit
175d9961ff
23
applet.cpp
23
applet.cpp
@ -2370,29 +2370,30 @@ QPainterPath Applet::shape() const
|
|||||||
QSizeF Applet::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
|
QSizeF Applet::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
|
||||||
{
|
{
|
||||||
QSizeF hint = QGraphicsWidget::sizeHint(which, constraint);
|
QSizeF hint = QGraphicsWidget::sizeHint(which, constraint);
|
||||||
|
const FormFactor ff = formFactor();
|
||||||
|
|
||||||
//in panels make sure that the contents won't exit from the panel
|
// in panels make sure that the contents won't exit from the panel
|
||||||
if (formFactor() == Horizontal && which == Qt::MinimumSize) {
|
if (which == Qt::MinimumSize) {
|
||||||
hint.setHeight(0);
|
if (ff == Horizontal) {
|
||||||
} else if (formFactor() == Vertical && which == Qt::MinimumSize) {
|
hint.setHeight(0);
|
||||||
hint.setWidth(0);
|
} else if (ff == Vertical) {
|
||||||
|
hint.setWidth(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// enforce a square size in panels
|
// enforce a square size in panels
|
||||||
if (d->aspectRatioMode == Plasma::Square) {
|
if (d->aspectRatioMode == Plasma::Square) {
|
||||||
if (formFactor() == Horizontal) {
|
if (ff == Horizontal) {
|
||||||
hint.setWidth(size().height());
|
hint.setWidth(size().height());
|
||||||
} else if (formFactor() == Vertical) {
|
} else if (ff == Vertical) {
|
||||||
hint.setHeight(size().width());
|
hint.setHeight(size().width());
|
||||||
}
|
}
|
||||||
} else if (d->aspectRatioMode == Plasma::ConstrainedSquare) {
|
} else if (d->aspectRatioMode == Plasma::ConstrainedSquare) {
|
||||||
//enforce a size not wider than tall
|
//enforce a size not wider than tall
|
||||||
if (formFactor() == Horizontal &&
|
if (ff == Horizontal && (which == Qt::MaximumSize || size().height() <= KIconLoader::SizeLarge)) {
|
||||||
(which == Qt::MaximumSize || size().height() <= KIconLoader::SizeLarge)) {
|
|
||||||
hint.setWidth(size().height());
|
hint.setWidth(size().height());
|
||||||
//enforce a size not taller than wide
|
//enforce a size not taller than wide
|
||||||
} else if (formFactor() == Vertical &&
|
} else if (ff == Vertical && (which == Qt::MaximumSize || size().width() <= KIconLoader::SizeLarge)) {
|
||||||
(which == Qt::MaximumSize || size().width() <= KIconLoader::SizeLarge)) {
|
|
||||||
hint.setHeight(size().width());
|
hint.setHeight(size().width());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user