Improve the export audio automatic setting:

http://www.kdenlive.org/mantis/view.php?id=1704
cleanup render widget ui

svn path=/trunk/kdenlive/; revision=4647
parent 400dd0e0
......@@ -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)
......
......@@ -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;
......
......@@ -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)
......
......@@ -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);
}
......@@ -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);
......
......@@ -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());
}
......
......@@ -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
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