Plasma::FrameSvg

Search for usage in LXR

#include <Plasma/FrameSvg>

Inheritance diagram for Plasma::FrameSvg:

Public Types

enum  EnabledBorder {
  NoBorder = 0, TopBorder = 1, BottomBorder = 2, LeftBorder = 4,
  RightBorder = 8, AllBorders = TopBorder | BottomBorder | LeftBorder | RightBorder
}
 
typedef QFlags< EnabledBorderEnabledBorders
 
- Public Types inherited from Plasma::Svg
enum  Status { Normal = 0, Selected, Inactive }
 

Properties

EnabledBorders enabledBorders
 
- Properties inherited from Plasma::Svg
Plasma::Theme::ColorGroup colorGroup
 
bool fromCurrentTheme
 
QString imagePath
 
bool multipleImages
 
QSize size
 
Plasma::Svg::Status status
 
bool usingRenderingCache
 
- Properties inherited from QObject
 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 int minimumDrawingHeight ()
 
Q_INVOKABLE int minimumDrawingWidth ()
 
Q_INVOKABLE void paintFrame (QPainter *painter, const QPointF &pos=QPointF(0, 0))
 
Q_INVOKABLE void paintFrame (QPainter *painter, const QRectF &target, const QRectF &source=QRectF())
 
Q_INVOKABLE QString prefix ()
 
Q_INVOKABLE void resizeFrame (const QSizeF &size)
 
Q_INVOKABLE void setCacheAllRenderedFrames (bool cache)
 
Q_INVOKABLE void setElementPrefix (const QString &prefix)
 
Q_INVOKABLE void setElementPrefix (Plasma::Types::Location location)
 
void setEnabledBorders (const EnabledBorders borders)
 
Q_INVOKABLE void setImagePath (const QString &path) override
 
void setRepaintBlocked (bool blocked)
 
- Public Member Functions inherited from Plasma::Svg
Plasma::Theme::ColorGroup colorGroup () const
 
bool containsMultipleImages () const
 
qreal devicePixelRatio ()
 
Q_INVOKABLE QRectF elementRect (const QString &elementId) const
 
QRectF elementRect (QStringView elementId) const
 
Q_INVOKABLE QSize elementSize (const QString &elementId) const
 
QSize elementSize (QStringView elementId) const
 
bool fromCurrentTheme () const
 
Q_INVOKABLE bool hasElement (const QString &elementId) const
 
bool hasElement (QStringView 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, const QRectF &rect, const QString &elementID=QString())
 
Q_INVOKABLE void paint (QPainter *painter, int x, int y, 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 ()
 
Q_INVOKABLE void resize (const QSizeF &size)
 
Q_INVOKABLE void resize (qreal width, qreal height)
 
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
 
Themetheme () const
 
bool useSystemColors () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () 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< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, 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 QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () 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
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (const QObject *object)
 
qobject_cast (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)
 
QThreadthread () const const
 

Related Functions

(Note that these are not member functions.)

 FrameSvg (QObject *parent=nullptr)
 

Additional Inherited Members

- Signals inherited from Plasma::Svg
void colorGroupChanged ()
 
void colorHintChanged ()
 
void fromCurrentThemeChanged (bool fromCurrentTheme)
 
void imagePathChanged ()
 
void repaintNeeded ()
 
void sizeChanged ()
 
void statusChanged (Plasma::Svg::Status status)
 
- Static Public Member Functions inherited from QObject
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 *context, Functor functor, 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)
 
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, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
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
 
QObjectsender () 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 directions
  • top - the top border; the height is fixed, but it will be scaled horizontally to the same width as center
  • bottom - the bottom border; scaled in the same way as top
  • left - the left border; the width is fixed, but it will be scaled vertically to the same height as center
  • right - the right border; scaled in the same way as left
  • topleft - fixed size; must be the same height as top and the same width as left
  • bottomleft, topright, bottomright - similar to topleft

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 62 of file framesvg.h.

Member Enumeration Documentation

◆ EnabledBorder

These flags represents what borders should be drawn.

Definition at line 72 of file framesvg.h.

Member Function Documentation

◆ actualPrefix()

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 994 of file framesvg.cpp.

◆ alphaMask()

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 323 of file framesvg.cpp.

◆ cacheAllRenderedFrames()

bool Plasma::FrameSvg::cacheAllRenderedFrames ( ) const
Returns
if all the different prefixes should be kept in a cache when rendered

Definition at line 368 of file framesvg.cpp.

◆ clearCache()

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 373 of file framesvg.cpp.

◆ contentsRect()

QRectF Plasma::FrameSvg::contentsRect ( ) const
Returns
the rectangle of the center element, taking the margins into account.

Definition at line 313 of file framesvg.cpp.

◆ enabledBorders()

EnabledBorders Plasma::FrameSvg::enabledBorders ( ) const

Convenience method to get the enabled borders.

Returns
what borders are painted

◆ fixedMarginSize()

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
edgethe margin edge we want, top, bottom, left or right
Returns
the margin size

Definition at line 248 of file framesvg.cpp.

◆ framePixmap()

QPixmap Plasma::FrameSvg::framePixmap ( )

Returns a pixmap of the SVG represented by this object.

Parameters
elelementIdthe 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 385 of file framesvg.cpp.

◆ frameSize()

QSizeF Plasma::FrameSvg::frameSize ( ) const
Returns
the size of the frame

Definition at line 187 of file framesvg.cpp.

◆ getFixedMargins()

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
leftleft margin size
toptop margin size
rightright margin size
bottombottom margin size

Definition at line 287 of file framesvg.cpp.

◆ getInset()

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
leftleft margin size
toptop margin size
rightright margin size
bottombottom margin size
Since
5.77

Definition at line 300 of file framesvg.cpp.

◆ getMargins()

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
leftleft margin size
toptop margin size
rightright margin size
bottombottom margin size

Definition at line 274 of file framesvg.cpp.

◆ hasElementPrefix() [1/2]

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
prefixthe given prefix we want to check if drawable (can have trailing '-' since 5.59)

Definition at line 129 of file framesvg.cpp.

◆ hasElementPrefix() [2/2]

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
locationthe given prefix we want to check if drawable

Definition at line 143 of file framesvg.cpp.

◆ insetSize()

qreal Plasma::FrameSvg::insetSize ( const Plasma::Types::MarginEdge  edge) const

Returns the insets margin size given the margin edge we want.

Parameters
edgethe margin edge we want, top, bottom, left or right
Returns
the margin size
Since
5.77

Definition at line 222 of file framesvg.cpp.

◆ isRepaintBlocked()

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 999 of file framesvg.cpp.

◆ marginSize()

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
edgethe margin edge we want, top, bottom, left or right
Returns
the margin size

Definition at line 196 of file framesvg.cpp.

◆ mask()

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 329 of file framesvg.cpp.

◆ minimumDrawingHeight()

int Plasma::FrameSvg::minimumDrawingHeight ( )

This will return the minimum height required to correctly draw this SVG.

Since
5.101

Definition at line 418 of file framesvg.cpp.

◆ minimumDrawingWidth()

int Plasma::FrameSvg::minimumDrawingWidth ( )

This will return the minimum width required to correctly draw this SVG.

Since
5.101

Definition at line 426 of file framesvg.cpp.

◆ paintFrame() [1/2]

void Plasma::FrameSvg::paintFrame ( QPainter painter,
const QPointF pos = QPointF(0, 0) 
)

Paints the loaded SVG with the elements that represents the border This is an overloaded member provided for convenience.

Parameters
painterthe QPainter to use
poswhere to paint the svg

Definition at line 406 of file framesvg.cpp.

◆ paintFrame() [2/2]

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
painterthe QPainter to use
targetthe target rectangle on the paint device
sourcethe portion rectangle of the source image

Definition at line 394 of file framesvg.cpp.

◆ prefix()

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 159 of file framesvg.cpp.

◆ resizeFrame()

void Plasma::FrameSvg::resizeFrame ( const QSizeF size)

Resize the frame maintaining the same border size.

Parameters
sizethe new size of the frame

Definition at line 164 of file framesvg.cpp.

◆ setCacheAllRenderedFrames()

void Plasma::FrameSvg::setCacheAllRenderedFrames ( bool  cache)

Sets whether saving all the rendered prefixes in a cache or not.

Parameters
cacheif use the cache or not

Definition at line 359 of file framesvg.cpp.

◆ setElementPrefix() [1/2]

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
prefixprefix for the SVG elements that make up the frame

Definition at line 110 of file framesvg.cpp.

◆ setElementPrefix() [2/2]

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
locationlocation in the UI this frame will be drawn

Definition at line 87 of file framesvg.cpp.

◆ setEnabledBorders()

void Plasma::FrameSvg::setEnabledBorders ( const EnabledBorders  borders)

Sets what borders should be painted.

Parameters
flagsborders we want to paint

Definition at line 69 of file framesvg.cpp.

◆ setImagePath()

void Plasma::FrameSvg::setImagePath ( const QString path)
overridevirtual

Loads a new Svg.

Parameters
imagePaththe new file

Reimplemented from Plasma::Svg.

Definition at line 54 of file framesvg.cpp.

◆ setRepaintBlocked()

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 1004 of file framesvg.cpp.

Friends And Related Function Documentation

◆ FrameSvg()

Plasma::FrameSvg::FrameSvg ( QObject parent = nullptr)
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
parentoptions QObject to parent this to

Definition at line 42 of file framesvg.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Mar 23 2023 04:18:17 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.