aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop/desktop-plugins/systemmonitor
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
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')
-rw-r--r--lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp61
-rw-r--r--lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.h57
-rw-r--r--lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.ui99
3 files changed, 217 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
diff --git a/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.h b/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.h
new file mode 100644
index 00000000..08e8c09c
--- /dev/null
+++ b/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.h
@@ -0,0 +1,57 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This plugin is a simple hardware status monitor on the desktop
+//===========================================
+#ifndef _LUMINA_DESKTOP_PLUGIN_HW_MONITOR_WIDGET_H
+#define _LUMINA_DESKTOP_PLUGIN_HW_MONITOR_WIDGET_H
+
+#include <QTimer>
+#include <QWidget>
+
+#include "../LDPlugin.h"
+
+namespace Ui{
+ class MonitorWidget;
+};
+
+class MonitorWidget : public QWidget{
+ Q_OBJECT
+public:
+ MonitorWidget(QWidget *parent = 0);
+ ~MonitorWidget();
+
+public slots:
+ void LoadIcons();
+
+private:
+ Ui::MonitorWidget *ui;
+ QTimer *upTimer;
+
+private slots:
+ void UpdateStats();
+};
+
+// Wrapper class to put this into a desktop plugin container
+class SysMonitorPlugin : public LDPlugin{
+ Q_OBJECT
+public:
+ SysMonitorPlugin(QWidget* parent, QString ID);
+ ~SysMonitorPlugin();
+
+private:
+ MonitorWidget *monitor;
+
+public slots:
+ void LocaleChange(){
+ QTimer::singleShot(0,monitor, SLOT(LoadIcons()));
+ }
+ void ThemeChange(){
+ QTimer::singleShot(0,monitor, SLOT(LoadIcons()));
+ }
+};
+
+#endif
diff --git a/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.ui b/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.ui
new file mode 100644
index 00000000..c3a58017
--- /dev/null
+++ b/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.ui
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MonitorWidget</class>
+ <widget class="QWidget" name="MonitorWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>300</width>
+ <height>122</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="leftMargin">
+ <number>2</number>
+ </property>
+ <property name="topMargin">
+ <number>2</number>
+ </property>
+ <property name="rightMargin">
+ <number>2</number>
+ </property>
+ <property name="bottomMargin">
+ <number>2</number>
+ </property>
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Summary</string>
+ </attribute>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>CPU Temp:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label_temps">
+ <property name="text">
+ <string notr="true"/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>CPU Usage:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QProgressBar" name="progress_cpu">
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Mem Usage:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QProgressBar" name="progress_mem">
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>CPU Log</string>
+ </attribute>
+ </widget>
+ <widget class="QWidget" name="tab_3">
+ <attribute name="title">
+ <string>Memory Log</string>
+ </attribute>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
bgstack15