diff --git a/applet.cpp b/applet.cpp index eac9009f8..37c41a6ff 100644 --- a/applet.cpp +++ b/applet.cpp @@ -757,8 +757,8 @@ void Applet::flushPendingConstraintsEvents() } //enforce square size in panels - if (aspectRatioMode() == Plasma::Square && (c & Plasma::SizeConstraint || c & Plasma::FormFactorConstraint) && - size().height() != size().width()) { + if ((c & Plasma::SizeConstraint || c & Plasma::FormFactorConstraint) && + aspectRatioMode() == Plasma::Square && size().height() != size().width()) { if (formFactor() == Horizontal) { setSizePolicy(QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Expanding)); resize(QSizeF(size().height(), size().height())); @@ -771,12 +771,25 @@ void Applet::flushPendingConstraintsEvents() setMaximumHeight(size().width()); setMinimumHeight(size().width()); } + + //or enforce a ConstrainedSquare size + } else if ((c & Plasma::SizeConstraint || c & Plasma::FormFactorConstraint) && + aspectRatioMode() == Plasma::ConstrainedSquare && size().height() != size().width()) { + if (formFactor() == Horizontal) { + //FIXME: it shouldn't be used maximum and minimum sizes, layouts are weird + setMaximumSize(size().height(), QWIDGETSIZE_MAX); + } else if (formFactor() == Vertical) { + setMaximumSize(QWIDGETSIZE_MAX, size().width()); + } //if we are on desktop again restore maximum size - } else if (aspectRatioMode() == Plasma::Square && (c & Plasma::FormFactorConstraint) && formFactor() != Horizontal && formFactor() != Vertical) { + } else if ((c & Plasma::FormFactorConstraint) && aspectRatioMode() == Plasma::Square || + aspectRatioMode() == Plasma::ConstrainedSquare && formFactor() != Horizontal && formFactor() != Vertical) { setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); setMinimumSize(0, 0); } + + Containment* containment = qobject_cast(this); if (isContainment() && containment) { containment->d->containmentConstraintsEvent(c); diff --git a/plasma.h b/plasma.h index f78a1dd37..db0b065a4 100644 --- a/plasma.h +++ b/plasma.h @@ -157,7 +157,8 @@ enum ImmutabilityType { Mutable = 1 /**< The item can be modified in any way **/ */ enum AspectRatioMode { IgnoreAspectRatio = 0 /**< The applet can be freely resized */, KeepAspectRatio = 1 /**< The applet keeps a fixed aspect ratio */, - Square = 2 /**< The applet is always a square */ + Square = 2 /**< The applet is always a square */, + ConstrainedSquare = 3 /** The applet is no wider (in horizontal formfactors) or no higher (in vertical ones) than a square*/ }; /**