LibrePCB Developers Documentation
waitingspinnerwidget.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_EDITOR_WAITINGSPINNERWIDGET_H
21#define LIBREPCB_EDITOR_WAITINGSPINNERWIDGET_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include <QtCore>
27#include <QtWidgets>
28
29/*******************************************************************************
30 * Namespace / Forward Declarations
31 ******************************************************************************/
32namespace librepcb {
33namespace editor {
34
35/*******************************************************************************
36 * Class WaitingSpinnerWidget
37 ******************************************************************************/
38
52class WaitingSpinnerWidget final : public QWidget {
53 Q_OBJECT
54
55public:
56 // Constructors / Destructor
57 explicit WaitingSpinnerWidget(QWidget* parent = nullptr) noexcept;
59 ~WaitingSpinnerWidget() noexcept;
60
61 // Setters
62 void setColor(const QColor& color) noexcept { mColor = color; }
63
64 // Operator Overloadings
66
67protected: // Methods
68 void showEvent(QShowEvent* e) noexcept override;
69 void hideEvent(QHideEvent* e) noexcept override;
70 void paintEvent(QPaintEvent* e) noexcept override;
71 bool eventFilter(QObject* watched, QEvent* event) noexcept override;
72
73private: // Methods
74 int calculateSize() const noexcept;
75 void updateSize() noexcept;
76 void updatePosition() noexcept;
77
78private: // Data
79 QColor mColor;
85 QScopedPointer<QTimer> mTimer;
86 QPointer<QWidget> mEventFilterObject;
87};
88
89/*******************************************************************************
90 * End of File
91 ******************************************************************************/
92
93} // namespace editor
94} // namespace librepcb
95
96#endif
A widget drawing a rotating spinner to indicate an ongoing operation.
Definition: waitingspinnerwidget.h:52
QPointer< QWidget > mEventFilterObject
Definition: waitingspinnerwidget.h:86
bool eventFilter(QObject *watched, QEvent *event) noexcept override
Definition: waitingspinnerwidget.cpp:108
void updateSize() noexcept
Definition: waitingspinnerwidget.cpp:124
void showEvent(QShowEvent *e) noexcept override
Definition: waitingspinnerwidget.cpp:77
void updatePosition() noexcept
Definition: waitingspinnerwidget.cpp:129
void hideEvent(QHideEvent *e) noexcept override
Definition: waitingspinnerwidget.cpp:82
WaitingSpinnerWidget(const WaitingSpinnerWidget &other)=delete
QScopedPointer< QTimer > mTimer
Definition: waitingspinnerwidget.h:85
void setColor(const QColor &color) noexcept
Definition: waitingspinnerwidget.h:62
WaitingSpinnerWidget(QWidget *parent=nullptr) noexcept
Definition: waitingspinnerwidget.cpp:38
WaitingSpinnerWidget & operator=(const WaitingSpinnerWidget &rhs)=delete
int mCircleDiameter
Definition: waitingspinnerwidget.h:82
int mMargin
Definition: waitingspinnerwidget.h:84
QColor mColor
Definition: waitingspinnerwidget.h:79
int mTotalRotations
Definition: waitingspinnerwidget.h:80
int calculateSize() const noexcept
Definition: waitingspinnerwidget.cpp:120
int mCurrentRotation
Definition: waitingspinnerwidget.h:81
void paintEvent(QPaintEvent *e) noexcept override
Definition: waitingspinnerwidget.cpp:87
~WaitingSpinnerWidget() noexcept
Definition: waitingspinnerwidget.cpp:70
int mDotDiameter
Definition: waitingspinnerwidget.h:83
Definition: occmodel.cpp:77