Got entirely rid of any 'settingsItems' or alias usages

remotes/origin/HEAD
markuspg 10 years ago
parent c522b5168e
commit 18b42ef0af

@ -22,13 +22,6 @@
#include <QMetaType> #include <QMetaType>
enum class settItms_t : unsigned short int { BROWSER_CMD, DVIPS_CMD, FILE_MANAGER, LC_INST_DIR,
LATEX_CMD, LOCAL_ZLEAF_NAME, LPR_CMD, NETSTAT_CMD, NETW_BRDCAST_ADDR,
ORSEE_URL, PING_COMMAND, POSTSCRIPT_VIEWER, PS2PDF_COMMAND,
SSH_KEY_ROOT, SSH_KEY_USER, RCP_CMD, RM_CMD, SERVER_IP, SSH_CMD,
TERM_EMUL_CMD, USER_NAME_ON_CLIENTS, VNC_VIEWER, WAKEONLAN_CMD,
WMCTRL_CMD, XSET_CMD, ZTREE_INST_DIR, SETT_ITMS_QUANT };
//! Opens a terminal for the client //! Opens a terminal for the client
enum class state_t : unsigned short int { enum class state_t : unsigned short int {
//! The client is booting but not yet responding //! The client is booting but not yet responding

@ -29,8 +29,7 @@ lc::Lablib::Lablib( QPlainTextEdit *argDebugMessagesTextEdit, QObject *argParent
debugMessagesTextEdit{ argDebugMessagesTextEdit }, debugMessagesTextEdit{ argDebugMessagesTextEdit },
labSettings{ "Economic Laboratory", "Labcontrol", this }, labSettings{ "Economic Laboratory", "Labcontrol", this },
occupiedPorts{ new QVector< int > }, occupiedPorts{ new QVector< int > },
sessionsModel{ new SessionsModel{ this } }, sessionsModel{ new SessionsModel{ this } }
settingsItems{ new QVector< QString* >{ ( int )settItms_t::SETT_ITMS_QUANT, nullptr } }
{ {
ReadSettings(); ReadSettings();
@ -76,10 +75,6 @@ lc::Lablib::~Lablib () {
delete InstalledZTreeVersions; delete InstalledZTreeVersions;
delete occupiedPorts; delete occupiedPorts;
delete webcams; delete webcams;
for (auto s: *settingsItems) {
delete s;
}
delete settingsItems;
} }
void lc::Lablib::DetectInstalledZTreeVersionsAndLaTeXHeaders() { void lc::Lablib::DetectInstalledZTreeVersionsAndLaTeXHeaders() {
@ -358,8 +353,7 @@ void lc::Lablib::StartNewZTreeInstance() {
sessionsModel->push_back( new Session{ debugMessagesTextEdit, chosenZTreeDataTargetPath, sessionsModel->push_back( new Session{ debugMessagesTextEdit, chosenZTreeDataTargetPath,
chosenZTreePort, chosenZTreeVersion, chosenZTreePort, chosenZTreeVersion,
PrintReceiptsForLocalClients, PrintReceiptsForLocalClients,
anonymousReceiptsPlaceholder, chosenLaTeXHeader, anonymousReceiptsPlaceholder, chosenLaTeXHeader } );
settingsItems } );
occupiedPorts->append( sessionsModel->back()->zTreePort ); occupiedPorts->append( sessionsModel->back()->zTreePort );
} }
catch ( Session::lcDataTargetPathCreationFailed ) { catch ( Session::lcDataTargetPathCreationFailed ) {

@ -182,7 +182,6 @@ private:
QVector< int > *occupiedPorts = nullptr; QVector< int > *occupiedPorts = nullptr;
bool PrintReceiptsForLocalClients = true; bool PrintReceiptsForLocalClients = true;
SessionsModel *sessionsModel = nullptr; //! A derivation from QAbstractTableModel used to store the single Session instances SessionsModel *sessionsModel = nullptr; //! A derivation from QAbstractTableModel used to store the single Session instances
QVector<QString*> *settingsItems = nullptr; //! A QVector storing all simple settings
QString userNameOnServer; //! The user name on the server as extracted from the environment variables QString userNameOnServer; //! The user name on the server as extracted from the environment variables
QStringList *webcams = nullptr; //! A QStringList containing all available stationary webcams in the laboratory QStringList *webcams = nullptr; //! A QStringList containing all available stationary webcams in the laboratory
}; };

@ -17,18 +17,21 @@
* 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 "receipts_handler.h" #include "receipts_handler.h"
#include "settings.h"
extern std::unique_ptr< lc::Settings > settings;
lc::ReceiptsHandler::ReceiptsHandler( QPlainTextEdit *argDebugMessagesTextEdit, lc::ReceiptsHandler::ReceiptsHandler( QPlainTextEdit *argDebugMessagesTextEdit,
const QString &argZTreeDataTargetPath, const QString &argZTreeDataTargetPath,
const bool &argPrintReceiptsForLocalClients, const bool &argPrintReceiptsForLocalClients,
const QString &argAnonymousReceiptsPlaceholder, const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName, const QString &argLatexHeaderName,
const QVector< QString* > * const argSettingsItems,
QObject *argParent ) : QObject *argParent ) :
QObject{ argParent }, QObject{ argParent },
anonymousReceiptsPlaceholder{ new QString{ argAnonymousReceiptsPlaceholder } }, anonymousReceiptsPlaceholder{ new QString{ argAnonymousReceiptsPlaceholder } },
settingsItems{ argSettingsItems },
debugMessagesTextEdit{ argDebugMessagesTextEdit }, debugMessagesTextEdit{ argDebugMessagesTextEdit },
latexHeaderName{ new QString{ argLatexHeaderName } }, latexHeaderName{ new QString{ argLatexHeaderName } },
printReceiptsForLocalClients{ new bool { argPrintReceiptsForLocalClients } }, printReceiptsForLocalClients{ new bool { argPrintReceiptsForLocalClients } },
@ -57,11 +60,9 @@ lc::ReceiptsHandler::ReceiptsHandler( QPlainTextEdit *argDebugMessagesTextEdit,
const bool &argPrintReceiptsForLocalClients, const bool &argPrintReceiptsForLocalClients,
const QString &argAnonymousReceiptsPlaceholder, const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName, const QString &argLatexHeaderName,
const QVector< QString* > * const argSettingsItems,
const QString * const argDateString, QObject *argParent ) : const QString * const argDateString, QObject *argParent ) :
QObject{ argParent }, QObject{ argParent },
anonymousReceiptsPlaceholder{ new QString{ argAnonymousReceiptsPlaceholder } }, anonymousReceiptsPlaceholder{ new QString{ argAnonymousReceiptsPlaceholder } },
settingsItems{ argSettingsItems },
dateString{ new QString{ *argDateString } }, dateString{ new QString{ *argDateString } },
debugMessagesTextEdit{ argDebugMessagesTextEdit }, debugMessagesTextEdit{ argDebugMessagesTextEdit },
latexHeaderName{ new QString{ argLatexHeaderName } }, latexHeaderName{ new QString{ argLatexHeaderName } },
@ -215,7 +216,7 @@ void lc::ReceiptsHandler::CreateReceiptsFromPaymentFile() {
delete latexText; delete latexText;
latexText = nullptr; latexText = nullptr;
receiptsPrinter = new ReceiptsPrinter{ dateString, zTreeDataTargetPath, settingsItems }; receiptsPrinter = new ReceiptsPrinter{ dateString, zTreeDataTargetPath };
receiptsPrinter->start(); receiptsPrinter->start();
connect( receiptsPrinter, &ReceiptsPrinter::PrintingFinished, connect( receiptsPrinter, &ReceiptsPrinter::PrintingFinished,
this, &ReceiptsHandler::DeleteReceiptsPrinterInstance ); this, &ReceiptsHandler::DeleteReceiptsPrinterInstance );
@ -273,10 +274,11 @@ QVector<QString> *lc::ReceiptsHandler::GetParticipantsDataFromPaymentFile() {
QString *lc::ReceiptsHandler::LoadLatexHeader() { QString *lc::ReceiptsHandler::LoadLatexHeader() {
// Prepare all facilities to read the latex header file // Prepare all facilities to read the latex header file
QFile latexHeaderFile( *( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ] + "/" + *latexHeaderName + "_header.tex" ); QFile latexHeaderFile( settings->lcInstDir + "/" + *latexHeaderName + "_header.tex" );
if ( !latexHeaderFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) { if ( !latexHeaderFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "LaTeX header could not be loaded" ), tr( "The LaTeX header at '%1/%2_header.tex' could not be loaded. Receipts printing will not work." ) QMessageBox messageBox{ QMessageBox::Critical, tr( "LaTeX header could not be loaded" ),
.arg( *( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ] ).arg( *latexHeaderName ), QMessageBox::Ok }; tr( "The LaTeX header at '%1/%2_header.tex' could not be loaded. Receipts printing will not work." )
.arg( settings->lcInstDir ).arg( *latexHeaderName ), QMessageBox::Ok };
messageBox.exec(); messageBox.exec();
return nullptr; return nullptr;
} }

@ -47,11 +47,13 @@ class ReceiptsHandler : public QObject {
public: public:
explicit ReceiptsHandler( QPlainTextEdit *argDebugMessagesTextEdit, const QString &argZTreeDataTargetPath, explicit ReceiptsHandler( QPlainTextEdit *argDebugMessagesTextEdit, const QString &argZTreeDataTargetPath,
const bool &argPrintReceiptsForLocalClients, const QString &argAnonymousReceiptsPlaceholder, const bool &argPrintReceiptsForLocalClients,
const QString &argLatexHeaderName, const QVector<QString*> * const argSettingsItems, QObject *argParent = nullptr ); const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName, QObject *argParent = nullptr );
explicit ReceiptsHandler( QPlainTextEdit *argDebugMessagesTextEdit, const QString &argZTreeDataTargetPath, explicit ReceiptsHandler( QPlainTextEdit *argDebugMessagesTextEdit, const QString &argZTreeDataTargetPath,
const bool &argPrintReceiptsForLocalClients, const QString &argAnonymousReceiptsPlaceholder, const bool &argPrintReceiptsForLocalClients,
const QString &argLatexHeaderName, const QVector<QString*> * const argSettingsItems, const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName,
const QString * const argDateString, QObject *argParent = nullptr ); const QString * const argDateString, QObject *argParent = nullptr );
~ReceiptsHandler(); ~ReceiptsHandler();
@ -76,7 +78,6 @@ private:
void MakeReceiptsAnonymous( QVector<paymentEntry_t*> *argDataVector, bool argAlsoAnonymizeClients ); void MakeReceiptsAnonymous( QVector<paymentEntry_t*> *argDataVector, bool argAlsoAnonymizeClients );
const QString * const anonymousReceiptsPlaceholder; //! Placeholder which shall be inserted for participant names if anonymous printing is desired (QString != "") const QString * const anonymousReceiptsPlaceholder; //! Placeholder which shall be inserted for participant names if anonymous printing is desired (QString != "")
const QVector<QString*> * const settingsItems; //! A QVector storing all needed command paths
QString *dateString = nullptr; QString *dateString = nullptr;
QPlainTextEdit * const debugMessagesTextEdit = nullptr; //! A pointer to the programs debug_messages_text_edit to be able to emit debugging messages QPlainTextEdit * const debugMessagesTextEdit = nullptr; //! A pointer to the programs debug_messages_text_edit to be able to emit debugging messages
QString expectedPaymentFileName; //! The name of the expected payment file QString expectedPaymentFileName; //! The name of the expected payment file

@ -17,15 +17,25 @@
* 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 "receiptsprinter.h" #include "receiptsprinter.h"
#include "settings.h"
extern std::unique_ptr< lc::Settings > settings;
lc::ReceiptsPrinter::ReceiptsPrinter( const QString * const argDateString, lc::ReceiptsPrinter::ReceiptsPrinter( const QString * const argDateString,
const QString * const argWorkpath, const QString * const argWorkpath,
const QVector< QString* > * const argSettingsItems,
QObject *argParent ) : QObject *argParent ) :
QThread{ argParent }, QThread{ argParent },
dateString{ argDateString }, dateString{ argDateString },
settingsItems{ argSettingsItems }, dvipsCmd{ settings->dvipsCmd },
latexCmd{ settings->latexCmd },
lprCmd{ settings->lprCmd },
postscriptViewer{ settings->postscriptViewer },
ps2pdfCmd{ settings->ps2pdfCmd },
rmCmd{ settings->rmCmd },
vncViewer{ settings->vncViewer },
workpath{ argWorkpath } workpath{ argWorkpath }
{ {
} }

@ -45,7 +45,7 @@ class ReceiptsPrinter : public QThread {
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
process->setProcessEnvironment( env ); process->setProcessEnvironment( env );
process->setWorkingDirectory( *workpath ); process->setWorkingDirectory( *workpath );
process->start( *( *settingsItems )[ ( int )settItms_t::LATEX_CMD ], arguments ); process->start( latexCmd, arguments );
if( !process->waitForFinished( processTimeOut ) ) { if( !process->waitForFinished( processTimeOut ) ) {
QMessageBox message_box{ QMessageBox::Warning, "dvi creation failed", "The creation of the receipts dvi timed out after 30 seconds. Automatic receipts creation will not work.", QMessageBox::Ok }; QMessageBox message_box{ QMessageBox::Warning, "dvi creation failed", "The creation of the receipts dvi timed out after 30 seconds. Automatic receipts creation will not work.", QMessageBox::Ok };
message_box.exec(); message_box.exec();
@ -63,7 +63,7 @@ class ReceiptsPrinter : public QThread {
process = new QProcess{}; process = new QProcess{};
process->setProcessEnvironment( env ); process->setProcessEnvironment( env );
process->setWorkingDirectory( *workpath ); process->setWorkingDirectory( *workpath );
process->start( *( *settingsItems )[ ( int )settItms_t::DVIPS_CMD ], arguments ); process->start( dvipsCmd, arguments );
if( !process->waitForFinished( processTimeOut ) ) { if( !process->waitForFinished( processTimeOut ) ) {
emit ErrorOccurred(new QString{ "The conversion of the receipts dvi to postscript timed out after 30 seconds. Automatic receipts creation will not work." }, new QString{ "dvi to postscript conversion failed" } ); emit ErrorOccurred(new QString{ "The conversion of the receipts dvi to postscript timed out after 30 seconds. Automatic receipts creation will not work." }, new QString{ "dvi to postscript conversion failed" } );
delete process; delete process;
@ -74,14 +74,14 @@ class ReceiptsPrinter : public QThread {
process = nullptr; process = nullptr;
// Print the postscript file // Print the postscript file
if ( ( *settingsItems )[ ( int )settItms_t::LPR_CMD ] ) { if ( !lprCmd.isEmpty() ) {
arguments = QStringList{}; arguments = QStringList{};
arguments << QString{ *workpath + "/" + *dateString + ".ps" }; arguments << QString{ *workpath + "/" + *dateString + ".ps" };
process = new QProcess{}; process = new QProcess{};
process->setProcessEnvironment( env ); process->setProcessEnvironment( env );
process->setWorkingDirectory( *workpath ); process->setWorkingDirectory( *workpath );
process->start( *( *settingsItems )[ ( int )settItms_t::LPR_CMD ], arguments ); process->start( lprCmd, arguments );
if( !process->waitForFinished( processTimeOut ) ) { if( !process->waitForFinished( processTimeOut ) ) {
emit ErrorOccurred( new QString{ "The receipts postscript file was successfully created but could not be printed." }, new QString{ "Printing failed" } ); emit ErrorOccurred( new QString{ "The receipts postscript file was successfully created but could not be printed." }, new QString{ "Printing failed" } );
} }
@ -90,14 +90,14 @@ class ReceiptsPrinter : public QThread {
} }
// Convert the postscript file to pdf // Convert the postscript file to pdf
if ( ( *settingsItems )[ ( int )settItms_t::PS2PDF_COMMAND ] ) { if ( !ps2pdfCmd.isEmpty() ) {
arguments = QStringList{}; arguments = QStringList{};
arguments << QString{ *workpath + "/" + *dateString + ".ps" } << QString{ *workpath + "/" + *dateString + ".pdf" }; arguments << QString{ *workpath + "/" + *dateString + ".ps" } << QString{ *workpath + "/" + *dateString + ".pdf" };
process = new QProcess{}; process = new QProcess{};
process->setProcessEnvironment( env ); process->setProcessEnvironment( env );
process->setWorkingDirectory( *workpath ); process->setWorkingDirectory( *workpath );
process->start( *( *settingsItems )[ ( int )settItms_t::PS2PDF_COMMAND ], arguments ); process->start( ps2pdfCmd, arguments );
if( !process->waitForFinished( processTimeOut ) ) { if( !process->waitForFinished( processTimeOut ) ) {
emit ErrorOccurred( new QString{ "The receipts were successfully printed but the creation of the PDF file failed." }, new QString{ "PDF creation failed" } ); emit ErrorOccurred( new QString{ "The receipts were successfully printed but the creation of the PDF file failed." }, new QString{ "PDF creation failed" } );
} }
@ -105,21 +105,21 @@ class ReceiptsPrinter : public QThread {
process = nullptr; process = nullptr;
// Show the postscript file if the conversion succeeded // Show the postscript file if the conversion succeeded
if ( ( *settingsItems )[ ( int )settItms_t::POSTSCRIPT_VIEWER ] ) { if ( !postscriptViewer.isEmpty() ) {
arguments = QStringList{}; arguments = QStringList{};
arguments << QString{ *workpath + "/" + *dateString + ".ps" }; arguments << QString{ *workpath + "/" + *dateString + ".ps" };
process = new QProcess{}; process = new QProcess{};
process->setProcessEnvironment( env ); process->setProcessEnvironment( env );
process->setWorkingDirectory( *workpath ); process->setWorkingDirectory( *workpath );
process->startDetached( *( *settingsItems )[ ( int )settItms_t::POSTSCRIPT_VIEWER ], arguments ); process->startDetached( postscriptViewer, arguments );
delete process; delete process;
process = nullptr; process = nullptr;
} }
} }
// Clean up the zTree working path // Clean up the zTree working path
if ( ( *settingsItems )[ ( int )settItms_t::RM_CMD ] ) { if ( !rmCmd.isEmpty() ) {
arguments = QStringList{}; arguments = QStringList{};
arguments << QString{ *workpath + "/" + *dateString + ".aux" } arguments << QString{ *workpath + "/" + *dateString + ".aux" }
<< QString{ *workpath + "/" + *dateString + ".dvi" } << QString{ *workpath + "/" + *dateString + ".dvi" }
@ -129,7 +129,7 @@ class ReceiptsPrinter : public QThread {
process = new QProcess{}; process = new QProcess{};
process->setProcessEnvironment( env ); process->setProcessEnvironment( env );
process->setWorkingDirectory( *workpath ); process->setWorkingDirectory( *workpath );
process->start( *( *settingsItems )[ ( int )settItms_t::RM_CMD ], arguments); process->start( rmCmd, arguments);
if( !process->waitForFinished( processTimeOut ) ) { if( !process->waitForFinished( processTimeOut ) ) {
emit ErrorOccurred(new QString("The cleanup of the temporary files for receipts creation timed out. Some spare files may be left in your zTree working directory."), new QString("Cleanup failed")); emit ErrorOccurred(new QString("The cleanup of the temporary files for receipts creation timed out. Some spare files may be left in your zTree working directory."), new QString("Cleanup failed"));
} }
@ -142,7 +142,6 @@ class ReceiptsPrinter : public QThread {
public: public:
explicit ReceiptsPrinter( const QString * const argDateString, explicit ReceiptsPrinter( const QString * const argDateString,
const QString * const argWorkpath, const QString * const argWorkpath,
const QVector< QString* > * const argSettingsItems,
QObject *argParent = nullptr ); QObject *argParent = nullptr );
signals: signals:
@ -151,8 +150,14 @@ signals:
private: private:
const QString * const dateString; //! The date string contained in the file paths const QString * const dateString; //! The date string contained in the file paths
const QString dvipsCmd;
const QString latexCmd;
const QString lprCmd;
const QString postscriptViewer;
const int processTimeOut = 15000; //! The maximum time which will be granted to a started process const int processTimeOut = 15000; //! The maximum time which will be granted to a started process
const QVector<QString*> * const settingsItems; //! A QVector storing all needed command paths const QString ps2pdfCmd;
const QString rmCmd;
const QString vncViewer;
const QString * const workpath; //! The path were zTree was ordered to store all its data const QString * const workpath; //! The path were zTree was ordered to store all its data
}; };

@ -17,20 +17,23 @@
* 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 "session.h" #include "session.h"
#include "settings.h"
extern std::unique_ptr< lc::Settings > settings;
lc::Session::Session( QPlainTextEdit * const argDebugMessagesTextEdit, lc::Session::Session( QPlainTextEdit * const argDebugMessagesTextEdit,
const QString &argZTreeDataTargetPath, const int argZTreePort, const QString &argZTreeDataTargetPath, const int argZTreePort,
const QString &argZTreeVersionPath, bool argPrintReceiptsForLocalClients, const QString &argZTreeVersionPath, bool argPrintReceiptsForLocalClients,
const QString &argAnonymousReceiptsPlaceholder, const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName, const QString &argLatexHeaderName ):
const QVector<QString*> * const argSettingsItems ):
zTreePort{ argZTreePort }, zTreePort{ argZTreePort },
anonymousReceiptsPlaceholder{ argAnonymousReceiptsPlaceholder }, anonymousReceiptsPlaceholder{ argAnonymousReceiptsPlaceholder },
debugMessagesTextEdit{ argDebugMessagesTextEdit }, debugMessagesTextEdit{ argDebugMessagesTextEdit },
latexHeaderName{ argLatexHeaderName }, latexHeaderName{ argLatexHeaderName },
printReceiptsForLocalClients{ argPrintReceiptsForLocalClients }, printReceiptsForLocalClients{ argPrintReceiptsForLocalClients },
settingsItems{ argSettingsItems },
zTreeDataTargetPath{ argZTreeDataTargetPath }, zTreeDataTargetPath{ argZTreeDataTargetPath },
zTreeVersionPath{ argZTreeVersionPath } zTreeVersionPath{ argZTreeVersionPath }
{ {
@ -45,7 +48,7 @@ lc::Session::Session( QPlainTextEdit * const argDebugMessagesTextEdit,
InitializeClasses(); InitializeClasses();
} }
if ( ( *settingsItems )[ ( int )settItms_t::WMCTRL_CMD ] ) { if ( !settings->wmctrlCmd.isEmpty() ) {
QTimer::singleShot( 5000, this, SLOT( RenameWindow() ) ); QTimer::singleShot( 5000, this, SLOT( RenameWindow() ) );
} }
} }
@ -77,13 +80,14 @@ void lc::Session::InitializeClasses() {
debugMessagesTextEdit->appendPlainText( "[DEBUG] New session's chosen_zTree_data_target_path: " + zTreeDataTargetPath ); debugMessagesTextEdit->appendPlainText( "[DEBUG] New session's chosen_zTree_data_target_path: " + zTreeDataTargetPath );
zTreeInstance = new ZTree{ debugMessagesTextEdit, zTreeDataTargetPath, zTreeInstance = new ZTree{ debugMessagesTextEdit, zTreeDataTargetPath,
zTreePort, zTreeVersionPath, settingsItems }; zTreePort, zTreeVersionPath };
// Only create a 'Receipts_Handler' instance, if all neccessary variables were set // Only create a 'Receipts_Handler' instance, if all neccessary variables were set
if ( latexHeaderName != "None found" && ( *settingsItems )[ ( int )settItms_t::DVIPS_CMD ] && ( *settingsItems )[ ( int )settItms_t::LATEX_CMD ] ) { if ( latexHeaderName != "None found" && !settings->dvipsCmd.isEmpty()
&& !settings->latexCmd.isEmpty() ) {
receiptsHandler = new ReceiptsHandler{ debugMessagesTextEdit, zTreeDataTargetPath, receiptsHandler = new ReceiptsHandler{ debugMessagesTextEdit, zTreeDataTargetPath,
printReceiptsForLocalClients, printReceiptsForLocalClients,
anonymousReceiptsPlaceholder, anonymousReceiptsPlaceholder,
latexHeaderName, settingsItems }; latexHeaderName };
} else { } else {
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] No ReceiptsHandler instance was created." ) ); debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] No ReceiptsHandler instance was created." ) );
} }
@ -99,7 +103,7 @@ void lc::Session::RenameWindow() {
QProcess renameZTreeWindowProcess; QProcess renameZTreeWindowProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
renameZTreeWindowProcess.setProcessEnvironment( env ); renameZTreeWindowProcess.setProcessEnvironment( env );
renameZTreeWindowProcess.startDetached( *( *settingsItems )[ ( int )settItms_t::WMCTRL_CMD ], arguments ); renameZTreeWindowProcess.startDetached( settings->wmctrlCmd, arguments );
debugMessagesTextEdit->appendPlainText( "[DEBUG] Renamed window" ); debugMessagesTextEdit->appendPlainText( "[DEBUG] Renamed window" );

@ -40,7 +40,7 @@ public:
Session( QPlainTextEdit * const argDebugMessagesTextEdit, const QString &argZTreeDataTargetPath, const int argZTreePort, Session( QPlainTextEdit * const argDebugMessagesTextEdit, const QString &argZTreeDataTargetPath, const int argZTreePort,
const QString &argZTreeVersionPath, bool argPrintReceiptsForLocalClients, const QString &argAnonymousReceiptsPlaceholder, const QString &argZTreeVersionPath, bool argPrintReceiptsForLocalClients, const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName, const QVector<QString*> * const argSettingsItems ); const QString &argLatexHeaderName );
~Session(); ~Session();
/*! Returns the data item with the given index /*! Returns the data item with the given index
@ -69,7 +69,6 @@ private:
const QString latexHeaderName; //! The name of the chosen LaTeX header const QString latexHeaderName; //! The name of the chosen LaTeX header
const bool printReceiptsForLocalClients = true; //! True if receipts shall be printed for local clients const bool printReceiptsForLocalClients = true; //! True if receipts shall be printed for local clients
ReceiptsHandler *receiptsHandler = nullptr; //! For automatic creation and printing of the receipts ReceiptsHandler *receiptsHandler = nullptr; //! For automatic creation and printing of the receipts
const QVector<QString*> * const settingsItems; //! A QVector container storing all needed command paths
QString zTreeDataTargetPath; //! The path were the data of this zTree instance's session will be saved QString zTreeDataTargetPath; //! The path were the data of this zTree instance's session will be saved
ZTree *zTreeInstance= nullptr; //! The session's zTree instance ZTree *zTreeInstance= nullptr; //! The session's zTree instance
const QString zTreeVersionPath; //! The path to the version of zTree used by this session's instance const QString zTreeVersionPath; //! The path to the version of zTree used by this session's instance

@ -20,9 +20,6 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) :
lcInstDir{ ReadSettingsItem( "labcontrol_installation_directory", lcInstDir{ ReadSettingsItem( "labcontrol_installation_directory",
"Labcontrol will missbehave with high propability.", "Labcontrol will missbehave with high propability.",
argSettings, true ) }, argSettings, true ) },
localzLeafName{ ReadSettingsItem( "local_zLeaf_name",
"The local zLeaf default name will default to 'local'.",
argSettings, false ) },
lprCmd{ ReadSettingsItem( "lpr_command", lprCmd{ ReadSettingsItem( "lpr_command",
"Receipts printing will not work.", "Receipts printing will not work.",
argSettings, true ) }, argSettings, true ) },
@ -82,7 +79,10 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) :
argSettings, true ) }, argSettings, true ) },
zTreeInstDir{ ReadSettingsItem( "ztree_installation_directory", zTreeInstDir{ ReadSettingsItem( "ztree_installation_directory",
"zTree will not be available.", "zTree will not be available.",
argSettings, true ) } argSettings, true ) },
localzLeafName{ ReadSettingsItem( "local_zLeaf_name",
"The local zLeaf default name will default to 'local'.",
argSettings, false ) }
{ {
} }

@ -17,15 +17,20 @@
* 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 "settings.h"
#include "ztree.h" #include "ztree.h"
extern std::unique_ptr< lc::Settings > settings;
lc::ZTree::ZTree( QPlainTextEdit *argDebugMessagesTextEdit, lc::ZTree::ZTree( QPlainTextEdit *argDebugMessagesTextEdit,
const QString &argZTreeDataTargetPath, const int &argZTreePort, const QString &argZTreeDataTargetPath, const int &argZTreePort,
const QString &argZTreeVersionPath, const QString &argZTreeVersionPath ) {
const QVector<QString*> * const argSettingsItems ) { QString program{ settings->lcInstDir + "/scripts/start_zTree_labcontrol2.sh" };
QString program{ *( *argSettingsItems )[ ( int )settItms_t::LC_INST_DIR ] + "/scripts/start_zTree_labcontrol2.sh" };
QStringList arguments; QStringList arguments;
arguments << *( *argSettingsItems )[ ( int )settItms_t::ZTREE_INST_DIR ] << argZTreeVersionPath << argZTreeDataTargetPath << QString::number( static_cast<int>( argZTreePort ) - 7000 ); arguments << settings->zTreeInstDir << argZTreeVersionPath << argZTreeDataTargetPath
<< QString::number( static_cast< int >( argZTreePort ) - 7000 );
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
zTreeInstance.setProcessEnvironment( env ); zTreeInstance.setProcessEnvironment( env );

@ -38,8 +38,7 @@ class ZTree: public QObject {
public: public:
ZTree( QPlainTextEdit *argDebugMessagesTextEdit, ZTree( QPlainTextEdit *argDebugMessagesTextEdit,
const QString &argZTreeDataTargetPath, const QString &argZTreeDataTargetPath,
const int &argZTreePort, const QString &argZTreeVersionPath, const int &argZTreePort, const QString &argZTreeVersionPath );
const QVector<QString*> * const argSettingsItems );
signals: signals:
void ZTreeClosed(); void ZTreeClosed();

Loading…
Cancel
Save