13#include <QCoreApplication>
49 const QString &pixmapPath);
54 QPixmap
pixmap()
const {
return m_pixmap; }
66 void setPixmap(
const QString &pixmapPath);
83 void setAppearance(
const bool defaultAppearance,
const QString &fileName);
115 void render(QPainter *painter,
const QRectF &boundingRect,
const bool selected)
const;
129 void rebuildSvgRenderer();
134 QPixmap m_basePixmap;
135 bool m_hasCustomRenderPixmap =
false;
136 std::shared_ptr<QSvgRenderer> m_svgRenderer;
138 QString m_pixmapPath;
139 QString m_currentPixmapPath;
140 QString m_resolvedPixmapPath;
142 QStringList m_defaultAppearances;
143 QStringList m_alternativeAppearances;
144 bool m_usingDefaultAppearance =
true;
146 QColor m_selectionBrush;
147 QColor m_selectionPen;
QStringList externalFiles() const
Returns the external (non-resource) appearance file paths the element depends on.
bool hasDefaultAppearances() const
Returns true if at least one default appearance is available.
ElementAppearance(GraphicElement *owner)
Constructs the appearance bound to its owning owner element.
void recomputeUsingDefault()
Recomputes the using-default flag by comparing the alternative and default lists.
void setRenderPixmap(const QPixmap &pixmap)
QColor selectionBrush() const
Fill color of the selection highlight rectangle.
QPointF pixmapCenter() const
Returns the centre point of the displayed pixmap in local coordinates.
~ElementAppearance()
Out-of-line so the unique_ptr to the forward-declared QSvgRenderer can be destroyed.
const QStringList & alternativeAppearances() const
Returns the active (possibly user-customised) appearance paths.
void applyOrientation()
Re-derives the displayed pixmap (and SVG renderer) from the owner's current orientation.
void setUsingDefaultAppearance(const bool value)
Sets the "using built-in default appearance" flag.
void render(QPainter *painter, const QRectF &boundingRect, const bool selected) const
Draws the selection highlight (when selected) and the SVG/pixmap body onto painter.
void setAppearance(const bool defaultAppearance, const QString &fileName)
Switches the appearance: restores defaults or applies fileName at slot 0.
const QStringList & defaultAppearances() const
Returns the built-in default appearance paths.
void setAlternativeAppearanceAt(const int index, const QString &path)
Sets one alternative-appearance slot without reloading the pixmap (serializer / subclass use).
void setPixmap(const int index)
Loads and applies the appearance at position index in the active list.
void resetAlternativeToDefault()
Copies the default appearances over the alternative list (restore-to-default).
void seedFromMetadata(const QStringList &defaultAppearances, const QStringList &alternativeAppearances, const QString &pixmapPath)
bool usingDefaultAppearance() const
Returns true when the active appearance still matches the built-in default.
QPixmap previewPixmapAt(const int index, const QSize &size) const
void applyTheme(const ThemeAttributes &theme)
Applies the selection-highlight colors from theme.
QPixmap pixmap() const
Returns the pixmap currently displayed.
void setAppearanceAt(const int index, const QString &fileName)
Sets a custom appearance at index (empty fileName restores that slot's default).
QColor selectionPen() const
Border color of the selection highlight rectangle.
Abstract base class for all graphical circuit elements in wiRedPanda.
Contains all color attributes for a theme.