SourceSelectButton.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /******************************************************************************
  2. Copyright (C) 2025 by Taylor Giampaolo <[email protected]>
  3. Lain Bailey <[email protected]>
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. ******************************************************************************/
  15. #pragma once
  16. #include <obs.hpp>
  17. #include <QLabel>
  18. #include <QPointer>
  19. #include <QPushButton>
  20. #include <QTimer>
  21. #include <QVBoxLayout>
  22. class QLabel;
  23. class Thumbnail;
  24. class SourceSelectButton : public QFrame {
  25. Q_OBJECT
  26. public:
  27. SourceSelectButton(obs_source_t *source, QWidget *parent = nullptr);
  28. ~SourceSelectButton();
  29. QPointer<QPushButton> getButton();
  30. QString text();
  31. void setRectVisible(bool visible);
  32. void setPreload(bool preload);
  33. protected:
  34. void resizeEvent(QResizeEvent *event) override;
  35. void moveEvent(QMoveEvent *event) override;
  36. void mouseMoveEvent(QMouseEvent *event) override;
  37. void buttonPressed();
  38. private:
  39. OBSWeakSource weakSource;
  40. std::shared_ptr<Thumbnail> thumbnail;
  41. QPointer<QLabel> image;
  42. QPushButton *button = nullptr;
  43. QVBoxLayout *layout = nullptr;
  44. QLabel *label = nullptr;
  45. bool preload = true;
  46. bool rectVisible = false;
  47. void setDefaultThumbnail();
  48. QPoint dragStartPosition;
  49. private slots:
  50. void thumbnailUpdated(QPixmap pixmap);
  51. };