Pool Video Switch v2
Software video switch for distributed remote display in a lecture environment
mainwindow.h
Go to the documentation of this file.
1 #ifndef PVS_MAINWINDOW_H_
2 #define PVS_MAINWINDOW_H_
3 
4 #include <QMainWindow>
5 
7 class ConnectionFrame;
8 class ListenServer;
10 class HelpWindow;
11 class ReloadRoomWindow;
12 class ClientLogin;
13 class Client;
14 class ClickLabel;
15 
16 class QLabel;
17 
18 namespace Ui
19 {
20 class MainWindow;
21 }
22 
27 class MainWindow : public QMainWindow
28 {
29  Q_OBJECT
30 
31 public:
32 
33  explicit MainWindow(QWidget *parent = nullptr);
34  ~MainWindow() override;
35 
36  QRect calcFrameGeometry(ConnectionFrame* frame) const;
37 
38 private:
39 
40  // Ui stuff
41  Ui::MainWindow *ui;
46  int _tilesX;
47  int _tilesY;
48  QImage* _backgroundImage = nullptr;
49  QLabel* _examModeLabel = nullptr;
50 
51  // Button block stuff
53  QList<QAction*> _lockingButtons;
54  static const qint64 BUTTON_BLOCK_TIME = 2000;
55 
56  // Management stuff
57  enum class Mode
58  {
59  Broadcast,
60  Multicast,
61  Unicast,
63  None
64  } _mode;
66 
67  QList<ConnectionFrame*> _clientFrames;
69 
71 
72  QPoint closestFreeSlot(const QPoint &preferredPixels, const ConnectionFrame* toIgnore);
73  void placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred = QPoint(-1, -1));
74  ConnectionFrame* createFrame(const QString &computerId = QString(), const QPoint *gridPosition = nullptr, bool fromRoomplan = false);
75  void startVncServerIfNecessary(int from);
76  void tellClientCurrentSituation(Client* client);
77  void reset(bool lock = false);
78  Client* getClientFromId(int id);
81 
82  void closeEvent(QCloseEvent *e) override;
83  void changeEvent(QEvent *e) override;
84  void resizeEvent(QResizeEvent *e) override;
85  void mouseReleaseEvent(QMouseEvent* e) override;
86 
87  int getTileWidthPx() const;
88  int getTileHeightPx() const;
89 
91 
92  void reloadCurrentRoom();
93 
94  void vncOneOnOne(bool exclusive);
95 
96 protected slots:
97  void disableButtons();
98  void enableButtons();
99  void clientCountChanged();
100 
101  void onSessionNameClick();
102  void onSessionNameUpdate();
103 
104  void onDeleteClient();
105 
106  void onButtonLock(bool checked);
107  void onButtonLockSingle();
108  void onButtonStudentToTutor();
110  void onButtonTutorToAll();
111  void onButtonTutorToStudent();
112  void onButtonStopProjection();
113 
114  void onButtonSetAsTutor();
116  void onReloadRoomOk();
117  void onReloadRoomCancel();
118 
119  void onButtonExit();
120  void onButtonHelp();
121  // connection frame
122  void onFrameMoving(ConnectionFrame* frame);
123  void onFrameDropped(ConnectionFrame* frame);
124  void onFrameClicked(ConnectionFrame* frame);
125  // Net
126  void onClientConnected(Client* client);
127  void onClientAuthenticating(Client* client, ClientLogin* request);
128  void onClientAuthenticated(Client* client);
129  void onVncServerStateChange(Client* client);
130  void onVncClientStateChange(Client* client);
131 
132 };
133 #endif
QRect calcFrameGeometry(ConnectionFrame *frame) const
Definition: mainwindow.cpp:814
MainWindow(QWidget *parent=nullptr)
Initialize MainWindow and ListenServer.
Definition: mainwindow.cpp:57
void enableButtons()
EnableButtons.
HelpWindow * _helpWindow
Definition: mainwindow.h:43
void onReloadRoomCancel()
Definition: mainwindow.cpp:709
void tellClientCurrentSituation(Client *client)
Tells the new client the current situation in class room.
Definition: mainwindow.cpp:334
void reset(bool lock=false)
reset
Definition: mainwindow.cpp:562
QTimer * _buttonLockTimer
Definition: mainwindow.h:52
Ui::MainWindow * ui
Definition: mainwindow.h:41
static const qint64 BUTTON_BLOCK_TIME
Definition: mainwindow.h:54
void mouseReleaseEvent(QMouseEvent *e) override
Handle Mouse Release Event.
Definition: mainwindow.cpp:542
void onFrameDropped(ConnectionFrame *frame)
Place frame to from user specified position.
Definition: mainwindow.cpp:601
QPoint closestFreeSlot(const QPoint &preferredPixels, const ConnectionFrame *toIgnore)
: find the closest available frame.
Definition: mainwindow.cpp:232
void onFrameMoving(ConnectionFrame *frame)
Definition: mainwindow.cpp:585
void clientCountChanged()
this function determines if the number of clients in exam mode comprise more than 50%...
Definition: mainwindow.cpp:160
ClickLabel * _sessionNameLabel
Definition: mainwindow.h:45
ConnectionFrame * createFrame(const QString &computerId=QString(), const QPoint *gridPosition=nullptr, bool fromRoomplan=false)
Create new Frame.
Definition: mainwindow.cpp:312
int getTileHeightPx() const
Definition: mainwindow.cpp:809
SessionNameWindow * _sessionNameWindow
Definition: mainwindow.h:42
void onReloadRoomOk()
Definition: mainwindow.cpp:772
int _lastClientCount
Definition: mainwindow.h:70
QImage * _backgroundImage
Definition: mainwindow.h:48
void changeEvent(QEvent *e) override
Change Event.
Definition: mainwindow.cpp:419
int _tilesX
Definition: mainwindow.h:46
void disableButtons()
DisableButtons.
void placeFrameInFreeSlot(ConnectionFrame *frame, QPoint preferred=QPoint(-1,-1))
Definition: mainwindow.cpp:300
void onVncClientStateChange(Client *client)
Handle VNC client state change.
void onClientAuthenticated(Client *client)
New client was authenticated, make several checks.
void onButtonExit()
On button exit, close application.
int getTileWidthPx() const
Definition: mainwindow.cpp:803
QWidget * _dropMarker
Definition: mainwindow.h:68
ReloadRoomWindow * _reloadWindow
Definition: mainwindow.h:44
void closeEvent(QCloseEvent *e) override
Handle closeEvent.
Definition: mainwindow.cpp:404
int _streamingSource
Definition: mainwindow.h:65
void onButtonTutorToAll()
Handle projection from tutor to all.
Definition: mainwindow.cpp:836
QLabel * _examModeLabel
Definition: mainwindow.h:49
QList< QAction * > _lockingButtons
Definition: mainwindow.h:53
void onButtonStudentToTutor()
Handle projection from one student to tutor.
Definition: mainwindow.cpp:921
ConnectionFrame * getSelectedFrame()
Return the Frame, which is currently selected by user.
Definition: mainwindow.cpp:386
void onVncServerStateChange(Client *client)
Handle if VNC Server State has changed.
void onButtonStudentToTutorExclusive()
Handle projection from one student to tutor, lock everyone else.
Definition: mainwindow.cpp:930
Definition: client.h:23
~MainWindow() override
Definition: mainwindow.cpp:204
void onSessionNameUpdate()
Update session name.
Definition: mainwindow.cpp:640
Class for clickable part on sessionName.
Definition: clicklabel.h:9
void onButtonLockSingle()
void vncOneOnOne(bool exclusive)
Definition: mainwindow.cpp:935
void onDeleteClient()
ConnectionFrame * getTutorFrame()
Return the Frame, which is currently beeing Tutor.
Definition: mainwindow.cpp:371
void resizeEvent(QResizeEvent *e) override
Resize event.
Definition: mainwindow.cpp:450
void reloadCurrentRoom()
Definition: mainwindow.cpp:717
void onSessionNameClick()
Show session name, after it was clicked on.
Definition: mainwindow.cpp:632
void startVncServerIfNecessary(int from)
MainWindow::startVncServerIfNecessary.
Definition: mainwindow.cpp:675
void onButtonSetAsTutor()
Handle button to set specific client as tutor.
int _tilesY
Definition: mainwindow.h:47
void updateContextButtonStates()
Definition: mainwindow.cpp:515
Class for representing the clients of current session, with a specific frame displaying username and ...
void onClientConnected(Client *client)
Handle from ListenServer signaled new client connection.
Class for listing on new client connection.
Definition: listenserver.h:13
void onFrameClicked(ConnectionFrame *frame)
Mark given frame after it was clicked on.
Definition: mainwindow.cpp:612
Client * getClientFromId(int id)
Returns connected client which belongs to given id.
Definition: mainwindow.cpp:354
void onClientAuthenticating(Client *client, ClientLogin *request)
Authenticate new Client client.
static QIcon * lock
enum MainWindow::Mode _mode
void onButtonStopProjection()
Handle Button StopProjection.
Definition: mainwindow.cpp:989
void onButtonLock(bool checked)
Handle button to lock or unlock screens of client(s).
Initializing MainWindow.
Definition: mainwindow.h:27
QList< ConnectionFrame * > _clientFrames
Definition: mainwindow.h:67
void onButtonHelp()
Display popup which explains possible actions about the buttons.
Definition: mainwindow.cpp:826
void onButtonTutorToStudent()
Handle the projection from Tutor to specific student.
Definition: mainwindow.cpp:868
void onButtonReloadRoomConfig()
Definition: mainwindow.cpp:698