added cmd lineedit and changed some ui minor elements

remotes/origin/HEAD
Tobias Weiss 7 years ago
parent 360f71210b
commit 70350155c1

@ -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.

@ -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;
}
@ -275,27 +277,17 @@ void lc::Client::StartZLeaf( const QString * argFakeName ) {
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;
} else {
if ( argFakeName == nullptr ) {
<< 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 );
<< cmd;
} 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 )
<< cmd
<< "/name" << *argFakeName;
}
}
// Start the process
QProcess startZLeafProcess;

@ -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
*/

@ -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;
}

@ -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:

@ -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 ) },

@ -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;

@ -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);
}

@ -101,7 +101,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="LPlanSession">
<widget class="QLabel" name="L_PlanSession">
<property name="text">
<string>Plan a session or print attendee list</string>
</property>
@ -122,7 +122,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="LPrintLocalFiles">
<widget class="QLabel" name="L_PrintLocalFiles">
<property name="text">
<string>Print local files</string>
</property>
@ -153,7 +153,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="LWebcamChooser">
<widget class="QLabel" name="L_WebcamChooser">
<property name="text">
<string>Show webcams</string>
</property>
@ -207,7 +207,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="LClientBootShutdown">
<widget class="QLabel" name="L_ClientBootShutdown">
<property name="text">
<string>Switch the selected clients on or off</string>
</property>
@ -248,7 +248,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="LVNC">
<widget class="QLabel" name="L_VNC">
<property name="text">
<string>Remote control the selected clients</string>
</property>
@ -329,7 +329,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="LBrowserActions">
<widget class="QLabel" name="L_BrowserActions">
<property name="text">
<string>Start browser on the selected clients</string>
</property>
@ -338,7 +338,7 @@
<item>
<layout class="QHBoxLayout" name="HLURL">
<item>
<widget class="QLabel" name="LURL">
<widget class="QLabel" name="L_URL">
<property name="text">
<string>URL:</string>
</property>
@ -425,7 +425,7 @@
</property>
<layout class="QVBoxLayout" name="VLcleanupRecoverLastSession">
<item>
<widget class="QLabel" name="LcleanupRecoverLastSession">
<widget class="QLabel" name="L_cleanupRecoverLastSession">
<property name="font">
<font>
<weight>50</weight>
@ -530,7 +530,7 @@
<item>
<widget class="QLabel" name="LDataTargetPath">
<property name="text">
<string>Data target path:</string>
<string>Data target path (No whitespaces allowed)</string>
</property>
</widget>
</item>
@ -708,14 +708,14 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="LzLeafCommandline">
<property name="text">
<string>command line to be executed</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<widget class="QLineEdit" name="LEzLeafCommandline">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -742,7 +742,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="LFakeName">
<widget class="QLabel" name="L_FakeName">
<property name="enabled">
<bool>true</bool>
</property>
@ -796,7 +796,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="L_LocalZleaf">
<property name="text">
<string>Local zLeaf</string>
</property>
@ -855,14 +855,14 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QLabel" name="LUserName">
<widget class="QLabel" name="L_UserName">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="LAdministrativeRights">
<widget class="QLabel" name="L_AdministrativeRights">
<property name="text">
<string>TextLabel</string>
</property>
@ -880,7 +880,7 @@
<item>
<layout class="QVBoxLayout" name="VLUseUser">
<item>
<widget class="QLabel" name="LUseUser">
<widget class="QLabel" name="L_UseUser">
<property name="text">
<string>User to be used for remote terminal session:</string>
</property>

Loading…
Cancel
Save