1 /***************************************************************************
2 * Copyright (C) 2007 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 "kdenlivesettings.h"
22 #include "profilesdialog.h"
23 #include "v4l/v4lcapture.h"
24 #include "kdenlive-config.h"
26 #include <KStandardDirs>
29 #include <kmimetype.h>
32 #include <KMimeTypeTrader>
36 #include <QXmlStreamWriter>
39 const double recommendedMltVersion = 510;
40 static const char kdenlive_version[] = VERSION;
42 Wizard::Wizard(bool upgrade, QWidget *parent) :
45 setWindowTitle(i18n("Config Wizard"));
46 setPixmap(QWizard::WatermarkPixmap, QPixmap(KStandardDirs::locate("appdata", "banner.png")));
48 QWizardPage *page1 = new QWizardPage;
49 page1->setTitle(i18n("Welcome"));
52 label = new QLabel(i18n("Your Kdenlive version was upgraded to version %1. Please take some time to review the basic settings", QString(kdenlive_version).section(' ', 0, 0)));
54 label = new QLabel(i18n("This is the first time you run Kdenlive. This wizard will let you adjust some basic settings, you will be ready to edit your first movie in a few seconds..."));
55 label->setWordWrap(true);
56 m_startLayout = new QVBoxLayout;
57 m_startLayout->addWidget(label);
58 QPushButton *but = new QPushButton(KIcon("help-about"), i18n("Discover the features of this Kdenlive release"), this);
59 connect(but, SIGNAL(clicked()), this, SLOT(slotShowWebInfos()));
60 m_startLayout->addStretch();
61 m_startLayout->addWidget(but);
64 page1->setLayout(m_startLayout);
67 QWizardPage *page4 = new QWizardPage;
68 page4->setTitle(i18n("Checking MLT engine"));
69 m_mltCheck.setupUi(page4);
72 WizardDelegate *listViewDelegate = new WizardDelegate(m_mltCheck.programList);
73 m_mltCheck.programList->setItemDelegate(listViewDelegate);
75 QWizardPage *page2 = new QWizardPage;
76 page2->setTitle(i18n("Video Standard"));
77 m_standard.setupUi(page2);
79 m_okIcon = KIcon("dialog-ok");
80 m_badIcon = KIcon("dialog-close");
82 // build profiles lists
83 QMap<QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
84 QMap<QString, QString>::const_iterator i = profilesInfo.constBegin();
85 while (i != profilesInfo.constEnd()) {
86 QMap< QString, QString > profileData = ProfilesDialog::getSettingsFromFile(i.value());
87 if (profileData.value("width") == "720") m_dvProfiles.insert(i.key(), i.value());
88 else if (profileData.value("width").toInt() >= 1080) m_hdvProfiles.insert(i.key(), i.value());
89 else m_otherProfiles.insert(i.key(), i.value());
93 m_standard.button_all->setChecked(true);
94 connect(m_standard.button_all, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
95 connect(m_standard.button_hdv, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
96 connect(m_standard.button_dv, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
98 connect(m_standard.profiles_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckSelectedItem()));
100 // select default profile
101 if (!KdenliveSettings::default_profile().isEmpty()) {
102 for (int i = 0; i < m_standard.profiles_list->count(); i++) {
103 if (m_standard.profiles_list->item(i)->data(Qt::UserRole).toString() == KdenliveSettings::default_profile()) {
104 m_standard.profiles_list->setCurrentRow(i);
105 m_standard.profiles_list->scrollToItem(m_standard.profiles_list->currentItem());
113 QWizardPage *page3 = new QWizardPage;
114 page3->setTitle(i18n("Additional Settings"));
115 m_extra.setupUi(page3);
116 m_extra.projectfolder->setMode(KFile::Directory);
117 m_extra.projectfolder->setUrl(KUrl(KdenliveSettings::defaultprojectfolder()));
118 m_extra.videothumbs->setChecked(KdenliveSettings::videothumbnails());
119 m_extra.audiothumbs->setChecked(KdenliveSettings::audiothumbnails());
120 m_extra.autosave->setChecked(KdenliveSettings::crashrecovery());
121 connect(m_extra.videothumbs, SIGNAL(stateChanged(int)), this, SLOT(slotCheckThumbs()));
122 connect(m_extra.audiothumbs, SIGNAL(stateChanged(int)), this, SLOT(slotCheckThumbs()));
127 QWizardPage *page6 = new QWizardPage;
128 page6->setTitle(i18n("Webcam"));
129 m_capture.setupUi(page6);
130 connect(m_capture.button_reload, SIGNAL(clicked()), this, SLOT(slotDetectWebcam()));
131 connect(m_capture.v4l_devices, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateCaptureParameters()));
132 connect(m_capture.v4l_formats, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSaveCaptureFormat()));
133 m_capture.button_reload->setIcon(KIcon("view-refresh"));
138 QWizardPage *page5 = new QWizardPage;
139 page5->setTitle(i18n("Checking system"));
140 m_check.setupUi(page5);
143 listViewDelegate = new WizardDelegate(m_check.programList);
144 m_check.programList->setItemDelegate(listViewDelegate);
146 QTimer::singleShot(500, this, SLOT(slotCheckMlt()));
149 void Wizard::slotDetectWebcam()
151 #if !defined(Q_WS_MAC) && !defined(Q_OS_FREEBSD)
152 m_capture.v4l_devices->blockSignals(true);
153 m_capture.v4l_devices->clear();
155 // Video 4 Linux device detection
156 for (int i = 0; i < 10; i++) {
157 QString path = "/dev/video" + QString::number(i);
158 if (QFile::exists(path)) {
159 QStringList deviceInfo = V4lCaptureHandler::getDeviceName(path.toUtf8().constData());
160 if (!deviceInfo.isEmpty()) {
161 m_capture.v4l_devices->addItem(deviceInfo.at(0), path);
162 m_capture.v4l_devices->setItemData(m_capture.v4l_devices->count() - 1, deviceInfo.at(1), Qt::UserRole + 1);
166 if (m_capture.v4l_devices->count() > 0) {
167 m_capture.v4l_status->setText(i18n("Select your default video4linux device"));
168 // select default device
170 for (int i = 0; i < m_capture.v4l_devices->count(); i++) {
171 QString device = m_capture.v4l_devices->itemData(i).toString();
172 if (device == KdenliveSettings::video4vdevice()) {
173 m_capture.v4l_devices->setCurrentIndex(i);
178 slotUpdateCaptureParameters();
179 if (!found) m_capture.v4l_devices->setCurrentIndex(0);
180 } else m_capture.v4l_status->setText(i18n("No device found, plug your webcam and refresh."));
181 m_capture.v4l_devices->blockSignals(false);
185 void Wizard::slotUpdateCaptureParameters()
187 QString device = m_capture.v4l_devices->itemData(m_capture.v4l_devices->currentIndex()).toString();
188 if (!device.isEmpty()) KdenliveSettings::setVideo4vdevice(device);
190 QString formats = m_capture.v4l_devices->itemData(m_capture.v4l_devices->currentIndex(), Qt::UserRole + 1).toString();
192 m_capture.v4l_formats->blockSignals(true);
193 m_capture.v4l_formats->clear();
195 QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
196 if (QFile::exists(vl4ProfilePath)) {
197 MltVideoProfile profileInfo = ProfilesDialog::getVideoProfile(vl4ProfilePath);
198 m_capture.v4l_formats->addItem(i18n("Current settings (%1x%2, %3/%4fps)", profileInfo.width, profileInfo.height, profileInfo.frame_rate_num, profileInfo.frame_rate_den), QStringList() << QString("unknown") <<QString::number(profileInfo.width)<<QString::number(profileInfo.height)<<QString::number(profileInfo.frame_rate_num)<<QString::number(profileInfo.frame_rate_den));
200 QStringList pixelformats = formats.split(">", QString::SkipEmptyParts);
203 QStringList itemRates;
204 for (int i = 0; i < pixelformats.count(); i++) {
205 QString format = pixelformats.at(i).section(':', 0, 0);
206 QStringList sizes = pixelformats.at(i).split(":", QString::SkipEmptyParts);
207 pixelFormat = sizes.takeFirst();
208 for (int j = 0; j < sizes.count(); j++) {
209 itemSize = sizes.at(j).section("=", 0, 0);
210 itemRates = sizes.at(j).section("=", 1, 1).split(",", QString::SkipEmptyParts);
211 for (int k = 0; k < itemRates.count(); k++) {
212 m_capture.v4l_formats->addItem("[" + format + "] " + itemSize + " (" + itemRates.at(k) + ")", QStringList() << format << itemSize.section('x', 0, 0) << itemSize.section('x', 1, 1) << itemRates.at(k).section('/', 0, 0) << itemRates.at(k).section('/', 1, 1));
216 if (!QFile::exists(vl4ProfilePath)) {
217 if (m_capture.v4l_formats->count() > 9) slotSaveCaptureFormat();
219 // No existing profile and no autodetected profiles
220 MltVideoProfile profileInfo;
221 profileInfo.width = 320;
222 profileInfo.height = 200;
223 profileInfo.frame_rate_num = 15;
224 profileInfo.frame_rate_den = 1;
225 profileInfo.display_aspect_num = 4;
226 profileInfo.display_aspect_den = 3;
227 profileInfo.sample_aspect_num = 1;
228 profileInfo.sample_aspect_den = 1;
229 profileInfo.progressive = 1;
230 profileInfo.colorspace = 601;
231 ProfilesDialog::saveProfile(profileInfo, vl4ProfilePath);
232 m_capture.v4l_formats->addItem(i18n("Default settings (%1x%2, %3/%4fps)", profileInfo.width, profileInfo.height, profileInfo.frame_rate_num, profileInfo.frame_rate_den), QStringList() << QString("unknown") <<QString::number(profileInfo.width)<<QString::number(profileInfo.height)<<QString::number(profileInfo.frame_rate_num)<<QString::number(profileInfo.frame_rate_den));
235 m_capture.v4l_formats->blockSignals(false);
238 void Wizard::checkMltComponents()
240 QSize itemSize(20, fontMetrics().height() * 2.5);
241 m_mltCheck.programList->setColumnWidth(0, 30);
242 m_mltCheck.programList->setIconSize(QSize(24, 24));
245 QTreeWidgetItem *mltitem = new QTreeWidgetItem(m_mltCheck.programList);
247 QTreeWidgetItem *meltitem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Melt") + " (" + KdenliveSettings::rendererpath() + ')');
248 meltitem->setData(1, Qt::UserRole, i18n("Required for rendering (part of MLT package)"));
249 meltitem->setSizeHint(0, itemSize);
250 meltitem->setIcon(0, m_okIcon);
252 // Check MLT's installed producers
253 QProcess checkProcess;
254 checkProcess.start(KdenliveSettings::rendererpath(), QStringList() << "-query" << "producer");
255 if (!checkProcess.waitForStarted()) {
256 meltitem->setIcon(0, m_badIcon);
257 meltitem->setData(1, Qt::UserRole, i18n("Error starting MLT's command line player (melt)"));
258 button(QWizard::NextButton)->setEnabled(false);
260 checkProcess.waitForFinished();
261 QByteArray result = checkProcess.readAllStandardError();
263 // Check MLT avformat module
264 QTreeWidgetItem *avformatItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Avformat module (FFmpeg)"));
265 avformatItem->setData(1, Qt::UserRole, i18n("Required to work with various video formats (hdv, mpeg, flash, ...)"));
266 avformatItem->setSizeHint(0, itemSize);
267 if (!result.contains("- avformat")) {
268 avformatItem->setIcon(0, m_badIcon);
269 m_mltCheck.tabWidget->setTabEnabled(1, false);
271 avformatItem->setIcon(0, m_okIcon);
272 // Make sure we have MLT > 0.3.4
275 QString exepath = KStandardDirs::findExe("pkg-config");
276 if (!exepath.isEmpty()) {
277 checkProcess.start(exepath, QStringList() << "--variable=version" << "mlt++");
278 if (!checkProcess.waitForStarted()) {
279 kDebug() << "// Error querying MLT's version";
281 checkProcess.waitForFinished();
282 mltVersion = checkProcess.readAllStandardOutput();
283 version = 1000 * mltVersion.section('.', 0, 0).toInt() + 100 * mltVersion.section('.', 1, 1).toInt() + mltVersion.section('.', 2, 2).toInt();
284 kDebug() << "// FOUND MLT's pkgconfig version: " << version;
288 checkProcess.start(KdenliveSettings::rendererpath(), QStringList() << "--version");
289 if (!checkProcess.waitForStarted()) {
290 kDebug() << "// Error querying MLT's version";
292 checkProcess.waitForFinished();
293 mltVersion = checkProcess.readAllStandardError();
294 mltVersion = mltVersion.section('\n', 0, 0).simplified();
295 mltVersion = mltVersion.section(' ', -1).simplified();
296 version = 1000 * mltVersion.section('.', 0, 0).toInt() + 100 * mltVersion.section('.', 1, 1).toInt() + mltVersion.section('.', 2, 2).toInt();
297 kDebug() << "// FOUND MLT version: " << version;
301 mltitem->setText(1, i18n("MLT version: %1", mltVersion.simplified()));
302 mltitem->setSizeHint(0, itemSize);
304 mltitem->setData(1, Qt::UserRole, i18n("Your MLT version is unsupported!!!"));
305 mltitem->setIcon(0, m_badIcon);
307 if (version < recommendedMltVersion) {
308 mltitem->setData(1, Qt::UserRole, i18n("Please upgrade to the latest MLT version"));
309 mltitem->setIcon(0, m_badIcon);
311 mltitem->setData(1, Qt::UserRole, i18n("MLT version is correct"));
312 mltitem->setIcon(0, m_okIcon);
314 // Check installed audio codecs
315 QProcess checkProcess2;
316 checkProcess2.start(KdenliveSettings::rendererpath(), QStringList() << "noise:" << "-consumer" << "avformat" << "acodec=list");
317 if (!checkProcess2.waitForStarted()) {
318 m_mltCheck.tabWidget->setTabEnabled(1, false);
319 kDebug() << "// Error parsing MLT's avformat codecs";
321 checkProcess2.waitForFinished();
322 QByteArray codecList = checkProcess2.readAllStandardError();
323 QString acodecList(codecList);
325 QStringList alist = acodecList.split('\n', QString::SkipEmptyParts);
326 for (int i = 0; i < alist.count(); i++) {
327 if (alist.at(i).contains("- ")) result.append(alist.at(i).section("- ", 1).simplified().toLower());
329 m_mltCheck.acodecs_list->addItems(result);
330 KdenliveSettings::setAudiocodecs(result);
331 //kDebug()<<"// FOUND LIST:\n\n"<<m_audioCodecs<<"\n\n++++++++++++++++++++";
333 // Check video codecs
334 checkProcess2.start(KdenliveSettings::rendererpath(), QStringList() << "noise:" << "-consumer" << "avformat" << "vcodec=list");
335 if (!checkProcess2.waitForStarted()) {
336 kDebug() << "// Error parsing MLT's avformat codecs";
338 checkProcess2.waitForFinished();
339 QByteArray codecList = checkProcess2.readAllStandardError();
340 QString vcodecList(codecList);
342 QStringList vlist = vcodecList.split('\n', QString::SkipEmptyParts);
343 for (int i = 0; i < vlist.count(); i++) {
344 if (vlist.at(i).contains("- ")) result.append(vlist.at(i).section("- ", 1).simplified().toLower());
346 m_mltCheck.vcodecs_list->addItems(result);
347 KdenliveSettings::setVideocodecs(result);
348 //kDebug()<<"// FOUND LIST:\n\n"<<m_videoCodecs<<"\n\n++++++++++++++++++++";
351 checkProcess2.start(KdenliveSettings::rendererpath(), QStringList() << "noise:" << "-consumer" << "avformat" << "f=list");
352 if (!checkProcess2.waitForStarted()) {
353 kDebug() << "// Error parsing MLT's avformat codecs";
355 checkProcess2.waitForFinished();
356 QByteArray codecList = checkProcess2.readAllStandardError();
357 QString vcodecList(codecList);
359 QStringList vlist = vcodecList.split('\n', QString::SkipEmptyParts);
360 for (int i = 0; i < vlist.count(); i++) {
361 if (vlist.at(i).contains("- ")) {
362 QString format = vlist.at(i).section("- ", 1).simplified().toLower();
363 if (format.contains(',')) {
364 QStringList sub = format.split(',', QString::SkipEmptyParts);
365 for (int j = 0; j < sub.count(); j++)
366 result.append(sub.at(j));
367 } else result.append(format);
370 m_mltCheck.formats_list->addItems(result);
371 KdenliveSettings::setSupportedformats(result);
372 //kDebug()<<"// FOUND LIST:\n\n"<<m_videoCodecs<<"\n\n++++++++++++++++++++";
378 // Check MLT dv module
379 QTreeWidgetItem *dvItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("DV module (libdv)"));
380 dvItem->setData(1, Qt::UserRole, i18n("Required to work with dv files if avformat module is not installed"));
381 dvItem->setSizeHint(0, itemSize);
382 if (!result.contains("- libdv")) {
383 dvItem->setIcon(0, m_badIcon);
385 dvItem->setIcon(0, m_okIcon);
388 // Check MLT image format module
389 QTreeWidgetItem *imageItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("QImage module"));
390 imageItem->setData(1, Qt::UserRole, i18n("Required to work with images"));
391 imageItem->setSizeHint(0, itemSize);
392 if (!result.contains("- qimage")) {
393 imageItem->setIcon(0, m_badIcon);
394 imageItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Pixbuf module"));
395 imageItem->setData(1, Qt::UserRole, i18n("Required to work with images"));
396 imageItem->setSizeHint(0, itemSize);
397 if (!result.contains("- pixbuf")) imageItem->setIcon(0, m_badIcon);
398 else imageItem->setIcon(0, m_okIcon);
400 imageItem->setIcon(0, m_okIcon);
403 // Check MLT title module
404 QTreeWidgetItem *titleItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Title module"));
405 titleItem->setData(1, Qt::UserRole, i18n("Required to work with titles"));
406 titleItem->setSizeHint(0, itemSize);
407 if (!result.contains("- kdenlivetitle")) {
408 KdenliveSettings::setHastitleproducer(false);
409 titleItem->setIcon(0, m_badIcon);
411 titleItem->setIcon(0, m_okIcon);
412 KdenliveSettings::setHastitleproducer(true);
417 void Wizard::slotCheckPrograms()
419 QSize itemSize(20, fontMetrics().height() * 2.5);
420 m_check.programList->setColumnWidth(0, 30);
421 m_check.programList->setIconSize(QSize(24, 24));
423 QTreeWidgetItem *item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("FFmpeg & ffplay"));
424 item->setData(1, Qt::UserRole, i18n("Required for webcam capture"));
425 item->setSizeHint(0, itemSize);
426 QString exepath = KStandardDirs::findExe("ffmpeg");
427 if (exepath.isEmpty()) item->setIcon(0, m_badIcon);
428 else if (KStandardDirs::findExe("ffplay").isEmpty()) item->setIcon(0, m_badIcon);
429 else item->setIcon(0, m_okIcon);
432 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("recordmydesktop"));
433 item->setData(1, Qt::UserRole, i18n("Required for screen capture"));
434 item->setSizeHint(0, itemSize);
435 if (KStandardDirs::findExe("recordmydesktop").isEmpty()) item->setIcon(0, m_badIcon);
436 else item->setIcon(0, m_okIcon);
438 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("dvgrab"));
439 item->setData(1, Qt::UserRole, i18n("Required for firewire capture"));
440 item->setSizeHint(0, itemSize);
441 if (KStandardDirs::findExe("dvgrab").isEmpty()) item->setIcon(0, m_badIcon);
442 else item->setIcon(0, m_okIcon);
445 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("dvdauthor"));
446 item->setData(1, Qt::UserRole, i18n("Required for creation of DVD"));
447 item->setSizeHint(0, itemSize);
448 if (KStandardDirs::findExe("dvdauthor").isEmpty()) item->setIcon(0, m_badIcon);
449 else item->setIcon(0, m_okIcon);
452 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("genisoimage or mkisofs"));
453 item->setData(1, Qt::UserRole, i18n("Required for creation of DVD ISO images"));
454 item->setSizeHint(0, itemSize);
455 if (KStandardDirs::findExe("genisoimage").isEmpty()) {
456 // no GenIso, check for mkisofs
457 if (!KStandardDirs::findExe("mkisofs").isEmpty()) {
458 item->setIcon(0, m_okIcon);
459 } else item->setIcon(0, m_badIcon);
460 } else item->setIcon(0, m_okIcon);
462 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("xine"));
463 item->setData(1, Qt::UserRole, i18n("Required to preview your DVD"));
464 item->setSizeHint(0, itemSize);
465 if (KStandardDirs::findExe("xine").isEmpty()) item->setIcon(0, m_badIcon);
466 else item->setIcon(0, m_okIcon);
468 // set up some default applications
470 if (KdenliveSettings::defaultimageapp().isEmpty()) {
471 program = KStandardDirs::findExe("gimp");
472 if (program.isEmpty()) program = KStandardDirs::findExe("krita");
473 if (!program.isEmpty()) KdenliveSettings::setDefaultimageapp(program);
475 if (KdenliveSettings::defaultaudioapp().isEmpty()) {
476 program = KStandardDirs::findExe("audacity");
477 if (program.isEmpty()) program = KStandardDirs::findExe("traverso");
478 if (!program.isEmpty()) KdenliveSettings::setDefaultaudioapp(program);
480 if (KdenliveSettings::defaultplayerapp().isEmpty()) {
481 KService::Ptr offer = KMimeTypeTrader::self()->preferredService("video/mpeg");
483 KdenliveSettings::setDefaultplayerapp(KRun::binaryName(offer->exec(), true));
487 void Wizard::installExtraMimes(QString baseName, QStringList globs)
489 QString mimefile = baseName;
490 mimefile.replace('/', '-');
491 KMimeType::Ptr mime = KMimeType::mimeType(baseName);
493 kDebug() << "KMimeTypeTrader: mimeType " << baseName << " not found";
495 QStringList extensions = mime->patterns();
496 QString comment = mime->comment();
497 foreach(const QString & glob, globs) {
498 if (!extensions.contains(glob)) extensions << glob;
500 kDebug() << "EXTS: " << extensions;
501 QString packageFileName = KStandardDirs::locateLocal("xdgdata-mime", "packages/" + mimefile + ".xml");
502 kDebug() << "INSTALLING NEW MIME TO: " << packageFileName;
503 QFile packageFile(packageFileName);
504 if (!packageFile.open(QIODevice::WriteOnly)) {
505 kError() << "Couldn't open" << packageFileName << "for writing";
508 QXmlStreamWriter writer(&packageFile);
509 writer.setAutoFormatting(true);
510 writer.writeStartDocument();
512 const QString nsUri = "http://www.freedesktop.org/standards/shared-mime-info";
513 writer.writeDefaultNamespace(nsUri);
514 writer.writeStartElement("mime-info");
515 writer.writeStartElement(nsUri, "mime-type");
516 writer.writeAttribute("type", baseName);
518 if (!comment.isEmpty()) {
519 writer.writeStartElement(nsUri, "comment");
520 writer.writeCharacters(comment);
521 writer.writeEndElement(); // comment
524 foreach(const QString & pattern, extensions) {
525 writer.writeStartElement(nsUri, "glob");
526 writer.writeAttribute("pattern", pattern);
527 writer.writeEndElement(); // glob
530 writer.writeEndElement(); // mime-info
531 writer.writeEndElement(); // mime-type
532 writer.writeEndDocument();
536 void Wizard::runUpdateMimeDatabase()
538 const QString localPackageDir = KStandardDirs::locateLocal("xdgdata-mime", QString());
539 //Q_ASSERT(!localPackageDir.isEmpty());
541 proc << "update-mime-database";
542 proc << localPackageDir;
543 const int exitCode = proc.execute();
545 kWarning() << proc.program() << "exited with error code" << exitCode;
549 void Wizard::slotCheckThumbs()
551 QString pixname = "timeline_vthumbs.png";
552 if (!m_extra.audiothumbs->isChecked() && !m_extra.videothumbs->isChecked()) {
553 pixname = "timeline_nothumbs.png";
554 } else if (m_extra.audiothumbs->isChecked()) {
555 if (m_extra.videothumbs->isChecked())
556 pixname = "timeline_avthumbs.png";
557 else pixname = "timeline_athumbs.png";
560 m_extra.timeline_preview->setPixmap(QPixmap(KStandardDirs::locate("appdata", pixname)));
563 void Wizard::slotCheckStandard()
565 m_standard.profiles_list->clear();
566 QStringList profiles;
567 if (!m_standard.button_hdv->isChecked()) {
569 QMapIterator<QString, QString> i(m_dvProfiles);
570 while (i.hasNext()) {
572 QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
573 item->setData(Qt::UserRole, i.value());
576 if (!m_standard.button_dv->isChecked()) {
578 QMapIterator<QString, QString> i(m_hdvProfiles);
579 while (i.hasNext()) {
581 QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
582 item->setData(Qt::UserRole, i.value());
585 if (m_standard.button_all->isChecked()) {
586 QMapIterator<QString, QString> i(m_otherProfiles);
587 while (i.hasNext()) {
589 QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
590 item->setData(Qt::UserRole, i.value());
592 //m_standard.profiles_list->sortItems();
595 for (int i = 0; i < m_standard.profiles_list->count(); i++) {
596 QListWidgetItem *item = m_standard.profiles_list->item(i);
598 QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(item->data(Qt::UserRole).toString());
599 const QString infoString = ("<strong>" + i18n("Frame size:") + " </strong>%1x%2<br /><strong>" + i18n("Frame rate:") + " </strong>%3/%4<br /><strong>" + i18n("Pixel aspect ratio:") + "</strong>%5/%6<br /><strong>" + i18n("Display aspect ratio:") + " </strong>%7/%8").arg(values.value("width"), values.value("height"), values.value("frame_rate_num"), values.value("frame_rate_den"), values.value("sample_aspect_num"), values.value("sample_aspect_den"), values.value("display_aspect_num"), values.value("display_aspect_den"));
600 item->setToolTip(infoString);
603 m_standard.profiles_list->setSortingEnabled(true);
604 m_standard.profiles_list->setCurrentRow(0);
607 void Wizard::slotCheckSelectedItem()
609 // Make sure we always have an item highlighted
610 m_standard.profiles_list->setCurrentRow(m_standard.profiles_list->currentRow());
614 void Wizard::adjustSettings()
616 if (m_extra.installmimes->isChecked()) {
618 globs << "*.mts" << "*.m2t" << "*.mod" << "*.ts" << "*.m2ts";
619 installExtraMimes("video/mpeg", globs);
622 installExtraMimes("video/dv", globs);
623 runUpdateMimeDatabase();
625 KdenliveSettings::setAudiothumbnails(m_extra.audiothumbs->isChecked());
626 KdenliveSettings::setVideothumbnails(m_extra.videothumbs->isChecked());
627 KdenliveSettings::setCrashrecovery(m_extra.autosave->isChecked());
628 if (m_standard.profiles_list->currentItem()) {
629 QString selectedProfile = m_standard.profiles_list->currentItem()->data(Qt::UserRole).toString();
630 if (selectedProfile.isEmpty()) selectedProfile = "dv_pal";
631 KdenliveSettings::setDefault_profile(selectedProfile);
633 QString path = m_extra.projectfolder->url().path();
634 if (KStandardDirs::makeDir(path) == false) {
635 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
636 } else KdenliveSettings::setDefaultprojectfolder(path);
640 void Wizard::slotCheckMlt()
642 QString errorMessage;
643 if (KdenliveSettings::rendererpath().isEmpty()) {
644 errorMessage.append(i18n("Your MLT installation cannot be found. Install MLT and restart Kdenlive.\n"));
646 /*QProcess checkProcess;
647 checkProcess.start(KdenliveSettings::rendererpath(), QStringList() << "-query" << "producer");
648 if (!checkProcess.waitForStarted())
649 errorMessage.append(i18n("Error starting MLT's command line player (melt)") + ".\n");
651 checkProcess.waitForFinished();
653 QByteArray result = checkProcess.readAllStandardError();
654 if (!result.contains("- avformat")) errorMessage.append(i18n("MLT's avformat (FFMPEG) module not found. Please check your FFMPEG and MLT install. Kdenlive will not work until this issue is fixed.") + "\n");*/
656 QProcess checkProcess2;
657 checkProcess2.start(KdenliveSettings::rendererpath(), QStringList() << "-query" << "consumer");
658 if (!checkProcess2.waitForStarted())
659 errorMessage.append(i18n("Error starting MLT's command line player (melt).") + '\n');
661 checkProcess2.waitForFinished();
663 QByteArray result = checkProcess2.readAllStandardError();
664 if (!result.contains("sdl") || !result.contains("sdl_preview")) errorMessage.append(i18n("MLT's SDL module not found. Please check your MLT install. Kdenlive will not work until this issue is fixed.") + '\n');
666 if (!errorMessage.isEmpty()) {
667 errorMessage.prepend(QString("<b>%1</b><br />").arg(i18n("Fatal Error")));
668 QLabel *pix = new QLabel();
669 pix->setPixmap(KIcon("dialog-error").pixmap(30));
670 QLabel *label = new QLabel(errorMessage);
671 label->setWordWrap(true);
672 m_startLayout->addSpacing(40);
673 m_startLayout->addWidget(pix);
674 m_startLayout->addWidget(label);
675 m_systemCheckIsOk = false;
676 button(QWizard::NextButton)->setEnabled(false);
677 } else m_systemCheckIsOk = true;
679 if (m_systemCheckIsOk) checkMltComponents();
683 bool Wizard::isOk() const
685 return m_systemCheckIsOk;
688 void Wizard::slotShowWebInfos()
690 KRun::runUrl(KUrl("http://kdenlive.org/discover/" + QString(kdenlive_version).section(' ', 0, 0)), "text/html", this);
693 void Wizard::slotSaveCaptureFormat()
695 QStringList format = m_capture.v4l_formats->itemData(m_capture.v4l_formats->currentIndex()).toStringList();
696 if (format.isEmpty()) return;
697 MltVideoProfile profile;
698 profile.description = "Video4Linux capture";
699 profile.colorspace = 601;
700 profile.width = format.at(1).toInt();
701 profile.height = format.at(2).toInt();
702 profile.sample_aspect_num = 1;
703 profile.sample_aspect_den = 1;
704 profile.display_aspect_num = format.at(1).toInt();
705 profile.display_aspect_den = format.at(2).toInt();
706 profile.frame_rate_num = format.at(3).toInt();
707 profile.frame_rate_den = format.at(4).toInt();
708 profile.progressive = 1;
709 QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
710 ProfilesDialog::saveProfile(profile, vl4ProfilePath);
713 #include "wizard.moc"