aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp
diff options
context:
space:
mode:
authorKen Moore <ken@pcbsd.org>2015-05-22 12:11:01 -0400
committerKen Moore <ken@pcbsd.org>2015-05-22 12:11:01 -0400
commit766980aeaba64e23001c7437220dd67afd70c052 (patch)
treedad60ac664a3598aee13d0801b3334aeea0d1220 /lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp
parentAdd a few new functions to LuminaOS: (diff)
downloadlumina-766980aeaba64e23001c7437220dd67afd70c052.tar.gz
lumina-766980aeaba64e23001c7437220dd67afd70c052.tar.bz2
lumina-766980aeaba64e23001c7437220dd67afd70c052.zip
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).
Diffstat (limited to 'lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp')
-rw-r--r--lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp61
1 files changed, 61 insertions, 0 deletions
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 <LuminaXDG.h>
+#include <LuminaOS.h>
+
+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
bgstack15