1/*
2 SPDX-FileCopyrightText: 2008 Aurélien Gâteau <agateau@kde.org>
3 SPDX-FileCopyrightText: 2009 Sebastian Trueg <trueg@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.1-or-later
6*/
7
8#ifndef _K_PIXMAPSEQUENCE_H_
9#define _K_PIXMAPSEQUENCE_H_
10
11#include <QSharedDataPointer>
12#include <QSize>
13
14#include <kwidgetsaddons_export.h>
15
16class QPixmap;
17
18/**
19 * \class KPixmapSequence kpixmapsequence.h KPixmapSequence
20 *
21 * \brief Loads and gives access to the frames of a typical multi-row pixmap
22 * as often used for spinners.
23 *
24 * KPixmapSequence is implicitly shared. Copying is fast.
25 *
26 * \author Aurélien Gâteau <agateau@kde.org>
27 * \author Sebastian Trueg <trueg@kde.org>
28 *
29 * \since 4.4
30 */
31class KWIDGETSADDONS_EXPORT KPixmapSequence
32{
33public:
34 /**
35 * Create an empty sequence
36 */
37 KPixmapSequence();
38
39 /**
40 * Copy constructor
41 */
42 KPixmapSequence(const KPixmapSequence &other);
43
44 /**
45 * Create a sequence from a pixmap.
46 *
47 * \param pixmap Pixmap to load
48 * \param frameSize The size of the frames to load. The width of the file has to be
49 * a multiple of the frame width; the same is true for the height. If an invalid
50 * size is specified the file is considered to be one column of square frames.
51 */
52 explicit KPixmapSequence(const QPixmap &pixmap, const QSize &frameSize = QSize());
53
54 /**
55 * Create a sequence from an icon name.
56 *
57 * \param fullPath The full path of the icon
58 * \param size The icon/frame size
59 */
60 KPixmapSequence(const QString &fullPath, int size);
61
62 /**
63 * Destructor
64 */
65 ~KPixmapSequence();
66
67 /**
68 * Create a copy of \p other. The data is implicitly shared.
69 */
70 KPixmapSequence &operator=(const KPixmapSequence &other);
71
72 /**
73 * \return \p true if a sequence was loaded successfully.
74 *
75 * \sa isEmpty
76 */
77 bool isValid() const;
78
79 /**
80 * \return \p true if no sequence was loaded successfully.
81 *
82 * \sa isValid
83 */
84 bool isEmpty() const;
85
86 /**
87 * \return The size of an individual frame in the sequence.
88 */
89 QSize frameSize() const;
90
91 /**
92 * The number of frames in this sequence.
93 */
94 int frameCount() const;
95
96 /**
97 * Retrieve the frame at \p index.
98 *
99 * \param index The index of the frame in question starting at 0.
100 */
101 QPixmap frameAt(int index) const;
102
103private:
104 QSharedDataPointer<class KPixmapSequencePrivate> d;
105};
106
107#endif
108

source code of kwidgetsaddons/src/kpixmapsequence.h