VolControl.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #include <obs.hpp>
  3. #include <QFrame>
  4. class OBSSourceLabel;
  5. class VolumeMeter;
  6. class VolumeSlider;
  7. class MuteCheckBox;
  8. class QLabel;
  9. class QPushButton;
  10. class VolControl : public QFrame {
  11. Q_OBJECT
  12. private:
  13. OBSSource source;
  14. std::vector<OBSSignal> sigs;
  15. OBSSourceLabel *nameLabel;
  16. QLabel *volLabel;
  17. VolumeMeter *volMeter;
  18. VolumeSlider *slider;
  19. MuteCheckBox *mute;
  20. QPushButton *config = nullptr;
  21. float levelTotal;
  22. float levelCount;
  23. OBSFader obs_fader;
  24. OBSVolMeter obs_volmeter;
  25. bool vertical;
  26. QMenu *contextMenu;
  27. static void OBSVolumeChanged(void *param, float db);
  28. static void OBSVolumeLevel(void *data, const float magnitude[MAX_AUDIO_CHANNELS],
  29. const float peak[MAX_AUDIO_CHANNELS], const float inputPeak[MAX_AUDIO_CHANNELS]);
  30. static void OBSVolumeMuted(void *data, calldata_t *calldata);
  31. static void OBSMixersOrMonitoringChanged(void *data, calldata_t *);
  32. void EmitConfigClicked();
  33. private slots:
  34. void VolumeChanged();
  35. void VolumeMuted(bool muted);
  36. void MixersOrMonitoringChanged();
  37. void SetMuted(bool checked);
  38. void SliderChanged(int vol);
  39. void updateText();
  40. signals:
  41. void ConfigClicked();
  42. public:
  43. explicit VolControl(OBSSource source, bool showConfig = false, bool vertical = false);
  44. ~VolControl();
  45. inline obs_source_t *GetSource() const { return source; }
  46. void SetMeterDecayRate(qreal q);
  47. void setPeakMeterType(enum obs_peak_meter_type peakMeterType);
  48. void EnableSlider(bool enable);
  49. inline void SetContextMenu(QMenu *cm) { contextMenu = cm; }
  50. void refreshColors();
  51. };