summaryrefslogtreecommitdiffstats
path: root/src/rampanel.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/rampanel.cpp
downloadksensors-191c434271e705161fbd01ed83b6d043a275bffc.tar.gz
ksensors-191c434271e705161fbd01ed83b6d043a275bffc.zip
Initial import of ksensors 0.7.3 sources
Diffstat (limited to 'src/rampanel.cpp')
-rw-r--r--src/rampanel.cpp106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/rampanel.cpp b/src/rampanel.cpp
new file mode 100644
index 0000000..b927ffb
--- /dev/null
+++ b/src/rampanel.cpp
@@ -0,0 +1,106 @@
+/***************************************************************************
+ rampanel.cpp - description
+ -------------------
+ begin : Fri Jan 11 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 "rampanel.h"
+
+#include "procinfo.h"
+
+RamPanel::RamPanel(QWidget *parent, const char *name, RamType type): Panel(parent,name)
+{
+ ramType= type;
+ memTotal= -1;
+ memUsed = -1;
+
+ arc = new QDialArc(this);
+ arc->installEventFilter(this);
+ arc->setAngles(180,-180);
+ arc->setGeometry( 6 , 64/4+9, 64-10, 64/2-8);
+ arc->setColorRanges(red,red,QColor(0,200,150)); // QColor(0,200,0));
+
+ lcd1= new QLCDString(this);
+ lcd1->setGeometry(6, 8,54,11);
+ lcd1->setShadow(true);
+ lcd1->setForeColor(getColorValue());
+ lcd1->setAlign(QLCDString::alignCenter);
+ lcd1->installEventFilter(this);
+
+ lcd2= new QLCDString(this);
+ lcd2->setGeometry(4, 52,58,8);
+ lcd2->setForeColor(getColorTitle());
+ lcd2->setAlign(QLCDString::alignCenter);
+ lcd2->installEventFilter(this);
+
+ updateInfo();
+}
+
+RamPanel::~RamPanel(){
+}
+
+
+void RamPanel::updateInfo()
+{
+ int newMemTotal,newMemUsed,newSwapTotal,newSwapUsed;
+
+ getMemInfo(&newMemTotal,&newMemUsed,&newSwapTotal,&newSwapUsed);
+
+ if(ramType==memSWAP) {
+ newMemTotal= newSwapTotal;
+ newMemUsed = newSwapUsed;
+ }
+
+ newMemUsed /=1024;
+ newMemTotal/=1024;
+
+ if(memTotal!=newMemTotal) {
+ arc->setValueRanges(0,newMemTotal);
+ QString str;
+ str.sprintf ( ramType==memSWAP ? "SWP %dM" : "RAM %dM", newMemTotal);
+ lcd2->display(str);
+ memTotal= newMemTotal;
+ }
+
+ if(memUsed!=newMemUsed) {
+ QString str;
+ str.sprintf ("%dM" , newMemUsed );
+ lcd1->display(str);
+ arc->setValue(newMemUsed);
+ arc->setValueLimitRanges(newMemUsed,newMemUsed);
+ memUsed = newMemUsed;
+ }
+
+}
+
+
+void RamPanel::paletteChange(const QPalette &oldPalette)
+{
+ lcd2->setForeColor(getColorTitle());
+ lcd1->setForeColor(getColorValue());
+ arc->setArrowColor(getColorValue());
+}
+
+void RamPanel::resizeEvent ( QResizeEvent *e )
+{
+ int w= width();
+ int h= height();
+
+ int i1= (h * 2) / 5;
+ int i2= (h * 4) / 5;
+
+ lcd1->setGeometry( 3 , h/8 , w -4 , h/4-h/16);
+ arc ->setGeometry( 3 , i1 , w -6 , i2-i1-2 );
+ lcd2->setGeometry( 3 , i2+1, w -6 , h-i2-h/11);
+}