20240125
This commit is contained in:
parent
e827eb150a
commit
be7dd0da25
|
@ -1,4 +1,4 @@
|
|||
#include "HxBroadcast.h"
|
||||
#include "HxBroadcast.h"
|
||||
|
||||
#include <QHostAddress>
|
||||
#include <QJsonDocument>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef HXBROADCAST_H
|
||||
#ifndef HXBROADCAST_H
|
||||
#define HXBROADCAST_H
|
||||
|
||||
#include <QObject>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "HxDisk.h"
|
||||
#include "HxDisk.h"
|
||||
|
||||
void HxDisk::mkpath(QString path)
|
||||
{
|
||||
|
|
2
HxDisk.h
2
HxDisk.h
|
@ -1,4 +1,4 @@
|
|||
#ifndef HXDISK_H
|
||||
#ifndef HXDISK_H
|
||||
#define HXDISK_H
|
||||
|
||||
#include "HxTrace.h"
|
||||
|
|
114
HxJson.cpp
114
HxJson.cpp
|
@ -1,57 +1,57 @@
|
|||
#include "HxJson.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
int HxJson::to_int(QJsonObject object, QString key)
|
||||
{
|
||||
auto value = object.value(key);
|
||||
|
||||
switch(value.type())
|
||||
{
|
||||
case QJsonValue::Double:
|
||||
return qRound(value.toDouble());
|
||||
|
||||
case QJsonValue::String:
|
||||
return value.toString().toInt();
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool HxJson::to_boolean(QJsonObject object, QString key)
|
||||
{
|
||||
auto value = object.value(key);
|
||||
|
||||
switch(value.type())
|
||||
{
|
||||
case QJsonValue::Bool:
|
||||
return value.toBool();
|
||||
|
||||
case QJsonValue::String:
|
||||
return QVariant(value.toString()).toBool();
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString HxJson::to_string(QJsonObject object, QString key)
|
||||
{
|
||||
auto value = object.value(key);
|
||||
|
||||
switch(value.type())
|
||||
{
|
||||
case QJsonValue::Bool:
|
||||
case QJsonValue::Double:
|
||||
return QString::number(value.toDouble());
|
||||
|
||||
case QJsonValue::String:
|
||||
return value.toString();
|
||||
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
QStringList HxJson::to_string_list(QJsonObject object, QString key, QString split){ return to_string(object, key).split(split);}
|
||||
#include "HxJson.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
int HxJson::to_int(QJsonObject object, QString key)
|
||||
{
|
||||
auto value = object.value(key);
|
||||
|
||||
switch(value.type())
|
||||
{
|
||||
case QJsonValue::Double:
|
||||
return qRound(value.toDouble());
|
||||
|
||||
case QJsonValue::String:
|
||||
return value.toString().toInt();
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool HxJson::to_boolean(QJsonObject object, QString key)
|
||||
{
|
||||
auto value = object.value(key);
|
||||
|
||||
switch(value.type())
|
||||
{
|
||||
case QJsonValue::Bool:
|
||||
return value.toBool();
|
||||
|
||||
case QJsonValue::String:
|
||||
return QVariant(value.toString()).toBool();
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString HxJson::to_string(QJsonObject object, QString key)
|
||||
{
|
||||
auto value = object.value(key);
|
||||
|
||||
switch(value.type())
|
||||
{
|
||||
case QJsonValue::Bool:
|
||||
case QJsonValue::Double:
|
||||
return QString::number(value.toDouble());
|
||||
|
||||
case QJsonValue::String:
|
||||
return value.toString();
|
||||
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
QStringList HxJson::to_string_list(QJsonObject object, QString key, QString split){ return to_string(object, key).split(split);}
|
||||
|
|
30
HxJson.h
30
HxJson.h
|
@ -1,15 +1,15 @@
|
|||
#ifndef HXJSON_H
|
||||
#define HXJSON_H
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
class HxJson
|
||||
{
|
||||
public:
|
||||
static int to_int(QJsonObject object, QString key);
|
||||
static bool to_boolean(QJsonObject object, QString key);
|
||||
static QString to_string(QJsonObject object, QString key);
|
||||
static QStringList to_string_list(QJsonObject object, QString key, QString split);
|
||||
};
|
||||
|
||||
#endif // HXJSON_H
|
||||
#ifndef HXJSON_H
|
||||
#define HXJSON_H
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
class HxJson
|
||||
{
|
||||
public:
|
||||
static int to_int(QJsonObject object, QString key);
|
||||
static bool to_boolean(QJsonObject object, QString key);
|
||||
static QString to_string(QJsonObject object, QString key);
|
||||
static QStringList to_string_list(QJsonObject object, QString key, QString split);
|
||||
};
|
||||
|
||||
#endif // HXJSON_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "HxSocket.h"
|
||||
#include "HxSocket.h"
|
||||
#include "HxThread.h"
|
||||
|
||||
#include <QHostInfo>
|
||||
|
|
2
HxSql.h
2
HxSql.h
|
@ -1,4 +1,4 @@
|
|||
#ifndef HXSQL_H
|
||||
#ifndef HXSQL_H
|
||||
#define HXSQL_H
|
||||
|
||||
#include <QSqlDatabase>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "HxSystem.h"
|
||||
#include "HxSystem.h"
|
||||
#include "HxProcess.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
@ -112,6 +112,10 @@ bool HxSystem::get_memory_status(double *memory_use, double *memory_total, doubl
|
|||
|
||||
bool HxSystem::get_program_status(double *cpu_usage, double *virtual_memory, double *resident_memory)
|
||||
{
|
||||
Q_UNUSED(cpu_usage);
|
||||
Q_UNUSED(virtual_memory);
|
||||
Q_UNUSED(resident_memory);
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
auto result = HxProcess::start(QString("ps u %1").arg(getpid()));
|
||||
|
||||
|
@ -193,6 +197,8 @@ bool HxSystem::get_harddisk_temperature(QString file_system, QString *temperatur
|
|||
|
||||
bool HxSystem::get_harddisk_smart(QString file_system, QString *smart)
|
||||
{
|
||||
Q_UNUSED(file_system);
|
||||
Q_UNUSED(smart);
|
||||
#ifdef Q_OS_LINUX
|
||||
auto result = HxProcess::start(QString("echo tvis | sudo -S smartctl -i %1 | grep 'SMART support is'").arg(file_system));
|
||||
if(result.indexOf("Unavailable") != -1)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef HXSYSTEM_H
|
||||
#ifndef HXSYSTEM_H
|
||||
#define HXSYSTEM_H
|
||||
|
||||
#include <QObject>
|
||||
|
|
2
HxTask.h
2
HxTask.h
|
@ -1,4 +1,4 @@
|
|||
#ifndef HXTASK_H
|
||||
#ifndef HXTASK_H
|
||||
#define HXTASK_H
|
||||
|
||||
#include "HxTrace.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef HXTHREAD_H
|
||||
#ifndef HXTHREAD_H
|
||||
#define HXTHREAD_H
|
||||
|
||||
#include <QObject>
|
||||
|
|
Loading…
Reference in New Issue
Block a user