]> git.sesse.net Git - kdenlive/blobdiff - src/statusbarmessagelabel.cpp
If a file has a license (for example when imported through online resource widget),
[kdenlive] / src / statusbarmessagelabel.cpp
index 3fcf28fc84d676a8b753cf0e3b4a49c0c5188860..42eef766691fb9ad5cc08f75b4a83faa8bc2c0c1 100644 (file)
  ***************************************************************************/
 
 #include "statusbarmessagelabel.h"
+#include "kdenlivesettings.h"
 
 #include <kcolorscheme.h>
 #include <kiconloader.h>
 #include <kicon.h>
 #include <klocale.h>
+#include <KNotification>
 
 #include <QFontMetrics>
 #include <QPainter>
 #include <QKeyEvent>
 #include <QPushButton>
 #include <QPixmap>
-#include <QTimer>
+
 
 StatusBarMessageLabel::StatusBarMessageLabel(QWidget* parent) :
         QWidget(parent),
@@ -40,17 +42,16 @@ StatusBarMessageLabel::StatusBarMessageLabel(QWidget* parent) :
         m_state(Default),
         m_illumination(-64),
         m_minTextHeight(-1),
-        m_timer(0),
         m_closeButton(0)
 {
     setMinimumHeight(KIconLoader::SizeSmall);
-
     QPalette palette;
     palette.setColor(QPalette::Background, Qt::transparent);
     setPalette(palette);
-
-    m_timer = new QTimer(this);
-    connect(m_timer, SIGNAL(timeout()), this, SLOT(timerDone()));
+    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();
@@ -65,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;
     }
 
@@ -83,7 +85,7 @@ void StatusBarMessageLabel::setMessage(const QString& text,
 
     m_illumination = -64;
     m_state = Default;
-    m_timer->stop();
+    m_timer.stop();
 
     const char* iconName = 0;
     QPixmap pixmap;
@@ -92,36 +94,47 @@ 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:
         iconName = "dialog-warning";
-        m_timer->start(100);
+        m_timer.start(100);
         m_state = Illuminate;
         m_closeButton->hide();
+        KNotification::event("ErrorMessage", m_text);
+        m_hidetimer.stop();
         break;
 
     case MltError:
         iconName = "dialog-close";
-        m_timer->start(100);
+        m_timer.start(100);
         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();
 }
 
@@ -144,8 +157,7 @@ void StatusBarMessageLabel::paintEvent(QPaintEvent* /* event */)
     QColor backgroundColor;
     if (m_state == Default || m_illumination < 0) backgroundColor = palette().window().color();
     else {
-        KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window);
-        backgroundColor = scheme.background(KColorScheme::NegativeBackground).color();
+        backgroundColor = KStatefulBrush(KColorScheme::Window, KColorScheme::NegativeBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme())).brush(this).color();
     }
     if (m_state == Desaturate && m_illumination > 0) {
         backgroundColor.setAlpha(m_illumination * 2);
@@ -175,7 +187,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()
@@ -192,7 +204,7 @@ void StatusBarMessageLabel::timerDone()
             update();
         } else {
             m_state = Illuminated;
-            m_timer->start(1500);
+            m_timer.start(1500);
         }
         break;
     }
@@ -201,7 +213,7 @@ void StatusBarMessageLabel::timerDone()
         // start desaturation
         if (m_type != MltError) {
             m_state = Desaturate;
-            m_timer->start(80);
+            m_timer.start(80);
         }
         break;
     }
@@ -211,7 +223,7 @@ void StatusBarMessageLabel::timerDone()
         if (m_illumination < -128) {
             m_illumination = 0;
             m_state = Default;
-            m_timer->stop();
+            m_timer.stop();
             setMessage(QString(), DefaultMessage);
         } else {
             m_illumination -= 5;