1 /***************************************************************************
2 * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include <QDomDocument>
22 #include <QItemDelegate>
23 #include <QTreeWidgetItem>
24 #include <QHeaderView>
26 #include <KStandardDirs>
28 #include <KMessageBox>
31 #include "kdenlivesettings.h"
32 #include "renderwidget.h"
33 #include "ui_saveprofile_ui.h"
35 const int GroupRole = Qt::UserRole;
36 const int ExtensionRole = GroupRole + 1;
37 const int StandardRole = GroupRole + 2;
38 const int RenderRole = GroupRole + 3;
39 const int ParamsRole = GroupRole + 4;
40 const int EditableRole = GroupRole + 5;
42 RenderWidget::RenderWidget(QWidget * parent): QDialog(parent) {
44 m_view.buttonDelete->setIcon(KIcon("trash-empty"));
45 m_view.buttonDelete->setToolTip(i18n("Delete profile"));
46 m_view.buttonDelete->setEnabled(false);
48 m_view.buttonEdit->setIcon(KIcon("document-properties"));
49 m_view.buttonEdit->setToolTip(i18n("Edit profile"));
50 m_view.buttonEdit->setEnabled(false);
52 m_view.buttonSave->setIcon(KIcon("document-new"));
53 m_view.buttonSave->setToolTip(i18n("Create new profile"));
55 m_view.buttonInfo->setIcon(KIcon("help-about"));
57 if (KdenliveSettings::showrenderparams()) {
58 m_view.buttonInfo->setDown(true);
59 } else m_view.advanced_params->hide();
61 m_view.experimentalrender->setChecked(KdenliveSettings::experimentalrender());
63 m_view.experimentalrender->setToolTip(i18n("Changing the size of video when rendering\nis not fully supported, you may have problems\nwith some effects or title clips, so the export\nprofiles that resize your video are marked as\nexperimental"));
65 connect(m_view.buttonInfo, SIGNAL(clicked()), this, SLOT(showInfoPanel()));
67 connect(m_view.buttonSave, SIGNAL(clicked()), this, SLOT(slotSaveProfile()));
68 connect(m_view.buttonEdit, SIGNAL(clicked()), this, SLOT(slotEditProfile()));
69 connect(m_view.buttonDelete, SIGNAL(clicked()), this, SLOT(slotDeleteProfile()));
70 connect(m_view.buttonStart, SIGNAL(clicked()), this, SLOT(slotExport()));
71 connect(m_view.buttonClose, SIGNAL(clicked()), this, SLOT(hide()));
72 connect(m_view.buttonClose2, SIGNAL(clicked()), this, SLOT(hide()));
73 connect(m_view.out_file, SIGNAL(textChanged(const QString &)), this, SLOT(slotUpdateButtons()));
74 connect(m_view.format_list, SIGNAL(currentRowChanged(int)), this, SLOT(refreshView()));
75 connect(m_view.size_list, SIGNAL(currentRowChanged(int)), this, SLOT(refreshParams()));
77 connect(m_view.render_guide, SIGNAL(clicked(bool)), this, SLOT(slotUpdateGuideBox()));
78 connect(m_view.render_zone, SIGNAL(clicked(bool)), this, SLOT(slotUpdateGuideBox()));
79 connect(m_view.render_full, SIGNAL(clicked(bool)), this, SLOT(slotUpdateGuideBox()));
81 connect(m_view.guide_end, SIGNAL(activated(int)), this, SLOT(slotCheckStartGuidePosition()));
82 connect(m_view.guide_start, SIGNAL(activated(int)), this, SLOT(slotCheckEndGuidePosition()));
84 connect(m_view.format_selection, SIGNAL(activated(int)), this, SLOT(refreshView()));
85 connect(m_view.experimentalrender, SIGNAL(stateChanged(int)), this, SLOT(slotUpdateExperimentalRendering()));
87 m_view.buttonStart->setEnabled(false);
88 m_view.guides_box->setVisible(false);
90 m_view.splitter->setStretchFactor(1, 5);
91 m_view.splitter->setStretchFactor(0, 2);
93 m_view.out_file->setMode(KFile::File);
95 m_view.running_jobs->setItemDelegate(new RenderViewDelegate(this));
96 QHeaderView *header = m_view.running_jobs->header();
97 QFontMetrics fm = fontMetrics();
98 //header->resizeSection(0, fm.width("typical-name-for-a-torrent.torrent"));
99 header->setResizeMode(0, QHeaderView::Interactive);
100 header->resizeSection(0, fm.width("typical-name-for-a-file.torrent"));
101 header->setResizeMode(1, QHeaderView::Fixed);
102 header->resizeSection(0, width() * 2 / 3);
103 header->setResizeMode(1, QHeaderView::Interactive);
104 //header->setResizeMode(1, QHeaderView::Fixed);
106 focusFirstVisibleItem();
109 void RenderWidget::slotUpdateExperimentalRendering() {
110 KdenliveSettings::setExperimentalrender(m_view.experimentalrender->isChecked());
115 void RenderWidget::showInfoPanel() {
116 if (m_view.advanced_params->isVisible()) {
117 m_view.advanced_params->setVisible(false);
118 m_view.buttonInfo->setDown(false);
119 KdenliveSettings::setShowrenderparams(false);
121 m_view.advanced_params->setVisible(true);
122 m_view.buttonInfo->setDown(true);
123 KdenliveSettings::setShowrenderparams(true);
127 void RenderWidget::slotUpdateGuideBox() {
128 m_view.guides_box->setVisible(m_view.render_guide->isChecked());
131 void RenderWidget::slotCheckStartGuidePosition() {
132 if (m_view.guide_start->currentIndex() > m_view.guide_end->currentIndex())
133 m_view.guide_start->setCurrentIndex(m_view.guide_end->currentIndex());
136 void RenderWidget::slotCheckEndGuidePosition() {
137 if (m_view.guide_end->currentIndex() < m_view.guide_start->currentIndex())
138 m_view.guide_end->setCurrentIndex(m_view.guide_start->currentIndex());
141 void RenderWidget::setGuides(QDomElement guidesxml, double duration) {
142 m_view.guide_start->clear();
143 m_view.guide_end->clear();
144 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
145 if (nodes.count() > 0) {
146 m_view.guide_start->addItem(i18n("Render"), "0");
147 m_view.render_guide->setEnabled(true);
148 } else m_view.render_guide->setEnabled(false);
149 for (int i = 0; i < nodes.count(); i++) {
150 QDomElement e = nodes.item(i).toElement();
152 m_view.guide_start->addItem(e.attribute("comment"), e.attribute("time").toDouble());
153 m_view.guide_end->addItem(e.attribute("comment"), e.attribute("time").toDouble());
156 if (nodes.count() > 0)
157 m_view.guide_end->addItem(i18n("End"), QString::number(duration));
160 void RenderWidget::slotUpdateButtons() {
161 if (m_view.out_file->url().isEmpty()) m_view.buttonStart->setEnabled(false);
162 else m_view.buttonStart->setEnabled(true);
165 void RenderWidget::slotSaveProfile() {
166 Ui::SaveProfile_UI ui;
167 QDialog *d = new QDialog(this);
169 QString customGroup = i18n("Custom");
170 QStringList groupNames;
171 for (int i = 0; i < m_view.format_list->count(); i++)
172 groupNames.append(m_view.format_list->item(i)->text());
173 if (!groupNames.contains(customGroup)) groupNames.prepend(customGroup);
174 ui.group_name->addItems(groupNames);
175 int pos = ui.group_name->findText(customGroup);
176 ui.group_name->setCurrentIndex(pos);
178 ui.parameters->setText(m_view.advanced_params->toPlainText());
179 ui.extension->setText(m_view.size_list->currentItem()->data(ExtensionRole).toString());
180 ui.profile_name->setFocus();
181 if (d->exec() == QDialog::Accepted && !ui.profile_name->text().simplified().isEmpty()) {
182 QString exportFile = KStandardDirs::locateLocal("appdata", "export/customprofiles.xml");
184 QFile file(exportFile);
185 doc.setContent(&file, false);
188 QDomElement documentElement;
189 bool groupExists = false;
191 QString newProfileName = ui.profile_name->text().simplified();
192 QString newGroupName = ui.group_name->currentText();
193 QDomNodeList groups = doc.elementsByTagName("group");
195 if (groups.count() == 0) {
196 QDomElement profiles = doc.createElement("profiles");
197 doc.appendChild(profiles);
198 } else while (!groups.item(i).isNull()) {
199 documentElement = groups.item(i).toElement();
200 groupName = documentElement.attribute("name");
201 kDebug() << "// SAVE, PARSING FROUP: " << i << ", name: " << groupName << ", LOOK FR: " << newGroupName;
202 if (groupName == newGroupName) {
209 documentElement = doc.createElement("group");
210 documentElement.setAttribute("name", ui.group_name->currentText());
211 documentElement.setAttribute("renderer", "avformat");
212 doc.documentElement().appendChild(documentElement);
214 QDomElement profileElement = doc.createElement("profile");
215 profileElement.setAttribute("name", newProfileName);
216 profileElement.setAttribute("extension", ui.extension->text().simplified());
217 profileElement.setAttribute("args", ui.parameters->toPlainText().simplified());
218 documentElement.appendChild(profileElement);
220 //QCString save = doc.toString().utf8();
222 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
223 KMessageBox::sorry(this, i18n("Unable to write to file %1", exportFile));
227 QTextStream out(&file);
228 out << doc.toString();
230 parseProfiles(newGroupName, newProfileName);
235 void RenderWidget::slotEditProfile() {
236 QListWidgetItem *item = m_view.size_list->currentItem();
238 QString currentGroup = m_view.format_list->currentItem()->text();
240 QString params = item->data(ParamsRole).toString();
241 QString extension = item->data(ExtensionRole).toString();
242 QString currentProfile = item->text();
244 Ui::SaveProfile_UI ui;
245 QDialog *d = new QDialog(this);
247 QStringList groupNames;
248 for (int i = 0; i < m_view.format_list->count(); i++)
249 groupNames.append(m_view.format_list->item(i)->text());
250 if (!groupNames.contains(currentGroup)) groupNames.prepend(currentGroup);
251 ui.group_name->addItems(groupNames);
252 int pos = ui.group_name->findText(currentGroup);
253 ui.group_name->setCurrentIndex(pos);
254 ui.profile_name->setText(currentProfile);
255 ui.extension->setText(extension);
256 ui.parameters->setText(params);
257 ui.profile_name->setFocus();
259 if (d->exec() == QDialog::Accepted) {
261 QString exportFile = KStandardDirs::locateLocal("appdata", "export/customprofiles.xml");
263 QFile file(exportFile);
264 doc.setContent(&file, false);
267 QDomElement documentElement;
268 bool groupExists = false;
270 QString newProfileName = ui.profile_name->text();
271 QString newGroupName = ui.group_name->currentText();
272 QDomNodeList groups = doc.elementsByTagName("group");
274 if (groups.count() == 0) {
275 QDomElement profiles = doc.createElement("profiles");
276 doc.appendChild(profiles);
277 } else while (!groups.item(i).isNull()) {
278 documentElement = groups.item(i).toElement();
279 groupName = documentElement.attribute("name");
280 kDebug() << "// SAVE, PARSING FROUP: " << i << ", name: " << groupName << ", LOOK FR: " << newGroupName;
281 if (groupName == newGroupName) {
288 documentElement = doc.createElement("group");
289 documentElement.setAttribute("name", ui.group_name->currentText());
290 documentElement.setAttribute("renderer", "avformat");
291 doc.documentElement().appendChild(documentElement);
293 QDomElement profileElement = doc.createElement("profile");
294 profileElement.setAttribute("name", newProfileName);
295 profileElement.setAttribute("extension", ui.extension->text().simplified());
296 profileElement.setAttribute("args", ui.parameters->toPlainText().simplified());
297 documentElement.appendChild(profileElement);
299 //QCString save = doc.toString().utf8();
301 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
302 KMessageBox::sorry(this, i18n("Unable to write to file %1", exportFile));
306 QTextStream out(&file);
307 out << doc.toString();
309 parseProfiles(newGroupName, newProfileName);
314 void RenderWidget::slotDeleteProfile() {
315 QString currentGroup = m_view.format_list->currentItem()->text();
316 QString currentProfile = m_view.size_list->currentItem()->text();
318 QString exportFile = KStandardDirs::locateLocal("appdata", "export/customprofiles.xml");
320 QFile file(exportFile);
321 doc.setContent(&file, false);
324 QDomElement documentElement;
325 bool groupExists = false;
327 QDomNodeList groups = doc.elementsByTagName("group");
330 while (!groups.item(i).isNull()) {
331 documentElement = groups.item(i).toElement();
332 groupName = documentElement.attribute("name");
333 if (groupName == currentGroup) {
334 QDomNodeList children = documentElement.childNodes();
335 for (int j = 0; j < children.count(); j++) {
336 QDomElement pro = children.at(j).toElement();
337 if (pro.attribute("name") == currentProfile) {
338 groups.item(i).removeChild(children.at(j));
339 if (groups.item(i).childNodes().isEmpty())
340 doc.documentElement().removeChild(groups.item(i));
349 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
350 KMessageBox::sorry(this, i18n("Unable to write to file %1", exportFile));
353 QTextStream out(&file);
354 out << doc.toString();
356 parseProfiles(currentGroup);
357 focusFirstVisibleItem();
360 void RenderWidget::updateButtons() {
361 if (!m_view.size_list->currentItem() || m_view.size_list->currentItem()->isHidden()) {
362 m_view.buttonSave->setEnabled(false);
363 m_view.buttonDelete->setEnabled(false);
364 m_view.buttonEdit->setEnabled(false);
366 m_view.buttonSave->setEnabled(true);
367 if (m_view.size_list->currentItem()->data(EditableRole).toString().isEmpty()) {
368 m_view.buttonDelete->setEnabled(false);
369 m_view.buttonEdit->setEnabled(false);
371 m_view.buttonDelete->setEnabled(true);
372 m_view.buttonEdit->setEnabled(true);
378 void RenderWidget::focusFirstVisibleItem() {
379 if (m_view.size_list->currentItem() && !m_view.size_list->currentItem()->isHidden()) {
383 for (uint ix = 0; ix < m_view.size_list->count(); ix++) {
384 QListWidgetItem *item = m_view.size_list->item(ix);
385 if (item && !item->isHidden()) {
386 m_view.size_list->setCurrentRow(ix);
390 if (!m_view.size_list->currentItem()) m_view.size_list->setCurrentRow(0);
394 void RenderWidget::slotExport() {
395 QListWidgetItem *item = m_view.size_list->currentItem();
397 QFile f(m_view.out_file->url().path());
399 if (KMessageBox::warningYesNo(this, i18n("File already exists. Do you want to overwrite it ?")) != KMessageBox::Yes)
402 QStringList overlayargs;
403 if (m_view.tc_overlay->isChecked()) {
404 QString filterFile = KStandardDirs::locate("appdata", "metadata.properties");
405 overlayargs << "meta.attr.timecode=1" << "meta.attr.timecode.markup=#timecode";
406 overlayargs << "-attach" << "data_feed:attr_check" << "-attach";
407 overlayargs << "data_show:" + filterFile << "_fezzik=1" << "dynamic=1";
409 double startPos = -1;
411 if (m_view.render_guide->isChecked()) {
412 startPos = m_view.guide_start->itemData(m_view.guide_start->currentIndex()).toDouble();
413 endPos = m_view.guide_end->itemData(m_view.guide_end->currentIndex()).toDouble();
415 QString renderArgs = m_view.advanced_params->toPlainText();
416 renderArgs.replace("%width", QString::number(m_profile.width));
417 renderArgs.replace("%height", QString::number(m_profile.height));
418 renderArgs.replace("%dar", "@" + QString::number(m_profile.display_aspect_num) + "/" + QString::number(m_profile.display_aspect_den));
419 if (m_view.force_progressive->checkState() == Qt::Checked) renderArgs.append(" progressive=1");
420 else if (m_view.force_progressive->checkState() == Qt::Unchecked) renderArgs.append(" progressive=0");
422 // Check if the rendering profile is different from project profile,
423 // in which case we need to use the producer_comsumer from MLT
424 bool resizeProfile = false;
426 QString std = item->data(ParamsRole).toString();
427 if (resizeProfile == false && std.contains(" s=")) {
428 QString subsize = std.section(" s=", 1, 1);
429 subsize = subsize.section(' ', 0, 0).toLower();
430 if (subsize != "%widthx%height") {
431 const QString currentSize = QString::number(m_profile.width) + 'x' + QString::number(m_profile.height);
432 if (subsize != currentSize) resizeProfile = true;
436 emit doRender(m_view.out_file->url().path(), item->data(RenderRole).toString(), overlayargs, renderArgs.simplified().split(' '), m_view.render_zone->isChecked(), m_view.play_after->isChecked(), startPos, endPos, resizeProfile);
439 void RenderWidget::setProfile(MltVideoProfile profile) {
441 //WARNING: this way to tell the video standard is a bit hackish...
442 if (m_profile.description.contains("pal", Qt::CaseInsensitive) || m_profile.description.contains("25", Qt::CaseInsensitive) || m_profile.description.contains("50", Qt::CaseInsensitive)) m_view.format_selection->setCurrentIndex(0);
443 else m_view.format_selection->setCurrentIndex(1);
444 m_view.force_progressive->setCheckState(Qt::PartiallyChecked);
448 void RenderWidget::refreshView() {
449 m_view.size_list->blockSignals(true);
450 QListWidgetItem *item = m_view.format_list->currentItem();
452 m_view.format_list->setCurrentRow(0);
453 item = m_view.format_list->currentItem();
457 QString group = item->text();
458 QListWidgetItem *sizeItem;
459 bool firstSelected = false;
460 const QStringList formatsList = KdenliveSettings::supportedformats();
461 const QStringList vcodecsList = KdenliveSettings::videocodecs();
462 const QStringList acodecsList = KdenliveSettings::audiocodecs();
463 for (int i = 0; i < m_view.size_list->count(); i++) {
464 sizeItem = m_view.size_list->item(i);
465 if (sizeItem->data(GroupRole) == group) {
466 std = sizeItem->data(StandardRole).toString();
467 if (!std.isEmpty()) {
468 if (std.contains("PAL", Qt::CaseInsensitive)) sizeItem->setHidden(m_view.format_selection->currentIndex() != 0);
469 else if (std.contains("NTSC", Qt::CaseInsensitive)) sizeItem->setHidden(m_view.format_selection->currentIndex() != 1);
471 sizeItem->setHidden(false);
472 if (!firstSelected) m_view.size_list->setCurrentItem(sizeItem);
473 firstSelected = true;
475 if (!KdenliveSettings::experimentalrender() && !sizeItem->isHidden()) {
476 // hide experimental codecs (which do resize the video)
477 std = sizeItem->data(ParamsRole).toString();
478 if (std.contains(" s=")) {
479 QString subsize = std.section(" s=", 1, 1);
480 subsize = subsize.section(' ', 0, 0).toLower();
481 if (subsize != "%widthx%height") {
482 const QString currentSize = QString::number(m_profile.width) + 'x' + QString::number(m_profile.height);
483 if (subsize != currentSize) sizeItem->setHidden(true);
487 if (!sizeItem->isHidden()) {
488 // Make sure the selected profile uses an installed avformat codec / format
489 std = sizeItem->data(ParamsRole).toString();
491 if (!formatsList.isEmpty()) {
493 if (std.startsWith("f=")) format = std.section("f=", 1, 1);
494 else if (std.contains(" f=")) format = std.section(" f=", 1, 1);
495 if (!format.isEmpty()) {
496 format = format.section(' ', 0, 0).toLower();
497 if (!formatsList.contains(format)) {
498 kDebug() << "***** UNSUPPORTED F: " << format;
499 sizeItem->setHidden(true);
503 if (!acodecsList.isEmpty() && !sizeItem->isHidden()) {
505 if (std.startsWith("acodec=")) format = std.section("acodec=", 1, 1);
506 else if (std.contains(" acodec=")) format = std.section(" acodec=", 1, 1);
507 if (!format.isEmpty()) {
508 format = format.section(' ', 0, 0).toLower();
509 if (!acodecsList.contains(format)) {
510 kDebug() << "***** UNSUPPORTED ACODEC: " << format;
511 sizeItem->setHidden(true);
515 if (!vcodecsList.isEmpty() && !sizeItem->isHidden()) {
517 if (std.startsWith("vcodec=")) format = std.section("vcodec=", 1, 1);
518 else if (std.contains(" vcodec=")) format = std.section(" vcodec=", 1, 1);
519 if (!format.isEmpty()) {
520 format = format.section(' ', 0, 0).toLower();
521 if (!vcodecsList.contains(format)) {
522 kDebug() << "***** UNSUPPORTED VCODEC: " << format;
523 sizeItem->setHidden(true);
528 } else sizeItem->setHidden(true);
530 focusFirstVisibleItem();
531 m_view.size_list->blockSignals(false);
535 void RenderWidget::refreshParams() {
536 QListWidgetItem *item = m_view.size_list->currentItem();
537 if (!item || item->isHidden()) {
538 m_view.advanced_params->clear();
539 m_view.buttonStart->setEnabled(false);
542 QString params = item->data(ParamsRole).toString();
543 QString extension = item->data(ExtensionRole).toString();
544 m_view.advanced_params->setPlainText(params);
545 m_view.advanced_params->setToolTip(params);
546 KUrl url = m_view.out_file->url();
547 if (!url.isEmpty()) {
548 QString path = url.path();
549 int pos = path.lastIndexOf('.') + 1;
550 if (pos == 0) path.append('.') + extension;
551 else path = path.left(pos) + extension;
552 m_view.out_file->setUrl(KUrl(path));
554 m_view.out_file->setUrl(KUrl(QDir::homePath() + "/untitled." + extension));
556 m_view.out_file->setFilter("*." + extension);
558 if (item->data(EditableRole).toString().isEmpty()) {
559 m_view.buttonDelete->setEnabled(false);
560 m_view.buttonEdit->setEnabled(false);
562 m_view.buttonDelete->setEnabled(true);
563 m_view.buttonEdit->setEnabled(true);
565 m_view.buttonStart->setEnabled(true);
568 void RenderWidget::parseProfiles(QString group, QString profile) {
569 m_view.size_list->clear();
570 m_view.format_list->clear();
571 QString exportFile = KStandardDirs::locate("appdata", "export/profiles.xml");
572 parseFile(exportFile, false);
573 exportFile = KStandardDirs::locateLocal("appdata", "export/customprofiles.xml");
574 if (QFile::exists(exportFile)) parseFile(exportFile, true);
576 QList<QListWidgetItem *> child;
577 child = m_view.format_list->findItems(group, Qt::MatchExactly);
578 if (!child.isEmpty()) m_view.format_list->setCurrentItem(child.at(0));
579 child = m_view.size_list->findItems(profile, Qt::MatchExactly);
580 if (!child.isEmpty()) m_view.size_list->setCurrentItem(child.at(0));
583 void RenderWidget::parseFile(QString exportFile, bool editable) {
585 QFile file(exportFile);
586 doc.setContent(&file, false);
588 QDomElement documentElement;
589 QDomElement profileElement;
590 QDomNodeList groups = doc.elementsByTagName("group");
592 if (groups.count() == 0) {
593 kDebug() << "// Export file: " << exportFile << " IS BROKEN";
601 QString prof_extension;
605 QListWidgetItem *item;
606 while (!groups.item(i).isNull()) {
607 documentElement = groups.item(i).toElement();
608 groupName = documentElement.attribute("name", QString::null);
609 extension = documentElement.attribute("extension", QString::null);
610 renderer = documentElement.attribute("renderer", QString::null);
611 if (m_view.format_list->findItems(groupName, Qt::MatchExactly).isEmpty())
612 new QListWidgetItem(groupName, m_view.format_list);
614 QDomNode n = groups.item(i).firstChild();
615 while (!n.isNull()) {
616 profileElement = n.toElement();
617 profileName = profileElement.attribute("name");
618 standard = profileElement.attribute("standard");
619 params = profileElement.attribute("args");
620 prof_extension = profileElement.attribute("extension");
621 if (!prof_extension.isEmpty()) extension = prof_extension;
622 item = new QListWidgetItem(profileName, m_view.size_list);
623 item->setData(GroupRole, groupName);
624 item->setData(ExtensionRole, extension);
625 item->setData(RenderRole, renderer);
626 item->setData(StandardRole, standard);
627 item->setData(ParamsRole, params);
628 if (editable) item->setData(EditableRole, "true");
636 void RenderWidget::setRenderJob(const QString &dest, int progress) {
637 QList<QTreeWidgetItem *> existing = m_view.running_jobs->findItems(dest, Qt::MatchExactly);
638 if (!existing.isEmpty()) {
639 if (progress == -1) {
640 // Job finished successfully
641 existing.at(0)->setIcon(0, KIcon("dialog-ok"));
642 existing.at(0)->setData(1, Qt::UserRole, 100);
643 } else if (progress == -2) {
645 existing.at(0)->setIcon(0, KIcon("dialog-close"));
646 existing.at(0)->setData(1, Qt::UserRole, 0);
647 } else existing.at(0)->setData(1, Qt::UserRole, progress);
650 QTreeWidgetItem *item = new QTreeWidgetItem(m_view.running_jobs, QStringList() << dest << QString());
651 if (progress == -1) {
652 // Job finished successfully
653 item->setIcon(0, KIcon("dialog-ok"));
654 item->setData(1, Qt::UserRole, 100);
655 } else if (progress == -2) {
657 item->setIcon(0, KIcon("dialog-close"));
658 item->setData(1, Qt::UserRole, 0);
659 } else item->setData(1, Qt::UserRole, progress);
663 #include "renderwidget.moc"