provide a rounded rectangle path generator so we can share this implementatoin around plasma
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=738424
This commit is contained in:
parent
86d745a644
commit
9c9e6e4371
15
plasma.cpp
15
plasma.cpp
@ -62,4 +62,19 @@ Direction locationToDirection(Location location)
|
|||||||
return Down;
|
return Down;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPainterPath roundedRectangle(const QRectF& rect, qreal radius)
|
||||||
|
{
|
||||||
|
QPainterPath path(QPointF(rect.left(), rect.top() + radius));
|
||||||
|
path.quadTo(rect.left(), rect.top(), rect.left() + radius, rect.top()); // Top left corner
|
||||||
|
path.lineTo(rect.right() - radius, rect.top()); // Top side
|
||||||
|
path.quadTo(rect.right(), rect.top(), rect.right(), rect.top() + radius); // Top right corner
|
||||||
|
path.lineTo(rect.right(), rect.bottom() - radius); // Right side
|
||||||
|
path.quadTo(rect.right(), rect.bottom(), rect.right() - radius, rect.bottom()); // Bottom right corner
|
||||||
|
path.lineTo(rect.left() + radius, rect.bottom()); // Bottom side
|
||||||
|
path.quadTo(rect.left(), rect.bottom(), rect.left(), rect.bottom() - radius); // Bottom left corner
|
||||||
|
path.closeSubpath();
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
6
plasma.h
6
plasma.h
@ -21,6 +21,7 @@
|
|||||||
#define PLASMA_DEFS_H
|
#define PLASMA_DEFS_H
|
||||||
|
|
||||||
#include <QtGui/QGraphicsItem>
|
#include <QtGui/QGraphicsItem>
|
||||||
|
#include <QtGui/QPainterPath>
|
||||||
|
|
||||||
#include <plasma/plasma_export.h>
|
#include <plasma/plasma_export.h>
|
||||||
|
|
||||||
@ -136,6 +137,11 @@ PLASMA_EXPORT qreal scalingFactor(ZoomLevel level);
|
|||||||
**/
|
**/
|
||||||
PLASMA_EXPORT Direction locationToDirection(Location location);
|
PLASMA_EXPORT Direction locationToDirection(Location location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a nicely rounded rectanglular path for painting.
|
||||||
|
*/
|
||||||
|
PLASMA_EXPORT QPainterPath roundedRectangle(const QRectF& rect, qreal radius);
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Constraints)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Constraints)
|
||||||
|
Loading…
Reference in New Issue
Block a user