Diffstat (limited to 'noncore/applets/memoryapplet/memorymeter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/memoryapplet/memorymeter.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/noncore/applets/memoryapplet/memorymeter.cpp b/noncore/applets/memoryapplet/memorymeter.cpp index 9299f49..9cdeaf4 100644 --- a/noncore/applets/memoryapplet/memorymeter.cpp +++ b/noncore/applets/memoryapplet/memorymeter.cpp @@ -22,34 +22,35 @@ #include <opie2/otaskbarapplet.h> #include <qtopia/power.h> #include <qtopia/config.h> #include <qtopia/qcopenvelope_qws.h> #include <qpainter.h> #include <qtimer.h> #include <qapplication.h> #include <qtopia/applnk.h> +using namespace Opie::Ui; MemoryMeter::MemoryMeter( QWidget *parent ) : QWidget( parent ), memoryView(0) { bvsz = QSize(); - if ( qApp->desktop()->height() >= 300 ) + if ( qApp->desktop()->height() >= 300 ) { memoryView = new MemoryStatus( 0, WStyle_StaysOnTop | WType_Popup ); memoryView->setFrameStyle( QFrame::Panel | QFrame::Raised ); - } - else + } + else { memoryView = new MemoryStatus( 0 ); memoryView->showMaximized(); } Config config("MemoryPlugin"); config.setGroup("Warning levels"); low = config.readNumEntry("low", 40); critical = config.readNumEntry("critical", 20); startTimer( 10000 ); setFixedWidth(10); @@ -70,50 +71,50 @@ int MemoryMeter::position() } QSize MemoryMeter::sizeHint() const { return QSize(10, AppLnk::smallIconSize()); } bool MemoryMeter::updateMemoryViewGeometry() { if (memoryView != 0) { QSize sz = memoryView->sizeHint(); - if ( sz != bvsz ) + if ( sz != bvsz ) { bvsz = sz; QRect r(memoryView->pos(), memoryView->sizeHint()); - if ( qApp->desktop()->height() >= 300 ) + if ( qApp->desktop()->height() >= 300 ) { QPoint curPos = mapToGlobal( rect().topLeft() ); int lp = qApp->desktop()->width() - memoryView->sizeHint().width(); r.moveTopLeft( QPoint(lp, curPos.y() - memoryView->sizeHint().height()-1) ); } memoryView->setGeometry(r); return TRUE; } return FALSE; } return FALSE; } void MemoryMeter::mousePressEvent( QMouseEvent *) { - if ( memoryView->isVisible() ) + if ( memoryView->isVisible() ) { memoryView->hide(); - } - else + } + else { bvsz = QSize(); updateMemoryViewGeometry(); memoryView->raise(); memoryView->show(); } } void MemoryMeter::timerEvent( QTimerEvent * ) { if (memoryView != 0) { @@ -197,51 +198,48 @@ void MemoryMeter::paintEvent( QPaintEvent* ) // // 100 - percent, since percent is amount remaining, and we draw // reverse to this. // used_height = percent * batt_height / 100; if (used_height < 0) used_height = 0; // // Drained section. // - if (used_height != 0) + if (used_height != 0) { p.setPen(NoPen); p.setBrush(gray); p.drawRect(batt_xoffset, batt_yoffset, band_width, used_height); p.drawRect(batt_xoffset + 2 * band_width, batt_yoffset, band_width, used_height); p.setBrush(gray/*.light(130)*/); p.drawRect(batt_xoffset + band_width, batt_yoffset, band_width, used_height); p.setBrush(gray/*.dark(120)*/); p.drawRect(batt_xoffset + 3 * band_width, batt_yoffset, band_width, used_height); } // // Unused section. // - if ( batt_height - used_height > 0 ) + if ( batt_height - used_height > 0 ) { int unused_offset = used_height + batt_yoffset; int unused_height = batt_height - used_height; p.setPen(NoPen); p.setBrush(c); p.drawRect(batt_xoffset, unused_offset, band_width, unused_height); p.drawRect(batt_xoffset + 2 * band_width, unused_offset, band_width, unused_height); p.setBrush(lightc); p.drawRect(batt_xoffset + band_width, unused_offset, band_width, unused_height); p.setBrush(darkc); p.drawRect(batt_xoffset + 3 * band_width, unused_offset, band_width, unused_height); } } -Q_EXPORT_INTERFACE() -{ - Q_CREATE_INSTANCE( OTaskbarAppletWrapper<MemoryMeter> ); -} +EXPORT_OPIE_APPLET_v1( MemoryMeter ) |