Plasma::FrameSvg
#include <Plasma/FrameSvg>

Public Types | |
enum | EnabledBorder { NoBorder = 0, TopBorder = 1, BottomBorder = 2, LeftBorder = 4, RightBorder = 8, AllBorders = TopBorder | BottomBorder | LeftBorder | RightBorder } |
typedef QFlags< EnabledBorder > | EnabledBorders |
![]() | |
enum | Status { Normal = 0, Selected } |
Properties | |
EnabledBorders | enabledBorders |
![]() | |
Plasma::Theme::ColorGroup | colorGroup |
bool | fromCurrentTheme |
QString | imagePath |
bool | multipleImages |
QSize | size |
Plasma::Svg::Status | status |
bool | usingRenderingCache |
![]() | |
objectName | |
Public Member Functions | |
QString | actualPrefix () const |
QPixmap | alphaMask () const |
Q_INVOKABLE bool | cacheAllRenderedFrames () const |
Q_INVOKABLE void | clearCache () |
Q_INVOKABLE QRectF | contentsRect () const |
EnabledBorders | enabledBorders () const |
Q_INVOKABLE qreal | fixedMarginSize (const Plasma::Types::MarginEdge edge) const |
Q_INVOKABLE QPixmap | framePixmap () |
Q_INVOKABLE QSizeF | frameSize () const |
Q_INVOKABLE void | getFixedMargins (qreal &left, qreal &top, qreal &right, qreal &bottom) const |
Q_INVOKABLE void | getInset (qreal &left, qreal &top, qreal &right, qreal &bottom) const |
Q_INVOKABLE void | getMargins (qreal &left, qreal &top, qreal &right, qreal &bottom) const |
Q_INVOKABLE bool | hasElementPrefix (const QString &prefix) const |
Q_INVOKABLE bool | hasElementPrefix (Plasma::Types::Location location) const |
Q_INVOKABLE qreal | insetSize (const Plasma::Types::MarginEdge edge) const |
bool | isRepaintBlocked () const |
Q_INVOKABLE qreal | marginSize (const Plasma::Types::MarginEdge edge) const |
Q_INVOKABLE QRegion | mask () const |
Q_INVOKABLE void | paintFrame (QPainter *painter, const QRectF &target, const QRectF &source=QRectF()) |
Q_INVOKABLE void | paintFrame (QPainter *painter, const QPointF &pos=QPointF(0, 0)) |
Q_INVOKABLE QString | prefix () |
Q_INVOKABLE void | resizeFrame (const QSizeF &size) |
Q_INVOKABLE void | setCacheAllRenderedFrames (bool cache) |
Q_INVOKABLE void | setElementPrefix (Plasma::Types::Location location) |
Q_INVOKABLE void | setElementPrefix (const QString &prefix) |
void | setEnabledBorders (const EnabledBorders borders) |
Q_INVOKABLE void | setImagePath (const QString &path) override |
void | setRepaintBlocked (bool blocked) |
![]() | |
Plasma::Theme::ColorGroup | colorGroup () const |
bool | containsMultipleImages () const |
qreal | devicePixelRatio () |
Q_INVOKABLE QRectF | elementRect (const QString &elementId) const |
Q_INVOKABLE QSize | elementSize (const QString &elementId) const |
bool | fromCurrentTheme () const |
Q_INVOKABLE bool | hasElement (const QString &elementId) const |
Q_INVOKABLE QImage | image (const QSize &size, const QString &elementID=QString()) |
QString | imagePath () const |
bool | isUsingRenderingCache () const |
Q_INVOKABLE bool | isValid () const |
Q_INVOKABLE void | paint (QPainter *painter, const QPointF &point, const QString &elementID=QString()) |
Q_INVOKABLE void | paint (QPainter *painter, int x, int y, const QString &elementID=QString()) |
Q_INVOKABLE void | paint (QPainter *painter, const QRectF &rect, const QString &elementID=QString()) |
Q_INVOKABLE void | paint (QPainter *painter, int x, int y, int width, int height, const QString &elementID=QString()) |
Q_INVOKABLE QPixmap | pixmap (const QString &elementID=QString()) |
Q_INVOKABLE void | resize (qreal width, qreal height) |
Q_INVOKABLE void | resize (const QSizeF &size) |
Q_INVOKABLE void | resize () |
qreal | scaleFactor () const |
void | setColorGroup (Plasma::Theme::ColorGroup group) |
void | setContainsMultipleImages (bool multiple) |
void | setDevicePixelRatio (qreal ratio) |
void | setScaleFactor (qreal factor) |
void | setStatus (Svg::Status status) |
void | setTheme (Plasma::Theme *theme) |
void | setUseSystemColors (bool system) |
void | setUsingRenderingCache (bool useCache) |
QSize | size () const |
Svg::Status | status () const |
Theme * | theme () const |
bool | useSystemColors () const |
![]() | |
QObject (QObject *parent) | |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () |
void | dumpObjectInfo () const const |
void | dumpObjectTree () |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
T | qobject_cast (QObject *object) |
T | qobject_cast (const QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
QThread * | thread () const const |
Related Functions | |
(Note that these are not member functions.) | |
FrameSvg (QObject *parent=nullptr) | |
![]() | |
Svg (QObject *parent=nullptr) | |
Additional Inherited Members | |
![]() | |
void | colorGroupChanged () |
void | colorHintChanged () |
void | fromCurrentThemeChanged (bool fromCurrentTheme) |
void | imagePathChanged () |
void | repaintNeeded () |
void | sizeChanged () |
void | statusChanged (Plasma::Svg::Status status) |
![]() | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
![]() | |
typedef | QObjectList |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Detailed Description
Provides an SVG with borders.
When using SVG images for a background of an object that may change its aspect ratio, such as a dialog, simply scaling a single image may not be enough.
FrameSvg allows SVGs to provide several elements for borders as well as a central element, each of which are scaled individually. These elements should be named
center
- the central element, which will be scaled in both directionstop
- the top border; the height is fixed, but it will be scaled horizontally to the same width ascenter
bottom
- the bottom border; scaled in the same way astop
left
- the left border; the width is fixed, but it will be scaled vertically to the same height ascenter
right
- the right border; scaled in the same way asleft
topleft
- fixed size; must be the same height astop
and the same width asleft
bottomleft
,topright
,bottomright
- similar totopleft
center
must exist, but all the others are optional. topleft
and topright
will be ignored if top
does not exist, and similarly for bottomleft
and bottomright
.
- See also
- Plasma::Svg
Definition at line 63 of file framesvg.h.
Member Enumeration Documentation
These flags represents what borders should be drawn.
Definition at line 73 of file framesvg.h.
Member Function Documentation
QString Plasma::FrameSvg::actualPrefix | ( | ) | const |
- Returns
- the prefix that is actually used (including a '-' at the end if not empty)
- See also
- prefix()
Definition at line 930 of file framesvg.cpp.
QPixmap Plasma::FrameSvg::alphaMask | ( | ) | const |
- Returns
- a pixmap whose alpha channel is the opacity of the frame. It may be the frame itself or a special frame with the mask- prefix
Definition at line 322 of file framesvg.cpp.
bool Plasma::FrameSvg::cacheAllRenderedFrames | ( | ) | const |
- Returns
- if all the different prefixes should be kept in a cache when rendered
Definition at line 359 of file framesvg.cpp.
void Plasma::FrameSvg::clearCache | ( | ) |
Deletes the internal cache freeing memory: use this if you want to switch the rendered element and you don't plan to switch back to the previous one for a long time and you used setUsingRenderingCache(true)
Definition at line 364 of file framesvg.cpp.
QRectF Plasma::FrameSvg::contentsRect | ( | ) | const |
- Returns
- the rectangle of the center element, taking the margins into account.
Definition at line 312 of file framesvg.cpp.
EnabledBorders Plasma::FrameSvg::enabledBorders | ( | ) | const |
Convenience method to get the enabled borders.
- Returns
- what borders are painted
qreal Plasma::FrameSvg::fixedMarginSize | ( | const Plasma::Types::MarginEdge | edge | ) | const |
Returns the margin size given the margin edge we want.
Compared to marginSize(), this doesn't depend whether the margin is enabled or not
- Parameters
-
edge the margin edge we want, top, bottom, left or right
- Returns
- the margin size
Definition at line 247 of file framesvg.cpp.
QPixmap Plasma::FrameSvg::framePixmap | ( | ) |
Returns a pixmap of the SVG represented by this object.
- Parameters
-
elelementId the ID string of the element to render, or an empty string for the whole SVG (the default)
- Returns
- a QPixmap of the rendered SVG
Definition at line 376 of file framesvg.cpp.
QSizeF Plasma::FrameSvg::frameSize | ( | ) | const |
- Returns
- the size of the frame
Definition at line 186 of file framesvg.cpp.
void Plasma::FrameSvg::getFixedMargins | ( | qreal & | left, |
qreal & | top, | ||
qreal & | right, | ||
qreal & | bottom | ||
) | const |
Convenience method that extracts the size of the four margins in the four output parameters Compared to getMargins(), this doesn't depend whether the margins are enabled or not.
- Parameters
-
left left margin size top top margin size right right margin size bottom bottom margin size
Definition at line 286 of file framesvg.cpp.
void Plasma::FrameSvg::getInset | ( | qreal & | left, |
qreal & | top, | ||
qreal & | right, | ||
qreal & | bottom | ||
) | const |
Convenience method that extracts the size of the four inset margins in the four output parameters.
- Parameters
-
left left margin size top top margin size right right margin size bottom bottom margin size
- Since
- 5.77
Definition at line 299 of file framesvg.cpp.
void Plasma::FrameSvg::getMargins | ( | qreal & | left, |
qreal & | top, | ||
qreal & | right, | ||
qreal & | bottom | ||
) | const |
Convenience method that extracts the size of the four margins in the four output parameters The disabled margins will be 0.
If you don't care about the margins being on or off, use getFixedMargins()
- Parameters
-
left left margin size top top margin size right right margin size bottom bottom margin size
Definition at line 273 of file framesvg.cpp.
bool Plasma::FrameSvg::hasElementPrefix | ( | const QString & | prefix | ) | const |
- Returns
- true if the svg has the necessary elements with the given prefix to draw a frame
- Parameters
-
prefix the given prefix we want to check if drawable (can have trailing '-' since 5.59)
Definition at line 128 of file framesvg.cpp.
bool Plasma::FrameSvg::hasElementPrefix | ( | Plasma::Types::Location | location | ) | const |
This is an overloaded method provided for convenience equivalent to hasElementPrefix("north"), hasElementPrefix("south") hasElementPrefix("west") and hasElementPrefix("east")
- Returns
- true if the svg has the necessary elements with the given prefix to draw a frame.
- Parameters
-
location the given prefix we want to check if drawable
Definition at line 142 of file framesvg.cpp.
qreal Plasma::FrameSvg::insetSize | ( | const Plasma::Types::MarginEdge | edge | ) | const |
Returns the insets margin size given the margin edge we want.
- Parameters
-
edge the margin edge we want, top, bottom, left or right
- Returns
- the margin size
- Since
- 5.77
Definition at line 221 of file framesvg.cpp.
bool Plasma::FrameSvg::isRepaintBlocked | ( | ) | const |
- Returns
- true if we are in a transaction of many changes at once and we don't want to rebuild the generated graphics for each change yet
- Since
- 5.31
Definition at line 935 of file framesvg.cpp.
qreal Plasma::FrameSvg::marginSize | ( | const Plasma::Types::MarginEdge | edge | ) | const |
Returns the margin size given the margin edge we want If the given margin is disabled, it will return 0.
If you don't care about the margin being on or off, use fixedMarginSize()
- Parameters
-
edge the margin edge we want, top, bottom, left or right
- Returns
- the margin size
Definition at line 195 of file framesvg.cpp.
QRegion Plasma::FrameSvg::mask | ( | ) | const |
Returns a mask that tightly contains the fully opaque areas of the svg.
- Returns
- a region of opaque areas
Definition at line 328 of file framesvg.cpp.
void Plasma::FrameSvg::paintFrame | ( | QPainter * | painter, |
const QRectF & | target, | ||
const QRectF & | source = QRectF() |
||
) |
Paints the loaded SVG with the elements that represents the border.
- Parameters
-
painter the QPainter to use target the target rectangle on the paint device source the portion rectangle of the source image
Definition at line 385 of file framesvg.cpp.
Paints the loaded SVG with the elements that represents the border This is an overloaded member provided for convenience.
- Parameters
-
painter the QPainter to use pos where to paint the svg
Definition at line 397 of file framesvg.cpp.
QString Plasma::FrameSvg::prefix | ( | ) |
Returns the prefix for SVG elements of the FrameSvg (including a '-' at the end if not empty)
- Returns
- the prefix
- See also
- actualPrefix()
Definition at line 158 of file framesvg.cpp.
void Plasma::FrameSvg::resizeFrame | ( | const QSizeF & | size | ) |
Resize the frame maintaining the same border size.
- Parameters
-
size the new size of the frame
Definition at line 163 of file framesvg.cpp.
void Plasma::FrameSvg::setCacheAllRenderedFrames | ( | bool | cache | ) |
Sets whether saving all the rendered prefixes in a cache or not.
- Parameters
-
cache if use the cache or not
Definition at line 350 of file framesvg.cpp.
void Plasma::FrameSvg::setElementPrefix | ( | Plasma::Types::Location | location | ) |
Sets the prefix (.
- See also
- setElementPrefix) to 'north', 'south', 'west' and 'east' when the location is TopEdge, BottomEdge, LeftEdge and RightEdge, respectively. Clears the prefix in other cases.
The prefix must exist in the SVG document, which means that this can only be called successfully after setImagePath is called.
- Parameters
-
location location in the UI this frame will be drawn
Definition at line 86 of file framesvg.cpp.
void Plasma::FrameSvg::setElementPrefix | ( | const QString & | prefix | ) |
Sets the prefix for the SVG elements to be used for painting.
For example, if prefix is 'active', then instead of using the 'top' element of the SVG file to paint the top border, 'active-top' element will be used. The same goes for other SVG elements.
If the elements with prefixes are not present, the default ones are used. (for the sake of speed, the test is present only for the 'center' element)
Setting the prefix manually resets the location to Floating.
The prefix must exist in the SVG document, which means that this can only be called successfully after setImagePath is called.
- Parameters
-
prefix prefix for the SVG elements that make up the frame
Definition at line 109 of file framesvg.cpp.
void Plasma::FrameSvg::setEnabledBorders | ( | const EnabledBorders | borders | ) |
Sets what borders should be painted.
- Parameters
-
flags borders we want to paint
Definition at line 68 of file framesvg.cpp.
|
overridevirtual |
Loads a new Svg.
- Parameters
-
imagePath the new file
Reimplemented from Plasma::Svg.
Definition at line 53 of file framesvg.cpp.
void Plasma::FrameSvg::setRepaintBlocked | ( | bool | blocked | ) |
If we will do several changes at once in the frame properties, such as prefix, enabled borders and size, in order to not regenerate the graphics for each change, set this property to true, and set it to false again after applying all the changes needed.
Note that any change will not be visible in the painted frame while this property is set to true.
- Since
- 5.31
Definition at line 940 of file framesvg.cpp.
Friends And Related Function Documentation
|
related |
Constructs a new FrameSvg that paints the proper named subelements as borders.
It may also be used as a regular Plasma::Svg object for direct access to elements in the Svg.
- Parameters
-
parent options QObject to parent this to
Definition at line 41 of file framesvg.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Mar 4 2021 22:42:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.