Commit 82ae0da8 authored by Simon Eugster's avatar Simon Eugster

Add delay to status bar messages

Simplified the status bar code and updated it to queue messages;
Consecutive error messages will not overwrite each other anymore.

Resolves: http://www.kdenlive.org/mantis/view.php?id=2519
parent 447f053c
......@@ -80,6 +80,7 @@ add_subdirectory(colorscopes)
add_subdirectory(commands)
add_subdirectory(databackup)
add_subdirectory(kiss_fft)
add_subdirectory(lib)
add_subdirectory(mimetypes)
add_subdirectory(onmonitoritems)
add_subdirectory(simplekeyframes)
......
set(kdenlive_SRCS
${kdenlive_SRCS}
lib/qtimerWithTime.cpp
PARENT_SCOPE
)
\ No newline at end of file
#include "qtimerWithTime.h"
void QTimerWithTime::start(int msec)
{
QTimer::start(msec);
m_time.start();
}
int QTimerWithTime::elapsed() const
{
return m_time.elapsed();
}
#include <QTimer>
#include <QTime>
class QTimerWithTime : public QTimer
{
Q_OBJECT
public:
virtual void start(int msec);
int elapsed() const;
private:
QTime m_time;
};
This diff is collapsed.
/***************************************************************************
* Copyright (C) 2006 by Peter Penz *
* 2012 Simon A. Eugster <simon.eu@gmail.com> *
* peter.penz@gmx.at *
* Code borrowed from Dolphin, adapted (2008) to Kdenlive by *
* Jean-Baptiste Mardelle, jb@kdenlive.org *
......@@ -28,13 +29,42 @@
#include <QPixmap>
#include <QWidget>
#include <QTimer>
#include <QSemaphore>
#include <definitions.h>
#include "lib/qtimerWithTime.h"
class QPaintEvent;
class QResizeEvent;
class QPushButton;
/**
Queue-able message item holding all important information
*/
struct StatusBarMessageItem {
QString text;
MessageType type;
int timeoutMillis;
bool confirmed; ///< MLT errors need to be confirmed.
/// \return true if the error still needs to be confirmed
bool needsConfirmation() const
{
return type == MltError && !confirmed;
}
StatusBarMessageItem(const QString& text = QString(), MessageType type = DefaultMessage, int timeoutMS = 0) :
text(text), type(type), timeoutMillis(timeoutMS), confirmed(false) {}
bool operator ==(const StatusBarMessageItem &other)
{
return type == other.type && text == other.text;
}
};
/**
* @brief Represents a message text label as part of the status bar.
*
......@@ -51,10 +81,6 @@ public:
explicit StatusBarMessageLabel(QWidget* parent);
virtual ~StatusBarMessageLabel();
MessageType type() const;
const QString& text() const;
// TODO: maybe a better approach is possible with the size hint
void setMinimumTextHeight(int min);
int minimumTextHeight() const;
......@@ -67,17 +93,11 @@ protected:
virtual void resizeEvent(QResizeEvent* event);
public slots:
void setMessage(const QString& text, MessageType type);
void setMessage(const QString& text, MessageType type, int timeoutMS = 0);
private slots:
void timerDone();
/**
* Increases the height of the message label so that
* the given text fits into given area.
*/
void assureVisibleText();
/**
* Returns the available width in pixels for the text.
*/
......@@ -93,21 +113,13 @@ private slots:
* Closes the currently shown error message and replaces it
* by the next pending message.
*/
void closeErrorMessage();
void confirmErrorMessage();
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();
bool slotMessageTimeout();
private:
enum State {
......@@ -120,31 +132,24 @@ private:
enum { GeometryTimeout = 100 };
enum { BorderGap = 2 };
MessageType m_type;
State m_state;
int m_illumination;
int m_minTextHeight;
QTimer m_timer;
QTimer m_hidetimer;
QString m_text;
QList<QString> m_pendingMessages;
QTimerWithTime m_queueTimer;
QSemaphore m_queueSemaphore;
QList<StatusBarMessageItem> m_messageQueue;
StatusBarMessageItem m_currentMessage;
QPixmap m_pixmap;
QPushButton* m_closeButton;
};
inline MessageType StatusBarMessageLabel::type() const
{
return m_type;
}
inline const QString& StatusBarMessageLabel::text() const
{
return m_text;
}
inline int StatusBarMessageLabel::minimumTextHeight() const
{
return m_minTextHeight;
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment