2025-12-07 12:00:44 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
#include <QGridLayout>
|
|
|
|
|
#include <QLabel>
|
2025-12-07 14:03:08 -07:00
|
|
|
#include <QPushButton>
|
2025-12-07 12:00:44 -07:00
|
|
|
#include <vector>
|
2025-12-07 14:03:08 -07:00
|
|
|
#include <memory>
|
2025-12-07 12:00:44 -07:00
|
|
|
|
|
|
|
|
namespace scar {
|
|
|
|
|
|
2025-12-07 14:03:08 -07:00
|
|
|
class ScreenCapture;
|
|
|
|
|
class ClientConnection;
|
|
|
|
|
|
2025-12-07 12:00:44 -07:00
|
|
|
struct VideoStream {
|
|
|
|
|
QString streamId;
|
|
|
|
|
QString username;
|
|
|
|
|
QLabel* videoLabel;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class VideoGridWidget : public QWidget {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit VideoGridWidget(QWidget* parent = nullptr);
|
2025-12-07 14:03:08 -07:00
|
|
|
~VideoGridWidget();
|
2025-12-07 12:00:44 -07:00
|
|
|
|
2025-12-07 14:03:08 -07:00
|
|
|
void setConnection(ClientConnection* connection);
|
2025-12-07 12:00:44 -07:00
|
|
|
void addStream(const QString& streamId, const QString& username);
|
|
|
|
|
void removeStream(const QString& streamId);
|
|
|
|
|
void updateFrame(const QString& streamId, const QPixmap& frame);
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
|
|
int streamCount() const { return streams_.size(); }
|
|
|
|
|
|
2025-12-07 14:03:08 -07:00
|
|
|
signals:
|
|
|
|
|
void screenShareRequested();
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void onScreenShareClicked();
|
|
|
|
|
|
2025-12-07 12:00:44 -07:00
|
|
|
private:
|
2025-12-07 14:03:08 -07:00
|
|
|
void resizeEvent(QResizeEvent* event) override;
|
|
|
|
|
void updateScreenShareButtonPosition();
|
2025-12-07 12:00:44 -07:00
|
|
|
void updateGridLayout();
|
|
|
|
|
int calculateColumns(int streamCount);
|
|
|
|
|
|
|
|
|
|
QGridLayout* gridLayout_;
|
|
|
|
|
QLabel* placeholderLabel_;
|
|
|
|
|
std::vector<VideoStream> streams_;
|
2025-12-07 14:03:08 -07:00
|
|
|
QPushButton* screenShareButton_;
|
|
|
|
|
ScreenCapture* screenCapture_;
|
|
|
|
|
ClientConnection* connection_;
|
|
|
|
|
bool isScreenSharing_;
|
2025-12-07 12:00:44 -07:00
|
|
|
|
|
|
|
|
static constexpr int MAX_STREAMS = 256;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace scar
|