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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/***************************************************************************
rampanel.cpp - description
-------------------
begin : Fri Jan 11 2002
copyright : (C) 2002 by Miguel Novas
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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(TQWidget *parent, const char *name, RamType type): Panel(parent,name)
{
ramType= type;
memTotal= -1;
memUsed = -1;
arc = new TQDialArc(this);
arc->installEventFilter(this);
arc->setAngles(180,-180);
arc->setGeometry( 6 , 64/4+9, 64-10, 64/2-8);
arc->setColorRanges(red,red,TQColor(0,200,150)); // TQColor(0,200,0));
lcd1= new TQLCDString(this);
lcd1->setGeometry(6, 8,54,11);
lcd1->setShadow(true);
lcd1->setForeColor(getColorValue());
lcd1->setAlign(TQLCDString::alignCenter);
lcd1->installEventFilter(this);
lcd2= new TQLCDString(this);
lcd2->setGeometry(4, 52,58,8);
lcd2->setForeColor(getColorTitle());
lcd2->setAlign(TQLCDString::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);
TQString str;
str.sprintf ( ramType==memSWAP ? "SWP %dM" : "RAM %dM", newMemTotal);
lcd2->display(str);
memTotal= newMemTotal;
}
if(memUsed!=newMemUsed) {
TQString str;
str.sprintf ("%dM" , newMemUsed );
lcd1->display(str);
arc->setValue(newMemUsed);
arc->setValueLimitRanges(newMemUsed,newMemUsed);
memUsed = newMemUsed;
}
}
void RamPanel::paletteChange(const TQPalette &oldPalette)
{
lcd2->setForeColor(getColorTitle());
lcd1->setForeColor(getColorValue());
arc->setArrowColor(getColorValue());
}
void RamPanel::resizeEvent ( TQResizeEvent *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);
}
|