/****************************************************************************** Copyright (C) 2025 by Taylor Giampaolo Lain Bailey This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ******************************************************************************/ #pragma once #include #include #include #include #include #include class QLabel; class Thumbnail; class ThumbnailView; class SourceSelectButton : public QAbstractButton { Q_OBJECT public: SourceSelectButton(OBSWeakSource weak, QWidget *parent = nullptr); ~SourceSelectButton(); std::string_view uuid() const { return sourceUuid; }; void setThumbnailEnabled(bool enabled); void updateThumbnail(); protected: void paintEvent(QPaintEvent *event) override; void resizeEvent(QResizeEvent *event) override; void enterEvent(QEnterEvent *event) override; void leaveEvent(QEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; void buttonPressed(); private: OBSWeakSource weakSource; QPointer thumbnail; QPointer image; std::string sourceUuid; std::vector signalHandlers; static void obsSourceRemoved(void *param, calldata_t *calldata); static void obsSourceRenamed(void *param, calldata_t *calldata); QLabel *label = nullptr; bool thumbnailEnabled = true; QPoint dragStartPosition; private slots: void updatePixmap(QPixmap pixmap); void handleSourceRemoved(); void handleSourceRenamed(QString name); signals: void sourceRemoved(); };