new aspect ratio mode ConstrainedSquare
it makes applets in panel to not be wider than tall in horizontal panels and not taller than wider in vertical panels, but can be for instance less wide than tall in horizontal panels, as opposed to square applets. it makes poossible to have icons with a reasonable size in very big panels as vertical panels usually are for instance svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=816757
This commit is contained in:
parent
3d45aae7fb
commit
1cb044332c
19
applet.cpp
19
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<Plasma::Containment*>(this);
|
||||
if (isContainment() && containment) {
|
||||
containment->d->containmentConstraintsEvent(c);
|
||||
|
3
plasma.h
3
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*/
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user