VolumeName.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /******************************************************************************
  2. Copyright (C) 2025 by Taylor Giampaolo <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include <obs.hpp>
  16. #include <QAbstractButton>
  17. #include <QLabel>
  18. #include <QPointer>
  19. class VolumeName : public QAbstractButton {
  20. Q_OBJECT;
  21. Q_PROPERTY(Qt::Alignment textAlignment READ alignment WRITE setAlignment)
  22. QPointer<QLabel> label{};
  23. int indicatorWidth;
  24. public:
  25. VolumeName(obs_source_t *source, QWidget *parent = nullptr);
  26. ~VolumeName();
  27. void setAlignment(Qt::Alignment alignment);
  28. Qt::Alignment alignment() const { return textAlignment; }
  29. QSize sizeHint() const override;
  30. void updateLabelText(const QString &name);
  31. void setText(const QString &text);
  32. protected:
  33. OBSSignal renamedSignal;
  34. OBSSignal removedSignal;
  35. OBSSignal destroyedSignal;
  36. Qt::Alignment textAlignment = Qt::AlignLeft;
  37. static void obsSourceRenamed(void *data, calldata_t *params);
  38. static void obsSourceRemoved(void *data, calldata_t *params);
  39. static void obsSourceDestroyed(void *data, calldata_t *params);
  40. void resizeEvent(QResizeEvent *event) override;
  41. void paintEvent(QPaintEvent *event) override;
  42. private slots:
  43. void onRenamed(QString name);
  44. void onRemoved();
  45. void onDestroyed();
  46. signals:
  47. void renamed(const char *name);
  48. void removed();
  49. void destroyed();
  50. };