Diffstat (limited to 'noncore/applets/memoryapplet/memorystatus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/memoryapplet/memorystatus.cpp | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/noncore/applets/memoryapplet/memorystatus.cpp b/noncore/applets/memoryapplet/memorystatus.cpp index b738312..c01ba28 100644 --- a/noncore/applets/memoryapplet/memorystatus.cpp +++ b/noncore/applets/memoryapplet/memorystatus.cpp | |||
@@ -17,66 +17,65 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "memorystatus.h" | 20 | #include "memorystatus.h" |
21 | #include "../../settings/sysinfo/memory.h" | 21 | #include "../../settings/sysinfo/memory.h" |
22 | #include "swapfile.h" | 22 | #include "swapfile.h" |
23 | 23 | ||
24 | #include <qpainter.h> | 24 | #include <qpainter.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qdrawutil.h> | 26 | #include <qdrawutil.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | 28 | ||
29 | #include <opie/otabwidget.h> | ||
30 | #include <qlayout.h> | 29 | #include <qlayout.h> |
31 | 30 | ||
32 | MemoryStatus::MemoryStatus(QWidget *parent, WFlags f ) | 31 | MemoryStatus::MemoryStatus(QWidget *parent, WFlags f ) |
33 | : QFrame(parent, 0, f), mi(0), sf(0) | 32 | : QFrame(parent, 0, f), mi(0), sf(0) |
34 | { | 33 | { |
35 | setCaption( tr("Memory Status") ); | 34 | setCaption( tr("Memory Status") ); |
36 | //resize( 220, 180 ); | 35 | //resize( 220, 180 ); |
37 | 36 | ||
38 | QVBoxLayout *lay = new QVBoxLayout( this ); | 37 | QVBoxLayout *lay = new QVBoxLayout( this ); |
39 | tab = new OTabWidget( this, "tabwidget", OTabWidget::Global ); | 38 | tab = new OTabWidget( this, "tabwidget", OTabWidget::Global ); |
40 | lay->addWidget( tab ); | 39 | lay->addWidget( tab ); |
41 | tab->addTab( mi = new MemoryInfo( tab ), "memory/memorytabicon", tr("Memory") ); | 40 | tab->addTab( mi = new MemoryInfo( tab ), "memory/memorytabicon", tr("Memory") ); |
42 | tab->addTab( sf = new Swapfile( tab ), "memory/storagetabicon", tr("Swapfile") ); | 41 | tab->addTab( sf = new Swapfile( tab ), "memory/storagetabicon", tr("Swapfile") ); |
43 | 42 | ||
44 | QLabel* about = new QLabel(tr("<center><b>Memory Monitor Plugin</b><br>" | 43 | QLabel* about = new QLabel(tr("<center><b>Memory Monitor Plugin</b><br>" |
45 | "Copyright (C) 2003 Anton Maslovsky<br>" | 44 | "Copyright (C) 2003 Anton Maslovsky<br>" |
46 | "<<a href=\"mailto:my-zaurus@narod.ru\">my-zaurus@narod.ru</a>><br>" | 45 | "<<a href=\"mailto:my-zaurus@narod.ru\">my-zaurus@narod.ru</a>><br>" |
47 | "<a href=\"http://my-zaurus.narod.ru\">http://my-zaurus.narod.ru</a><br>" | 46 | "<a href=\"http://my-zaurus.narod.ru\">http://my-zaurus.narod.ru</a><br>" |
48 | "Based on source code from:<br> qswap (udoseidel@gmx.de) <br> Battery Applet (trolltech.com) <br> SysInfo (OPIE)<br><br>" | 47 | "Based on source code from:<br> qswap (udoseidel@gmx.de) <br> Battery Applet (trolltech.com) <br> SysInfo (OPIE)<br><br>" |
49 | "This program is licensed under GNU GPL.</center>"), tab); | 48 | "This program is licensed under GNU GPL.</center>"), tab); |
50 | 49 | ||
51 | tab->addTab( about, "memory/info", tr("About") ); | 50 | tab->addTab( about, "memory/info", tr("About") ); |
52 | 51 | ||
53 | tab->setCurrentTab( tr( "Memory" ) ); | 52 | tab->setCurrentTab( tr( "Memory" ) ); |
54 | } | 53 | } |
55 | 54 | ||
56 | int MemoryStatus::percent() | 55 | int MemoryStatus::percent() |
57 | { | 56 | { |
58 | if (mi == 0) | 57 | if (mi == 0) |
59 | return 100; | 58 | return 100; |
60 | 59 | ||
61 | int total = mi->total; | 60 | int total = mi->total; |
62 | if (mi->swaptotal > 0) | 61 | if (mi->swaptotal > 0) |
63 | total += mi->swaptotal; | 62 | total += mi->swaptotal; |
64 | 63 | ||
65 | int used = mi->realUsed; | 64 | int used = mi->realUsed; |
66 | if (mi->swapused > 0) | 65 | if (mi->swapused > 0) |
67 | total += mi->swapused; | 66 | total += mi->swapused; |
68 | 67 | ||
69 | return ((total - used) * 100)/total; | 68 | return ((total - used) * 100)/total; |
70 | } | 69 | } |
71 | 70 | ||
72 | QSize MemoryStatus::sizeHint() const | 71 | QSize MemoryStatus::sizeHint() const |
73 | { | 72 | { |
74 | QSize s = tab->size(); | 73 | QSize s = tab->size(); |
75 | s.setWidth(200); | 74 | s.setWidth(200); |
76 | s.setHeight((mi->swaptotal > 0) ? 220 : 200); | 75 | s.setHeight((mi->swaptotal > 0) ? 220 : 200); |
77 | return s; | 76 | return s; |
78 | } | 77 | } |
79 | 78 | ||
80 | MemoryStatus::~MemoryStatus() | 79 | MemoryStatus::~MemoryStatus() |
81 | { | 80 | { |
82 | } | 81 | } |