@ -1,5 +1,5 @@
/*
/*
* Copyright 2014 - 201 6 Markus Prasser
* Copyright 2014 - 201 8 Markus Prasser , Tobias Weiss
*
*
* This file is part of Labcontrol .
* This file is part of Labcontrol .
*
*
@ -17,8 +17,6 @@
* along with Labcontrol . If not , see < http : //www.gnu.org/licenses/>.
* along with Labcontrol . If not , see < http : //www.gnu.org/licenses/>.
*/
*/
# include <memory>
# include <QtGlobal>
# include <QtGlobal>
# include <QDebug>
# include <QDebug>
# include <QInputDialog>
# include <QInputDialog>
@ -28,15 +26,15 @@
# include "manualprintingsetup.h"
# include "manualprintingsetup.h"
# include "Lib/settings.h"
# include "Lib/settings.h"
extern std : : unique_ptr < lc : : Settings > settings ;
lc : : MainWindow : : MainWindow ( Settings * const argSettings ,
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 ) ) ,
settings { argSettings } ,
ui { new Ui : : MainWindow }
ui { new Ui : : MainWindow }
{
{
ui - > setupUi ( this ) ;
ui - > setupUi ( this ) ;
lablib = new Lablib { this } ;
lablib = new Lablib { settings , this } ;
LoadIconPixmaps ( ) ;
LoadIconPixmaps ( ) ;
@ -80,17 +78,20 @@ lc::MainWindow::MainWindow( QWidget *argParent ) :
}
}
}
}
lc : : MainWindow : : ~ MainWindow ( ) {
lc : : MainWindow : : ~ MainWindow ( )
{
delete ui ;
delete ui ;
delete valid_items ;
delete valid_items ;
}
}
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 "
" disabled. You won't be able to perform administrative "
" admin tab will be disabled. You won't be "
" actions but can conduct experiments normally. " ) ,
" able to perform administrative actions "
" but can conduct experiments normally. " ) ,
QMessageBox : : Ok } ;
QMessageBox : : Ok } ;
messageBox . exec ( ) ;
messageBox . exec ( ) ;
return false ;
return false ;
@ -101,7 +102,8 @@ bool lc::MainWindow::CheckIfUserIsAdmin() {
return lablib - > CheckIfUserIsAdmin ( ) ;
return lablib - > CheckIfUserIsAdmin ( ) ;
}
}
void lc : : MainWindow : : DisableDisfunctionalWidgets ( ) {
void lc : : MainWindow : : DisableDisfunctionalWidgets ( )
{
const QStringList & zTreeEntries = settings - > installedZTreeVersions ;
const QStringList & zTreeEntries = settings - > installedZTreeVersions ;
if ( zTreeEntries . isEmpty ( ) ) {
if ( zTreeEntries . isEmpty ( ) ) {
ui - > CBClientNames - > setEnabled ( false ) ;
ui - > CBClientNames - > setEnabled ( false ) ;
@ -258,7 +260,8 @@ void lc::MainWindow::DisableDisfunctionalWidgets() {
}
}
}
}
void lc : : MainWindow : : LoadIconPixmaps ( ) {
void lc : : MainWindow : : LoadIconPixmaps ( )
{
if ( settings - > lcDataDir . isEmpty ( ) ) {
if ( settings - > lcDataDir . isEmpty ( ) ) {
return ;
return ;
}
}
@ -280,7 +283,8 @@ 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 " ;
@ -297,8 +301,9 @@ void lc::MainWindow::on_PBKillLocalzLeaf_clicked() {
qDebug ( ) < < program < < arguments ;
qDebug ( ) < < program < < arguments ;
}
}
void lc : : MainWindow : : on_PBPrintPaymentFileManually_clicked ( ) {
void lc : : MainWindow : : on_PBPrintPaymentFileManually_clicked ( )
ManualPrintingSetup * manPrint = new ManualPrintingSetup { this } ;
{
ManualPrintingSetup * manPrint = new ManualPrintingSetup { settings , this } ;
manPrint - > setWindowFlags ( Qt : : Window ) ;
manPrint - > setWindowFlags ( Qt : : Window ) ;
manPrint - > show ( ) ;
manPrint - > show ( ) ;
connect ( manPrint , SIGNAL ( destroyed ( QObject * ) ) ,
connect ( manPrint , SIGNAL ( destroyed ( QObject * ) ) ,
@ -307,11 +312,13 @@ void lc::MainWindow::on_PBPrintPaymentFileManually_clicked() {
this , & MainWindow : : StartReceiptsHandler ) ;
this , & 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 = 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 ) {
+ + numberOfSelectedClients ;
+ + numberOfSelectedClients ;
}
}
@ -322,7 +329,8 @@ void lc::MainWindow::on_PBRunzLeaf_clicked() {
messageBox . exec ( ) ;
messageBox . exec ( ) ;
} else {
} else {
const QString * const fakeName = new QString { ui - > CBClientNames - > currentText ( ) } ;
const QString * const fakeName = new QString { ui - > CBClientNames - > currentText ( ) } ;
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 - > StartZLeaf ( fakeName ) ;
client - > StartZLeaf ( fakeName ) ;
@ -332,13 +340,15 @@ void lc::MainWindow::on_PBRunzLeaf_clicked() {
}
}
}
}
void lc : : MainWindow : : on_RBUseLocalUser_toggled ( bool checked ) {
void lc : : MainWindow : : on_RBUseLocalUser_toggled ( bool checked )
{
if ( checked ) {
if ( checked ) {
qDebug ( ) < < " 'RBUseLocalUser' got toggled. " ;
qDebug ( ) < < " 'RBUseLocalUser' got toggled. " ;
}
}
}
}
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 * > ;
@ -446,18 +456,23 @@ void lc::MainWindow::SetupWidgets() {
void lc : : MainWindow : : StartReceiptsHandler ( QString argzTreeDataTargetPath ,
void lc : : MainWindow : : StartReceiptsHandler ( QString argzTreeDataTargetPath ,
bool argReceiptsForLocalClients ,
bool argReceiptsForLocalClients ,
QString argAnonymousReceiptsPlaceholder ,
QString argAnonymousReceiptsPlaceholder ,
QString argLatexHeaderName , QString argDateString ) {
QString argLatexHeaderName ,
ReceiptsHandler * recHand = new ReceiptsHandler { argzTreeDataTargetPath ,
QString argDateString )
{
const auto recHand = new ReceiptsHandler { settings , argzTreeDataTargetPath ,
argReceiptsForLocalClients ,
argReceiptsForLocalClients ,
argAnonymousReceiptsPlaceholder ,
argAnonymousReceiptsPlaceholder ,
argLatexHeaderName , argDateString , this } ;
argLatexHeaderName ,
argDateString , this } ;
connect ( recHand , & ReceiptsHandler : : PrintingFinished ,
connect ( recHand , & ReceiptsHandler : : PrintingFinished ,
recHand , & ReceiptsHandler : : deleteLater ) ;
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 ) ) ) ;
@ -489,9 +504,11 @@ 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 = 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 - > Boot ( ) ;
client - > Boot ( ) ;
@ -499,7 +516,8 @@ void lc::MainWindow::on_PBBoot_clicked() {
}
}
}
}
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 ) ;
@ -509,52 +527,62 @@ 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 " ;
}
}
delete file_dialog ;
delete file_dialog ;
}
}
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 = static_cast < Client * > ( ( * it ) . data ( Qt : : UserRole ) . value < void * > ( ) ) ;
client - > BeamFile ( fileToBeam , & settings - > pkeyPathUser , & settings - > userNameOnClients ) ;
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 = 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 * > ( ) ) ;
// 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 ( ) ;
}
}
@ -565,7 +593,8 @@ void lc::MainWindow::on_PBShutdown_clicked() {
}
}
}
}
void lc : : MainWindow : : on_CBWebcamChooser_activated ( int argIndex ) {
void lc : : MainWindow : : on_CBWebcamChooser_activated ( int argIndex )
{
if ( argIndex ! = 0 ) {
if ( argIndex ! = 0 ) {
QString program { settings - > webcamDisplayCmd } ;
QString program { settings - > webcamDisplayCmd } ;
QStringList arguments ;
QStringList arguments ;
@ -586,7 +615,8 @@ 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 = 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 - > StartClientBrowser ( & argURL , & argFullscreen ) ;
client - > StartClientBrowser ( & argURL , & argFullscreen ) ;
@ -598,10 +628,12 @@ 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 = 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 - > StopClientBrowser ( ) ;
client - > StopClientBrowser ( ) ;
@ -616,7 +648,8 @@ void lc::MainWindow::on_PBstopBrowser_clicked()
void lc : : MainWindow : : on_PBViewDesktopViewOnly_clicked ( )
void lc : : MainWindow : : on_PBViewDesktopViewOnly_clicked ( )
{
{
QModelIndexList activatedItems = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activatedItems = 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 ( ) ;
@ -628,7 +661,8 @@ void lc::MainWindow::on_PBViewDesktopViewOnly_clicked()
void lc : : MainWindow : : on_PBViewDesktopFullControl_clicked ( )
void lc : : MainWindow : : on_PBViewDesktopFullControl_clicked ( )
{
{
QModelIndexList activatedItems = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activatedItems = 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 ( ) ;
@ -638,9 +672,11 @@ void lc::MainWindow::on_PBViewDesktopFullControl_clicked()
/* 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 = 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 - > StartZLeaf ( nullptr , ui - > LEzLeafCommandline - > text ( ) ) ;
client - > StartZLeaf ( nullptr , ui - > LEzLeafCommandline - > text ( ) ) ;
@ -648,8 +684,9 @@ void lc::MainWindow::on_PBStartzLeaf_clicked() {
}
}
}
}
void lc : : MainWindow : : on_PBStartLocalzLeaf_clicked ( ) {
void lc : : MainWindow : : on_PBStartLocalzLeaf_clicked ( )
LocalzLeafStarter * localzLeafStarter = new LocalzLeafStarter { this } ;
{
LocalzLeafStarter * localzLeafStarter = new LocalzLeafStarter { settings , this } ;
localzLeafStarter - > setWindowFlags ( Qt : : Window ) ;
localzLeafStarter - > setWindowFlags ( Qt : : Window ) ;
localzLeafStarter - > show ( ) ;
localzLeafStarter - > show ( ) ;
connect ( localzLeafStarter , & LocalzLeafStarter : : LocalzLeafRequested ,
connect ( localzLeafStarter , & LocalzLeafStarter : : LocalzLeafRequested ,
@ -659,7 +696,8 @@ void lc::MainWindow::on_PBStartLocalzLeaf_clicked() {
}
}
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 ;
@ -687,7 +725,8 @@ void lc::MainWindow::on_PBStopZtree_clicked()
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 ;
@ -721,7 +760,8 @@ void lc::MainWindow::on_CBDataTargetPath_activated( int argIndex )
}
}
// Open a folder chooser dialog for zTree data path
// Open a folder chooser dialog for zTree data path
void lc : : MainWindow : : GetNewDataTargetPath ( ) {
void lc : : MainWindow : : GetNewDataTargetPath ( )
{
QFileDialog fileDialog { this } ;
QFileDialog fileDialog { this } ;
fileDialog . setFileMode ( QFileDialog : : Directory ) ;
fileDialog . setFileMode ( QFileDialog : : Directory ) ;
fileDialog . setDirectory ( QDir : : homePath ( ) ) ;
fileDialog . setDirectory ( QDir : : homePath ( ) ) ;
@ -749,7 +789,8 @@ void lc::MainWindow::on_ChBPrintanonymousreceipts_clicked()
}
}
// Start session button actions
// Start session button actions
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 " ) ,
@ -793,7 +834,8 @@ 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
@ -816,7 +858,8 @@ void lc::MainWindow::on_PBStartSession_clicked() {
void lc : : MainWindow : : on_PBKillzLeaf_clicked ( )
void lc : : MainWindow : : on_PBKillzLeaf_clicked ( )
{
{
QModelIndexList activated_items = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activated_items = 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 ( ) ;
@ -826,7 +869,8 @@ void lc::MainWindow::on_PBKillzLeaf_clicked()
/* Admin tab functions */
/* Admin tab functions */
void lc : : MainWindow : : on_PBOpenFilesystem_clicked ( ) {
void lc : : MainWindow : : on_PBOpenFilesystem_clicked ( )
{
// Determine the correct user to be used
// Determine the correct user to be used
QString * userToBeUsed = nullptr ;
QString * userToBeUsed = nullptr ;
if ( ui - > RBUseUserRoot - > isChecked ( ) ) {
if ( ui - > RBUseUserRoot - > isChecked ( ) ) {
@ -836,7 +880,8 @@ void lc::MainWindow::on_PBOpenFilesystem_clicked() {
}
}
QModelIndexList activated_items = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activated_items = 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 - > OpenFilesystem ( userToBeUsed ) ;
client - > OpenFilesystem ( userToBeUsed ) ;
@ -845,7 +890,8 @@ void lc::MainWindow::on_PBOpenFilesystem_clicked() {
delete userToBeUsed ;
delete userToBeUsed ;
}
}
void lc : : MainWindow : : on_PBExecute_clicked ( ) {
void lc : : MainWindow : : on_PBExecute_clicked ( )
{
// Get the command to be executed ...
// Get the command to be executed ...
QString command = ui - > CBCommandToExecute - > currentText ( ) ;
QString command = ui - > CBCommandToExecute - > currentText ( ) ;
@ -860,7 +906,8 @@ 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 = 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 - > OpenTerminal ( command , ui - > RBUseUserRoot - > isChecked ( ) ) ;
client - > OpenTerminal ( command , ui - > RBUseUserRoot - > isChecked ( ) ) ;
@ -870,7 +917,8 @@ void lc::MainWindow::on_PBExecute_clicked() {
}
}
// Issue open terminal call
// Issue open terminal call
void lc : : MainWindow : : on_PBOpenTerminal_clicked ( ) {
void lc : : MainWindow : : on_PBOpenTerminal_clicked ( )
{
QString pkeyPathUser ;
QString pkeyPathUser ;
if ( ui - > RBUseUserRoot - > isChecked ( ) ) {
if ( ui - > RBUseUserRoot - > isChecked ( ) ) {
pkeyPathUser = settings - > pkeyPathRoot ;
pkeyPathUser = settings - > pkeyPathRoot ;
@ -878,7 +926,8 @@ void lc::MainWindow::on_PBOpenTerminal_clicked() {
pkeyPathUser = settings - > pkeyPathUser ;
pkeyPathUser = settings - > pkeyPathUser ;
}
}
QModelIndexList activated_items = ui - > TVClients - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndexList activated_items = 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 - > OpenTerminal ( QString { } , ui - > RBUseUserRoot - > isChecked ( ) ) ;
client - > OpenTerminal ( QString { } , ui - > RBUseUserRoot - > isChecked ( ) ) ;