Toolbox Qt
Loading...
Searching...
No Matches
labelscl.h
1#ifndef TBQ_WIDGETS_QLABELSCL_H
2#define TBQ_WIDGETS_QLABELSCL_H
3
4#include "toolboxqt/toolboxqt_global.h"
5
6#include <QLabel>
7#include <QMovie>
8
9namespace tbq
10{
11
12class TOOLBOXQT_EXPORT LabelScl : public QLabel
13{
14 Q_OBJECT
15
16public:
17 explicit LabelScl(QWidget *parent = nullptr);
18
19public:
20 const QPixmap& getPixmap() const;
21 QPixmap getPixmapScaled() const;
22
23 void animPlay(bool start);
24 void animStart();
25 void animStop();
26
27public:
28 void setImg(const QPixmap &pixmap);
29 void setImg(const QImage &img);
30 void setImg(const QImage *img);
31
32 void setAnimation(const QString &animation);
33
34 void setTextAlt(const QString &text);
35
36public:
37 virtual int heightForWidth(int width) const override;
38 virtual QSize sizeHint() const override;
39
40public slots:
41 void resizeEvent(QResizeEvent *event) override;
42
43private:
44 void updateMovieFrame();
45 void updatePixmap();
46
47private: // Disable inherited public methods that can confuse users
48 using QLabel::setMovie;
49
50private:
51 QPixmap m_pixmap;
52
53 QString m_text;
54 std::unique_ptr<QMovie> m_anim;
55};
56
57} // namespace tbq
58
59#endif // TBQ_WIDGETS_QLABELSCL_H
Label that will properly scale image or animation.
Definition: labelscl.h:13