Commit 0b0face0 authored by Julius Künzel's avatar Julius Künzel
Browse files

Improvements and fixes for the status bar message field

- Fix info messages are not shown because overwritten by tooltip
- Don't add message to cue again if the same message is shown at the
moment.
- Don't allow background animation to be longer than the message display
time
- Show Message at least 2000ms (everything else is definetly to short to
read)
parent 672ef532
......@@ -144,7 +144,7 @@ enum MonitorSceneType {
MonitorSplitTrack
};
enum MessageType { DefaultMessage, ProcessingJobMessage, OperationCompletedMessage, InformationMessage, ErrorMessage, MltError, DirectMessage };
enum MessageType { DefaultMessage, ProcessingJobMessage, OperationCompletedMessage, InformationMessage, ErrorMessage, MltError, TooltipMessage };
namespace BinMessage {
enum BinCategory { NoMessage = 0, ProfileMessage, StreamsMessage, InformationMessage };
......
......@@ -55,6 +55,8 @@ QColor FlashLabel::color() const
StatusBarMessageLabel::StatusBarMessageLabel(QWidget *parent)
: QWidget(parent)
, m_minTextHeight(-1)
, m_keymapText()
, m_tooltipText()
, m_queueSemaphore(1)
{
setMinimumHeight(KIconLoader::SizeSmall);
......@@ -128,6 +130,16 @@ void StatusBarMessageLabel::setProgressMessage(const QString &text, MessageType
void StatusBarMessageLabel::setMessage(const QString &text, MessageType type, int timeoutMS)
{
if (type == TooltipMessage) {
m_tooltipText = text;
if (m_currentMessage.type == DefaultMessage) {
m_label->setText(m_tooltipText);
}
return;
}
if (type == m_currentMessage.type && text == m_currentMessage.text) {
return;
}
StatusBarMessageItem item(text, type, timeoutMS);
if (type == OperationCompletedMessage) {
m_progress->setVisible(false);
......@@ -138,13 +150,12 @@ void StatusBarMessageLabel::setMessage(const QString &text, MessageType type, in
m_queueSemaphore.acquire();
if (!m_messageQueue.contains(item)) {
if (item.type == ErrorMessage || item.type == MltError || item.type == ProcessingJobMessage || item.type == OperationCompletedMessage || item.type == DirectMessage) {
if (item.type == ErrorMessage || item.type == MltError || item.type == ProcessingJobMessage || item.type == OperationCompletedMessage) {
qCDebug(KDENLIVE_LOG) << item.text;
// Put the new error message at first place and immediately show it
if (item.timeoutMillis < 3000) {
item.timeoutMillis = 3000;
}
item.timeoutMillis = qMax(item.timeoutMillis, 3000);
if (item.type == ProcessingJobMessage) {
// This is a job progress info, discard previous ones
QList<StatusBarMessageItem> cleanList;
......@@ -166,6 +177,7 @@ void StatusBarMessageLabel::setMessage(const QString &text, MessageType type, in
m_queueTimer.start(delay);
} else {
// Message with normal priority
item.timeoutMillis = qMax(item.timeoutMillis, 2000);
m_messageQueue.push_back(item);
if (!m_queueTimer.isValid() || m_queueTimer.elapsed() >= m_currentMessage.timeoutMillis) {
m_queueTimer.start(0);
......@@ -213,13 +225,11 @@ bool StatusBarMessageLabel::slotMessageTimeout()
if (!m_messageQueue.isEmpty()) {
if (!m_currentMessage.needsConfirmation()) {
// If we only have the default message left to show in the queue,
// keep the current one for a little longer.
m_queueTimer.start(m_currentMessage.timeoutMillis + 4000 * static_cast<int>(m_messageQueue.at(0).type == DefaultMessage));
m_queueTimer.start(m_currentMessage.timeoutMillis);
}
}
QColor bgColor = KStatefulBrush(KColorScheme::Window, KColorScheme::NegativeBackground).brush(m_container->palette()).color();
QColor errorBgColor = KStatefulBrush(KColorScheme::Window, KColorScheme::NegativeBackground).brush(m_container->palette()).color();
const char *iconName = nullptr;
m_container->setColor(m_container->palette().window().color());
switch (m_currentMessage.type) {
......@@ -236,7 +246,7 @@ bool StatusBarMessageLabel::slotMessageTimeout()
iconName = "dialog-information";
m_pixmap->setCursor(Qt::ArrowCursor);
QPropertyAnimation *anim = new QPropertyAnimation(m_container, "color", this);
anim->setDuration(3000);
anim->setDuration(qMin(m_currentMessage.timeoutMillis, 3000));
anim->setEasingCurve(QEasingCurve::InOutQuad);
anim->setKeyValueAt(0.2, m_container->palette().highlight().color());
anim->setEndValue(m_container->palette().window().color());
......@@ -248,11 +258,11 @@ bool StatusBarMessageLabel::slotMessageTimeout()
iconName = "dialog-warning";
m_pixmap->setCursor(Qt::ArrowCursor);
QPropertyAnimation *anim = new QPropertyAnimation(m_container, "color", this);
anim->setStartValue(bgColor);
anim->setKeyValueAt(0.8, bgColor);
anim->setStartValue(errorBgColor);
anim->setKeyValueAt(0.8, errorBgColor);
anim->setEndValue(m_container->palette().window().color());
anim->setEasingCurve(QEasingCurve::OutCubic);
anim->setDuration(4000);
anim->setDuration(qMin(m_currentMessage.timeoutMillis, 4000));
anim->start(QPropertyAnimation::DeleteWhenStopped);
break;
}
......@@ -260,15 +270,16 @@ bool StatusBarMessageLabel::slotMessageTimeout()
iconName = "dialog-close";
m_pixmap->setCursor(Qt::PointingHandCursor);
QPropertyAnimation *anim = new QPropertyAnimation(m_container, "color", this);
anim->setStartValue(bgColor);
anim->setEndValue(bgColor);
anim->setStartValue(errorBgColor);
anim->setEndValue(errorBgColor);
anim->setEasingCurve(QEasingCurve::OutCubic);
anim->setDuration(3000);
anim->setDuration(qMin(m_currentMessage.timeoutMillis, 3000));
anim->start(QPropertyAnimation::DeleteWhenStopped);
break;
}
case DefaultMessage:
m_pixmap->setCursor(Qt::ArrowCursor);
m_label->setText(m_tooltipText);
default:
break;
}
......
......@@ -51,7 +51,7 @@ struct StatusBarMessageItem
int timeoutMillis;
bool confirmed{false}; ///< MLT errors need to be confirmed.
/// \return true if the error still needs to be confirmed
/// @return true if the error still needs to be confirmed
bool needsConfirmation() const { return (type == MltError && !confirmed); }
StatusBarMessageItem(QString messageText = QString(), MessageType messageType = DefaultMessage, int timeoutMS = 0)
......@@ -120,6 +120,7 @@ private:
QLabel *m_label;
QLabel *m_keyMap;
QString m_keymapText;
QString m_tooltipText;
QProgressBar *m_progress;
QTimerWithTime m_queueTimer;
QSemaphore m_queueSemaphore;
......
......@@ -1996,8 +1996,7 @@ void TimelineController::slipPosChanged(int offset) {
int inPoint = mainClip->getIn() - offset;
pCore->monitorManager()->projectMonitor()->slotTrimmingPos(inPoint, offset, inPoint, outPoint);
QString info = i18n("In:%1, Out:%2 (%3%4)", simplifiedTC(inPoint), simplifiedTC(outPoint), (offset < 0 ? "-" : "+"), simplifiedTC(qFabs(offset)));
pCore->displayMessage(info, DirectMessage);
showToolTip(i18n("In:%1, Out:%2 (%3%4)", simplifiedTC(inPoint), simplifiedTC(outPoint), (offset < 0 ? "-" : "+"), simplifiedTC(qFabs(offset))));
}
void TimelineController::ripplePosChanged(int size, bool right) {
......@@ -4877,7 +4876,7 @@ bool TimelineController::guidesLocked() const
void TimelineController::showToolTip(const QString &info) const
{
pCore->displayMessage(info, DirectMessage);
pCore->displayMessage(info, TooltipMessage);
}
void TimelineController::showKeyBinding(const QString &info) const
......
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