]> git.sesse.net Git - kdenlive/blobdiff - src/statusbarmessagelabel.cpp
cleanup
[kdenlive] / src / statusbarmessagelabel.cpp
index b7a5581257378e34924c0f98eed275b2245b7cfd..5e65f2e4c5c2abd18174cd9a9efd9d96feafb3c3 100644 (file)
@@ -26,6 +26,7 @@
 #include <kiconloader.h>
 #include <kicon.h>
 #include <klocale.h>
+#include <KNotification>
 
 #include <QFontMetrics>
 #include <QPainter>
@@ -47,8 +48,10 @@ StatusBarMessageLabel::StatusBarMessageLabel(QWidget* parent) :
     QPalette palette;
     palette.setColor(QPalette::Background, Qt::transparent);
     setPalette(palette);
-
+    m_hidetimer.setSingleShot(true);
+    m_hidetimer.setInterval(5000);
     connect(&m_timer, SIGNAL(timeout()), this, SLOT(timerDone()));
+    connect(&m_hidetimer, SIGNAL(timeout()), this, SLOT(closeErrorMessage()));
 
     m_closeButton = new QPushButton(i18nc("@action:button", "Close"), this);
     m_closeButton->hide();
@@ -63,6 +66,7 @@ void StatusBarMessageLabel::setMessage(const QString& text,
                                        MessageType type)
 {
     if ((text == m_text) && (type == m_type)) {
+        if (type == ErrorMessage) KNotification::event("ErrorMessage", m_text);
         return;
     }
 
@@ -90,11 +94,13 @@ void StatusBarMessageLabel::setMessage(const QString& text,
         iconName = "dialog-ok";
         // "ok" icon should probably be "dialog-success", but we don't have that icon in KDE 4.0
         m_closeButton->hide();
+        m_hidetimer.stop();
         break;
 
     case InformationMessage:
         iconName = "dialog-information";
         m_closeButton->hide();
+        m_hidetimer.start();
         break;
 
     case ErrorMessage:
@@ -102,6 +108,8 @@ void StatusBarMessageLabel::setMessage(const QString& text,
         m_timer.start(100);
         m_state = Illuminate;
         m_closeButton->hide();
+        KNotification::event("ErrorMessage", m_text);
+        m_hidetimer.stop();
         break;
 
     case MltError:
@@ -110,16 +118,23 @@ void StatusBarMessageLabel::setMessage(const QString& text,
         m_state = Illuminate;
         updateCloseButtonPosition();
         m_closeButton->show();
+        m_hidetimer.stop();
         break;
 
     case DefaultMessage:
     default:
         m_closeButton->hide();
+        m_hidetimer.stop();
         break;
     }
 
     m_pixmap = (iconName == 0) ? QPixmap() : SmallIcon(iconName);
-    QTimer::singleShot(GeometryTimeout, this, SLOT(assureVisibleText()));
+
+    /*QFontMetrics fontMetrics(font());
+    setMaximumWidth(fontMetrics.boundingRect(m_text).width() + m_pixmap.width() + (BorderGap * 4));
+    updateGeometry();*/
+
+    //QTimer::singleShot(GeometryTimeout, this, SLOT(assureVisibleText()));
     update();
 }
 
@@ -173,7 +188,7 @@ void StatusBarMessageLabel::resizeEvent(QResizeEvent* event)
 {
     QWidget::resizeEvent(event);
     updateCloseButtonPosition();
-    QTimer::singleShot(GeometryTimeout, this, SLOT(assureVisibleText()));
+    //QTimer::singleShot(GeometryTimeout, this, SLOT(assureVisibleText()));
 }
 
 void StatusBarMessageLabel::timerDone()