KWidgetsAddons

kpixmapsequenceoverlaypainter.h
1/*
2 SPDX-FileCopyrightText: 2009 Sebastian Trueg <trueg@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#ifndef _K_PIXMAPSEQUENCE_OVERLAY_PAINTER_H_
8#define _K_PIXMAPSEQUENCE_OVERLAY_PAINTER_H_
9
10#include <QObject>
11#include <QPoint>
12#include <memory>
13
14#include <kwidgetsaddons_export.h>
15
16class KPixmapSequence;
17class QWidget;
18class QEvent;
19class QRect;
20
21/**
22 * \class KPixmapSequenceOverlayPainter kpixmapsequenceoverlaypainter.h KPixmapSequenceOverlayPainter
23 *
24 * \brief Paints a KPixmapSequence on top of any widget at any position.
25 *
26 * The KPixmapSequenceOverlayPainter paints an overlay on top of an arbitrary QWidget
27 * using a KPixmapSequence. This is typically used for spinners indicating that a process
28 * is not finished yet.
29 *
30 * \author Sebastian Trueg <trueg@kde.org>
31 *
32 * \since 4.4
33 */
34class KWIDGETSADDONS_EXPORT KPixmapSequenceOverlayPainter : public QObject
35{
36 Q_OBJECT
37
38public:
39 /**
40 * Constructor
41 */
42 explicit KPixmapSequenceOverlayPainter(QObject *parent = nullptr);
43 KPixmapSequenceOverlayPainter(const KPixmapSequence &seq, QObject *parent = nullptr);
44
45 /**
46 * Destructor
47 */
49
50 /**
51 * The sequence used to draw the overlay.
52 *
53 * \sa setSequence
54 */
55 KPixmapSequence sequence() const;
56
57 /**
58 * The interval between frames.
59 *
60 * \sa setInterval
61 */
62 int interval() const;
63
64 /**
65 * The optional rect to draw the pixmaps in.
66 * \sa setRect
67 */
68 QRect rect() const;
69
70 /**
71 * The alignment of the pixmaps in the rect.
72 * \sa setAlignment
73 */
74 Qt::Alignment alignment() const;
75
76 /**
77 * The optional offset within the rect.
78 * \sa setOffset
79 */
80 QPoint offset() const;
81
82public Q_SLOTS:
83 /**
84 * Set the sequence to be used. By default the KDE busy sequence is used.
85 */
86 void setSequence(const KPixmapSequence &seq);
87
88 /**
89 * Set the interval between frames. The default is 200.
90 */
91 void setInterval(int msecs);
92
93 /**
94 * Set the widget to draw the overlay on.
95 */
96 void setWidget(QWidget *w);
97
98 /**
99 * Set the rect in which to place the sequence. Be aware that
100 * this optional property does not scale the pixmaps (except if
101 * it is smaller) but allows to change the placement.
102 *
103 * \param rect The rect in which to draw the pixmap using alignment
104 * and offset. Be aware that setting a rect bigger than the widget
105 * can lead to weird painting errors.
106 *
107 * Defaults to the widget's rect.
108 */
109 void setRect(const QRect &rect);
110
111 /**
112 * Set the alignment of the sequence in rect.
113 *
114 * \param align alignment of the overlay. Qt::AlignJustify does not make sense here.
115 * Defaults to Qt::Center.
116 */
117 void setAlignment(Qt::Alignment align);
118
119 /**
120 * Set the offset relative to the placement determined by alignment
121 * and rect.
122 *
123 * \param offset An optional offset which allows an absolute placement.
124 *
125 * Defaults to an empty point.
126 */
127 void setOffset(const QPoint &offset);
128
129 /**
130 * Start drawing the sequence.
131 *
132 * The overlay will be drawn until a call to stop()
133 */
134 void start();
135
136 /**
137 * Stop drawing the overlay.
138 */
139 void stop();
140
141protected:
142 bool eventFilter(QObject *obj, QEvent *event) override;
143
144private:
145 std::unique_ptr<class KPixmapSequenceOverlayPainterPrivate> const d;
146};
147
148#endif
Paints a KPixmapSequence on top of any widget at any position.
Loads and gives access to the frames of a typical multi-row pixmap as often used for spinners.
void stop(Ekos::AlignState mode)
Q_SCRIPTABLE Q_NOREPLY void start()
Q_SLOTSQ_SLOTS
virtual bool eventFilter(QObject *watched, QEvent *event)
typedef Alignment
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 19 2024 11:51:03 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.