QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ProgressState.h
Go to the documentation of this file.
1#pragma once
2
3#include "QGCState.h"
4
5#include <functional>
6
25class ProgressState : public QGCState
26{
27 Q_OBJECT
28 Q_DISABLE_COPY(ProgressState)
29
30public:
31 using ProgressCallback = std::function<float()>;
32 using Action = std::function<void()>;
33
39 ProgressState(const QString& stateName, QState* parent, float progress, Action action = nullptr);
40
46 ProgressState(const QString& stateName, QState* parent, ProgressCallback progressCallback, Action action = nullptr);
47
49 float progress() const;
50
52 void setProgress(float progress);
53
56
57signals:
60
61protected:
62 void onEnter() override;
63
64private:
65 float _fixedProgress = 0.0f;
66 ProgressCallback _progressCallback;
67 Action _action;
68 bool _useCallback = false;
69};
void onEnter() override
Override to perform actions on state entry.
float progress() const
Get the current progress value.
void progressChanged(float progress)
Emitted when the state is entered with the current progress value.
std::function< void()> Action
void setProgress(float progress)
Set a fixed progress value.
void setProgressCallback(ProgressCallback callback)
Set a progress callback.
std::function< float()> ProgressCallback
QString stateName() const