renderwidget.cpp 102 KB
Newer Older
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/***************************************************************************
 *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
 ***************************************************************************/

20

21 22 23
#include "renderwidget.h"
#include "kdenlivesettings.h"
#include "ui_saveprofile_ui.h"
24
#include "timecode.h"
Vincent PINON's avatar
Vincent PINON committed
25
#include "dialogs/profilesdialog.h"
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
26 27 28

#include <KStandardDirs>
#include <KDebug>
29
#include <KMessageBox>
30
#include <KRun>
31
#include <KIO/NetAccess>
32
#include <KColorScheme>
33
#include <KNotification>
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
34

35 36 37 38 39
#include <QDomDocument>
#include <QTreeWidgetItem>
#include <QListWidgetItem>
#include <QHeaderView>
#include <QInputDialog>
40
#include <QProcess>
41
#include <QDBusConnectionInterface>
42
#include <QThread>
43
#include <QScriptEngine>
44
#include <QKeyEvent>
45
#include <QTimer>
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
46

47 48
#include "locale.h"

49 50

// Render profiles roles
51 52 53 54 55 56 57 58 59 60 61 62 63
enum {GroupRole = Qt::UserRole,
      ExtensionRole,
      StandardRole,
      RenderRole,
      ParamsRole,
      EditableRole,
      MetaGroupRole,
      ExtraRole,
      BitratesRole,
      DefaultBitrateRole,
      AudioBitratesRole,
      DefaultAudioBitrateRole
     };
64

65 66 67
// Render job roles
const int ParametersRole = Qt::UserRole + 1;
const int TimeRole = Qt::UserRole + 2;
68 69
const int ProgressRole = Qt::UserRole + 3;
const int ExtraInfoRole = Qt::UserRole + 5;
70

71 72
const int DirectRenderType = QTreeWidgetItem::Type;
const int ScriptRenderType = QTreeWidgetItem::UserType;
73 74


75 76 77 78
// Running job status
const int WAITINGJOB = 0;
const int RUNNINGJOB = 1;
const int FINISHEDJOB = 2;
79 80 81 82
const int FAILEDJOB = 3;
const int ABORTEDJOB = 4;


Laurent Montel's avatar
Laurent Montel committed
83 84
RenderJobItem::RenderJobItem(QTreeWidget * parent, const QStringList & strings, int type)
    : QTreeWidgetItem(parent, strings, type),
85 86
    m_status(-1)
{
87
    setSizeHint(1, QSize(parent->columnWidth(1), parent->fontMetrics().height() * 3));
88 89 90 91 92
    setStatus(WAITINGJOB);
}

void RenderJobItem::setStatus(int status)
{
Laurent Montel's avatar
Laurent Montel committed
93 94
    if (m_status == status)
        return;
95 96 97
    m_status = status;
    switch (status) {
        case WAITINGJOB:
98
            setIcon(0, QIcon::fromTheme("media-playback-pause"));
99 100 101 102
            setData(1, Qt::UserRole, i18n("Waiting..."));
            break;
        case FINISHEDJOB:
            setData(1, Qt::UserRole, i18n("Rendering finished"));
103
            setIcon(0, QIcon::fromTheme("dialog-ok"));
104
            setData(1, ProgressRole, 100);
105 106 107
            break;
        case FAILEDJOB:
            setData(1, Qt::UserRole, i18n("Rendering crashed"));
108
            setIcon(0, QIcon::fromTheme("dialog-close"));
109
            setData(1, ProgressRole, 100);
110 111 112
            break;
        case ABORTEDJOB:
            setData(1, Qt::UserRole, i18n("Rendering aborted"));
113
            setIcon(0, QIcon::fromTheme("dialog-cancel"));
114
            setData(1, ProgressRole, 100);
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
        
        default:
            break;
    }
}

int RenderJobItem::status() const
{
    return m_status;
}

void RenderJobItem::setMetadata(const QString &data)
{
    m_data = data;
}

const QString RenderJobItem::metadata() const
{
    return m_data;
}
135 136


Laurent Montel's avatar
Laurent Montel committed
137
RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, const MltVideoProfile &profile, QWidget * parent) :
138
        QDialog(parent),
139
        m_projectFolder(projectfolder),
140
        m_profile(profile),
141
        m_blockProcessing(false)
142
{
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
143
    m_view.setupUi(this);
144 145 146
    int size = style()->pixelMetric(QStyle::PM_SmallIconSize);
    QSize iconSize(size, size);
    
147
    setWindowTitle(i18n("Rendering"));
148 149 150 151 152 153
    m_view.buttonDelete->setIconSize(iconSize);
    m_view.buttonEdit->setIconSize(iconSize);
    m_view.buttonSave->setIconSize(iconSize);
    m_view.buttonInfo->setIconSize(iconSize);
    m_view.buttonFavorite->setIconSize(iconSize);
    
154
    m_view.buttonDelete->setIcon(QIcon::fromTheme("trash-empty"));
155 156 157
    m_view.buttonDelete->setToolTip(i18n("Delete profile"));
    m_view.buttonDelete->setEnabled(false);

158
    m_view.buttonEdit->setIcon(QIcon::fromTheme("document-properties"));
159 160 161
    m_view.buttonEdit->setToolTip(i18n("Edit profile"));
    m_view.buttonEdit->setEnabled(false);

162
    m_view.buttonSave->setIcon(QIcon::fromTheme("document-new"));
163 164
    m_view.buttonSave->setToolTip(i18n("Create new profile"));

165 166
    m_view.buttonInfo->setIcon(QIcon::fromTheme("help-about"));
    m_view.hide_log->setIcon(QIcon::fromTheme("go-down"));
167

168
    m_view.buttonFavorite->setIcon(QIcon::fromTheme("favorites"));
169
    m_view.buttonFavorite->setToolTip(i18n("Copy profile to favorites"));
170
    
171 172
    m_view.show_all_profiles->setToolTip(i18n("Show profiles with different framerate"));
    
173
    m_view.advanced_params->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5);
174 175 176
    
    m_view.buttonRender->setEnabled(false);
    m_view.buttonGenerateScript->setEnabled(false);
177
    setRescaleEnabled(false);
178 179 180 181 182 183 184 185
    m_view.guides_box->setVisible(false);
    m_view.open_dvd->setVisible(false);
    m_view.create_chapter->setVisible(false);
    m_view.open_browser->setVisible(false);
    m_view.error_box->setVisible(false);
    m_view.tc_type->setEnabled(false);
    m_view.checkTwoPass->setEnabled(false);
    
186 187
    if (KdenliveSettings::showrenderparams()) {
        m_view.buttonInfo->setDown(true);
Laurent Montel's avatar
Laurent Montel committed
188 189 190
    } else {
        m_view.advanced_params->hide();
    }
191
    
192
    m_view.proxy_render->setHidden(!enableProxy);
193

194 195 196 197
    KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
    QColor bg = scheme.background(KColorScheme::NegativeBackground).color();
    m_view.errorBox->setStyleSheet(QString("QGroupBox { background-color: rgb(%1, %2, %3); border-radius: 5px;}; ").arg(bg.red()).arg(bg.green()).arg(bg.blue()));
    int height = QFontInfo(font()).pixelSize();
198
    m_view.errorIcon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(height, height));
199 200 201 202 203 204 205 206 207 208
    m_view.errorBox->setHidden(true);

#if KDE_IS_VERSION(4,7,0)
    m_infoMessage = new KMessageWidget;
    QGridLayout *s =  static_cast <QGridLayout*> (m_view.tab->layout());
    s->addWidget(m_infoMessage, 16, 0, 1, -1);
    m_infoMessage->setCloseButtonVisible(false);
    m_infoMessage->hide();
#endif

209 210 211 212
    m_view.encoder_threads->setMaximum(QThread::idealThreadCount());
    m_view.encoder_threads->setValue(KdenliveSettings::encodethreads());
    connect(m_view.encoder_threads, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateEncodeThreads(int)));

213 214 215
    m_view.rescale_keep->setChecked(KdenliveSettings::rescalekeepratio());
    connect(m_view.rescale_width, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateRescaleWidth(int)));
    connect(m_view.rescale_height, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateRescaleHeight(int)));
216
    m_view.rescale_keep->setIcon(QIcon::fromTheme("insert-link"));
217 218
    m_view.rescale_keep->setToolTip(i18n("Preserve aspect ratio"));
    connect(m_view.rescale_keep, SIGNAL(clicked()), this, SLOT(slotSwitchAspectRatio()));
219

220 221 222
    connect(m_view.buttonRender, SIGNAL(clicked()), this, SLOT(slotPrepareExport()));
    connect(m_view.buttonGenerateScript, SIGNAL(clicked()), this, SLOT(slotGenerateScript()));

223 224 225 226
    m_view.abort_job->setEnabled(false);
    m_view.start_script->setEnabled(false);
    m_view.delete_script->setEnabled(false);

227 228
    m_view.format_list->setAlternatingRowColors(true);
    m_view.size_list->setAlternatingRowColors(true);
229

230 231 232
    connect(m_view.export_audio, SIGNAL(stateChanged(int)), this, SLOT(slotUpdateAudioLabel(int)));
    m_view.export_audio->setCheckState(Qt::PartiallyChecked);

233
    parseProfiles();
234
    parseScriptFiles();
235 236
    m_view.running_jobs->setUniformRowHeights(false);
    m_view.scripts_list->setUniformRowHeights(false);
237 238
    connect(m_view.start_script, SIGNAL(clicked()), this, SLOT(slotStartScript()));
    connect(m_view.delete_script, SIGNAL(clicked()), this, SLOT(slotDeleteScript()));
239 240
    connect(m_view.scripts_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckScript()));
    connect(m_view.running_jobs, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckJob()));
Laurent Montel's avatar
Laurent Montel committed
241
    connect(m_view.running_jobs, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(slotPlayRendering(QTreeWidgetItem*,int)));
242

243 244
    connect(m_view.buttonInfo, SIGNAL(clicked()), this, SLOT(showInfoPanel()));

245
    connect(m_view.buttonSave, SIGNAL(clicked()), this, SLOT(slotSaveProfile()));
246
    connect(m_view.buttonEdit, SIGNAL(clicked()), this, SLOT(slotEditProfile()));
247
    connect(m_view.buttonDelete, SIGNAL(clicked()), this, SLOT(slotDeleteProfile()));
248 249
    connect(m_view.buttonFavorite, SIGNAL(clicked()), this, SLOT(slotCopyToFavorites()));

250
    connect(m_view.abort_job, SIGNAL(clicked()), this, SLOT(slotAbortCurrentJob()));
251
    connect(m_view.start_job, SIGNAL(clicked()), this, SLOT(slotStartCurrentJob()));
252 253 254
    connect(m_view.clean_up, SIGNAL(clicked()), this, SLOT(slotCLeanUpJobs()));
    connect(m_view.hide_log, SIGNAL(clicked()), this, SLOT(slotHideLog()));

255 256
    connect(m_view.buttonClose, SIGNAL(clicked()), this, SLOT(hide()));
    connect(m_view.buttonClose2, SIGNAL(clicked()), this, SLOT(hide()));
257
    connect(m_view.buttonClose3, SIGNAL(clicked()), this, SLOT(hide()));
258
    connect(m_view.rescale, SIGNAL(toggled(bool)), this, SLOT(setRescaleEnabled(bool)));
259
    connect(m_view.destination_list, SIGNAL(activated(int)), this, SLOT(refreshCategory()));
Laurent Montel's avatar
Laurent Montel committed
260
    connect(m_view.out_file, SIGNAL(textChanged(QString)), this, SLOT(slotUpdateButtons()));
261
    connect(m_view.out_file, SIGNAL(urlSelected(QUrl)), this, SLOT(slotUpdateButtons(QUrl)));
262 263
    connect(m_view.format_list, SIGNAL(currentRowChanged(int)), this, SLOT(refreshView()));
    connect(m_view.size_list, SIGNAL(currentRowChanged(int)), this, SLOT(refreshParams()));
264
    connect(m_view.show_all_profiles, SIGNAL(stateChanged(int)), this, SLOT(refreshView()));
265

Laurent Montel's avatar
Laurent Montel committed
266
    connect(m_view.size_list, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(slotEditItem(QListWidgetItem*)));
267

268 269 270 271 272 273 274
    connect(m_view.render_guide, SIGNAL(clicked(bool)), this, SLOT(slotUpdateGuideBox()));
    connect(m_view.render_zone, SIGNAL(clicked(bool)), this, SLOT(slotUpdateGuideBox()));
    connect(m_view.render_full, SIGNAL(clicked(bool)), this, SLOT(slotUpdateGuideBox()));

    connect(m_view.guide_end, SIGNAL(activated(int)), this, SLOT(slotCheckStartGuidePosition()));
    connect(m_view.guide_start, SIGNAL(activated(int)), this, SLOT(slotCheckEndGuidePosition()));

275
    connect(m_view.tc_overlay, SIGNAL(toggled(bool)), m_view.tc_type, SLOT(setEnabled(bool)));
276

277 278
    m_view.splitter->setStretchFactor(1, 5);
    m_view.splitter->setStretchFactor(0, 2);
279

280
    m_view.out_file->setMode(KFile::File);
281
    m_view.out_file->setFocusPolicy(Qt::ClickFocus);
282

283
    m_view.running_jobs->setHeaderLabels(QStringList() << QString() << i18n("File"));
284 285
    m_jobsDelegate = new RenderViewDelegate(this);
    m_view.running_jobs->setItemDelegate(m_jobsDelegate);
286

287
    QHeaderView *header = m_view.running_jobs->header();
288 289
    header->setResizeMode(0, QHeaderView::Fixed);
    header->resizeSection(0, 30);
290
    header->setResizeMode(1, QHeaderView::Interactive);
291

292
    m_view.scripts_list->setHeaderLabels(QStringList() << QString() << i18n("Script Files"));
293 294
    m_scriptsDelegate = new RenderViewDelegate(this);
    m_view.scripts_list->setItemDelegate(m_scriptsDelegate);
295 296 297
    header = m_view.scripts_list->header();
    header->setResizeMode(0, QHeaderView::Fixed);
    header->resizeSection(0, 30);
298

Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
299 300 301 302
    // Find path for Kdenlive renderer
    m_renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
    if (!QFile::exists(m_renderer)) {
        m_renderer = KStandardDirs::findExe("kdenlive_render");
Laurent Montel's avatar
Laurent Montel committed
303 304 305 306
        if (m_renderer.isEmpty())
            m_renderer = KStandardDirs::locate("exe", "kdenlive_render");
        if (m_renderer.isEmpty())
            m_renderer = "kdenlive_render";
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
307 308
    }

309
    QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
310
    if (!interface || (!interface->isServiceRegistered("org.kde.ksmserver") && !interface->isServiceRegistered("org.gnome.SessionManager")))
311 312
        m_view.shutdown->setEnabled(false);

313
    focusFirstVisibleItem();
314
    adjustSize();
315 316 317 318 319 320
}

QSize RenderWidget::sizeHint() const
{
    // Make sure the widget has minimum size on opening
    return QSize(200, 200);
321 322
}

323 324 325 326 327 328 329 330
RenderWidget::~RenderWidget()
{
    m_view.running_jobs->blockSignals(true);
    m_view.scripts_list->blockSignals(true);
    m_view.running_jobs->clear();
    m_view.scripts_list->clear();
    delete m_jobsDelegate;
    delete m_scriptsDelegate;
331 332 333
#if KDE_IS_VERSION(4,7,0)
    delete m_infoMessage;
#endif
334 335
}

336 337
void RenderWidget::slotEditItem(QListWidgetItem *item)
{
Laurent Montel's avatar
Laurent Montel committed
338 339 340
    const QString edit = item->data(EditableRole).toString();
    if (edit.isEmpty() || !edit.endsWith(QLatin1String("customprofiles.xml")))
        slotSaveProfile();
341 342 343
    else slotEditProfile();
}

344 345
void RenderWidget::showInfoPanel()
{
346 347 348 349 350 351 352 353 354
    if (m_view.advanced_params->isVisible()) {
        m_view.advanced_params->setVisible(false);
        m_view.buttonInfo->setDown(false);
        KdenliveSettings::setShowrenderparams(false);
    } else {
        m_view.advanced_params->setVisible(true);
        m_view.buttonInfo->setDown(true);
        KdenliveSettings::setShowrenderparams(true);
    }
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
355 356
}

357
void RenderWidget::setDocumentPath(const QString &path)
358
{
359
    if (m_view.out_file->url().adjusted(QUrl::RemoveFilename).path() == QUrl(m_projectFolder).adjusted(QUrl::RemoveFilename).path()) {
360
        const QString fileName = m_view.out_file->url().fileName();
361
        m_view.out_file->setUrl(QUrl(path + fileName));
362
    }
363
    m_projectFolder = path;
364
    parseScriptFiles();
365

366 367
}

368 369
void RenderWidget::slotUpdateGuideBox()
{
370 371 372
    m_view.guides_box->setVisible(m_view.render_guide->isChecked());
}

373 374
void RenderWidget::slotCheckStartGuidePosition()
{
375 376 377 378
    if (m_view.guide_start->currentIndex() > m_view.guide_end->currentIndex())
        m_view.guide_start->setCurrentIndex(m_view.guide_end->currentIndex());
}

379 380
void RenderWidget::slotCheckEndGuidePosition()
{
381 382 383 384
    if (m_view.guide_end->currentIndex() < m_view.guide_start->currentIndex())
        m_view.guide_end->setCurrentIndex(m_view.guide_start->currentIndex());
}

385 386
void RenderWidget::setGuides(QDomElement guidesxml, double duration)
{
387 388 389
    m_view.guide_start->clear();
    m_view.guide_end->clear();
    QDomNodeList nodes = guidesxml.elementsByTagName("guide");
Laurent Montel's avatar
Laurent Montel committed
390
    if (!nodes.isEmpty()) {
391
        m_view.guide_start->addItem(i18n("Beginning"), "0");
392
        m_view.render_guide->setEnabled(true);
393 394 395 396 397
        m_view.create_chapter->setEnabled(true);
    } else {
        m_view.render_guide->setEnabled(false);
        m_view.create_chapter->setEnabled(false);
    }
398
    double fps = (double) m_profile.frame_rate_num / m_profile.frame_rate_den;
399
    for (int i = 0; i < nodes.count(); ++i) {
400 401
        QDomElement e = nodes.item(i).toElement();
        if (!e.isNull()) {
402 403 404 405
            GenTime pos = GenTime(e.attribute("time").toDouble());
            const QString guidePos = Timecode::getStringTimecode(pos.frames(fps), fps);
            m_view.guide_start->addItem(e.attribute("comment") + '/' + guidePos, e.attribute("time").toDouble());
            m_view.guide_end->addItem(e.attribute("comment") + '/' + guidePos, e.attribute("time").toDouble());
406 407
        }
    }
Laurent Montel's avatar
Laurent Montel committed
408
    if (!nodes.isEmpty())
409 410 411
        m_view.guide_end->addItem(i18n("End"), QString::number(duration));
}

412
/**
Simon Eugster's avatar
Simon Eugster committed
413 414 415
 * Will be called when the user selects an output file via the file dialog.
 * File extension will be added automatically.
 */
416
void RenderWidget::slotUpdateButtons(const QUrl &url)
417
{
418 419 420 421
    if (m_view.out_file->url().isEmpty()) {
        m_view.buttonGenerateScript->setEnabled(false);
        m_view.buttonRender->setEnabled(false);
    } else {
422 423
        updateButtons(); // This also checks whether the selected format is available
    }
424
    if (!url.isEmpty()) {
425
        QListWidgetItem *item = m_view.size_list->currentItem();
426
        if (!item) {
427 428
            m_view.buttonRender->setEnabled(false);
            m_view.buttonGenerateScript->setEnabled(false);
429 430
            return;
        }
Laurent Montel's avatar
Laurent Montel committed
431 432
        const QString extension = item->data(ExtensionRole).toString();
        m_view.out_file->setUrl(filenameWithExtension(url, extension));
433 434 435
    }
}

Simon Eugster's avatar
Simon Eugster committed
436 437 438 439
/**
 * Will be called when the user changes the output file path in the text line.
 * File extension must NOT be added, would make editing impossible!
 */
440 441
void RenderWidget::slotUpdateButtons()
{
442 443 444 445 446 447
    if (m_view.out_file->url().isEmpty()) {
        m_view.buttonRender->setEnabled(false);
        m_view.buttonGenerateScript->setEnabled(false);
    } else {
        updateButtons(); // This also checks whether the selected format is available
    }
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
448 449
}

450 451
void RenderWidget::slotSaveProfile()
{
452
    //TODO: update to correctly use metagroups
453
    Ui::SaveProfile_UI ui;
454
    QPointer<QDialog> d = new QDialog(this);
455
    ui.setupUi(d);
456

457
    for (int i = 0; i < m_view.destination_list->count(); ++i)
458
        ui.destination_list->addItem(m_view.destination_list->itemIcon(i), m_view.destination_list->itemText(i), m_view.destination_list->itemData(i, Qt::UserRole));
459 460

    ui.destination_list->setCurrentIndex(m_view.destination_list->currentIndex());
461
    QString dest = ui.destination_list->itemData(ui.destination_list->currentIndex(), Qt::UserRole).toString();
462

463
    QString customGroup = m_view.format_list->currentItem()->text();
Yuri Chornoivan's avatar
Yuri Chornoivan committed
464
    if (customGroup.isEmpty()) customGroup = i18nc("Group Name", "Custom");
465
    ui.group_name->setText(customGroup);
466

467
    QStringList arguments = m_view.advanced_params->toPlainText().split(' ', QString::SkipEmptyParts);
468
    ui.parameters->setText(arguments.join(" "));
469 470
    ui.extension->setText(m_view.size_list->currentItem()->data(ExtensionRole).toString());
    ui.profile_name->setFocus();
471
    QListWidgetItem *item = m_view.size_list->currentItem();
472 473 474 475 476 477 478 479
    if (ui.parameters->toPlainText().contains("%bitrate") || ui.parameters->toPlainText().contains("%quality")) {
        if (ui.parameters->toPlainText().contains("%quality")) {
            ui.vbitrates_label->setText(i18n("Qualities"));
            ui.default_vbitrate_label->setText(i18n("Default quality"));
        } else {
            ui.vbitrates_label->setText(i18n("Bitrates"));
            ui.default_vbitrate_label->setText(i18n("Default bitrate"));
        }
480 481
        if ( item && item->data(BitratesRole).canConvert(QVariant::StringList) && item->data(BitratesRole).toStringList().count()) {
            QStringList bitrates = item->data(BitratesRole).toStringList();
482
            ui.vbitrates_list->setText(bitrates.join(","));
483 484 485 486 487
            if (item->data(DefaultBitrateRole).canConvert(QVariant::String))
                ui.default_vbitrate->setValue(item->data(DefaultBitrateRole).toInt());
        }
    }
    else ui.vbitrates->setHidden(true);
488 489 490 491 492 493 494 495 496
    if (ui.parameters->toPlainText().contains("%audiobitrate") || ui.parameters->toPlainText().contains("%audioquality")) {
        if (ui.parameters->toPlainText().contains("%audioquality")) {
            ui.abitrates_label->setText(i18n("Qualities"));
            ui.default_abitrate_label->setText(i18n("Default quality"));
        } else {
            ui.abitrates_label->setText(i18n("Bitrates"));
            ui.default_abitrate_label->setText(i18n("Default bitrate"));
        }
        if ( item && item->data(AudioBitratesRole).canConvert(QVariant::StringList) && item->data(AudioBitratesRole).toStringList().count()) {
497
            QStringList bitrates = item->data(AudioBitratesRole).toStringList();
498
            ui.abitrates_list->setText(bitrates.join(","));
499 500 501 502 503
            if (item->data(DefaultAudioBitrateRole).canConvert(QVariant::String))
                ui.default_abitrate->setValue(item->data(DefaultAudioBitrateRole).toInt());
        }
    }
    else ui.abitrates->setHidden(true);
504

505
    if (d->exec() == QDialog::Accepted && !ui.profile_name->text().simplified().isEmpty()) {
506 507
        QString newProfileName = ui.profile_name->text().simplified();
        QString newGroupName = ui.group_name->text().simplified();
Yuri Chornoivan's avatar
Yuri Chornoivan committed
508
        if (newGroupName.isEmpty()) newGroupName = i18nc("Group Name", "Custom");
509
        QString newMetaGroupId = ui.destination_list->itemData(ui.destination_list->currentIndex(), Qt::UserRole).toString();
510 511

        QDomDocument doc;
512 513 514 515 516
        QDomElement profileElement = doc.createElement("profile");
        profileElement.setAttribute("name", newProfileName);
        profileElement.setAttribute("category", newGroupName);
        profileElement.setAttribute("destinationid", newMetaGroupId);
        profileElement.setAttribute("extension", ui.extension->text().simplified());
517 518
        QString args = ui.parameters->toPlainText().simplified();
        profileElement.setAttribute("args", args);
519
        if (args.contains("%bitrate")) {
520
            // profile has a variable bitrate
521 522
            profileElement.setAttribute("defaultbitrate", QString::number(ui.default_vbitrate->value()));
            profileElement.setAttribute("bitrates", ui.vbitrates_list->text());
523 524 525
        } else if (args.contains("%quality")) {
            profileElement.setAttribute("defaultquality", QString::number(ui.default_vbitrate->value()));
            profileElement.setAttribute("qualities", ui.vbitrates_list->text());
526
        }
527 528

        if (args.contains("%audiobitrate")) {
529
            // profile has a variable bitrate
530 531
            profileElement.setAttribute("defaultaudiobitrate", QString::number(ui.default_abitrate->value()));
            profileElement.setAttribute("audiobitrates", ui.abitrates_list->text());
532 533 534 535
        } else if (args.contains("%audioquality")) {
            // profile has a variable bitrate
            profileElement.setAttribute("defaultaudioquality", QString::number(ui.default_abitrate->value()));
            profileElement.setAttribute("audioqualities", ui.abitrates_list->text());
536
        }
537 538 539
        doc.appendChild(profileElement);
        saveProfile(doc.documentElement());

540 541 542 543 544 545
        parseProfiles(newMetaGroupId, newGroupName, newProfileName);
    }
    delete d;
}


546
void RenderWidget::saveProfile(const QDomElement &newprofile)
547
{
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568
    QString exportFile = KStandardDirs::locateLocal("appdata", "export/customprofiles.xml");
    QDomDocument doc;
    QFile file(exportFile);
    doc.setContent(&file, false);
    file.close();
    QDomElement documentElement;
    QDomElement profiles = doc.documentElement();
    if (profiles.isNull() || profiles.tagName() != "profiles") {
        doc.clear();
        profiles = doc.createElement("profiles");
        profiles.setAttribute("version", 1);
        doc.appendChild(profiles);
    }
    int version = profiles.attribute("version", 0).toInt();
    if (version < 1) {
        kDebug() << "// OLD profile version";
        doc.clear();
        profiles = doc.createElement("profiles");
        profiles.setAttribute("version", 1);
        doc.appendChild(profiles);
    }
569

570

571 572 573 574 575 576 577 578 579
    QDomNodeList profilelist = doc.elementsByTagName("profile");
    int i = 0;
    while (!profilelist.item(i).isNull()) {
        // make sure a profile with same name doesn't exist
        documentElement = profilelist.item(i).toElement();
        QString profileName = documentElement.attribute("name");
        if (profileName == newprofile.attribute("name")) {
            // a profile with that same name already exists
            bool ok;
Vincent PINON's avatar
Vincent PINON committed
580
            QString newProfileName = QInputDialog::getText(this, i18n("Profile already exists"), i18n("This profile name already exists. Change the name if you don't want to overwrite it."), KLineEdit::Normal, profileName, &ok);
581 582 583 584
            if (!ok) return;
            if (profileName == newProfileName) {
                profiles.removeChild(profilelist.item(i));
                break;
585 586
            }
        }
587
        ++i;
588
    }
589

590
    profiles.appendChild(newprofile);
591

592
    //QCString save = doc.toString().utf8();
593

594 595 596 597 598 599 600 601
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
        KMessageBox::sorry(this, i18n("Unable to write to file %1", exportFile));
        return;
    }
    QTextStream out(&file);
    out << doc.toString();
    if (file.error() != QFile::NoError) {
        KMessageBox::error(this, i18n("Cannot write to file %1", exportFile));
602
        file.close();
603 604 605
        return;
    }
    file.close();
606 607 608 609 610
}

void RenderWidget::slotCopyToFavorites()
{
    QListWidgetItem *item = m_view.size_list->currentItem();
Laurent Montel's avatar
Laurent Montel committed
611 612
    if (!item)
        return;
613 614 615 616 617 618 619 620
    QString currentGroup = m_view.format_list->currentItem()->text();

    QString params = item->data(ParamsRole).toString();
    QString extension = item->data(ExtensionRole).toString();
    QString currentProfile = item->text();
    QDomDocument doc;
    QDomElement profileElement = doc.createElement("profile");
    profileElement.setAttribute("name", currentProfile);
Yuri Chornoivan's avatar
Yuri Chornoivan committed
621
    profileElement.setAttribute("category", i18nc("Category Name", "Custom"));
622 623 624
    profileElement.setAttribute("destinationid", "favorites");
    profileElement.setAttribute("extension", extension);
    profileElement.setAttribute("args", params);
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641
    if (params.contains("%bitrate")) {
        // profile has a variable bitrate
        profileElement.setAttribute("defaultbitrate", item->data(DefaultBitrateRole).toString());
        profileElement.setAttribute("bitrates", item->data(BitratesRole).toStringList().join(","));
    } else if (params.contains("%quality")) {
        profileElement.setAttribute("defaultquality", item->data(DefaultBitrateRole).toString());
        profileElement.setAttribute("qualities", item->data(BitratesRole).toStringList().join(","));
    }
    if (params.contains("%audiobitrate")) {
        // profile has a variable bitrate
        profileElement.setAttribute("defaultaudiobitrate", item->data(DefaultAudioBitrateRole).toString());
        profileElement.setAttribute("audiobitrates", item->data(AudioBitratesRole).toStringList().join(","));
    } else if (params.contains("%audioquality")) {
        // profile has a variable bitrate
        profileElement.setAttribute("defaultaudioquality", item->data(DefaultAudioBitrateRole).toString());
        profileElement.setAttribute("audioqualities", item->data(AudioBitratesRole).toStringList().join(","));
    }
642 643 644
    doc.appendChild(profileElement);
    saveProfile(doc.documentElement());
    parseProfiles(m_view.destination_list->itemData(m_view.destination_list->currentIndex(), Qt::UserRole).toString(), currentGroup, currentProfile);
645 646
}

647 648
void RenderWidget::slotEditProfile()
{
649 650 651 652 653 654 655 656 657
    QListWidgetItem *item = m_view.size_list->currentItem();
    if (!item) return;
    QString currentGroup = m_view.format_list->currentItem()->text();

    QString params = item->data(ParamsRole).toString();
    QString extension = item->data(ExtensionRole).toString();
    QString currentProfile = item->text();

    Ui::SaveProfile_UI ui;
658
    QPointer<QDialog> d = new QDialog(this);
659
    ui.setupUi(d);
660

661
    for (int i = 0; i < m_view.destination_list->count(); ++i)
662 663 664 665 666 667
        ui.destination_list->addItem(m_view.destination_list->itemIcon(i), m_view.destination_list->itemText(i), m_view.destination_list->itemData(i, Qt::UserRole));

    ui.destination_list->setCurrentIndex(m_view.destination_list->currentIndex());
    QString dest = ui.destination_list->itemData(ui.destination_list->currentIndex(), Qt::UserRole).toString();

    QString customGroup = m_view.format_list->currentItem()->text();
Yuri Chornoivan's avatar
Yuri Chornoivan committed
668
    if (customGroup.isEmpty()) customGroup = i18nc("Group Name", "Custom");
669 670
    ui.group_name->setText(customGroup);

671 672 673 674
    ui.profile_name->setText(currentProfile);
    ui.extension->setText(extension);
    ui.parameters->setText(params);
    ui.profile_name->setFocus();
675 676 677 678 679 680 681 682
    if (ui.parameters->toPlainText().contains("%bitrate") || ui.parameters->toPlainText().contains("%quality")) {
        if (ui.parameters->toPlainText().contains("%quality")) {
            ui.vbitrates_label->setText(i18n("Qualities"));
            ui.default_vbitrate_label->setText(i18n("Default quality"));
        } else {
            ui.vbitrates_label->setText(i18n("Bitrates"));
            ui.default_vbitrate_label->setText(i18n("Default bitrate"));
        }
683 684
        if ( item->data(BitratesRole).canConvert(QVariant::StringList) && item->data(BitratesRole).toStringList().count()) {
            QStringList bitrates = item->data(BitratesRole).toStringList();
685
            ui.vbitrates_list->setText(bitrates.join(","));
686 687 688
            if (item->data(DefaultBitrateRole).canConvert(QVariant::String))
                ui.default_vbitrate->setValue(item->data(DefaultBitrateRole).toInt());
        }
Laurent Montel's avatar
Laurent Montel committed
689 690
    } else {
        ui.vbitrates->setHidden(true);
691
    }
Laurent Montel's avatar
Laurent Montel committed
692

693 694 695 696 697 698 699 700 701
    if (ui.parameters->toPlainText().contains("%audiobitrate") || ui.parameters->toPlainText().contains("%audioquality")) {
        if (ui.parameters->toPlainText().contains("%audioquality")) {
            ui.abitrates_label->setText(i18n("Qualities"));
            ui.default_abitrate_label->setText(i18n("Default quality"));
        } else {
            ui.abitrates_label->setText(i18n("Bitrates"));
            ui.default_abitrate_label->setText(i18n("Default bitrate"));
        }
        if ( item->data(AudioBitratesRole).canConvert(QVariant::StringList) && item->data(AudioBitratesRole).toStringList().count()) {
702
            QStringList bitrates = item->data(AudioBitratesRole).toStringList();
703
            ui.abitrates_list->setText(bitrates.join(","));
704 705 706 707 708 709
            if (item->data(DefaultAudioBitrateRole).canConvert(QVariant::String))
                ui.default_abitrate->setValue(item->data(DefaultAudioBitrateRole).toInt());
        }
    }
    else ui.abitrates->setHidden(true);
    
710
    d->setWindowTitle(i18n("Edit Profile"));
711
    if (d->exec() == QDialog::Accepted) {
712
        slotDeleteProfile(false);
713
        QString exportFile = KStandardDirs::locateLocal("appdata", "export/customprofiles.xml");
714 715 716 717 718
        QDomDocument doc;
        QFile file(exportFile);
        doc.setContent(&file, false);
        file.close();
        QDomElement documentElement;
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733
        QDomElement profiles = doc.documentElement();

        if (profiles.isNull() || profiles.tagName() != "profiles") {
            doc.clear();
            profiles = doc.createElement("profiles");
            profiles.setAttribute("version", 1);
            doc.appendChild(profiles);
        }

        int version = profiles.attribute("version", 0).toInt();
        if (version < 1) {
            kDebug() << "// OLD profile version";
            doc.clear();
            profiles = doc.createElement("profiles");
            profiles.setAttribute("version", 1);
734
            doc.appendChild(profiles);
735 736 737 738
        }

        QString newProfileName = ui.profile_name->text().simplified();
        QString newGroupName = ui.group_name->text().simplified();
Yuri Chornoivan's avatar
Yuri Chornoivan committed
739
        if (newGroupName.isEmpty()) newGroupName = i18nc("Group Name", "Custom");
740 741 742 743 744 745 746 747 748 749
        QString newMetaGroupId = ui.destination_list->itemData(ui.destination_list->currentIndex(), Qt::UserRole).toString();
        QDomNodeList profilelist = doc.elementsByTagName("profile");
        int i = 0;
        while (!profilelist.item(i).isNull()) {
            // make sure a profile with same name doesn't exist
            documentElement = profilelist.item(i).toElement();
            QString profileName = documentElement.attribute("name");
            if (profileName == newProfileName) {
                // a profile with that same name already exists
                bool ok;
Vincent PINON's avatar
Vincent PINON committed
750
                newProfileName = QInputDialog::getText(this, i18n("Profile already exists"), i18n("This profile name already exists. Change the name if you don't want to overwrite it."), KLineEdit::Normal, newProfileName, &ok);
751 752 753
                if (!ok) return;
                if (profileName == newProfileName) {
                    profiles.removeChild(profilelist.item(i));
754 755 756
                    break;
                }
            }
757
            ++i;
758
        }
759

760 761
        QDomElement profileElement = doc.createElement("profile");
        profileElement.setAttribute("name", newProfileName);
762 763
        profileElement.setAttribute("category", newGroupName);
        profileElement.setAttribute("destinationid", newMetaGroupId);
764
        profileElement.setAttribute("extension", ui.extension->text().simplified());
765 766
        QString args = ui.parameters->toPlainText().simplified();
        profileElement.setAttribute("args", args);
767
        if (args.contains("%bitrate")) {
768
            // profile has a variable bitrate
769
            profileElement.setAttribute("defaultbitrate", QString::number(ui.default_vbitrate->value()));
770
            profileElement.setAttribute("bitrates", ui.vbitrates_list->text());
771 772 773
        } else if(args.contains("%quality")) {
            profileElement.setAttribute("defaultquality", QString::number(ui.default_vbitrate->value()));
            profileElement.setAttribute("qualities", ui.vbitrates_list->text());
774
        }
775
        if (args.contains("%audiobitrate")) {
776
            // profile has a variable bitrate
777
            profileElement.setAttribute("defaultaudiobitrate", QString::number(ui.default_abitrate->value()));
778
            profileElement.setAttribute("audiobitrates", ui.abitrates_list->text());
779 780 781
        } else if (args.contains("%audioquality")) {
            profileElement.setAttribute("defaultaudioquality", QString::number(ui.default_abitrate->value()));
            profileElement.setAttribute("audioqualities", ui.abitrates_list->text());
782 783
        }

784
        profiles.appendChild(profileElement);
785 786

        //QCString save = doc.toString().utf8();
787
        delete d;
788
        if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
789
            KMessageBox::error(this, i18n("Cannot write to file %1", exportFile));
790 791 792 793
            return;
        }
        QTextStream out(&file);
        out << doc.toString();
794 795 796 797 798
        if (file.error() != QFile::NoError) {
            KMessageBox::error(this, i18n("Cannot write to file %1", exportFile));
            file.close();
            return;
        }
799
        file.close();
800
        parseProfiles(newMetaGroupId, newGroupName, newProfileName);
801
    } else delete d;
802 803
}

804 805
void RenderWidget::slotDeleteProfile(bool refresh)
{
806 807 808
    //TODO: delete a profile installed by KNewStuff the easy way
    /*
    QString edit = m_view.size_list->currentItem()->data(EditableRole).toString();
809
    if (!edit.endsWith(QLatin1String("customprofiles.xml"))) {
810
        // This is a KNewStuff installed file, process through KNS
811 812 813 814 815 816
        KNS::Engine engine(0);
        if (engine.init("kdenlive_render.knsrc")) {
            KNS::Entry::List entries;
        }
        return;
    }*/
817 818
    QString currentGroup = m_view.format_list->currentItem()->text();
    QString currentProfile = m_view.size_list->currentItem()->text();
819
    QString metaGroupId = m_view.destination_list->itemData(m_view.destination_list->currentIndex(), Qt::UserRole).toString();
820

821
    QString exportFile = KStandardDirs::locateLocal("appdata", "export/customprofiles.xml");
822 823 824 825 826 827
    QDomDocument doc;
    QFile file(exportFile);
    doc.setContent(&file, false);
    file.close();

    QDomElement documentElement;
828
    QDomNodeList profiles = doc.elementsByTagName("profile");
829
    int i = 0;
830 831 832
    QString groupName;
    QString profileName;
    QString destination;
833

834 835 836 837 838 839 840 841 842
    while (!profiles.item(i).isNull()) {
        documentElement = profiles.item(i).toElement();
        profileName = documentElement.attribute("name");
        groupName = documentElement.attribute("category");
        destination = documentElement.attribute("destinationid");

        if (profileName == currentProfile && groupName == currentGroup && destination == metaGroupId) {
            kDebug() << "// GOT it: " << profileName;
            doc.documentElement().removeChild(profiles.item(i));
843 844
            break;
        }
845
        ++i;
846 847 848 849 850 851 852 853
    }

    if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
        KMessageBox::sorry(this, i18n("Unable to write to file %1", exportFile));
        return;
    }
    QTextStream out(&file);
    out << doc.toString();
854 855 856 857 858
    if (file.error() != QFile::NoError) {
        KMessageBox::error(this, i18n("Cannot write to file %1", exportFile));
        file.close();
        return;
    }
859
    file.close();
860 861 862 863
    if (refresh) {
        parseProfiles(metaGroupId, currentGroup);
        focusFirstVisibleItem();
    }
864 865
}

866 867
void RenderWidget::updateButtons()
{
868 869 870 871
    if (!m_view.size_list->currentItem() || m_view.size_list->currentItem()->isHidden()) {
        m_view.buttonSave->setEnabled(false);
        m_view.buttonDelete->setEnabled(false);
        m_view.buttonEdit->setEnabled(false);
872 873
        m_view.buttonRender->setEnabled(false);
        m_view.buttonGenerateScript->setEnabled(false);
874 875
    } else {
        m_view.buttonSave->setEnabled(true);
876 877
        m_view.buttonRender->setEnabled(m_view.size_list->currentItem()->toolTip().isEmpty());
        m_view.buttonGenerateScript->setEnabled(m_view.size_list->currentItem()->toolTip().isEmpty());
878
        QString edit = m_view.size_list->currentItem()->data(EditableRole).toString();
879
        if (edit.isEmpty() || !edit.endsWith(QLatin1String("customprofiles.xml"))) {
880 881 882
            m_view.buttonDelete->setEnabled(false);
            m_view.buttonEdit->setEnabled(false);
        } else {
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
883 884
            m_view.buttonDelete->setEnabled(true);
            m_view.buttonEdit->setEnabled(true);
885 886 887 888 889
        }
    }
}


890
void RenderWidget::focusFirstVisibleItem(const QString &profile)
891
{
892
    if (!profile.isEmpty()) {
Laurent Montel's avatar
Laurent Montel committed
893 894 895
        QList <QListWidgetItem *> child = m_view.size_list->findItems(profile, Qt::MatchExactly);
        if (!child.isEmpty())
            m_view.size_list->setCurrentItem(child.at(0));
896
    }
897
    if (m_view.size_list->currentItem()) {
898 899 900
        updateButtons();
        return;
    }
901
    m_view.size_list->setCurrentRow(0);
902
    updateButtons();
903 904
}

905 906 907 908 909 910
void RenderWidget::slotPrepareExport(bool scriptExport)
{
    if (!QFile::exists(KdenliveSettings::rendererpath())) {
        KMessageBox::sorry(this, i18n("Cannot find the melt program required for rendering (part of Mlt)"));
        return;
    }
Simon Eugster's avatar
Simon Eugster committed
911
    if (m_view.play_after->isChecked() && KdenliveSettings::defaultplayerapp().isEmpty()) {
912
        KMessageBox::sorry(this, i18n("Cannot play video after rendering because the default video player application is not set.\nPlease define it in Kdenlive settings dialog."));
Simon Eugster's avatar
Simon Eugster committed
913
    }
914 915
    QString chapterFile;
    if (m_view.create_chapter->isChecked()) chapterFile = m_view.out_file->url().path() + ".dvdchapter";
Simon Eugster's avatar
Simon Eugster committed
916 917

    // mantisbt 1051
918 919
    if (!KStandardDirs::makeDir(m_view.out_file->url().adjusted(QUrl::RemoveFilename).path())) {
        KMessageBox::sorry(this, i18n("The directory %1, could not be created.\nPlease make sure you have the required permissions.", m_view.out_file->url().adjusted(QUrl::RemoveFilename).path()));
920 921
        return;
    }
Simon Eugster's avatar
Simon Eugster committed
922

923 924 925 926
    emit prepareRenderingData(scriptExport, m_view.render_zone->isChecked(), chapterFile);
}


927
void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const QMap<QString, QString> &metadata, const QString &playlistPath, const QString &scriptPath, bool exportAudio)
928
{
929
    QListWidgetItem *item = m_view.size_list->currentItem();
Laurent Montel's avatar
Laurent Montel committed
930 931
    if (!item)
        return;
932

933
    QString dest = m_view.out_file->url().path().trimmed();
Laurent Montel's avatar
Laurent Montel committed
934 935
    if (dest.isEmpty())
        return;
936 937 938 939

    // Check whether target file has an extension.
    // If not, ask whether extension should be added or not.
    QString extension = item->data(ExtensionRole).toString();
940
    if (!dest.endsWith(extension, Qt::CaseInsensitive)) {
941
        if (KMessageBox::questionYesNo(this, i18n("File has no extension. Add extension (%1)?", extension)) == KMessageBox::Yes) {
942
            dest.append('.' + extension);
943 944
        }
    }
945 946 947 948 949 950 951
    // Checks for image sequence
    if (extension == "jpg" || extension == "png") {
        // format string for counter?
        if(!QRegExp(".*%[0-9]*d.*").exactMatch(dest)) {
            dest = dest.section('.',0,-2) + "_%05d." + extension;
        }
    }
952

953
    QFile f(dest);
954
    if (f.exists()) {
955
        if (KMessageBox::warningYesNo(this, i18n("Output file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
956 957
            return;
    }
958

959 960 961
    QStringList overlayargs;
    if (m_view.tc_overlay->isChecked()) {
        QString filterFile = KStandardDirs::locate("appdata", "metadata.properties");
962
        overlayargs << "meta.attr.timecode=1" << "meta.attr.timecode.markup=#" + QString(m_view.tc_type->currentIndex() ? "frame" : "timecode");
963
        overlayargs << "-attach" << "data_feed:attr_check" << "-attach";
964
        overlayargs << "data_show:" + filterFile << "_loader=1" << "dynamic=1";
965
    }
966 967 968 969 970 971

    QStringList render_process_args;

    if (!scriptExport) render_process_args << "-erase";
    if (KdenliveSettings::usekuiserver()) render_process_args << "-kuiserver";

972 973 974
    // get process id
    render_process_args << QString("-pid:%1").arg(QCoreApplication::applicationPid());

975 976
    // Set locale for render process if required
    if (QLocale().decimalPoint() != QLocale::system().decimalPoint()) {