|
|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2014-2016 Markus Prasser
|
|
|
|
* Copyright 2014-2018 Markus Prasser, Tobias Weiss
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This file is part of Labcontrol.
|
|
|
|
* This file is part of Labcontrol.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
@ -153,14 +153,16 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) :
|
|
|
|
qDebug() << "Detected z-Tree versions" << installedZTreeVersions;
|
|
|
|
qDebug() << "Detected z-Tree versions" << installedZTreeVersions;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lc::Settings::~Settings() {
|
|
|
|
lc::Settings::~Settings()
|
|
|
|
|
|
|
|
{
|
|
|
|
for (QVector<Client *>::iterator it = clients.begin(); it != clients.end(); ++it) {
|
|
|
|
for (QVector<Client *>::iterator it = clients.begin(); it != clients.end(); ++it) {
|
|
|
|
delete *it;
|
|
|
|
delete *it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool lc::Settings::CheckPathAndComplain(const QString &argPath, const QString &argVariableName,
|
|
|
|
bool lc::Settings::CheckPathAndComplain(const QString &argPath, const QString &argVariableName,
|
|
|
|
const QString &argMessage ) {
|
|
|
|
const QString &argMessage)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!QFile::exists(argPath)) {
|
|
|
|
if (!QFile::exists(argPath)) {
|
|
|
|
qDebug() << "The path" << argPath << "specified by" << argVariableName
|
|
|
|
qDebug() << "The path" << argPath << "specified by" << argVariableName
|
|
|
|
<< "does not exist:" << argMessage;
|
|
|
|
<< "does not exist:" << argMessage;
|
|
|
|
@ -171,7 +173,8 @@ bool lc::Settings::CheckPathAndComplain( const QString &argPath, const QString &
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QVector<lc::Client *> lc::Settings::CreateClients(const QSettings &argSettings,
|
|
|
|
QVector<lc::Client *> lc::Settings::CreateClients(const QSettings &argSettings,
|
|
|
|
const QString &argPingCmd ) {
|
|
|
|
const QString &argPingCmd)
|
|
|
|
|
|
|
|
{
|
|
|
|
QVector<Client *> tempClientVec;
|
|
|
|
QVector<Client *> tempClientVec;
|
|
|
|
|
|
|
|
|
|
|
|
// Get the client quantity to check the value lists for clients creation for correct length
|
|
|
|
// Get the client quantity to check the value lists for clients creation for correct length
|
|
|
|
@ -246,7 +249,9 @@ QVector< lc::Client* > lc::Settings::CreateClients( const QSettings &argSettings
|
|
|
|
return tempClientVec;
|
|
|
|
return tempClientVec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QMap< QString, lc::Client* > lc::Settings::CreateClIPsToClMap( const QVector< Client* > &argClients ) {
|
|
|
|
QMap< QString, lc::Client * > lc::Settings::CreateClIPsToClMap(const QVector<Client *>
|
|
|
|
|
|
|
|
&argClients)
|
|
|
|
|
|
|
|
{
|
|
|
|
QMap<QString, Client * > tempMap;
|
|
|
|
QMap<QString, Client * > tempMap;
|
|
|
|
for (const auto &s : argClients) {
|
|
|
|
for (const auto &s : argClients) {
|
|
|
|
tempMap.insert(s->ip, s);
|
|
|
|
tempMap.insert(s->ip, s);
|
|
|
|
@ -260,7 +265,8 @@ QMap< QString, lc::Client* > lc::Settings::CreateClIPsToClMap( const QVector< Cl
|
|
|
|
return tempMap;
|
|
|
|
return tempMap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QStringList lc::Settings::DetectInstalledLaTeXHeaders() const {
|
|
|
|
QStringList lc::Settings::DetectInstalledLaTeXHeaders() const
|
|
|
|
|
|
|
|
{
|
|
|
|
QStringList tempLaTeXHeaders{"None found"};
|
|
|
|
QStringList tempLaTeXHeaders{"None found"};
|
|
|
|
// Detect the installed LaTeX headers
|
|
|
|
// Detect the installed LaTeX headers
|
|
|
|
if (!lcDataDir.isEmpty()) {
|
|
|
|
if (!lcDataDir.isEmpty()) {
|
|
|
|
@ -278,7 +284,8 @@ QStringList lc::Settings::DetectInstalledLaTeXHeaders() const {
|
|
|
|
return tempLaTeXHeaders;
|
|
|
|
return tempLaTeXHeaders;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QStringList lc::Settings::DetectInstalledzTreeVersions() const {
|
|
|
|
QStringList lc::Settings::DetectInstalledzTreeVersions() const
|
|
|
|
|
|
|
|
{
|
|
|
|
QStringList tempInstzTreeVersions;
|
|
|
|
QStringList tempInstzTreeVersions;
|
|
|
|
if (!zTreeInstDir.isEmpty()) {
|
|
|
|
if (!zTreeInstDir.isEmpty()) {
|
|
|
|
QDir zTreeDirectory{zTreeInstDir, "zTree_*", QDir::Name,
|
|
|
|
QDir zTreeDirectory{zTreeInstDir, "zTree_*", QDir::Name,
|
|
|
|
@ -294,7 +301,8 @@ QStringList lc::Settings::DetectInstalledzTreeVersions() const {
|
|
|
|
return tempInstzTreeVersions;
|
|
|
|
return tempInstzTreeVersions;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QStringList lc::Settings::GetAdminUsers( const QSettings &argSettings ) {
|
|
|
|
QStringList lc::Settings::GetAdminUsers(const QSettings &argSettings)
|
|
|
|
|
|
|
|
{
|
|
|
|
// Read the list of users with administrative rights
|
|
|
|
// Read the list of users with administrative rights
|
|
|
|
if (!argSettings.contains("admin_users")) {
|
|
|
|
if (!argSettings.contains("admin_users")) {
|
|
|
|
qDebug() << "The 'admin_users' variable was not set."
|
|
|
|
qDebug() << "The 'admin_users' variable was not set."
|
|
|
|
@ -309,7 +317,8 @@ QStringList lc::Settings::GetAdminUsers( const QSettings &argSettings ) {
|
|
|
|
return QStringList{};
|
|
|
|
return QStringList{};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
quint16 lc::Settings::GetClientHelpNotificationServerPort( const QSettings &argSettings ) {
|
|
|
|
quint16 lc::Settings::GetClientHelpNotificationServerPort(const QSettings &argSettings)
|
|
|
|
|
|
|
|
{
|
|
|
|
// Read the port the ClientHelpNotificationServer shall listen on
|
|
|
|
// Read the port the ClientHelpNotificationServer shall listen on
|
|
|
|
quint16 clientHelpNotificationServerPort = argSettings.value("client_help_server_port",
|
|
|
|
quint16 clientHelpNotificationServerPort = argSettings.value("client_help_server_port",
|
|
|
|
0).toUInt();
|
|
|
|
0).toUInt();
|
|
|
|
@ -325,7 +334,8 @@ quint16 lc::Settings::GetClientHelpNotificationServerPort( const QSettings &argS
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int lc::Settings::GetDefaultReceiptIndex( const QSettings &argSettings ) {
|
|
|
|
int lc::Settings::GetDefaultReceiptIndex( const QSettings &argSettings )
|
|
|
|
|
|
|
|
{
|
|
|
|
// Read the default receipt index for the 'CBReceipts' combobox
|
|
|
|
// Read the default receipt index for the 'CBReceipts' combobox
|
|
|
|
if (!argSettings.contains("default_receipt_index")) {
|
|
|
|
if (!argSettings.contains("default_receipt_index")) {
|
|
|
|
qDebug() << "'default_receipt_index' was not set. It will default to '0'.";
|
|
|
|
qDebug() << "'default_receipt_index' was not set. It will default to '0'.";
|
|
|
|
@ -336,7 +346,8 @@ int lc::Settings::GetDefaultReceiptIndex( const QSettings &argSettings ) {
|
|
|
|
return tempIndex;
|
|
|
|
return tempIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int lc::Settings::GetInitialPort( const QSettings &argSettings ) {
|
|
|
|
int lc::Settings::GetInitialPort( const QSettings &argSettings )
|
|
|
|
|
|
|
|
{
|
|
|
|
// Read the initial port number
|
|
|
|
// Read the initial port number
|
|
|
|
if (!argSettings.contains("initial_port")) {
|
|
|
|
if (!argSettings.contains("initial_port")) {
|
|
|
|
qDebug() << "The 'initial_port' variable was not set."
|
|
|
|
qDebug() << "The 'initial_port' variable was not set."
|
|
|
|
@ -347,7 +358,8 @@ int lc::Settings::GetInitialPort( const QSettings &argSettings ) {
|
|
|
|
return initialPort;
|
|
|
|
return initialPort;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString lc::Settings::GetLocalUserName() {
|
|
|
|
QString lc::Settings::GetLocalUserName()
|
|
|
|
|
|
|
|
{
|
|
|
|
const QProcessEnvironment env{QProcessEnvironment::systemEnvironment()};
|
|
|
|
const QProcessEnvironment env{QProcessEnvironment::systemEnvironment()};
|
|
|
|
QString userName;
|
|
|
|
QString userName;
|
|
|
|
// For Linux
|
|
|
|
// For Linux
|
|
|
|
@ -366,7 +378,8 @@ QString lc::Settings::GetLocalUserName() {
|
|
|
|
QString lc::Settings::ReadSettingsItem(const QString &argVariableName,
|
|
|
|
QString lc::Settings::ReadSettingsItem(const QString &argVariableName,
|
|
|
|
const QString &argMessage,
|
|
|
|
const QString &argMessage,
|
|
|
|
const QSettings &argSettings,
|
|
|
|
const QSettings &argSettings,
|
|
|
|
bool argItemIsFile) {
|
|
|
|
bool argItemIsFile)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!argSettings.contains(argVariableName)) {
|
|
|
|
if (!argSettings.contains(argVariableName)) {
|
|
|
|
qDebug() << argVariableName << "was not set." << argMessage;
|
|
|
|
qDebug() << argVariableName << "was not set." << argMessage;
|
|
|
|
return QString{};
|
|
|
|
return QString{};
|
|
|
|
@ -381,11 +394,12 @@ QString lc::Settings::ReadSettingsItem( const QString &argVariableName,
|
|
|
|
return QString{};
|
|
|
|
return QString{};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void lc::Settings::SetLocalzLeafSize( QString arg) {
|
|
|
|
void lc::Settings::SetLocalzLeafSize(QString arg)
|
|
|
|
|
|
|
|
{
|
|
|
|
localzLeafSize = arg;
|
|
|
|
localzLeafSize = arg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void lc::Settings::SetChosenZTreePort( const int argPort ){
|
|
|
|
void lc::Settings::SetChosenZTreePort(const int argPort)
|
|
|
|
|
|
|
|
{
|
|
|
|
chosenzTreePort = argPort;
|
|
|
|
chosenzTreePort = argPort;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|