Minor Settings clean-ups

remotes/origin/HEAD
markuspg 6 years ago
parent d663ec6aeb
commit 9d304905e3

@ -17,6 +17,7 @@
* along with Labcontrol. If not, see <http://www.gnu.org/licenses/>.
*/
#include "client.h"
#include "clientpinger.h"
#include "settings.h"
@ -36,8 +37,6 @@ lc::Client::Client(const QString &argIP, const QString &argMAC, const QString &a
protectedCycles{0},
settings{argSettings}
{
qRegisterMetaType<state_t>("state_t");
if (!argPingCmd.isEmpty()) {
pinger = new ClientPinger{ip, argPingCmd};
pinger->moveToThread(&pingerThread);
@ -79,8 +78,8 @@ void lc::Client::BeamFile(const QString &argFileToBeam,
}
const QStringList arguments{"-2", "-i", *argPublickeyPathUser, "-l",
"32768", "-r", argFileToBeam,
QString{*argUserNameOnClients + "@" + ip + ":media4ztree"}};
"32768", "-r", argFileToBeam,
QString{*argUserNameOnClients + "@" + ip + ":media4ztree"}};
// Start the process
QProcess beamFileProcess;
@ -126,8 +125,8 @@ void lc::Client::GotStatusChanged(state_t argState)
void lc::Client::KillZLeaf()
{
const QStringList arguments{"-i", settings->pkeyPathUser,
QString{settings->userNameOnClients + "@" + ip},
settings->killallCmd, "-I", "-q", "zleaf.exe"};
QString{settings->userNameOnClients + "@" + ip},
settings->killallCmd, "-I", "-q", "zleaf.exe"};
// Start the process
QProcess killZLeafProcess;
@ -237,8 +236,8 @@ void lc::Client::Shutdown()
return;
}
const QStringList arguments{"-i", settings->pkeyPathUser,
QString{settings->userNameOnClients + "@" + ip},
"sudo shutdown -P now"};
QString{settings->userNameOnClients + "@" + ip},
"sudo shutdown -P now"};
// Start the process
QProcess shutdownProcess;

@ -17,6 +17,7 @@
* along with Labcontrol. If not, see <http://www.gnu.org/licenses/>.
*/
#include "client.h"
#include "clienthelpnotificationserver.h"
#include "settings.h"

@ -17,6 +17,7 @@
* along with Labcontrol. If not, see <http://www.gnu.org/licenses/>.
*/
#include "client.h"
#include "session.h"
#include "settings.h"

@ -50,9 +50,6 @@ lc::Settings::Settings(const QSettings &argSettings, QObject *argParent) :
"Datapath not set. Labcontrol will missbehave with high propability.",
argSettings, true)},
localUserName{GetLocalUserName()},
localzLeafSize{ReadSettingsItem("local_zLeaf_size",
"Resolution of local zLeaf window",
argSettings, false)},
lprCmd{ReadSettingsItem("lpr_command",
"Receipts printing will not work.",
argSettings, true)},
@ -136,6 +133,9 @@ lc::Settings::Settings(const QSettings &argSettings, QObject *argParent) :
chosenzTreePort{GetInitialPort(argSettings)},
localzLeafName{ReadSettingsItem("local_zLeaf_name",
"The local zLeaf default name will default to 'local'.",
argSettings, false)},
localzLeafSize{ReadSettingsItem("local_zLeaf_size",
"Resolution of local zLeaf window",
argSettings, false)}
{
clients = CreateClients(argSettings, pingCmd);
@ -395,13 +395,3 @@ QString lc::Settings::ReadSettingsItem(const QString &argVariableName,
}
return QString{};
}
void lc::Settings::SetLocalzLeafSize(QString arg)
{
localzLeafSize = arg;
}
void lc::Settings::SetChosenZTreePort(const int argPort)
{
chosenzTreePort = argPort;
}

@ -24,10 +24,10 @@
#include <QObject>
#include <QSettings>
#include "client.h"
namespace lc {
class Client;
class Settings : public QObject
{
Q_OBJECT
@ -39,35 +39,26 @@ public:
Settings &operator=(const Settings &argSettings) = delete;
Settings(Settings &&argSettings ) = delete;
Settings &operator=(Settings &&argSettings) = delete;
~Settings();
int GetChosenZTreePort() const
{
return chosenzTreePort;
}
const QVector<Client *> &GetClients() const
{
return clients;
}
~Settings() override;
int GetChosenZTreePort() const noexcept;
const QVector<Client *> &GetClients() const;
QString GetLocalzLeafName() const;
void SetChosenZTreePort(const int argPort);
QString GetLocalzLeafSize() const;
void SetChosenZTreePort(const int argPort) noexcept;
void SetLocalzLeafName(const QString &argLocalzLeafName);
void SetLocalzLeafSize(const QString &argSize);
const int defaultReceiptIndex = 0;
const QString browserCmd;
const QString clientBrowserCmd;
QMap<QString, Client *> clIPsToClMap;
const QString dvipsCmd;
const QString fileMngr;
const QString killallCmd;
const QString latexCmd;
const QString lcDataDir;
const QString localUserName;
QString localzLeafSize;
void SetLocalzLeafSize(QString arg);
QString GetLocalzLeafSize() const
{
return localzLeafSize;
}
const QString lprCmd;
const QString netstatCmd;
const QString netwBrdAddr;
@ -121,21 +112,44 @@ private:
int chosenzTreePort = 0;
QVector<Client *> clients;
QString localzLeafName;
public:
QMap<QString, Client *> clIPsToClMap;
QString localzLeafSize;
};
} // namespace lc
inline int lc::Settings::GetChosenZTreePort() const noexcept
{
return chosenzTreePort;
}
inline const QVector<lc::Client *> &lc::Settings::GetClients() const
{
return clients;
}
inline QString lc::Settings::GetLocalzLeafName() const
{
return localzLeafName;
}
inline QString lc::Settings::GetLocalzLeafSize() const
{
return localzLeafSize;
}
inline void lc::Settings::SetChosenZTreePort(const int argPort) noexcept
{
chosenzTreePort = argPort;
}
inline void lc::Settings::SetLocalzLeafName(const QString &argLocalzLeafName)
{
localzLeafName = argLocalzLeafName;
}
inline void lc::Settings::SetLocalzLeafSize(const QString &argSize)
{
localzLeafSize = argSize;
}
#endif // SETTINGS_H

@ -18,12 +18,15 @@
*/
#include "mainwindow.h"
#include "Lib/client.h"
#include "Lib/settings.h"
#include <QApplication>
int main(int argc, char *argv[])
{
qRegisterMetaType<state_t>();
QApplication a{argc, argv};
lc::Settings settings{QSettings{"Labcontrol", "Labcontrol"}};
lc::MainWindow w{&settings};

@ -267,12 +267,12 @@ void lc::MainWindow::LoadIconPixmaps()
}
const QStringList iconNames{ QStringList{}
<< "unknown.png"
<< "off.png"
<< "down.png"
<< "boot.png"
<< "on.png"
<< "zLeaf.png" };
<< "unknown.png"
<< "off.png"
<< "down.png"
<< "boot.png"
<< "on.png"
<< "zLeaf.png" };
for ( int i = 0; i < ( int )icons_t::ICON_QUANTITY; i++ ) {
if ( !icons[ i ].load( settings->lcDataDir + "/icons/" + iconNames[ i ] ) ) {
@ -710,8 +710,8 @@ void lc::MainWindow::StartLocalzLeaf( QString argzLeafName, QString argzLeafVers
<< QString{ settings->zTreeInstDir + "/zTree_" + argzLeafVersion + "/zleaf.exe" }
<< "/server" << "127.0.0.1" << "/channel"
<< QString::number( argzTreePort - 7000 ) << "/name" << argzLeafName;
if ( !settings->localzLeafSize.isEmpty() ) {
arguments << "/size" << QString{ settings->localzLeafSize };
if (!settings->GetLocalzLeafSize().isEmpty()) {
arguments << "/size" << settings->GetLocalzLeafSize();
}
qDebug() << "Start local zLeaf:" << arguments;

Loading…
Cancel
Save