Made 'lc::Settings::localzLeafName' private

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

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

@ -21,6 +21,7 @@
#define LABLIB_H
#include <list>
#include <memory>
#include <QDir>
#include <QItemSelectionModel>
@ -42,6 +43,9 @@
#include "netstatagent.h"
#include "session.h"
#include "sessionsmodel.h"
#include "settings.h"
extern std::unique_ptr< lc::Settings > settings;
namespace lc {
@ -91,7 +95,7 @@ public:
*
* @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
*
* @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
*/
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
*
* @return A pointer to the server's user's name

@ -10,14 +10,21 @@ class Settings : public QObject {
Q_OBJECT
public:
Settings() = delete;
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 dvipsCmd;
const QString fileMngr;
const QString latexCmd;
const QString lcInstDir;
const QString localzLeafName;
const QString lprCmd;
const QString netstatCmd;
const QString netwBrdAddr;
@ -46,8 +53,18 @@ private:
const QString &argMessage,
const QSettings &argSettings,
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

@ -509,11 +509,12 @@ void lc::MainWindow::on_PBStartLocalzLeaf_clicked() {
if ( ( messageBox != nullptr && messageBox->clickedButton() == messageBox->button( QMessageBox::Yes ) ) || !local_zLeaves_are_running ) {
// 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." ),
QLineEdit::Normal, *lablib->GetLocalZLeafDefaultName() );
QString name = QInputDialog::getText( this, tr( "The local zLeaf's name" ),
tr( "Please enter the name the local zLeaf shall have." ),
QLineEdit::Normal, lablib->GetLocalZLeafDefaultName() );
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;
arguments << ui->CBzLeafVersion->currentText() << "127.0.0.1" << QString::number( ui->SBzLeafPort->value() - 7000 ) << name;

Loading…
Cancel
Save