#pragma once #include #include #include #include #include #include namespace scar { class ScreenCapture; class ClientConnection; struct VideoStream { QString streamId; QString username; QLabel* videoLabel; }; class VideoGridWidget : public QWidget { Q_OBJECT public: explicit VideoGridWidget(QWidget* parent = nullptr); ~VideoGridWidget(); void setConnection(ClientConnection* connection); 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(); } signals: void screenShareRequested(); private slots: void onScreenShareClicked(); private: void resizeEvent(QResizeEvent* event) override; void updateScreenShareButtonPosition(); void updateGridLayout(); int calculateColumns(int streamCount); QGridLayout* gridLayout_; QLabel* placeholderLabel_; std::vector streams_; QPushButton* screenShareButton_; ScreenCapture* screenCapture_; ClientConnection* connection_; bool isScreenSharing_; static constexpr int MAX_STREAMS = 256; }; } // namespace scar