59 Q_PROPERTY(
int channelCount READ channelCount WRITE setChannelCount NOTIFY appearanceChanged)
60 Q_PROPERTY(
double minimum READ minimum WRITE setMinimum NOTIFY rangeChanged)
61 Q_PROPERTY(
double maximum READ maximum WRITE setMaximum NOTIFY rangeChanged)
62 Q_PROPERTY(
double warningThreshold READ warningThreshold WRITE setWarningThreshold NOTIFY appearanceChanged)
63 Q_PROPERTY(
double errorThreshold READ errorThreshold WRITE setErrorThreshold NOTIFY appearanceChanged)
64 Q_PROPERTY(
int segmentCount READ segmentCount WRITE setSegmentCount NOTIFY appearanceChanged)
65 Q_PROPERTY(DisplayMode displayMode READ displayMode WRITE setDisplayMode NOTIFY appearanceChanged)
66 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY appearanceChanged)
67 Q_PROPERTY(
bool peakHoldEnabled READ isPeakHoldEnabled WRITE setPeakHoldEnabled NOTIFY appearanceChanged)
68 Q_PROPERTY(
int peakHoldTimeMs READ peakHoldTimeMs WRITE setPeakHoldTimeMs NOTIFY appearanceChanged)
69 Q_PROPERTY(
double peakDecayRate READ peakDecayRate WRITE setPeakDecayRate NOTIFY appearanceChanged)
70 Q_PROPERTY(
bool scaleVisible READ isScaleVisible WRITE setScaleVisible NOTIFY appearanceChanged)
71 Q_PROPERTY(QString unit READ unit WRITE setUnit NOTIFY appearanceChanged)
72 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY appearanceChanged)
73 Q_PROPERTY(QColor normalColor READ normalColor WRITE setNormalColor NOTIFY appearanceChanged)
74 Q_PROPERTY(QColor warningColor READ warningColor WRITE setWarningColor NOTIFY appearanceChanged)
75 Q_PROPERTY(QColor errorColor READ errorColor WRITE setErrorColor NOTIFY appearanceChanged)
76 Q_PROPERTY(QColor peakColor READ peakColor WRITE setPeakColor NOTIFY appearanceChanged)
77 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY appearanceChanged)
78 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor NOTIFY appearanceChanged)
82 enum class DisplayMode {
92 explicit LevelMeter(QWidget *parent =
nullptr);
96 [[nodiscard]]
int channelCount()
const;
98 [[nodiscard]]
double minimum()
const;
100 [[nodiscard]]
double maximum()
const;
102 [[nodiscard]]
double warningThreshold()
const;
104 [[nodiscard]]
double errorThreshold()
const;
106 [[nodiscard]]
int segmentCount()
const;
108 [[nodiscard]] DisplayMode displayMode()
const;
110 [[nodiscard]] Qt::Orientation orientation()
const;
112 [[nodiscard]]
bool isPeakHoldEnabled()
const;
114 [[nodiscard]]
int peakHoldTimeMs()
const;
116 [[nodiscard]]
double peakDecayRate()
const;
118 [[nodiscard]]
bool isScaleVisible()
const;
120 [[nodiscard]] QString unit()
const;
122 [[nodiscard]] QString title()
const;
125 [[nodiscard]]
double value(
int channel = 0)
const;
127 [[nodiscard]]
double peakValue(
int channel = 0)
const;
129 [[nodiscard]] QVector<double> values()
const;
132 [[nodiscard]] QStringList channelLabels()
const;
135 [[nodiscard]] QColor normalColor()
const;
137 [[nodiscard]] QColor warningColor()
const;
139 [[nodiscard]] QColor errorColor()
const;
141 [[nodiscard]] QColor peakColor()
const;
143 [[nodiscard]] QColor backgroundColor()
const;
145 [[nodiscard]] QColor textColor()
const;
147 [[nodiscard]] QSize sizeHint()
const override;
148 [[nodiscard]] QSize minimumSizeHint()
const override;
152 void setValue(
double value);
154 void setValue(
int channel,
double value);
156 void setValues(
const QVector<double> &values);
161 void setChannelCount(
int count);
163 void setRange(
double min,
double max);
165 void setMinimum(
double min);
167 void setMaximum(
double max);
169 void setWarningThreshold(
double threshold);
171 void setErrorThreshold(
double threshold);
173 void setSegmentCount(
int count);
175 void setDisplayMode(DisplayMode mode);
177 void setOrientation(Qt::Orientation orientation);
179 void setPeakHoldEnabled(
bool enabled);
181 void setPeakHoldTimeMs(
int ms);
183 void setPeakDecayRate(
double rate);
185 void setScaleVisible(
bool visible);
187 void setUnit(
const QString &unit);
189 void setTitle(
const QString &title);
191 void setChannelLabels(
const QStringList &labels);
193 void setNormalColor(
const QColor &color);
195 void setWarningColor(
const QColor &color);
197 void setErrorColor(
const QColor &color);
199 void setPeakColor(
const QColor &color);
201 void setBackgroundColor(
const QColor &color);
203 void setTextColor(
const QColor &color);
207 void valueChanged(
int channel,
double value);
209 void overloadOccurred(
int channel);
211 void rangeChanged(
double min,
double max);
213 void appearanceChanged();
216 void paintEvent(QPaintEvent *event)
override;
217 void resizeEvent(QResizeEvent *event)
override;
218 void changeEvent(QEvent *event)
override;
221 void updatePeakDecay();
224 void renderStaticBackground();
225 void drawChannelBar(QPainter &painter,
int chIndex,
const QRectF &barRect);
226 void drawSegmentedBar(QPainter &painter,
double val,
double peakVal,
const QRectF &barRect);
227 void drawContinuousBar(QPainter &painter,
double val,
double peakVal,
const QRectF &barRect);
228 QColor colorForNormalizedValue(
double norm)
const;
229 QVector<QRectF> calculateBarRects(
const QRectF &contentRect)
const;
231 std::unique_ptr<LevelMeterPrivate> d_ptr;