From 766980aeaba64e23001c7437220dd67afd70c052 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 22 May 2015 12:11:01 -0400 Subject: Finish cleaning up the new CPU/Memory desction routines in libLumina, and add a new desktop plugin for monitoring system statistics (CPU/Mem usage, CPU temps). --- .../systemmonitor/MonitorWidget.cpp | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp (limited to 'lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp') diff --git a/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp b/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp new file mode 100644 index 00000000..419b33cb --- /dev/null +++ b/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp @@ -0,0 +1,61 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2015, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "MonitorWidget.h" +#include "ui_MonitorWidget.h" + + +#include +#include + +MonitorWidget::MonitorWidget(QWidget *parent) : QWidget(parent), ui(new Ui::MonitorWidget()){ + ui->setupUi(this); //load the designer form + upTimer = new QTimer(this); + upTimer->setInterval(2000); //update every 2 seconds + connect(upTimer, SIGNAL(timeout()), this, SLOT(UpdateStats()) ); + LoadIcons(); + upTimer->start(); +} + +MonitorWidget::~MonitorWidget(){ + //qDebug() << "Removing MonitorWidget"; +} + +void MonitorWidget::LoadIcons(){ + ui->tabWidget->setTabIcon(0,LXDG::findIcon("appointment-recurring","") ); //Summary + ui->tabWidget->setTabIcon(1,LXDG::findIcon("cpu","") ); //CPU Log + ui->tabWidget->setTabIcon(2,LXDG::findIcon("media-flash-memory","") ); //Mem Log +} + +void MonitorWidget::UpdateStats(){ + //qDebug() << "Updating System statistics..."; + ui->label_temps->setText( LOS::CPUTemperatures().join(", ") ); + if(ui->progress_cpu->isEnabled()){ + int perc = LOS::CPUUsagePercent(); + ui->progress_cpu->setValue(perc); + if(perc<0){ ui->progress_cpu->setEnabled(false); } //disable this for future checks + } + if(ui->progress_mem->isEnabled()){ + int perc = LOS::MemoryUsagePercent(); + ui->progress_mem->setValue(perc); + if(perc<0){ ui->progress_mem->setEnabled(false); } //disable this for future checks + } + //Also perform/update the logs as necessary + // -- TO DO -- +} + +SysMonitorPlugin::SysMonitorPlugin(QWidget *parent, QString ID) : LDPlugin(parent, ID, true){ + monitor = new MonitorWidget(this); + this->setLayout( new QVBoxLayout() ); + this->layout()->setContentsMargins(0,0,0,0); + this->layout()->addWidget(monitor); + + this->setInitialSize(300,75); +} + +SysMonitorPlugin::~SysMonitorPlugin(){ + //qDebug() << "Remove SysMonitorPlugin"; +} \ No newline at end of file -- cgit