volume-control.hpp 893 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include <obs.hpp>
  3. #include <QWidget>
  4. #include <QProgressBar>
  5. /* TODO: Make a real volume control that isn't terrible */
  6. class QLabel;
  7. class QSlider;
  8. class VolControl : public QWidget {
  9. Q_OBJECT
  10. private:
  11. OBSSource source;
  12. QLabel *nameLabel;
  13. QLabel *volLabel;
  14. QProgressBar *volMeter;
  15. QSlider *slider;
  16. bool signalChanged;
  17. uint64_t lastMeterTime;
  18. float levelTotal;
  19. float levelCount;
  20. static void OBSVolumeChanged(void *param, calldata_t calldata);
  21. static void OBSVolumeLevel(void *data, calldata_t calldata);
  22. private slots:
  23. void VolumeChanged(int vol);
  24. void VolumeLevel(float level);
  25. void SliderChanged(int vol);
  26. public:
  27. VolControl(OBSSource source);
  28. ~VolControl();
  29. inline obs_source_t GetSource() const {return source;}
  30. QString GetName() const;
  31. void SetName(const QString &newName);
  32. };