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