1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
//===========================================
// 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("drive-harddisk","") ); //Disk Usage
//ui->tabWidget->setTabIcon(1,LXDG::findIcon("cpu","") ); //CPU Log
//ui->tabWidget->setTabIcon(2,LXDG::findIcon("media-flash-memory-stick","") ); //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
}
ui->label_diskinfo->setText( LOS::DiskUsage().join("\n") );
//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(monitor->width(),monitor->height());
}
SysMonitorPlugin::~SysMonitorPlugin(){
//qDebug() << "Remove SysMonitorPlugin";
}
|