From f73b97780a3d10449830c1e256263475ed912336 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Wed, 28 Nov 2007 21:08:12 +0000 Subject: [PATCH] min/max setters and getters for content size svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=742754 --- applet.cpp | 38 +++++++++++++++++++++++++++++++++++--- applet.h | 20 ++++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/applet.cpp b/applet.cpp index ecd512a5c..0473943d2 100644 --- a/applet.cpp +++ b/applet.cpp @@ -907,13 +907,13 @@ Location Applet::location() const QSizeF Applet::contentSize() const { - int top , left , right , bottom; - d->getBorderSize(left,top,right,bottom); + int top, left, right, bottom; + d->getBorderSize(left, top, right, bottom); // kDebug() << "Geometry size: " << geometry().size(); // kDebug() << "Borders: " << left << top << right << bottom; - return geometry().size() - QSizeF(left+right,top+bottom); + return geometry().size() - QSizeF(left + right, top + bottom); } QSizeF Applet::contentSizeHint() const @@ -925,6 +925,38 @@ QSizeF Applet::contentSizeHint() const return contentSize(); } +void Applet::setMinimumContentSize(const QSizeF &minSize) +{ + int top, left, right, bottom; + d->getBorderSize(left, top, right, bottom); + + setMinimumSize(minSize + QSizeF(left + right, top + bottom)); +} + +QSizeF Applet::minimumContentSize() const +{ + int top, left, right, bottom; + d->getBorderSize(left, top, right, bottom); + + return minimumSize() - QSizeF(left + right, top + bottom); +} + +void Applet::setMaximumContentSize(const QSizeF &maxSize) +{ + int top, left, right, bottom; + d->getBorderSize(left, top, right, bottom); + + setMaximumSize(maxSize + QSizeF(left + right, top + bottom)); +} + +QSizeF Applet::maximumContentSize() const +{ + int top, left, right, bottom; + d->getBorderSize(left, top, right, bottom); + + return maximumSize() - QSizeF(left + right, top + bottom); +} + QString Applet::globalName() const { if (!d->appletDescription.isValid()) { diff --git a/applet.h b/applet.h index 0d910eb69..b8b220117 100644 --- a/applet.h +++ b/applet.h @@ -234,6 +234,26 @@ class PLASMA_EXPORT Applet : public Widget */ virtual QSizeF contentSizeHint() const; + /** + * Sets the minimum size for the content of this applet + */ + void setMinimumContentSize(const QSizeF &minSize); + + /** + * Get the minimum size for the content of this applet + */ + QSizeF minimumContentSize() const; + + /** + * Sets the maximum size for the content of this applet. + */ + void setMaximumContentSize(const QSizeF &maxSize); + + /** + * Get the minimum size for the content of this applet + */ + QSizeF maximumContentSize() const; + /** * Returns a list of all known applets. *