summaryrefslogtreecommitdiff
path: root/noncore/applets/memoryapplet/memorystatus.cpp
Unidiff
Diffstat (limited to 'noncore/applets/memoryapplet/memorystatus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/memoryapplet/memorystatus.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/noncore/applets/memoryapplet/memorystatus.cpp b/noncore/applets/memoryapplet/memorystatus.cpp
new file mode 100644
index 0000000..a800fa5
--- a/dev/null
+++ b/noncore/applets/memoryapplet/memorystatus.cpp
@@ -0,0 +1,82 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include "memorystatus.h"
21#include "../../apps/sysinfo/memory.h"
22#include "swapfile.h"
23
24#include <qpainter.h>
25#include <qpushbutton.h>
26#include <qdrawutil.h>
27#include <qlabel.h>
28
29#include <opie/otabwidget.h>
30#include <qlayout.h>
31
32MemoryStatus::MemoryStatus(QWidget *parent, WFlags f )
33 : QFrame(parent, 0, f), mi(0), sf(0)
34{
35 setCaption( tr("Memory Status") );
36 //resize( 220, 180 );
37
38 QVBoxLayout *lay = new QVBoxLayout( this );
39 tab = new OTabWidget( this, "tabwidget", OTabWidget::Global );
40 lay->addWidget( tab );
41 tab->addTab( mi = new MemoryInfo( tab ), "memory/memorytabicon", tr("Memory") );
42 tab->addTab( sf = new Swapfile( tab ), "memory/storagetabicon", tr("Swapfile") );
43
44 QLabel* about = new QLabel(tr("<center><b>Memory Monitor Plugin</b><br>"
45 "Copyright (C) 2003 Anton Maslovsky<br>"
46 "&lt;<a href=\"mailto:my-zaurus@narod.ru\">my-zaurus@narod.ru</a>&gt;<br>"
47 "<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>"
49 "This program is licensed under GNU GPL.</center>"), tab);
50
51 tab->addTab( about, "memory/info", tr("About") );
52
53 tab->setCurrentTab( tr( "Memory" ) );
54}
55
56int MemoryStatus::percent()
57{
58 if (mi == 0)
59 return 100;
60
61 int total = mi->total;
62 if (mi->swaptotal > 0)
63 total += mi->swaptotal;
64
65 int used = mi->realUsed;
66 if (mi->swapused > 0)
67 total += mi->swapused;
68
69 return ((total - used) * 100)/total;
70}
71
72QSize MemoryStatus::sizeHint() const
73{
74 QSize s = tab->size();
75 s.setWidth(200);
76 s.setHeight((mi->swaptotal > 0) ? 220 : 200);
77 return s;
78}
79
80MemoryStatus::~MemoryStatus()
81{
82}