Increase heap size on Symbian.
[dorian] / widgets / translucentbutton.cpp
index 3a37aa3..3b4121e 100644 (file)
@@ -4,15 +4,18 @@
 #include "platform.h"
 
 const int TranslucentButton::pixels = 95;
+const int TranslucentButton::elevatorInterval = 750;
 
 TranslucentButton::TranslucentButton(const QString &name_, QWidget *parent):
     QLabel(parent), name(name_), transparent(true)
 {
-    setGeometry(0, 0, pixels, pixels);
-    timer = new QTimer(this);
-    timer->setSingleShot(true);
-    connect(timer, SIGNAL(timeout()), this, SLOT(stopFlash()));
-    show();
+    setFixedSize(pixels, pixels);
+    elevatorTimer = startTimer(elevatorInterval);
+}
+
+TranslucentButton::~TranslucentButton()
+{
+    killTimer(elevatorTimer);
 }
 
 void TranslucentButton::paintEvent(QPaintEvent *)
@@ -20,7 +23,7 @@ void TranslucentButton::paintEvent(QPaintEvent *)
     QPainter painter(this);
     if (!transparent) {
         painter.setRenderHint(QPainter::Antialiasing, true);
-        painter.drawPixmap(0, 0, QPixmap(Platform::icon(name)).scaled(
+        painter.drawPixmap(0, 0, QPixmap(Platform::instance()->icon(name)).scaled(
                 QSize(pixels, pixels), Qt::IgnoreAspectRatio,
                 Qt::SmoothTransformation));
     } else {
@@ -30,11 +33,11 @@ void TranslucentButton::paintEvent(QPaintEvent *)
 
 void TranslucentButton::flash(int duration)
 {
-    show();
     raise();
+    show();
     transparent = false;
     update();
-    timer->start(duration);
+    QTimer::singleShot(duration, this, SLOT(stopFlash()));
 }
 
 void TranslucentButton::stopFlash()
@@ -49,3 +52,11 @@ void TranslucentButton::mouseReleaseEvent(QMouseEvent *e)
     emit triggered();
     e->accept();
 }
+
+void TranslucentButton::timerEvent(QTimerEvent *e)
+{
+    if (e->timerId() == elevatorTimer) {
+        raise();
+    }
+    QLabel::timerEvent(e);
+}