KWidgetsAddons

kbusyindicatorwidget.h
1/*
2 SPDX-FileCopyrightText: 2019 Harald Sitter <sitter@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#ifndef KBUSYINDICATORWIDGET_H
8#define KBUSYINDICATORWIDGET_H
9
10#include <QWidget>
11#include <kwidgetsaddons_export.h>
12#include <memory>
13
14/**
15 * @class KBusyIndicatorWidget kbusyindicatorwidget.h KBusyIndicatorWidget
16 *
17 * @brief Rotating spinning icon to indicate busyness
18 *
19 * When you need to communicate to the user that your application is busy with
20 * something you'll want to use a KBusyIndicatorWidget to display an spinnning
21 * indicator icon. The spinning animation can be stopped and started.
22 *
23 * A way of using this widget is to combine it with a QLabel to construct a
24 * status line:
25 *
26 * ```
27 * auto layout = new QHBoxLayout;
28 * layout->addWidget(new KBusyIndicatorWidget);
29 * layout->addWidget(new QLabel(QStringLiteral("Watering the flowers...")));
30 * ```
31 *
32 * @image html kbusyindicatorwidget.png "KBusyIndicatorWidget with label"
33 *
34 * The KBusyIndicatorWidget differs from the KPixmapSequenceWidget by animating
35 * a scaled icon instead of rendering a pixmap sequence. It supports multiple,
36 * semi-arbitrary sizes, with quality constrained only by the resolution of the
37 * available icons.
38 *
39 * @since 5.61.0
40 */
41class KWIDGETSADDONS_EXPORT KBusyIndicatorWidget : public QWidget
42{
44
45 Q_PROPERTY(bool isRunning READ isRunning WRITE setRunning)
46
47public:
48 /**
49 * Create a new KBusyIndicatorWidget widget
50 */
51 explicit KBusyIndicatorWidget(QWidget *parent = nullptr);
52
53 /**
54 * Destroy the widget
55 */
57
58 /**
59 * Return the smallest reasonable size for the widget
60 *
61 * @return Minimum size as a QSize object
62 */
63 QSize minimumSizeHint() const override;
64
65 /**
66 * Return whether the spinning animation is running
67 *
68 * @return if the spinning animation is running
69 *
70 * @see setRunning()
71 *
72 * @since 6.11.0
73 */
74 bool isRunning() const;
75
76public Q_SLOTS:
77 /**
78 * Start the spinning animation
79 *
80 * @see setRunning()
81 *
82 * @since 6.10.0
83 */
84 void start();
85
86 /**
87 * Stop the spinning animation
88 *
89 * @see setRunning()
90 *
91 * @since 6.10.0
92 */
93 void stop();
94
95 /**
96 * By calling this method with @p enable = true the spinning
97 * abnimation will be started. Stopped if false.
98 *
99 * @see start()
100 * @see stop()
101 *
102 * @since 6.11.0
103 */
104 void setRunning(const bool enable = true);
105
106protected:
107 void showEvent(QShowEvent *event) override;
108 void hideEvent(QHideEvent *event) override;
109 void resizeEvent(QResizeEvent *event) override;
110 void paintEvent(QPaintEvent *) override;
111 bool event(QEvent *event) override;
112
113private:
114 std::unique_ptr<class KBusyIndicatorWidgetPrivate> const d;
115};
116
117#endif // KBUSYINDICATORWIDGET_H
void setRunning(const bool enable=true)
By calling this method with enable = true the spinning abnimation will be started.
~KBusyIndicatorWidget() override
Destroy the widget.
KBusyIndicatorWidget(QWidget *parent=nullptr)
Create a new KBusyIndicatorWidget widget.
void stop(Ekos::AlignState mode)
Q_SCRIPTABLE Q_NOREPLY void start()
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SLOTSQ_SLOTS
QObject * parent() const const
QWidget(QWidget *parent, Qt::WindowFlags f)
virtual bool event(QEvent *event) override
virtual void hideEvent(QHideEvent *event)
virtual void paintEvent(QPaintEvent *event)
virtual void resizeEvent(QResizeEvent *event)
virtual void showEvent(QShowEvent *event)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:56:58 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.