From ccc1b7e667ceaaeb878ffaa728245c3268c5cf73 Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Thu, 5 Jun 2014 18:45:50 +0200 Subject: Fixed SegFauls by setting _streamingSource to integer and just using the clients id, instead of real pointers. --- src/server/mainwindow/mainwindow.cpp | 74 +++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 30 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index a6c90c0..6ac7422 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -57,7 +57,7 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : _tutorFrame = NULL; _selectedFrame = NULL; _mode = Mode::Multicast; - _streamingSource = NULL; + _streamingSource = 0; _sessionNameWindow = new SessionNameWindow(this); _helpWindow = new HelpWindow(this); @@ -266,10 +266,14 @@ void MainWindow::tellClientCurrentSituation(Client* client) if (_mode == Mode::Broadcast){ // _watchers.insert(client->id(), client); client->setWatcher(true); - client->startVncClient(_streamingSource); + Client* c = getClientFromId(_streamingSource); + if (c != NULL) { + client->startVncClient(c); + } } else if (_mode == Mode::LockedMulticast) client->lockScreen(true); + } /***************************************************************************//** @@ -384,8 +388,8 @@ void MainWindow::reset() (*it)->client()->lockScreen(false); // Stop server (Clients get stopped on ACK) - if (_streamingSource != NULL) - _streamingSource->stopVncServer(); + if (getClientFromId(_streamingSource) != NULL) + getClientFromId(_streamingSource)->stopVncServer(); } /* @@ -489,7 +493,7 @@ void MainWindow::changeProjection(Client *from, Mode mode, Client *to) // Set all clients as watchers for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) { - if ((*it)->client() != NULL && (*it)->client() != _streamingSource) + if ((*it)->client() != NULL && (*it)->client() != getClientFromId(_streamingSource)) { // _watchers.insert((*it)->client()->id(), (*it)->client()); (*it)->client()->setWatcher(true); @@ -528,17 +532,20 @@ void MainWindow::changeProjection(Client *from, Mode mode, Client *to) _mode = mode; // if there is a server running which is not "from" stop it. - if (_streamingSource != NULL && _streamingSource != from) - _streamingSource->stopVncServer(); + if (getClientFromId(_streamingSource) != NULL && getClientFromId(_streamingSource) != from) + getClientFromId(_streamingSource)->stopVncServer(); // Set new streaming source - _streamingSource = from; + _streamingSource = from->id(); // If streaming source is already active avoid a restart - if (_streamingSource->isActiveVncServer()) - this->onVncServerStateChange(_streamingSource); - else // Could not take shortcut, (re)start VNC server on source - _streamingSource->startVncServer(); + Client* c = getClientFromId(_streamingSource); + if (c != NULL) { + if (c->isActiveVncServer()) + this->onVncServerStateChange(c); + else // Could not take shortcut, (re)start VNC server on source + c->startVncServer(); + } } /***************************************************************************//** @@ -882,7 +889,7 @@ void MainWindow::onClientAuthenticated(Client* client) */ void MainWindow::onVncServerStateChange(Client* client) { - if (client == _streamingSource) + if (client == getClientFromId(_streamingSource)) EnableButtons(); if (client->isActiveVncServer()) @@ -910,7 +917,7 @@ void MainWindow::onVncServerStateChange(Client* client) if ( (*it)->client() != NULL) { // if (_watchers.contains((*it)->client()->id())) - if (getClientFromId((*it)->client()->id())->isWatcher()) + if ((*it)->client()->isWatcher()) { // Unlock destination and connect VNCclient (*it)->client()->lockScreen(false); @@ -957,25 +964,32 @@ void MainWindow::onVncServerStateChange(Client* client) */ void MainWindow::onVncClientStateChange(Client* client) { - // VNC Client stopped -> remove from watchers - if (!client->isActiveVncClient()){ - // _watchers.remove(client->id()); - getClientFromId(client->id())->setWatcher(false); - - // If noboody is watching the multicast stop VNC server - // if (_watchers.isEmpty() && _mode != Mode::Broadcast) - // _streamingSource->stopVncServer(); - bool noWatchers = true; - for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) - { - if ((*it)->client() != NULL) + if (client != NULL) + { + // VNC Client stopped -> remove from watchers + if (!client->isActiveVncClient()){ + // _watchers.remove(client->id()); + getClientFromId(client->id())->setWatcher(false); + + // If noboody is watching the multicast stop VNC server + // if (_watchers.isEmpty() && _mode != Mode::Broadcast) + // _streamingSource->stopVncServer(); + bool noWatchers = true; + for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) { - if ((*it)->client()->isWatcher()) - noWatchers = false; + if ((*it)->client() != NULL) + { + if ((*it)->client()->isWatcher()) + noWatchers = false; + } + } + if (noWatchers && _mode != Mode::Broadcast) + { + Client* c = getClientFromId(_streamingSource); + if (c != NULL) + c->stopVncServer(); } } - if (noWatchers && _mode != Mode::Broadcast) - _streamingSource->stopVncServer(); } } -- cgit v1.2.3-55-g7522 From 8602764f8f069ec3cb6c8965262c016557bedb32 Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Tue, 17 Jun 2014 12:05:16 +0200 Subject: Removed _tutorFrame and _selectedFrame out of MainWindow to prevent possible SegFaults because of too many Pointers to ConnectionFrames. Wrote to getters getTutorFrame() and getSelectedFrame(), which are just iterating over ConnectionFrames and looking for flags _isTutor and _isSelected. --- src/server/connectionframe/connectionframe.cpp | 12 +-- src/server/connectionframe/connectionframe.h | 4 +- src/server/mainwindow/mainwindow.cpp | 127 ++++++++++++++++--------- src/server/mainwindow/mainwindow.h | 3 +- 4 files changed, 94 insertions(+), 52 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp index b09139c..caf99fc 100644 --- a/src/server/connectionframe/connectionframe.cpp +++ b/src/server/connectionframe/connectionframe.cpp @@ -50,7 +50,7 @@ static QIcon *term = NULL, *cam = NULL, *eye = NULL, *lock = NULL; * @param height */ ConnectionFrame::ConnectionFrame(QWidget *parent, int width, int height) : - QGroupBox(parent), _client(NULL), _timerId(0), _timerCounter(0), _selected(false), _isTutor(false) + QGroupBox(parent), _client(NULL), _timerId(0), _timerCounter(0), _isSelected(false), _isTutor(false) { //defines the ui-stuff @@ -295,9 +295,9 @@ void ConnectionFrame::timerEvent(QTimerEvent* event) */ void ConnectionFrame::setSelection(bool selected) { - if (_selected == selected) + if (_isSelected == selected) return; - _selected = selected; + _isSelected = selected; this->updateAppearance(); } @@ -322,7 +322,7 @@ void ConnectionFrame::updateAppearance() if (_client == NULL) { // Unconnected Frame - if (_selected) + if (_isSelected) this->setStyleSheet(style_selectedStudent); else this->setStyleSheet(style_disconnected); @@ -336,13 +336,13 @@ void ConnectionFrame::updateAppearance() // Normal client, no special stuff active - if (_selected && _isTutor){ + if (_isSelected && _isTutor){ this->setStyleSheet(style_selectedTutor); } else if (_isTutor){ this->setStyleSheet(style_tutor); } - else if (_selected){ + else if (_isSelected){ this->setStyleSheet(style_selectedStudent); } diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h index 72f641d..353ebb8 100644 --- a/src/server/connectionframe/connectionframe.h +++ b/src/server/connectionframe/connectionframe.h @@ -32,7 +32,7 @@ private: Client *_client; int _timerId, _timerCounter; - bool _selected; + bool _isSelected; bool _isTutor; static const int _startDragDistance = 40; @@ -53,7 +53,7 @@ public: void setSize(int width, int height); void assignClient(Client *client); void setSelection(bool selected); - const inline bool selected() const { return _selected; } + const inline bool isSelected() const { return _isSelected; } const QString& computerId() const { return _computerId; } Client* client() const { return _client; } diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 6ac7422..4af9fe1 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -53,9 +53,6 @@ const QString MainWindow::sStrSourceDestSame = tr("Selected projection target is MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow), _tbIconSize(24), _tbArea(Qt::LeftToolBarArea) { - - _tutorFrame = NULL; - _selectedFrame = NULL; _mode = Mode::Multicast; _streamingSource = 0; @@ -291,6 +288,12 @@ bool MainWindow::isManagerMachine(Client* client) return false; } +/***************************************************************************//** + * Returns connected client which belongs to given id. + * Iterating over ConnectionFrames and comparing id to given id. + * @param id + * @return Client with given id, if not NULL. + */ Client* MainWindow::getClientFromId(int id) { for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) @@ -304,6 +307,38 @@ Client* MainWindow::getClientFromId(int id) return NULL; } +/***************************************************************************//** + * Return the Frame, which is currently beeing Tutor. + * Iterating over all ConnectionFrames, and looking for flag _isTutor. + * @return Frame with flag _isTutor = true, + * else NULL if no Tutor is available. + */ +ConnectionFrame* MainWindow::getTutorFrame() +{ + for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) + { + if (((*it) != NULL) && ((*it)->isTutor())) + return (*it); + } + return NULL; +} + +/***************************************************************************//** + * Return the Frame, which is currently selected by user. + * Iterating over all ConnectionFrame and looking for flag _isSelected. + * @return Frame with flag _isSelected = true, + * else NULL if no frame is selected. + */ +ConnectionFrame* MainWindow::getSelectedFrame() +{ + for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) + { + if (((*it) != NULL) && ((*it)->isSelected())) + return (*it); + } + return NULL; +} + /* * Overridden methods */ @@ -370,9 +405,9 @@ void MainWindow::mouseReleaseEvent(QMouseEvent* e) const QSize frame(ui->frmRoom->size()); if (frame.width() > pos.x() && frame.height() > pos.y()) { - if (_selectedFrame != NULL) { - _selectedFrame->setSelection(false); - _selectedFrame = NULL; + if (getSelectedFrame() != NULL) + { + getSelectedFrame()->setSelection(false); } } } @@ -451,15 +486,18 @@ void MainWindow::onPlaceFrame(ConnectionFrame* frame) void MainWindow::onFrameClicked(ConnectionFrame* frame) { // If same frame is clicked again,, do nothing - if (_selectedFrame == frame) + if (getSelectedFrame() == frame) return; // If another frame has been selected, unselect it // Set the ui selected and set a new reference - if (_selectedFrame != NULL) - _selectedFrame->setSelection(false); - _selectedFrame = frame; - _selectedFrame->setSelection(true); + if (getSelectedFrame() != NULL) + { + getSelectedFrame()->setSelection(false); + } + frame->setSelection(true); + qDebug() << "ID of frame: " << frame->computerId(); + qDebug() << "ID of selectedFrame: " << getSelectedFrame()->computerId(); } /***************************************************************************//** @@ -565,12 +603,12 @@ void MainWindow::onButtonTutorToAll() { ui->action_Lock->setChecked(false); - if (_tutorFrame == NULL) + if (getTutorFrame() == NULL) QMessageBox::critical(this, tr("Projection"), sStrTutorNdef); - else if (_tutorFrame->client() == NULL) + else if (getTutorFrame()->client() == NULL) QMessageBox::critical(this, tr("Projection"), sStrTutorOffline); else - changeProjection(_tutorFrame->client(), Mode::Broadcast); + changeProjection(getTutorFrame()->client(), Mode::Broadcast); } /***************************************************************************//** @@ -582,12 +620,12 @@ void MainWindow::onButtonStudentToAll() { ui->action_Lock->setChecked(false); - if (_selectedFrame == NULL) + if (getSelectedFrame() == NULL) QMessageBox::critical(this, tr("Projection"), sStrSourceNdef); - if (_selectedFrame->client() == NULL) + if (getSelectedFrame()->client() == NULL) QMessageBox::critical(this, tr("Projection"), sStrSourceOffline); else - changeProjection(_selectedFrame->client(), Mode::Broadcast); + changeProjection(getSelectedFrame()->client(), Mode::Broadcast); } /***************************************************************************//** @@ -598,18 +636,18 @@ void MainWindow::onButtonTutorToStudent() { ui->action_Lock->setChecked(false); - if (_selectedFrame == NULL) + if (getSelectedFrame() == NULL) QMessageBox::critical(this, tr("Projection"), sStrDestNdef); - else if (_tutorFrame == NULL) + else if (getTutorFrame() == NULL) QMessageBox::critical(this, tr("Projection"), sStrTutorNdef); - else if (_selectedFrame == _tutorFrame) + else if (getSelectedFrame() == getTutorFrame()) QMessageBox::critical(this, tr("Projection"), sStrSourceDestSame); - else if (_selectedFrame->client() == NULL) + else if (getSelectedFrame()->client() == NULL) QMessageBox::critical(this, tr("Projection"), sStrDestOffline); - else if (_tutorFrame->client() == NULL) + else if (getTutorFrame()->client() == NULL) QMessageBox::critical(this, tr("Projection"), sStrTutorOffline); else - changeProjection(_tutorFrame->client(), Mode::Multicast, _selectedFrame->client()); + changeProjection(getTutorFrame()->client(), Mode::Multicast, getSelectedFrame()->client()); } /***************************************************************************//** @@ -620,18 +658,18 @@ void MainWindow::onButtonStudentToTutor() { ui->action_Lock->setChecked(false); - if (_selectedFrame == NULL) + if (getSelectedFrame() == NULL) QMessageBox::critical(this, tr("Projection"), sStrSourceNdef); - else if (_tutorFrame == NULL) + else if (getTutorFrame() == NULL) QMessageBox::critical(this, tr("Projection"), sStrTutorNdef); - else if (_tutorFrame == _selectedFrame) + else if (getTutorFrame() == getSelectedFrame()) QMessageBox::critical(this, tr("Projection"), sStrSourceDestSame); - else if (_selectedFrame->client() == NULL) + else if (getSelectedFrame()->client() == NULL) QMessageBox::critical(this, tr("Projection"), sStrSourceOffline); - else if (_tutorFrame->client() == NULL) + else if (getTutorFrame()->client() == NULL) QMessageBox::critical(this, tr("Projection"), sStrTutorOffline); else - changeProjection(_selectedFrame->client(), Mode::Multicast, _tutorFrame->client()); + changeProjection(getSelectedFrame()->client(), Mode::Multicast, getTutorFrame()->client()); } @@ -642,18 +680,18 @@ void MainWindow::onButtonStudentToTutorExclusive() { ui->action_Lock->setChecked(false); - if (_selectedFrame == NULL) + if (getSelectedFrame() == NULL) QMessageBox::critical(this, tr("Projection"), sStrSourceNdef); - else if (_tutorFrame == NULL) + else if (getTutorFrame() == NULL) QMessageBox::critical(this, tr("Projection"), sStrTutorNdef); - else if (_tutorFrame == _selectedFrame) + else if (getTutorFrame() == getSelectedFrame()) QMessageBox::critical(this, tr("Projection"), sStrSourceDestSame); - else if (_selectedFrame->client() == NULL) + else if (getSelectedFrame()->client() == NULL) QMessageBox::critical(this, tr("Projection"), sStrSourceOffline); - else if (_tutorFrame->client() == NULL) + else if (getTutorFrame()->client() == NULL) QMessageBox::critical(this, tr("Projection"), sStrTutorOffline); else - changeProjection(_selectedFrame->client(), Mode::LockedMulticast, _tutorFrame->client()); + changeProjection(getSelectedFrame()->client(), Mode::LockedMulticast, getTutorFrame()->client()); } @@ -706,30 +744,33 @@ void MainWindow::onButtonSetAsTutor() ui->action_Lock->setChecked(false); // If no frame is selected, warning. - if (_selectedFrame == NULL) + if (getSelectedFrame() == NULL) { QMessageBox::critical(this, tr("Selection"), tr("No client is selected.")); return; } // If frame of inactive client has been selected unselect it - if (_selectedFrame->client() == NULL) + if (getSelectedFrame()->client() == NULL) { QMessageBox::critical(this, tr("Selection"), tr("The selected client is not connected.")); return; } else // If selected client is locked, first unlock - _selectedFrame->client()->lockScreen(false); + { + getSelectedFrame()->client()->lockScreen(false); + } // If same frame is already tutor, do nothing - if (_selectedFrame == _tutorFrame) + if (getSelectedFrame() == getTutorFrame()) return; // Else unset the old and set the new tutor - if (_tutorFrame != NULL) - _tutorFrame->setTutor(false); - _tutorFrame = _selectedFrame; - _tutorFrame->setTutor(true); + if (getTutorFrame() != NULL) + { + getTutorFrame()->setTutor(false); + } + getSelectedFrame()->setTutor(true); } /***************************************************************************//** diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index 64accd9..dbef1b1 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -39,7 +39,6 @@ private: int _tbIconSize; Qt::ToolBarArea _tbArea; int _tileWidth, _tileHeight; - ConnectionFrame *_tutorFrame, *_selectedFrame; static const int _tilesX = 9; static const int _tilesY = 7; @@ -86,6 +85,8 @@ private: void mouseReleaseEvent(QMouseEvent* e); Client* getClientFromId(int id); + ConnectionFrame* getTutorFrame(); + ConnectionFrame* getSelectedFrame(); protected slots: void onTutorListDownloaded(QByteArray& tutorList); -- cgit v1.2.3-55-g7522 From 1d771836abd9b0ef4bffbfe7f09a6f8ff2cc85db Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Tue, 17 Jun 2014 12:31:06 +0200 Subject: Moved method isManagerMachine() from MainWindow to Client. isManagerMachine() is now called just once directly in lockScreen(). --- src/server/mainwindow/mainwindow.cpp | 22 ++-------------------- src/server/mainwindow/mainwindow.h | 1 - src/server/net/client.cpp | 17 ++++++++++++++++- src/server/net/client.h | 2 ++ 4 files changed, 20 insertions(+), 22 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 4af9fe1..5063df6 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -273,21 +273,6 @@ void MainWindow::tellClientCurrentSituation(Client* client) } -/***************************************************************************//** - * Checks if client and manager runs on same machine. - * @param client - * @return Return true, if pvsmanager is running on client. - */ -bool MainWindow::isManagerMachine(Client* client) -{ - foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) - if (address != QHostAddress(QHostAddress::LocalHost) - && client != NULL - && client->ip() == address.toString()) - return true; - return false; -} - /***************************************************************************//** * Returns connected client which belongs to given id. * Iterating over ConnectionFrames and comparing id to given id. @@ -719,9 +704,7 @@ void MainWindow::onButtonLock(bool checked) for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) { - // Check if client is Tutor or the manager is also running on this machine. - bool isManager = isManagerMachine((*it)->client()); - if ((*it)->client() == NULL || isManager) + if ((*it)->client() == NULL) continue; (*it)->client()->lockScreen(checked); } @@ -972,8 +955,7 @@ void MainWindow::onVncServerStateChange(Client* client) else { // Lock others and stop their clients - bool isManager = isManagerMachine((*it)->client()); - (*it)->client()->lockScreen(_mode == Mode::LockedMulticast && isManager != true); + (*it)->client()->lockScreen(_mode == Mode::LockedMulticast); (*it)->client()->stopVncClient(); } } diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index dbef1b1..851dc84 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -76,7 +76,6 @@ private: void savePosition(ConnectionFrame *cf); void changeProjection(Client *from, Mode mode = Mode::Broadcast, Client *to = NULL); void tellClientCurrentSituation(Client* client); - bool isManagerMachine(Client* client); void reset(); void closeEvent(QCloseEvent *e); diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 135157c..584b254 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -11,6 +11,7 @@ #include "../../shared/util.h" #include #include +#include #define CHALLENGE_LEN 20 @@ -310,10 +311,24 @@ void Client::stopVncClient() } } +/***************************************************************************//** + * Checks if client and manager runs on same machine. + * @return Return true, if pvsmanager is running on client. + */ +bool Client::isManagerMachine() +{ + foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) + if (address != QHostAddress(QHostAddress::LocalHost) + && this != NULL + && this->ip() == address.toString()) + return true; + return false; +} + /******************************************************************************/ void Client::lockScreen(bool lock) { - if (!_isTutor && _locked != lock){ + if (!_isTutor && _locked != lock && !isManagerMachine()){ _locked = lock; NetworkMessage msg; msg.setField(_ID, _LOCK); diff --git a/src/server/net/client.h b/src/server/net/client.h index 1031838..6872959 100644 --- a/src/server/net/client.h +++ b/src/server/net/client.h @@ -71,6 +71,8 @@ private: static int _clientIdCounter; + bool isManagerMachine(); + void handleMsg(); void sendMessage(NetworkMessage& message); -- cgit v1.2.3-55-g7522 From badab5545b2f51c5692fd03e5b3a657678880a66 Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Tue, 17 Jun 2014 15:05:28 +0200 Subject: Delete connected clients and connectionFrames after sessionName has changed. Surround camera and eye icon with borderline for better contrast on frames. --- icons/cf_icon_cam.svg | 28 +++++++++++++++++--------- icons/cf_icon_eye.svg | 18 ++++++++--------- icons/cf_icon_lock.svg | 18 ++++++++--------- src/server/connectionframe/connectionframe.cpp | 6 +++++- src/server/mainwindow/mainwindow.cpp | 11 +++++++++- 5 files changed, 51 insertions(+), 30 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/icons/cf_icon_cam.svg b/icons/cf_icon_cam.svg index cd1599d..c51ab6d 100644 --- a/icons/cf_icon_cam.svg +++ b/icons/cf_icon_cam.svg @@ -21,6 +21,14 @@ style="display:inline;enable-background:new"> + + + + inkscape:window-width="1280" + inkscape:window-height="1000" + inkscape:window-x="0" + inkscape:window-y="24" + inkscape:window-maximized="1"> diff --git a/icons/cf_icon_eye.svg b/icons/cf_icon_eye.svg index 06d6f85..6f7f3f8 100644 --- a/icons/cf_icon_eye.svg +++ b/icons/cf_icon_eye.svg @@ -36,23 +36,23 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1920" - inkscape:window-height="1156" + inkscape:window-width="1280" + inkscape:window-height="1000" id="namedview8" showgrid="true" - inkscape:zoom="4.2142857" - inkscape:cx="-20.387675" - inkscape:cy="53.464011" - inkscape:window-x="-2" - inkscape:window-y="-3" + inkscape:zoom="5.9599" + inkscape:cx="42.050215" + inkscape:cy="67.037619" + inkscape:window-x="0" + inkscape:window-y="24" inkscape:window-maximized="1" inkscape:current-layer="svg2" showguides="false" inkscape:snap-page="false" inkscape:snap-grids="true" /> + d="m 118.02062,-192 q -10.67506,-16.11394 -26.757696,-24.10255 4.284038,7.10106 4.284038,15.3628 0,12.63167 -9.235251,21.61034 -9.235255,8.97875 -22.227825,8.97875 -12.992567,0 -22.227825,-8.97875 -9.23525,-8.97867 -9.23525,-21.61034 0,-8.26174 4.284038,-15.3628 -16.082688,7.98861 -26.757662,24.10255 9.340603,13.9972 23.42173,22.29316 14.081132,8.29593 30.514969,8.29593 16.433837,0 30.514972,-8.29593 Q 108.67994,-178.0028 118.02062,-192 z m -50.565695,-26.21926 q 0,-1.36558 -0.983217,-2.32142 -0.983214,-0.95593 -2.387822,-0.95593 -8.778759,0 -15.064353,6.11096 -6.285591,6.11102 -6.285591,14.6459 0,1.36556 0.983221,2.32151 0.983223,0.95595 2.387828,0.95595 1.4046,0 2.387817,-0.95595 0.983222,-0.95595 0.983222,-2.32151 0,-5.87193 4.284036,-10.03702 4.284033,-4.16506 10.32382,-4.16506 1.404608,0 2.387822,-0.95596 0.983217,-0.95585 0.983217,-2.32147 z M 127.01005,-192 q 0,2.32146 -1.40458,4.71127 -9.83222,15.7042 -26.441665,25.16096 -16.609408,9.45662 -35.079919,9.45662 -18.470509,0 -35.079922,-9.49091 -16.609413,-9.49077 -26.441625,-25.12667 -1.4046014,-2.38981 -1.4046014,-4.71127 0,-2.32149 1.4046014,-4.7113 9.832212,-15.63587 26.441625,-25.12664 16.609413,-9.49091 35.079922,-9.49091 18.470511,0 35.079919,9.49091 16.609445,9.49077 26.441665,25.12664 1.40458,2.38981 1.40458,4.7113 z" /> diff --git a/icons/cf_icon_lock.svg b/icons/cf_icon_lock.svg index 40eac88..ceff44b 100644 --- a/icons/cf_icon_lock.svg +++ b/icons/cf_icon_lock.svg @@ -36,25 +36,25 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1920" - inkscape:window-height="1156" + inkscape:window-width="1280" + inkscape:window-height="1000" id="namedview2995" showgrid="false" - inkscape:zoom="0.26339286" - inkscape:cx="1103.7208" - inkscape:cy="559.2271" - inkscape:window-x="-2" - inkscape:window-y="-3" + inkscape:zoom="0.37249375" + inkscape:cx="377.5311" + inkscape:cy="1119.8752" + inkscape:window-x="0" + inkscape:window-y="24" inkscape:window-maximized="1" inkscape:current-layer="svg2989" /> + style="fill:#cccccc;stroke:none;stroke-opacity:1;stroke-width:7.87667644999999972;stroke-miterlimit:4;stroke-dasharray:none"> + style="fill:#cccccc;stroke:none;stroke-opacity:1;stroke-width:7.87667644999999972;stroke-miterlimit:4;stroke-dasharray:none" /> diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp index caf99fc..dbe408c 100644 --- a/src/server/connectionframe/connectionframe.cpp +++ b/src/server/connectionframe/connectionframe.cpp @@ -101,7 +101,11 @@ ConnectionFrame::ConnectionFrame(QWidget *parent, int width, int height) : ConnectionFrame::~ConnectionFrame() { - // + if (_client != NULL) + { + _client->deleteLater(); + } + _iconLayout->deleteLater(); } /** diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 5063df6..bbabc66 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -498,6 +498,14 @@ void MainWindow::onSessionNameClick() */ void MainWindow::onSessionNameUpdate() { + // Stop all projections and clear all clients, which where connected to old sessionName. + reset(); + for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) + { + (*it)->hide(); + (*it)->deleteLater(); + } + _clientFrames.clear(); _sessionNameLabel->setText(tr("Session Name: %1 [click to edit]").arg(Global::sessionName())); } @@ -992,7 +1000,8 @@ void MainWindow::onVncClientStateChange(Client* client) // VNC Client stopped -> remove from watchers if (!client->isActiveVncClient()){ // _watchers.remove(client->id()); - getClientFromId(client->id())->setWatcher(false); + if (getClientFromId(client->id()) != NULL) + getClientFromId(client->id())->setWatcher(false); // If noboody is watching the multicast stop VNC server // if (_watchers.isEmpty() && _mode != Mode::Broadcast) -- cgit v1.2.3-55-g7522 From e5c884b2b36f6ea4cadbe9e835b0b10f7ffbaf3b Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Thu, 19 Jun 2014 15:28:50 +0200 Subject: NEW feature: Possible to delete offline client by drag and drop to trash, which is positioned in the right bottom corner of manager. --- gui/server_normal/mainwindow.ui | 29 +- icons/trash.svg | 1187 ++++++++++++++++++++++++++ pvsmgr.qrc | 1 + src/server/connectionframe/connectionframe.h | 1 + src/server/mainwindow/mainwindow.cpp | 47 +- src/server/mainwindow/mainwindow.h | 2 + 6 files changed, 1260 insertions(+), 7 deletions(-) create mode 100644 icons/trash.svg (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/gui/server_normal/mainwindow.ui b/gui/server_normal/mainwindow.ui index 6d29c97..8ab1c05 100644 --- a/gui/server_normal/mainwindow.ui +++ b/gui/server_normal/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 838 - 607 + 1246 + 858 @@ -46,6 +46,28 @@ 2 + + + + 10 + 10 + 111 + 121 + + + + false + + + + + + :/trash + + + true + + @@ -181,7 +203,7 @@ - + :/reset:/reset @@ -218,7 +240,6 @@ - diff --git a/icons/trash.svg b/icons/trash.svg new file mode 100644 index 0000000..e217a09 --- /dev/null +++ b/icons/trash.svg @@ -0,0 +1,1187 @@ + + + + + trash + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + trash + + + hrum + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pvsmgr.qrc b/pvsmgr.qrc index 3837cee..40df258 100644 --- a/pvsmgr.qrc +++ b/pvsmgr.qrc @@ -15,6 +15,7 @@ icons/keyboard_key.svg icons/student2tutor_extension.svg icons/help.svg + icons/trash.svg AUTHORS TRANSLATION build/pvsmgr_de_DE.qm diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h index 353ebb8..5a4e1df 100644 --- a/src/server/connectionframe/connectionframe.h +++ b/src/server/connectionframe/connectionframe.h @@ -51,6 +51,7 @@ public: const QPixmap& getFramePixmap() const { return _remoteScreen; } void setSize(int width, int height); + const inline QPoint& getPreviousPosition() const { return _previousPosition; } void assignClient(Client *client); void setSelection(bool selected); const inline bool isSelected() const { return _isSelected; } diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index bbabc66..a52690f 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -44,6 +44,8 @@ const QString MainWindow::sStrSourceOffline = tr("The projection source is offli const QString MainWindow::sStrDestNdef = tr("Please select a projection destination."); const QString MainWindow::sStrDestOffline = tr("The projection destination is offline."); const QString MainWindow::sStrSourceDestSame = tr("Selected projection target is tutor."); +const QString MainWindow::sStrClientOnline = tr("Selected client is currently online."); +const QString MainWindow::sStrNoDestAv = tr("No projection destination available."); /***************************************************************************//** * Initialize MainWindow and ListenServer. @@ -78,6 +80,9 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : ui->action_Exit->setStatusTip(tr("Exit")); ui->action_Lock->setStatusTip(tr("Lock or Unlock all Clients")); + _tileWidth = 10; + _tileHeight = 10; + // Initialize FileDownloader. if (!ipListUrl.isEmpty()) { @@ -125,9 +130,6 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : setUnifiedTitleAndToolBarOnMac(true); this->showMaximized(); // show the Mainwindow maximized - _tileWidth = 10; - _tileHeight = 10; - _listenServer = new ListenServer(CLIENT_PORT); connect(_listenServer, SIGNAL(newClient(Client*)), this, SLOT(onClientConnected(Client*))); _discoveryListener = new DiscoveryListener(); @@ -369,6 +371,14 @@ void MainWindow::resizeEvent(QResizeEvent* e) (*it)->move((oldpos.x() / _tileWidth) * nw, (oldpos.y() / _tileHeight) * nh); (*it)->setSize(nw, nh); } + + // Resize trash and set position. + const int width = ui->frmRoom->geometry().width() - (nw + 1); + const int height = ui->frmRoom->geometry().height() - (nh + 1); + ui->trash->move(width, height); + ui->trash->resize(nw, nh); + // qDebug() << "Trash pos: " << ui->trash->pos(); + _tileWidth = nw; _tileHeight = nh; } @@ -449,6 +459,35 @@ void MainWindow::onPlaceFrame(ConnectionFrame* frame) y = 0; else if (y > s.height() - _tileHeight) y = (_tilesY - 1) * _tileHeight; + + const QRect &trashCenter = ui->trash->geometry(); + // Check if x coordinate is in trash position. + if (trashCenter.contains(p)) + { + // Do not offer deleting online client. + if (frame->client() != NULL) + { + QMessageBox::critical(this, tr("Selection"), sStrClientOnline); + frame->move(frame->getPreviousPosition()); + return; + } + else + { + int ret = QMessageBox::question(this, "Warning", "Sure, You want to delete selected client?", 0, 1, 2); + if (ret == 1) + { + frame->hide(); + frame->deleteLater(); + _clientFrames.removeOne(frame); + return; + } + else + { + frame->move(frame->getPreviousPosition()); + return; + } + } + } qDebug("Move D"); frame->move(x, y); savePosition(frame); @@ -600,6 +639,8 @@ void MainWindow::onButtonTutorToAll() QMessageBox::critical(this, tr("Projection"), sStrTutorNdef); else if (getTutorFrame()->client() == NULL) QMessageBox::critical(this, tr("Projection"), sStrTutorOffline); + else if (_clientFrames.size() == 1) + QMessageBox::critical(this, tr("Projection"), sStrNoDestAv); else changeProjection(getTutorFrame()->client(), Mode::Broadcast); } diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index 851dc84..524a0b1 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -69,6 +69,8 @@ private: static const QString sStrDestNdef; static const QString sStrDestOffline; static const QString sStrSourceDestSame; + static const QString sStrClientOnline; + static const QString sStrNoDestAv; void placeFrameInFreeSlot(ConnectionFrame* frame); ConnectionFrame* createFrame(); -- cgit v1.2.3-55-g7522