summaryrefslogtreecommitdiffstats
path: root/src/infopanels.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-07-24 09:39:37 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-07-24 09:39:37 -0500
commit191c434271e705161fbd01ed83b6d043a275bffc (patch)
tree0919a0a91d56167a9d36bca3881c513006b68a9b /src/infopanels.cpp
downloadksensors-191c434271e705161fbd01ed83b6d043a275bffc.tar.gz
ksensors-191c434271e705161fbd01ed83b6d043a275bffc.zip
Initial import of ksensors 0.7.3 sources
Diffstat (limited to 'src/infopanels.cpp')
-rw-r--r--src/infopanels.cpp91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/infopanels.cpp b/src/infopanels.cpp
new file mode 100644
index 0000000..18d4736
--- /dev/null
+++ b/src/infopanels.cpp
@@ -0,0 +1,91 @@
+/***************************************************************************
+ infopanels.cpp - description
+ -------------------
+ begin : vie may 10 2002
+ copyright : (C) 2002 by Miguel Novas
+ email : michaell@teleline.es
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "infopanels.h"
+
+
+
+InfoPanels::InfoPanels(QWidget *panelsWidget, QObject *parent, const char *name): PanelsGroup(widget,parent,name)
+{
+ widget= panelsWidget;
+ timerPanelCount=0;
+ timer = new QTimer(this);
+ configChanged("proc.CPUINFO");
+ configChanged("proc.RAMINFO");
+ configChanged("proc.SWAPINFO");
+ configChanged("proc.CPULOAD");
+ configChanged("proc.UPTIME");
+}
+
+InfoPanels::~InfoPanels(){
+}
+
+void InfoPanels::configChanged(const char *name)
+{
+ if(!strcmp(name,"proc")) readUpdateInterval();
+ else {
+ Panel *panel= (Panel *)widget->child(name);
+ if( Panel::readShow(name)!= (bool)panel ) {
+ if(panel) delete panel;
+ else {
+ if(!strcmp(name,"proc.CPUINFO" )) panel= new CpuPanel(widget,name);
+ else
+ if(!strcmp(name,"proc.RAMINFO" )) panel= new RamPanel(widget,name,RamPanel::memRAM);
+ else
+ if(!strcmp(name,"proc.SWAPINFO")) panel= new RamPanel(widget,name,RamPanel::memSWAP);
+ else
+ if(!strcmp(name,"proc.CPULOAD" )) panel= new CpuTimePanel(widget,name);
+ else
+ if(!strcmp(name,"proc.UPTIME" )) panel= new UpTimePanel(widget,name);
+ if(panel) timerConnect(panel);
+ }
+ }
+ }
+}
+
+void InfoPanels::timerConnect(Panel *display)
+{
+ if(timerPanelCount==0) timer->start( cfgReadUpdateInterval()*1000 );
+ connect( timer , SIGNAL(timeout() ), display, SLOT(updateInfo()) );
+ connect( display, SIGNAL(destroyed()), this , SLOT(infoPanelDestroyed()) );
+ timerPanelCount++;
+}
+
+void InfoPanels::infoPanelDestroyed()
+{
+ if(--timerPanelCount<=0) timer->stop();
+}
+
+void InfoPanels::cfgWriteUpdateInterval(int interval)
+{
+ KGlobal::config()->setGroup("ShowWidget");
+ KGlobal::config()->writeEntry("UpdateInterval" , interval );
+}
+
+int InfoPanels::cfgReadUpdateInterval()
+{
+ KGlobal::config()->setGroup("ShowWidget");
+ return KGlobal::config()->readNumEntry("UpdateInterval" , 5 );
+}
+
+void InfoPanels::readUpdateInterval()
+{
+ timer->changeInterval(cfgReadUpdateInterval()*1000);
+}
+
+// ******************* Public static methods **********************
+