From a2fd531c81ba0e895dff319b0597e45b4206273f Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Mon, 28 Apr 2014 19:35:59 +0200 Subject: Adding comments for each method in the .cpp files and class definition in the .h files. --- src/server/mainwindow/mainwindow.cpp | 160 +++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 6534179..3ed2b57 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -35,6 +35,11 @@ // Auto-generated ui class #include "ui_mainwindow.h" +/** + * Initialize MainWindow and ListenServer. + * @param ipListUrl + * @param parent + */ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow), _tbIconSize(24), _tbArea(Qt::LeftToolBarArea) { @@ -107,6 +112,11 @@ MainWindow::~MainWindow() delete ui; } +/** + * Place the frames at possible Position. + * If current position out of range, place frame into next free cell. + * @param frame + */ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame) { // Get occupied cell of each frame and store status in an array @@ -155,6 +165,12 @@ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame) } } +/** + * Create new Frame. + * Create new frame and add to current available frame list. + * Also connect signals frameMoved() and clicked() with slots. + * @return ConnectionFrame* + */ ConnectionFrame* MainWindow::createFrame() { // Allocate and resize @@ -166,6 +182,14 @@ ConnectionFrame* MainWindow::createFrame() return cf; } +/** + * Load position. + * @param settings + * @param id + * @param x + * @param y + * @return If loadPosition was successfull. + */ bool MainWindow::loadPosition(QSettings& settings, const QString& id, int& x, int& y) { settings.beginGroup("client_position"); @@ -179,6 +203,10 @@ bool MainWindow::loadPosition(QSettings& settings, const QString& id, int& x, in return true; } +/** + * Save position of given connectionFrame. + * @param cf + */ void MainWindow::savePosition(ConnectionFrame *cf) { Client *client = cf->client(); @@ -195,6 +223,11 @@ void MainWindow::savePosition(ConnectionFrame *cf) * Overridden methods */ +/** + * Handle closeEvent. + * If user calls closing MainWindow, close, else ignore. + * @param e + */ void MainWindow::closeEvent(QCloseEvent* e) { int ret = QMessageBox::question(this, "Test", "Exit?", 0, 1, 2); @@ -204,11 +237,19 @@ void MainWindow::closeEvent(QCloseEvent* e) e->ignore(); } +/** + * Change Event. + * @param e + */ void MainWindow::changeEvent(QEvent* e) { QMainWindow::changeEvent(e); } +/** + * Resize event. + * @param e + */ void MainWindow::resizeEvent(QResizeEvent* e) { QMainWindow::resizeEvent(e); @@ -219,6 +260,12 @@ void MainWindow::resizeEvent(QResizeEvent* e) _timerTimeout = 8; } +/** + * Handle Mouse Release Event. + * Check if click was inside the frame and if that is the case, set the selection of each connected + * client to false. + * @param e + */ void MainWindow::mouseReleaseEvent(QMouseEvent* e) { // Try to figure out if the user clicked inside the "room" frame @@ -237,6 +284,10 @@ void MainWindow::mouseReleaseEvent(QMouseEvent* e) } } +/** + * Handle Timer EventtimerEvent. + * @param event + */ void MainWindow::timerEvent(QTimerEvent* event) { if (event->timerId() == _timerId) @@ -293,6 +344,11 @@ void MainWindow::timerEvent(QTimerEvent* event) * Slots */ +/** + * Extract information from downloaded tutorList. + * Split downloaded file by new line and store ips in _tutorList. + * @param tutorList + */ void MainWindow::onTutorListDownloaded(QByteArray& tutorList) { // qDebug() << tutorList; @@ -300,6 +356,11 @@ void MainWindow::onTutorListDownloaded(QByteArray& tutorList) _tutorList = data.split(QRegExp("[\r\n]"),QString::SkipEmptyParts); qDebug() << _tutorList; } + +/** + * Place Frame to from user specified position. + * @param frame + */ void MainWindow::onPlaceFrame(ConnectionFrame* frame) { if (_tilesX <= 0 || _tilesY <= 0) @@ -331,6 +392,10 @@ void MainWindow::onPlaceFrame(ConnectionFrame* frame) } } +/** + * Mark given frame after it was clicked on. + * @param frame + */ void MainWindow::onFrameClicked(ConnectionFrame* frame) { for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) @@ -342,22 +407,34 @@ void MainWindow::onFrameClicked(ConnectionFrame* frame) } } +/** + * Show session name, after it was clicked on. + */ void MainWindow::onSessionNameClick() { _sessionNameWindow->show(Global::sessionName()); } +/** + * Update session name. + */ void MainWindow::onSessionNameUpdate() { _sessionNameLabel->setText(tr("Session Name: %1 [click to edit]").arg(Global::sessionName())); } +/** + * OnButtonSettings. + */ void MainWindow::onButtonSettings() { // Move to any free tile placeFrameInFreeSlot(createFrame()); } +/** + * OnButtonChat. + */ void MainWindow::onButtonChat() { /* @@ -367,6 +444,12 @@ void MainWindow::onButtonChat() */ } +/** + * Check if given client is valid. + * And if that is the case return true. + * @param client + * @return If client is valid or not. + */ bool MainWindow::isValidClient(Client* client) { for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) @@ -378,6 +461,10 @@ bool MainWindow::isValidClient(Client* client) return false; } +/** + * Check if buttons are blocked. + * @return If buttons are blocked or not. + */ bool MainWindow::areButtonsBlocked() { bool result; @@ -388,6 +475,13 @@ bool MainWindow::areButtonsBlocked() return result; } +/** + * Handle VNC settings for a projection from "from" to "to". + * Check if projection source is active vnc client. + * Check if projection is One --> Many or One --> One. + * @param from + * @param to + */ void MainWindow::prepareForProjection(Client * const from, Client * const to) { // Projection source is never allowed to be an active VNC viewer @@ -469,6 +563,12 @@ void MainWindow::prepareForProjection(Client * const from, Client * const to) from->startVncServer(); } +/** + * Button projection from one student to all the others. + * First get which client is projectionSource and set this one as from. + * Set projection source for all clients,except the selected one, to false. + * Then call prepareForProjection(from, Null). + */ void MainWindow::onButtonStudentToAll() { if (areButtonsBlocked()) @@ -494,6 +594,11 @@ void MainWindow::onButtonStudentToAll() prepareForProjection(from, NULL); } +/** + * Handle projection from one student to tutor. + * Get the client to project from and get client, who is tutor, as to. + * Call prepareForProjection(from, to). + */ void MainWindow::onButtonStudentToTutor() { if (areButtonsBlocked()) @@ -530,6 +635,12 @@ void MainWindow::onButtonStudentToTutor() prepareForProjection(from, to); } +/** + * Handle projection from tutor to all. + * Get the client who is tutor and set the projectionSource of all + * clients, except the tutor ones, to false. + * Call prepareForProjection(from, to). + */ void MainWindow::onButtonTutorToAll() { if (areButtonsBlocked()) @@ -556,6 +667,11 @@ void MainWindow::onButtonTutorToAll() prepareForProjection(from, NULL); } +/** + * Handle the projection from Tutor to specific student. + * Set the client who is tutor as from and the selected client as to. + * Call prepareForProjection(from, to). + */ void MainWindow::onButtonTutorToStudent() { if (areButtonsBlocked()) @@ -592,6 +708,11 @@ void MainWindow::onButtonTutorToStudent() prepareForProjection(from, to); } +/** + * Handle Button StopProjection. + * Set ProjectionSource of each client to false and create a NetworkMessage to + * stop the active VNC Server and the active VNC Client(s). + */ void MainWindow::onButtonStopProjection() { if (areButtonsBlocked()) @@ -619,6 +740,12 @@ void MainWindow::onButtonStopProjection() } } +/** + * Handle button to lock or unlock screens of client(s). + * If already locked, do nothing, else create a NetworkMessage to lock (checked) or + * unlock (!checked) the client(s), except the tutor. + * @param checked + */ void MainWindow::onButtonLock(bool checked) { if (areButtonsBlocked()) @@ -639,11 +766,18 @@ void MainWindow::onButtonLock(bool checked) } } +/** + * On button exit, close application. + */ void MainWindow::onButtonExit() { this->close(); } +/** + * Handle button to set specific client as tutor. + * Unset active tutor and set selected client, if not inactive, as new tutor. + */ void MainWindow::onButtonSetAsTutor() { bool selected = false; @@ -669,6 +803,10 @@ void MainWindow::onButtonSetAsTutor() } } +/** + * Handle from ListenServer signaled new client connection. + * @param client + */ void MainWindow::onClientConnected(Client* client) { qDebug("ListenServer told MainWindow about new connection"); @@ -676,6 +814,11 @@ void MainWindow::onClientConnected(Client* client) connect(client, SIGNAL(authenticated(Client*)), this, SLOT(onClientAuthenticated(Client*))); } +/** + * Authenticate new Client client. + * @param client + * @param request + */ void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request) { disconnect(client, SIGNAL(authenticating(Client*, ClientLogin*)), this, SLOT(onClientAuthenticating(Client*, ClientLogin*))); @@ -713,6 +856,11 @@ void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request) request->name = check; } +/** + * After authenticating new client, check if that's the first one and set tutor if necessary. + * Also check the current VNC status and take these setting also for the new client. + * @param client + */ void MainWindow::onClientAuthenticated(Client* client) { disconnect(client, SIGNAL(authenticated(Client*)), this, SLOT(onClientAuthenticated(Client*))); @@ -814,6 +962,12 @@ void MainWindow::onClientAuthenticated(Client* client) } } +/** + * Handle if VNC Server State has changed. + * Check if VNC server has been started/stopped on some client and start VNC server/reset pending + * VNC projection information. + * @param client + */ void MainWindow::onVncServerStateChange(Client* client) { if (!isValidClient(client)) // Check here because this slot is connected queued @@ -869,6 +1023,12 @@ void MainWindow::onVncServerStateChange(Client* client) } } +/** + * Handle VNC client state change. + * Check if any vnc client is in use, and if that is not the case, stop VNC Server. + * @param client + * @param lastProjectionSource + */ void MainWindow::onVncClientStateChange(Client* client, int lastProjectionSource) { if (!isValidClient(client)) // Check here because this slot is connected queued -- cgit v1.2.3-55-g7522