1
0
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:
Elias Steurer 2019-09-01 12:01:42 +02:00
parent de8afdc9cd
commit 0da9cc7435
4 changed files with 13 additions and 21 deletions

View File

@ -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);
}

View File

@ -4,6 +4,7 @@
#include <QDebug>
#include <QTimer>
#include <QString>
#ifdef Q_OS_WIN
#include <qt_windows.h>
#endif

View File

@ -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;
}

View File

@ -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;
};