]> git.sesse.net Git - kdenlive/commitdiff
Improve the export audio automatic setting:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 26 Jul 2010 17:55:17 +0000 (17:55 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 26 Jul 2010 17:55:17 +0000 (17:55 +0000)
http://www.kdenlive.org/mantis/view.php?id=1704
cleanup render widget ui

svn path=/trunk/kdenlive/; revision=4647

src/customtrackview.cpp
src/customtrackview.h
src/mainwindow.cpp
src/renderwidget.cpp
src/renderwidget.h
src/trackview.cpp
src/trackview.h

index 7913e0d27616c2722d34abb77cb97a9f84cd2a1b..0dbcbd82f6b0613c43099c39919ce7fbc818bb62 100644 (file)
@@ -173,10 +173,6 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen
     connect(&m_thumbsTimer, SIGNAL(timeout()), this, SLOT(slotFetchNextThumbs()));
     m_thumbsTimer.setInterval(500);
     m_thumbsTimer.setSingleShot(true);
-
-    connect(&m_audioMonitorTimer, SIGNAL(timeout()), this, SIGNAL(documentModified()));
-    m_audioMonitorTimer.setInterval(2000);
-    m_audioMonitorTimer.setSingleShot(true);
 }
 
 CustomTrackView::~CustomTrackView()
@@ -201,7 +197,6 @@ void CustomTrackView::keyPressEvent(QKeyEvent * event)
 void CustomTrackView::setDocumentModified()
 {
     m_document->setModified(true);
-    m_audioMonitorTimer.start();
 }
 
 void CustomTrackView::setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition, QActionGroup *clipTypeGroup, QMenu *markermenu)
index 9c7af680e614216e279fdb3c96f58fcb8f8cb4a6..a5b9828ae2bd31688adbc33ee885087c4c3a45fd 100644 (file)
@@ -305,8 +305,6 @@ private:
     QActionGroup *m_clipTypeGroup;
     QTimer m_scrollTimer;
     QTimer m_thumbsTimer;
-    /** @brief Monitor for changes in timeline (do we have audio data) */
-    QTimer m_audioMonitorTimer;
     int m_scrollOffset;
     bool m_clipDrag;
 
index 11b87847377ec34e3e6a319d1928e7f82c91af37..1e1a719bccb6d7951574802218f3e67db5da6855 100644 (file)
@@ -1987,7 +1987,6 @@ void MainWindow::slotRenderProject()
             m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
             m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("rendercategory"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
         }
-        if (m_activeTimeline) connect(m_activeTimeline, SIGNAL(projectHasAudio(bool)), m_renderWidget, SLOT(slotEnableAudio(bool)));
     }
     slotCheckRenderStatus();
     m_renderWidget->show();
@@ -2191,9 +2190,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
 
 
     trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
-    if (m_renderWidget) {
-        if (m_activeTimeline) disconnect(m_activeTimeline, SIGNAL(projectHasAudio(bool)), m_renderWidget, SLOT(slotEnableAudio(bool)));
-    }
     m_activeTimeline = trackView;
     if (m_renderWidget) {
         slotCheckRenderStatus();
@@ -2201,7 +2197,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
         m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
         m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
         m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("rendercategory"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
-        connect(m_activeTimeline, SIGNAL(projectHasAudio(bool)), m_renderWidget, SLOT(slotEnableAudio(bool)));
     }
     //doc->setRenderer(m_projectMonitor->render);
     m_commandStack->setActiveStack(doc->commandStack());
@@ -3452,8 +3447,11 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
             }
         }
     }
-
-    m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
+    bool exportAudio;
+    if (m_renderWidget->automaticAudioExport()) {
+        exportAudio = m_activeTimeline->checkProjectAudio();
+    } else exportAudio = m_renderWidget->selectedAudioExport();
+    m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
 }
 
 void MainWindow::slotUpdateTimecodeFormat(int ix)
index 569d34d32bf6e2d2c31a31a9f3c7892bb23b0dca..ff9525951b3d2b0162bfdfc0580c13dfdf248191 100644 (file)
@@ -62,8 +62,7 @@ const int FINISHEDJOB = 2;
 RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
         QDialog(parent),
         m_projectFolder(projectfolder),
-        m_blockProcessing(false),
-        m_autoAudio(false)
+        m_blockProcessing(false)
 {
     m_view.setupUi(this);
     setWindowTitle(i18n("Rendering"));
@@ -117,7 +116,8 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
 
     parseProfiles();
     parseScriptFiles();
-
+    m_view.running_jobs->setUniformRowHeights(false);
+    m_view.scripts_list->setUniformRowHeights(false);
     connect(m_view.start_script, SIGNAL(clicked()), this, SLOT(slotStartScript()));
     connect(m_view.delete_script, SIGNAL(clicked()), this, SLOT(slotDeleteScript()));
     connect(m_view.scripts_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckScript()));
@@ -680,7 +680,7 @@ void RenderWidget::slotPrepareExport(bool scriptExport)
 }
 
 
-void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const QString &playlistPath, const QString &scriptPath)
+void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const QString &playlistPath, const QString &scriptPath, bool exportAudio)
 {
     QListWidgetItem *item = m_view.size_list->currentItem();
     if (!item) return;
@@ -752,8 +752,7 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     else if (m_view.scanning_list->currentIndex() == 2) renderArgs.append(" progressive=0");
 
     // disable audio if requested
-    if (m_view.export_audio->checkState() == Qt::Unchecked || (m_view.export_audio->checkState() == Qt::PartiallyChecked && !m_autoAudio))
-        renderArgs.append(" an=1 ");
+    if (!exportAudio) renderArgs.append(" an=1 ");
 
     // Check if the rendering profile is different from project profile,
     // in which case we need to use the producer_comsumer from MLT
@@ -822,7 +821,6 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
         return;
     }
     renderParameters << scriptName;
-    m_view.tabWidget->setCurrentIndex(1);
 
     // Save rendering profile to document
     emit selectedRenderProfile(m_view.size_list->currentItem()->data(MetaGroupRole).toString(), m_view.size_list->currentItem()->data(GroupRole).toString(), m_view.size_list->currentItem()->text(), dest);
@@ -867,6 +865,10 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
         }
     }
     renderItem->setData(1, Qt::UserRole + 3, render_process_args);
+    if (exportAudio == false) renderItem->setData(1, Qt::UserRole + 5, i18n("Video without audio track"));
+    else  renderItem->setData(1, Qt::UserRole + 5, QString());
+    m_view.running_jobs->setCurrentItem(renderItem);
+    m_view.tabWidget->setCurrentIndex(1);
     checkRenderStatus();
 }
 
@@ -1551,6 +1553,12 @@ void RenderWidget::slotCheckJob()
         activate = true;
     }
     m_view.abort_job->setEnabled(activate);
+    for (int i = 0; i < m_view.running_jobs->topLevelItemCount(); i++) {
+        current = m_view.running_jobs->topLevelItem(i);
+        if (current == m_view.running_jobs->currentItem()) {
+            current->setSizeHint(1, QSize(m_view.running_jobs->columnWidth(1), fontMetrics().height() * 3));
+        } else current->setSizeHint(1, QSize(m_view.running_jobs->columnWidth(1), fontMetrics().height() * 2));
+    }
 }
 
 void RenderWidget::slotCLeanUpJobs()
@@ -1625,10 +1633,16 @@ void RenderWidget::parseScriptFiles()
 
 void RenderWidget::slotCheckScript()
 {
-    QTreeWidgetItem *item = m_view.scripts_list->currentItem();
-    if (item == NULL) return;
-    m_view.start_script->setEnabled(item->data(0, Qt::UserRole).toString().isEmpty());
+    QTreeWidgetItem *current = m_view.scripts_list->currentItem();
+    if (current == NULL) return;
+    m_view.start_script->setEnabled(current->data(0, Qt::UserRole).toString().isEmpty());
     m_view.delete_script->setEnabled(true);
+    for (int i = 0; i < m_view.scripts_list->topLevelItemCount(); i++) {
+        current = m_view.scripts_list->topLevelItem(i);
+        if (current == m_view.scripts_list->currentItem()) {
+            current->setSizeHint(1, QSize(m_view.scripts_list->columnWidth(1), fontMetrics().height() * 3));
+        } else current->setSizeHint(1, QSize(m_view.scripts_list->columnWidth(1), fontMetrics().height() * 2));
+    }
 }
 
 void RenderWidget::slotStartScript()
@@ -1791,12 +1805,6 @@ void RenderWidget::missingClips(bool hasMissing)
     } else m_view.errorLabel->setHidden(true);
 }
 
-void RenderWidget::slotEnableAudio(bool enable)
-{
-    m_autoAudio = enable;
-    if (m_view.export_audio->checkState() == Qt::PartiallyChecked) m_view.export_audio->setText(m_autoAudio ? i18n("Export audio (on)") : i18n("Export audio (off)"));
-}
-
 void RenderWidget::slotUpdateRescaleWidth(int val)
 {
     KdenliveSettings::setDefaultrescalewidth(val);
@@ -1826,7 +1834,18 @@ void RenderWidget::slotSwitchAspectRatio()
 void RenderWidget::slotUpdateAudioLabel(int ix)
 {
     if (ix == Qt::PartiallyChecked)
-        m_view.export_audio->setText(m_autoAudio ? i18n("Export audio (on)") : i18n("Export audio (off)"));
+        m_view.export_audio->setText(i18n("Export audio (automatic)"));
     else
-        m_view.export_audio->setText(i18n("Audio export"));
-}
\ No newline at end of file
+        m_view.export_audio->setText(i18n("Export audio"));
+}
+
+bool RenderWidget::automaticAudioExport() const
+{
+    return (m_view.export_audio->checkState() == Qt::PartiallyChecked);
+}
+
+bool RenderWidget::selectedAudioExport() const
+{
+    return (m_view.export_audio->checkState() != Qt::Unchecked);
+}
+
index 353f420c370d2e343389244aabbd95626cdd7746..3167a97a2b68b11001723d85909420d92084d7d3 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <QPushButton>
 #include <QPainter>
-#include <QItemDelegate>
+#include <QStyledItemDelegate>
 
 #include "definitions.h"
 #include "ui_renderwidget_ui.h"
@@ -32,46 +32,56 @@ class QDomElement;
 
 
 // RenderViewDelegate is used to draw the progress bars.
-class RenderViewDelegate : public QItemDelegate
+class RenderViewDelegate : public QStyledItemDelegate
 {
     Q_OBJECT
 public:
-    RenderViewDelegate(QWidget *parent) : QItemDelegate(parent) {}
+    RenderViewDelegate(QWidget *parent) : QStyledItemDelegate(parent) {}
 
     void paint(QPainter *painter, const QStyleOptionViewItem &option,
                const QModelIndex &index) const {
         if (index.column() == 1) {
-            QRect r1 = option.rect;
             painter->save();
-            if (option.state & (QStyle::State_Selected)) {
-                painter->setPen(option.palette.color(QPalette::HighlightedText));
-                painter->fillRect(r1, option.palette.highlight());
-            } else painter->setPen(option.palette.color(QPalette::Text));
+            int factor = 2;
+            QStyleOptionViewItemV4 opt(option);
+            QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
+            const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
+            style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);
+
+            if (option.state & QStyle::State_Selected) {
+                painter->setPen(option.palette.highlightedText().color());
+                factor = 3;
+            }// else painter->setPen(option.palette.color(QPalette::Text));
             QFont font = painter->font();
             font.setBold(true);
             painter->setFont(font);
-            int mid = (int)((r1.height() / 2));
+            QRect r1 = option.rect;
+            r1.adjust(0, textMargin, 0, - textMargin);
+            int mid = (int)((r1.height() / factor));
             r1.setBottom(r1.y() + mid);
-            QRect r2 = option.rect;
-            r2.setTop(r2.y() + mid);
             painter->drawText(r1, Qt::AlignLeft | Qt::AlignBottom , index.data().toString());
+            r1.setBottom(r1.bottom() + mid);
+            r1.setTop(r1.bottom() - mid);
             font.setBold(false);
             painter->setFont(font);
-            painter->setPen(option.palette.color(QPalette::Mid));
-            painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , index.data(Qt::UserRole).toString());
+            painter->drawText(r1, Qt::AlignLeft | Qt::AlignVCenter , index.data(Qt::UserRole).toString());
+            if (factor > 2) {
+                r1.setBottom(r1.bottom() + mid);
+                r1.setTop(r1.bottom() - mid);
+                painter->drawText(r1, Qt::AlignLeft | Qt::AlignVCenter , index.data(Qt::UserRole + 5).toString());
+            }
             painter->restore();
         } else if (index.column() == 2) {
             // Set up a QStyleOptionProgressBar to precisely mimic the
             // environment of a progress bar.
+            QStyleOptionViewItemV4 opt(option);
+            QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
+            style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);
+
             QStyleOptionProgressBar progressBarOption;
             progressBarOption.state = option.state;
             progressBarOption.direction = QApplication::layoutDirection();
             QRect rect = option.rect;
-            if (option.state & (QStyle::State_Selected)) {
-                painter->setPen(option.palette.color(QPalette::HighlightedText));
-                painter->fillRect(rect, option.palette.highlight());
-            }
-
             int mid = rect.height() / 2;
             rect.setTop(rect.top() + mid / 2);
             rect.setHeight(mid);
@@ -89,7 +99,7 @@ public:
 
             // Draw the progress bar onto the view.
             QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter);
-        } else QItemDelegate::paint(painter, option, index);
+        } else QStyledItemDelegate::paint(painter, option, index);
     }
 };
 
@@ -113,11 +123,13 @@ public:
     QString getFreeScriptName(const QString &prefix = QString());
     bool startWaitingRenderJobs();
     void missingClips(bool hasMissing);
+    /** @brief Returns true if the export audio checkbox is set to automatic. */
+    bool automaticAudioExport() const;
+    /** @brief Returns true if user wants audio export. */
+    bool selectedAudioExport() const;
 
 public slots:
-    void slotExport(bool scriptExport, int zoneIn, int zoneOut, const QString &playlistPath, const QString &scriptPath);
-    /** @brief Enable / disable audio export if audio export checkbox is in auto mode. */
-    void slotEnableAudio(bool enable);
+    void slotExport(bool scriptExport, int zoneIn, int zoneOut, const QString &playlistPath, const QString &scriptPath, bool exportAudio);
 
 private slots:
     void slotUpdateButtons(KUrl url);
@@ -171,8 +183,6 @@ private:
     void saveProfile(QDomElement newprofile);
     QList <QListWidgetItem *> m_renderItems;
     QList <QListWidgetItem *> m_renderCategory;
-    /** @brief True if current project has audio, false otherwise. */
-    bool m_autoAudio;
 
 signals:
     void abortProcess(const QString &url);
index e086b21aff5bbb76a3c9eb68017bebd194de7ba7..4efc9067860ebc7fc45bcb3866042f847076dcaf 100644 (file)
@@ -117,7 +117,6 @@ TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) :
 
     slotChangeZoom(m_doc->zoom().x(), m_doc->zoom().y());
     slotSetZone(m_doc->zone());
-    connect(m_trackview, SIGNAL(documentModified()), this, SLOT(slotCheckProjectAudio()));
 }
 
 TrackView::~TrackView()
@@ -148,7 +147,7 @@ int TrackView::tracksNumber() const
     return m_projectTracks - 1;
 }
 
-void TrackView::slotCheckProjectAudio()
+bool TrackView::checkProjectAudio() const
 {
     bool hasAudio = false;
     const QList <TrackInfo> list = m_doc->tracksList();
@@ -160,7 +159,7 @@ void TrackView::slotCheckProjectAudio()
             break;
         }
     }
-    emit projectHasAudio(hasAudio);
+    return hasAudio;
 }
 
 int TrackView::inPoint() const
@@ -452,7 +451,6 @@ void TrackView::parseDocument(QDomDocument doc)
         else
             KMessageBox::information(this, i18n("Your project file was upgraded to the latest Kdenlive document version, but it was not possible to create a backup copy.", backupFile));
     }
-    slotCheckProjectAudio();
     //m_trackview->setCursorPos(cursorPos);
     //m_scrollBox->setGeometry(0, 0, 300 * zoomFactor(), m_scrollArea->height());
 }
index 0529f8498237b522f489b27741444dd7709ac229..e1ee869808a21508d2d1809bbc51de61c22cd2fd 100644 (file)
@@ -69,6 +69,10 @@ public:
     * Used to change from displaying frames to timecode or vice versa. */
     void updateRuler();
 
+    /** @brief Parse tracks to see if project has audio in it.
+    *
+    * Parses all tracks to check if there is audio data. */
+    bool checkProjectAudio() const;
 
 protected:
     virtual void keyPressEvent(QKeyEvent * event);
@@ -120,11 +124,6 @@ private slots:
      * of the vertical scrollbar is maximal */
     void slotUpdateVerticalScroll(int min, int max);
 
-    /** @brief Parse tracks to see if project has audio in it.
-    *
-    * Parses all tracks to check if there is audio data. */
-    void slotCheckProjectAudio();
-
 signals:
     void mousePosition(int);
     void cursorMoved();
@@ -134,8 +133,6 @@ signals:
     void configTrack(int);
     void updateTracksInfo();
     void setZoom(int);
-    /** @brief Inform render widget if our project has audio */
-    void projectHasAudio(bool);
 };
 
 #endif