@ -19,22 +19,20 @@
# include <memory>
# include <memory>
# include <QtGlobal>
# include "Lib/settings.h"
# include <QDebug>
# include <QInputDialog>
# include <QButtonGroup>
# include "localzleafstarter.h"
# include "localzleafstarter.h"
# include "mainwindow.h"
# include "mainwindow.h"
# include "manualprintingsetup.h"
# include "manualprintingsetup.h"
# include "Lib/settings.h"
# include <QButtonGroup>
# include <QDebug>
# include <QInputDialog>
# include <QtGlobal>
extern std : : unique_ptr < lc : : Settings > settings ;
extern std : : unique_ptr < lc : : Settings > settings ;
lc : : MainWindow : : MainWindow ( QWidget * argParent ) :
lc : : MainWindow : : MainWindow ( QWidget * argParent )
QMainWindow { argParent } ,
: QMainWindow { argParent } ,
icons ( static_cast < int > ( icons_t : : ICON_QUANTITY ) ) ,
icons ( static_cast < int > ( icons_t : : ICON_QUANTITY ) ) , ui { new Ui : : MainWindow } {
ui { new Ui : : MainWindow }
{
ui - > setupUi ( this ) ;
ui - > setupUi ( this ) ;
lablib = new Lablib { this } ;
lablib = new Lablib { this } ;
@ -43,8 +41,8 @@ lc::MainWindow::MainWindow( QWidget *argParent ) :
SetupWidgets ( ) ;
SetupWidgets ( ) ;
if ( valid_items ) {
if ( valid_items ) {
gui_update_timer = new QTimer { this } ;
gui_update_timer = new QTimer { this } ;
connect ( gui_update_timer , & QTimer : : timeout ,
connect ( gui_update_timer , & QTimer : : timeout , this ,
this , & MainWindow : : UpdateClientsTableView ) ;
& MainWindow : : UpdateClientsTableView ) ;
gui_update_timer - > start ( 500 ) ;
gui_update_timer - > start ( 500 ) ;
}
}
@ -59,22 +57,24 @@ lc::MainWindow::MainWindow( QWidget *argParent ) :
ui - > CBDataTargetPath - > addItem ( QDir : : homePath ( ) ) ;
ui - > CBDataTargetPath - > addItem ( QDir : : homePath ( ) ) ;
ui - > CBDataTargetPath - > addItem ( QDir : : homePath ( ) + " /zTreeData " ) ;
ui - > CBDataTargetPath - > addItem ( QDir : : homePath ( ) + " /zTreeData " ) ;
ui - > CBDataTargetPath - > setCurrentIndex ( 2 ) ;
ui - > CBDataTargetPath - > setCurrentIndex ( 2 ) ;
connect ( this , & MainWindow : : RequestNewDataTargetPath ,
connect ( this , & MainWindow : : RequestNewDataTargetPath , this ,
this , & MainWindow : : GetNewDataTargetPath ) ;
& MainWindow : : GetNewDataTargetPath ) ;
if ( settings - > dvipsCmd . isEmpty ( ) | | settings - > latexCmd . isEmpty ( )
if ( settings - > dvipsCmd . isEmpty ( ) | | settings - > latexCmd . isEmpty ( ) | |
| | settings - > lcDataDir . isEmpty ( ) | | settings - > lprCmd . isEmpty ( )
settings - > lcDataDir . isEmpty ( ) | | settings - > lprCmd . isEmpty ( ) | |
| | settings - > postscriptViewer . isEmpty ( ) | | settings - > ps2pdfCmd . isEmpty ( )
settings - > postscriptViewer . isEmpty ( ) | | settings - > ps2pdfCmd . isEmpty ( ) | |
| | settings - > rmCmd . isEmpty ( ) | | settings - > vncViewer . isEmpty ( ) ) {
settings - > rmCmd . isEmpty ( ) | | settings - > vncViewer . isEmpty ( ) ) {
QMessageBox : : information ( this , tr ( " Receipts printing will not work " ) ,
QMessageBox : : information (
this , tr ( " Receipts printing will not work " ) ,
tr ( " Some component essential for receipts creation and "
tr ( " Some component essential for receipts creation and "
" printing is missing. No receipts will be created or "
" printing is missing. No receipts will be created or "
" printed. " ) , QMessageBox : : Ok ) ;
" printed. " ) ,
QMessageBox : : Ok ) ;
} else {
} else {
ui - > CBReceiptsHeader - > addItems ( settings - > installedLaTeXHeaders ) ;
ui - > CBReceiptsHeader - > addItems ( settings - > installedLaTeXHeaders ) ;
if ( settings - > defaultReceiptIndex
if ( settings - > defaultReceiptIndex & &
& & settings - > defaultReceiptIndex < ui - > CBReceiptsHeader - > count ( ) ) {
settings - > defaultReceiptIndex < ui - > CBReceiptsHeader - > count ( ) ) {
ui - > CBReceiptsHeader - > setCurrentIndex ( settings - > defaultReceiptIndex ) ;
ui - > CBReceiptsHeader - > setCurrentIndex ( settings - > defaultReceiptIndex ) ;
}
}
}
}
@ -87,7 +87,8 @@ lc::MainWindow::~MainWindow() {
bool lc : : MainWindow : : CheckIfUserIsAdmin ( ) {
bool lc : : MainWindow : : CheckIfUserIsAdmin ( ) {
if ( settings - > localUserName . isEmpty ( ) ) {
if ( settings - > localUserName . isEmpty ( ) ) {
QMessageBox messageBox { QMessageBox : : Warning , tr ( " User not detectable " ) ,
QMessageBox messageBox {
QMessageBox : : Warning , tr ( " User not detectable " ) ,
tr ( " Your user name could not be queryed. The admin tab will be "
tr ( " Your user name could not be queryed. The admin tab will be "
" disabled. You won't be able to perform administrative "
" disabled. You won't be able to perform administrative "
" actions but can conduct experiments normally. " ) ,
" actions but can conduct experiments normally. " ) ,
@ -112,12 +113,14 @@ void lc::MainWindow::DisableDisfunctionalWidgets() {
ui - > PBStartzLeaf - > setEnabled ( false ) ;
ui - > PBStartzLeaf - > setEnabled ( false ) ;
}
}
// Disable all z-Leaf killing related buttons if the 'killall' command is not available
// Disable all z-Leaf killing related buttons if the 'killall' command is not
// available
if ( settings - > killallCmd . isEmpty ( ) ) {
if ( settings - > killallCmd . isEmpty ( ) ) {
ui - > PBKillLocalzLeaf - > setEnabled ( false ) ;
ui - > PBKillLocalzLeaf - > setEnabled ( false ) ;
ui - > PBKillzLeaf - > setEnabled ( false ) ;
ui - > PBKillzLeaf - > setEnabled ( false ) ;
}
}
// Disable all functions relying on the labcontrol installation directory if it is not available
// Disable all functions relying on the labcontrol installation directory if
// it is not available
if ( settings - > lcDataDir . isEmpty ( ) ) {
if ( settings - > lcDataDir . isEmpty ( ) ) {
ui - > CBClientNames - > setEnabled ( false ) ;
ui - > CBClientNames - > setEnabled ( false ) ;
ui - > CBWebcamChooser - > setEnabled ( false ) ;
ui - > CBWebcamChooser - > setEnabled ( false ) ;
@ -144,14 +147,14 @@ void lc::MainWindow::DisableDisfunctionalWidgets() {
}
}
// Disable 'PBShowORSEE', if 'orsee_command' was not set
// Disable 'PBShowORSEE', if 'orsee_command' was not set
if ( settings - > browserCmd . isEmpty ( )
if ( settings - > browserCmd . isEmpty ( ) | | settings - > orseeUrl . isEmpty ( ) ) {
| | settings - > orseeUrl . isEmpty ( ) ) {
ui - > PBShowORSEE - > setEnabled ( false ) ;
ui - > PBShowORSEE - > setEnabled ( false ) ;
}
}
// Disable all widgets needless if 'public_key_path_user' or 'user_name_on_clients' was not set
// Disable all widgets needless if 'public_key_path_user' or
if ( settings - > pkeyPathUser . isEmpty ( )
// 'user_name_on_clients' was not set
| | settings - > userNameOnClients . isEmpty ( ) ) {
if ( settings - > pkeyPathUser . isEmpty ( ) | |
settings - > userNameOnClients . isEmpty ( ) ) {
ui - > CBClientNames - > setEnabled ( false ) ;
ui - > CBClientNames - > setEnabled ( false ) ;
ui - > LEFilePath - > setEnabled ( false ) ;
ui - > LEFilePath - > setEnabled ( false ) ;
ui - > L_FakeName - > setEnabled ( false ) ;
ui - > L_FakeName - > setEnabled ( false ) ;
@ -171,8 +174,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() {
ui - > RBUseLocalUser - > click ( ) ;
ui - > RBUseLocalUser - > click ( ) ;
}
}
if ( settings - > pkeyPathRoot . isEmpty ( )
if ( settings - > pkeyPathRoot . isEmpty ( ) & & settings - > pkeyPathUser . isEmpty ( ) ) {
& & settings - > pkeyPathUser . isEmpty ( ) ) {
ui - > GBExecuteOnEveryClient - > setEnabled ( false ) ;
ui - > GBExecuteOnEveryClient - > setEnabled ( false ) ;
ui - > GBOptionsForAdminActions - > setEnabled ( false ) ;
ui - > GBOptionsForAdminActions - > setEnabled ( false ) ;
ui - > PBOpenTerminal - > setEnabled ( false ) ;
ui - > PBOpenTerminal - > setEnabled ( false ) ;
@ -232,9 +234,9 @@ void lc::MainWindow::DisableDisfunctionalWidgets() {
ui - > PBBoot - > setEnabled ( false ) ;
ui - > PBBoot - > setEnabled ( false ) ;
}
}
// Deactivate the webcam choosing interface if no webcams are available or the viewer is missing
// Deactivate the webcam choosing interface if no webcams are available or the
if ( settings - > webcamDisplayCmd . isEmpty ( )
// viewer is missing
| | settings - > webcams . isEmpty ( ) ) {
if ( settings - > webcamDisplayCmd . isEmpty ( ) | | settings - > webcams . isEmpty ( ) ) {
ui - > CBWebcamChooser - > setEnabled ( false ) ;
ui - > CBWebcamChooser - > setEnabled ( false ) ;
ui - > L_WebcamChooser - > setEnabled ( false ) ;
ui - > L_WebcamChooser - > setEnabled ( false ) ;
}
}
@ -263,8 +265,7 @@ void lc::MainWindow::LoadIconPixmaps() {
return ;
return ;
}
}
const QStringList iconNames { QStringList { }
const QStringList iconNames { QStringList { } < < " unknown.png "
< < " unknown.png "
< < " off.png "
< < " off.png "
< < " down.png "
< < " down.png "
< < " boot.png "
< < " boot.png "
@ -273,9 +274,12 @@ void lc::MainWindow::LoadIconPixmaps() {
for ( int i = 0 ; i < ( int ) icons_t : : ICON_QUANTITY ; i + + ) {
for ( int i = 0 ; i < ( int ) icons_t : : ICON_QUANTITY ; i + + ) {
if ( ! icons [ i ] . load ( settings - > lcDataDir + " /icons/ " + iconNames [ i ] ) ) {
if ( ! icons [ i ] . load ( settings - > lcDataDir + " /icons/ " + iconNames [ i ] ) ) {
QMessageBox : : information ( this , tr ( " Could not load icon '%1' " ) . arg ( 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. " )
tr ( " The icon in '%1/icons/%2' could not be loaded. " )
. arg ( settings - > lcDataDir ) . arg ( iconNames [ i ] ) , QMessageBox : : Ok ) ;
. arg ( settings - > lcDataDir )
. arg ( iconNames [ i ] ) ,
QMessageBox : : Ok ) ;
}
}
}
}
}
}
@ -283,7 +287,9 @@ void lc::MainWindow::LoadIconPixmaps() {
void lc : : MainWindow : : on_PBKillLocalzLeaf_clicked ( ) {
void lc : : MainWindow : : on_PBKillLocalzLeaf_clicked ( ) {
QString program { settings - > killallCmd } ;
QString program { settings - > killallCmd } ;
QStringList arguments ;
QStringList arguments ;
arguments < < " -I " < < " -q " < < " zleaf.exe " ;
arguments < < " -I "
< < " -q "
< < " zleaf.exe " ;
// Start the process
// Start the process
QProcess killLocalzLeafProc ;
QProcess killLocalzLeafProc ;
@ -301,30 +307,39 @@ void lc::MainWindow::on_PBPrintPaymentFileManually_clicked() {
ManualPrintingSetup * manPrint = new ManualPrintingSetup { this } ;
ManualPrintingSetup * manPrint = new ManualPrintingSetup { this } ;
manPrint - > setWindowFlags ( Qt : : Window ) ;
manPrint - > setWindowFlags ( Qt : : Window ) ;
manPrint - > show ( ) ;
manPrint - > show ( ) ;
connect ( manPrint , SIGNAL ( destroyed ( QObject * ) ) ,
connect ( manPrint , SIGNAL ( destroyed ( QObject * ) ) , manPrint ,
manPrint , SLOT ( deleteLater ( ) ) ) ;
SLOT ( deleteLater ( ) ) ) ;
connect ( manPrint , & ManualPrintingSetup : : RequestReceiptsHandler ,
connect ( manPrint , & ManualPrintingSetup : : RequestReceiptsHandler , this ,
this , & MainWindow : : StartReceiptsHandler ) ;
& MainWindow : : StartReceiptsHandler ) ;
}
}
void lc : : MainWindow : : on_PBRunzLeaf_clicked ( ) {
void lc : : MainWindow : : on_PBRunzLeaf_clicked ( ) {
// Check if more than one client is selected and issue a warning message if so
// Check if more than one client is selected and issue a warning message if so
unsigned short int numberOfSelectedClients = 0 ;
unsigned short int numberOfSelectedClients = 0 ;
QModelIndexList activatedItems = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activatedItems =
for ( QModelIndexList : : ConstIterator it = activatedItems . cbegin ( ) ; it ! = activatedItems . cend ( ) ; + + it ) {
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
for ( QModelIndexList : : ConstIterator it = activatedItems . cbegin ( ) ;
it ! = activatedItems . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
+ + numberOfSelectedClients ;
+ + numberOfSelectedClients ;
}
}
}
}
qDebug ( ) < < numberOfSelectedClients < < " clients are selected. " ;
qDebug ( ) < < numberOfSelectedClients < < " clients are selected. " ;
if ( numberOfSelectedClients > 1 ) {
if ( numberOfSelectedClients > 1 ) {
QMessageBox messageBox { QMessageBox : : Information , tr ( " Too many clients selected " ) , tr ( " There are too many clients selected in the table view on the left. Please select only one. " ) , QMessageBox : : Ok , this } ;
QMessageBox messageBox {
QMessageBox : : Information , tr ( " Too many clients selected " ) ,
tr ( " There are too many clients selected in the table view on the left. "
" Please select only one. " ) ,
QMessageBox : : Ok , this } ;
messageBox . exec ( ) ;
messageBox . exec ( ) ;
} else {
} else {
const QString * const fakeName = new QString { ui - > CBClientNames - > currentText ( ) } ;
const QString * const fakeName =
for ( QModelIndexList : : ConstIterator it = activatedItems . cbegin ( ) ; it ! = activatedItems . cend ( ) ; + + it ) {
new QString { ui - > CBClientNames - > currentText ( ) } ;
for ( QModelIndexList : : ConstIterator it = activatedItems . cbegin ( ) ;
it ! = activatedItems . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > StartZLeaf ( fakeName ) ;
client - > StartZLeaf ( fakeName ) ;
}
}
}
}
@ -339,7 +354,8 @@ void lc::MainWindow::on_RBUseLocalUser_toggled(bool checked) {
}
}
void lc : : MainWindow : : SetupWidgets ( ) {
void lc : : MainWindow : : SetupWidgets ( ) {
// Fill the 'CBClientNames' with possible client names and the 'TVClients' with the clients
// Fill the 'CBClientNames' with possible client names and the 'TVClients'
// with the clients
if ( ! settings - > GetClients ( ) . isEmpty ( ) ) {
if ( ! settings - > GetClients ( ) . isEmpty ( ) ) {
valid_items = new QVector < QStandardItem * > ;
valid_items = new QVector < QStandardItem * > ;
valid_items - > reserve ( settings - > GetClients ( ) . size ( ) ) ;
valid_items - > reserve ( settings - > GetClients ( ) . size ( ) ) ;
@ -350,7 +366,9 @@ void lc::MainWindow::SetupWidgets() {
// Check if a client already exists at the given position and skip, if so
// Check if a client already exists at the given position and skip, if so
if ( clients_view_model - > item ( temp_ypos , temp_xpos ) ) {
if ( clients_view_model - > item ( temp_ypos , temp_xpos ) ) {
QMessageBox : : information ( this , tr ( " Double assignment to one position " ) ,
QMessageBox : : information ( this , tr ( " Double assignment to one position " ) ,
tr ( " Two clients where set for the same position, '%1' will be dropped. " ) . arg ( s - > name ) ) ;
tr ( " Two clients where set for the same "
" position, '%1' will be dropped. " )
. arg ( s - > name ) ) ;
continue ;
continue ;
}
}
@ -369,8 +387,11 @@ void lc::MainWindow::SetupWidgets() {
ui - > TVClients - > setModel ( clients_view_model ) ;
ui - > TVClients - > setModel ( clients_view_model ) ;
valid_items - > squeeze ( ) ;
valid_items - > squeeze ( ) ;
} else {
} else {
QMessageBox messageBox { QMessageBox : : Warning , tr ( " Could not construct clients view " ) ,
QMessageBox messageBox {
tr ( " The creation of the clients view failed. Please check the file '/etc/xdg/Labcontrol/Labcontrol.conf'. " ) , QMessageBox : : Ok , this } ;
QMessageBox : : Warning , tr ( " Could not construct clients view " ) ,
tr ( " The creation of the clients view failed. Please check the file "
" '/etc/xdg/Labcontrol/Labcontrol.conf'. " ) ,
QMessageBox : : Ok , this } ;
messageBox . exec ( ) ;
messageBox . exec ( ) ;
ui - > CBClientNames - > setEnabled ( false ) ;
ui - > CBClientNames - > setEnabled ( false ) ;
ui - > GBClientActions - > setEnabled ( false ) ;
ui - > GBClientActions - > setEnabled ( false ) ;
@ -389,12 +410,14 @@ void lc::MainWindow::SetupWidgets() {
ui - > CBWebcamChooser - > addItem ( s ) ;
ui - > CBWebcamChooser - > addItem ( s ) ;
}
}
// Disable the admin tab if the user has no administrative rights and set it up
// Disable the admin tab if the user has no administrative rights and set it
// up
if ( CheckIfUserIsAdmin ( ) ) {
if ( CheckIfUserIsAdmin ( ) ) {
ui - > TAdminActions - > setEnabled ( true ) ;
ui - > TAdminActions - > setEnabled ( true ) ;
ui - > L_AdministrativeRights - > setText ( tr ( " You have administrative rights. " ) ) ;
ui - > L_AdministrativeRights - > setText ( tr ( " You have administrative rights. " ) ) ;
} else {
} 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 ( ) ) {
if ( ! settings - > userNameOnClients . isEmpty ( ) ) {
@ -412,20 +435,28 @@ void lc::MainWindow::SetupWidgets() {
// Fill the CBCommandToExecute QComboBox
// Fill the CBCommandToExecute QComboBox
if ( ! settings - > userNameOnClients . isEmpty ( ) ) {
if ( ! settings - > userNameOnClients . isEmpty ( ) ) {
ui - > CBCommandToExecute - > addItems ( QStringList { } < < " " < < " apt update "
ui - > CBCommandToExecute - > addItems (
< < " apt full-upgrade -y " < < " reboot "
QStringList { } < < " "
< < " rm -rfv /home/ " + settings - > userNameOnClients + " /.mozilla "
< < " apt update "
< < " apt full-upgrade -y "
< < " reboot "
< < " rm -rfv /home/ " + settings - > userNameOnClients +
" /.mozilla "
< < " uname -a " ) ;
< < " uname -a " ) ;
} else {
} else {
ui - > CBCommandToExecute - > addItems ( QStringList { } < < " " < < " apt update "
ui - > CBCommandToExecute - > addItems ( QStringList { } < < " "
< < " apt full-upgrade -y " < < " reboot " < < " uname -a " ) ;
< < " apt update "
< < " apt full-upgrade -y "
< < " reboot "
< < " uname -a " ) ;
}
}
// Disable buttons which are not configured
// Disable buttons which are not configured
// DisableDisfunctionalWidgets();
// DisableDisfunctionalWidgets();
// Set the info text in LInfo on the TInfo tab
// Set the info text in LInfo on the TInfo tab
ui - > LInfo - > setText ( " This is Labcontrol version 2.1.6 \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 "
" Developers \n \n "
" 0day-2016 Henning Prömpers \n "
" 0day-2016 Henning Prömpers \n "
" 2014-2016 Markus Prasser \n "
" 2014-2016 Markus Prasser \n "
@ -440,24 +471,29 @@ void lc::MainWindow::SetupWidgets() {
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \n "
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \n "
" See the GNU General Public License for more details. \n \n "
" See the GNU General Public License for more details. \n \n "
" You should have received a copy of the GNU General Public License \n "
" You should have received a copy of the GNU General Public License \n "
" along with Labcontrol. If not, see <http://www.gnu.org/licenses/>. \n \n \n " ) ;
" along with Labcontrol. If not, see "
" <http://www.gnu.org/licenses/>. \n \n \n " ) ;
}
}
void lc : : MainWindow : : StartReceiptsHandler ( QString argzTreeDataTargetPath ,
void lc : : MainWindow : : StartReceiptsHandler (
bool argReceiptsForLocalClients ,
QString argzTreeDataTargetPath , bool argReceiptsForLocalClients ,
QString argAnonymousReceiptsPlaceholder ,
QString argAnonymousReceiptsPlaceholder , QString argLatexHeaderName ,
QString argLatexHeaderName , QString argDateString ) {
QString argDateString ) {
ReceiptsHandler * recHand = new ReceiptsHandler { argzTreeDataTargetPath ,
ReceiptsHandler * recHand =
new ReceiptsHandler { argzTreeDataTargetPath ,
argReceiptsForLocalClients ,
argReceiptsForLocalClients ,
argAnonymousReceiptsPlaceholder ,
argAnonymousReceiptsPlaceholder ,
argLatexHeaderName , argDateString , this } ;
argLatexHeaderName ,
connect ( recHand , & ReceiptsHandler : : PrintingFinished ,
argDateString ,
recHand , & ReceiptsHandler : : deleteLater ) ;
this } ;
connect ( recHand , & ReceiptsHandler : : PrintingFinished , recHand ,
& ReceiptsHandler : : deleteLater ) ;
}
}
void lc : : MainWindow : : UpdateClientsTableView ( ) {
void lc : : MainWindow : : UpdateClientsTableView ( ) {
for ( auto s : * valid_items ) {
for ( auto s : * valid_items ) {
state_t state = static_cast < Client * > ( s - > data ( Qt : : UserRole ) . value < void * > ( ) ) - > GetClientState ( ) ;
state_t state = static_cast < Client * > ( s - > data ( Qt : : UserRole ) . value < void * > ( ) )
- > GetClientState ( ) ;
switch ( state ) {
switch ( state ) {
case state_t : : RESPONDING :
case state_t : : RESPONDING :
s - > setBackground ( QBrush ( QColor ( 128 , 255 , 128 , 255 ) ) ) ;
s - > setBackground ( QBrush ( QColor ( 128 , 255 , 128 , 255 ) ) ) ;
@ -490,17 +526,21 @@ void lc::MainWindow::UpdateClientsTableView() {
/* Experiment tab functions */
/* Experiment tab functions */
void lc : : MainWindow : : on_PBBoot_clicked ( ) {
void lc : : MainWindow : : on_PBBoot_clicked ( ) {
QModelIndexList activatedItems = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activatedItems =
for ( QModelIndexList : : ConstIterator it = activatedItems . cbegin ( ) ; it ! = activatedItems . cend ( ) ; + + it ) {
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
for ( QModelIndexList : : ConstIterator it = activatedItems . cbegin ( ) ;
it ! = activatedItems . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > Boot ( ) ;
client - > Boot ( ) ;
}
}
}
}
}
}
void lc : : MainWindow : : on_PBChooseFile_clicked ( ) {
void lc : : MainWindow : : on_PBChooseFile_clicked ( ) {
QFileDialog * file_dialog = new QFileDialog { this , tr ( " Choose a file to beam " ) , QDir : : homePath ( ) } ;
QFileDialog * file_dialog =
new QFileDialog { this , tr ( " Choose a file to beam " ) , QDir : : homePath ( ) } ;
file_dialog - > setFileMode ( QFileDialog : : Directory ) ;
file_dialog - > setFileMode ( QFileDialog : : Directory ) ;
file_dialog - > setOption ( QFileDialog : : DontUseNativeDialog , true ) ;
file_dialog - > setOption ( QFileDialog : : DontUseNativeDialog , true ) ;
file_dialog - > setOption ( QFileDialog : : ReadOnly , true ) ;
file_dialog - > setOption ( QFileDialog : : ReadOnly , true ) ;
@ -509,8 +549,7 @@ void lc::MainWindow::on_PBChooseFile_clicked() {
if ( file_dialog - > exec ( ) ) {
if ( file_dialog - > exec ( ) ) {
ui - > LEFilePath - > setText ( file_dialog - > selectedFiles ( ) . at ( 0 ) ) ;
ui - > LEFilePath - > setText ( file_dialog - > selectedFiles ( ) . at ( 0 ) ) ;
qDebug ( ) < < " Chose file " < < ui - > LEFilePath - > text ( ) < < " for beaming. " ;
qDebug ( ) < < " Chose file " < < ui - > LEFilePath - > text ( ) < < " for beaming. " ;
}
} else {
else {
ui - > LEFilePath - > setText ( tr ( " File choosing cancelled " ) ) ;
ui - > LEFilePath - > setText ( tr ( " File choosing cancelled " ) ) ;
qDebug ( ) < < " File choosing cancelled " ;
qDebug ( ) < < " File choosing cancelled " ;
}
}
@ -518,43 +557,56 @@ void lc::MainWindow::on_PBChooseFile_clicked() {
}
}
void lc : : MainWindow : : on_PBBeamFile_clicked ( ) {
void lc : : MainWindow : : on_PBBeamFile_clicked ( ) {
QModelIndexList activatedItems = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activatedItems =
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
const QString fileToBeam { ui - > LEFilePath - > text ( ) } ;
const QString fileToBeam { ui - > LEFilePath - > text ( ) } ;
if ( fileToBeam = = " " ) {
if ( fileToBeam = = " " ) {
QMessageBox : : information ( this , " Upload failed " , " You didn't choose any folder to upload. " ) ;
QMessageBox : : information ( this , " Upload failed " ,
" You didn't choose any folder to upload. " ) ;
} else {
} else {
// Iterate over the selected clients to upload the file
// Iterate over the selected clients to upload the file
for ( QModelIndexList : : ConstIterator it = activatedItems . cbegin ( ) ; it ! = activatedItems . cend ( ) ; + + it ) {
for ( QModelIndexList : : ConstIterator it = activatedItems . cbegin ( ) ;
it ! = activatedItems . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
client - > BeamFile ( fileToBeam , & settings - > pkeyPathUser , & settings - > userNameOnClients ) ;
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > BeamFile ( fileToBeam , & settings - > pkeyPathUser ,
& settings - > userNameOnClients ) ;
}
}
}
}
// Inform the user about the path
// 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! " ) ;
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 ( ) {
void lc : : MainWindow : : on_PBShowORSEE_clicked ( ) { lablib - > ShowOrsee ( ) ; }
lablib - > ShowOrsee ( ) ;
}
void lc : : MainWindow : : on_PBShowPreprints_clicked ( ) {
void lc : : MainWindow : : on_PBShowPreprints_clicked ( ) { lablib - > ShowPreprints ( ) ; }
lablib - > ShowPreprints ( ) ;
}
void lc : : MainWindow : : on_PBShutdown_clicked ( ) {
void lc : : MainWindow : : on_PBShutdown_clicked ( ) {
// Confirmation dialog
// Confirmation dialog
QMessageBox : : StandardButton reply ;
QMessageBox : : StandardButton reply ;
reply = QMessageBox : : question ( this , " Confirm " , " Really shutdown the selected clients? " , QMessageBox : : Yes | QMessageBox : : No ) ;
reply = QMessageBox : : question ( this , " Confirm " ,
" Really shutdown the selected clients? " ,
QMessageBox : : Yes | QMessageBox : : No ) ;
if ( reply = = QMessageBox : : Yes ) {
if ( reply = = QMessageBox : : Yes ) {
QModelIndexList activatedItems = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activatedItems =
for ( QModelIndexList : : ConstIterator it = activatedItems . cbegin ( ) ; it ! = activatedItems . cend ( ) ; + + it ) {
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
for ( QModelIndexList : : ConstIterator it = activatedItems . cbegin ( ) ;
it ! = activatedItems . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
// Do not shut down the server itself
// Do not shut down the server itself
if ( client - > name = = " self " ) {
if ( client - > name = = " self " ) {
QMessageBox : : information ( NULL , " Shutdown canceled " , " It is not allowed to shutdown the server itself via labcontrol! " ) ;
QMessageBox : : information ( NULL , " Shutdown canceled " ,
" It is not allowed to shutdown the server "
" itself via labcontrol! " ) ;
} else {
} else {
client - > Shutdown ( ) ;
client - > Shutdown ( ) ;
}
}
@ -581,29 +633,35 @@ void lc::MainWindow::on_CBWebcamChooser_activated( int argIndex ) {
}
}
}
}
void lc : : MainWindow : : on_PBstartBrowser_clicked ( )
void lc : : MainWindow : : on_PBstartBrowser_clicked ( ) {
{
QString argURL = ui - > LEURL - > text ( ) ;
QString argURL = ui - > LEURL - > text ( ) ;
bool argFullscreen = ui - > CBFullscreen - > checkState ( ) ;
bool argFullscreen = ui - > CBFullscreen - > checkState ( ) ;
QModelIndexList activated_items = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activated_items =
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ; it ! = activated_items . cend ( ) ; + + it ) {
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ;
it ! = activated_items . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > StartClientBrowser ( & argURL , & argFullscreen ) ;
client - > StartClientBrowser ( & argURL , & argFullscreen ) ;
}
}
}
}
}
}
void lc : : MainWindow : : on_PBstopBrowser_clicked ( )
void lc : : MainWindow : : on_PBstopBrowser_clicked ( ) {
{
// Confirmation dialog
// Confirmation dialog
QMessageBox : : StandardButton reply ;
QMessageBox : : StandardButton reply ;
reply = QMessageBox : : question ( this , " Confirm " , " Really kill all selected browser instances? " , QMessageBox : : Yes | QMessageBox : : No ) ;
reply = QMessageBox : : question ( this , " Confirm " ,
" Really kill all selected browser instances? " ,
QMessageBox : : Yes | QMessageBox : : No ) ;
if ( reply = = QMessageBox : : Yes ) {
if ( reply = = QMessageBox : : Yes ) {
QModelIndexList activated_items = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activated_items =
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ; it ! = activated_items . cend ( ) ; + + it ) {
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ;
it ! = activated_items . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > StopClientBrowser ( ) ;
client - > StopClientBrowser ( ) ;
}
}
}
}
@ -613,36 +671,42 @@ void lc::MainWindow::on_PBstopBrowser_clicked()
}
}
// View only VNC button
// View only VNC button
void lc : : MainWindow : : on_PBViewDesktopViewOnly_clicked ( )
void lc : : MainWindow : : on_PBViewDesktopViewOnly_clicked ( ) {
{
QModelIndexList activatedItems =
QModelIndexList activatedItems = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
for ( QModelIndexList : : ConstIterator it = activatedItems . cbegin ( ) ; it ! = activatedItems . cend ( ) ; + + it ) {
for ( QModelIndexList : : ConstIterator it = activatedItems . cbegin ( ) ;
it ! = activatedItems . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > ShowDesktopViewOnly ( ) ;
client - > ShowDesktopViewOnly ( ) ;
}
}
}
}
}
}
// Full control VNC button
// Full control VNC button
void lc : : MainWindow : : on_PBViewDesktopFullControl_clicked ( )
void lc : : MainWindow : : on_PBViewDesktopFullControl_clicked ( ) {
{
QModelIndexList activatedItems =
QModelIndexList activatedItems = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
for ( QModelIndexList : : ConstIterator it = activatedItems . cbegin ( ) ; it ! = activatedItems . cend ( ) ; + + it ) {
for ( QModelIndexList : : ConstIterator it = activatedItems . cbegin ( ) ;
it ! = activatedItems . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > ShowDesktopFullControl ( ) ;
client - > ShowDesktopFullControl ( ) ;
}
}
}
}
}
}
/* Session tab functions */
/* Session tab functions */
void lc : : MainWindow : : on_PBStartzLeaf_clicked ( ) {
void lc : : MainWindow : : on_PBStartzLeaf_clicked ( ) {
QModelIndexList activated_items = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activated_items =
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ; it ! = activated_items . cend ( ) ; + + it ) {
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ;
it ! = activated_items . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > StartZLeaf ( nullptr , ui - > LEzLeafCommandline - > text ( ) ) ;
client - > StartZLeaf ( nullptr , ui - > LEzLeafCommandline - > text ( ) ) ;
}
}
}
}
@ -652,16 +716,17 @@ void lc::MainWindow::on_PBStartLocalzLeaf_clicked() {
LocalzLeafStarter * localzLeafStarter = new LocalzLeafStarter { this } ;
LocalzLeafStarter * localzLeafStarter = new LocalzLeafStarter { this } ;
localzLeafStarter - > setWindowFlags ( Qt : : Window ) ;
localzLeafStarter - > setWindowFlags ( Qt : : Window ) ;
localzLeafStarter - > show ( ) ;
localzLeafStarter - > show ( ) ;
connect ( localzLeafStarter , & LocalzLeafStarter : : LocalzLeafRequested ,
connect ( localzLeafStarter , & LocalzLeafStarter : : LocalzLeafRequested , this ,
this , & MainWindow : : StartLocalzLeaf ) ;
& MainWindow : : StartLocalzLeaf ) ;
connect ( localzLeafStarter , SIGNAL ( LocalzLeafRequested ( QString , QString , int ) ) ,
connect ( localzLeafStarter , SIGNAL ( LocalzLeafRequested ( QString , QString , int ) ) ,
localzLeafStarter , SLOT ( deleteLater ( ) ) ) ;
localzLeafStarter , SLOT ( deleteLater ( ) ) ) ;
}
}
void lc : : MainWindow : : StartLocalzLeaf ( QString argzLeafName , QString argzLeafVersion ,
void lc : : MainWindow : : StartLocalzLeaf ( QString argzLeafName ,
QString argzLeafVersion ,
int argzTreePort ) {
int argzTreePort ) {
if ( settings - > tasksetCmd . isEmpty ( ) | | settings - > wineCmd . isEmpty ( )
if ( settings - > tasksetCmd . isEmpty ( ) | | settings - > wineCmd . isEmpty ( ) | |
| | settings - > zTreeInstDir . isEmpty ( ) ) {
settings - > zTreeInstDir . isEmpty ( ) ) {
return ;
return ;
}
}
@ -669,9 +734,12 @@ void lc::MainWindow::StartLocalzLeaf( QString argzLeafName, QString argzLeafVers
startProc . setProcessEnvironment ( QProcessEnvironment : : systemEnvironment ( ) ) ;
startProc . setProcessEnvironment ( QProcessEnvironment : : systemEnvironment ( ) ) ;
QStringList arguments ;
QStringList arguments ;
arguments < < " 0x00000001 " < < settings - > wineCmd
arguments < < " 0x00000001 " < < settings - > wineCmd
< < QString { settings - > zTreeInstDir + " /zTree_ " + argzLeafVersion + " /zleaf.exe " }
< < QString { settings - > zTreeInstDir + " /zTree_ " + argzLeafVersion +
< < " /server " < < " 127.0.0.1 " < < " /channel "
" /zleaf.exe " }
< < QString : : number ( argzTreePort - 7000 ) < < " /name " < < argzLeafName ;
< < " /server "
< < " 127.0.0.1 "
< < " /channel " < < QString : : number ( argzTreePort - 7000 ) < < " /name "
< < argzLeafName ;
if ( ! settings - > localzLeafSize . isEmpty ( ) ) {
if ( ! settings - > localzLeafSize . isEmpty ( ) ) {
arguments < < " /size " < < QString { settings - > localzLeafSize } ;
arguments < < " /size " < < QString { settings - > localzLeafSize } ;
}
}
@ -680,14 +748,17 @@ void lc::MainWindow::StartLocalzLeaf( QString argzLeafName, QString argzLeafVers
startProc . startDetached ( settings - > tasksetCmd , arguments ) ;
startProc . startDetached ( settings - > tasksetCmd , arguments ) ;
}
}
void lc : : MainWindow : : on_PBStopZtree_clicked ( )
void lc : : MainWindow : : on_PBStopZtree_clicked ( ) {
{
QString program { settings - > killallCmd } ;
QString program { settings - > killallCmd } ;
QStringList arguments ;
QStringList arguments ;
arguments < < " -I " < < " -q " < < " ztree.exe " ;
arguments < < " -I "
< < " -q "
< < " ztree.exe " ;
// Confirmation dialog
// Confirmation dialog
QMessageBox : : StandardButton reply ;
QMessageBox : : StandardButton reply ;
reply = QMessageBox : : question ( this , " Confirm " , " Really kill all z-Tree instances? " , QMessageBox : : Yes | QMessageBox : : No ) ;
reply = QMessageBox : : question ( this , " Confirm " ,
" Really kill all z-Tree instances? " ,
QMessageBox : : Yes | QMessageBox : : No ) ;
if ( reply = = QMessageBox : : Yes ) {
if ( reply = = QMessageBox : : Yes ) {
// Kill all z-Tree processes
// Kill all z-Tree processes
QProcess killLocalzLeafProc ;
QProcess killLocalzLeafProc ;
@ -701,9 +772,9 @@ void lc::MainWindow::on_PBStopZtree_clicked()
}
}
}
}
void lc : : MainWindow : : on_PBRecoverCrashedSession_clicked ( )
void lc : : MainWindow : : on_PBRecoverCrashedSession_clicked ( ) {
{
// TODO: Implement the functionality of the restore session script in here (no
// TODO: Implement the functionality of the restore session script in here (no zenity script)
// zenity script)
QProcess startProc ;
QProcess startProc ;
startProc . setProcessEnvironment ( QProcessEnvironment : : systemEnvironment ( ) ) ;
startProc . setProcessEnvironment ( QProcessEnvironment : : systemEnvironment ( ) ) ;
if ( ! settings - > restartCrashedSessionScript . isEmpty ( ) ) {
if ( ! settings - > restartCrashedSessionScript . isEmpty ( ) ) {
@ -711,8 +782,7 @@ void lc::MainWindow::on_PBRecoverCrashedSession_clicked()
}
}
}
}
void lc : : MainWindow : : on_CBDataTargetPath_activated ( int argIndex )
void lc : : MainWindow : : on_CBDataTargetPath_activated ( int argIndex ) {
{
if ( ! argIndex ) {
if ( ! argIndex ) {
emit RequestNewDataTargetPath ( ) ;
emit RequestNewDataTargetPath ( ) ;
}
}
@ -735,15 +805,13 @@ void lc::MainWindow::GetNewDataTargetPath() {
}
}
// Dummy function for enabling anonymous receipts section in UI
// Dummy function for enabling anonymous receipts section in UI
void lc : : MainWindow : : on_CBReceiptsHeader_activated ( int argIndex )
void lc : : MainWindow : : on_CBReceiptsHeader_activated ( int argIndex ) {
{
Q_UNUSED ( argIndex ) ;
Q_UNUSED ( argIndex ) ;
ui - > CBReceiptsHeader - > setStyleSheet ( " " ) ;
ui - > CBReceiptsHeader - > setStyleSheet ( " " ) ;
}
}
// Anonymous receipients header check box
// Anonymous receipients header check box
void lc : : MainWindow : : on_ChBPrintanonymousreceipts_clicked ( )
void lc : : MainWindow : : on_ChBPrintanonymousreceipts_clicked ( ) {
{
ui - > LReplaceParticipantNames - > setEnabled ( true ) ;
ui - > LReplaceParticipantNames - > setEnabled ( true ) ;
ui - > CBReplaceParticipantNames - > setEnabled ( true ) ;
ui - > CBReplaceParticipantNames - > setEnabled ( true ) ;
}
}
@ -752,16 +820,20 @@ void lc::MainWindow::on_ChBPrintanonymousreceipts_clicked()
void lc : : MainWindow : : on_PBStartSession_clicked ( ) {
void lc : : MainWindow : : on_PBStartSession_clicked ( ) {
if ( ui - > CBzTreeVersion - > currentIndex ( ) = = 0 ) {
if ( ui - > CBzTreeVersion - > currentIndex ( ) = = 0 ) {
QMessageBox : : information ( this , tr ( " No z-Tree version chosen " ) ,
QMessageBox : : information (
this , tr ( " No z-Tree version chosen " ) ,
tr ( " A z-Tree version was not chosen, yet. This setting is "
tr ( " A z-Tree version was not chosen, yet. This setting is "
" mandatory. " ) , QMessageBox : : Ok ) ;
" mandatory. " ) ,
QMessageBox : : Ok ) ;
return ;
return ;
}
}
const QModelIndexList activatedItems = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
const QModelIndexList activatedItems =
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
if ( ! ui - > ChBSessionWithoutAttachedClients - > isChecked ( ) ) {
if ( ! ui - > ChBSessionWithoutAttachedClients - > isChecked ( ) ) {
if ( ! activatedItems . length ( ) ) {
if ( ! activatedItems . length ( ) ) {
QMessageBox : : information ( this , tr ( " Canceled, no clients were chosen " ) ,
QMessageBox : : information (
this , tr ( " Canceled, no clients were chosen " ) ,
tr ( " The start of a new session was canceled. \n "
tr ( " The start of a new session was canceled. \n "
" Some clients have to be selected first or the "
" Some clients have to be selected first or the "
" creation of sessions without clients must be "
" creation of sessions without clients must be "
@ -776,9 +848,11 @@ void lc::MainWindow::on_PBStartSession_clicked() {
}
}
QVector < Client * > associatedClients ;
QVector < Client * > associatedClients ;
for ( auto cit = activatedItems . cbegin ( ) ; cit ! = activatedItems . cend ( ) ; + + cit ) {
for ( auto cit = activatedItems . cbegin ( ) ; cit ! = activatedItems . cend ( ) ;
+ + cit ) {
if ( ( * cit ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * cit ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * cit ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * cit ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > SetSessionPort ( ui - > SBPort - > value ( ) ) ;
client - > SetSessionPort ( ui - > SBPort - > value ( ) ) ;
client - > SetzLeafVersion ( ui - > CBzTreeVersion - > currentText ( ) ) ;
client - > SetzLeafVersion ( ui - > CBzTreeVersion - > currentText ( ) ) ;
associatedClients . append ( client ) ;
associatedClients . append ( client ) ;
@ -793,14 +867,19 @@ void lc::MainWindow::on_PBStartSession_clicked() {
ui - > CBzTreeVersion - > currentText ( ) ) ;
ui - > CBzTreeVersion - > currentText ( ) ) ;
// Display the command line
// Display the command line
QString cmd = this - > lablib - > getzLeafArgs ( ui - > SBPort - > value ( ) , ui - > CBzTreeVersion - > currentText ( ) ) . join ( " " ) ;
QString cmd =
this - > lablib
- > getzLeafArgs ( ui - > SBPort - > value ( ) , ui - > CBzTreeVersion - > currentText ( ) )
. join ( " " ) ;
ui - > LEzLeafCommandline - > setText ( cmd ) ;
ui - > LEzLeafCommandline - > setText ( cmd ) ;
// Start z-Leaf on selected clients if checkbox is activated
// Start z-Leaf on selected clients if checkbox is activated
if ( ui - > ChBautoStartClientZleaf - > isChecked ( ) ) {
if ( ui - > ChBautoStartClientZleaf - > isChecked ( ) ) {
for ( auto cit = activatedItems . cbegin ( ) ; cit ! = activatedItems . cend ( ) ; + + cit ) {
for ( auto cit = activatedItems . cbegin ( ) ; cit ! = activatedItems . cend ( ) ;
+ + cit ) {
if ( ( * cit ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * cit ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * cit ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * cit ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > StartZLeaf ( nullptr , cmd ) ;
client - > StartZLeaf ( nullptr , cmd ) ;
}
}
}
}
@ -813,12 +892,14 @@ void lc::MainWindow::on_PBStartSession_clicked() {
ui - > SBPort - > setValue ( newPort ) ;
ui - > SBPort - > setValue ( newPort ) ;
}
}
void lc : : MainWindow : : on_PBKillzLeaf_clicked ( )
void lc : : MainWindow : : on_PBKillzLeaf_clicked ( ) {
{
QModelIndexList activated_items =
QModelIndexList activated_items = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ; it ! = activated_items . cend ( ) ; + + it ) {
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ;
it ! = activated_items . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > KillZLeaf ( ) ;
client - > KillZLeaf ( ) ;
}
}
}
}
@ -835,10 +916,13 @@ void lc::MainWindow::on_PBOpenFilesystem_clicked() {
userToBeUsed = new QString { settings - > userNameOnClients } ;
userToBeUsed = new QString { settings - > userNameOnClients } ;
}
}
QModelIndexList activated_items = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activated_items =
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ; it ! = activated_items . cend ( ) ; + + it ) {
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ;
it ! = activated_items . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > OpenFilesystem ( userToBeUsed ) ;
client - > OpenFilesystem ( userToBeUsed ) ;
}
}
}
}
@ -859,14 +943,16 @@ void lc::MainWindow::on_PBExecute_clicked() {
}
}
qDebug ( ) < < " Executing command " < < command < < " on chosen clients. " ;
qDebug ( ) < < " Executing command " < < command < < " on chosen clients. " ;
QModelIndexList activated_items = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activated_items =
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ; it ! = activated_items . cend ( ) ; + + it ) {
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ;
it ! = activated_items . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > OpenTerminal ( command , ui - > RBUseUserRoot - > isChecked ( ) ) ;
client - > OpenTerminal ( command , ui - > RBUseUserRoot - > isChecked ( ) ) ;
}
}
}
}
}
}
// Issue open terminal call
// Issue open terminal call
@ -877,27 +963,35 @@ void lc::MainWindow::on_PBOpenTerminal_clicked() {
} else {
} else {
pkeyPathUser = settings - > pkeyPathUser ;
pkeyPathUser = settings - > pkeyPathUser ;
}
}
QModelIndexList activated_items = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activated_items =
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ; it ! = activated_items . cend ( ) ; + + it ) {
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ;
it ! = activated_items . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > OpenTerminal ( QString { } , ui - > RBUseUserRoot - > isChecked ( ) ) ;
client - > OpenTerminal ( QString { } , ui - > RBUseUserRoot - > isChecked ( ) ) ;
}
}
}
}
}
}
// Enable RMB
// Enable RMB
void lc : : MainWindow : : on_PBEnableRMB_clicked ( )
void lc : : MainWindow : : on_PBEnableRMB_clicked ( ) {
{
// Confirmation dialog
// Confirmation dialog
QMessageBox : : StandardButton reply ;
QMessageBox : : StandardButton reply ;
reply = QMessageBox : : question ( this , " Confirm " , " Really enable the right mouse button on selected clients? " , QMessageBox : : Yes | QMessageBox : : No ) ;
reply = QMessageBox : : question (
this , " Confirm " ,
" Really enable the right mouse button on selected clients? " ,
QMessageBox : : Yes | QMessageBox : : No ) ;
if ( reply = = QMessageBox : : Yes ) {
if ( reply = = QMessageBox : : Yes ) {
qDebug ( ) < < " Enabling RMB on chosen clients. " ;
qDebug ( ) < < " Enabling RMB on chosen clients. " ;
QModelIndexList activated_items = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activated_items =
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ; it ! = activated_items . cend ( ) ; + + it ) {
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ;
it ! = activated_items . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > ControlRMB ( true ) ;
client - > ControlRMB ( true ) ;
}
}
}
}
@ -905,17 +999,22 @@ void lc::MainWindow::on_PBEnableRMB_clicked()
}
}
// Disable RMB
// Disable RMB
void lc : : MainWindow : : on_PBDisableRMB_clicked ( )
void lc : : MainWindow : : on_PBDisableRMB_clicked ( ) {
{
// Confirmation dialog
// Confirmation dialog
QMessageBox : : StandardButton reply ;
QMessageBox : : StandardButton reply ;
reply = QMessageBox : : question ( this , " Confirm " , " Really disable the right mouse button on selected clients? " , QMessageBox : : Yes | QMessageBox : : No ) ;
reply = QMessageBox : : question (
this , " Confirm " ,
" Really disable the right mouse button on selected clients? " ,
QMessageBox : : Yes | QMessageBox : : No ) ;
if ( reply = = QMessageBox : : Yes ) {
if ( reply = = QMessageBox : : Yes ) {
qDebug ( ) < < " Disabling RMB on chosen clients. " ;
qDebug ( ) < < " Disabling RMB on chosen clients. " ;
QModelIndexList activated_items = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activated_items =
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ; it ! = activated_items . cend ( ) ; + + it ) {
ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
for ( QModelIndexList : : ConstIterator it = activated_items . cbegin ( ) ;
it ! = activated_items . cend ( ) ; + + it ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
if ( ( * it ) . data ( Qt : : DisplayRole ) . type ( ) ! = 0 ) {
Client * client = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
Client * client =
static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > ControlRMB ( false ) ;
client - > ControlRMB ( false ) ;
}
}
}
}