From a9b237f1821b6afe27212c49663ebef18742836a Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Sun, 27 Aug 2017 22:06:15 +0200 Subject: [PATCH 01/22] Changelog init --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ac64fc..8a81926 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed ### Removed +## [v2.1.4] - 2017-08-27 +* Added dialog for Upload folder button ## [v2.1.0] - 2016-10-12 ### Added * Manual printing of _z-Tree_ payment files From 9f0344303401df0be525e31d7ccf64d35b267b27 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Fri, 1 Sep 2017 10:35:58 +0200 Subject: [PATCH 02/22] ui tests --- src/Lib/client.cpp | 4 +- src/mainwindow.cpp | 24 +-- src/mainwindow.h | 1 - src/mainwindow.ui | 393 +++++++++++++++++++++++++-------------------- 4 files changed, 236 insertions(+), 186 deletions(-) diff --git a/src/Lib/client.cpp b/src/Lib/client.cpp index 66d39ce..8190a52 100755 --- a/src/Lib/client.cpp +++ b/src/Lib/client.cpp @@ -105,7 +105,7 @@ void lc::Client::Boot() { GotStatusChanged( state_t::BOOTING ); } -void lc::Client::DeactiveScreensaver() { +/*void lc::Client::DeactiveScreensaver() { QStringList arguments; arguments << "-i" << settings->pkeyPathUser << QString{ settings->userNameOnClients + "@" + ip } @@ -119,7 +119,7 @@ void lc::Client::DeactiveScreensaver() { // Output message via the debug messages tab qDebug() << settings->sshCmd << arguments.join( " " ); -} +}*/ void lc::Client::GotStatusChanged( state_t argState ) { if ( ( protectedCycles > 0 ) && ( state == state_t::BOOTING ) && ( argState != state_t::RESPONDING ) ) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2aec657..e2f2266 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -81,7 +81,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { ui->CBClientNames->setEnabled( false ); ui->CBWebcamChooser->setEnabled( false ); ui->GBClientActions->setEnabled( false ); - ui->GBzTree->setEnabled( false ); + //ui->GBzTree->setEnabled( false ); ui->LEFilePath->setEnabled( false ); ui->LFakeName->setEnabled( false ); ui->LWebcamChooser->setEnabled( false ); @@ -117,7 +117,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { ui->LFakeName->setEnabled( false ); ui->PBBeamFile->setEnabled( false ); ui->PBChooseFile->setEnabled( false ); - ui->PBDeactivateScreensaver->setEnabled( false ); + //ui->PBDeactivateScreensaver->setEnabled( false ); ui->PBKillzLeaf->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); ui->PBShutdown->setEnabled( false ); @@ -171,7 +171,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { ui->CBClientNames->setEnabled( false ); ui->LFakeName->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); - ui->PBStartSession->setEnabled( false ); + //ui->PBStartSession->setEnabled( false ); ui->PBStartLocalzLeaf->setEnabled( false ); ui->PBStartzLeaf->setEnabled( false ); } @@ -184,7 +184,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { // Disable 'PBViewDesktop' if 'vnc_viewer' was not set if ( settings->vncViewer.isEmpty() ) { - ui->PBViewDesktop->setEnabled( false ); + //ui->PBViewDesktop->setEnabled( false ); } // Disable 'PBBoot' if 'wakeonlan_command' was not set @@ -203,21 +203,21 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { ui->CBClientNames->setEnabled( false ); ui->LFakeName->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); - ui->PBStartSession->setEnabled( false ); + //ui->PBStartSession->setEnabled( false ); ui->PBStartLocalzLeaf->setEnabled( false ); ui->PBStartzLeaf->setEnabled( false ); } // Disable the disable screensaver function if the 'xset_command' was not set - if ( settings->xsetCmd.isEmpty() ) { - ui->PBDeactivateScreensaver->setEnabled( false ); - } + //if ( settings->xsetCmd.isEmpty() ) { + // ui->PBDeactivateScreensaver->setEnabled( false ); + //} if ( settings->zTreeInstDir.isEmpty() ) { ui->CBClientNames->setEnabled( false ); ui->LFakeName->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); - ui->PBStartSession->setEnabled( false ); + //ui->PBStartSession->setEnabled( false ); ui->PBStartLocalzLeaf->setEnabled( false ); ui->PBStartzLeaf->setEnabled( false ); } @@ -297,12 +297,12 @@ void lc::MainWindow::on_PBChooseFile_clicked() { delete file_dialog; } -void lc::MainWindow::on_PBDeactivateScreensaver_clicked() { +/*void lc::MainWindow::on_PBDeactivateScreensaver_clicked() { for ( auto s : settings->GetClients() ) { if ( s->GetClientState() >= state_t::RESPONDING ) s->DeactiveScreensaver(); } -} +}*/ void lc::MainWindow::on_PBExecute_clicked() { // This will be set to false, if the command shall be executed only on the chosen clients (that's if not all clients are up) @@ -615,7 +615,7 @@ void lc::MainWindow::SetupWidgets() { const QStringList &zTreeEntries = settings->installedZTreeVersions; if ( zTreeEntries.isEmpty() ) { ui->CBClientNames->setEnabled( false ); - ui->GBzTree->setEnabled( false ); + //ui->GBzTree->setEnabled( false ); ui->LFakeName->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); ui->PBStartLocalzLeaf->setEnabled( false ); diff --git a/src/mainwindow.h b/src/mainwindow.h index 90f0925..e66316c 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -61,7 +61,6 @@ private slots: void on_PBBeamFile_clicked(); void on_PBBoot_clicked(); void on_PBChooseFile_clicked(); - void on_PBDeactivateScreensaver_clicked(); void on_PBExecute_clicked(); void on_PBKillLocalzLeaf_clicked(); void on_PBKillzLeaf_clicked(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index e655b53..530adf9 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -40,62 +40,57 @@ - - - - - 0 - 0 - - + + - z-Tree - - - false + Experiment preparation / server actions - + - - - Start a new session. A new window will be opened to enter all required parameters. - + - Start session + Show ORSEE - - - true + + + Qt::Horizontal + + + + - Show sessions + Show preprints - + - Kill all local z-Tree instances + Choose a payment file manually, which will then be printed. - Terminate z-Tree + Print payment file manually - + Qt::Horizontal - + + + Stop all local z-Tree instances + - Session recovery: + Stop z-Tree @@ -107,74 +102,104 @@ - - - Choose a payment file manually, which will then be printed. - - - Print payment file manually + + + Qt::Horizontal - - - - - - - Client actions - - - - - Boots the selected clients. - - - Boot + + + + + Start local z-Leaf + + + + + + + Stop local z-Leaf + + + + + + + + + Qt::Horizontal - - - Turns off the selected clients. + + + true + + + + 16777215 + 16777215 + - Shutdown + <html><head/><body><p>Run zLeaf with another name than the client's:</p></body></html> + + + Qt::RichText + + + false + + + true - - - Starts zLeaf on the selected clients with the port given in the 'zTree' groupbox. - - - Start z-Leaf + + + true + + + Choose the name the z-Leaf shall have + + - - - Kills zLeaf on all selected clients. - + - Terminate z-Leaf + Run z-Leaf with chosen name - - - Shows the desktop of the selected clients. + + + Qt::Horizontal + + + + - View desktop + Show webcams: + + + + + Choose webcam + + + + @@ -186,174 +211,173 @@ 6 - + - Further local actions + Client actions - + - - - Show ORSEE + + + Boots the selected clients. - - - - - Show preprints + Boot - - - - - Start local z-Leaf - - - - - - - Kill local z-Leaf - - - - - - - - - - - - Special actions - - - - + + + Turns off the selected clients. + - Show webcam: + Shutdown - - - - Choose webcam - - + + + Qt::Horizontal + - - - Qt::Horizontal + + + Starts zLeaf on the selected clients with the port given in the 'zTree' groupbox. + + + Start z-Leaf on selected clients - + - Deactivates the screensavers on the selected clients. + Stops zLeaf on all selected clients - Deactivate screensaver + Stop z-Leaf on selected clients - + Qt::Horizontal - - - true - - - - 16777215 - 16777215 - + + + Shows the desktop of the selected clients. - <html><head/><body><p>Run zLeaf with another name than the client's:</p></body></html> + View desktop of selected clients (viel only) - - Qt::RichText - - - false - - - true - - - - - - - true - - - - Choose the name the z-Leaf shall have - - - + - Run z-Leaf with chosen name + View desktop of selected clients (full control) - + Qt::Horizontal - - - Upoad folder: - - - - - + - + - + - Choose folder + Upload folder to all selected clients: + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - true + + + + + Choose folder + + + + + + + true + + + + + + + + + Start to upload folder + + + + + + Qt::Horizontal + + + + + + + Start browser on all selected clients: + + + + + + + + + URL: + + + + + + + + + + - + - Beam folder to ~/media4zTree on all clients + Start browser + + + + + + + Stop browser @@ -366,6 +390,30 @@ + + + true + + + Start session + + + + + 9 + 9 + 761 + 411 + + + + + + + + Settings + + false @@ -507,6 +555,9 @@ + + true + 0 From f9f7e5f92fefcaf4f56696ba03e441f4b668822e Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Sun, 3 Sep 2017 21:24:57 +0200 Subject: [PATCH 03/22] major ui changes, deleted some files --- Labcontrol.pro | 3 - src/Lib/client.cpp | 30 ++- src/Lib/client.h | 4 + src/Lib/settings.h | 1 + src/mainwindow.cpp | 50 ++--- src/mainwindow.h | 3 +- src/mainwindow.ui | 415 ++++++++++++++++++++++++++++++++++++++--- src/sessiondisplay.cpp | 34 ---- src/sessiondisplay.h | 46 ----- src/sessiondisplay.ui | 24 --- 10 files changed, 433 insertions(+), 177 deletions(-) delete mode 100755 src/sessiondisplay.cpp delete mode 100755 src/sessiondisplay.h delete mode 100755 src/sessiondisplay.ui diff --git a/Labcontrol.pro b/Labcontrol.pro index 76cba58..e5a81ac 100755 --- a/Labcontrol.pro +++ b/Labcontrol.pro @@ -8,7 +8,6 @@ SOURCES += src/localzleafstarter.cpp \ src/main.cpp \ src/mainwindow.cpp \ src/manualprintingsetup.cpp \ - src/sessiondisplay.cpp \ src/sessionstarter.cpp \ src/Lib/client.cpp \ src/Lib/clienthelpnotificationserver.cpp \ @@ -25,7 +24,6 @@ SOURCES += src/localzleafstarter.cpp \ HEADERS += src/localzleafstarter.h \ src/mainwindow.h \ src/manualprintingsetup.h \ - src/sessiondisplay.h \ src/sessionstarter.h \ src/Lib/client.h \ src/Lib/clienthelpnotificationserver.h \ @@ -43,7 +41,6 @@ HEADERS += src/localzleafstarter.h \ FORMS += src/localzleafstarter.ui \ src/mainwindow.ui \ src/manualprintingsetup.ui \ - src/sessiondisplay.ui \ src/sessionstarter.ui QMAKE_CXXFLAGS += -std=c++11 diff --git a/src/Lib/client.cpp b/src/Lib/client.cpp index 8190a52..fb0d1d1 100755 --- a/src/Lib/client.cpp +++ b/src/Lib/client.cpp @@ -105,22 +105,6 @@ void lc::Client::Boot() { GotStatusChanged( state_t::BOOTING ); } -/*void lc::Client::DeactiveScreensaver() { - QStringList arguments; - arguments << "-i" << settings->pkeyPathUser - << QString{ settings->userNameOnClients + "@" + ip } - << settings->xsetCmd << "-display" << ":0.0" << "dpms" << "force" << "on"; - - // Start the process - QProcess deactiveScreensaverProcess; - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - deactiveScreensaverProcess.setProcessEnvironment( env ); - deactiveScreensaverProcess.startDetached( settings->sshCmd, arguments ); - - // Output message via the debug messages tab - qDebug() << settings->sshCmd << arguments.join( " " ); -}*/ - void lc::Client::GotStatusChanged( state_t argState ) { if ( ( protectedCycles > 0 ) && ( state == state_t::BOOTING ) && ( argState != state_t::RESPONDING ) ) { return; @@ -319,3 +303,17 @@ void lc::Client::StartZLeaf( const QString * const argFakeName ) { qDebug() << settings->sshCmd << arguments.join( " " ); } } + +void lc::Client::StartClientBrowser( const QString * const argURL ) { + //Declarations + QStringList arguments; + + // Start the process + QProcess startClientBrowserProcess; + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + startClientBrowserProcess.setProcessEnvironment( env ); + startClientBrowserProcess.startDetached( settings->clientBrowserCmd, arguments ); + + // Output message via the debug messages tab + qDebug() << settings->clientBrowserCmd << arguments.join( " " ); +} diff --git a/src/Lib/client.h b/src/Lib/client.h index 0b474bd..cad1ffc 100755 --- a/src/Lib/client.h +++ b/src/Lib/client.h @@ -113,6 +113,10 @@ public: @param argFakeName The name the zLeaf instance shall have (if not the default, which is the hostname of the client) */ void StartZLeaf( const QString * const argFakeName = nullptr ); + /*! + @param argURL URL to open in clients browser + */ + void StartClientBrowser( const QString * const argURL = nullptr ); private: const QString &GetzLeafVersion() const { return zLeafVersion; } diff --git a/src/Lib/settings.h b/src/Lib/settings.h index f727369..b2851f4 100755 --- a/src/Lib/settings.h +++ b/src/Lib/settings.h @@ -84,6 +84,7 @@ public: const QStringList installedLaTeXHeaders; const QStringList installedZTreeVersions; const quint16 clientHelpNotificationServerPort = 0; + const QString clientBrowserCmd; private: static bool CheckPathAndComplain( const QString &argPath, const QString &argVariableName, diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e2f2266..30196e2 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -71,6 +71,16 @@ bool lc::MainWindow::CheckIfUserIsAdmin() { } void lc::MainWindow::DisableDisfunctionalWidgets() { + const QStringList &zTreeEntries = settings->installedZTreeVersions; + if ( zTreeEntries.isEmpty() ) { + ui->CBClientNames->setEnabled( false ); + //ui->GBzTree->setEnabled( false ); + ui->LFakeName->setEnabled( false ); + ui->PBRunzLeaf->setEnabled( false ); + ui->PBStartLocalzLeaf->setEnabled( false ); + ui->PBStartzLeaf->setEnabled( false ); + } + // Disable all z-Leaf killing related buttons if the 'killall' command is not available if ( settings->killallCmd.isEmpty() ) { ui->PBKillLocalzLeaf->setEnabled( false ); @@ -462,14 +472,6 @@ void lc::MainWindow::on_PBShowPreprints_clicked() { lablib->ShowPreprints(); } -void lc::MainWindow::on_PBShowSessions_clicked() { - QWidget *sessionDisplay = new SessionDisplay{ lablib->GetSessionsModel(), this }; - sessionDisplay->setWindowFlags( Qt::Window ); - sessionDisplay->show(); - connect( sessionDisplay, &SessionDisplay::destroyed, - sessionDisplay, &SessionDisplay::deleteLater ); -} - void lc::MainWindow::on_PBShutdown_clicked() { // Confirmation dialog QMessageBox::StandardButton reply; @@ -612,16 +614,6 @@ void lc::MainWindow::SetupWidgets() { ui->CBWebcamChooser->addItem( s ); } - const QStringList &zTreeEntries = settings->installedZTreeVersions; - if ( zTreeEntries.isEmpty() ) { - ui->CBClientNames->setEnabled( false ); - //ui->GBzTree->setEnabled( false ); - ui->LFakeName->setEnabled( false ); - ui->PBRunzLeaf->setEnabled( false ); - ui->PBStartLocalzLeaf->setEnabled( false ); - ui->PBStartzLeaf->setEnabled( false ); - } - // Disable the admin tab if the user has no administrative rights and set it up if ( CheckIfUserIsAdmin() ) { ui->TAdminActions->setEnabled( true ); @@ -654,10 +646,15 @@ void lc::MainWindow::SetupWidgets() { << "apt full-upgrade -y" << "reboot" << "uname -a" ); } - DisableDisfunctionalWidgets(); + // Disable buttons which are not configured + //DisableDisfunctionalWidgets(); // Set the info text in LInfo on the TInfo tab - ui->LInfo->setText( "This is Labcontrol.\n\nCopyright 2014-2016 Markus Prasser\n\n\n" + ui->LInfo->setText( "This is Labcontrol.\n\nDevelopers\n\n" + "0day-2016 Henning Prömpers\n" + "2014-2016 Markus Prasser\n" + "2016 - now WiwilabHiwiOrgaization\n\n\n" + "\n\nCopyright\n\n\n" "Labcontrol is free software: you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" "the Free Software Foundation, either version 3 of the License, or\n" @@ -735,7 +732,7 @@ void lc::MainWindow::UpdateClientsTableView() { } } -// TODO: Implement the functionality of the script in here +// TODO: Implement the functionality of the restore session script in here (no zenity script) void lc::MainWindow::on_PBrestartCrashedSession_clicked() { QProcess startProc; startProc.setProcessEnvironment( QProcessEnvironment::systemEnvironment() ); @@ -764,3 +761,14 @@ void lc::MainWindow::on_PBKillzTree_clicked() qDebug() << "Canceled killing all z-Tree processes"; } } + +void lc::MainWindow::on_PBstartBrowser_clicked() +{ + QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); + for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { + if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { + Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); + client->StartZLeaf( nullptr ); + } + } +} diff --git a/src/mainwindow.h b/src/mainwindow.h index e66316c..58f4734 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -25,7 +25,6 @@ enum class icons_t : unsigned short int { UNKNOWN, OFF, DOWN, BOOT, ON, ZLEAF, I #include "Lib/client.h" #include "Lib/lablib.h" #include "sessionstarter.h" -#include "sessiondisplay.h" #include "ui_mainwindow.h" #include @@ -70,7 +69,6 @@ private slots: void on_PBRunzLeaf_clicked(); void on_PBShowORSEE_clicked(); void on_PBShowPreprints_clicked(); - void on_PBShowSessions_clicked(); void on_PBShutdown_clicked(); void on_PBStartLocalzLeaf_clicked(); void on_PBStartSession_clicked(); @@ -117,6 +115,7 @@ private slots: QString argDateString ); void on_PBrestartCrashedSession_clicked(); void on_PBKillzTree_clicked(); + void on_PBstartBrowser_clicked(); }; } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 530adf9..e9fba06 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -35,7 +35,7 @@ - Experimenter actions + Experiment actions @@ -54,7 +54,7 @@ - + Qt::Horizontal @@ -78,7 +78,7 @@ - + Qt::Horizontal @@ -102,7 +102,7 @@ - + Qt::Horizontal @@ -127,7 +127,7 @@ - + Qt::Horizontal @@ -145,7 +145,7 @@ - <html><head/><body><p>Run zLeaf with another name than the client's:</p></body></html> + <html><head/><body><p>Run zLeaf with another name than local <br/>(or selected client's hostname):</p></body></html> Qt::RichText @@ -178,7 +178,7 @@ - + Qt::Horizontal @@ -200,6 +200,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -237,7 +250,7 @@ - + Qt::Horizontal @@ -264,7 +277,7 @@ - + Qt::Horizontal @@ -276,7 +289,7 @@ Shows the desktop of the selected clients. - View desktop of selected clients (viel only) + View desktop of selected clients (view only) @@ -288,7 +301,7 @@ - + Qt::Horizontal @@ -297,9 +310,9 @@ - + - + Upload folder to all selected clients: @@ -309,7 +322,7 @@ - + @@ -338,21 +351,21 @@ - + Qt::Horizontal - + Start browser on all selected clients: - + @@ -361,21 +374,32 @@ - + + + http:// + + - + + + Fullscreen + + + + + - + Start browser - + Stop browser @@ -383,6 +407,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -395,24 +432,242 @@ true - Start session + Session actions 9 - 9 + 79 + 371 + 381 + + + + + 9 + + + 9 + + + 9 + + + 9 + + + + + New session + + + + + + + + + z-Tree version + + + + + + + + + + Data target path: + + + + + + + + + + + + Port: + + + + + + + 7000 + + + 10000 + + + + + + + + + + + Use ramdisk for gamesafe file + + + + + + + Allow session without attached clients + + + + + + + Start z-Leaf on clients with the session + + + true + + + + + + + Start session + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + 390 + 140 + 381 + 321 + + + + + + + + 10 + 10 761 - 411 + 57 - + + + + + Cleanup / recover last session + + + + + + + + + Stop z-Tree + + + + + + + Recover crashed session + + + + + + + + + Qt::Horizontal + + + + + + + + + 388 + 108 + 381 + 321 + + + + + + + Template for receipts: + + + + + + + + + + Print anonymous receipts + + + + + + + Substitute participant names with: + + + + + + + + + + Print receipt for local client + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + - - - - Settings - @@ -531,12 +786,110 @@ + + + Settings + + + + + 10 + 10 + 371 + 451 + + + + + + + TextLabel + + + + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + + + + + + + + + + + + + + + + + + + + + 390 + 10 + 381 + 451 + + + + + Qt::RightToLeft - Info + Credits diff --git a/src/sessiondisplay.cpp b/src/sessiondisplay.cpp deleted file mode 100755 index 77a9ff2..0000000 --- a/src/sessiondisplay.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2014-2016 Markus Prasser - * - * This file is part of Labcontrol. - * - * Labcontrol is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Labcontrol is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Labcontrol. If not, see . - */ - -#include "sessiondisplay.h" -#include "ui_sessiondisplay.h" - -lc::SessionDisplay::SessionDisplay( QAbstractTableModel *argSessionsModel, - QWidget *argParent ) : - QWidget{ argParent }, - ui{ new Ui::SessionDisplay } -{ - ui->setupUi( this ); - ui->TVSessions->setModel( argSessionsModel ); -} - -lc::SessionDisplay::~SessionDisplay() { - delete ui; -} diff --git a/src/sessiondisplay.h b/src/sessiondisplay.h deleted file mode 100755 index a8e72af..0000000 --- a/src/sessiondisplay.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2014-2016 Markus Prasser - * - * This file is part of Labcontrol. - * - * Labcontrol is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Labcontrol is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Labcontrol. If not, see . - */ - -#ifndef SESSIONDISPLAY_H -#define SESSIONDISPLAY_H - -#include -#include - -namespace lc { - -namespace Ui { -class SessionDisplay; -} - -class SessionDisplay : public QWidget { - Q_OBJECT - -public: - explicit SessionDisplay( QAbstractTableModel *argSessionsModel, - QWidget *argParent = nullptr ); - ~SessionDisplay(); - -private: - Ui::SessionDisplay *ui = nullptr; -}; - -} - -#endif // SESSIONDISPLAY_H diff --git a/src/sessiondisplay.ui b/src/sessiondisplay.ui deleted file mode 100755 index aa796c1..0000000 --- a/src/sessiondisplay.ui +++ /dev/null @@ -1,24 +0,0 @@ - - - lc::SessionDisplay - - - - 0 - 0 - 400 - 300 - - - - Session Display - - - - - - - - - - From adcfb722b9cf97a7b6f1cae216f4493dbcce9b91 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Tue, 5 Sep 2017 08:48:29 +0200 Subject: [PATCH 04/22] added start/stop browser feature --- src/Lib/client.cpp | 41 +++++++++++++++++++++++++++---- src/Lib/client.h | 11 ++++++--- src/Lib/settings.cpp | 3 +++ src/mainwindow.cpp | 24 +++++++++++++++++-- src/mainwindow.h | 1 + src/mainwindow.ui | 57 +++++++++++++++++++++++++------------------- 6 files changed, 103 insertions(+), 34 deletions(-) diff --git a/src/Lib/client.cpp b/src/Lib/client.cpp index fb0d1d1..3680dc2 100755 --- a/src/Lib/client.cpp +++ b/src/Lib/client.cpp @@ -246,7 +246,7 @@ void lc::Client::Shutdown() { GotStatusChanged( state_t::SHUTTING_DOWN ); } -void lc::Client::StartZLeaf( const QString * const argFakeName ) { +void lc::Client::StartZLeaf( const QString * argFakeName ) { if ( state < state_t::RESPONDING || zLeafVersion.isEmpty() || GetSessionPort() < 7000 ) { return; } @@ -304,16 +304,49 @@ void lc::Client::StartZLeaf( const QString * const argFakeName ) { } } -void lc::Client::StartClientBrowser( const QString * const argURL ) { +void lc::Client::StartClientBrowser( const QString * const argURL, const bool * const argFullscreen ) { //Declarations QStringList arguments; + // Output message via the debug messages tab + qDebug() << settings->sshCmd << arguments.join( " " ); + + //Build arguments list for SSH command + arguments << "-i" << settings->pkeyPathUser + << QString{ settings->userNameOnClients + "@" + ip } + << "DISPLAY=:0.0" + << settings->clientBrowserCmd + << *argURL; + + // Start the process + QProcess startClientBrowserProcess; + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + startClientBrowserProcess.setProcessEnvironment( env ); + startClientBrowserProcess.startDetached( settings->sshCmd, arguments ); + + // Output message via the debug messages tab + qDebug() << settings->sshCmd << arguments.join( " " ); +} + +void lc::Client::StopClientBrowser() { + //Declarations + QStringList arguments; + + //Build arguments list + arguments << "-i" << settings->pkeyPathUser + << QString{ settings->userNameOnClients + "@" + ip } + << "DISPLAY=:0.0" + << "killall" + << settings->clientBrowserCmd + << "&& sleep 1" + << "&& rm -R /home/ewfuser/.mozilla/firefox/*"; + // Start the process QProcess startClientBrowserProcess; QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); startClientBrowserProcess.setProcessEnvironment( env ); - startClientBrowserProcess.startDetached( settings->clientBrowserCmd, arguments ); + startClientBrowserProcess.startDetached( settings->sshCmd, arguments ); // Output message via the debug messages tab - qDebug() << settings->clientBrowserCmd << arguments.join( " " ); + qDebug() << settings->sshCmd << arguments.join( " " ); } diff --git a/src/Lib/client.h b/src/Lib/client.h index cad1ffc..22f78fe 100755 --- a/src/Lib/client.h +++ b/src/Lib/client.h @@ -112,11 +112,16 @@ public: /*! @param argFakeName The name the zLeaf instance shall have (if not the default, which is the hostname of the client) */ - void StartZLeaf( const QString * const argFakeName = nullptr ); + void StartZLeaf(const QString *argFakeName = nullptr ); /*! - @param argURL URL to open in clients browser + * \brief Opens a browser window on the client + * @param argURL URL to open in clients browser */ - void StartClientBrowser( const QString * const argURL = nullptr ); + void StartClientBrowser( const QString *argURL = nullptr, const bool *argFullscreen = nullptr ); + /*! + * \brief Closes all browser instances + */ + void StopClientBrowser(); private: const QString &GetzLeafVersion() const { return zLeafVersion; } diff --git a/src/Lib/settings.cpp b/src/Lib/settings.cpp index fb26344..5da9d4b 100755 --- a/src/Lib/settings.cpp +++ b/src/Lib/settings.cpp @@ -31,6 +31,9 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) : browserCmd{ ReadSettingsItem( "browser_command", "Opening ORSEE in a browser will not work.", argSettings, true ) }, + clientBrowserCmd{ ReadSettingsItem( "client_browser_command", + "Opening a browser window on clients will not work.", + argSettings, false ) }, dvipsCmd{ ReadSettingsItem( "dvips_command", "Receipts creation will not work.", argSettings, true ) }, diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 30196e2..d467e91 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -758,17 +758,37 @@ void lc::MainWindow::on_PBKillzTree_clicked() // Output message via the debug messages tab qDebug() << program << arguments; } else { - qDebug() << "Canceled killing all z-Tree processes"; + qDebug() << "Canceled stopping all z-Tree processes"; } } void lc::MainWindow::on_PBstartBrowser_clicked() { + QString argURL = ui->LEURL->text(); + bool argFullscreen = ui->CBFullscreen->checkState(); QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); - client->StartZLeaf( nullptr ); + client->StartClientBrowser( &argURL, &argFullscreen ); } } } + +void lc::MainWindow::on_PBstopBrowser_clicked() +{ + // Confirmation dialog + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this, "Confirm", "Really kill all selected browser instances?", QMessageBox::Yes|QMessageBox::No); + if (reply == QMessageBox::Yes) { + QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); + for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { + if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { + Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); + client->StopClientBrowser( ); + } + } + } else { + qDebug() << "Canceled stopping all selected browser processes"; + } +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 58f4734..2761216 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -116,6 +116,7 @@ private slots: void on_PBrestartCrashedSession_clicked(); void on_PBKillzTree_clicked(); void on_PBstartBrowser_clicked(); + void on_PBstopBrowser_clicked(); }; } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index e9fba06..066a1af 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -6,7 +6,7 @@ 0 0 - 800 + 658 900 @@ -163,6 +163,9 @@ true + + Choose the name z-Leaf shall have + Choose the name the z-Leaf shall have @@ -201,7 +204,7 @@ - + Qt::Vertical @@ -383,10 +386,13 @@ - + Fullscreen + + true + @@ -399,7 +405,7 @@ - + Stop browser @@ -408,7 +414,7 @@ - + Qt::Vertical @@ -438,9 +444,9 @@ 9 - 79 - 371 - 381 + 69 + 311 + 391 @@ -458,6 +464,12 @@ + + + 50 + false + + New session @@ -554,29 +566,24 @@ - - - - 390 - 140 - 381 - 321 - - - - 10 10 - 761 - 57 + 621 + 55 + + + 50 + false + + Cleanup / recover last session @@ -612,10 +619,10 @@ - 388 - 108 - 381 - 321 + 330 + 100 + 301 + 361 From 7bea07b7ac3a7bebb1a76bb4850a6381d73517c3 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Sat, 9 Sep 2017 16:19:48 +0200 Subject: [PATCH 05/22] Added functionality to new layout. Moved config location. --- doc/manual.tex | 2 +- src/Lib/client.cpp | 54 +-- src/Lib/client.h | 3 +- src/Lib/lablib.cpp | 2 +- src/main.cpp | 2 +- src/mainwindow.cpp | 280 +++++++++----- src/mainwindow.h | 20 +- src/mainwindow.ui | 818 ++++++++++++++++++++++++----------------- src/sessionstarter.cpp | 1 + 9 files changed, 722 insertions(+), 460 deletions(-) diff --git a/doc/manual.tex b/doc/manual.tex index 5bc94ed..107271a 100755 --- a/doc/manual.tex +++ b/doc/manual.tex @@ -93,7 +93,7 @@ Like already mentioned all \emph{z-Tree} and \emph{z-Leaf} versions should be co The directories in the \texttt{data} directory should be copied to the \emph{zTree installation directory}. -Afterwards place the \texttt{Labcontrol.conf} in a subfolder \texttt{Economic Laboratory} in the place where \emph{QSettings} stores its definitions on your platform (on \emph{Linux} this would be \texttt{/etc/xdg/Economic Laboratory/Labcontrol.conf}) and adjust it to your needs and prerequisites. +Afterwards place the \texttt{Labcontrol.conf} in a subfolder \texttt{Labcontrol} in the place where \emph{QSettings} stores its definitions on your platform (on \emph{Linux} this would be \texttt{/etc/xdg/Labcontrol/Labcontrol.conf}) and adjust it to your needs and prerequisites. To allow \emph{Labcontrol} to control the clients password-less public-key authentication must be available at least for the experiment user on the clients. For administration this is also required for \texttt{root}. Also all clients should be known by \texttt{ /etc/ssh/ssh\_known\_hosts}. This file must be readable by the users! If this is missing \emph{Labcontrol} will query the user on every connection attempt, which is not user-friendly. diff --git a/src/Lib/client.cpp b/src/Lib/client.cpp index 3680dc2..0a86444 100755 --- a/src/Lib/client.cpp +++ b/src/Lib/client.cpp @@ -157,26 +157,13 @@ void lc::Client::OpenTerminal( const QString &argCommand, const bool &argOpenAsR QStringList *arguments = nullptr; arguments = new QStringList; if ( !argOpenAsRoot ) { - *arguments << "--title" << name << "-e" << - QString{ settings->sshCmd + " -i " + settings->pkeyPathUser + " " - + settings->userNameOnClients + "@" + ip }; + *arguments << "-e" + << QString{ "'" + settings->sshCmd + " -i " + settings->pkeyPathUser + " " + + settings->userNameOnClients + "@" + ip + "'"}; } else { - *arguments << "--title" << name << "-e" << - QString{ settings->sshCmd + " -i " + settings->pkeyPathRoot - + " " + "root@" + ip }; - } - - if ( settings->termEmulCmd.contains( "konsole" ) ) { - arguments->prepend( "--new-tab" ); - arguments->prepend( "--show-tabbar" ); - } else { - if ( settings->termEmulCmd.contains( "gnome-terminal" ) ) { - arguments->prepend( "--tab" ); - } - } - - if ( !argCommand.isEmpty() ) { - arguments->last().append( " '" + argCommand + "'" ); + *arguments << "-e" << + QString{ "'" + settings->sshCmd + " -i " + settings->pkeyPathRoot + + " " + "root@" + ip + "'"}; } QProcess openTerminalProcess; @@ -208,7 +195,20 @@ void lc::Client::SetStateToZLEAF_RUNNING( QString argClientIP ) { } } -void lc::Client::ShowDesktop() { +void lc::Client::ShowDesktopViewOnly() { + QStringList arguments; + arguments << ip; + + QProcess showDesktopProcess; + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + showDesktopProcess.setProcessEnvironment( env ); + showDesktopProcess.startDetached( settings->vncViewer, arguments ); + + // Output message via the debug messages tab + qDebug() << settings->vncViewer << arguments.join( " " ); +} + +void lc::Client::ShowDesktopFullControl() { QStringList arguments; arguments << ip; @@ -308,16 +308,18 @@ void lc::Client::StartClientBrowser( const QString * const argURL, const bool * //Declarations QStringList arguments; - // Output message via the debug messages tab - qDebug() << settings->sshCmd << arguments.join( " " ); - - //Build arguments list for SSH command + // Build arguments list for SSH command arguments << "-i" << settings->pkeyPathUser << QString{ settings->userNameOnClients + "@" + ip } << "DISPLAY=:0.0" << settings->clientBrowserCmd << *argURL; + // Add fullscreen toggle if checked + if (*argFullscreen == true){ + arguments << "& sleep 3 && DISPLAY=:0.0 xdotool key --clearmodifiers F11"; + } + // Start the process QProcess startClientBrowserProcess; QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); @@ -335,11 +337,9 @@ void lc::Client::StopClientBrowser() { //Build arguments list arguments << "-i" << settings->pkeyPathUser << QString{ settings->userNameOnClients + "@" + ip } - << "DISPLAY=:0.0" << "killall" << settings->clientBrowserCmd - << "&& sleep 1" - << "&& rm -R /home/ewfuser/.mozilla/firefox/*"; + << "& sleep 1 && rm -R /home/ewfuser/.mozilla/firefox/*"; // Start the process QProcess startClientBrowserProcess; diff --git a/src/Lib/client.h b/src/Lib/client.h index 22f78fe..6cf1893 100755 --- a/src/Lib/client.h +++ b/src/Lib/client.h @@ -103,7 +103,8 @@ public: void SetSessionPort( int argSP ) { sessionPort = argSP; } void SetzLeafVersion( const QString &argzLeafV ) { zLeafVersion = argzLeafV; } //! Shows the desktop of the given client - void ShowDesktop(); + void ShowDesktopViewOnly(); + void ShowDesktopFullControl(); /*! * \brief Shuts down the client */ diff --git a/src/Lib/lablib.cpp b/src/Lib/lablib.cpp index 1f82560..3fcca0f 100755 --- a/src/Lib/lablib.cpp +++ b/src/Lib/lablib.cpp @@ -26,7 +26,7 @@ lc::Lablib::Lablib( QObject *argParent ) : QObject{ argParent }, - labSettings{ "Economic Laboratory", "Labcontrol", this }, + labSettings{ "Labcontrol", "Labcontrol", this }, sessionsModel{ new SessionsModel{ this } } { for ( const auto &s : settings->GetClients() ) { diff --git a/src/main.cpp b/src/main.cpp index d9f7695..ba01477 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,7 +28,7 @@ std::unique_ptr< lc::Settings > settings; int main( int argc, char *argv[] ) { QApplication a{ argc, argv }; - settings.reset( new lc::Settings{ QSettings{ "Economic Laboratory", "Labcontrol" } } ); + settings.reset( new lc::Settings{ QSettings{ "Labcontrol", "Labcontrol" } } ); lc::MainWindow w; w.show(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d467e91..26cff83 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -47,6 +47,37 @@ lc::MainWindow::MainWindow( QWidget *argParent ) : this, &MainWindow::UpdateClientsTableView ); gui_update_timer->start( 500 ); } + + /* session actions */ + + // Add z-Tree versions to the corresponding combo box + ui->CBzTreeVersion->addItem( tr( "Please choose a version:" ) ); + ui->CBzTreeVersion->addItems( settings->installedZTreeVersions ); + + // Add default path to the corresponding combo box + ui->CBDataTargetPath->addItem( tr( "Set a new path HERE" ) ); + ui->CBDataTargetPath->addItem( QDir::homePath() ); + ui->CBDataTargetPath->addItem( QDir::homePath() + "/zTreeData" ); + ui->CBDataTargetPath->setCurrentIndex( 2 ); + connect( this, &MainWindow::RequestNewDataTargetPath, + this, &MainWindow::GetNewDataTargetPath ); + + if ( settings->dvipsCmd.isEmpty() || settings->latexCmd.isEmpty() + || settings->lcInstDir.isEmpty() || settings->lprCmd.isEmpty() + || settings->postscriptViewer.isEmpty() || settings->ps2pdfCmd.isEmpty() + || settings->rmCmd.isEmpty() || settings->vncViewer.isEmpty() ) { + QMessageBox::information( this, tr( "Receipts printing will not work" ), + tr( "Some component essential for receipts creation and" + " printing is missing. No receipts will be created or" + " printed." ), QMessageBox::Ok ); + } else { + ui->CBReceiptsHeader->addItems( settings->installedLaTeXHeaders ); + + if ( settings->defaultReceiptIndex + && settings->defaultReceiptIndex < ui->CBReceiptsHeader->count() ) { + ui->CBReceiptsHeader->setCurrentIndex( settings->defaultReceiptIndex ); + } + } } lc::MainWindow::~MainWindow() { @@ -218,11 +249,6 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { ui->PBStartzLeaf->setEnabled( false ); } - // Disable the disable screensaver function if the 'xset_command' was not set - //if ( settings->xsetCmd.isEmpty() ) { - // ui->PBDeactivateScreensaver->setEnabled( false ); - //} - if ( settings->zTreeInstDir.isEmpty() ) { ui->CBClientNames->setEnabled( false ); ui->LFakeName->setEnabled( false ); @@ -271,12 +297,19 @@ void lc::MainWindow::on_CBWebcamChooser_activated( int argIndex ) { void lc::MainWindow::on_PBBeamFile_clicked() { QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); const QString fileToBeam{ ui->LEFilePath->text() }; + if(fileToBeam == ""){ + QMessageBox::information(this, "Upload failed", "You didn't choose any folder to upload."); + } else { + //Iterate over the selected clients to upload the file 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 * >() ); client->BeamFile( fileToBeam, &settings->pkeyPathUser, &settings->userNameOnClients ); } } + // Inform the user about the path + QMessageBox::information(this, "Upload completed", "The folder was copied to all selected clients.\nThe path on every client is /home/ewfuser" + fileToBeam.mid(fileToBeam.lastIndexOf('/')) +".\nDon't forget to adjust the media path within zTree!"); + } } void lc::MainWindow::on_PBBoot_clicked() { @@ -307,13 +340,6 @@ void lc::MainWindow::on_PBChooseFile_clicked() { delete file_dialog; } -/*void lc::MainWindow::on_PBDeactivateScreensaver_clicked() { - for ( auto s : settings->GetClients() ) { - if ( s->GetClientState() >= state_t::RESPONDING ) - s->DeactiveScreensaver(); - } -}*/ - void lc::MainWindow::on_PBExecute_clicked() { // This will be set to false, if the command shall be executed only on the chosen clients (that's if not all clients are up) bool executeOnEveryClient = true; @@ -384,16 +410,6 @@ void lc::MainWindow::on_PBKillLocalzLeaf_clicked() { qDebug() << program << arguments; } -void lc::MainWindow::on_PBKillzLeaf_clicked() { - QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); - for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { - if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { - Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); - client->KillZLeaf(); - } - } -} - void lc::MainWindow::on_PBOpenFilesystem_clicked() { // Determine the correct user to be used QString * userToBeUsed = nullptr; @@ -504,39 +520,6 @@ void lc::MainWindow::on_PBStartLocalzLeaf_clicked() { localzLeafStarter, SLOT( deleteLater() ) ); } -void lc::MainWindow::on_PBStartSession_clicked() { - SessionStarter *sessionStarter = new SessionStarter{ lablib->GetOccupiedPorts(), this }; - sessionStarter->setWindowFlags( Qt::Window ); - sessionStarter->show(); - connect( sessionStarter, &SessionStarter::RequestNewSession, - lablib, &Lablib::StartNewSession ); - connect( sessionStarter, &SessionStarter::destroyed, - sessionStarter, &SessionStarter::deleteLater ); -// // Show an error message, if no zTree version was chosen yet -// if (ui->CBzTreeVersion->currentIndex() == 0) { -// QMessageBox messageBox{ QMessageBox::Warning, tr("Unset zTree version"), tr("There is no zTree version chosen yet. Please choose one."), QMessageBox::Ok, this }; -// messageBox.exec(); -// return; -// } - -// // Ask a second time, if no valid LaTeX header was set -// if (ui->CBReceiptsHeader->currentText() == "None found") { -// QMessageBox messageBox{ QMessageBox::Information, tr("No valid LaTeX header chosen"), -// tr("No valid LaTeX header was chosen. Receipts creation and printing will not work. Shall a new zTree instance be started nonetheless?"), QMessageBox::Yes | QMessageBox::No, this }; -// messageBox.exec(); -// if (messageBox.clickedButton() == messageBox.button(QMessageBox::No)) -// return; -// } - -// ui->CBDataTargetPath->setStyleSheet( "" ); -// ui->CBPrintanonymousreceipts->setStyleSheet( "" ); -// ui->CBReceiptsHeader->setStyleSheet( "" ); -// ui->CBReceiptsforLocalClients->setStyleSheet( "" ); -// ui->SBPort->setStyleSheet( "" ); - -// lablib->StartNewZTreeInstance(); -} - void lc::MainWindow::on_PBStartzLeaf_clicked() { QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { @@ -547,16 +530,6 @@ void lc::MainWindow::on_PBStartzLeaf_clicked() { } } -void lc::MainWindow::on_PBViewDesktop_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 * >() ); - client->ShowDesktop(); - } - } -} - void lc::MainWindow::on_RBUseLocalUser_toggled(bool checked) { if ( checked ) { qDebug() << "'RBUseLocalUser' got toggled."; @@ -595,7 +568,7 @@ void lc::MainWindow::SetupWidgets() { valid_items->squeeze(); } else { QMessageBox messageBox{ QMessageBox::Warning, tr( "Could not construct clients view" ), - tr( "The creation of the clients view failed. Please check the file '/etc/xdg/Economic Laboratory/Labcontrol.conf'." ), QMessageBox::Ok, this }; + tr( "The creation of the clients view failed. Please check the file '/etc/xdg/Labcontrol/Labcontrol.conf'." ), QMessageBox::Ok, this }; messageBox.exec(); ui->CBClientNames->setEnabled( false ); ui->GBClientActions->setEnabled( false ); @@ -732,16 +705,64 @@ void lc::MainWindow::UpdateClientsTableView() { } } -// TODO: Implement the functionality of the restore session script in here (no zenity script) -void lc::MainWindow::on_PBrestartCrashedSession_clicked() { - QProcess startProc; - startProc.setProcessEnvironment( QProcessEnvironment::systemEnvironment() ); - if ( !settings->restartCrashedSessionScript.isEmpty() ) { - startProc.startDetached( settings->restartCrashedSessionScript); +void lc::MainWindow::on_PBstartBrowser_clicked() +{ + QString argURL = ui->LEURL->text(); + bool argFullscreen = ui->CBFullscreen->checkState(); + QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); + for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { + if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { + Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); + client->StartClientBrowser( &argURL, &argFullscreen ); + } + } +} + +void lc::MainWindow::on_PBstopBrowser_clicked() +{ + // Confirmation dialog + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this, "Confirm", "Really kill all selected browser instances?", QMessageBox::Yes|QMessageBox::No); + if (reply == QMessageBox::Yes) { + QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); + for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { + if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { + Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); + client->StopClientBrowser( ); + } + } + } else { + qDebug() << "Canceled stopping all selected browser processes"; + } +} + +// View only VNC Button +void lc::MainWindow::on_PBViewDesktopViewOnly_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 * >() ); + client->ShowDesktopViewOnly(); + } + } +} + +void lc::MainWindow::on_PBViewDesktopFullControl_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 * >() ); + client->ShowDesktopFullControl(); + } } } -void lc::MainWindow::on_PBKillzTree_clicked() + +/* Session action functions */ + +void lc::MainWindow::on_PBStopZtree_clicked() { QString program{ settings->killallCmd }; QStringList arguments; @@ -758,37 +779,106 @@ void lc::MainWindow::on_PBKillzTree_clicked() // Output message via the debug messages tab qDebug() << program << arguments; } else { - qDebug() << "Canceled stopping all z-Tree processes"; + qDebug() << "Canceled stopping all z-Tree processes"; } } -void lc::MainWindow::on_PBstartBrowser_clicked() +void lc::MainWindow::on_PBRecoverCrashedSession_clicked() { - QString argURL = ui->LEURL->text(); - bool argFullscreen = ui->CBFullscreen->checkState(); - QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); - for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { - if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { - Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); - client->StartClientBrowser( &argURL, &argFullscreen ); + // TODO: Implement the functionality of the restore session script in here (no zenity script) + QProcess startProc; + startProc.setProcessEnvironment( QProcessEnvironment::systemEnvironment() ); + if ( !settings->restartCrashedSessionScript.isEmpty() ) { + startProc.startDetached( settings->restartCrashedSessionScript); } - } } -void lc::MainWindow::on_PBstopBrowser_clicked() +void lc::MainWindow::on_CBDataTargetPath_activated( int argIndex ) { - // Confirmation dialog - QMessageBox::StandardButton reply; - reply = QMessageBox::question(this, "Confirm", "Really kill all selected browser instances?", QMessageBox::Yes|QMessageBox::No); - if (reply == QMessageBox::Yes) { - QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); - for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { - if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { - Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); - client->StopClientBrowser( ); + if ( !argIndex ) { + emit RequestNewDataTargetPath(); + } + + ui->CBDataTargetPath->setStyleSheet( "" ); +} + +// Open a folder coose dialog if first position in the combo box is clicked +void lc::MainWindow::GetNewDataTargetPath() { + QFileDialog fileDialog{ this }; + fileDialog.setFileMode( QFileDialog::Directory ); + fileDialog.setDirectory( QDir::homePath() ); + fileDialog.setOption( QFileDialog::ShowDirsOnly, true ); + fileDialog.setOption( QFileDialog::DontUseNativeDialog, true ); + if ( fileDialog.exec() ) { + const QString fileName = fileDialog.selectedFiles().at( 0 ); + ui->CBDataTargetPath->addItem( fileName ); + ui->CBDataTargetPath->setCurrentText( fileName ); + } +} + +// Start session button actions +void lc::MainWindow::on_PBStartSession_clicked() { + if ( ui->CBzTreeVersion->currentIndex() == 0 ) { + QMessageBox::information( this, tr( "No z-Tree version chosen" ), + tr( "A z-Tree version was not chosen, yet. This setting is" + " mandatory." ), QMessageBox::Ok ); + return; + } + + const QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); + if( !ui->ChBSessionWithoutAttachedClients->isChecked() ) { + if ( !activatedItems.length() ) { + QMessageBox::information( this, tr( "Canceled, no clients were chosen" ), + tr( "The start of a new session was canceled." + " Some clients have to be selected first or the" + " creation of sessions without clients must be" + " allowed with the checkbox close to the bottom" ) ); + return; + } + } + + QString anonymousReceiptsPlaceholder; + if ( ui->ChBPrintAnonymousReceipts->isChecked() ) { + anonymousReceiptsPlaceholder = ui->CBReplaceParticipantNames->currentText(); + } + + QVector< Client* > associatedClients; + for ( auto cit = activatedItems.cbegin(); cit != activatedItems.cend(); ++cit ) { + if ( ( *cit ).data( Qt::DisplayRole ).type() != 0 ) { + Client *client = static_cast< Client* >( ( *cit ).data( Qt::UserRole ).value< void* >() ); + client->SetSessionPort( ui->SBPort->value() ); + client->SetzLeafVersion( ui->CBzTreeVersion->currentText() ); + associatedClients.append( client ); + } + } + + emit RequestNewSession( associatedClients, anonymousReceiptsPlaceholder, + ui->ChBReceiptsForLocalClients->isChecked(), + ui->CBReceiptsHeader->currentText(), + ui->CBDataTargetPath->currentText(), + static_cast< quint16 >( ui->SBPort->value() ), + ui->CBzTreeVersion->currentText() ); + + //Start z-Leaf on selected clients if checkbox is activated + if( ui->ChBautoStartClientZleaf->isChecked() ) { + for ( auto cit = activatedItems.cbegin(); cit != activatedItems.cend(); ++cit ) { + if ( ( *cit ).data( Qt::DisplayRole ).type() != 0 ) { + Client *client = static_cast< Client* >( ( *cit ).data( Qt::UserRole ).value< void * >() ); + client->StartZLeaf( nullptr ); } } - } else { - qDebug() << "Canceled stopping all selected browser processes"; } } + +// Anonymous receipients header check box +void lc::MainWindow::on_ChBPrintanonymousreceipts_clicked() +{ + ui->LReplaceParticipantNames->setEnabled(true); + ui->CBReplaceParticipantNames->setEnabled(true); +} + +void lc::MainWindow::on_CBReceiptsHeader_activated(int argIndex) +{ + Q_UNUSED( argIndex ); + ui->CBReceiptsHeader->setStyleSheet( "" ); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 2761216..0b78ac5 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -62,7 +62,6 @@ private slots: void on_PBChooseFile_clicked(); void on_PBExecute_clicked(); void on_PBKillLocalzLeaf_clicked(); - void on_PBKillzLeaf_clicked(); void on_PBOpenFilesystem_clicked(); void on_PBOpenTerminal_clicked(); void on_PBPrintPaymentFileManually_clicked(); @@ -73,7 +72,8 @@ private slots: void on_PBStartLocalzLeaf_clicked(); void on_PBStartSession_clicked(); void on_PBStartzLeaf_clicked(); - void on_PBViewDesktop_clicked(); + void on_PBViewDesktopViewOnly_clicked(); + void on_PBViewDesktopFullControl_clicked(); void on_RBUseLocalUser_toggled(bool checked); void StartLocalzLeaf( QString argzLeafName, QString argzLeafVersion, int argzTreePort ); //! Updates the icons of the QTableView displaying the clients' states @@ -84,6 +84,12 @@ private slots: void UpdateClientsTableView(); signals: + /*Session actions*/ + void RequestNewDataTargetPath(); + void RequestNewSession( QVector< Client* > argAssocCl, QString argParticipNameReplacement, + bool argPrintLocalReceipts, QString argReceiptsHeader, + QString argzTreeDataTargetPath, quint16 argzTreePort, + QString argzTreeVersion ); private: //! Checks, if the user has administrative rights @@ -113,10 +119,16 @@ private slots: QString argAnonymousReceiptsPlaceholder, QString argLatexHeaderName, QString argDateString ); - void on_PBrestartCrashedSession_clicked(); - void on_PBKillzTree_clicked(); void on_PBstartBrowser_clicked(); void on_PBstopBrowser_clicked(); + + /* Session actions */ + void on_PBStopZtree_clicked(); + void on_PBRecoverCrashedSession_clicked(); + void GetNewDataTargetPath(); + void on_CBDataTargetPath_activated( int argIndex ); + void on_CBReceiptsHeader_activated(int argIndex); + void on_ChBPrintanonymousreceipts_clicked(); }; } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 066a1af..7d2cf24 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -6,10 +6,16 @@ 0 0 - 658 + 730 900 + + + 0 + 0 + + Labcontrol @@ -18,6 +24,15 @@ ../../../../../../usr/local/share/labcontrol/icons/icon.png../../../../../../usr/local/share/labcontrol/icons/icon.png + + true + + + + 0 + 0 + + @@ -25,158 +40,108 @@ true - + 0 0 + + + 640 + 580 + + + + + 0 + 0 + + + + + false + true + + - 0 + 1 + + + true + + + false + + true + + + + 0 + 0 + + - Experiment actions + Experiment prepatation + + + 0 + 0 + + Experiment preparation / server actions - - - Show ORSEE - - - - - - - Qt::Horizontal - - - - - + - Show preprints + Plan a session or print attendee list - - - Choose a payment file manually, which will then be printed. - + - Print payment file manually + Show ORSEE - + Qt::Horizontal - - - Stop all local z-Tree instances - - - Stop z-Tree - - - - - + - Continue crashed session - - - - - - - Qt::Horizontal - - - - - - - - - Start local z-Leaf - - - - - - - Stop local z-Leaf - - - - - - - - - Qt::Horizontal + Print local files - - - true - - - - 16777215 - 16777215 - - + - <html><head/><body><p>Run zLeaf with another name than local <br/>(or selected client's hostname):</p></body></html> - - - Qt::RichText - - - false - - - true + Show preprints - - - true - - - Choose the name z-Leaf shall have + + + Choose a payment file manually, which will then be printed. - - - Choose the name the z-Leaf shall have - - - - - - - Run z-Leaf with chosen name + Print payment file manually @@ -190,7 +155,7 @@ - Show webcams: + Show webcams @@ -228,6 +193,15 @@ + + true + + + + 0 + 0 + + Client actions @@ -259,26 +233,6 @@ - - - - Starts zLeaf on the selected clients with the port given in the 'zTree' groupbox. - - - Start z-Leaf on selected clients - - - - - - - Stops zLeaf on all selected clients - - - Stop z-Leaf on selected clients - - - @@ -317,7 +271,7 @@ - Upload folder to all selected clients: + Upload folder to all selected clients Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft @@ -363,7 +317,7 @@ - Start browser on all selected clients: + Start browser on all selected clients @@ -437,33 +391,27 @@ true + + + 0 + 439 + + Session actions - + - 9 - 69 - 311 - 391 + 10 + 10 + 691 + 103 - - - 9 - - - 9 - - - 9 - - - 9 - + - + 50 @@ -471,215 +419,386 @@ - New session + Cleanup / recover last session - + - + - z-Tree version + Stop z-Tree - - - - + - Data target path: + Recover crashed session - - - - - - - - - Port: - - - - - - - 7000 - - - 10000 - - - - - - - - Use ramdisk for gamesafe file - - - - - - - Allow session without attached clients - - - - - - - Start z-Leaf on clients with the session + + + Stops zLeaf on all selected clients - - true - - - - - - Start session + Stop z-Leaf on selected clients - + - Qt::Vertical - - - - 20 - 40 - + Qt::Horizontal - + - + 10 - 10 - 621 - 55 + 120 + 691 + 469 - + + + QLayout::SetDefaultConstraint + - - - - 50 - false - - + - Cleanup / recover last session + New Session - + - - - Stop z-Tree + + + 9 - - - - - - Recover crashed session + + 9 - - - - - - - - Qt::Horizontal - - - - - - - - - 330 - 100 - 301 - 361 - - - - - - - Template for receipts: - - - - - - - - - - Print anonymous receipts - - - - - - - Substitute participant names with: - - - - - - - - - - Print receipt for local client - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - false - + + 9 + + + 9 + + + + + z-Tree version + + + + + + + + + + Data target path: + + + + + + + + + + 0 + + + + + + + Port: + + + + + + + 7000 + + + 10000 + + + + + + + + + + + Qt::Horizontal + + + + + + + Template for receipts + + + + + + + + + + Print anonymous receipts + + + + + + + false + + + Replace participant names with: + + + + + + + false + + + true + + + + \hspace{5cm} + + + + + anonym + + + + + anonymous + + + + + nicht ausfüllen + + + + + + + + Print receipt for local client + + + false + + + + + + + Qt::Horizontal + + + + + + + true + + + Use ramdisk for gamesafe file + + + + + + + Allow session without attached clients + + + + + + + Start z-Leaf on clients with the session + + + true + + + + + + + Start session + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + z-Leaves + + + 4 + + + + + + + Starts zLeaf on the selected clients with the port given in the 'zTree' groupbox. + + + Start z-Leaf on selected clients + + + + + + + Qt::Horizontal + + + + + + + true + + + + 16777215 + 16777215 + + + + <html><head/><body><p>Run zLeaf with another name<br/>(select a single client):</p></body></html> + + + Qt::RichText + + + false + + + true + + + + + + + true + + + Choose the name z-Leaf shall have + + + + Choose the name z-Leaf shall have + + + + + + + + Run z-Leaf with chosen name + + + + + + + Qt::Horizontal + + + + + + + + + Start local z-Leaf + + + + + + + Stop local z-Leaf + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + false + Admin actions @@ -793,7 +912,7 @@ - + Settings @@ -802,8 +921,8 @@ 10 10 - 371 - 451 + 311 + 201 @@ -879,17 +998,6 @@ - - - - 390 - 10 - 381 - 451 - - - - @@ -918,15 +1026,65 @@ true + + + 0 + 0 + + 0 256 - + + + 8 + + + false + + Qt::LeftToRight + + + false + + + true + + + true + + + true + + + true + + + 115 + + + 30 + + + true + + + true + + + 35 + + + 25 + + + true + diff --git a/src/sessionstarter.cpp b/src/sessionstarter.cpp index 44f9940..1c44be4 100755 --- a/src/sessionstarter.cpp +++ b/src/sessionstarter.cpp @@ -98,6 +98,7 @@ lc::SessionStarter::SessionStarter( const QVector< quint16 > &argOccupiedPorts, lc::SessionStarter::~SessionStarter() { delete ui; } + void lc::SessionStarter::CheckIfPortIsOccupied( quint16 argPort ) { if ( occupiedPorts.contains( argPort ) ) { CheckIfPortIsOccupied( argPort + 1 ); From 6bd69f1f7eca0f7bfb77d9e420a37587f3aafb91 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Tue, 12 Sep 2017 21:52:59 +0200 Subject: [PATCH 06/22] made start session working --- src/sessionstarter.cpp | 207 -------------------------- src/sessionstarter.h | 69 --------- src/sessionstarter.ui | 319 ----------------------------------------- 3 files changed, 595 deletions(-) delete mode 100755 src/sessionstarter.cpp delete mode 100755 src/sessionstarter.h delete mode 100755 src/sessionstarter.ui diff --git a/src/sessionstarter.cpp b/src/sessionstarter.cpp deleted file mode 100755 index 1c44be4..0000000 --- a/src/sessionstarter.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright 2014-2016 Markus Prasser - * - * This file is part of Labcontrol. - * - * Labcontrol is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Labcontrol is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Labcontrol. If not, see . - */ - -#include - -#include -#include -#include - -#include "sessionstarter.h" -#include "ui_sessionstarter.h" -#include "Lib/settings.h" - -extern std::unique_ptr< lc::Settings > settings; - -lc::SessionStarter::SessionStarter( const QVector< quint16 > &argOccupiedPorts, - QWidget *argParent ) : - QWidget{ argParent }, - clientsViewModel{ new QStandardItemModel{ this } }, - occupiedPorts{ argOccupiedPorts }, - ui{ new Ui::SessionStarter } -{ - ui->setupUi( this ); - - CheckIfPortIsOccupied( settings->GetChosenZTreePort() ); - - if ( settings->dvipsCmd.isEmpty() || settings->latexCmd.isEmpty() - || settings->lcInstDir.isEmpty() || settings->lprCmd.isEmpty() - || settings->postscriptViewer.isEmpty() || settings->ps2pdfCmd.isEmpty() - || settings->rmCmd.isEmpty() || settings->vncViewer.isEmpty() ) { - ui->GBReceipts->setEnabled( false ); - QMessageBox::information( this, tr( "Receipts printing will not work" ), - tr( "Some component essential for receipts creation and" - " printing is missing. No receipts will be created or" - " printed." ), QMessageBox::Ok ); - } else { - ui->CBReceiptsHeader->addItems( settings->installedLaTeXHeaders ); - - if ( settings->defaultReceiptIndex - && settings->defaultReceiptIndex < ui->CBReceiptsHeader->count() ) { - ui->CBReceiptsHeader->setCurrentIndex( settings->defaultReceiptIndex ); - } - } - - ui->CBzTreeVersion->addItem( tr( "Please choose a version:" ) ); - ui->CBzTreeVersion->addItems( settings->installedZTreeVersions ); - - ui->CBDataTargetPath->addItem( tr( "Set a new path HERE" ) ); - ui->CBDataTargetPath->addItem( QDir::homePath() ); - ui->CBDataTargetPath->addItem( QDir::homePath() + "/zTreeData" ); - ui->CBDataTargetPath->setCurrentIndex( 2 ); - connect( this, &SessionStarter::RequestNewDataTargetPath, - this, &SessionStarter::GetNewDataTargetPath ); - - for ( auto *s : settings->GetClients() ) { - int tempXPos = s->xPosition - 1, tempYPos = s->yPosition; - - if ( clientsViewModel->item( tempYPos, tempXPos ) ) { - QMessageBox::information( this, tr( "Double assignment to one position" ), - tr( "Two client where set for the same position. Client" - " '%1' will be dropped." ).arg( s->name ) ); - continue; - } - - QStandardItem *item = new QStandardItem( s->name ); - item->setEditable( false ); - const QString sessionPort{ QString::number( s->GetSessionPort() ) }; - if ( sessionPort == "0" ) { - item->setText( s->name ); - } else { - item->setBackground( QBrush{ QColor{ 196, 196, 255 } } ); - item->setSelectable( false ); - item->setText( QString{ "(" + sessionPort + ") " + s->name } ); - } - QVariant v = qVariantFromValue( static_cast< void* >( s ) ); - item->setData( v, Qt::UserRole ); - clientsViewModel->setItem( tempYPos, tempXPos, item ); - } - ui->TVClients->setModel( clientsViewModel ); -} - -lc::SessionStarter::~SessionStarter() { - delete ui; -} - -void lc::SessionStarter::CheckIfPortIsOccupied( quint16 argPort ) { - if ( occupiedPorts.contains( argPort ) ) { - CheckIfPortIsOccupied( argPort + 1 ); - } else { - ui->SBPort->setValue( argPort ); - } -} - -void lc::SessionStarter::GetNewDataTargetPath() { - QFileDialog fileDialog{ this }; - fileDialog.setFileMode( QFileDialog::Directory ); - fileDialog.setDirectory( QDir::homePath() ); - fileDialog.setOption( QFileDialog::ShowDirsOnly, true ); - fileDialog.setOption( QFileDialog::DontUseNativeDialog, true ); - if ( fileDialog.exec() ) { - const QString fileName = fileDialog.selectedFiles().at( 0 ); - ui->CBDataTargetPath->addItem( fileName ); - ui->CBDataTargetPath->setCurrentText( fileName ); - } -} - -void lc::SessionStarter::on_CBDataTargetPath_activated( int argIndex ) { - if ( !argIndex ) { - emit RequestNewDataTargetPath(); - } - - ui->CBDataTargetPath->setStyleSheet( "" ); -} - -void lc::SessionStarter::on_CBReceiptsHeader_activated( int argIndex ) { - Q_UNUSED( argIndex ); - ui->CBReceiptsHeader->setStyleSheet( "" ); -} - -void lc::SessionStarter::on_CBzTreeVersion_activated( int argIndex ) { - Q_UNUSED( argIndex ); - ui->CBzTreeVersion->setStyleSheet( "" ); -} - -void lc::SessionStarter::on_ChBPrintAnonymousReceipts_clicked( bool argChecked ) { - ui->ChBPrintAnonymousReceipts->setStyleSheet( "" ); - - ui->LReplaceParticipantNames->setEnabled( argChecked ); - ui->CBReplaceParticipantNames->setEnabled( argChecked ); -} - -void lc::SessionStarter::on_PBStartSession_clicked() { - if ( ui->CBzTreeVersion->currentIndex() == 0 ) { - QMessageBox::information( this, tr( "No z-Tree version chosen" ), - tr( "A z-Tree version was not chosen, yet. This setting is" - " mandatory." ), QMessageBox::Ok ); - return; - } - - const QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); - if( !ui->ChBSessionWithoutClients->isChecked() ) { - if ( !activatedItems.length() ) { - QMessageBox::information( this, tr( "Canceled, no clients were chosen" ), - tr( "The start of a new session was canceled." - " Some clients have to be selected first or the" - " creation of sessions without clients must be" - " allowed with the checkbox close to the bottom" ) ); - return; - } - } - - QString anonymousReceiptsPlaceholder; - if ( ui->ChBPrintAnonymousReceipts->isChecked() ) { - anonymousReceiptsPlaceholder = ui->CBReplaceParticipantNames->currentText(); - } - - QVector< Client* > associatedClients; - for ( auto cit = activatedItems.cbegin(); cit != activatedItems.cend(); ++cit ) { - if ( ( *cit ).data( Qt::DisplayRole ).type() != 0 ) { - Client *client = static_cast< Client* >( ( *cit ).data( Qt::UserRole ).value< void* >() ); - client->SetSessionPort( ui->SBPort->value() ); - client->SetzLeafVersion( ui->CBzTreeVersion->currentText() ); - associatedClients.append( client ); - } - } - - emit RequestNewSession( associatedClients, anonymousReceiptsPlaceholder, - ui->ChBReceiptsForLocalClients->isChecked(), - ui->CBReceiptsHeader->currentText(), - ui->CBDataTargetPath->currentText(), - static_cast< quint16 >( ui->SBPort->value() ), - ui->CBzTreeVersion->currentText() ); - - //Start z-Leaf on selected clients if checkbox is activated - if( ui->ChBautoStartClientZleaf->isChecked() ) { - for ( auto cit = activatedItems.cbegin(); cit != activatedItems.cend(); ++cit ) { - if ( ( *cit ).data( Qt::DisplayRole ).type() != 0 ) { - Client *client = static_cast< Client* >( ( *cit ).data( Qt::UserRole ).value< void * >() ); - client->StartZLeaf( nullptr ); - } - } - } - - this->deleteLater(); -} - -void lc::SessionStarter::on_SBPort_editingFinished() { - ui->SBPort->setStyleSheet( "" ); - - CheckIfPortIsOccupied( ui->SBPort->value() ); -} diff --git a/src/sessionstarter.h b/src/sessionstarter.h deleted file mode 100755 index dea501e..0000000 --- a/src/sessionstarter.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2014-2016 Markus Prasser - * - * This file is part of Labcontrol. - * - * Labcontrol is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Labcontrol is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Labcontrol. If not, see . - */ - -#ifndef SESSIONSTARTER_H -#define SESSIONSTARTER_H - -#include - -class QStandardItemModel; - -namespace lc { - -class Client; - -namespace Ui { -class SessionStarter; -} - -class SessionStarter : public QWidget { - Q_OBJECT - -public: - explicit SessionStarter( const QVector< quint16 > &argOccupiedPorts, - QWidget *argParent = nullptr ); - ~SessionStarter(); - -signals: - void RequestNewDataTargetPath(); - void RequestNewSession( QVector< Client* > argAssocCl, QString argParticipNameReplacement, - bool argPrintLocalReceipts, QString argReceiptsHeader, - QString argzTreeDataTargetPath, quint16 argzTreePort, - QString argzTreeVersion ); - -private: - void CheckIfPortIsOccupied( quint16 argPort ); - - QStandardItemModel *clientsViewModel = nullptr; - const QVector< quint16 > &occupiedPorts; - Ui::SessionStarter *ui = nullptr; - -private slots: - void GetNewDataTargetPath(); - void on_CBDataTargetPath_activated( int argIndex ); - void on_CBReceiptsHeader_activated( int argIndex ); - void on_CBzTreeVersion_activated( int argIndex ); - void on_ChBPrintAnonymousReceipts_clicked( bool argChecked ); - void on_PBStartSession_clicked(); - void on_SBPort_editingFinished(); -}; - -} - -#endif // SESSIONSTARTER_H diff --git a/src/sessionstarter.ui b/src/sessionstarter.ui deleted file mode 100755 index 18ad722..0000000 --- a/src/sessionstarter.ui +++ /dev/null @@ -1,319 +0,0 @@ - - - lc::SessionStarter - - - - 0 - 0 - 640 - 600 - - - - Form - - - - - - - - z-Tree - - - - - - The z-Tree version which shall be used for the experiment. - - - z-Tree version: - - - - - - - The z-Tree version which shall be used for the experiment. - - - background: cyan; - - - 32 - - - - - - - The path where z-Tree shall store its data. - -Please take care that it does not contain any spaces or other special characters. - - - Data target path: - - - - - - - The path where z-Tree shall store its data. - -Please take care that it does not contain any spaces or other special characters. - - - background: cyan; - - - - - - - - - The port which will be used by started z-Tree and z-Leaf instances. This only matters if multiple experiments shall be run in parallel. - - - Port: - - - - - - - true - - - The port which will be used by started z-Tree and z-Leaf instances. This only matters if multiple experiments shall be run in parallel. - - - background: cyan; - - - 7000 - - - 65535 - - - - - - - - - false - - - This function is not implemented, yet. - - - Use ramdisk for gamesafe file - - - - - - - - - - Receipts - - - - - - Choose the LaTeX template which shall be used for receipts creation. - - - Template for receipts: - - - - - - - Choose the LaTeX template which shall be used for receipts creation. - - - background: cyan; - - - - - - - Check this if you want the created receipts to be anonymous. - - - background: cyan; - - - Print anonymous receipts - - - - - - - false - - - Choose a string which shall replace the participant name on the anonymous receipts. - - - Substitute participants' names with: - - - - - - - false - - - Choose a string which shall replace the participant name on the anonymous receipts. - - - true - - - \hspace{5cm} - - - 0 - - - - \hspace{5cm} - - - - - anonym - - - - - anonymous - - - - - nicht ausfüllen - - - - - - - - This decides if receipts shall be printed for any z-Leaf instance running locally on the server. - -Warning: If this is disabled no receipts will be printed for ANY participant whose name contains the character string "local"! - - - Print receipts for local clients - - - true - - - - - - - - - - - - Select the clients which shall be attached to this session: - - - Select the clients which shall be attached to this session: - - - - - - - Select the clients which shall be attached to this session. - - - false - - - false - - - - - - - - 0 - 0 - - - - This allows an experimenter to override the normally hard requirement of choosing clients to be attached to the started session and start a session without attached clients. - - - Allow session without attached clients - - - - - - - Start z-Leaf on clients with the session - - - - - - - Start a new session according to the above made settings. - - - Start session - - - - - - - Cancel the creation of a new session. - - - Cancel - - - - - - - - - PBCancel - clicked() - lc::SessionStarter - deleteLater() - - - 319 - 552 - - - 319 - 287 - - - - - From 072bca9c2c23094f867925edda1db199cf808f29 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Tue, 12 Sep 2017 21:53:30 +0200 Subject: [PATCH 07/22] made start session working --- Labcontrol.pro | 5 +---- src/Lib/client.cpp | 4 ++++ src/Lib/lablib.h | 4 ++-- src/Lib/settings.cpp | 2 +- src/mainwindow.cpp | 11 +++++++--- src/mainwindow.h | 1 - src/mainwindow.ui | 48 +++++++++++++++++++++++++++++--------------- 7 files changed, 48 insertions(+), 27 deletions(-) diff --git a/Labcontrol.pro b/Labcontrol.pro index e5a81ac..64cf3b4 100755 --- a/Labcontrol.pro +++ b/Labcontrol.pro @@ -8,7 +8,6 @@ SOURCES += src/localzleafstarter.cpp \ src/main.cpp \ src/mainwindow.cpp \ src/manualprintingsetup.cpp \ - src/sessionstarter.cpp \ src/Lib/client.cpp \ src/Lib/clienthelpnotificationserver.cpp \ src/Lib/clientpinger.cpp \ @@ -24,7 +23,6 @@ SOURCES += src/localzleafstarter.cpp \ HEADERS += src/localzleafstarter.h \ src/mainwindow.h \ src/manualprintingsetup.h \ - src/sessionstarter.h \ src/Lib/client.h \ src/Lib/clienthelpnotificationserver.h \ src/Lib/clientpinger.h \ @@ -40,8 +38,7 @@ HEADERS += src/localzleafstarter.h \ FORMS += src/localzleafstarter.ui \ src/mainwindow.ui \ - src/manualprintingsetup.ui \ - src/sessionstarter.ui + src/manualprintingsetup.ui QMAKE_CXXFLAGS += -std=c++11 diff --git a/src/Lib/client.cpp b/src/Lib/client.cpp index 0a86444..1f1685c 100755 --- a/src/Lib/client.cpp +++ b/src/Lib/client.cpp @@ -166,6 +166,10 @@ void lc::Client::OpenTerminal( const QString &argCommand, const bool &argOpenAsR + " " + "root@" + ip + "'"}; } + if ( !argCommand.isEmpty() ) { + arguments->last().append( " '" + argCommand + "'" ); + } + QProcess openTerminalProcess; QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); openTerminalProcess.setProcessEnvironment( env ); diff --git a/src/Lib/lablib.h b/src/Lib/lablib.h index 865d94c..18afbdb 100755 --- a/src/Lib/lablib.h +++ b/src/Lib/lablib.h @@ -88,13 +88,13 @@ public: void SetLocalZLeafDefaultName( const QString &argName ); void ShowOrsee(); void ShowPreprints(); - -public slots: void StartNewSession( QVector< Client* > argAssocCl, QString argParticipNameReplacement, bool argPrintLocalReceipts, QString argReceiptsHeader, QString argzTreeDataTargetPath, quint16 argzTreePort, QString argzTreeVersion ); +public slots: + signals: void ZLEAF_RUNNING( QString argClientIP ); diff --git a/src/Lib/settings.cpp b/src/Lib/settings.cpp index 5da9d4b..f435f57 100755 --- a/src/Lib/settings.cpp +++ b/src/Lib/settings.cpp @@ -47,7 +47,7 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) : "Receipts creation will not work.", argSettings, true ) }, lcInstDir{ ReadSettingsItem( "labcontrol_installation_directory", - "Labcontrol will missbehave with high propability.", + "Datapath not set. Labcontrol will missbehave with high propability.", argSettings, true ) }, localUserName{ GetLocalUserName() }, localzLeafSize{ ReadSettingsItem( "local_zLeaf_size", diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 26cff83..ea14205 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -818,6 +818,7 @@ void lc::MainWindow::GetNewDataTargetPath() { // Start session button actions void lc::MainWindow::on_PBStartSession_clicked() { + if ( ui->CBzTreeVersion->currentIndex() == 0 ) { QMessageBox::information( this, tr( "No z-Tree version chosen" ), tr( "A z-Tree version was not chosen, yet. This setting is" @@ -829,10 +830,10 @@ void lc::MainWindow::on_PBStartSession_clicked() { if( !ui->ChBSessionWithoutAttachedClients->isChecked() ) { if ( !activatedItems.length() ) { QMessageBox::information( this, tr( "Canceled, no clients were chosen" ), - tr( "The start of a new session was canceled." + tr( "The start of a new session was canceled.\n" " Some clients have to be selected first or the" " creation of sessions without clients must be" - " allowed with the checkbox close to the bottom" ) ); + " allowed with the checkbox." ) ); return; } } @@ -852,7 +853,7 @@ void lc::MainWindow::on_PBStartSession_clicked() { } } - emit RequestNewSession( associatedClients, anonymousReceiptsPlaceholder, + this->lablib->StartNewSession ( associatedClients, anonymousReceiptsPlaceholder, ui->ChBReceiptsForLocalClients->isChecked(), ui->CBReceiptsHeader->currentText(), ui->CBDataTargetPath->currentText(), @@ -868,6 +869,10 @@ void lc::MainWindow::on_PBStartSession_clicked() { } } } + + //Set port to +1 + int newPort = ui->SBPort->text().toInt() + 1; + ui->SBPort->setValue(newPort); } // Anonymous receipients header check box diff --git a/src/mainwindow.h b/src/mainwindow.h index 0b78ac5..9b8c210 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -24,7 +24,6 @@ enum class icons_t : unsigned short int { UNKNOWN, OFF, DOWN, BOOT, ON, ZLEAF, I #include "Lib/client.h" #include "Lib/lablib.h" -#include "sessionstarter.h" #include "ui_mainwindow.h" #include diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 7d2cf24..d283eba 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -406,7 +406,7 @@ 10 10 691 - 103 + 71 @@ -432,6 +432,23 @@ + + + + Stops zLeaf on all selected clients + + + Stop z-Leaf on selected clients + + + + + + + Qt::Vertical + + + @@ -441,16 +458,6 @@ - - - - Stops zLeaf on all selected clients - - - Stop z-Leaf on selected clients - - - @@ -464,9 +471,9 @@ 10 - 120 + 88 691 - 469 + 461 @@ -1049,6 +1056,15 @@ Qt::LeftToRight + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustToContents + false @@ -1056,7 +1072,7 @@ true - true + false true @@ -1071,7 +1087,7 @@ 30 - true + false true @@ -1083,7 +1099,7 @@ 25 - true + false From 910fe0ed551a1eef6374a5adadf71d3765558bd0 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Wed, 13 Sep 2017 16:46:18 +0200 Subject: [PATCH 08/22] Changed TerminalStart quotes, Added Kill zLeave function --- src/Lib/client.cpp | 8 ++++---- src/Lib/settings.h | 2 +- src/mainwindow.cpp | 33 +++++++++++++++++++++++---------- src/mainwindow.h | 1 + src/mainwindow.ui | 6 +++--- 5 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/Lib/client.cpp b/src/Lib/client.cpp index 1f1685c..5d9bd23 100755 --- a/src/Lib/client.cpp +++ b/src/Lib/client.cpp @@ -158,12 +158,12 @@ void lc::Client::OpenTerminal( const QString &argCommand, const bool &argOpenAsR arguments = new QStringList; if ( !argOpenAsRoot ) { *arguments << "-e" - << QString{ "'" + settings->sshCmd + " -i " + settings->pkeyPathUser + " " - + settings->userNameOnClients + "@" + ip + "'"}; + << QString{ settings->sshCmd + " -i " + settings->pkeyPathUser + " " + + settings->userNameOnClients + "@" + ip }; } else { *arguments << "-e" << - QString{ "'" + settings->sshCmd + " -i " + settings->pkeyPathRoot - + " " + "root@" + ip + "'"}; + QString{ settings->sshCmd + " -i " + settings->pkeyPathRoot + + " " + "root@" + ip}; } if ( !argCommand.isEmpty() ) { diff --git a/src/Lib/settings.h b/src/Lib/settings.h index b2851f4..edc6023 100755 --- a/src/Lib/settings.h +++ b/src/Lib/settings.h @@ -48,6 +48,7 @@ public: const int defaultReceiptIndex = 0; const QString browserCmd; + const QString clientBrowserCmd; const QString dvipsCmd; const QString fileMngr; const QString killallCmd; @@ -84,7 +85,6 @@ public: const QStringList installedLaTeXHeaders; const QStringList installedZTreeVersions; const quint16 clientHelpNotificationServerPort = 0; - const QString clientBrowserCmd; private: static bool CheckPathAndComplain( const QString &argPath, const QString &argVariableName, diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ea14205..816eb75 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -429,6 +429,7 @@ void lc::MainWindow::on_PBOpenFilesystem_clicked() { delete userToBeUsed; } +// Issue open terminal call void lc::MainWindow::on_PBOpenTerminal_clicked() { QString pkeyPathUser; if ( ui->RBUseUserRoot->isChecked() ) { @@ -816,6 +817,20 @@ void lc::MainWindow::GetNewDataTargetPath() { } } +// Dummy function for enabling anonymous receipts section in UI +void lc::MainWindow::on_CBReceiptsHeader_activated(int argIndex) +{ + Q_UNUSED( argIndex ); + ui->CBReceiptsHeader->setStyleSheet( "" ); +} + +// Anonymous receipients header check box +void lc::MainWindow::on_ChBPrintanonymousreceipts_clicked() +{ + ui->LReplaceParticipantNames->setEnabled(true); + ui->CBReplaceParticipantNames->setEnabled(true); +} + // Start session button actions void lc::MainWindow::on_PBStartSession_clicked() { @@ -875,15 +890,13 @@ void lc::MainWindow::on_PBStartSession_clicked() { ui->SBPort->setValue(newPort); } -// Anonymous receipients header check box -void lc::MainWindow::on_ChBPrintanonymousreceipts_clicked() +void lc::MainWindow::on_PBKillzLeaf_clicked() { - ui->LReplaceParticipantNames->setEnabled(true); - ui->CBReplaceParticipantNames->setEnabled(true); -} - -void lc::MainWindow::on_CBReceiptsHeader_activated(int argIndex) -{ - Q_UNUSED( argIndex ); - ui->CBReceiptsHeader->setStyleSheet( "" ); + QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); + for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { + if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { + Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); + client->KillZLeaf(); + } + } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 9b8c210..154afef 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -128,6 +128,7 @@ private slots: void on_CBDataTargetPath_activated( int argIndex ); void on_CBReceiptsHeader_activated(int argIndex); void on_ChBPrintanonymousreceipts_clicked(); + void on_PBKillzLeaf_clicked(); }; } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index d283eba..6be33ee 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -64,7 +64,7 @@ - 1 + 2 true @@ -1075,7 +1075,7 @@ false - true + false true @@ -1090,7 +1090,7 @@ false - true + false 35 From d1cc49b2029155a9ef10aa8df76026bffef4d5ce Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Wed, 20 Sep 2017 23:08:50 +0200 Subject: [PATCH 09/22] structured config --- data/Labcontrol.conf | 95 ++++++++++++++++++++++++++++---------------- src/mainwindow.ui | 2 +- 2 files changed, 62 insertions(+), 35 deletions(-) diff --git a/data/Labcontrol.conf b/data/Labcontrol.conf index bf54f48..9561019 100755 --- a/data/Labcontrol.conf +++ b/data/Labcontrol.conf @@ -1,11 +1,33 @@ [General] -# The user names of all users which shall be able to conduct administrative tasks with Labcontrol -admin_users="UserA|UserB|UserC" -# The browser in which ORSEE shall be displayed -browser_command=/usr/bin/firefox +### Server settings +# The IP of the server running zTree +server_ip=192.168.1.200 +# Network broadcast address +network_broadcast_address=192.168.1.255 +# The port which shall be used by zTree by default +initial_port=8000 # The port the client help server shall listen on client_help_server_port=XXXX -# Client settings +# User names of all users which shall be able to conduct administrative tasks with Labcontrol +admin_users="UserA|UserB|UserC" +# The public keys to access the clients as root +pkey_path_root=/usr/local/share/labcontrol/id_labclient_root +# The public keys to access the clients as unprivileged user +pkey_path_user=/usr/local/share/labcontrol/id_labclient_dsa +# The default name for locally started zLeaves +local_zLeaf_name=local +# Default dimension for locally started zLeaves +local_zLeaf_size=1280x1024 +# If multiple receipts are availabe, this indicates, which one will be shown by default (the index counting from 0 following an alphabetical ordering) +default_receipt_index=0 +# The URL address of your lab's ORSEE +orsee_url=http://yourORSEEserver.tld +# URLs to available webcams +webcams="http://user:pass@webcam_left|http://user:pass@webcam_right" +# Display names for the webcams +webcam_names="Webcam right|Webcam left" + +### Client settings # The client settings are represented as an array. So the info of the first client stands in the first field in every section and the same is valid for the other clients with other indices each. client_ips=192.168.1.1|192.168.1.2|192.168.1.3|192.168.1.4|192.168.1.5|192.168.1.6|192.168.1.7|192.168.1.8|192.168.1.9|192.168.1.10|192.168.1.11|192.168.1.12|192.168.1.13|192.168.1.14|192.168.1.15|192.168.1.16|192.168.1.17|192.168.1.18|192.168.1.19|192.168.1.20|192.168.1.21|192.168.1.22|192.168.1.23|192.168.1.24 client_macs=00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00|00:00:00:00:00:00 @@ -16,50 +38,55 @@ client_quantity=24 # The following two coordinates specify where the client will be shown in the coordinate grid at the bottom of the Labcontrol screen client_xpos=1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24 client_ypos=1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1 -# If multiple receipts are availabe, this indicates, which one will be shown by default (the index counting from 0 following an alphabetical ordering) -default_receipt_index=0 -dvips_command=/usr/bin/dvips -file_manager=/usr/bin/dolphin -# The port which shall be used by zTree by default -initial_port=8000 +# The name of the user of the clients which is used to conduct experiments +user_name_on_clients=user + +[Binary paths] +# Path to your lpr binary +lpr_command=/usr/bin/lpr +# Path to your netstat binary +netstat_command=/bin/netstat # The command used to kill 'zleaf.exe' instances (part of the 'psmisc' package) killall_command=/usr/bin/killall # Where all Labcontrol data got installed labcontrol_installation_directory=/usr/local/share/labcontrol +# Path to your latex binary latex_command=/usr/bin/latex -# The default name for locally started zLeaves -local_zLeaf_name=local -local_zLeaf_size=1280x1024 -lpr_command=/usr/bin/lpr -netstat_command=/bin/netstat -network_broadcast_address=192.168.1.255 -# The URL address of your lab's ORSEE -orsee_url=http://yourORSEEserver.tld +# Path to your dvips binary +dvips_command=/usr/bin/dvips +# Path to your filemanager binary +file_manager=/usr/bin/dolphin +# Path to your ping binary ping_command=/bin/ping -# The public keys to access the clients -pkey_path_root=/usr/local/share/labcontrol/id_labclient_root -pkey_path_user=/usr/local/share/labcontrol/id_labclient_dsa +# Path to PDF/Postscript viewer binary postscript_viewer=/usr/bin/okular +# Path to ps2pdf binary ps2pdf_command=/usr/bin/ps2pdf +# Path to rm binary rm_command=/bin/rm +# Path to SCP binary scp_command=/usr/bin/scp -# The IP of the server running zTree -server_ip=192.168.1.200 +# The browser in which ORSEE shall be displayed +browser_command=/usr/bin/firefox +# Path to wmctrl binary ssh_command=/usr/bin/ssh +# Path to taskset binary taskset_command=/usr/bin/taskset -terminal_emulator_command=/usr/bin/konsole -# The name of the user of the clients which is used to conduct experiments -user_name_on_clients=user +# Path to terminal-emulator binary +terminal_emulator_command=/usr/bin/gnome-terminal +# Path to wine binary +wine_command=/usr/bin/wine +# Path to wmctrl binary +wmctrl_command=/usr/bin/wmctrl +# Path to xset binary +xset_command=/usr/bin/xset +# Path to VNC viewer binary vnc_viewer=/usr/bin/vinagre +# Path to wakeonlan binary wakeonlan_command=/usr/bin/wakeonlan # The program used to view the laboratory's webcams webcam_command=/usr/local/bin/WebcamDisplay -# URLs to available webcams -webcams="webcam_left|webcam_right" -wine_command=/usr/bin/wine -wmctrl_command=/usr/bin/wmctrl -xset_command=/usr/bin/xset # The folder were all zTree versions are installed (in subfolders matching the scheme zTree_X.Y.Z) ztree_installation_directory=/opt/z-Leaves -# Script to be called after session crash -restart_crashed_session_script=/home/scripts/start_zTree_after_crash.sh \ No newline at end of file +# Script to be called after session crash +restart_crashed_session_script=/home/scripts/start_zTree_after_crash.sh diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 6be33ee..7ab21e1 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -64,7 +64,7 @@ - 2 + 0 true From e54f75f678b4fc11424777a03b9657cb00d81cfa Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Thu, 21 Sep 2017 00:31:51 +0200 Subject: [PATCH 10/22] set version info. updated config file --- src/mainwindow.cpp | 2 +- src/mainwindow.ui | 161 ++++++++++++++++++++++----------------------- 2 files changed, 80 insertions(+), 83 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 816eb75..9ac015d 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -624,7 +624,7 @@ void lc::MainWindow::SetupWidgets() { //DisableDisfunctionalWidgets(); // Set the info text in LInfo on the TInfo tab - ui->LInfo->setText( "This is Labcontrol.\n\nDevelopers\n\n" + ui->LInfo->setText( "This is Labcontrol version 2.1.4\n\n\nDevelopers\n\n" "0day-2016 Henning Prömpers\n" "2014-2016 Markus Prasser\n" "2016 - now WiwilabHiwiOrgaization\n\n\n" diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 7ab21e1..532324e 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -11,7 +11,7 @@ - + 0 0 @@ -64,7 +64,7 @@ - 0 + 3 true @@ -206,6 +206,13 @@ Client actions + + + + Switch the selected clients on or off + + + @@ -240,20 +247,27 @@ + + + + Remote control the selected clients + + + Shows the desktop of the selected clients. - View desktop of selected clients (view only) + View desktop (view only) - View desktop of selected clients (full control) + Control desktop (mouse and keyboard) @@ -271,7 +285,7 @@ - Upload folder to all selected clients + Upload folder to the selected clients Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft @@ -317,7 +331,7 @@ - Start browser on all selected clients + Start browser on the selected clients @@ -923,87 +937,70 @@ Settings - + + + + 240 + 520 + 201 + 23 + + + + Change settings temporarly + + + 10 10 - 311 - 201 + 691 + 501 - - - - - TextLabel - - - - - - - - - - TextLabel - - - - - - - TextLabel - - - - - - - TextLabel - - - - - - - TextLabel - - - - - - - TextLabel - - - - - - - TextLabel - - - - - - - - - - - - - - - - - - - - - - + + Qt::ScrollBarAlwaysOn + + + true + + + + + 0 + 0 + 675 + 499 + + + + + + 0 + 0 + 671 + 611 + + + + + + + Server settings + + + + + + + Client settings + + + + + + @@ -1011,7 +1008,7 @@ Qt::RightToLeft - Credits + Info From 88202cb6068a240dccac3799e0836943a2160337 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Thu, 21 Sep 2017 03:25:33 +0200 Subject: [PATCH 11/22] minor config changes --- data/Labcontrol.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data/Labcontrol.conf b/data/Labcontrol.conf index 9561019..faabc23 100755 --- a/data/Labcontrol.conf +++ b/data/Labcontrol.conf @@ -23,7 +23,7 @@ default_receipt_index=0 # The URL address of your lab's ORSEE orsee_url=http://yourORSEEserver.tld # URLs to available webcams -webcams="http://user:pass@webcam_left|http://user:pass@webcam_right" +webcams=http://user:pass@webcam_left|http://user:pass@webcam_right # Display names for the webcams webcam_names="Webcam right|Webcam left" @@ -49,7 +49,8 @@ netstat_command=/bin/netstat # The command used to kill 'zleaf.exe' instances (part of the 'psmisc' package) killall_command=/usr/bin/killall # Where all Labcontrol data got installed -labcontrol_installation_directory=/usr/local/share/labcontrol +labcontrol_installation_directory=/usr/local/share/labcontrol #DOTO: REMOVE WHEN NOT NEEDED ANYMORE (AFTER 2.1.4 MIRGRATION +labcontrol_data_directory=/usr/local/share/labcontrol # Path to your latex binary latex_command=/usr/bin/latex # Path to your dvips binary From 716e38d732e25c81b0797f30581b2e3423e39804 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Thu, 21 Sep 2017 03:30:56 +0200 Subject: [PATCH 12/22] minor config changes --- data/Labcontrol.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/Labcontrol.conf b/data/Labcontrol.conf index faabc23..0be3d84 100755 --- a/data/Labcontrol.conf +++ b/data/Labcontrol.conf @@ -41,7 +41,7 @@ client_ypos=1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1 # The name of the user of the clients which is used to conduct experiments user_name_on_clients=user -[Binary paths] +### Binary paths # Path to your lpr binary lpr_command=/usr/bin/lpr # Path to your netstat binary @@ -49,7 +49,7 @@ netstat_command=/bin/netstat # The command used to kill 'zleaf.exe' instances (part of the 'psmisc' package) killall_command=/usr/bin/killall # Where all Labcontrol data got installed -labcontrol_installation_directory=/usr/local/share/labcontrol #DOTO: REMOVE WHEN NOT NEEDED ANYMORE (AFTER 2.1.4 MIRGRATION +labcontrol_installation_directory=/usr/local/share/labcontrol #DOTO: REMOVE WHEN NOT NEEDED ANYMORE (AFTER 2.1.4 MIRGRATION) labcontrol_data_directory=/usr/local/share/labcontrol # Path to your latex binary latex_command=/usr/bin/latex From 35b72ed066e557e8d2b3ab663bebb1ef120a70d4 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Thu, 21 Sep 2017 03:35:46 +0200 Subject: [PATCH 13/22] minor config changes --- data/Labcontrol.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/Labcontrol.conf b/data/Labcontrol.conf index 0be3d84..20c8190 100755 --- a/data/Labcontrol.conf +++ b/data/Labcontrol.conf @@ -49,7 +49,8 @@ netstat_command=/bin/netstat # The command used to kill 'zleaf.exe' instances (part of the 'psmisc' package) killall_command=/usr/bin/killall # Where all Labcontrol data got installed -labcontrol_installation_directory=/usr/local/share/labcontrol #DOTO: REMOVE WHEN NOT NEEDED ANYMORE (AFTER 2.1.4 MIRGRATION) +#DOTO: REMOVE VAGUE NAME WHEN NOT NEEDED ANYMORE (AFTER 2.1.4 MIRGRATION) +labcontrol_installation_directory=/usr/local/share/labcontrol labcontrol_data_directory=/usr/local/share/labcontrol # Path to your latex binary latex_command=/usr/bin/latex From 8143cdeb2dd7aaca5940f753c564eb4b78ee34a3 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Fri, 22 Sep 2017 08:16:07 +0200 Subject: [PATCH 14/22] settings tab changed --- data/Labcontrol.conf | 2 +- src/Lib/lablib.cpp | 2 +- src/Lib/receipts_handler.cpp | 4 +- src/Lib/settings.cpp | 13 ++- src/Lib/settings.h | 6 +- src/mainwindow.cpp | 201 +++++++++++++++++++---------------- src/mainwindow.h | 3 + src/mainwindow.ui | 40 +++++-- src/manualprintingsetup.cpp | 2 +- 9 files changed, 160 insertions(+), 113 deletions(-) diff --git a/data/Labcontrol.conf b/data/Labcontrol.conf index 20c8190..ac4c646 100755 --- a/data/Labcontrol.conf +++ b/data/Labcontrol.conf @@ -50,7 +50,7 @@ netstat_command=/bin/netstat killall_command=/usr/bin/killall # Where all Labcontrol data got installed #DOTO: REMOVE VAGUE NAME WHEN NOT NEEDED ANYMORE (AFTER 2.1.4 MIRGRATION) -labcontrol_installation_directory=/usr/local/share/labcontrol +labcontrol_data_directory=/usr/local/share/labcontrol labcontrol_data_directory=/usr/local/share/labcontrol # Path to your latex binary latex_command=/usr/bin/latex diff --git a/src/Lib/lablib.cpp b/src/Lib/lablib.cpp index 3fcca0f..7fc5729 100755 --- a/src/Lib/lablib.cpp +++ b/src/Lib/lablib.cpp @@ -107,7 +107,7 @@ void lc::Lablib::ShowPreprints() { QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); showPreprintsProcess.setProcessEnvironment( env ); QString program{ settings->fileMngr }; - QStringList arguments{ QStringList{} << settings->lcInstDir + "/preprints" }; + QStringList arguments{ QStringList{} << settings->lcDataDir + "/preprints" }; showPreprintsProcess.startDetached( program, arguments ); // Output message via the debug messages tab diff --git a/src/Lib/receipts_handler.cpp b/src/Lib/receipts_handler.cpp index d702b6a..c7f0f1b 100755 --- a/src/Lib/receipts_handler.cpp +++ b/src/Lib/receipts_handler.cpp @@ -255,11 +255,11 @@ QVector *lc::ReceiptsHandler::GetParticipantsDataFromPaymentFile() { QString *lc::ReceiptsHandler::LoadLatexHeader() { // Prepare all facilities to read the latex header file - QFile latexHeaderFile( settings->lcInstDir + "/" + latexHeaderName + "_header.tex" ); + QFile latexHeaderFile( settings->lcDataDir + "/" + latexHeaderName + "_header.tex" ); if ( !latexHeaderFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) { QMessageBox messageBox{ QMessageBox::Critical, tr( "LaTeX header could not be loaded" ), tr( "The LaTeX header at '%1/%2_header.tex' could not be loaded. Receipts printing will not work." ) - .arg( settings->lcInstDir ).arg( latexHeaderName ), QMessageBox::Ok }; + .arg( settings->lcDataDir ).arg( latexHeaderName ), QMessageBox::Ok }; messageBox.exec(); return nullptr; } diff --git a/src/Lib/settings.cpp b/src/Lib/settings.cpp index f435f57..b56d04c 100755 --- a/src/Lib/settings.cpp +++ b/src/Lib/settings.cpp @@ -46,7 +46,7 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) : latexCmd{ ReadSettingsItem( "latex_command", "Receipts creation will not work.", argSettings, true ) }, - lcInstDir{ ReadSettingsItem( "labcontrol_installation_directory", + lcDataDir{ ReadSettingsItem( "labcontrol_data_directory", "Datapath not set. Labcontrol will missbehave with high propability.", argSettings, true ) }, localUserName{ GetLocalUserName() }, @@ -261,12 +261,12 @@ QMap< QString, lc::Client* > lc::Settings::CreateClIPsToClMap( const QVector< Cl QStringList lc::Settings::DetectInstalledLaTeXHeaders() const { QStringList tempLaTeXHeaders{ "None found" }; // Detect the installed LaTeX headers - if ( !lcInstDir.isEmpty() ) { - QDir laTeXDirectory{ lcInstDir, "*_header.tex", QDir::Name, + if ( !lcDataDir.isEmpty() ) { + QDir laTeXDirectory{ lcDataDir, "*_header.tex", QDir::Name, QDir::CaseSensitive | QDir::Files | QDir::Readable }; if ( !laTeXDirectory.exists() || laTeXDirectory.entryList().isEmpty() ) { qDebug() << "Receipts printing will not work. No LaTeX headers could be found in" - << lcInstDir; + << lcDataDir; } else { tempLaTeXHeaders = laTeXDirectory.entryList(); tempLaTeXHeaders.replaceInStrings( "_header.tex", "" ); @@ -378,3 +378,8 @@ QString lc::Settings::ReadSettingsItem( const QString &argVariableName, } return QString{}; } + +void lc::Settings::SetLocalzLeafSize( QString arg) { + localzLeafSize = arg; +} + diff --git a/src/Lib/settings.h b/src/Lib/settings.h index edc6023..1489a69 100755 --- a/src/Lib/settings.h +++ b/src/Lib/settings.h @@ -32,6 +32,8 @@ class Settings : public QObject { Q_OBJECT public: + void SetLocalzLeafSize( QString arg); + Settings() = delete; explicit Settings( const QSettings &argSettings, QObject *argParent = nullptr ); Settings( const Settings &argSettings ) = delete; @@ -53,9 +55,9 @@ public: const QString fileMngr; const QString killallCmd; const QString latexCmd; - const QString lcInstDir; + const QString lcDataDir; const QString localUserName; - const QString localzLeafSize; + QString localzLeafSize; const QString lprCmd; const QString netstatCmd; const QString netwBrdAddr; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9ac015d..cd049a1 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -63,7 +63,7 @@ lc::MainWindow::MainWindow( QWidget *argParent ) : this, &MainWindow::GetNewDataTargetPath ); if ( settings->dvipsCmd.isEmpty() || settings->latexCmd.isEmpty() - || settings->lcInstDir.isEmpty() || settings->lprCmd.isEmpty() + || settings->lcDataDir.isEmpty() || settings->lprCmd.isEmpty() || settings->postscriptViewer.isEmpty() || settings->ps2pdfCmd.isEmpty() || settings->rmCmd.isEmpty() || settings->vncViewer.isEmpty() ) { QMessageBox::information( this, tr( "Receipts printing will not work" ), @@ -118,11 +118,10 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { ui->PBKillzLeaf->setEnabled( false ); } // Disable all functions relying on the labcontrol installation directory if it is not available - if ( settings->lcInstDir.isEmpty() ) { + if ( settings->lcDataDir.isEmpty() ) { ui->CBClientNames->setEnabled( false ); ui->CBWebcamChooser->setEnabled( false ); ui->GBClientActions->setEnabled( false ); - //ui->GBzTree->setEnabled( false ); ui->LEFilePath->setEnabled( false ); ui->LFakeName->setEnabled( false ); ui->LWebcamChooser->setEnabled( false ); @@ -158,7 +157,6 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { ui->LFakeName->setEnabled( false ); ui->PBBeamFile->setEnabled( false ); ui->PBChooseFile->setEnabled( false ); - //ui->PBDeactivateScreensaver->setEnabled( false ); ui->PBKillzLeaf->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); ui->PBShutdown->setEnabled( false ); @@ -212,7 +210,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { ui->CBClientNames->setEnabled( false ); ui->LFakeName->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); - //ui->PBStartSession->setEnabled( false ); + ui->PBStartSession->setEnabled( false ); ui->PBStartLocalzLeaf->setEnabled( false ); ui->PBStartzLeaf->setEnabled( false ); } @@ -225,7 +223,8 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { // Disable 'PBViewDesktop' if 'vnc_viewer' was not set if ( settings->vncViewer.isEmpty() ) { - //ui->PBViewDesktop->setEnabled( false ); + ui->PBViewDesktopViewOnly->setEnabled( false ); + ui->PBViewDesktopFullControl->setEnabled( false ); } // Disable 'PBBoot' if 'wakeonlan_command' was not set @@ -253,14 +252,14 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { ui->CBClientNames->setEnabled( false ); ui->LFakeName->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); - //ui->PBStartSession->setEnabled( false ); + ui->PBStartSession->setEnabled( false ); ui->PBStartLocalzLeaf->setEnabled( false ); ui->PBStartzLeaf->setEnabled( false ); } } void lc::MainWindow::LoadIconPixmaps() { - if ( settings->lcInstDir.isEmpty() ) { + if ( settings->lcDataDir.isEmpty() ) { return; } @@ -273,45 +272,14 @@ void lc::MainWindow::LoadIconPixmaps() { << "zLeaf.png" }; for ( int i = 0; i < ( int )icons_t::ICON_QUANTITY; i++ ) { - if ( !icons[ i ].load( settings->lcInstDir + "/icons/" + iconNames[ i ] ) ) { + if ( !icons[ i ].load( settings->lcDataDir + "/icons/" + iconNames[ i ] ) ) { QMessageBox::information( this, tr( "Could not load icon '%1'" ).arg( iconNames[ i ] ), tr( "The icon in '%1/icons/%2' could not be loaded." ) - .arg( settings->lcInstDir ).arg( iconNames[ i ] ), QMessageBox::Ok ); + .arg( settings->lcDataDir ).arg( iconNames[ i ] ), QMessageBox::Ok ); } } } -void lc::MainWindow::on_CBWebcamChooser_activated( int argIndex ) { - if ( argIndex != 0 ) { - QString program{ settings->webcamDisplayCmd }; - QStringList arguments; - arguments << ui->CBWebcamChooser->currentText(); - - QProcess showWebcamProcess; - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - showWebcamProcess.setProcessEnvironment( env ); - showWebcamProcess.startDetached( program, arguments ); - } -} - -void lc::MainWindow::on_PBBeamFile_clicked() { - QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); - const QString fileToBeam{ ui->LEFilePath->text() }; - if(fileToBeam == ""){ - QMessageBox::information(this, "Upload failed", "You didn't choose any folder to upload."); - } else { - //Iterate over the selected clients to upload the file - 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 * >() ); - client->BeamFile( fileToBeam, &settings->pkeyPathUser, &settings->userNameOnClients ); - } - } - // Inform the user about the path - QMessageBox::information(this, "Upload completed", "The folder was copied to all selected clients.\nThe path on every client is /home/ewfuser" + fileToBeam.mid(fileToBeam.lastIndexOf('/')) +".\nDon't forget to adjust the media path within zTree!"); - } -} - void lc::MainWindow::on_PBBoot_clicked() { QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) { @@ -340,6 +308,24 @@ void lc::MainWindow::on_PBChooseFile_clicked() { delete file_dialog; } +void lc::MainWindow::on_PBBeamFile_clicked() { + QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); + const QString fileToBeam{ ui->LEFilePath->text() }; + if(fileToBeam == ""){ + QMessageBox::information(this, "Upload failed", "You didn't choose any folder to upload."); + } else { + //Iterate over the selected clients to upload the file + 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 * >() ); + client->BeamFile( fileToBeam, &settings->pkeyPathUser, &settings->userNameOnClients ); + } + } + // Inform the user about the path + QMessageBox::information(this, "Upload completed", "The folder was copied to all selected clients.\nThe path on every client is /home/ewfuser" + fileToBeam.mid(fileToBeam.lastIndexOf('/')) +".\nDon't forget to adjust the media path within zTree!"); + } +} + void lc::MainWindow::on_PBExecute_clicked() { // This will be set to false, if the command shall be executed only on the chosen clients (that's if not all clients are up) bool executeOnEveryClient = true; @@ -429,23 +415,6 @@ void lc::MainWindow::on_PBOpenFilesystem_clicked() { delete userToBeUsed; } -// Issue open terminal call -void lc::MainWindow::on_PBOpenTerminal_clicked() { - QString pkeyPathUser; - if ( ui->RBUseUserRoot->isChecked() ) { - pkeyPathUser = settings->pkeyPathRoot; - } else { - pkeyPathUser = settings->pkeyPathUser; - } - QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); - for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { - if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { - Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); - client->OpenTerminal( QString{}, ui->RBUseUserRoot->isChecked() ); - } - } -} - void lc::MainWindow::on_PBPrintPaymentFileManually_clicked() { ManualPrintingSetup *manPrint = new ManualPrintingSetup{ this }; manPrint->setWindowFlags( Qt::Window ); @@ -521,16 +490,6 @@ void lc::MainWindow::on_PBStartLocalzLeaf_clicked() { localzLeafStarter, SLOT( deleteLater() ) ); } -void lc::MainWindow::on_PBStartzLeaf_clicked() { - QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); - for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { - if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { - Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); - client->StartZLeaf( nullptr ); - } - } -} - void lc::MainWindow::on_RBUseLocalUser_toggled(bool checked) { if ( checked ) { qDebug() << "'RBUseLocalUser' got toggled."; @@ -624,11 +583,12 @@ void lc::MainWindow::SetupWidgets() { //DisableDisfunctionalWidgets(); // Set the info text in LInfo on the TInfo tab - ui->LInfo->setText( "This is Labcontrol version 2.1.4\n\n\nDevelopers\n\n" + ui->LInfo->setText( "This is Labcontrol version 2.1.4\n\n\n\n\n\n" + "Developers\n\n" "0day-2016 Henning Prömpers\n" "2014-2016 Markus Prasser\n" "2016 - now WiwilabHiwiOrgaization\n\n\n" - "\n\nCopyright\n\n\n" + "Copyright\n\n" "Labcontrol is free software: you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" "the Free Software Foundation, either version 3 of the License, or\n" @@ -639,27 +599,10 @@ void lc::MainWindow::SetupWidgets() { "See the GNU General Public License for more details.\n\n" "You should have received a copy of the GNU General Public License\n" "along with Labcontrol. If not, see .\n\n\n" ); -} -void lc::MainWindow::StartLocalzLeaf( QString argzLeafName, QString argzLeafVersion, - int argzTreePort ) { - if ( settings->tasksetCmd.isEmpty() || settings->wineCmd.isEmpty() - || settings->zTreeInstDir.isEmpty() ) { - return; - } + // Fill settings tab + ui->LESettingsServerLocalzLeafSize->setText ( settings->localzLeafSize ); - QProcess startProc; - startProc.setProcessEnvironment( QProcessEnvironment::systemEnvironment() ); - QStringList arguments; - arguments << "0x00000001" << settings->wineCmd - << QString{ settings->zTreeInstDir + "/zTree_" + argzLeafVersion + "/zleaf.exe" } - << "/server" << "127.0.0.1" << "/channel" - << QString::number( argzTreePort - 7000 ) << "/name" << argzLeafName; - if ( !settings->localzLeafSize.isEmpty() ) { - arguments << "/size" << QString{ settings->localzLeafSize }; - } - - startProc.startDetached( settings->tasksetCmd, arguments ); } void lc::MainWindow::StartReceiptsHandler( QString argzTreeDataTargetPath, @@ -706,6 +649,21 @@ void lc::MainWindow::UpdateClientsTableView() { } } +/* Experiment tab functions */ + +void lc::MainWindow::on_CBWebcamChooser_activated( int argIndex ) { + if ( argIndex != 0 ) { + QString program{ settings->webcamDisplayCmd }; + QStringList arguments; + arguments << ui->CBWebcamChooser->currentText(); + + QProcess showWebcamProcess; + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + showWebcamProcess.setProcessEnvironment( env ); + showWebcamProcess.startDetached( program, arguments ); + } +} + void lc::MainWindow::on_PBstartBrowser_clicked() { QString argURL = ui->LEURL->text(); @@ -737,7 +695,7 @@ void lc::MainWindow::on_PBstopBrowser_clicked() } } -// View only VNC Button +// View only VNC button void lc::MainWindow::on_PBViewDesktopViewOnly_clicked() { QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); @@ -749,6 +707,7 @@ void lc::MainWindow::on_PBViewDesktopViewOnly_clicked() } } +// Full control VNC button void lc::MainWindow::on_PBViewDesktopFullControl_clicked() { QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); @@ -761,7 +720,38 @@ void lc::MainWindow::on_PBViewDesktopFullControl_clicked() } -/* Session action functions */ +/* Session tab functions */ + +void lc::MainWindow::on_PBStartzLeaf_clicked() { + QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); + for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { + if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { + Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); + client->StartZLeaf( nullptr ); + } + } +} + +void lc::MainWindow::StartLocalzLeaf( QString argzLeafName, QString argzLeafVersion, + int argzTreePort ) { + if ( settings->tasksetCmd.isEmpty() || settings->wineCmd.isEmpty() + || settings->zTreeInstDir.isEmpty() ) { + return; + } + + QProcess startProc; + startProc.setProcessEnvironment( QProcessEnvironment::systemEnvironment() ); + QStringList arguments; + arguments << "0x00000001" << settings->wineCmd + << QString{ settings->zTreeInstDir + "/zTree_" + argzLeafVersion + "/zleaf.exe" } + << "/server" << "127.0.0.1" << "/channel" + << QString::number( argzTreePort - 7000 ) << "/name" << argzLeafName; + if ( !settings->localzLeafSize.isEmpty() ) { + arguments << "/size" << QString{ settings->localzLeafSize }; + } + + startProc.startDetached( settings->tasksetCmd, arguments ); +} void lc::MainWindow::on_PBStopZtree_clicked() { @@ -803,7 +793,7 @@ void lc::MainWindow::on_CBDataTargetPath_activated( int argIndex ) ui->CBDataTargetPath->setStyleSheet( "" ); } -// Open a folder coose dialog if first position in the combo box is clicked +// Open a folder chooser dialog for zTree data path void lc::MainWindow::GetNewDataTargetPath() { QFileDialog fileDialog{ this }; fileDialog.setFileMode( QFileDialog::Directory ); @@ -900,3 +890,30 @@ void lc::MainWindow::on_PBKillzLeaf_clicked() } } } + +/* Admin tab functions */ + +// Issue open terminal call +void lc::MainWindow::on_PBOpenTerminal_clicked() { + QString pkeyPathUser; + if ( ui->RBUseUserRoot->isChecked() ) { + pkeyPathUser = settings->pkeyPathRoot; + } else { + pkeyPathUser = settings->pkeyPathUser; + } + QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); + for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { + if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { + Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); + client->OpenTerminal( QString{}, ui->RBUseUserRoot->isChecked() ); + } + } +} + +/* Settings tab functions */ + +// Change settings temporarly call +void lc::MainWindow::on_PBChangeSettingsTemp_clicked() +{ + settings->SetLocalzLeafSize( ui->LESettingsServerLocalzLeafSize->text() ); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 154afef..3a8d6d6 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -129,6 +129,9 @@ private slots: void on_CBReceiptsHeader_activated(int argIndex); void on_ChBPrintanonymousreceipts_clicked(); void on_PBKillzLeaf_clicked(); + + /* Settings actions */ + void on_PBChangeSettingsTemp_clicked(); }; } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 532324e..46eafc9 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -64,7 +64,7 @@ - 3 + 0 true @@ -207,7 +207,7 @@ - + Switch the selected clients on or off @@ -248,7 +248,7 @@ - + Remote control the selected clients @@ -950,7 +950,7 @@ Change settings temporarly - + 10 @@ -965,7 +965,7 @@ true - + 0 @@ -980,24 +980,44 @@ 0 0 671 - 611 + 481 - + - + Server settings - - + + Client settings + + + + local_zleaf_size + + + + + + + + + + server_ip + + + + + + diff --git a/src/manualprintingsetup.cpp b/src/manualprintingsetup.cpp index e1aed9a..2eda978 100755 --- a/src/manualprintingsetup.cpp +++ b/src/manualprintingsetup.cpp @@ -34,7 +34,7 @@ lc::ManualPrintingSetup::ManualPrintingSetup( QWidget *argParent ) : ui->setupUi( this ); if ( settings->dvipsCmd.isEmpty() || settings->latexCmd.isEmpty() - || settings->lcInstDir.isEmpty() || settings->lprCmd.isEmpty() + || settings->lcDataDir.isEmpty() || settings->lprCmd.isEmpty() || settings->postscriptViewer.isEmpty() || settings->ps2pdfCmd.isEmpty() || settings->rmCmd.isEmpty() || settings->vncViewer.isEmpty() ) { ui->VLManualPrintingSetup->setEnabled( false ); From 0bcbdab93950fe51e5f88e118256f734be96cdb4 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Sun, 24 Sep 2017 15:57:48 +0200 Subject: [PATCH 15/22] added VNC full control functionality --- src/Lib/client.cpp | 2 +- src/mainwindow.ui | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Lib/client.cpp b/src/Lib/client.cpp index 5d9bd23..a3629ad 100755 --- a/src/Lib/client.cpp +++ b/src/Lib/client.cpp @@ -214,7 +214,7 @@ void lc::Client::ShowDesktopViewOnly() { void lc::Client::ShowDesktopFullControl() { QStringList arguments; - arguments << ip; + arguments << ip + ":5901"; QProcess showDesktopProcess; QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 46eafc9..733e1af 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -64,7 +64,7 @@ - 0 + 1 true From 4bbf149fe6d3853af14816ddba9fc9f93959860b Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Mon, 25 Sep 2017 07:32:22 +0200 Subject: [PATCH 16/22] deleted settings tab and added cmd ui to sessions tab --- src/Lib/settings.cpp | 4 + src/Lib/settings.h | 9 +- src/localzleafstarter.cpp | 9 ++ src/localzleafstarter.ui | 28 +++- src/mainwindow.cpp | 300 +++++++++++++++++--------------------- src/mainwindow.h | 3 - src/mainwindow.ui | 120 ++++----------- 7 files changed, 196 insertions(+), 277 deletions(-) diff --git a/src/Lib/settings.cpp b/src/Lib/settings.cpp index b56d04c..11e6d14 100755 --- a/src/Lib/settings.cpp +++ b/src/Lib/settings.cpp @@ -383,3 +383,7 @@ void lc::Settings::SetLocalzLeafSize( QString arg) { localzLeafSize = arg; } +void lc::Settings::SetChosenZTreePort( const int argPort ){ + chosenzTreePort = argPort; +} + diff --git a/src/Lib/settings.h b/src/Lib/settings.h index 1489a69..42398b4 100755 --- a/src/Lib/settings.h +++ b/src/Lib/settings.h @@ -32,8 +32,6 @@ class Settings : public QObject { Q_OBJECT public: - void SetLocalzLeafSize( QString arg); - Settings() = delete; explicit Settings( const QSettings &argSettings, QObject *argParent = nullptr ); Settings( const Settings &argSettings ) = delete; @@ -58,6 +56,8 @@ public: const QString lcDataDir; const QString localUserName; QString localzLeafSize; + void SetLocalzLeafSize( QString arg); + QString GetLocalzLeafSize() const { return localzLeafSize; } const QString lprCmd; const QString netstatCmd; const QString netwBrdAddr; @@ -120,11 +120,6 @@ inline QString lc::Settings::GetLocalzLeafName() const { return localzLeafName; } -inline void lc::Settings::SetChosenZTreePort( const int argPort ) { - chosenzTreePort = argPort; - qDebug() << "'chosenZTreePort' set to:" << chosenzTreePort; -} - inline void lc::Settings::SetLocalzLeafName( const QString &argLocalzLeafName ) { localzLeafName = argLocalzLeafName; } diff --git a/src/localzleafstarter.cpp b/src/localzleafstarter.cpp index 244caa7..2c25413 100755 --- a/src/localzleafstarter.cpp +++ b/src/localzleafstarter.cpp @@ -33,10 +33,15 @@ lc::LocalzLeafStarter::LocalzLeafStarter( QWidget *argParent ) : { ui->setupUi( this ); + //Choose initial port from settings if ( settings->GetChosenZTreePort() ) { ui->SBzLeafPort->setValue( settings->GetChosenZTreePort() ); } + //Choose initial z-Leave size from settings + ui->LELocalzLeafSize->setText( settings->GetLocalzLeafSize() ); + + ui->CBzLeafVersion->addItem( tr( "Please choose a version" ) ); if ( !settings->installedZTreeVersions.isEmpty() ) { ui->CBzLeafVersion->addItems( settings->installedZTreeVersions ); @@ -55,6 +60,10 @@ void lc::LocalzLeafStarter::on_PBStartLocalzLeaf_clicked() { return; } + //Set chosen z-Leaf size + settings->SetLocalzLeafSize( ui->LELocalzLeafSize->text() ); + + //Emit start local z-Leaf request to main window emit LocalzLeafRequested( ui->LEzLeafName->text(), ui->CBzLeafVersion->currentText(), ui->SBzLeafPort->value() ); } diff --git a/src/localzleafstarter.ui b/src/localzleafstarter.ui index ecc4410..b92dea5 100755 --- a/src/localzleafstarter.ui +++ b/src/localzleafstarter.ui @@ -6,7 +6,7 @@ 0 0 - 352 + 371 352 @@ -20,7 +20,7 @@ This sets the name with which this local z-Leaf will connect to z-Tree. - Set the name of the to be started z-Leaf: + Set the name of the to be started z-Leaf @@ -43,7 +43,7 @@ Choose of which version the started z-Leaf shall be. - Choose the version of the to be started z-Leaf: + Choose the version of the to be started z-Leaf @@ -66,12 +66,15 @@ Set the port on which the z-Tree which shall be connected to listens. - Choose the port the to be started z-Leaf shall listen on: + Choose the port the to be started z-Leaf shall listen on + + ArrowCursor + Set the port on which the z-Tree which shall be connected to listens. @@ -89,6 +92,23 @@ + + + + Choose the size the local z-Leaf shall have + + + + + + + + + + Qt::Horizontal + + + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cd049a1..e720c69 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -280,105 +280,6 @@ void lc::MainWindow::LoadIconPixmaps() { } } -void lc::MainWindow::on_PBBoot_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 * >() ); - client->Boot(); - } - } -} - -void lc::MainWindow::on_PBChooseFile_clicked() { - QFileDialog *file_dialog = new QFileDialog{ this, tr( "Choose a file to beam" ), QDir::homePath() }; - file_dialog->setFileMode( QFileDialog::Directory ); - file_dialog->setOption( QFileDialog::DontUseNativeDialog, true ); - file_dialog->setOption( QFileDialog::ReadOnly, true ); - file_dialog->setOption( QFileDialog::ShowDirsOnly, true ); - - if(file_dialog->exec()) { - ui->LEFilePath->setText(file_dialog->selectedFiles().at(0)); - qDebug() << "Chose file" << ui->LEFilePath->text() << "for beaming."; - } - else { - ui->LEFilePath->setText( tr( "File choosing cancelled" ) ); - qDebug() << "File choosing cancelled"; - } - delete file_dialog; -} - -void lc::MainWindow::on_PBBeamFile_clicked() { - QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); - const QString fileToBeam{ ui->LEFilePath->text() }; - if(fileToBeam == ""){ - QMessageBox::information(this, "Upload failed", "You didn't choose any folder to upload."); - } else { - //Iterate over the selected clients to upload the file - 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 * >() ); - client->BeamFile( fileToBeam, &settings->pkeyPathUser, &settings->userNameOnClients ); - } - } - // Inform the user about the path - QMessageBox::information(this, "Upload completed", "The folder was copied to all selected clients.\nThe path on every client is /home/ewfuser" + fileToBeam.mid(fileToBeam.lastIndexOf('/')) +".\nDon't forget to adjust the media path within zTree!"); - } -} - -void lc::MainWindow::on_PBExecute_clicked() { - // This will be set to false, if the command shall be executed only on the chosen clients (that's if not all clients are up) - bool executeOnEveryClient = true; - - // Cancel, if not all clients are up and running - for ( auto s: settings->GetClients() ) { - if ( !( s->name.contains( "backup", Qt::CaseInsensitive ) ) ) { - if ( s->GetClientState() < state_t::RESPONDING ) { - QMessageBox messageBox{ QMessageBox::Warning, tr( "Not all clients are running" ), - tr( "Not all clients are running. The command could not be executed on every client and should therefore be canceled to keep the clients consistent.\n\nAre you sure you want to continue only with the currently chosen clients?" ), QMessageBox::No | QMessageBox::Yes, this }; - messageBox.setDefaultButton( QMessageBox::No ); - messageBox.exec(); - executeOnEveryClient = false; - if ( messageBox.clickedButton() == messageBox.button( QMessageBox::No ) ) { - return; - } else { - break; - } - } - } - } - - // Get the command to be executed ... - QString command = ui->CBCommandToExecute->currentText(); - - // Set the correct public key - QString pkeyPathUser; - if ( ui->RBUseUserRoot->isChecked() ) { - pkeyPathUser = settings->pkeyPathRoot; - } else { - pkeyPathUser = settings->pkeyPathUser; - } - - // and execute it - if ( executeOnEveryClient ) { - qDebug() << "Executing command" << command << "on every client."; - for ( auto s: settings->GetClients() ) { - if ( !( s->name.contains( "backup", Qt::CaseInsensitive ) ) ) { - s->OpenTerminal( command, ui->RBUseUserRoot->isChecked() ); - } - } - } else { - qDebug() << "Executing command" << command << "only on chosen clients."; - QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); - for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { - if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { - Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); - client->OpenTerminal( command, ui->RBUseUserRoot->isChecked() ); - } - } - } -} - void lc::MainWindow::on_PBKillLocalzLeaf_clicked() { QString program{ settings->killallCmd }; QStringList arguments; @@ -396,25 +297,6 @@ void lc::MainWindow::on_PBKillLocalzLeaf_clicked() { qDebug() << program << arguments; } -void lc::MainWindow::on_PBOpenFilesystem_clicked() { - // Determine the correct user to be used - QString * userToBeUsed = nullptr; - if ( ui->RBUseUserRoot->isChecked() ) { - userToBeUsed = new QString{ "root" }; - } else { - userToBeUsed = new QString{ settings->userNameOnClients }; - } - - QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); - for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { - if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { - Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); - client->OpenFilesystem( userToBeUsed ); - } - } - delete userToBeUsed; -} - void lc::MainWindow::on_PBPrintPaymentFileManually_clicked() { ManualPrintingSetup *manPrint = new ManualPrintingSetup{ this }; manPrint->setWindowFlags( Qt::Window ); @@ -450,46 +332,6 @@ void lc::MainWindow::on_PBRunzLeaf_clicked() { } } -void lc::MainWindow::on_PBShowORSEE_clicked() { - lablib->ShowOrsee(); -} - -void lc::MainWindow::on_PBShowPreprints_clicked() { - lablib->ShowPreprints(); -} - -void lc::MainWindow::on_PBShutdown_clicked() { - // 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"; - } -} - -void lc::MainWindow::on_PBStartLocalzLeaf_clicked() { - LocalzLeafStarter *localzLeafStarter = new LocalzLeafStarter{ this }; - localzLeafStarter->setWindowFlags( Qt::Window ); - localzLeafStarter->show(); - connect( localzLeafStarter, &LocalzLeafStarter::LocalzLeafRequested, - this, &MainWindow::StartLocalzLeaf ); - connect( localzLeafStarter, SIGNAL( LocalzLeafRequested( QString, QString, int ) ), - localzLeafStarter, SLOT( deleteLater() ) ); -} - void lc::MainWindow::on_RBUseLocalUser_toggled(bool checked) { if ( checked ) { qDebug() << "'RBUseLocalUser' got toggled."; @@ -599,10 +441,6 @@ void lc::MainWindow::SetupWidgets() { "See the GNU General Public License for more details.\n\n" "You should have received a copy of the GNU General Public License\n" "along with Labcontrol. If not, see .\n\n\n" ); - - // Fill settings tab - ui->LESettingsServerLocalzLeafSize->setText ( settings->localzLeafSize ); - } void lc::MainWindow::StartReceiptsHandler( QString argzTreeDataTargetPath, @@ -651,6 +489,82 @@ void lc::MainWindow::UpdateClientsTableView() { /* Experiment tab functions */ +void lc::MainWindow::on_PBBoot_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 * >() ); + client->Boot(); + } + } +} + +void lc::MainWindow::on_PBChooseFile_clicked() { + QFileDialog *file_dialog = new QFileDialog{ this, tr( "Choose a file to beam" ), QDir::homePath() }; + file_dialog->setFileMode( QFileDialog::Directory ); + file_dialog->setOption( QFileDialog::DontUseNativeDialog, true ); + file_dialog->setOption( QFileDialog::ReadOnly, true ); + file_dialog->setOption( QFileDialog::ShowDirsOnly, true ); + + if(file_dialog->exec()) { + ui->LEFilePath->setText(file_dialog->selectedFiles().at(0)); + qDebug() << "Chose file" << ui->LEFilePath->text() << "for beaming."; + } + else { + ui->LEFilePath->setText( tr( "File choosing cancelled" ) ); + qDebug() << "File choosing cancelled"; + } + delete file_dialog; +} + +void lc::MainWindow::on_PBBeamFile_clicked() { + QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); + const QString fileToBeam{ ui->LEFilePath->text() }; + if(fileToBeam == ""){ + QMessageBox::information(this, "Upload failed", "You didn't choose any folder to upload."); + } else { + //Iterate over the selected clients to upload the file + 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 * >() ); + client->BeamFile( fileToBeam, &settings->pkeyPathUser, &settings->userNameOnClients ); + } + } + // Inform the user about the path + QMessageBox::information(this, "Upload completed", "The folder was copied to all selected clients.\nThe path on every client is /home/ewfuser/media4ztree" + fileToBeam.mid(fileToBeam.lastIndexOf('/')) +".\nDon't forget to adjust the media path within zTree!"); + } +} + +void lc::MainWindow::on_PBShowORSEE_clicked() { + lablib->ShowOrsee(); +} + +void lc::MainWindow::on_PBShowPreprints_clicked() { + lablib->ShowPreprints(); +} + +void lc::MainWindow::on_PBShutdown_clicked() { + // 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"; + } +} + void lc::MainWindow::on_CBWebcamChooser_activated( int argIndex ) { if ( argIndex != 0 ) { QString program{ settings->webcamDisplayCmd }; @@ -732,6 +646,16 @@ void lc::MainWindow::on_PBStartzLeaf_clicked() { } } +void lc::MainWindow::on_PBStartLocalzLeaf_clicked() { + LocalzLeafStarter *localzLeafStarter = new LocalzLeafStarter{ this }; + localzLeafStarter->setWindowFlags( Qt::Window ); + localzLeafStarter->show(); + connect( localzLeafStarter, &LocalzLeafStarter::LocalzLeafRequested, + this, &MainWindow::StartLocalzLeaf ); + connect( localzLeafStarter, SIGNAL( LocalzLeafRequested( QString, QString, int ) ), + localzLeafStarter, SLOT( deleteLater() ) ); +} + void lc::MainWindow::StartLocalzLeaf( QString argzLeafName, QString argzLeafVersion, int argzTreePort ) { if ( settings->tasksetCmd.isEmpty() || settings->wineCmd.isEmpty() @@ -877,6 +801,7 @@ void lc::MainWindow::on_PBStartSession_clicked() { //Set port to +1 int newPort = ui->SBPort->text().toInt() + 1; + settings->SetChosenZTreePort(newPort); ui->SBPort->setValue(newPort); } @@ -893,6 +818,49 @@ void lc::MainWindow::on_PBKillzLeaf_clicked() /* Admin tab functions */ +void lc::MainWindow::on_PBOpenFilesystem_clicked() { + // Determine the correct user to be used + QString * userToBeUsed = nullptr; + if ( ui->RBUseUserRoot->isChecked() ) { + userToBeUsed = new QString{ "root" }; + } else { + userToBeUsed = new QString{ settings->userNameOnClients }; + } + + QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); + for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { + if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { + Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); + client->OpenFilesystem( userToBeUsed ); + } + } + delete userToBeUsed; +} + +void lc::MainWindow::on_PBExecute_clicked() { + + // Get the command to be executed ... + QString command = ui->CBCommandToExecute->currentText(); + + // Set the correct public key + QString pkeyPathUser; + if ( ui->RBUseUserRoot->isChecked() ) { + pkeyPathUser = settings->pkeyPathRoot; + } else { + pkeyPathUser = settings->pkeyPathUser; + } + + qDebug() << "Executing command" << command << " on chosen clients."; + QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); + for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { + if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { + Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); + client->OpenTerminal( command, ui->RBUseUserRoot->isChecked() ); + } + } + +} + // Issue open terminal call void lc::MainWindow::on_PBOpenTerminal_clicked() { QString pkeyPathUser; @@ -909,11 +877,3 @@ void lc::MainWindow::on_PBOpenTerminal_clicked() { } } } - -/* Settings tab functions */ - -// Change settings temporarly call -void lc::MainWindow::on_PBChangeSettingsTemp_clicked() -{ - settings->SetLocalzLeafSize( ui->LESettingsServerLocalzLeafSize->text() ); -} diff --git a/src/mainwindow.h b/src/mainwindow.h index 3a8d6d6..154afef 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -129,9 +129,6 @@ private slots: void on_CBReceiptsHeader_activated(int argIndex); void on_ChBPrintanonymousreceipts_clicked(); void on_PBKillzLeaf_clicked(); - - /* Settings actions */ - void on_PBChangeSettingsTemp_clicked(); }; } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 733e1af..51c126b 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -64,7 +64,7 @@ - 1 + 0 true @@ -487,7 +487,7 @@ 10 88 691 - 461 + 468 @@ -707,6 +707,23 @@ + + + + command line to be executed + + + + + + + + 0 + 0 + + + + @@ -778,6 +795,13 @@ + + + + Local zLeaf + + + @@ -911,7 +935,7 @@ - Execute command on every client + Execute command on selected clients @@ -933,96 +957,6 @@ - - - Settings - - - - - 240 - 520 - 201 - 23 - - - - Change settings temporarly - - - - - - 10 - 10 - 691 - 501 - - - - Qt::ScrollBarAlwaysOn - - - true - - - - - 0 - 0 - 675 - 499 - - - - - - 0 - 0 - 671 - 481 - - - - - - - Server settings - - - - - - - Client settings - - - - - - - local_zleaf_size - - - - - - - - - - server_ip - - - - - - - - - - - Qt::RightToLeft From 360f71210b2de1bfcb1a28fa972aca4d4820a427 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Sun, 1 Oct 2017 21:43:31 +0200 Subject: [PATCH 17/22] ui stylesheet changes --- src/localzleafstarter.ui | 6 +++--- src/mainwindow.ui | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/localzleafstarter.ui b/src/localzleafstarter.ui index b92dea5..4fae56f 100755 --- a/src/localzleafstarter.ui +++ b/src/localzleafstarter.ui @@ -30,7 +30,7 @@ This sets the name with which this local z-Leaf will connect to z-Tree. - background: cyan; + local @@ -53,7 +53,7 @@ Choose of which version the started z-Leaf shall be. - background: cyan; + 32 @@ -79,7 +79,7 @@ Set the port on which the z-Tree which shall be connected to listens. - background: cyan; + 7000 diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 51c126b..8278855 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -666,7 +666,7 @@ - Start z-Leaf on clients with the session + Start z-Leaf on clients with default parameters true From 70350155c1f6a6eaeb0c53cac2acc1f905d768c5 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Tue, 3 Oct 2017 23:35:02 +0200 Subject: [PATCH 18/22] added cmd lineedit and changed some ui minor elements --- data/Labcontrol.conf | 4 ++-- src/Lib/client.cpp | 34 +++++++++++++-------------------- src/Lib/client.h | 11 +++++++---- src/Lib/lablib.cpp | 17 +++++++++++++++++ src/Lib/lablib.h | 8 ++++++++ src/Lib/settings.cpp | 2 ++ src/Lib/settings.h | 1 + src/mainwindow.cpp | 45 ++++++++++++++++++++++++++------------------ src/mainwindow.ui | 32 +++++++++++++++---------------- 9 files changed, 93 insertions(+), 61 deletions(-) diff --git a/data/Labcontrol.conf b/data/Labcontrol.conf index ac4c646..d04b702 100755 --- a/data/Labcontrol.conf +++ b/data/Labcontrol.conf @@ -23,9 +23,9 @@ default_receipt_index=0 # The URL address of your lab's ORSEE orsee_url=http://yourORSEEserver.tld # URLs to available webcams -webcams=http://user:pass@webcam_left|http://user:pass@webcam_right +webcams=http://user:pass@webcam_right|http://user:pass@webcam_left # Display names for the webcams -webcam_names="Webcam right|Webcam left" +webcams_names="Webcam right|Webcam left" ### Client settings # The client settings are represented as an array. So the info of the first client stands in the first field in every section and the same is valid for the other clients with other indices each. diff --git a/src/Lib/client.cpp b/src/Lib/client.cpp index a3629ad..95045b3 100755 --- a/src/Lib/client.cpp +++ b/src/Lib/client.cpp @@ -23,8 +23,10 @@ #include "client.h" #include "settings.h" +#include "lablib.h" extern std::unique_ptr< lc::Settings > settings; +extern std::unique_ptr< lc::Lablib > lablib; lc::Client::Client( const QString &argIP, const QString &argMAC, const QString &argName, unsigned short int argXPosition, unsigned short int argYPosition, @@ -250,7 +252,7 @@ void lc::Client::Shutdown() { GotStatusChanged( state_t::SHUTTING_DOWN ); } -void lc::Client::StartZLeaf( const QString * argFakeName ) { +void lc::Client::StartZLeaf( const QString * argFakeName, QString cmd ) { if ( state < state_t::RESPONDING || zLeafVersion.isEmpty() || GetSessionPort() < 7000 ) { return; } @@ -269,32 +271,22 @@ void lc::Client::StartZLeaf( const QString * argFakeName ) { if ( ( messageBoxRunningZLeafFound.get() != nullptr && messageBoxRunningZLeafFound->clickedButton() - == messageBoxRunningZLeafFound->button( QMessageBox::Yes ) ) + == messageBoxRunningZLeafFound->button( QMessageBox::Yes ) ) || state != state_t::ZLEAF_RUNNING ) { QStringList arguments; if ( argFakeName == nullptr && GetSessionPort() == 7000 ) { arguments << "-i" << settings->pkeyPathUser << QString{ settings->userNameOnClients + "@" + ip } - << "DISPLAY=:0.0" << settings->tasksetCmd << "0x00000001" << settings->wineCmd - << QString{ settings->zTreeInstDir + "/zTree_" + GetzLeafVersion() + "/zleaf.exe" } - << "/server" << settings->serverIP; + << cmd; + } else if ( argFakeName == nullptr ) { + arguments << "-i" << settings->pkeyPathUser + << QString{ settings->userNameOnClients + "@" + ip } + << cmd; } else { - if ( argFakeName == nullptr ) { - arguments << "-i" << settings->pkeyPathUser - << QString{ settings->userNameOnClients + "@" + ip } - << "DISPLAY=:0.0" << settings->tasksetCmd << "0x00000001" << settings->wineCmd - << QString{ settings->zTreeInstDir + "/zTree_" + GetzLeafVersion() + "/zleaf.exe" } - << "/server" << settings->serverIP << "/channel" - << QString::number( GetSessionPort() - 7000 ); - } else { - arguments << "-i" << settings->pkeyPathUser - << QString{ settings->userNameOnClients + "@" + ip } - << "DISPLAY=:0.0" << settings->tasksetCmd << "0x00000001" << settings->wineCmd - << QString{ settings->zTreeInstDir + "/zTree_" + GetzLeafVersion() + "/zleaf.exe" } - << "/server" << settings->serverIP << "/channel" - << QString::number( GetSessionPort() - 7000 ) - << "/name" << *argFakeName; - } + arguments << "-i" << settings->pkeyPathUser + << QString{ settings->userNameOnClients + "@" + ip } + << cmd + << "/name" << *argFakeName; } // Start the process diff --git a/src/Lib/client.h b/src/Lib/client.h index 6cf1893..2b75897 100755 --- a/src/Lib/client.h +++ b/src/Lib/client.h @@ -96,7 +96,7 @@ public: void OpenFilesystem( const QString * const argUserToBeUsed ); /*! * \brief Opens a terminal for the client - * \param argCommand A command which shall be executed in the terminal window (Pass an empty QString if not wanted) + * \param argCommand A command which shall be executed in the terminal window (Pass an empty QString if not wanted) * \param argOpenAsRoot Run the terminal session as root (true) or as normal user (false) */ void OpenTerminal( const QString &argCommand, const bool &argOpenAsRoot ); @@ -109,16 +109,19 @@ public: * \brief Shuts down the client */ void Shutdown(); - //! Starts a zLeaf instance on the client + /*! - @param argFakeName The name the zLeaf instance shall have (if not the default, which is the hostname of the client) + * \brief Starts a zLeaf instance on the client + * @param argFakeName The name the zLeaf instance shall have (if not the default, which is the hostname of the client) */ - void StartZLeaf(const QString *argFakeName = nullptr ); + void StartZLeaf(const QString *argFakeName = nullptr, QString cmd = "" ); + /*! * \brief Opens a browser window on the client * @param argURL URL to open in clients browser */ void StartClientBrowser( const QString *argURL = nullptr, const bool *argFullscreen = nullptr ); + /*! * \brief Closes all browser instances */ diff --git a/src/Lib/lablib.cpp b/src/Lib/lablib.cpp index 7fc5729..aef9889 100755 --- a/src/Lib/lablib.cpp +++ b/src/Lib/lablib.cpp @@ -167,3 +167,20 @@ void lc::Lablib::SetLocalZLeafDefaultName( const QString &argName ) { settings->SetLocalzLeafName( argName ); labSettings.setValue( "local_zLeaf_name", argName ); } + +//Returns the commandline that is issued on the client when zleaf is started +QStringList lc::Lablib::getzLeafArgs( int sessionPort, QString zleafVersion ){ + QStringList arguments; + if ( sessionPort == 7000 ) { + arguments << "DISPLAY=:0.0" << settings->tasksetCmd << "0x00000001" << settings->wineCmd + << QString{ settings->zTreeInstDir + "/zTree_" + zleafVersion + "/zleaf.exe" } + << "/server" << settings->serverIP; + } else { + arguments << "DISPLAY=:0.0" << settings->tasksetCmd << "0x00000001" << settings->wineCmd + << QString{ settings->zTreeInstDir + "/zTree_" + zleafVersion + "/zleaf.exe" } + << "/server" << settings->serverIP << "/channel" + << QString::number( sessionPort- 7000 ); + } + + return arguments; +} diff --git a/src/Lib/lablib.h b/src/Lib/lablib.h index 18afbdb..68764aa 100755 --- a/src/Lib/lablib.h +++ b/src/Lib/lablib.h @@ -93,6 +93,14 @@ public: QString argzTreeDataTargetPath, quint16 argzTreePort, QString argzTreeVersion ); + /*! + * \brief Returns the commandline to issue on the client(s) in order to start zLeaf + * @param sessionPort The port zLeaf shall connect to + * @param zLeafVersion zLeaf Version to start + */ + QStringList getzLeafArgs( int sessionPort, QString zleafVersion ); + + public slots: signals: diff --git a/src/Lib/settings.cpp b/src/Lib/settings.cpp index 11e6d14..7214061 100755 --- a/src/Lib/settings.cpp +++ b/src/Lib/settings.cpp @@ -112,6 +112,8 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) : argSettings, true ) }, webcams{ argSettings.value( "webcams", "" ).toString().split( '|', QString::SkipEmptyParts, Qt::CaseInsensitive ) }, + webcams_names{ argSettings.value( "webcams_names", "" ).toString().split( '|', QString::SkipEmptyParts, + Qt::CaseInsensitive ) }, wineCmd{ ReadSettingsItem( "wine_command", "Running z-Leaves or z-Tree will be possible.", argSettings, true ) }, diff --git a/src/Lib/settings.h b/src/Lib/settings.h index 42398b4..685f66b 100755 --- a/src/Lib/settings.h +++ b/src/Lib/settings.h @@ -78,6 +78,7 @@ public: const QString wakeonlanCmd; const QString webcamDisplayCmd; const QStringList webcams; + const QStringList webcams_names; const QString wineCmd; const QString wmctrlCmd; const QString xsetCmd; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e720c69..83df214 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -106,7 +106,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { if ( zTreeEntries.isEmpty() ) { ui->CBClientNames->setEnabled( false ); //ui->GBzTree->setEnabled( false ); - ui->LFakeName->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); ui->PBStartLocalzLeaf->setEnabled( false ); ui->PBStartzLeaf->setEnabled( false ); @@ -123,8 +123,8 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { ui->CBWebcamChooser->setEnabled( false ); ui->GBClientActions->setEnabled( false ); ui->LEFilePath->setEnabled( false ); - ui->LFakeName->setEnabled( false ); - ui->LWebcamChooser->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); + ui->L_WebcamChooser->setEnabled( false ); ui->PBBeamFile->setEnabled( false ); ui->PBChooseFile->setEnabled( false ); ui->PBKillLocalzLeaf->setEnabled( false ); @@ -154,7 +154,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { || settings->userNameOnClients.isEmpty() ) { ui->CBClientNames->setEnabled( false ); ui->LEFilePath->setEnabled( false ); - ui->LFakeName->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); ui->PBBeamFile->setEnabled( false ); ui->PBChooseFile->setEnabled( false ); ui->PBKillzLeaf->setEnabled( false ); @@ -195,7 +195,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { if ( settings->sshCmd.isEmpty() ) { ui->CBClientNames->setEnabled( false ); ui->GBClientActions->setEnabled( false ); - ui->LFakeName->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); ui->LEFilePath->setEnabled( false ); ui->PBBeamFile->setEnabled( false ); ui->PBChooseFile->setEnabled( false ); @@ -208,7 +208,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { if ( settings->tasksetCmd.isEmpty() ) { ui->CBClientNames->setEnabled( false ); - ui->LFakeName->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); ui->PBStartSession->setEnabled( false ); ui->PBStartLocalzLeaf->setEnabled( false ); @@ -236,12 +236,12 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { if ( settings->webcamDisplayCmd.isEmpty() || settings->webcams.isEmpty() ) { ui->CBWebcamChooser->setEnabled( false ); - ui->LWebcamChooser->setEnabled( false ); + ui->L_WebcamChooser->setEnabled( false ); } if ( settings->wineCmd.isEmpty() ) { ui->CBClientNames->setEnabled( false ); - ui->LFakeName->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); //ui->PBStartSession->setEnabled( false ); ui->PBStartLocalzLeaf->setEnabled( false ); @@ -250,7 +250,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { if ( settings->zTreeInstDir.isEmpty() ) { ui->CBClientNames->setEnabled( false ); - ui->LFakeName->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); ui->PBStartSession->setEnabled( false ); ui->PBStartLocalzLeaf->setEnabled( false ); @@ -375,7 +375,7 @@ void lc::MainWindow::SetupWidgets() { ui->CBClientNames->setEnabled( false ); ui->GBClientActions->setEnabled( false ); ui->LEFilePath->setEnabled( false ); - ui->LFakeName->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); ui->PBBeamFile->setEnabled( false ); ui->PBChooseFile->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); @@ -385,18 +385,18 @@ void lc::MainWindow::SetupWidgets() { // Fill the 'CBWebcamChooser' with all available network webcams if ( !settings->webcams.isEmpty() ) { - for ( const auto &s : settings->webcams ) + for ( const auto &s : settings->webcams_names ) ui->CBWebcamChooser->addItem( s ); } // Disable the admin tab if the user has no administrative rights and set it up if ( CheckIfUserIsAdmin() ) { ui->TAdminActions->setEnabled( true ); - ui->LAdministrativeRights->setText( tr( "You have administrative rights." ) ); + ui->L_AdministrativeRights->setText( tr( "You have administrative rights." ) ); } else { - ui->LAdministrativeRights->setText( tr( "You don't have administrative rights." ) ); + ui->L_AdministrativeRights->setText( tr( "You don't have administrative rights." ) ); } - ui->LUserName->setText( tr( "You are user %1" ).arg( settings->localUserName ) ); + ui->L_UserName->setText( tr( "You are user %1" ).arg( settings->localUserName ) ); if ( !settings->userNameOnClients.isEmpty() ) { ui->RBUseLocalUser->setText( settings->userNameOnClients ); } else { @@ -569,7 +569,10 @@ void lc::MainWindow::on_CBWebcamChooser_activated( int argIndex ) { if ( argIndex != 0 ) { QString program{ settings->webcamDisplayCmd }; QStringList arguments; - arguments << ui->CBWebcamChooser->currentText(); + + // Attention argIndex is NOT 0-based + arguments << settings->webcams[argIndex-1]; + qDebug() << "Webcam" << arguments << "will be opened"; QProcess showWebcamProcess; QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); @@ -674,6 +677,7 @@ void lc::MainWindow::StartLocalzLeaf( QString argzLeafName, QString argzLeafVers arguments << "/size" << QString{ settings->localzLeafSize }; } + qDebug() << "Start local zLeaf:" << arguments; startProc.startDetached( settings->tasksetCmd, arguments ); } @@ -789,19 +793,24 @@ void lc::MainWindow::on_PBStartSession_clicked() { static_cast< quint16 >( ui->SBPort->value() ), ui->CBzTreeVersion->currentText() ); + //Display the command line + QString cmd = this->lablib->getzLeafArgs( ui->SBPort->value(), ui->CBzTreeVersion->currentText()).join(" "); + ui->LEzLeafCommandline->setText(cmd); + //Start z-Leaf on selected clients if checkbox is activated if( ui->ChBautoStartClientZleaf->isChecked() ) { for ( auto cit = activatedItems.cbegin(); cit != activatedItems.cend(); ++cit ) { if ( ( *cit ).data( Qt::DisplayRole ).type() != 0 ) { Client *client = static_cast< Client* >( ( *cit ).data( Qt::UserRole ).value< void * >() ); - client->StartZLeaf( nullptr ); + client->StartZLeaf( nullptr, cmd ); } } } - //Set port to +1 + //Set chosen Port + settings->SetChosenZTreePort(ui->SBPort->text().toInt()); + // Increment port number int newPort = ui->SBPort->text().toInt() + 1; - settings->SetChosenZTreePort(newPort); ui->SBPort->setValue(newPort); } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 8278855..da11085 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -101,7 +101,7 @@ - + Plan a session or print attendee list @@ -122,7 +122,7 @@ - + Print local files @@ -153,7 +153,7 @@ - + Show webcams @@ -207,7 +207,7 @@ - + Switch the selected clients on or off @@ -248,7 +248,7 @@ - + Remote control the selected clients @@ -329,7 +329,7 @@ - + Start browser on the selected clients @@ -338,7 +338,7 @@ - + URL: @@ -425,7 +425,7 @@ - + 50 @@ -530,7 +530,7 @@ - Data target path: + Data target path (No whitespaces allowed) @@ -708,14 +708,14 @@ - + command line to be executed - + 0 @@ -742,7 +742,7 @@ - + true @@ -796,7 +796,7 @@ - + Local zLeaf @@ -855,14 +855,14 @@ - + TextLabel - + TextLabel @@ -880,7 +880,7 @@ - + User to be used for remote terminal session: From 6b0893612895ac40cbfd1caba6b1f212cc779e58 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Tue, 3 Oct 2017 23:50:56 +0200 Subject: [PATCH 19/22] updated changelog --- CHANGELOG.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a81926..e2a4528 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed ### Removed -## [v2.1.4] - 2017-08-27 -* Added dialog for Upload folder button +## [v2.1.4] - 2017-10-03 +### Added +* Dialog for Upload folder button +* Open browser on clients +* Full Control VNC Button +* LineEdit for zLeaf CMD +### Changed +* Session popup is now a tab +* Tab layout separated in prep / session / admin / info +* Version info displayed in info ## [v2.1.0] - 2016-10-12 ### Added * Manual printing of _z-Tree_ payment files From 51cb37a3da592fefaf960b14a83cc96c99322ac8 Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Tue, 17 Oct 2017 15:55:55 +0200 Subject: [PATCH 20/22] fixed missing cmd parameter for start session for selected clients button --- src/Lib/client.cpp | 6 +----- src/Lib/lablib.cpp | 1 + src/mainwindow.cpp | 5 ++--- src/mainwindow.ui | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Lib/client.cpp b/src/Lib/client.cpp index 95045b3..bd6d109 100755 --- a/src/Lib/client.cpp +++ b/src/Lib/client.cpp @@ -274,11 +274,7 @@ void lc::Client::StartZLeaf( const QString * argFakeName, QString cmd ) { == messageBoxRunningZLeafFound->button( QMessageBox::Yes ) ) || state != state_t::ZLEAF_RUNNING ) { QStringList arguments; - if ( argFakeName == nullptr && GetSessionPort() == 7000 ) { - arguments << "-i" << settings->pkeyPathUser - << QString{ settings->userNameOnClients + "@" + ip } - << cmd; - } else if ( argFakeName == nullptr ) { + if ( argFakeName == nullptr ) { arguments << "-i" << settings->pkeyPathUser << QString{ settings->userNameOnClients + "@" + ip } << cmd; diff --git a/src/Lib/lablib.cpp b/src/Lib/lablib.cpp index aef9889..78fa67a 100755 --- a/src/Lib/lablib.cpp +++ b/src/Lib/lablib.cpp @@ -182,5 +182,6 @@ QStringList lc::Lablib::getzLeafArgs( int sessionPort, QString zleafVersion ){ << QString::number( sessionPort- 7000 ); } + //Return the crafted QStringList return arguments; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 83df214..2b992d4 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -638,13 +638,12 @@ void lc::MainWindow::on_PBViewDesktopFullControl_clicked() /* Session tab functions */ - void lc::MainWindow::on_PBStartzLeaf_clicked() { QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); - client->StartZLeaf( nullptr ); + client->StartZLeaf( nullptr, ui->LEzLeafCommandline->text() ); } } } @@ -807,7 +806,7 @@ void lc::MainWindow::on_PBStartSession_clicked() { } } - //Set chosen Port + // Set chosen Port settings->SetChosenZTreePort(ui->SBPort->text().toInt()); // Increment port number int newPort = ui->SBPort->text().toInt() + 1; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index da11085..20bcaf1 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -64,7 +64,7 @@ - 0 + 1 true From 95f0c6e182bc0e2da6fed0472ee9202bf2f29d6d Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Fri, 10 Nov 2017 18:27:02 +0100 Subject: [PATCH 21/22] final version 2.1.5 commit --- CHANGELOG.md | 3 ++- src/mainwindow.cpp | 2 +- src/mainwindow.ui | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2a4528..f7134cc 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed ### Removed -## [v2.1.4] - 2017-10-03 +## [v2.1.5] - 2017-10-21 ### Added * Dialog for Upload folder button * Open browser on clients @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). * Session popup is now a tab * Tab layout separated in prep / session / admin / info * Version info displayed in info + ## [v2.1.0] - 2016-10-12 ### Added * Manual printing of _z-Tree_ payment files diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2b992d4..b0fb33d 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -425,7 +425,7 @@ void lc::MainWindow::SetupWidgets() { //DisableDisfunctionalWidgets(); // Set the info text in LInfo on the TInfo tab - ui->LInfo->setText( "This is Labcontrol version 2.1.4\n\n\n\n\n\n" + ui->LInfo->setText( "This is Labcontrol version 2.1.5\n\n\n\n\n\n" "Developers\n\n" "0day-2016 Henning Prömpers\n" "2014-2016 Markus Prasser\n" diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 20bcaf1..da11085 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -64,7 +64,7 @@ - 1 + 0 true From dc0a461b73ed6a69c5d432ba74a2eac3cdc0ecad Mon Sep 17 00:00:00 2001 From: Tobias Weiss Date: Tue, 25 Feb 2020 09:05:52 +0100 Subject: [PATCH 22/22] fix url for firefix --- Labcontrol.pro.user.4.8-pre1 | 276 +++++++++++++++++++++++++++++++++++ data/Labcontrol.conf | 4 + src/Lib/client.cpp | 76 ++++++++-- src/Lib/client.h | 7 +- src/Lib/settings.cpp | 3 + src/Lib/settings.h | 1 + src/mainwindow.cpp | 43 +++++- src/mainwindow.h | 2 + src/mainwindow.ui | 66 +++++++-- 9 files changed, 452 insertions(+), 26 deletions(-) create mode 100644 Labcontrol.pro.user.4.8-pre1 diff --git a/Labcontrol.pro.user.4.8-pre1 b/Labcontrol.pro.user.4.8-pre1 new file mode 100644 index 0000000..7bcc688 --- /dev/null +++ b/Labcontrol.pro.user.4.8-pre1 @@ -0,0 +1,276 @@ + + + + + + EnvironmentId + {e5c02e28-17c9-4196-8348-d8ad584d5f67} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + {244db1fd-ad78-44f7-be44-4616619a867c} + 0 + 0 + 0 + + /home/weiss/build-Labcontrol-Desktop-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /home/weiss/build-Labcontrol-Desktop-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 2 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + Labcontrol + + Qt4ProjectManager.Qt4RunConfiguration:/home/weiss/Labcontrol_fork/Labcontrol.pro + true + + Labcontrol.pro + false + + + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/data/Labcontrol.conf b/data/Labcontrol.conf index d04b702..4799cfd 100755 --- a/data/Labcontrol.conf +++ b/data/Labcontrol.conf @@ -92,3 +92,7 @@ webcam_command=/usr/local/bin/WebcamDisplay ztree_installation_directory=/opt/z-Leaves # Script to be called after session crash restart_crashed_session_script=/home/scripts/start_zTree_after_crash.sh +# Client default browser cmd (firefox) - need to be quoted! +client_browser_command="firefox-esr" +# Client cromium cmd- need to be quoted! +client_chromium_command="chromium" diff --git a/src/Lib/client.cpp b/src/Lib/client.cpp index bd6d109..d81c73e 100755 --- a/src/Lib/client.cpp +++ b/src/Lib/client.cpp @@ -21,10 +21,14 @@ #include +// To substitute client name in argURL browser call +#include + #include "client.h" #include "settings.h" #include "lablib.h" + extern std::unique_ptr< lc::Settings > settings; extern std::unique_ptr< lc::Lablib > lablib; @@ -296,20 +300,41 @@ void lc::Client::StartZLeaf( const QString * argFakeName, QString cmd ) { } } -void lc::Client::StartClientBrowser( const QString * const argURL, const bool * const argFullscreen ) { +void lc::Client::StartClientBrowser( const QString * const argURL, const bool * const argFullscreen, const QString * const argBrowser ) { //Declarations QStringList arguments; - // Build arguments list for SSH command - arguments << "-i" << settings->pkeyPathUser - << QString{ settings->userNameOnClients + "@" + ip } - << "DISPLAY=:0.0" - << settings->clientBrowserCmd - << *argURL; - - // Add fullscreen toggle if checked - if (*argFullscreen == true){ - arguments << "& sleep 3 && DISPLAY=:0.0 xdotool key --clearmodifiers F11"; + QString processedArgUrl(*argURL); + QRegularExpression clientRegEx(QStringLiteral("%CLIENT%")); + processedArgUrl.replace(clientRegEx,this->name); + //qDebug() << processedArgUrl; + + if(argBrowser==QString("firefox")){ + // Build arguments list for SSH command + arguments << "-i" << settings->pkeyPathUser + << QString{ settings->userNameOnClients + "@" + ip } + << "DISPLAY=:0.0" + << settings->clientBrowserCmd + << processedArgUrl; + + // Add fullscreen toggle if checked + if (*argFullscreen == true){ + arguments << "& sleep 3 && DISPLAY=:0.0 xdotool key --clearmodifiers F11"; + } + } else if (argBrowser==QString("chromium")) { + // Build arguments list for SSH command + arguments << "-i" << settings->pkeyPathUser + << QString{ settings->userNameOnClients + "@" + ip } + << "DISPLAY=:0.0" + << settings->clientChromiumCmd + << "--noerrdialogs --kiosk" + << "--app='" + processedArgUrl + "'" + << "> /dev/null 2>&1 &disown"; + + // Add fullscreen toggle if checked + //if (*argFullscreen == true){ + // arguments << "&& sleep 3 && DISPLAY=:0.0 xdotool key --clearmodifiers F11"; + //} } // Start the process @@ -331,7 +356,34 @@ void lc::Client::StopClientBrowser() { << QString{ settings->userNameOnClients + "@" + ip } << "killall" << settings->clientBrowserCmd - << "& sleep 1 && rm -R /home/ewfuser/.mozilla/firefox/*"; + << "& sleep 1 && rm -R /home/ewfuser/.mozilla/firefox/*" + << "& killall" + << settings->clientChromiumCmd; + + // Start the process + QProcess startClientBrowserProcess; + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + startClientBrowserProcess.setProcessEnvironment( env ); + startClientBrowserProcess.startDetached( settings->sshCmd, arguments ); + + // Output message via the debug messages tab + qDebug() << settings->sshCmd << arguments.join( " " ); +} + +void lc::Client::ControlRMB(bool enable) { + //Declarations + QStringList arguments; + + //Build arguments list + if(enable){ + arguments << "-i" << settings->pkeyPathUser + << QString{ settings->userNameOnClients + "@" + ip } + << "DISPLAY=:0 xinput set-button-map 'Microsoft Basic Optical Mouse' 1 2 3 4 5 6 7 8 9 10 11 12 > /dev/null 2>&1 &disown;"; + } else { + arguments << "-i" << settings->pkeyPathUser + << QString{ settings->userNameOnClients + "@" + ip } + << "DISPLAY=:0 xinput set-button-map 'Microsoft Basic Optical Mouse' 1 2 0 4 5 6 7 8 9 10 11 12 > /dev/null 2>&1 &disown;"; + } // Start the process QProcess startClientBrowserProcess; diff --git a/src/Lib/client.h b/src/Lib/client.h index 2b75897..7206e84 100755 --- a/src/Lib/client.h +++ b/src/Lib/client.h @@ -120,13 +120,18 @@ public: * \brief Opens a browser window on the client * @param argURL URL to open in clients browser */ - void StartClientBrowser( const QString *argURL = nullptr, const bool *argFullscreen = nullptr ); + void StartClientBrowser( const QString *argURL = nullptr, const bool *argFullscreen = nullptr, const QString *argBrowser = nullptr ); /*! * \brief Closes all browser instances */ void StopClientBrowser(); + /*! + * \brief Enable/Disable right mouse button + */ + void ControlRMB(bool enable = true); + private: const QString &GetzLeafVersion() const { return zLeafVersion; } diff --git a/src/Lib/settings.cpp b/src/Lib/settings.cpp index 7214061..9d862bf 100755 --- a/src/Lib/settings.cpp +++ b/src/Lib/settings.cpp @@ -34,6 +34,9 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) : clientBrowserCmd{ ReadSettingsItem( "client_browser_command", "Opening a browser window on clients will not work.", argSettings, false ) }, + clientChromiumCmd{ ReadSettingsItem( "client_chromium_command", + "Opening a chromium window on clients will not work.", + argSettings, false ) }, dvipsCmd{ ReadSettingsItem( "dvips_command", "Receipts creation will not work.", argSettings, true ) }, diff --git a/src/Lib/settings.h b/src/Lib/settings.h index 685f66b..ecc8983 100755 --- a/src/Lib/settings.h +++ b/src/Lib/settings.h @@ -49,6 +49,7 @@ public: const int defaultReceiptIndex = 0; const QString browserCmd; const QString clientBrowserCmd; + const QString clientChromiumCmd; const QString dvipsCmd; const QString fileMngr; const QString killallCmd; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b0fb33d..72db13c 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -22,7 +22,7 @@ #include #include #include - +#include #include "localzleafstarter.h" #include "mainwindow.h" #include "manualprintingsetup.h" @@ -425,7 +425,7 @@ void lc::MainWindow::SetupWidgets() { //DisableDisfunctionalWidgets(); // Set the info text in LInfo on the TInfo tab - ui->LInfo->setText( "This is Labcontrol version 2.1.5\n\n\n\n\n\n" + ui->LInfo->setText( "This is Labcontrol version 2.1.6\n\n\n\n\n\n" "Developers\n\n" "0day-2016 Henning Prömpers\n" "2014-2016 Markus Prasser\n" @@ -585,11 +585,12 @@ void lc::MainWindow::on_PBstartBrowser_clicked() { QString argURL = ui->LEURL->text(); bool argFullscreen = ui->CBFullscreen->checkState(); + QString argBrowser = ui->CB_BrowserSelection->currentText(); QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); - client->StartClientBrowser( &argURL, &argFullscreen ); + client->StartClientBrowser( &argURL, &argFullscreen, &argBrowser ); } } } @@ -885,3 +886,39 @@ void lc::MainWindow::on_PBOpenTerminal_clicked() { } } } + +// Enable RMB +void lc::MainWindow::on_PBEnableRMB_clicked() +{ + // Confirmation dialog + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this, "Confirm", "Really enable the right mouse button on selected clients?", QMessageBox::Yes|QMessageBox::No); + if (reply == QMessageBox::Yes) { + qDebug() << "Enabling RMB on chosen clients."; + QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); + for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { + if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { + Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); + client->ControlRMB(true); + } + } + } +} + +// Disable RMB +void lc::MainWindow::on_PBDisableRMB_clicked() +{ + // Confirmation dialog + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this, "Confirm", "Really disable the right mouse button on selected clients?", QMessageBox::Yes|QMessageBox::No); + if (reply == QMessageBox::Yes) { + qDebug() << "Disabling RMB on chosen clients."; + QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); + for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { + if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { + Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); + client->ControlRMB(false); + } + } + } +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 154afef..1fdd824 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -129,6 +129,8 @@ private slots: void on_CBReceiptsHeader_activated(int argIndex); void on_ChBPrintanonymousreceipts_clicked(); void on_PBKillzLeaf_clicked(); + void on_PBEnableRMB_clicked(); + void on_PBDisableRMB_clicked(); }; } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index da11085..35f7de9 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 730 - 900 + 903 @@ -240,13 +240,6 @@ - - - - Qt::Horizontal - - - @@ -271,6 +264,31 @@ + + + + Control right mouse botton (RMB) + + + + + + + + + Enable RMB + + + + + + + Disable RMB + + + + + @@ -335,6 +353,13 @@ + + + + %CLIENT% is a placeholder for hostname in URL + + + @@ -347,16 +372,37 @@ - http:// + http://localhost:8000/%CLIENT% + + + + Use the following browser + + + + + + + + chromium + + + + + firefox + + + + - Fullscreen + Fullscreen (only FF) true