File indexing completed on 2024-12-08 10:16:05
0001 /* 0002 SPDX-FileCopyrightText: 2020-2022 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KPUBLICTRANSPORT_STYLEDFRAMESVGITEM_H 0008 #define KPUBLICTRANSPORT_STYLEDFRAMESVGITEM_H 0009 0010 #include <QImage> 0011 #include <QQuickPaintedItem> 0012 0013 namespace KPublicTransport { 0014 0015 /** Styled SVG border-image element. */ 0016 class StyledFrameSvgItem : public QQuickPaintedItem 0017 { 0018 Q_OBJECT 0019 QML_ELEMENT 0020 Q_PROPERTY(double borderTop MEMBER m_borderTop NOTIFY borderTopChanged) 0021 Q_PROPERTY(double borderBottom MEMBER m_borderBottom NOTIFY borderBottomChanged) 0022 Q_PROPERTY(double borderLeft MEMBER m_borderLeft NOTIFY borderLeftChanged) 0023 Q_PROPERTY(double borderRight MEMBER m_borderRight NOTIFY borderRightChanged) 0024 0025 Q_PROPERTY(QColor lineColor MEMBER m_lineColor NOTIFY colorChanged) 0026 Q_PROPERTY(QColor backgroundColor MEMBER m_fillColor NOTIFY colorChanged) // fillColor is already a property in the base class 0027 0028 Q_PROPERTY(QString source MEMBER m_source NOTIFY sourceChanged) 0029 0030 public: 0031 explicit StyledFrameSvgItem(QQuickItem *parent = nullptr); 0032 ~StyledFrameSvgItem(); 0033 0034 void paint(QPainter *painter) override; 0035 0036 Q_SIGNALS: 0037 void borderTopChanged(); 0038 void borderBottomChanged(); 0039 void borderLeftChanged(); 0040 void borderRightChanged(); 0041 void colorChanged(); 0042 void sourceChanged(); 0043 0044 private: 0045 void invalidateImage(); 0046 void loadImage(); 0047 0048 double m_borderTop = 0; 0049 double m_borderBottom = 0; 0050 double m_borderLeft = 0; 0051 double m_borderRight = 0; 0052 QColor m_lineColor; 0053 QColor m_fillColor; 0054 QString m_source; 0055 QImage m_image; 0056 }; 0057 0058 } 0059 0060 #endif // KPUBLICTRANSPORT_STYLEDFRAMESVGITEM_H