Diffstat (limited to 'noncore/applets/memoryapplet/memorymeter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/memoryapplet/memorymeter.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/noncore/applets/memoryapplet/memorymeter.cpp b/noncore/applets/memoryapplet/memorymeter.cpp index 54b5c52..9299f49 100644 --- a/noncore/applets/memoryapplet/memorymeter.cpp +++ b/noncore/applets/memoryapplet/memorymeter.cpp | |||
@@ -1,92 +1,95 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "memorymeter.h" | 20 | #include "memorymeter.h" |
21 | #include "memorystatus.h" | 21 | #include "memorystatus.h" |
22 | 22 | ||
23 | #include <opie2/otaskbarapplet.h> | ||
23 | #include <qtopia/power.h> | 24 | #include <qtopia/power.h> |
24 | #include <qtopia/config.h> | 25 | #include <qtopia/config.h> |
25 | |||
26 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
27 | #include <qtopia/qcopenvelope_qws.h> | 26 | #include <qtopia/qcopenvelope_qws.h> |
28 | #endif | ||
29 | 27 | ||
30 | #include <qpainter.h> | 28 | #include <qpainter.h> |
31 | #include <qtimer.h> | 29 | #include <qtimer.h> |
32 | #include <qapplication.h> | 30 | #include <qapplication.h> |
33 | 31 | ||
34 | #include <qtopia/applnk.h> | 32 | #include <qtopia/applnk.h> |
35 | 33 | ||
36 | MemoryMeter::MemoryMeter( QWidget *parent ) | 34 | MemoryMeter::MemoryMeter( QWidget *parent ) |
37 | : QWidget( parent ), memoryView(0) | 35 | : QWidget( parent ), memoryView(0) |
38 | { | 36 | { |
39 | bvsz = QSize(); | 37 | bvsz = QSize(); |
40 | if ( qApp->desktop()->height() >= 300 ) | 38 | if ( qApp->desktop()->height() >= 300 ) |
41 | { | 39 | { |
42 | memoryView = new MemoryStatus( 0, WStyle_StaysOnTop | WType_Popup ); | 40 | memoryView = new MemoryStatus( 0, WStyle_StaysOnTop | WType_Popup ); |
43 | memoryView->setFrameStyle( QFrame::Panel | QFrame::Raised ); | 41 | memoryView->setFrameStyle( QFrame::Panel | QFrame::Raised ); |
44 | } | 42 | } |
45 | else | 43 | else |
46 | { | 44 | { |
47 | memoryView = new MemoryStatus( 0 ); | 45 | memoryView = new MemoryStatus( 0 ); |
48 | memoryView->showMaximized(); | 46 | memoryView->showMaximized(); |
49 | } | 47 | } |
50 | 48 | ||
51 | Config config("MemoryPlugin"); | 49 | Config config("MemoryPlugin"); |
52 | config.setGroup("Warning levels"); | 50 | config.setGroup("Warning levels"); |
53 | low = config.readNumEntry("low", 40); | 51 | low = config.readNumEntry("low", 40); |
54 | critical = config.readNumEntry("critical", 20); | 52 | critical = config.readNumEntry("critical", 20); |
55 | 53 | ||
56 | startTimer( 10000 ); | 54 | startTimer( 10000 ); |
57 | setFixedWidth(10); | 55 | setFixedWidth(10); |
58 | setFixedHeight(AppLnk::smallIconSize()); | 56 | setFixedHeight(AppLnk::smallIconSize()); |
59 | usageTimer = new QTimer( this ); | 57 | usageTimer = new QTimer( this ); |
60 | connect( usageTimer, SIGNAL(timeout()), this, SLOT(usageTimeout()) ); | 58 | connect( usageTimer, SIGNAL(timeout()), this, SLOT(usageTimeout()) ); |
61 | timerEvent(0); | 59 | timerEvent(0); |
62 | } | 60 | } |
63 | 61 | ||
64 | MemoryMeter::~MemoryMeter() | 62 | MemoryMeter::~MemoryMeter() |
65 | { | 63 | { |
66 | delete (QWidget *) memoryView; | 64 | delete (QWidget *) memoryView; |
67 | } | 65 | } |
68 | 66 | ||
67 | int MemoryMeter::position() | ||
68 | { | ||
69 | return 7; | ||
70 | } | ||
71 | |||
69 | QSize MemoryMeter::sizeHint() const | 72 | QSize MemoryMeter::sizeHint() const |
70 | { | 73 | { |
71 | return QSize(10, AppLnk::smallIconSize()); | 74 | return QSize(10, AppLnk::smallIconSize()); |
72 | } | 75 | } |
73 | 76 | ||
74 | bool MemoryMeter::updateMemoryViewGeometry() | 77 | bool MemoryMeter::updateMemoryViewGeometry() |
75 | { | 78 | { |
76 | if (memoryView != 0) | 79 | if (memoryView != 0) |
77 | { | 80 | { |
78 | QSize sz = memoryView->sizeHint(); | 81 | QSize sz = memoryView->sizeHint(); |
79 | if ( sz != bvsz ) | 82 | if ( sz != bvsz ) |
80 | { | 83 | { |
81 | bvsz = sz; | 84 | bvsz = sz; |
82 | QRect r(memoryView->pos(), memoryView->sizeHint()); | 85 | QRect r(memoryView->pos(), memoryView->sizeHint()); |
83 | if ( qApp->desktop()->height() >= 300 ) | 86 | if ( qApp->desktop()->height() >= 300 ) |
84 | { | 87 | { |
85 | QPoint curPos = mapToGlobal( rect().topLeft() ); | 88 | QPoint curPos = mapToGlobal( rect().topLeft() ); |
86 | int lp = qApp->desktop()->width() - memoryView->sizeHint().width(); | 89 | int lp = qApp->desktop()->width() - memoryView->sizeHint().width(); |
87 | r.moveTopLeft( QPoint(lp, curPos.y() - memoryView->sizeHint().height()-1) ); | 90 | r.moveTopLeft( QPoint(lp, curPos.y() - memoryView->sizeHint().height()-1) ); |
88 | } | 91 | } |
89 | memoryView->setGeometry(r); | 92 | memoryView->setGeometry(r); |
90 | return TRUE; | 93 | return TRUE; |
91 | } | 94 | } |
92 | return FALSE; | 95 | return FALSE; |
@@ -216,24 +219,29 @@ void MemoryMeter::paintEvent( QPaintEvent* ) | |||
216 | p.setBrush(gray/*.dark(120)*/); | 219 | p.setBrush(gray/*.dark(120)*/); |
217 | p.drawRect(batt_xoffset + 3 * band_width, batt_yoffset, band_width, used_height); | 220 | p.drawRect(batt_xoffset + 3 * band_width, batt_yoffset, band_width, used_height); |
218 | } | 221 | } |
219 | 222 | ||
220 | // | 223 | // |
221 | // Unused section. | 224 | // Unused section. |
222 | // | 225 | // |
223 | if ( batt_height - used_height > 0 ) | 226 | if ( batt_height - used_height > 0 ) |
224 | { | 227 | { |
225 | int unused_offset = used_height + batt_yoffset; | 228 | int unused_offset = used_height + batt_yoffset; |
226 | int unused_height = batt_height - used_height; | 229 | int unused_height = batt_height - used_height; |
227 | p.setPen(NoPen); | 230 | p.setPen(NoPen); |
228 | p.setBrush(c); | 231 | p.setBrush(c); |
229 | p.drawRect(batt_xoffset, unused_offset, band_width, unused_height); | 232 | p.drawRect(batt_xoffset, unused_offset, band_width, unused_height); |
230 | p.drawRect(batt_xoffset + 2 * band_width, unused_offset, band_width, unused_height); | 233 | p.drawRect(batt_xoffset + 2 * band_width, unused_offset, band_width, unused_height); |
231 | 234 | ||
232 | p.setBrush(lightc); | 235 | p.setBrush(lightc); |
233 | p.drawRect(batt_xoffset + band_width, unused_offset, band_width, unused_height); | 236 | p.drawRect(batt_xoffset + band_width, unused_offset, band_width, unused_height); |
234 | 237 | ||
235 | p.setBrush(darkc); | 238 | p.setBrush(darkc); |
236 | p.drawRect(batt_xoffset + 3 * band_width, unused_offset, band_width, unused_height); | 239 | p.drawRect(batt_xoffset + 3 * band_width, unused_offset, band_width, unused_height); |
237 | } | 240 | } |
238 | } | 241 | } |
239 | 242 | ||
243 | Q_EXPORT_INTERFACE() | ||
244 | { | ||
245 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<MemoryMeter> ); | ||
246 | } | ||
247 | |||