Cleanup status bar messaging system an display audio align progress.

Fixes #432
parent f11408fe
......@@ -701,7 +701,6 @@ Bin::Bin(std::shared_ptr<ProjectItemModel> model, QWidget *parent)
connect(m_itemModel.get(), &ProjectItemModel::refreshPanel, this, &Bin::refreshPanel);
connect(m_itemModel.get(), &ProjectItemModel::refreshClip, this, &Bin::refreshClip);
connect(m_itemModel.get(), &ProjectItemModel::emitMessage, this, &Bin::emitMessage);
connect(m_itemModel.get(), static_cast<void (ProjectItemModel::*)(const QStringList &, const QModelIndex &)>(&ProjectItemModel::itemDropped), this,
static_cast<void (Bin::*)(const QStringList &, const QModelIndex &)>(&Bin::slotItemDropped));
......@@ -1113,7 +1112,7 @@ void Bin::slotLocateClip()
qCDebug(KDENLIVE_LOG) << " / / " + url.toString();
} else {
if (!exists) {
emitMessage(i18n("Could not locate %1", url.toString()), 100, ErrorMessage);
pCore->displayMessage(i18n("Could not locate %1", url.toString()), ErrorMessage, 300);
}
return;
}
......@@ -2864,10 +2863,6 @@ void Bin::slotResetInfoMessage()
}
}
void Bin::emitMessage(const QString &text, int progress, MessageType type)
{
emit displayMessage(text, progress, type);
}
void Bin::slotSetSorting()
{
......
......@@ -232,8 +232,6 @@ public:
void editMasterEffect(const std::shared_ptr<AbstractProjectItem> &clip);
/** @brief An effect setting was changed, update stack if displayed. */
void updateMasterEffect(ClipController *ctl);
/** @brief Display a message about an operation in status bar. */
void emitMessage(const QString &, int, MessageType);
void rebuildMenu();
void refreshIcons();
......@@ -459,7 +457,6 @@ signals:
/** @brief Request that the given clip is displayed in the clip monitor */
void requestClipShow(std::shared_ptr<ProjectClip>);
void displayBinMessage(const QString &, KMessageWidget::MessageType);
void displayMessage(const QString &, int, MessageType);
void requesteInvalidRemoval(const QString &, const QString &, const QString &);
/** @brief Analysis data changed, refresh panel. */
void updateAnalysisData(const QString &);
......
......@@ -562,7 +562,11 @@ void Core::pushUndo(QUndoCommand *command)
void Core::displayMessage(const QString &message, MessageType type, int timeout)
{
if (m_mainWindow) {
m_mainWindow->displayMessage(message, type, timeout);
if (type == ProcessingJobMessage || type == OperationCompletedMessage) {
m_mainWindow->displayProgressMessage(message, type, timeout);
} else {
m_mainWindow->displayMessage(message, type, timeout);
}
} else {
qDebug() << message;
}
......
......@@ -200,13 +200,13 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, QString projectFolder, QUndoGroup *und
}
} else {
qCDebug(KDENLIVE_LOG) << " // / processing file open: validate";
parent->slotGotProgressInfo(i18n("Validating"), 100);
pCore->displayMessage(i18n("Validating"), OperationCompletedMessage, 100);
qApp->processEvents();
DocumentValidator validator(m_document, url);
success = validator.isProject();
if (!success) {
// It is not a project file
parent->slotGotProgressInfo(i18n("File %1 is not a Kdenlive project file", m_url.toLocalFile()), 100);
pCore->displayMessage(i18n("File %1 is not a Kdenlive project file", m_url.toLocalFile()), OperationCompletedMessage, 100);
if (KMessageBox::warningContinueCancel(
parent, i18n("File %1 is not a valid project file.\nDo you want to open a backup file?", m_url.toLocalFile()),
i18n("Error opening file"), KGuiItem(i18n("Open Backup"))) == KMessageBox::Continue) {
......
......@@ -40,7 +40,7 @@ AudioCorrelation::~AudioCorrelation()
void AudioCorrelation::slotAnnounceEnvelope()
{
emit displayMessage(i18n("Audio analysis finished"), OperationCompletedMessage, 500);
emit displayMessage(i18n("Audio analysis finished"), OperationCompletedMessage, 300);
}
void AudioCorrelation::addChild(AudioEnvelope *envelope)
......
......@@ -17,9 +17,11 @@
#include <QImage>
#include <QTime>
#include <QtConcurrent>
#include <KLocalizedString>
#include <algorithm>
#include <cmath>
#include <memory>
AudioEnvelope::AudioEnvelope(const QString &binId, int clipId, size_t offset, size_t length, size_t startPos)
: m_offset(offset)
, m_clipId(clipId)
......@@ -107,7 +109,8 @@ AudioEnvelope::AudioSummary AudioEnvelope::loadAndNormalizeEnvelope() const
QTime t;
t.start();
m_producer->seek(0);
for (size_t i = 0; i < summary.audioAmplitudes.size(); ++i) {
size_t max = summary.audioAmplitudes.size();
for (size_t i = 0; i < max; ++i) {
std::unique_ptr<Mlt::Frame> frame(m_producer->get_frame((int)i));
qint64 position = mlt_frame_get_position(frame->get_frame());
int samples = mlt_sample_calculator(m_producer->get_fps(), samplingRate, position);
......@@ -117,6 +120,7 @@ AudioEnvelope::AudioSummary AudioEnvelope::loadAndNormalizeEnvelope() const
for (int k = 0; k < samples; ++k) {
summary.audioAmplitudes[i] += abs(data[k]);
}
pCore->displayMessage(i18n("Processing data analysis"), ProcessingJobMessage, (int) (100 * i / max));
}
qCDebug(KDENLIVE_LOG) << "Calculating the envelope (" << m_envelopeSize << " frames) took " << t.elapsed() << " ms.";
qCDebug(KDENLIVE_LOG) << "Normalizing envelope ...";
......@@ -125,10 +129,11 @@ AudioEnvelope::AudioSummary AudioEnvelope::loadAndNormalizeEnvelope() const
// Normalize the envelope.
summary.amplitudeMax = 0;
for (size_t i = 0; i < summary.audioAmplitudes.size(); ++i) {
for (size_t i = 0; i < max; ++i) {
summary.audioAmplitudes[i] -= meanBeforeNormalization;
summary.amplitudeMax = std::max(summary.amplitudeMax, qAbs(summary.audioAmplitudes[i]));
}
pCore->displayMessage(i18n("Audio analysis finished"), OperationCompletedMessage, 300);
return summary;
}
......
......@@ -851,7 +851,7 @@ void MainWindow::slotConnectMonitors()
}
void MainWindow::createSplitOverlay(std::shared_ptr<Mlt::Filter> filter)
{
{
if (m_assetPanel->effectStackOwner().first == ObjectType::TimelineClip) {
getMainTimeline()->controller()->createSplitOverlay(m_assetPanel->effectStackOwner().second, filter);
m_projectMonitor->activateSplit();
......@@ -1133,6 +1133,7 @@ void MainWindow::setupActions()
m_messageLabel = new StatusBarMessageLabel(this);
m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
connect(this, &MainWindow::displayMessage, m_messageLabel, &StatusBarMessageLabel::setMessage);
connect(this, &MainWindow::displayProgressMessage, m_messageLabel, &StatusBarMessageLabel::setProgressMessage);
statusBar()->addWidget(m_messageLabel, 0);
QWidget *spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
......@@ -2019,7 +2020,6 @@ void MainWindow::connectDocument()
connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), project, SLOT(setModified()));
connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), project, SLOT(setModified()));
connect(project, &KdenliveDoc::docModified, this, &MainWindow::slotUpdateDocumentState);
connect(pCore->bin(), SIGNAL(displayMessage(QString, int, MessageType)), m_messageLabel, SLOT(setProgressMessage(QString, int, MessageType)));
if (m_renderWidget) {
slotCheckRenderStatus();
......@@ -2682,11 +2682,6 @@ void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
m_zoomSlider->setToolTip(i18n("Zoom Level: %1/%2", max - zoomlevel, max));
}
void MainWindow::slotGotProgressInfo(const QString &message, int progress, MessageType type)
{
m_messageLabel->setProgressMessage(message, progress, type);
}
void MainWindow::customEvent(QEvent *e)
{
if (e->type() == QEvent::User) {
......
......@@ -252,7 +252,6 @@ private:
void updateActionsToolTip();
public slots:
void slotGotProgressInfo(const QString &message, int progress, MessageType type = DefaultMessage);
void slotReloadEffects(const QStringList &paths);
Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
......@@ -481,6 +480,7 @@ signals:
void setPreviewProgress(int);
void setRenderProgress(int);
void displayMessage(const QString &, MessageType, int);
void displayProgressMessage(const QString &, MessageType, int);
/** @brief Project profile changed, update render widget accordingly. */
void updateRenderWidgetProfile();
/** @brief Clear asset view if itemId is displayed. */
......
......@@ -491,7 +491,7 @@ void ProjectManager::openFile(const QUrl &url)
if (checkForBackupFile(url)) {
return;
}
pCore->window()->slotGotProgressInfo(i18n("Opening file %1", url.toLocalFile()), 100, InformationMessage);
pCore->displayMessage(i18n("Opening file %1", url.toLocalFile()), OperationCompletedMessage, 100);
doOpenFile(url, nullptr);
}
......@@ -558,7 +558,7 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale)
m_project->getDocumentProperty(QStringLiteral("disablepreview")).toInt());
emit docOpened(m_project);
pCore->window()->slotGotProgressInfo(QString(), 100);
pCore->displayMessage(QString(), OperationCompletedMessage, 100);
if (openBackup) {
slotOpenBackup(url);
}
......@@ -805,13 +805,13 @@ void ProjectManager::moveProjectData(const QString &src, const QString &dest)
void ProjectManager::slotMoveProgress(KJob *, unsigned long progress)
{
pCore->window()->slotGotProgressInfo(i18n("Moving project folder"), static_cast<int>(progress), ProcessingJobMessage);
pCore->displayMessage(i18n("Moving project folder"), ProcessingJobMessage, static_cast<int>(progress));
}
void ProjectManager::slotMoveFinished(KJob *job)
{
if (job->error() == 0) {
pCore->window()->slotGotProgressInfo(QString(), 100, InformationMessage);
pCore->displayMessage(QString(), OperationCompletedMessage, 100);
auto *copyJob = static_cast<KIO::CopyJob *>(job);
QString newFolder = copyJob->destUrl().toLocalFile();
// Check if project folder is inside document folder, in which case, paths will be relative
......
......@@ -96,7 +96,7 @@ void StatusBarMessageLabel::mousePressEvent(QMouseEvent *event)
}
}
void StatusBarMessageLabel::setProgressMessage(const QString &text, int progress, MessageType type, int timeoutMS)
void StatusBarMessageLabel::setProgressMessage(const QString &text, MessageType type, int progress)
{
if (type == ProcessingJobMessage) {
m_progress->setValue(progress);
......@@ -107,7 +107,7 @@ void StatusBarMessageLabel::setProgressMessage(const QString &text, int progress
if (text == m_currentMessage.text) {
return;
}
setMessage(text, type, timeoutMS);
setMessage(text, type, 0);
}
void StatusBarMessageLabel::setMessage(const QString &text, MessageType type, int timeoutMS)
......@@ -122,7 +122,7 @@ 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) {
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
......
......@@ -98,7 +98,7 @@ protected:
void resizeEvent(QResizeEvent *event) override;
public slots:
void setProgressMessage(const QString &text, int progress = 100, MessageType type = ProcessingJobMessage, int timeoutMS = 0);
void setProgressMessage(const QString &text, MessageType type = ProcessingJobMessage, int progress = 100);
void setMessage(const QString &text, MessageType type = DefaultMessage, int timeoutMS = 0);
private slots:
......
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