aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2016-05-21 02:10:10 +0200
committerJean-Baptiste Mardelle <[email protected]>2016-05-21 02:10:10 +0200
commit9040da7eebd193cac66643aa46017125d4d87499 (patch)
tree777471ed6746be3f752b59b90975d8f960fbc04c
parent4e4870bbb16b0c83cade0eff3aeeedda190e3be6 (diff)
Timeline preview render: put small progress bar inside start button
Ref: T1949
-rw-r--r--src/doc/kdenlivedoc.cpp5
-rw-r--r--src/doc/kdenlivedoc.h1
-rw-r--r--src/mainwindow.cpp48
-rw-r--r--src/mainwindow.h18
-rw-r--r--src/renderer.cpp5
-rw-r--r--src/timeline/timeline.cpp6
6 files changed, 80 insertions, 3 deletions
diff --git a/src/doc/kdenlivedoc.cpp b/src/doc/kdenlivedoc.cpp
index ea9ebaa..c328d24 100644
--- a/src/doc/kdenlivedoc.cpp
+++ b/src/doc/kdenlivedoc.cpp
@@ -1611,3 +1611,8 @@ void KdenliveDoc::invalidatePreviews(QList <int> chunks)
}
setModified(true);
}
+
+void KdenliveDoc::previewProgress(int p)
+{
+ pCore->window()->setPreviewProgress(p);
+}
diff --git a/src/doc/kdenlivedoc.h b/src/doc/kdenlivedoc.h
index 9c81588..6e785e7 100644
--- a/src/doc/kdenlivedoc.h
+++ b/src/doc/kdenlivedoc.h
@@ -158,6 +158,7 @@ public:
bool profileChanged(const QString &profile) const;
void doAddAction(const QString &name, QAction *a);
void invalidatePreviews(QList <int> chunks);
+ void previewProgress(int p);
private:
QUrl m_url;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index d3784b3..14eeced 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -108,6 +108,41 @@
#include <QVBoxLayout>
#include <QtGlobal>
+MyToolButton::MyToolButton(QWidget *parent) : QToolButton(parent)
+{
+ m_progress = width() - 6;
+}
+
+void MyToolButton::setProgress(int progress)
+{
+ int prog = (width() - 6) * (double) progress / 100;
+ if (prog == m_progress)
+ return;
+ m_progress = progress < 0 ? -1 : prog;
+ update();
+}
+
+int MyToolButton::progress() const
+{
+ return m_progress;
+}
+
+void MyToolButton::paintEvent(QPaintEvent *event)
+{
+ QToolButton::paintEvent(event);
+ if (m_progress < width() - 6) {
+ QPainter painter(this);
+ painter.setRenderHint(QPainter::Antialiasing, true);
+ if (m_progress < 0)
+ painter.fillRect(3, height() - 5, (width() - 6), 3, Qt::red);
+ else
+ painter.fillRect(3, height() - 5, m_progress, 3, palette().highlight().color());
+ painter.setPen(palette().shadow().color());
+ painter.drawRoundedRect(2, height() - 6, width() - 4, 5, 2, 2);
+ }
+}
+
+
static const char version[] = KDENLIVE_VERSION;
namespace Mlt
{
@@ -543,16 +578,27 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
timelineTb->addAction(actionCollection()->action(QStringLiteral("remove_extract")));
timelineTb->addAction(actionCollection()->action(QStringLiteral("remove_lift")));
- QToolButton *timelinePreview = new QToolButton(this);
+ MyToolButton *timelinePreview = new MyToolButton(this);
QMenu *tlMenu = new QMenu(this);
timelinePreview->setMenu(tlMenu);
+ connect(this, &MainWindow::setPreviewProgress, timelinePreview, &MyToolButton::setProgress);
+
QAction *prevRender = actionCollection()->action(QStringLiteral("prerender_timeline_zone"));
tlMenu->addAction(prevRender);
tlMenu->addAction(actionCollection()->action(QStringLiteral("set_render_timeline_zone")));
tlMenu->addAction(actionCollection()->action(QStringLiteral("unset_render_timeline_zone")));
timelinePreview->setDefaultAction(prevRender);
+ timelinePreview->setPopupMode(QToolButton::MenuButtonPopup);
+ timelinePreview->setAutoRaise(true);
timelineTb->addWidget(timelinePreview);
+ /*QPropertyAnimation *animation = new QPropertyAnimation(timelinePreview, "progress");
+ animation->setDuration(1000);
+ animation->setLoopCount(-1);
+ animation->setStartValue(1);
+ animation->setEndValue(100);
+ animation->start();*/
+
timelineTb->addAction(toolButtonAction);
QWidget *sep = new QWidget(this);
sep->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 987aff5..62c25de 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -60,6 +60,23 @@ class KIconLoader;
#define EXIT_RESTART (42)
+
+class MyToolButton: public QToolButton
+{
+ Q_PROPERTY(int progress READ progress WRITE setProgress)
+ Q_OBJECT
+public:
+ explicit MyToolButton(QWidget *parent = 0);
+ int progress() const;
+ void setProgress(int);
+
+protected:
+ virtual void paintEvent(QPaintEvent *event);
+
+private:
+ int m_progress;
+};
+
class /*KDENLIVECORE_EXPORT*/ MainWindow : public KXmlGuiWindow
{
Q_OBJECT
@@ -450,6 +467,7 @@ signals:
void configurationChanged();
void GUISetupDone();
void reloadTheme();
+ void setPreviewProgress(int);
};
diff --git a/src/renderer.cpp b/src/renderer.cpp
index 4847aa7..dd8dc78 100644
--- a/src/renderer.cpp
+++ b/src/renderer.cpp
@@ -1673,8 +1673,11 @@ void Render::doPreviewRender(QList <int> frames, QDir folder, QString id, QStrin
args << "-consumer" << "avformat:" + folder.absoluteFilePath(fileName);
args << consumerParams;
int result = QProcess::execute(KdenliveSettings::rendererpath(), args);
- if (result < 0) {
+ if (result != 0) {
// Something is wrong, abort
+ qDebug()<<"+++++++++\n++ ERROR ++\n++++++";
+ emit previewRender(i, QString(), -1);
+ QFile::remove(folder.absoluteFilePath(fileName));
break;
}
emit previewRender(i, folder.absoluteFilePath(fileName), progress);
diff --git a/src/timeline/timeline.cpp b/src/timeline/timeline.cpp
index dc8a165..4b27ae8 100644
--- a/src/timeline/timeline.cpp
+++ b/src/timeline/timeline.cpp
@@ -1745,6 +1745,10 @@ void Timeline::gotPreviewRender(int frame, const QString &file, int progress)
m_tractor->unlock();
m_hasOverlayTrack = true;
}
+ if (file.isEmpty()) {
+ m_doc->previewProgress(progress);
+ return;
+ }
Mlt::Producer *overlayTrack = m_tractor->track(tracksCount());
m_tractor->lock();
Mlt::Playlist trackPlaylist((mlt_playlist) overlayTrack->get_service());
@@ -1758,7 +1762,7 @@ void Timeline::gotPreviewRender(int frame, const QString &file, int progress)
}
}
m_tractor->unlock();
- m_doc->progressInfo(i18n("Rendering preview"), progress);
+ m_doc->previewProgress(progress);
m_doc->setModified(true);
//m_doc->updatePreview(progress);
}