audio_widget.h 850 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef __AUDIO_WIDGET_H__
  2. #define __AUDIO_WIDGET_H__
  3. #include <QCheckBox>
  4. #include <QLabel>
  5. #include <QPushButton>
  6. #include <QSlider>
  7. #include <QSpinBox>
  8. #include "audio_render.h"
  9. class AudioWidget : public QWidget
  10. {
  11. Q_OBJECT
  12. public:
  13. AudioWidget(QWidget* parent = nullptr);
  14. void ShowVolume(float volume)
  15. {
  16. _render->setLevel(volume);
  17. _render->update();
  18. }
  19. void SetName(const std::string& name) { _nameLabel->setText(name.c_str()); }
  20. double GetVolume() { return _mutebox->isChecked() ? 0 : _volumeBox->value(); }
  21. private:
  22. void _CreateUi();
  23. void _CreateConnect();
  24. QLabel* _nameLabel = nullptr;
  25. AudioRender* _render = nullptr;
  26. QCheckBox* _mutebox = nullptr;
  27. QDoubleSpinBox* _volumeBox = nullptr;
  28. float _lastShowVal = 0;
  29. signals:
  30. void SetVolumeScale(float scale);
  31. };
  32. #endif