#ifndef PVS_CONNECTIONFRAME_H_ #define PVS_CONNECTIONFRAME_H_ #include #include class QBoxLayout; class QLabel; class MainWindow; class Client; /** * Class for representing the clients of current session, with a specific frame * displaying username and hostname for each one. */ class ConnectionFrame : public QGroupBox { Q_OBJECT private: QString _computerId; QBoxLayout *_mainLayout; QBoxLayout *_iconLayout; QLabel *_lblUserName; QLabel *_lblHostName; QLabel *_lblExamMode; QLabel *_icoCam, *_icoEye, *_icoLock; QList _icons; QImage _remoteScreen; QPoint _clickPoint; QPoint _previousPosition; QPoint _gridPosition; QSize _desiredThumbSize; Client *_client{}; int _timerId{}, _timerCounter{}; bool _isSelected{}; bool _isTutor{}; bool _isFromRoomplan; void showDefaultThumb(); void calcDesiredThumbSize(const QSize &frameSize); QLabel* addIcon(const QIcon* icon); MainWindow *_mainWindow; public: static bool paintDisabled; ConnectionFrame(MainWindow* main, QWidget* parent, bool fromRoomplan = false); ~ConnectionFrame() override; const QPoint& getGridPosition() const { return _gridPosition; } void setGridPosition(int x, int y); void setGridPosition(const QPoint& pos); void updateGeometry(); void assignClient(Client *client); void setSelection(bool selected); bool isSelected() const { return _isSelected; } const QString& computerId() const { return _computerId; } void setComputerId(QString computerId) { if (_client != nullptr) return; _computerId = std::move(computerId); updateLabels(); } Client* client() const { return _client; } bool isTutor() const { return _isTutor; } bool isFromRoomplan() const { return _isFromRoomplan; } void setTutor(bool b); protected: void resizeEvent(QResizeEvent* event) override; void mouseDoubleClickEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* e) override; void enterEvent(QEvent* event) override; void leaveEvent(QEvent* event) override; void mousePressEvent(QMouseEvent* event) override; void mouseMoveEvent(QMouseEvent* event) override; void paintEvent(QPaintEvent *event) override; void timerEvent(QTimerEvent* event) override; signals: void frameMoving(ConnectionFrame* frame); void frameMoved(ConnectionFrame* frame); void doubleClicked(ConnectionFrame* frame); void clicked(ConnectionFrame* frame); private slots: void onClientDisconnected(); void onThumbUpdated(Client* client, const QImage& thumb); void updateAppearance(); void updateLabels(); }; #endif