@ -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 - > 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 " ) ,
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 ( ) {
@ -71,20 +102,29 @@ 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 - > L_FakeName - > 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 ) ;
ui - > PBKillzLeaf - > setEnabled ( false ) ;
}
// Disable all functions relying on the labcontrol installation directory if it is not available
if ( settings - > lcInstDir . isEmpty ( ) ) {
if ( settings - > lc Data Dir. isEmpty ( ) ) {
ui - > CBClientNames - > setEnabled ( false ) ;
ui - > CBWebcamChooser - > setEnabled ( false ) ;
ui - > GBClientActions - > setEnabled ( false ) ;
ui - > GBzTree - > setEnabled ( false ) ;
ui - > LEFilePath - > setEnabled ( false ) ;
ui - > L FakeName- > setEnabled ( false ) ;
ui - > L WebcamChooser- > setEnabled ( false ) ;
ui - > L _ FakeName- > setEnabled ( false ) ;
ui - > L _ WebcamChooser- > setEnabled ( false ) ;
ui - > PBBeamFile - > setEnabled ( false ) ;
ui - > PBChooseFile - > setEnabled ( false ) ;
ui - > PBKillLocalzLeaf - > setEnabled ( false ) ;
@ -114,10 +154,9 @@ void lc::MainWindow::DisableDisfunctionalWidgets() {
| | settings - > userNameOnClients . isEmpty ( ) ) {
ui - > CBClientNames - > setEnabled ( false ) ;
ui - > LEFilePath - > setEnabled ( false ) ;
ui - > L FakeName- > setEnabled ( false ) ;
ui - > L _ FakeName- > 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 ) ;
@ -156,7 +195,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() {
if ( settings - > sshCmd . isEmpty ( ) ) {
ui - > CBClientNames - > setEnabled ( false ) ;
ui - > GBClientActions - > setEnabled ( false ) ;
ui - > L FakeName- > setEnabled ( false ) ;
ui - > L _ FakeName- > setEnabled ( false ) ;
ui - > LEFilePath - > setEnabled ( false ) ;
ui - > PBBeamFile - > setEnabled ( false ) ;
ui - > PBChooseFile - > setEnabled ( false ) ;
@ -169,7 +208,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() {
if ( settings - > tasksetCmd . isEmpty ( ) ) {
ui - > CBClientNames - > setEnabled ( false ) ;
ui - > L FakeName- > setEnabled ( false ) ;
ui - > L _ FakeName- > setEnabled ( false ) ;
ui - > PBRunzLeaf - > setEnabled ( false ) ;
ui - > PBStartSession - > setEnabled ( false ) ;
ui - > PBStartLocalzLeaf - > setEnabled ( false ) ;
@ -184,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
@ -196,26 +236,21 @@ void lc::MainWindow::DisableDisfunctionalWidgets() {
if ( settings - > webcamDisplayCmd . isEmpty ( )
| | settings - > webcams . isEmpty ( ) ) {
ui - > CBWebcamChooser - > setEnabled ( false ) ;
ui - > L WebcamChooser- > setEnabled ( false ) ;
ui - > L _ WebcamChooser- > setEnabled ( false ) ;
}
if ( settings - > wineCmd . isEmpty ( ) ) {
ui - > CBClientNames - > setEnabled ( false ) ;
ui - > L FakeName- > setEnabled ( false ) ;
ui - > L _ FakeName- > 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 - > zTreeInstDir . isEmpty ( ) ) {
ui - > CBClientNames - > setEnabled ( false ) ;
ui - > L FakeName- > setEnabled ( false ) ;
ui - > L_FakeName - > setEnabled ( false ) ;
ui - > PBRunzLeaf - > setEnabled ( false ) ;
ui - > PBStartSession - > setEnabled ( false ) ;
ui - > PBStartLocalzLeaf - > setEnabled ( false ) ;
@ -224,7 +259,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() {
}
void lc : : MainWindow : : LoadIconPixmaps ( ) {
if ( settings - > lc Inst Dir. isEmpty ( ) ) {
if ( settings - > lc Data Dir. isEmpty ( ) ) {
return ;
}
@ -237,122 +272,10 @@ void lc::MainWindow::LoadIconPixmaps() {
< < " zLeaf.png " } ;
for ( int i = 0 ; i < ( int ) icons_t : : ICON_QUANTITY ; i + + ) {
if ( ! icons [ i ] . load ( settings - > lc Inst Dir + " /icons/ " + iconNames [ i ] ) ) {
if ( ! icons [ i ] . load ( settings - > lc Data Dir + " /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 ) ;
}
}
}
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 ( ) } ;
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 ) ;
}
}
}
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_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 ;
// 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 \n Are 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 ( ) ) ;
}
. arg ( settings - > lcDataDir ) . arg ( iconNames [ i ] ) , QMessageBox : : Ok ) ;
}
}
}
@ -374,51 +297,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 ;
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_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 ) ;
@ -454,107 +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_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 ;
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_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 ) {
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_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. " ;
@ -593,12 +370,12 @@ 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 ) ;
ui - > LEFilePath - > setEnabled ( false ) ;
ui - > L FakeName- > setEnabled ( false ) ;
ui - > L _ FakeName- > setEnabled ( false ) ;
ui - > PBBeamFile - > setEnabled ( false ) ;
ui - > PBChooseFile - > setEnabled ( false ) ;
ui - > PBRunzLeaf - > setEnabled ( false ) ;
@ -608,28 +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 ) ;
}
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 ) ;
ui - > L AdministrativeRights- > setText ( tr ( " You have administrative rights. " ) ) ;
ui - > L_AdministrativeRights - > setText ( tr ( " You have administrative rights. " ) ) ;
} else {
ui - > L AdministrativeRights- > setText ( tr ( " You don't have administrative rights. " ) ) ;
ui - > L_AdministrativeRights - > setText ( tr ( " You don't have administrative rights. " ) ) ;
}
ui - > L UserName- > 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 {
@ -654,10 +421,16 @@ 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 \n Copyright 2014-2016 Markus Prasser \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 "
" 2016 - now WiwilabHiwiOrgaization \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 "
@ -670,27 +443,6 @@ void lc::MainWindow::SetupWidgets() {
" along with Labcontrol. If not, see <http://www.gnu.org/licenses/>. \n \n \n " ) ;
}
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 : : StartReceiptsHandler ( QString argzTreeDataTargetPath ,
bool argReceiptsForLocalClients ,
QString argAnonymousReceiptsPlaceholder ,
@ -735,21 +487,205 @@ void lc::MainWindow::UpdateClientsTableView() {
}
}
// TODO: Implement the functionality of the script in here
void lc : : MainWindow : : on_PBrestartCrashedSession_clicked ( ) {
QProcess startProc ;
startProc . setProcessEnvironment ( QProcessEnvironment : : systemEnvironment ( ) ) ;
if ( ! settings - > restartCrashedSessionScript . isEmpty ( ) ) {
startProc . startDetached ( settings - > restartCrashedSessionScript ) ;
/* 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_PBKillzTree_clicked ( )
{
QString program { settings - > killallCmd } ;
QStringList arguments ;
arguments < < " -I " < < " -q " < < " ztree.exe " ;
// Confirmation dialog
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. \n The path on every client is /home/ewfuser/media4ztree " + fileToBeam . mid ( fileToBeam . lastIndexOf ( ' / ' ) ) + " . \n Don'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 } ;
QStringList arguments ;
// Attention argIndex is NOT 0-based
arguments < < settings - > webcams [ argIndex - 1 ] ;
qDebug ( ) < < " Webcam " < < arguments < < " will be opened " ;
QProcess showWebcamProcess ;
QProcessEnvironment env = QProcessEnvironment : : systemEnvironment ( ) ;
showWebcamProcess . setProcessEnvironment ( env ) ;
showWebcamProcess . startDetached ( program , arguments ) ;
}
}
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 ( ) ;
}
}
}
// Full control VNC button
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 ( ) ;
}
}
}
/* 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 , ui - > LEzLeafCommandline - > text ( ) ) ;
}
}
}
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 ( )
| | 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 } ;
}
qDebug ( ) < < " Start local zLeaf: " < < arguments ;
startProc . startDetached ( settings - > tasksetCmd , arguments ) ;
}
void lc : : MainWindow : : on_PBStopZtree_clicked ( )
{
QString program { settings - > killallCmd } ;
QStringList arguments ;
arguments < < " -I " < < " -q " < < " ztree.exe " ;
// Confirmation dialog
QMessageBox : : StandardButton reply ;
reply = QMessageBox : : question ( this , " Confirm " , " Really kill all z-Tree instances? " , QMessageBox : : Yes | QMessageBox : : No ) ;
if ( reply = = QMessageBox : : Yes ) {
@ -761,6 +697,191 @@ 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_PBRecoverCrashedSession_clicked ( )
{
// 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_CBDataTargetPath_activated ( int argIndex )
{
if ( ! argIndex ) {
emit RequestNewDataTargetPath ( ) ;
}
ui - > CBDataTargetPath - > setStyleSheet ( " " ) ;
}
// Open a folder chooser dialog for zTree data path
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 ) ;
}
}
// 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 ( ) {
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. \n "
" Some clients have to be selected first or the "
" creation of sessions without clients must be "
" allowed with the checkbox. " ) ) ;
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 ) ;
}
}
this - > lablib - > StartNewSession ( associatedClients , anonymousReceiptsPlaceholder ,
ui - > ChBReceiptsForLocalClients - > isChecked ( ) ,
ui - > CBReceiptsHeader - > currentText ( ) ,
ui - > CBDataTargetPath - > currentText ( ) ,
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 , cmd ) ;
}
}
}
// Set chosen Port
settings - > SetChosenZTreePort ( ui - > SBPort - > text ( ) . toInt ( ) ) ;
// Increment port number
int newPort = ui - > SBPort - > text ( ) . toInt ( ) + 1 ;
ui - > SBPort - > setValue ( newPort ) ;
}
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 ( ) ;
}
}
}
/* 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 ;
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 ( ) ) ;
}
}
}