Minor Settings clean-ups

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

@ -17,6 +17,7 @@
* along with Labcontrol. If not, see <http://www.gnu.org/licenses/>. * along with Labcontrol. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "client.h"
#include "clientpinger.h" #include "clientpinger.h"
#include "settings.h" #include "settings.h"
@ -36,8 +37,6 @@ lc::Client::Client(const QString &argIP, const QString &argMAC, const QString &a
protectedCycles{0}, protectedCycles{0},
settings{argSettings} settings{argSettings}
{ {
qRegisterMetaType<state_t>("state_t");
if (!argPingCmd.isEmpty()) { if (!argPingCmd.isEmpty()) {
pinger = new ClientPinger{ip, argPingCmd}; pinger = new ClientPinger{ip, argPingCmd};
pinger->moveToThread(&pingerThread); pinger->moveToThread(&pingerThread);

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

@ -17,6 +17,7 @@
* along with Labcontrol. If not, see <http://www.gnu.org/licenses/>. * along with Labcontrol. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "client.h"
#include "session.h" #include "session.h"
#include "settings.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.", "Datapath not set. Labcontrol will missbehave with high propability.",
argSettings, true)}, argSettings, true)},
localUserName{GetLocalUserName()}, localUserName{GetLocalUserName()},
localzLeafSize{ReadSettingsItem("local_zLeaf_size",
"Resolution of local zLeaf window",
argSettings, false)},
lprCmd{ReadSettingsItem("lpr_command", lprCmd{ReadSettingsItem("lpr_command",
"Receipts printing will not work.", "Receipts printing will not work.",
argSettings, true)}, argSettings, true)},
@ -136,6 +133,9 @@ lc::Settings::Settings(const QSettings &argSettings, QObject *argParent) :
chosenzTreePort{GetInitialPort(argSettings)}, chosenzTreePort{GetInitialPort(argSettings)},
localzLeafName{ReadSettingsItem("local_zLeaf_name", localzLeafName{ReadSettingsItem("local_zLeaf_name",
"The local zLeaf default name will default to 'local'.", "The local zLeaf default name will default to 'local'.",
argSettings, false)},
localzLeafSize{ReadSettingsItem("local_zLeaf_size",
"Resolution of local zLeaf window",
argSettings, false)} argSettings, false)}
{ {
clients = CreateClients(argSettings, pingCmd); clients = CreateClients(argSettings, pingCmd);
@ -395,13 +395,3 @@ QString lc::Settings::ReadSettingsItem(const QString &argVariableName,
} }
return QString{}; 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 <QObject>
#include <QSettings> #include <QSettings>
#include "client.h"
namespace lc { namespace lc {
class Client;
class Settings : public QObject class Settings : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -39,35 +39,26 @@ public:
Settings &operator=(const Settings &argSettings) = delete; Settings &operator=(const Settings &argSettings) = delete;
Settings(Settings &&argSettings ) = delete; Settings(Settings &&argSettings ) = delete;
Settings &operator=(Settings &&argSettings) = delete; Settings &operator=(Settings &&argSettings) = delete;
~Settings(); ~Settings() override;
int GetChosenZTreePort() const int GetChosenZTreePort() const noexcept;
{ const QVector<Client *> &GetClients() const;
return chosenzTreePort;
}
const QVector<Client *> &GetClients() const
{
return clients;
}
QString GetLocalzLeafName() const; QString GetLocalzLeafName() const;
void SetChosenZTreePort(const int argPort); QString GetLocalzLeafSize() const;
void SetChosenZTreePort(const int argPort) noexcept;
void SetLocalzLeafName(const QString &argLocalzLeafName); void SetLocalzLeafName(const QString &argLocalzLeafName);
void SetLocalzLeafSize(const QString &argSize);
const int defaultReceiptIndex = 0; const int defaultReceiptIndex = 0;
const QString browserCmd; const QString browserCmd;
const QString clientBrowserCmd; const QString clientBrowserCmd;
QMap<QString, Client *> clIPsToClMap;
const QString dvipsCmd; const QString dvipsCmd;
const QString fileMngr; const QString fileMngr;
const QString killallCmd; const QString killallCmd;
const QString latexCmd; const QString latexCmd;
const QString lcDataDir; const QString lcDataDir;
const QString localUserName; const QString localUserName;
QString localzLeafSize;
void SetLocalzLeafSize(QString arg);
QString GetLocalzLeafSize() const
{
return localzLeafSize;
}
const QString lprCmd; const QString lprCmd;
const QString netstatCmd; const QString netstatCmd;
const QString netwBrdAddr; const QString netwBrdAddr;
@ -121,21 +112,44 @@ private:
int chosenzTreePort = 0; int chosenzTreePort = 0;
QVector<Client *> clients; QVector<Client *> clients;
QString localzLeafName; QString localzLeafName;
QString localzLeafSize;
public:
QMap<QString, Client *> clIPsToClMap;
}; };
} // namespace lc } // 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 inline QString lc::Settings::GetLocalzLeafName() const
{ {
return localzLeafName; 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) inline void lc::Settings::SetLocalzLeafName(const QString &argLocalzLeafName)
{ {
localzLeafName = argLocalzLeafName; localzLeafName = argLocalzLeafName;
} }
inline void lc::Settings::SetLocalzLeafSize(const QString &argSize)
{
localzLeafSize = argSize;
}
#endif // SETTINGS_H #endif // SETTINGS_H

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

@ -710,8 +710,8 @@ void lc::MainWindow::StartLocalzLeaf( QString argzLeafName, QString argzLeafVers
<< QString{ settings->zTreeInstDir + "/zTree_" + argzLeafVersion + "/zleaf.exe" } << QString{ settings->zTreeInstDir + "/zTree_" + argzLeafVersion + "/zleaf.exe" }
<< "/server" << "127.0.0.1" << "/channel" << "/server" << "127.0.0.1" << "/channel"
<< QString::number( argzTreePort - 7000 ) << "/name" << argzLeafName; << QString::number( argzTreePort - 7000 ) << "/name" << argzLeafName;
if ( !settings->localzLeafSize.isEmpty() ) { if (!settings->GetLocalzLeafSize().isEmpty()) {
arguments << "/size" << QString{ settings->localzLeafSize }; arguments << "/size" << settings->GetLocalzLeafSize();
} }
qDebug() << "Start local zLeaf:" << arguments; qDebug() << "Start local zLeaf:" << arguments;

Loading…
Cancel
Save