1/*
2 SPDX-FileCopyrightText: 2009 Sebastian Trueg <trueg@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#include "kpixmapsequencewidget.h"
8#include "kpixmapsequence.h"
9#include "kpixmapsequenceoverlaypainter.h"
10
11class KPixmapSequenceWidgetPrivate
12{
13public:
14 KPixmapSequenceOverlayPainter *m_painter = nullptr;
15};
16
17KPixmapSequenceWidget::KPixmapSequenceWidget(QWidget *parent)
18 : QWidget(parent)
19 , d(new KPixmapSequenceWidgetPrivate)
20{
21 d->m_painter = new KPixmapSequenceOverlayPainter(this);
22 d->m_painter->setWidget(this);
23}
24
25KPixmapSequenceWidget::KPixmapSequenceWidget(const KPixmapSequence &seq, QWidget *parent)
26 : QWidget(parent)
27 , d(new KPixmapSequenceWidgetPrivate)
28{
29 d->m_painter = new KPixmapSequenceOverlayPainter(seq);
30 d->m_painter->setWidget(this);
31 if (seq.isValid()) {
32 d->m_painter->start();
33 }
34}
35
36KPixmapSequenceWidget::~KPixmapSequenceWidget()
37{
38 delete d->m_painter;
39}
40
41KPixmapSequence KPixmapSequenceWidget::sequence() const
42{
43 return d->m_painter->sequence();
44}
45
46int KPixmapSequenceWidget::interval() const
47{
48 return d->m_painter->interval();
49}
50
51QSize KPixmapSequenceWidget::sizeHint() const
52{
53 if (d->m_painter->sequence().isValid()) {
54 return d->m_painter->sequence().frameSize();
55 } else {
56 return QWidget::sizeHint();
57 }
58}
59
60void KPixmapSequenceWidget::setSequence(const KPixmapSequence &seq)
61{
62 d->m_painter->setSequence(seq);
63 if (seq.isValid()) {
64 setFixedSize(seq.frameSize());
65 d->m_painter->start();
66 } else {
67 d->m_painter->stop();
68 }
69}
70
71void KPixmapSequenceWidget::setInterval(int msecs)
72{
73 d->m_painter->setInterval(msecs);
74}
75
76#include "moc_kpixmapsequencewidget.cpp"
77

source code of kwidgetsaddons/src/kpixmapsequencewidget.cpp