From: Marco Gittler Date: Mon, 25 Feb 2008 15:55:36 +0000 (+0000) Subject: show progress of auido thumb creation X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=b49b418e2634eeee7e9b6126150eefe77358310f;p=kdenlive show progress of auido thumb creation svn path=/branches/KDE4/; revision=1935 --- diff --git a/src/events.h b/src/events.h new file mode 100644 index 00000000..ecc11f9e --- /dev/null +++ b/src/events.h @@ -0,0 +1,33 @@ +/*************************************************************************** + events.h - description + ------------------- + begin : Feb 15 2008 + copyright : (C) 2008 by Marco Gittler + email : g.marco@freenet.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef EVENTS_H +#define EVENTS_H + +#include + +class ProgressEvent : public QEvent { +public: + ProgressEvent( int value, QEvent::Type eventType ) + : QEvent( eventType ), m_val( value ) {}; + int value() const { return m_val; }; +private: + int m_val; + +}; + +#endif diff --git a/src/kthumb.cpp b/src/kthumb.cpp index cf3dee8e..d905aa72 100644 --- a/src/kthumb.cpp +++ b/src/kthumb.cpp @@ -42,7 +42,7 @@ #include "renderer.h" #include "kthumb.h" #include "kdenlivesettings.h" - +#include "events.h" void MyThread::init(KUrl url, QString target, double frame, double frameLength, int frequency, int channels, int arrayWidth) { stop_me = false; @@ -80,11 +80,11 @@ void MyThread::init(KUrl url, QString target, double frame, double frameLength, Mlt::Filter m_convert(prof,"volume"); m_convert.set("gain", "normalise"); m_producer.attach(m_convert); - } + }*/ - /*TODO if (qApp->mainWidget()) - QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(-1, 10005)); - */ + if (QApplication::activeWindow()) + QApplication::postEvent(QApplication::activeWindow(), new ProgressEvent(-1, (QEvent::Type)10005)); + int last_val = 0; int val = 0; kDebug() << "for " << m_frame << " " << m_frameLength << " " << m_producer.is_valid(); @@ -92,7 +92,8 @@ void MyThread::init(KUrl url, QString target, double frame, double frameLength, if (stop_me) break; val=(int)((z-m_frame)/(m_frame+m_frameLength)*100.0); if (last_val!=val & val > 1){ - //TODO QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(val, 10005)); + QApplication::postEvent(QApplication::activeWindow(), new ProgressEvent(val, (QEvent::Type)10005)); + last_val=val; } m_producer.seek( z ); @@ -125,9 +126,11 @@ void MyThread::init(KUrl url, QString target, double frame, double frameLength, m_isWorking = false; if (stop_me) { f.remove(); - //TODO QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(-1, 10005)); + QApplication::postEvent(QApplication::activeWindow(), new ProgressEvent(-1, (QEvent::Type)10005)); + } - //TODO else QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(0, 10005)); + QApplication::postEvent(QApplication::activeWindow(), new ProgressEvent(0, (QEvent::Type)10005)); + } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e8c556c3..7b385d3a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -50,6 +50,7 @@ #include "initeffects.h" #include "profilesdialog.h" #include "projectsettings.h" +#include "events.h" #define ID_STATUS_MSG 1 #define ID_EDITMODE_MSG 2 @@ -136,6 +137,14 @@ MainWindow::MainWindow(QWidget *parent) m_timecodeFormat = new KComboBox(this); m_timecodeFormat->addItem(i18n("hh:mm:ss::ff")); m_timecodeFormat->addItem(i18n("Frames")); + + statusProgressBar=new QProgressBar(this); + statusProgressBar->setMinimum(0); + statusProgressBar->setMaximum(100); + statusLabel=new QLabel(this); + + statusBar()->insertPermanentWidget(0,statusProgressBar,1); + statusBar()->insertPermanentWidget(1,statusLabel,1); statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS); statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat); @@ -499,5 +508,15 @@ void MainWindow::slotPreferences() //connect( dialog, SIGNAL(settingsChanged()), this, SLOT(updateConfiguration()) ); dialog->show(); } - +void MainWindow::customEvent ( QEvent * event ){ + if (event->type()==10005){ + ProgressEvent* p=(ProgressEvent*) event; + statusProgressBar->setValue(p->value()); + statusProgressBar->setFormat("%p done"); + if (p->value()>0) + statusLabel->setText(tr("Creating Audio Thumbs")); + else + statusLabel->setText(""); + } +} #include "mainwindow.moc" diff --git a/src/mainwindow.h b/src/mainwindow.h index 060f657e..4f7f2497 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -43,6 +44,7 @@ #include "effectslistview.h" #include "effectstackview.h" + class MainWindow : public KXmlGuiWindow { Q_OBJECT @@ -51,12 +53,14 @@ class MainWindow : public KXmlGuiWindow MainWindow(QWidget *parent=0); void parseProfiles(); - + void customEvent ( QEvent * event ); protected: virtual bool queryClose(); private: KTabWidget* m_timelineArea; + QProgressBar *statusProgressBar; + QLabel* statusLabel; void setupActions(); QString fileName; KdenliveDoc *m_activeDocument;