From af07c529791a131e5f05f5ad55bc42b6be48627c Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Mon, 31 Oct 2016 15:31:50 +0100 Subject: [PATCH] Added Kill z-Tree button, Added confirmation dialog for shutdown button, further minor UI changes --- .gitignore | 1 + src/mainwindow.cpp | 46 ++++++++++++++++++++++------ src/mainwindow.h | 1 + src/mainwindow.ui | 75 ++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 101 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index d9a9aee..06b7d96 100755 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ # Qt Creator User Project Files *.pro.user +*.eccba64 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index acc776b..2aec657 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -471,17 +471,24 @@ void lc::MainWindow::on_PBShowSessions_clicked() { } void lc::MainWindow::on_PBShutdown_clicked() { - QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); - for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) { - if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { - Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); - // Do not shut down the server itself - if ( client->name == "self"){ - QMessageBox::information(NULL, "Shutdown canceled", "It is not allowed to shutdown the server itself via labcontrol!"); - } else { - client->Shutdown(); + // Confirmation dialog + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this, "Confirm", "Really shutdown the selected clients?", QMessageBox::Yes|QMessageBox::No); + if (reply == QMessageBox::Yes) { + QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); + for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) { + if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { + Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); + // Do not shut down the server itself + if ( client->name == "self"){ + QMessageBox::information(NULL, "Shutdown canceled", "It is not allowed to shutdown the server itself via labcontrol!"); + } else { + client->Shutdown(); + } } } + } else { + qDebug() << "Canceled shutting down the selected clients"; } } @@ -736,3 +743,24 @@ void lc::MainWindow::on_PBrestartCrashedSession_clicked() { startProc.startDetached( settings->restartCrashedSessionScript); } } + +void lc::MainWindow::on_PBKillzTree_clicked() +{ + QString program{ settings->killallCmd }; + QStringList arguments; + arguments << "-I" << "-q" << "ztree.exe"; + // Confirmation dialog + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this, "Confirm", "Really kill all z-Tree instances?", QMessageBox::Yes|QMessageBox::No); + if (reply == QMessageBox::Yes) { + // Kill all z-Tree processes + QProcess killLocalzLeafProc; + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + killLocalzLeafProc.setProcessEnvironment( env ); + killLocalzLeafProc.startDetached( program, arguments ); + // Output message via the debug messages tab + qDebug() << program << arguments; + } else { + qDebug() << "Canceled killing all z-Tree processes"; + } +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 6d56d50..90f0925 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -117,6 +117,7 @@ private slots: QString argLatexHeaderName, QString argDateString ); void on_PBrestartCrashedSession_clicked(); + void on_PBKillzTree_clicked(); }; } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 121f9eb..248eea4 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -40,15 +40,21 @@ - + + + + 0 + 0 + + z-Tree false - + @@ -69,6 +75,16 @@ + + + + Kill all local z-Tree instances + + + Kill z-Tree + + + @@ -99,32 +115,32 @@ - + - Starts zLeaf on the selected clients with the port given in the 'zTree' groupbox. + Turns off the selected clients. - Start z-Leaf + Shutdown - + - Kills zLeaf on all selected clients. + Starts zLeaf on the selected clients with the port given in the 'zTree' groupbox. - Kill z-Leaf + Start z-Leaf - + - Turns off the selected clients. + Kills zLeaf on all selected clients. - Shutdown + Kill z-Leaf @@ -218,6 +234,13 @@ + + + + Qt::Horizontal + + + @@ -228,6 +251,13 @@ + + + + Qt::Horizontal + + + @@ -240,7 +270,7 @@ - <html><head/><body><p>Run zLeaf with another name than the client's.<br/>Choose the name the zLeaf shall have:</p></body></html> + <html><head/><body><p>Run zLeaf with another name than the client's:</p></body></html> Qt::RichText @@ -258,12 +288,31 @@ true + + + Choose the name the z-Leaf shall have + + - Run z-Leaf + Run z-Leaf with chosen name + + + + + + + Qt::Horizontal + + + + + + + Upoad folder: