Pool Video Switch v2
Software video switch for distributed remote display in a lecture environment
connectionframe.h
Go to the documentation of this file.
1 #ifndef PVS_CONNECTIONFRAME_H_
2 #define PVS_CONNECTIONFRAME_H_
3 
4 #include <QGroupBox>
5 #include <utility>
6 
7 class QBoxLayout;
8 class QLabel;
9 
10 class MainWindow;
11 class Client;
12 
17 class ConnectionFrame : public QGroupBox
18 {
19 
20  Q_OBJECT
21 
22 private:
23 
24  QString _computerId;
25 
26  QBoxLayout *_mainLayout;
27  QBoxLayout *_iconLayout;
31 
33  QList<QLabel*> _icons;
34 
35  QImage _remoteScreen;
36 
37  QPoint _clickPoint;
39  QPoint _gridPosition;
41 
43 
45  bool _isSelected{};
46  bool _isTutor{};
48 
49  void showDefaultThumb();
50  void calcDesiredThumbSize(const QSize &frameSize);
51  QLabel* addIcon(const QIcon* icon);
52 
54 
55 public:
56 
57  static bool paintDisabled;
58 
59  ConnectionFrame(MainWindow* main, QWidget* parent, bool fromRoomplan = false);
60  ~ConnectionFrame() override;
61 
62  const QPoint& getGridPosition() const { return _gridPosition; }
63  void setGridPosition(int x, int y);
64  void setGridPosition(const QPoint& pos);
65  void updateGeometry();
66 
67  void assignClient(Client *client);
68  void setSelection(bool selected);
69  bool isSelected() const { return _isSelected; }
70 
71  const QString& computerId() const { return _computerId; }
72  void setComputerId(QString computerId) {
73  if (_client != nullptr)
74  return;
75  _computerId = std::move(computerId); updateLabels();
76  }
77  Client* client() const { return _client; }
78 
79  bool isTutor() const { return _isTutor; }
80  bool isFromRoomplan() const { return _isFromRoomplan; }
81  void setTutor(bool b);
82 
83 protected:
84  void resizeEvent(QResizeEvent* event) override;
85  void mouseDoubleClickEvent(QMouseEvent* event) override;
86  void mouseReleaseEvent(QMouseEvent* e) override;
87  void enterEvent(QEvent* event) override;
88  void leaveEvent(QEvent* event) override;
89  void mousePressEvent(QMouseEvent* event) override;
90  void mouseMoveEvent(QMouseEvent* event) override;
91  void paintEvent(QPaintEvent *event) override;
92  void timerEvent(QTimerEvent* event) override;
93 
94 signals:
95  void frameMoving(ConnectionFrame* frame);
96  void frameMoved(ConnectionFrame* frame);
97  void doubleClicked(ConnectionFrame* frame);
98  void clicked(ConnectionFrame* frame);
99 
100 private slots:
101  void onClientDisconnected();
102  void onThumbUpdated(Client* client, const QImage& thumb);
103  void updateAppearance();
104  void updateLabels();
105 };
106 
107 #endif
QLabel * _lblHostName
void onClientDisconnected()
Handle if client was disconnected.
bool isFromRoomplan() const
void leaveEvent(QEvent *event) override
Handle mouse leaves frame.
~ConnectionFrame() override
void setTutor(bool b)
Set tutor status of frame.
QLabel * _lblUserName
Client * client() const
void timerEvent(QTimerEvent *event) override
Handle timer event.
void onThumbUpdated(Client *client, const QImage &thumb)
Update thumb of specific client.
void paintEvent(QPaintEvent *event) override
Draw remote screen in frame.
void setGridPosition(int x, int y)
void doubleClicked(ConnectionFrame *frame)
void mousePressEvent(QMouseEvent *event) override
Handle mouse press on frame.
bool isTutor() const
QBoxLayout * _iconLayout
const QString & computerId() const
void resizeEvent(QResizeEvent *event) override
void showDefaultThumb()
Show default thumg instead of remote screen in connectionFrame.
QLabel * addIcon(const QIcon *icon)
Add icon to connection frame.
static bool paintDisabled
void updateAppearance()
Update appearence of frame.
void setComputerId(QString computerId)
QList< QLabel * > _icons
void mouseMoveEvent(QMouseEvent *event) override
Hanle mouse movement over frame.
MainWindow * _mainWindow
QPoint _previousPosition
const QPoint & getGridPosition() const
Definition: client.h:23
bool isSelected() const
void setSelection(bool selected)
Set frame as selected or not.
QLabel * _lblExamMode
void enterEvent(QEvent *event) override
Handle if mouse reaches frame.
void frameMoved(ConnectionFrame *frame)
void calcDesiredThumbSize(const QSize &frameSize)
Class for representing the clients of current session, with a specific frame displaying username and ...
void clicked(ConnectionFrame *frame)
ConnectionFrame(MainWindow *main, QWidget *parent, bool fromRoomplan=false)
Initialize frame for connected client.
QBoxLayout * _mainLayout
void assignClient(Client *client)
Assign client to connectionFrame.
void mouseDoubleClickEvent(QMouseEvent *event) override
Handle double click event on frame.
Initializing MainWindow.
Definition: mainwindow.h:27
void frameMoving(ConnectionFrame *frame)
void mouseReleaseEvent(QMouseEvent *e) override
Handle mouse release event on frame.
int main(int argc, char **argv)
Definition: main.cpp:12