summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2018-07-19 17:20:30 +0200
committerSimon Rettberg2018-07-19 17:20:30 +0200
commit87eaae3e4e2f6d542956df870609b798b9fa9d26 (patch)
tree9cc85ec51589e1e7b14dae7e05a059b15a8cf8d2
parent[server] SessionNameWindow: Set focus to text box on open (diff)
downloadpvs2-87eaae3e4e2f6d542956df870609b798b9fa9d26.tar.gz
pvs2-87eaae3e4e2f6d542956df870609b798b9fa9d26.tar.xz
pvs2-87eaae3e4e2f6d542956df870609b798b9fa9d26.zip
[server] Offer deleting temp. clients on session name change
If the user changes the session name, we now ask whether to disconnect and delete all clients that just connected via session name and don't belong to the currently loaded room layout.
-rw-r--r--src/server/connectionframe/connectionframe.cpp6
-rw-r--r--src/server/connectionframe/connectionframe.h4
-rw-r--r--src/server/mainwindow/mainwindow.cpp80
-rw-r--r--src/server/mainwindow/mainwindow.h4
4 files changed, 40 insertions, 54 deletions
diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp
index 85d2e32..fb2c96a 100644
--- a/src/server/connectionframe/connectionframe.cpp
+++ b/src/server/connectionframe/connectionframe.cpp
@@ -68,9 +68,9 @@ bool ConnectionFrame::paintDisabled = false;
* @param width
* @param height
*/
-ConnectionFrame::ConnectionFrame(MainWindow* main, QWidget *parent) :
+ConnectionFrame::ConnectionFrame(MainWindow* main, QWidget *parent, bool fromRoomplan) :
QGroupBox(parent), _client(NULL), _timerId(0), _timerCounter(0), _isSelected(false), _isTutor(false),
- _mainWindow(main)
+ _isFromRoomplan(fromRoomplan), _mainWindow(main)
{
//defines the ui-stuff
@@ -82,8 +82,6 @@ ConnectionFrame::ConnectionFrame(MainWindow* main, QWidget *parent) :
lock = new QIcon(":cf_lock");
}
- //this->setAttribute(Qt::WA_OpaquePaintEvent);
-
_mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
_mainLayout->setSpacing(1);
_mainLayout->setMargin(3);
diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h
index 72f57f3..4558406 100644
--- a/src/server/connectionframe/connectionframe.h
+++ b/src/server/connectionframe/connectionframe.h
@@ -38,6 +38,7 @@ private:
int _timerId, _timerCounter;
bool _isSelected;
bool _isTutor;
+ bool _isFromRoomplan;
static const int _startDragDistance = 40;
@@ -50,7 +51,7 @@ public:
static bool paintDisabled;
- ConnectionFrame(MainWindow* main, QWidget* parent);
+ ConnectionFrame(MainWindow* main, QWidget* parent, bool fromRoomplan = false);
virtual ~ConnectionFrame();
const inline QPoint getGridPosition() const { return _gridPosition; }
@@ -68,6 +69,7 @@ public:
Client* client() const { return _client; }
inline bool isTutor() { return _isTutor; }
+ inline bool isFromRoomplan() { return _isFromRoomplan; }
void setTutor(bool b);
protected:
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 568896c..6fc80f3 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -79,9 +79,9 @@ MainWindow::MainWindow(QWidget* parent) :
_sessionNameWindow = new SessionNameWindow(this);
_helpWindow = new HelpWindow(this);
- _helpWindow->setWindowTitle("Help");
+ _helpWindow->setWindowTitle(tr("Help"));
_reloadWindow = new ReloadRoomWindow(this);
- _reloadWindow->setWindowTitle("Reload Room");
+ _reloadWindow->setWindowTitle(tr("Reload Room"));
ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint);
@@ -174,9 +174,7 @@ MainWindow::MainWindow(QWidget* parent) :
_discoveryListener = new DiscoveryListener();
// Finally
- _countSessionNameUpdate = 0;
this->onSessionNameUpdate(); // Just make lable visible.
- _countSessionNameUpdate = 0;
reloadCurrentRoom();
}
@@ -341,29 +339,15 @@ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferredPi
* Also connect signals frameMoved() and clicked() with slots.
* @return ConnectionFrame*
*/
-ConnectionFrame* MainWindow::createFrame()
+ConnectionFrame* MainWindow::createFrame(const QString &computerId, const QPoint* gridPosition, bool fromRoomplan)
{
- ConnectionFrame *cf = new ConnectionFrame(this, ui->frmRoom);
- // Move to any free tile
- placeFrameInFreeSlot(cf);
- _clientFrames.append(cf);
- cf->show();
- connect(cf, SIGNAL(frameMoved(ConnectionFrame *)), this, SLOT(onPlaceFrame(ConnectionFrame *)));
- connect(cf, SIGNAL(clicked(ConnectionFrame *)), this, SLOT(onFrameClicked(ConnectionFrame *)));
- return cf;
-}
-
-/***************************************************************************//**
- * 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(QString computerId, QPoint gridPosition)
-{
- ConnectionFrame *cf = new ConnectionFrame(this, ui->frmRoom);
+ ConnectionFrame *cf = new ConnectionFrame(this, ui->frmRoom, fromRoomplan);
+ if (gridPosition == NULL) {
+ placeFrameInFreeSlot(cf);
+ } else {
+ cf->setGridPosition(*gridPosition);
+ }
cf->setComputerId(computerId);
- cf->setGridPosition(gridPosition);
_clientFrames.append(cf);
cf->show();
connect(cf, SIGNAL(frameMoved(ConnectionFrame *)), this, SLOT(onPlaceFrame(ConnectionFrame *)));
@@ -670,13 +654,6 @@ void MainWindow::onFrameClicked(ConnectionFrame* frame)
*/
void MainWindow::onSessionNameClick()
{
- _countSessionNameUpdate++;
- if (_countSessionNameUpdate > 1) {
- int ret = QMessageBox::question(this, "Warning", tr("Sure, You want to change SessionName again?\n"
- "All Clients will be deleted afterwards."), 0, 1, 2);
- if (ret != 1)
- return;
- }
_sessionNameWindow->show((serverApp->sessionName()));
}
@@ -685,18 +662,33 @@ void MainWindow::onSessionNameClick()
*/
void MainWindow::onSessionNameUpdate()
{
- // Stop all projections and clear all clients, which where connected to old sessionName.
+ _sessionNameLabel->setText(tr("Session Name: %1 [click to edit]").arg(serverApp->sessionName()));
+ bool haveAdditionalClient = false;
+ for (QMutableListIterator<ConnectionFrame*> it(_clientFrames); it.hasNext(); ) {
+ if (!it.next()->isFromRoomplan()) {
+ haveAdditionalClient = true;
+ break;
+ }
+ }
+ if (!haveAdditionalClient)
+ return; // No additional client exists, don't ask about reset
+ // Current layout contains additional clients (voa session name), ask to delete
+ QMessageBox::StandardButton ret = QMessageBox::question(this,
+ tr("Question"), tr("Do you want to delete and disconnect any clients\n"
+ "not belonging to the current room layout?"),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+ if (ret != QMessageBox::Ok)
+ return;
+ // Stop all projections and clear all clients, which were connected to old sessionName.
reset();
- if (_countSessionNameUpdate > 1) {
- {
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- (*it)->hide();
- (*it)->deleteLater();
- }
- _clientFrames.clear();
+ for (QMutableListIterator<ConnectionFrame*> it(_clientFrames); it.hasNext(); ) {
+ ConnectionFrame *cf = it.next();
+ if (!cf->isFromRoomplan()) {
+ cf->hide();
+ cf->deleteLater();
+ it.remove();
}
}
- _sessionNameLabel->setText(tr("Session Name: %1 [click to edit]").arg(serverApp->sessionName()));
}
/***************************************************************************//**
@@ -763,7 +755,7 @@ void MainWindow::reloadCurrentRoom()
QString computerId = it.key();
QPoint pos = it.value();
- ConnectionFrame *cf = createFrame(computerId, pos);
+ ConnectionFrame *cf = createFrame(computerId, &pos, true);
onPlaceFrame(cf);
if (computerId == room->tutorIP) {
qDebug() << "set computer with id " << computerId << " as tutor per configuration";
@@ -1172,9 +1164,6 @@ void MainWindow::onClientAuthenticated(Client* client)
ConnectionFrame *existing = NULL;
ConnectionFrame *cf = NULL;
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) {
- // qDebug() << "Existing frame ip: " << (*it)->computerId();
- // qDebug() << "New Clients ip: " << client->ip();
- // qDebug() << ((*it)->computerId() == client->ip());
if ((*it)->computerId() == client->ip()) {
existing = *it;
}
@@ -1189,7 +1178,6 @@ void MainWindow::onClientAuthenticated(Client* client)
cf->assignClient(client);
connect(client, SIGNAL(disconnected()), this, SLOT(clientCountChanged()));
- //resizeEvent(NULL); // This is where all the positioning should be
tellClientCurrentSituation(client);
clientCountChanged();
}
diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h
index cf7b068..4e99747 100644
--- a/src/server/mainwindow/mainwindow.h
+++ b/src/server/mainwindow/mainwindow.h
@@ -70,7 +70,6 @@ private:
None
} _mode;
int _streamingSource;
- int _countSessionNameUpdate;
QList<ConnectionFrame*> _clientFrames;
ListenServer *_listenServer;
@@ -80,8 +79,7 @@ private:
QPoint closestFreeSlot(QPoint preferredPixels, ConnectionFrame* toIgnore);
void placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred = QPoint(-1, -1));
- ConnectionFrame* createFrame();
- ConnectionFrame* createFrame(QString computerId, QPoint gridPosition);
+ ConnectionFrame* createFrame(const QString &computerId = QString(), const QPoint *gridPosition = NULL, bool fromRoomplan = false);
void savePosition(ConnectionFrame *cf);
void startVncServerIfNecessary(int from);
void tellClientCurrentSituation(Client* client);