Made 'lc::Settings::localzLeafName' private

remotes/origin/HEAD
markuspg 10 years ago
parent bb5d76fe84
commit c522b5168e

@ -17,16 +17,11 @@
* 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 <QErrorMessage> #include <QErrorMessage>
#include <QFile> #include <QFile>
#include <QTextStream> #include <QTextStream>
#include "lablib.h" #include "lablib.h"
#include "settings.h"
extern std::unique_ptr< lc::Settings > settings;
lc::Lablib::Lablib( QPlainTextEdit *argDebugMessagesTextEdit, QObject *argParent ) : lc::Lablib::Lablib( QPlainTextEdit *argDebugMessagesTextEdit, QObject *argParent ) :
QObject{ argParent }, QObject{ argParent },
@ -144,8 +139,8 @@ void lc::Lablib::GotNetstatQueryResult( QStringList *argActiveZLeafConnections )
void lc::Lablib::ReadSettings() { void lc::Lablib::ReadSettings() {
// Let the local zLeaf name default to 'local' if none was given in the settings // Let the local zLeaf name default to 'local' if none was given in the settings
if ( !( *settingsItems )[ ( int )settItms_t::LOCAL_ZLEAF_NAME ] ) { if ( settings->GetLocalzLeafName().isEmpty() ) {
settingsItems->replace( ( int )settItms_t::LOCAL_ZLEAF_NAME, new QString{ tr( "local" ) } ); settings->SetLocalzLeafName( tr( "local" ) );
} }
// Read the list of users with administrative rights // Read the list of users with administrative rights
@ -375,7 +370,6 @@ void lc::Lablib::StartNewZTreeInstance() {
} }
void lc::Lablib::SetLocalZLeafDefaultName( const QString &argName ) { void lc::Lablib::SetLocalZLeafDefaultName( const QString &argName ) {
delete ( *settingsItems )[ ( int )settItms_t::LOCAL_ZLEAF_NAME ]; settings->SetLocalzLeafName( argName );
( *settingsItems )[ ( int )settItms_t::LOCAL_ZLEAF_NAME ] = new QString{ argName };
labSettings.setValue( "local_zLeaf_name", argName ); labSettings.setValue( "local_zLeaf_name", argName );
} }

@ -21,6 +21,7 @@
#define LABLIB_H #define LABLIB_H
#include <list> #include <list>
#include <memory>
#include <QDir> #include <QDir>
#include <QItemSelectionModel> #include <QItemSelectionModel>
@ -42,6 +43,9 @@
#include "netstatagent.h" #include "netstatagent.h"
#include "session.h" #include "session.h"
#include "sessionsmodel.h" #include "sessionsmodel.h"
#include "settings.h"
extern std::unique_ptr< lc::Settings > settings;
namespace lc { namespace lc {
@ -91,7 +95,7 @@ public:
* *
* @return 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 ( *settingsItems )[ ( int )settItms_t::LOCAL_ZLEAF_NAME ]; } QString GetLocalZLeafDefaultName() const { return settings->GetLocalzLeafName(); }
/** Returns a pointer to a QVector<unsigned int> containing all by sessions occupied ports /** Returns a pointer to a QVector<unsigned int> containing all by sessions occupied ports
* *
* @return A pointer to a QVector<unsigned int> containing all occupied ports * @return A pointer to a QVector<unsigned int> containing all occupied ports
@ -107,16 +111,6 @@ public:
* @return True if receipts for local clients shall be printed * @return True if receipts for local clients shall be printed
*/ */
bool GetPrintReceiptsForLocalClients() const { return PrintReceiptsForLocalClients; } bool GetPrintReceiptsForLocalClients() const { return PrintReceiptsForLocalClients; }
/** Returns a pointer to a specified QString stored in 'settings_items' storing all command QString pointers
*
* @return A pointer to to a specified QString stored in 'settings_items' storing all command QString pointers
*/
QString *GetSettingsItem( settItms_t argItem ) const { return ( *settingsItems )[ ( int )argItem ]; }
/** Returns a pointer to the 'settingsItems' storing all command QString pointers
*
* @return A pointer to the 'settingsItems' storing all command QString pointers
*/
QVector<QString*> *GetSettingsItems() const { return settingsItems; }
/** Returns a pointer to server's user's name /** Returns a pointer to server's user's name
* *
* @return A pointer to the server's user's name * @return A pointer to the server's user's name

@ -10,14 +10,21 @@ class Settings : public QObject {
Q_OBJECT Q_OBJECT
public: public:
Settings() = delete;
explicit Settings( const QSettings &argSettings, QObject *argParent = nullptr ); explicit Settings( const QSettings &argSettings, QObject *argParent = nullptr );
Settings( const Settings &argSettings ) = delete;
Settings& operator=( const Settings &argSettings ) = delete;
Settings( Settings &&argSettings ) = delete;
Settings& operator=( Settings &&argSettings ) = delete;
QString GetLocalzLeafName() const;
void SetLocalzLeafName( const QString &argLocalzLeafName );
const QString browserCmd; const QString browserCmd;
const QString dvipsCmd; const QString dvipsCmd;
const QString fileMngr; const QString fileMngr;
const QString latexCmd; const QString latexCmd;
const QString lcInstDir; const QString lcInstDir;
const QString localzLeafName;
const QString lprCmd; const QString lprCmd;
const QString netstatCmd; const QString netstatCmd;
const QString netwBrdAddr; const QString netwBrdAddr;
@ -46,8 +53,18 @@ private:
const QString &argMessage, const QString &argMessage,
const QSettings &argSettings, const QSettings &argSettings,
bool argItemIsFile ); bool argItemIsFile );
QString localzLeafName;
}; };
} }
inline QString lc::Settings::GetLocalzLeafName() const {
return localzLeafName;
}
inline void lc::Settings::SetLocalzLeafName( const QString &argLocalzLeafName ) {
localzLeafName = argLocalzLeafName;
}
#endif // SETTINGS_H #endif // SETTINGS_H

@ -509,11 +509,12 @@ void lc::MainWindow::on_PBStartLocalzLeaf_clicked() {
if ( ( messageBox != nullptr && messageBox->clickedButton() == messageBox->button( QMessageBox::Yes ) ) || !local_zLeaves_are_running ) { if ( ( messageBox != nullptr && messageBox->clickedButton() == messageBox->button( QMessageBox::Yes ) ) || !local_zLeaves_are_running ) {
// Ask for the name the local zLeaf shall have // Ask for the name the local zLeaf shall have
QString name = QInputDialog::getText( this, tr( "The local zLeaf's name" ), tr( "Please enter the name the local zLeaf shall have." ), QString name = QInputDialog::getText( this, tr( "The local zLeaf's name" ),
QLineEdit::Normal, *lablib->GetLocalZLeafDefaultName() ); tr( "Please enter the name the local zLeaf shall have." ),
QLineEdit::Normal, lablib->GetLocalZLeafDefaultName() );
lablib->SetLocalZLeafDefaultName( name ); lablib->SetLocalZLeafDefaultName( name );
QString program = QString{ *lablib->GetSettingsItem( settItms_t::LC_INST_DIR ) + "/scripts/start_zLeaf_labcontrol2.sh" }; QString program = QString{ settings->lcInstDir + "/scripts/start_zLeaf_labcontrol2.sh" };
QStringList arguments; QStringList arguments;
arguments << ui->CBzLeafVersion->currentText() << "127.0.0.1" << QString::number( ui->SBzLeafPort->value() - 7000 ) << name; arguments << ui->CBzLeafVersion->currentText() << "127.0.0.1" << QString::number( ui->SBzLeafPort->value() - 7000 ) << name;

Loading…
Cancel
Save