From f96ebb409544c7c1a38993fdee607490b41afd2a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Mon, 10 Mar 2008 21:01:01 +0000 Subject: [PATCH] New export profiles file format, export is now working as expected svn path=/branches/KDE4/; revision=2044 --- CMakeLists.txt | 2 +- export/CMakeLists.txt | 5 + export/profiles.xml | 20 ++++ src/mainwindow.cpp | 6 +- src/mainwindow.h | 2 +- src/renderwidget.cpp | 131 ++++++++++++++++++++++- src/renderwidget.h | 6 +- src/widgets/renderwidget_ui.ui | 186 +++++++++++++++++---------------- 8 files changed, 258 insertions(+), 100 deletions(-) create mode 100644 export/CMakeLists.txt create mode 100644 export/profiles.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 16ed5d0f..cc2e6c7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,4 +19,4 @@ FIND_PACKAGE(LIBFFMPEG REQUIRED) add_subdirectory(src src/cmake_bindir) add_subdirectory(renderer renderer/cmake_bindir) add_subdirectory(effects ) - \ No newline at end of file +add_subdirectory(export ) \ No newline at end of file diff --git a/export/CMakeLists.txt b/export/CMakeLists.txt new file mode 100644 index 00000000..e6a43c2d --- /dev/null +++ b/export/CMakeLists.txt @@ -0,0 +1,5 @@ +INSTALL (FILES + +profiles.xml + +DESTINATION share/apps/kdenlive/export) diff --git a/export/profiles.xml b/export/profiles.xml new file mode 100644 index 00000000..d516b481 --- /dev/null +++ b/export/profiles.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8852041b..b579101d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -483,7 +483,7 @@ void MainWindow::slotRenderProject() { m_renderWidget->show(); } -void MainWindow::slotDoRender(const QString &dest, const QStringList &args, bool zoneOnly, bool playAfter) { +void MainWindow::slotDoRender(const QString &dest, const QStringList &avformat_args, bool zoneOnly, bool playAfter) { if (dest.isEmpty()) return; int in; int out; @@ -502,7 +502,7 @@ void MainWindow::slotDoRender(const QString &dest, const QStringList &args, bool if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out); QString videoPlayer = "-"; if (playAfter) videoPlayer = "kmplayer"; - args << "inigo" << videoPlayer << temp.fileName() << dest; + args << "inigo" << videoPlayer << temp.fileName() << dest << avformat_args; QProcess::startDetached("kdenlive_render", args); } } @@ -561,7 +561,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha connect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool))); connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*))); m_activeTimeline = trackView; - + if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard()); m_monitorManager->setTimecode(doc->timecode()); doc->setRenderer(m_projectMonitor->render); m_commandStack->setActiveStack(doc->commandStack()); diff --git a/src/mainwindow.h b/src/mainwindow.h index a284aef0..4f0cee8c 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -134,7 +134,7 @@ private slots: void slotSwitchVideoThumbs(); void slotSwitchAudioThumbs(); void slotRenderProject(); - void slotDoRender(const QString &dest, const QStringList &args, bool zoneOnly, bool playAfter); + void slotDoRender(const QString &dest, const QStringList &avformat_args, bool zoneOnly, bool playAfter); }; #endif diff --git a/src/renderwidget.cpp b/src/renderwidget.cpp index 14968532..8cb2cfc1 100644 --- a/src/renderwidget.cpp +++ b/src/renderwidget.cpp @@ -17,7 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include + +#include #include #include @@ -26,11 +27,20 @@ #include "kdenlivesettings.h" #include "renderwidget.h" -RenderWidget::RenderWidget(QWidget * parent): QDialog(parent) { +const int GroupRole = Qt::UserRole; +const int ExtensionRole = GroupRole + 1; +const int StandardRole = GroupRole + 2; +const int RenderRole = GroupRole + 3; +const int ParamsRole = GroupRole + 4; + +RenderWidget::RenderWidget(QWidget * parent): QDialog(parent), m_standard("PAL") { m_view.setupUi(this); connect(m_view.buttonStart, SIGNAL(clicked()), this, SLOT(slotExport())); connect(m_view.out_file, SIGNAL(textChanged(const QString &)), this, SLOT(slotUpdateButtons())); + connect(m_view.format_list, SIGNAL(currentRowChanged(int)), this, SLOT(refreshView())); + connect(m_view.size_list, SIGNAL(currentRowChanged(int)), this, SLOT(refreshParams())); m_view.buttonStart->setEnabled(false); + parseProfiles(); } void RenderWidget::slotUpdateButtons() { @@ -44,7 +54,122 @@ void RenderWidget::slotExport() { if (KMessageBox::warningYesNo(this, i18n("File already exists. Doy you want to overwrite it ?")) != KMessageBox::Yes) return; } - emit doRender(m_view.out_file->url().path(), QStringList(), m_view.zone_only->isChecked(), m_view.play_after->isChecked()); + emit doRender(m_view.out_file->url().path(), m_view.advanced_params->text().split(' '), m_view.zone_only->isChecked(), m_view.play_after->isChecked()); +} + +void RenderWidget::setDocumentStandard(QString std) { + m_standard = std; + refreshView(); +} + +void RenderWidget::refreshView() { + QListWidgetItem *item = m_view.format_list->currentItem(); + if (!item) { + m_view.format_list->setCurrentRow(0); + item = m_view.format_list->currentItem(); + } + if (!item) return; + QString std; + QString group = item->text(); + QListWidgetItem *sizeItem; + bool firstSelected = false; + for (int i = 0; i < m_view.size_list->count(); i++) { + sizeItem = m_view.size_list->item(i); + std = sizeItem->data(StandardRole).toString(); + if (!std.isEmpty() && !std.contains(m_standard, Qt::CaseInsensitive)) sizeItem->setHidden(true); + else if (sizeItem->data(GroupRole) == group) { + sizeItem->setHidden(false); + if (!firstSelected) m_view.size_list->setCurrentItem(sizeItem); + firstSelected = true; + } else sizeItem->setHidden(true); + } + +} + +void RenderWidget::refreshParams() { + QListWidgetItem *item = m_view.size_list->currentItem(); + if (!item) return; + QString params = item->data(ParamsRole).toString(); + QString extension = item->data(ExtensionRole).toString(); + m_view.advanced_params->setText(params); + m_view.advanced_params->setToolTip(params); + KUrl url = m_view.out_file->url(); + if (!url.isEmpty()) { + QString path = url.path(); + int pos = path.lastIndexOf('.') + 1; + if (pos == 0) path.append('.') + extension; + else path = path.left(pos) + extension; + m_view.out_file->setUrl(KUrl(path)); + } else { + m_view.out_file->setUrl(KUrl(QDir::homePath() + "/untitled." + extension)); + } +} + +void RenderWidget::parseProfiles() { + QString exportFile = KStandardDirs::locate("data", "kdenlive/export/profiles.xml"); + QDomDocument doc; + QFile file(exportFile); + doc.setContent(&file, false); + QDomElement documentElement; + QDomElement profileElement; + + QDomNodeList groups = doc.elementsByTagName("group"); + + if (groups.count() == 0) { + kDebug() << "// Export file: " << exportFile << " IS BROKEN"; + return; + } + kDebug() << "// FOUND FFECT GROUP: " << groups.count() << " IS BROKEN"; + int i = 0; + QString groupName; + QString profileName; + QString extension; + QString prof_extension; + QString renderer; + QString params; + QString standard; + QListWidgetItem *item; + while (!groups.item(i).isNull()) { + documentElement = groups.item(i).toElement(); + groupName = documentElement.attribute("name", QString::null); + extension = documentElement.attribute("extension", QString::null); + renderer = documentElement.attribute("renderer", QString::null); + new QListWidgetItem(groupName, m_view.format_list); + + QDomNode n = groups.item(i).firstChild(); + while (!n.isNull()) { + profileElement = n.toElement(); + profileName = profileElement.attribute("name"); + standard = profileElement.attribute("standard"); + params = profileElement.attribute("args"); + prof_extension = profileElement.attribute("extension"); + if (!prof_extension.isEmpty()) extension = prof_extension; + item = new QListWidgetItem(profileName, m_view.size_list); + item->setData(GroupRole, groupName); + item->setData(ExtensionRole, extension); + item->setData(RenderRole, renderer); + item->setData(StandardRole, standard); + item->setData(ParamsRole, params); + n = n.nextSibling(); + } + + i++; + /* + bool ladspaOk = true; + if (tag == "ladspa") { + QString library = documentElement.attribute("library", QString::null); + if (KStandardDirs::locate("ladspa_plugin", library).isEmpty()) ladspaOk = false; + } + + // Parse effect file + if ((filtersList.contains(tag) || producersList.contains(tag)) && ladspaOk) { + bool isAudioEffect = false; + QDomNode propsnode = documentElement.elementsByTagName("properties").item(0); + if (!propsnode.isNull()) { + QDomElement propselement = propsnode.toElement(); + */ + } + refreshView(); } diff --git a/src/renderwidget.h b/src/renderwidget.h index 55324e78..2bbed5ff 100644 --- a/src/renderwidget.h +++ b/src/renderwidget.h @@ -31,13 +31,17 @@ class RenderWidget : public QDialog { public: RenderWidget(QWidget * parent = 0); - + void setDocumentStandard(QString std); private slots: void slotUpdateButtons(); void slotExport(); + void refreshView(); + void refreshParams(); private: Ui::RenderWidget_UI m_view; + QString m_standard; + void parseProfiles(); signals: void doRender(const QString&, const QStringList &, bool, bool); diff --git a/src/widgets/renderwidget_ui.ui b/src/widgets/renderwidget_ui.ui index e8c076f2..6566530f 100644 --- a/src/widgets/renderwidget_ui.ui +++ b/src/widgets/renderwidget_ui.ui @@ -5,12 +5,12 @@ 0 0 - 374 - 243 + 389 + 374 - Dialog + Rendering @@ -20,102 +20,36 @@ - + - - - - Video Profile - - - - - - - - - - - Image size: - - - - - - - 720x576 - - - - - - - Frame rate: - - - - - - - 25 - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 6 - - - - - - - - + Selected zone only - + Play after render - - - - Parameters - - - - - + + + + + + Extra parameters + + + + + + + @@ -124,7 +58,20 @@ - + + + + Qt::Horizontal + + + + 153 + 27 + + + + + Qt::Horizontal @@ -134,24 +81,81 @@ + + + + 0 + + + + Templates + + + + + + Format + + + + + + + + + + + 0 + 0 + + + + + + + + + + + S + + + + + + + D + + + + + + + - - KComboBox - QComboBox -
kcombobox.h
-
KLineEdit QLineEdit
klineedit.h
+ + KListWidget + QListWidget +
klistwidget.h
+
KPushButton QPushButton
kpushbutton.h
+ + KTabWidget + QTabWidget +
ktabwidget.h
+ 1 +
KUrlRequester QFrame -- 2.39.2