QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskGraphicLabel.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_GRAPHIC_LABEL_H
7#define QSK_GRAPHIC_LABEL_H
8
9#include "QskControl.h"
10
11class QskGraphic;
12class QskColorFilter;
13
14class QSK_EXPORT QskGraphicLabel : public QskControl
15{
16 Q_OBJECT
17
18 Q_PROPERTY( QUrl source READ source WRITE setSource NOTIFY sourceChanged USER true )
19
20 Q_PROPERTY( bool mirror READ mirror WRITE setMirror NOTIFY mirrorChanged )
21
22 Q_PROPERTY( QSizeF graphicStrutSize READ graphicStrutSize
23 WRITE setGraphicStrutSize RESET resetGraphicStrutSize
24 NOTIFY graphicStrutSizeChanged )
25
26 Q_PROPERTY( int graphicRole READ graphicRole
27 WRITE setGraphicRole RESET resetGraphicRole NOTIFY graphicRoleChanged )
28
29 Q_PROPERTY( Qt::Alignment alignment READ alignment
30 WRITE setAlignment RESET resetAlignment NOTIFY alignmentChanged )
31
32 Q_PROPERTY( FillMode fillMode READ fillMode
33 WRITE setFillMode NOTIFY fillModeChanged )
34
35 Q_PROPERTY( bool panel READ hasPanel
36 WRITE setPanel NOTIFY panelChanged )
37
38 using Inherited = QskControl;
39
40 public:
41 QSK_SUBCONTROLS( Panel, Graphic )
42
43 enum FillMode
44 {
45 Stretch,
46 PreserveAspectFit,
47 PreserveAspectCrop,
48 Pad
49 };
50
51 Q_ENUM( FillMode )
52
53 QskGraphicLabel( QQuickItem* parent = nullptr );
54
55 QskGraphicLabel( const QUrl& url, QQuickItem* parent = nullptr );
56 QskGraphicLabel( const QString& url, QQuickItem* parent = nullptr );
57
58 QskGraphicLabel( const QskGraphic&, QQuickItem* parent = nullptr );
59
60 ~QskGraphicLabel() override;
61
62 QskGraphic graphic() const;
63
64 virtual QskColorFilter graphicFilter() const;
65
66 QUrl source() const;
67 void setSource( const QString& source );
68 void setSource( const QUrl& url );
69
70 void setGraphicStrutSize( const QSizeF& size );
71 QSizeF graphicStrutSize() const;
72 void resetGraphicStrutSize();
73
74 QSizeF effectiveSourceSize() const;
75
76 void setMirror( bool on );
77 bool mirror() const;
78
79 void setAlignment( Qt::Alignment );
80 void resetAlignment();
81 Qt::Alignment alignment() const;
82
83 void setFillMode( FillMode );
84 FillMode fillMode() const;
85
86 bool isEmpty() const;
87
88 void setGraphicRole( int role );
89 void resetGraphicRole();
90 int graphicRole() const;
91
92 void setPanel( bool );
93 bool hasPanel() const;
94
95 Q_SIGNALS:
96 void sourceChanged();
97 void mirrorChanged();
98 void graphicStrutSizeChanged();
99 void graphicRoleChanged( int );
100 void alignmentChanged( Qt::Alignment );
101 void fillModeChanged( FillMode );
102 void panelChanged( bool );
103
104 public Q_SLOTS:
105 void setGraphic( const QskGraphic& );
106
107 protected:
109 void changeEvent( QEvent* ) override;
110
111 void updateResources() override;
112 virtual QskGraphic loadSource( const QUrl& ) const;
113
114 private:
115 class PrivateData;
116 std::unique_ptr< PrivateData > m_data;
117};
118
119#endif
Base class of all controls.
Definition QskControl.h:23
A paint device for scalable graphics.
Definition QskGraphic.h:28
virtual void geometryChangeEvent(QskGeometryChangeEvent *)
Definition QskItem.cpp:855
virtual void changeEvent(QEvent *)
Definition QskItem.cpp:859