mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 10:42:29 +01:00
Cleanup sysinfo SDK to use smart pointer
This commit is contained in:
parent
de8afdc9cd
commit
0da9cc7435
@ -7,7 +7,6 @@
|
||||
|
||||
CPU::CPU(QObject *parent) : QObject(parent)
|
||||
{
|
||||
// signal obj, signal function pointer, slot obj, slot function pointer
|
||||
connect(&m_updateTimer,&QTimer::timeout,this,&CPU::update);
|
||||
m_updateTimer.start(m_tickRate);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <QString>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <qt_windows.h>
|
||||
#endif
|
||||
|
@ -1,15 +1,8 @@
|
||||
#include "sysinfo.h"
|
||||
|
||||
SysInfo::SysInfo(QQuickItem *parent):
|
||||
QQuickItem(parent)
|
||||
SysInfo::SysInfo(QQuickItem* parent)
|
||||
: QQuickItem(parent)
|
||||
, m_ram(std::make_unique<RAM>())
|
||||
, m_cpu(std::make_unique<CPU>())
|
||||
{
|
||||
// FIXME Elias 2018 QQmlEngine cannot handle smartpointers yet....
|
||||
m_ram = new RAM();
|
||||
m_cpu = new CPU();
|
||||
}
|
||||
|
||||
SysInfo::~SysInfo()
|
||||
{
|
||||
delete m_cpu;
|
||||
delete m_ram;
|
||||
}
|
||||
|
@ -1,30 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <QQuickItem>
|
||||
#include <memory>
|
||||
|
||||
#include "cpu.h"
|
||||
#include "ram.h"
|
||||
#include <QQuickItem>
|
||||
#include <QSharedPointer>
|
||||
#include <memory>
|
||||
|
||||
class SysInfo : public QQuickItem {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(SysInfo)
|
||||
|
||||
Q_PROPERTY(RAM* ram READ ram NOTIFY ramChanged)
|
||||
Q_PROPERTY(CPU* cpu READ cpu NOTIFY cpuChanged)
|
||||
|
||||
public:
|
||||
SysInfo(QQuickItem* parent = nullptr);
|
||||
~SysInfo();
|
||||
~SysInfo(){}
|
||||
|
||||
RAM* ram() const
|
||||
{
|
||||
return m_ram;
|
||||
return m_ram.get();
|
||||
}
|
||||
|
||||
CPU* cpu() const
|
||||
{
|
||||
return m_cpu;
|
||||
return m_cpu.get();
|
||||
}
|
||||
|
||||
public slots:
|
||||
@ -34,6 +33,6 @@ signals:
|
||||
void cpuChanged(CPU* cpu);
|
||||
|
||||
private:
|
||||
RAM* m_ram;
|
||||
CPU* m_cpu;
|
||||
std::unique_ptr<RAM> m_ram;
|
||||
std::unique_ptr<CPU> m_cpu;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user