summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.h
blob: 4b23ae72fb2097ba4bcc8408922640eb1c9bb738 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef _MAINWINDOW_H_
#define _MAINWINDOW_H_

#include <QtGui>
#include <QMainWindow>
#include "../net/client.h"
#include "../net/filedownloader.h"

class SessionNameWindow;
class ConnectionFrame;
class ListenServer;
class DiscoveryListener;

namespace Ui
{
	class MainWindow;
}

class MainWindow : public QMainWindow
{
	Q_OBJECT

private:
	Ui::MainWindow *ui;
	SessionNameWindow *_sessionNameWindow;
	QLabel *_sessionNameLabel;
	QList<ConnectionFrame*> _clientFrames;
	int _tbIconSize;
	Qt::ToolBarArea _tbArea;
	int _tileWidth, _tileHeight;
	int _timerId, _timerTimeout;
	ListenServer *_listenServer;
	DiscoveryListener *_discoveryListener;
	FileDownloader _fileDownloader;
	QStringList _tutorList;

	// Magic numbers
	static const qint64 _buttonBlockTime = 1000;
	static const int _tilesX = 9;
	static const int _tilesY = 7;

	void placeFrameInFreeSlot(ConnectionFrame* frame);
	ConnectionFrame* createFrame();
	bool loadPosition(QSettings& settings, const QString& id, int& x, int& y);
	void savePosition(ConnectionFrame *cf);
	void prepareForProjection(Client * const from, Client * const to);
	bool isValidClient(Client* client);
	bool areButtonsBlocked();

public:
	MainWindow(QString ipListUrl, QWidget *parent = 0);
	~MainWindow();

protected:
	void closeEvent(QCloseEvent *e);
	void changeEvent(QEvent *e);
	void resizeEvent(QResizeEvent *e);
	void mouseReleaseEvent(QMouseEvent* e);
	void timerEvent(QTimerEvent* event);

protected slots:
	// This
	void onTutorListDownloaded(QByteArray& tutorList);
	void onSessionNameClick();
	void onSessionNameUpdate();
	void onButtonSettings();
	void onButtonChat();
	void onButtonStudentToAll();
	void onButtonStudentToTutor();
	void onButtonTutorToAll();
	void onButtonTutorToStudent();
	void onButtonStopProjection();
	void onButtonLock(bool checked);
	void onButtonExit();
	void onButtonSetAsTutor();
	// connection frame
	void onPlaceFrame(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, int lastProjectionSource);
};
#endif