#ifndef _MAINWINDOW_H_ #define _MAINWINDOW_H_ #include #include #include "../net/client.h" class SessionNameWindow; class ConnectionFrame; class ListenServer; class DiscoveryListener; class HelpWindow; class ReloadRoomWindow; namespace Ui { class MainWindow; } /** * Initializing MainWindow. * Handle ButtonEvents and initialize ListenServer. */ class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = 0); ~MainWindow(); QRect calcFrameGeometry(ConnectionFrame* frame) const; private: // Ui stuff Ui::MainWindow *ui; SessionNameWindow *_sessionNameWindow; HelpWindow *_helpWindow; ReloadRoomWindow *_reloadWindow; QLabel *_sessionNameLabel; int _tbIconSize; Qt::ToolBarArea _tbArea; int _tilesX; int _tilesY; QImage* _backgroundImage = nullptr; QLabel* _examModeLabel = nullptr; /* virtual columns to preserve the aspect ratio of the loaded room */ int _virtCols; int _virtRows; // Button block stuff QTimer *_buttonLockTimer; QList _lockingButtons; static const qint64 BUTTON_BLOCK_TIME = 2000; // Management stuff enum class Mode { Broadcast, Multicast, Unicast, LockedUnicast, None } _mode; int _streamingSource; QList _clientFrames; QWidget *_dropMarker; ListenServer *_listenServer; DiscoveryListener *_discoveryListener; int _lastClientCount; QPoint closestFreeSlot(const QPoint preferredPixels, const ConnectionFrame* toIgnore); void placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred = QPoint(-1, -1)); ConnectionFrame* createFrame(const QString &computerId = QString(), const QPoint *gridPosition = nullptr, bool fromRoomplan = false); void savePosition(ConnectionFrame *cf); void startVncServerIfNecessary(int from); void tellClientCurrentSituation(Client* client); void reset(bool lock = false); Client* getClientFromId(int id); ConnectionFrame* getTutorFrame(); ConnectionFrame* getSelectedFrame(); void closeEvent(QCloseEvent *e); void changeEvent(QEvent *e); void resizeEvent(QResizeEvent *e); void mouseReleaseEvent(QMouseEvent* e); int getTileWidthPx() const; int getTileHeightPx() const; void updateContextButtonStates(); void reloadCurrentRoom(); void vncOneOnOne(bool exclusive); protected slots: void disableButtons(); void enableButtons(); void clientCountChanged(); void onSessionNameClick(); void onSessionNameUpdate(); void onDeleteClient(); void onButtonLock(bool checked); void onButtonLockSingle(); void onButtonStudentToTutor(); void onButtonStudentToTutorExclusive(); void onButtonTutorToAll(); void onButtonTutorToStudent(); void onButtonStopProjection(); void onButtonSetAsTutor(); void onButtonReloadRoomConfig(); void onReloadRoomOk(); void onReloadRoomCancel(); void onButtonExit(); void onButtonHelp(); // connection frame void onFrameMoving(ConnectionFrame* frame); void onFrameDropped(ConnectionFrame* frame); void onFrameClicked(ConnectionFrame* frame); // Net void onClientConnected(Client* client); void onClientAuthenticating(Client* client, ClientLogin* request); void onClientAuthenticated(Client* client); void onVncServerStateChange(Client* client); void onVncClientStateChange(Client* client); }; #endif