From e1561ece2cc4ad8c1bfb52812cb96953665f491e Mon Sep 17 00:00:00 2001 From: markuspg Date: Sat, 8 Oct 2016 13:32:15 +0200 Subject: [PATCH] Merged client creation and more settings in 'lc::Settings' --- src/Lib/client.cpp | 7 +- src/Lib/client.h | 3 +- src/Lib/clienthelpnotificationserver.cpp | 8 +- src/Lib/clienthelpnotificationserver.h | 4 +- src/Lib/lablib.cpp | 100 ++-------------------- src/Lib/lablib.h | 19 ----- src/Lib/settings.cpp | 101 ++++++++++++++++++++++- src/Lib/settings.h | 11 +++ src/mainwindow.cpp | 21 ++--- src/sessionstarter.cpp | 10 +-- src/sessionstarter.h | 5 +- src/sessionstarter.ui | 3 + 12 files changed, 141 insertions(+), 151 deletions(-) diff --git a/src/Lib/client.cpp b/src/Lib/client.cpp index 1f614c6..7b6311a 100644 --- a/src/Lib/client.cpp +++ b/src/Lib/client.cpp @@ -27,7 +27,8 @@ extern std::unique_ptr< lc::Settings > settings; lc::Client::Client( const QString &argIP, const QString &argMAC, const QString &argName, - unsigned short int argXPosition, unsigned short int argYPosition ): + unsigned short int argXPosition, unsigned short int argYPosition, + const QString &argPingCmd ): ip{ argIP }, mac{ argMAC }, name{ argName }, @@ -37,8 +38,8 @@ lc::Client::Client( const QString &argIP, const QString &argMAC, const QString & { qRegisterMetaType< state_t >( "STATE" ); - if ( !settings->pingCmd.isEmpty() ) { - pinger = new ClientPinger{ ip, settings->pingCmd }; + if ( !argPingCmd.isEmpty() ) { + pinger = new ClientPinger{ ip, argPingCmd }; pinger->moveToThread( &pingerThread ); connect( &pingerThread, &QThread::finished, pinger, &QObject::deleteLater ); diff --git a/src/Lib/client.h b/src/Lib/client.h index 9502f4d..fe6a0bb 100644 --- a/src/Lib/client.h +++ b/src/Lib/client.h @@ -60,7 +60,8 @@ public: * \param argYPosition The client's y coordinate in the lab's grid */ Client( const QString &argIP, const QString &argMAC, const QString &argName, - unsigned short int argXPosition, unsigned short int argYPosition ); + unsigned short int argXPosition, unsigned short int argYPosition, + const QString &argPingCmd ); //! Client's destructor ~Client(); //! Beams the chosen file to the client's 'media4ztree' directory diff --git a/src/Lib/clienthelpnotificationserver.cpp b/src/Lib/clienthelpnotificationserver.cpp index 23be155..40938c0 100644 --- a/src/Lib/clienthelpnotificationserver.cpp +++ b/src/Lib/clienthelpnotificationserver.cpp @@ -24,10 +24,8 @@ extern std::unique_ptr< lc::Settings > settings; -lc::ClientHelpNotificationServer::ClientHelpNotificationServer( const QMap< QString, Client* > * const argClientIPsToClientsMap, - QObject *argParent ) : +lc::ClientHelpNotificationServer::ClientHelpNotificationServer( QObject *argParent ) : QObject{ argParent }, - clientIPsToClientsMap{ argClientIPsToClientsMap }, hostAddress{ settings->serverIP } { QNetworkConfigurationManager manager; @@ -94,8 +92,8 @@ void lc::ClientHelpNotificationServer::SendReply() { QString peerAddress = clientConnection->peerAddress().toString(); QString peerName; bool unknownClient = false; - if ( clientIPsToClientsMap->contains( peerAddress ) ) { - peerName = ( *clientIPsToClientsMap )[ peerAddress ]->name; + if ( settings->clIPsToClMap.contains( peerAddress ) ) { + peerName = settings->clIPsToClMap[ peerAddress ]->name; } else { unknownClient = true; } diff --git a/src/Lib/clienthelpnotificationserver.h b/src/Lib/clienthelpnotificationserver.h index a7f7c64..d46e9d7 100644 --- a/src/Lib/clienthelpnotificationserver.h +++ b/src/Lib/clienthelpnotificationserver.h @@ -32,15 +32,13 @@ namespace lc { class ClientHelpNotificationServer : public QObject { Q_OBJECT public: - explicit ClientHelpNotificationServer( const QMap< QString, Client* > * const argClientIPsToClientsMap, - QObject *argParent = nullptr ); + explicit ClientHelpNotificationServer( QObject *argParent = nullptr ); signals: public slots: private: - const QMap< QString, Client* > * const clientIPsToClientsMap = nullptr; QTcpServer *helpMessageServer = nullptr; const QHostAddress hostAddress; QNetworkSession *networkSession = nullptr; diff --git a/src/Lib/lablib.cpp b/src/Lib/lablib.cpp index a7f5dd8..817c07b 100644 --- a/src/Lib/lablib.cpp +++ b/src/Lib/lablib.cpp @@ -26,13 +26,14 @@ lc::Lablib::Lablib( QObject *argParent ) : QObject{ argParent }, - clientIPsToClientsMap{ new QMap< QString, Client* > }, labSettings{ "Economic Laboratory", "Labcontrol", this }, occupiedPorts{ new QVector< int > }, sessionsModel{ new SessionsModel{ this } } { - ReadSettings(); - + for ( const auto &s : settings->GetClients() ) { + connect( this, &Lablib::ZLEAF_RUNNING, + s, &Client::SetStateToZLEAF_RUNNING ); + } DetectInstalledZTreeVersionsAndLaTeXHeaders(); // Initialize all 'netstat' query mechanisms @@ -51,8 +52,7 @@ lc::Lablib::Lablib( QObject *argParent ) : // Initialize the server for client help requests retrieval if ( settings->clientHelpNotificationServerPort && !settings->serverIP.isEmpty() ) { - clientHelpNotificationServer = new ClientHelpNotificationServer{ clientIPsToClientsMap, - this }; + clientHelpNotificationServer = new ClientHelpNotificationServer{ this }; } } @@ -63,12 +63,6 @@ lc::Lablib::~Lablib () { } netstatThread.quit(); netstatThread.wait(); - if ( clients ) { - for ( QVector< Client* >::iterator it = clients->begin(); it != clients->end(); ++it ) { - delete *it; - } - } - delete clients; delete occupiedPorts; } @@ -97,90 +91,6 @@ void lc::Lablib::GotNetstatQueryResult( QStringList *argActiveZLeafConnections ) delete argActiveZLeafConnections; } -void lc::Lablib::ReadSettings() { - // Get the client quantity to check the value lists for clients creation for correct length - int clientQuantity = 0; - if ( !labSettings.contains("client_quantity" ) ) { - QMessageBox messageBox{ QMessageBox::Information, tr( "'client_quantity' not set" ), - tr( "The 'client_quantity' variable was not set. The client quantity will be guessed by the amount of client ips set in 'client_ips'." ) }; - messageBox.exec(); - qDebug() << "'client_quantity' was not set. The client quantity will be guessed" - " by the amount of client IPs set in 'client_ips'."; - clientQuantity = labSettings.value( "client_ips", "" ).toString().split( '/', QString::SkipEmptyParts, Qt::CaseSensitive ).length(); - qDebug() << "'clientQuantity':" << clientQuantity; - } else { - clientQuantity = labSettings.value( "client_quantity" ).toInt(); - qDebug() << "'clientQuantity':" << clientQuantity; - } - - // Create all the clients in the lab - QStringList clientIPs = labSettings.value( "client_ips" ).toString().split( '|', QString::SkipEmptyParts, Qt::CaseSensitive ); - if ( clientIPs.length() != clientQuantity ) { - QMessageBox messageBox{ QMessageBox::Critical, tr( "Wrong client ip quantity" ), - tr( "The quantity of client ips does not match the client quantity. Client creation will fail. No clients will be available for interaction." ), QMessageBox::Ok }; - messageBox.exec(); - return; - } - qDebug() << "Client IPs:" << clientIPs.join( " / " ); - QStringList clientMACs = labSettings.value( "client_macs" ).toString().split( '|', QString::SkipEmptyParts, Qt::CaseSensitive ); - if ( clientMACs.length() != clientQuantity ) { - QMessageBox messageBox{ QMessageBox::Critical, tr( "Wrong client mac quantity" ), - tr( "The quantity of client macs does not match the client quantity. Client creation will fail. No clients will be available for interaction." ), QMessageBox::Ok }; - messageBox.exec(); - return; - } - qDebug() << "Client MACs:" << clientMACs.join( " / " ); - QStringList clientNames = labSettings.value( "client_names" ).toString().split( '|', QString::SkipEmptyParts, Qt::CaseSensitive ); - if ( clientNames.length() != clientQuantity ) { - QMessageBox messageBox{ QMessageBox::Critical, tr( "Wrong client name quantity" ), - tr( "The quantity of client names does not match the client quantity. Client creation will fail. No clients will be available for interaction." ), QMessageBox::Ok }; - messageBox.exec(); - return; - } - qDebug() << "Client names:" << clientNames.join( " / " ); - QStringList clientXPositions = labSettings.value( "client_xpos" ).toString().split( '|', QString::SkipEmptyParts, Qt::CaseSensitive ); - if ( clientXPositions.length() != clientQuantity ) { - QMessageBox messageBox{ QMessageBox::Critical, tr( "Wrong client x positions quantity" ), - tr( "The quantity of client x positions does not match the client quantity. Client creation will fail. No clients will be available for interaction." ), QMessageBox::Ok }; - messageBox.exec(); - return; - } - qDebug() << "clientXPositions:" << clientXPositions.join( " / " ); - QStringList clientYPositions = labSettings.value( "client_ypos" ).toString().split( '|', QString::SkipEmptyParts, Qt::CaseSensitive ); - if ( clientYPositions.length() != clientQuantity ) { - QMessageBox messageBox{ QMessageBox::Critical, tr( "Wrong client y positions quantity" ), - tr( "The quantity of client y positions does not match the client quantity. Client creation will fail. No clients will be available for interaction." ), QMessageBox::Ok }; - messageBox.exec(); - return; - } - qDebug() << "clientYPositions:" << clientYPositions.join( " / " ); - - clients = new QVector< Client* >; - for ( int i = 0; i < clientQuantity; i++ ) { - clients->append( new Client{ clientIPs[ i ], clientMACs[ i ], clientNames[ i ], - clientXPositions[ i ].toUShort(), - clientYPositions[ i ].toUShort() } ); - - // Add an corresponding entry to the 'client_ips_to_clients_map' std::map - ( *clientIPsToClientsMap )[ clients->last()->ip ] = clients->last(); - - // Get the address of the Client instance in RAM for display - const void *clientPointerAddress = static_cast< const void* >( ( *clientIPsToClientsMap )[ clients->last()->ip ] ); - - // Connect the 'Client' instance to the 'ZLEAF_RUNNING(QString client_ip)' signal - connect( this, &Lablib::ZLEAF_RUNNING, - clients->last(), &Client::SetStateToZLEAF_RUNNING ); - - qDebug() << "Added" << clients->last()->name - << "to 'clientIPsToClientsMap':" << clientPointerAddress; - } -} - -void lc::Lablib::SetPrintReceiptsForLocalClients( const bool &argPrintReceiptsForLocalClients ) { - PrintReceiptsForLocalClients = argPrintReceiptsForLocalClients; - qDebug() << "Set 'PrintReceiptsForLocalClients' to:" << PrintReceiptsForLocalClients; -} - void lc::Lablib::ShowOrsee() { QProcess showOrseeProcess; QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); diff --git a/src/Lib/lablib.h b/src/Lib/lablib.h index 431bc86..72225c6 100644 --- a/src/Lib/lablib.h +++ b/src/Lib/lablib.h @@ -71,16 +71,6 @@ public: * \return True, if the account has administrative rights; false, otherwise */ bool CheckIfUserIsAdmin() const; - /** Returns a pointer to the clients known to Lablib - * - * @return A QVector of pointers to the Client class instances - */ - QVector< Client* > *GetClients () const { return clients; } - /** Returns a pointer to the QString storing the default name for local zLeafs - * - * @return A pointer to the QString storing the default name for local zLeafs - */ - QString GetLocalZLeafDefaultName() const { return settings->GetLocalzLeafName(); } /** Returns a pointer to a QVector containing all by sessions occupied ports * * @return A pointer to a QVector containing all occupied ports @@ -91,17 +81,11 @@ public: * @return A pointer to the QAbstractTableModel storing the Session instances */ SessionsModel *GetSessionsModel () const { return sessionsModel; } - /** Returns true if receipts for local clients shall be printed - * - * @return True if receipts for local clients shall be printed - */ - bool GetPrintReceiptsForLocalClients() const { return PrintReceiptsForLocalClients; } //! Sets the default name of local zLeaf instances /** * @param argName The default name local zLeaf instances shall have */ void SetLocalZLeafDefaultName( const QString &argName ); - void SetPrintReceiptsForLocalClients( const bool &argPrintReceiptsForLocalClients ); void ShowOrsee(); void ShowPreprints(); @@ -125,14 +109,11 @@ private: void ReadSettings(); ClientHelpNotificationServer *clientHelpNotificationServer = nullptr; //! A server to retrieve help requests from the clients - QMap< QString, Client* > * clientIPsToClientsMap = nullptr; //! A map container storing ip-client pairs - QVector *clients = nullptr; //! A QVector storing pointers to all Client instances QSettings labSettings; NetstatAgent *netstatAgent = nullptr; //! Tries to detect active zLeaf connections from the clients QThread netstatThread; QTimer *netstatTimer = nullptr; //! A timer for regular execution of the NetstatAgent instance's request mechanism QVector< int > *occupiedPorts = nullptr; - bool PrintReceiptsForLocalClients = true; SessionsModel *sessionsModel = nullptr; //! A derivation from QAbstractTableModel used to store the single Session instances }; diff --git a/src/Lib/settings.cpp b/src/Lib/settings.cpp index 75e2ccb..688fa27 100644 --- a/src/Lib/settings.cpp +++ b/src/Lib/settings.cpp @@ -22,6 +22,7 @@ #include #include +#include "client.h" #include "settings.h" lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) : @@ -122,9 +123,11 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) : installedZTreeVersions{ DetectInstalledzTreeVersions() }, clientHelpNotificationServerPort{ GetClientHelpNotificationServerPort( argSettings ) }, chosenzTreePort{ GetInitialPort( argSettings ) }, + clients{ CreateClients( argSettings, pingCmd ) }, localzLeafName{ ReadSettingsItem( "local_zLeaf_name", "The local zLeaf default name will default to 'local'.", - argSettings, false ) } + argSettings, false ) }, + clIPsToClMap{ CreateClIPsToClMap( clients ) } { // Let the local zLeaf name default to 'local' if none was given in the settings if ( localzLeafName.isEmpty() ) { @@ -139,6 +142,12 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) : qDebug() << "Detected z-Tree versions" << installedZTreeVersions; } +lc::Settings::~Settings() { + for ( QVector< Client* >::iterator it = clients.begin(); it != clients.end(); ++it ) { + delete *it; + } +} + bool lc::Settings::CheckPathAndComplain( const QString &argPath, const QString &argVariableName, const QString &argMessage ) { if ( !QFile::exists( argPath ) ) { @@ -150,6 +159,96 @@ bool lc::Settings::CheckPathAndComplain( const QString &argPath, const QString & return true; } +QVector< lc::Client* > lc::Settings::CreateClients( const QSettings &argSettings, + const QString &argPingCmd ) { + QVector< Client* > tempClientVec; + + // Get the client quantity to check the value lists for clients creation for correct length + int clientQuantity = 0; + if ( !argSettings.contains("client_quantity" ) ) { + qWarning() << "'client_quantity' was not set. The client quantity will be guessed" + " by the amount of client IPs set in 'client_ips'."; + clientQuantity = argSettings.value( "client_ips", "" ).toString() + .split( '/', QString::SkipEmptyParts, Qt::CaseSensitive ).length(); + qDebug() << "'clientQuantity':" << clientQuantity; + } else { + bool ok = true; + clientQuantity = argSettings.value( "client_quantity" ).toInt( &ok ); + if ( !ok ) { + qWarning() << "The variable 'client_quantity' was not convertible to int"; + } + qDebug() << "'clientQuantity':" << clientQuantity; + } + + // Create all the clients in the lab + QStringList clientIPs = argSettings.value( "client_ips" ).toString() + .split( '|', QString::SkipEmptyParts, Qt::CaseSensitive ); + if ( clientIPs.length() != clientQuantity ) { + qWarning() << "The quantity of client ips does not match the client quantity. Client" + " creation will fail. No clients will be available for interaction."; + return tempClientVec; + } + qDebug() << "Client IPs:" << clientIPs.join( " / " ); + + QStringList clientMACs = argSettings.value( "client_macs" ).toString() + .split( '|', QString::SkipEmptyParts, Qt::CaseSensitive ); + if ( clientMACs.length() != clientQuantity ) { + qWarning() << "The quantity of client macs does not match the client quantity. Client" + " creation will fail. No clients will be available for interaction."; + return tempClientVec; + } + qDebug() << "Client MACs:" << clientMACs.join( " / " ); + + QStringList clientNames = argSettings.value( "client_names" ).toString() + .split( '|', QString::SkipEmptyParts, Qt::CaseSensitive ); + if ( clientNames.length() != clientQuantity ) { + qWarning() << "The quantity of client names does not match the client quantity. Client" + " creation will fail. No clients will be available for interaction."; + return tempClientVec; + } + qDebug() << "Client names:" << clientNames.join( " / " ); + + QStringList clientXPositions = argSettings.value( "client_xpos" ).toString() + .split( '|', QString::SkipEmptyParts, Qt::CaseSensitive ); + if ( clientXPositions.length() != clientQuantity ) { + qWarning() << "The quantity of client x positions does not match the client quantity." + " Client creation will fail. No clients will be available for interaction."; + return tempClientVec; + } + qDebug() << "clientXPositions:" << clientXPositions.join( " / " ); + + QStringList clientYPositions = argSettings.value( "client_ypos" ).toString() + .split( '|', QString::SkipEmptyParts, Qt::CaseSensitive ); + if ( clientYPositions.length() != clientQuantity ) { + qWarning() << "The quantity of client y positions does not match the client quantity." + " Client creation will fail. No clients will be available for interaction."; + return tempClientVec; + } + qDebug() << "clientYPositions:" << clientYPositions.join( " / " ); + + for ( int i = 0; i < clientQuantity; i++ ) { + tempClientVec.append( new Client{ clientIPs[ i ], clientMACs[ i ], clientNames[ i ], + clientXPositions[ i ].toUShort(), + clientYPositions[ i ].toUShort(), argPingCmd } ); + } + + return tempClientVec; +} + +QMap< QString, lc::Client* > lc::Settings::CreateClIPsToClMap( const QVector< Client* > &argClients ) { + QMap< QString, Client* > tempMap; + for ( const auto &s : argClients ) { + tempMap.insert( s->ip, s ); + + // Get the address of the Client instance in RAM for display + const void *clientPtrAddr = static_cast< const void* >( tempMap[ s->ip ] ); + + qDebug() << "Added" << s->name + << "to 'clientIPsToClientsMap':" << clientPtrAddr; + } + return tempMap; +} + QStringList lc::Settings::DetectInstalledLaTeXHeaders() const { QStringList tempLaTeXHeaders{ "None found" }; // Detect the installed LaTeX headers diff --git a/src/Lib/settings.h b/src/Lib/settings.h index fb47629..e981c56 100644 --- a/src/Lib/settings.h +++ b/src/Lib/settings.h @@ -24,6 +24,8 @@ #include #include +#include "client.h" + namespace lc { class Settings : public QObject { @@ -36,8 +38,10 @@ public: Settings& operator=( const Settings &argSettings ) = delete; Settings( Settings &&argSettings ) = delete; Settings& operator=( Settings &&argSettings ) = delete; + ~Settings(); int GetChosenZTreePort() const { return chosenzTreePort; } + QVector< Client* > &GetClients() { return clients; } QString GetLocalzLeafName() const; void SetChosenZTreePort( const int argPort ); void SetLocalzLeafName( const QString &argLocalzLeafName ); @@ -82,6 +86,9 @@ public: private: static bool CheckPathAndComplain( const QString &argPath, const QString &argVariableName, const QString &argMessage ); + static QVector< Client* > CreateClients( const QSettings &argSettings, + const QString &argPingCmd ); + static QMap< QString, Client* > CreateClIPsToClMap( const QVector< Client* > &argClients ); QStringList DetectInstalledLaTeXHeaders() const; QStringList DetectInstalledzTreeVersions() const; static QStringList GetAdminUsers( const QSettings &argSettings ); @@ -95,7 +102,11 @@ private: bool argItemIsFile ); int chosenzTreePort = 0; + QVector< Client* > clients; QString localzLeafName; + +public: + const QMap< QString, Client* > clIPsToClMap; }; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index df97013..092a826 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -297,8 +297,7 @@ void lc::MainWindow::on_PBChooseFile_clicked() { } void lc::MainWindow::on_PBDeactivateScreensaver_clicked() { - QVector< Client* > *clients = lablib->GetClients(); - for ( auto s : *clients ) { + for ( auto s : settings->GetClients() ) { if ( s->GetClientState() >= state_t::RESPONDING ) s->DeactiveScreensaver(); } @@ -309,15 +308,13 @@ void lc::MainWindow::on_PBExecute_clicked() { bool executeOnEveryClient = true; // Cancel, if not all clients are up and running - QVector< Client* > *clients = lablib->GetClients(); - for ( auto s: *clients ) { + for ( auto s: settings->GetClients() ) { if ( !( s->name.contains( "backup", Qt::CaseInsensitive ) ) ) { if ( s->GetClientState() < state_t::RESPONDING ) { QMessageBox messageBox{ QMessageBox::Warning, tr( "Not all clients are running" ), tr( "Not all clients are running. The command could not be executed on every client and should therefore be canceled to keep the clients consistent.\n\nAre you sure you want to continue only with the currently chosen clients?" ), QMessageBox::No | QMessageBox::Yes, this }; messageBox.setDefaultButton( QMessageBox::No ); messageBox.exec(); - clients = nullptr; executeOnEveryClient = false; if ( messageBox.clickedButton() == messageBox.button( QMessageBox::No ) ) { return; @@ -342,7 +339,7 @@ void lc::MainWindow::on_PBExecute_clicked() { // and execute it if ( executeOnEveryClient ) { qDebug() << "Executing command" << command << "on every client."; - for ( auto s: *clients ) { + for ( auto s: settings->GetClients() ) { if ( !( s->name.contains( "backup", Qt::CaseInsensitive ) ) ) { s->OpenTerminal( command, ui->RBUseUserRoot->isChecked() ); } @@ -357,8 +354,6 @@ void lc::MainWindow::on_PBExecute_clicked() { } } } - - clients = nullptr; } void lc::MainWindow::on_PBKillLocalzLeaf_clicked() { @@ -537,7 +532,7 @@ void lc::MainWindow::on_PBStartzLeaf_clicked() { } void lc::MainWindow::on_PBStartzTree_clicked() { - SessionStarter *sessionStarter = new SessionStarter{ lablib, this }; + SessionStarter *sessionStarter = new SessionStarter{ this }; sessionStarter->setWindowFlags( Qt::Window ); sessionStarter->show(); connect( sessionStarter, &SessionStarter::SessionRequested, @@ -605,12 +600,11 @@ void lc::MainWindow::SetupWidgets() { // Set the correct initial port for the ui->SBzLeafPort->setValue( settings->GetChosenZTreePort() ); // Fill the 'CBClientNames' with possible client names and the 'TVClients' with the clients - const QVector< Client* > *clients = lablib->GetClients(); - if ( !( clients == nullptr ) ) { + if ( !settings->GetClients().isEmpty() ) { valid_items = new QVector< QStandardItem * >; - valid_items->reserve( clients->size() ); + valid_items->reserve( settings->GetClients().size() ); clients_view_model = new QStandardItemModel{ this }; - for ( auto *s : *clients ) { + for ( auto *s : settings->GetClients() ) { int temp_xpos = s->xPosition - 1, temp_ypos = s->yPosition - 1; // Check if a client already exists at the given position and skip, if so @@ -654,7 +648,6 @@ void lc::MainWindow::SetupWidgets() { for ( const auto &s : settings->webcams ) ui->CBWebcamChooser->addItem( s ); } - clients = nullptr; const QStringList &zTreeEntries = settings->installedZTreeVersions; if ( zTreeEntries.isEmpty() ) { diff --git a/src/sessionstarter.cpp b/src/sessionstarter.cpp index 0e07117..2f9fa7a 100644 --- a/src/sessionstarter.cpp +++ b/src/sessionstarter.cpp @@ -27,9 +27,8 @@ extern std::unique_ptr< lc::Settings > settings; -lc::SessionStarter::SessionStarter( Lablib *argLablib, QWidget *parent ) : +lc::SessionStarter::SessionStarter( QWidget *parent ) : QWidget{ parent }, - lablib{ argLablib }, ui{ new Ui::SessionStarter } { ui->setupUi( this ); @@ -89,9 +88,9 @@ void lc::SessionStarter::on_ChBPrintanonymousreceipts_clicked( bool checked ) { ui->ChBPrintanonymousreceipts->setStyleSheet( "" ); } -void lc::SessionStarter::on_ChBReceiptsforLocalClients_clicked( bool checked ) { +void lc::SessionStarter::on_ChBReceiptsforLocalClients_clicked( bool argChecked ) { + Q_UNUSED( argChecked ); ui->ChBReceiptsforLocalClients->setStyleSheet( "" ); - lablib->SetPrintReceiptsForLocalClients( checked ); } void lc::SessionStarter::on_PBStartzTree_clicked() { @@ -148,7 +147,4 @@ void lc::SessionStarter::SetupWidgets() { ui->CBDataTargetPath->setCurrentIndex( 2 ); connect( this, &SessionStarter::NewDataTargetPathRequested, this, &SessionStarter::GetNewDataTargetPath ); - - // Set the initial status of CBReceiptsforLocalClients according to the settings in lcLablib - ui->ChBReceiptsforLocalClients->setChecked( lablib->GetPrintReceiptsForLocalClients() ); } diff --git a/src/sessionstarter.h b/src/sessionstarter.h index 7d85d0e..7edca57 100644 --- a/src/sessionstarter.h +++ b/src/sessionstarter.h @@ -35,7 +35,7 @@ class SessionStarter : public QWidget { Q_OBJECT public: - explicit SessionStarter( Lablib *argLablib, QWidget *parent = nullptr ); + explicit SessionStarter( QWidget *parent = nullptr ); ~SessionStarter(); //! This gets thrown as an exception if this class is created even if it shouldn't @@ -48,7 +48,6 @@ signals: QString argChosenLatexHeader ); private: - Lablib * const lablib = nullptr; Ui::SessionStarter *ui = nullptr; void SetupWidgets(); @@ -60,7 +59,7 @@ private slots: void on_CBReceiptsHeader_activated( const QString &argHeader ); void on_CBzTreeVersion_activated( const QString &argVersion ); void on_ChBPrintanonymousreceipts_clicked( bool checked ); - void on_ChBReceiptsforLocalClients_clicked(bool checked); + void on_ChBReceiptsforLocalClients_clicked( bool argChecked ); void on_PBStartzTree_clicked(); void on_SBPort_editingFinished(); diff --git a/src/sessionstarter.ui b/src/sessionstarter.ui index 521723d..64916eb 100644 --- a/src/sessionstarter.ui +++ b/src/sessionstarter.ui @@ -196,6 +196,9 @@ Please take care that it does not contain any spaces or other special characters Print receipts for local clients + + true +