summaryrefslogblamecommitdiffstats
path: root/src/server/mainwindow/mainwindow.h
blob: 3de0e1ce09fa2b73c60544acc4dccd745d171896 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11




                      
                          




                        
                 
                       
 
             


                         



                                                   

                                     
                
 

       
                                        

                        
        
 

                              
                                              
                                       
                                               


                                             

                     
                                    
                                      
 
 



                                                                         
                             

                                              
                                                    
 


                                    
                           
                         

                          


                              
                
                             
                                    
 
                                              

                                                    
                                           
 
                                                                              
                                                                                          
                                       
                                                                                               
                                                                                                 
                                               
                                                 
                                                        
                                    
                     


                                            
 



                                               
 

                                
 


                                

                               
                

                                   
 

                          
                                        
                                      
                                               

                                      
                                      
 
                                  
                                        

                                  

                            
                            

                              
                           
                                                                      





                                                                          
                                                    

                              
  
      
#ifndef _MAINWINDOW_H_
#define _MAINWINDOW_H_

#include <QtGui>
#include <QMainWindow>
#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();	

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 = NULL;
	QLabel* _examModeLabel = NULL;


    /* virtual columns to preserve the aspect ratio of the loaded room */
    int _virtCols;
    int _virtRows;

	// Button block stuff
	QTimer              *_buttonLockTimer;
	QList<QAction*>     _lockingButtons;
	static const qint64 _buttonBlockTime = 2000;

    /* Context-sensitive Buttons */
    QList<QAction*> _contextButtons;

	// Management stuff
	enum class Mode {
		Broadcast,
		Multicast,
		Unicast,
		LockedUnicast,
		None
	} _mode;
	int _streamingSource;
	int _countSessionNameUpdate;

	QList<ConnectionFrame*> _clientFrames;
	ListenServer            *_listenServer;
	DiscoveryListener       *_discoveryListener;
	QStringList             _tutorList;

    QPoint closestFreeSlot(QPoint preferredPixels, ConnectionFrame* toIgnore);
	void placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred = QPoint(0,0));
	ConnectionFrame* createFrame();
	ConnectionFrame* createFrame(QString computerId, QPoint position, QPoint gridPosition);
	bool loadPosition(QSharedPointer<QSettings> settings, const QString& id, int& x, int& y);
	void savePosition(ConnectionFrame *cf);
	void startVncServerIfNecessary(int from);
	void tellClientCurrentSituation(Client* client);
	void tryToUseRoomTemplate();
	void reset();
	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 lockContextButtons();
    void unlockContextButtons();

    void switchRoomTo(QString);

protected slots:
	void onSessionNameClick();
	void onSessionNameUpdate();

    void onDeleteClient();

	void onButtonLock(bool checked);
	void onButtonStudentToTutor();
	void onButtonStudentToTutorExclusive();
	void onButtonTutorToAll();
	void onButtonTutorToStudent();
	void onButtonStopProjection();

	void onButtonSetAsTutor();
	void onButtonReloadRoomConfig();
	void onReloadRoomOk();
	void onReloadRoomCancel();

	void onButtonExit();
	void onButtonHelp();
	void DisableButtons();
	void EnableButtons();
	// connection frame
	void onPlaceFrame(bool activateTrash, 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);

	void updateExamMode();
};
#endif