]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/statusbarmessagelabel.h
Dolphin is now a KUniqueApplication. A lot of thanks go to Oscar Blumberg, who submit...
[dolphin.git] / src / statusbarmessagelabel.h
index 03683c107290cf732b0274f621599f532e4d91b6..154915e4cc5ebaad5dae7331350c02c83cd92aea 100644 (file)
 #ifndef STATUSBARMESSAGELABEL_H
 #define STATUSBARMESSAGELABEL_H
 
-#include <qwidget.h>
-#include <qpixmap.h>
-#include <qstring.h>
-//Added by qt3to4:
-#include <QPaintEvent>
-#include <QResizeEvent>
 #include <dolphinstatusbar.h>
+
+#include <QList>
+#include <QPixmap>
+#include <QString>
+#include <QWidget>
+
+class QPaintEvent;
+class QResizeEvent;
+class QPushButton;
 class QTimer;
 
 /**
@@ -46,12 +49,14 @@ public:
     explicit StatusBarMessageLabel(QWidget* parent);
     virtual ~StatusBarMessageLabel();
 
-    void setType(DolphinStatusBar::Type type);
-    DolphinStatusBar::Type type() const { return m_type; }
+    void setMessage(const QString& text, DolphinStatusBar::Type type);
 
-    void setText(const QString& text);
+    DolphinStatusBar::Type type() const { return m_type; }
     const QString& text() const { return m_text; }
 
+    void setDefaultText(const QString& text) { m_defaultText = text; }
+    const QString& defaultText() const { return m_defaultText; }
+
     // TODO: maybe a better approach is possible with the size hint
     void setMinimumTextHeight(int min);
     int minimumTextHeight() const { return m_minTextHeight; }
@@ -84,6 +89,32 @@ private slots:
      */
     int availableTextWidth() const;
 
+    /**
+     * Moves the close button to the upper right corner
+     * of the message label.
+     */
+    void updateCloseButtonPosition();
+
+    /**
+     * Closes the currently shown error message and replaces it
+     * by the next pending message.
+     */
+    void closeErrorMessage();
+
+private:
+    /**
+     * Shows the next pending error message. If no pending message
+     * was in the queue, false is returned.
+     */
+    bool showPendingMessage();
+
+    /**
+     * Resets the message label properties. This is useful when the
+     * result of invoking StatusBarMessageLabel::setMessage() should
+     * not rely on previous states.
+     */
+    void reset();
+
 private:
     enum State {
         Default,
@@ -100,13 +131,16 @@ private:
     int m_minTextHeight;
     QTimer* m_timer;
     QString m_text;
+    QString m_defaultText;
+    QList<QString> m_pendingMessages;
     QPixmap m_pixmap;
+    QPushButton* m_closeButton;
 
     QColor mixColors(const QColor& c1,
                      const QColor& c2,
                      int percent) const;
 
-    int pixmapGap() const { return 3; }
+    int borderGap() const { return 2; }
 };
 
 #endif