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 #if !defined(Q_OS_FREEBSD)
24 #include "v4l/v4lcapture.h"
26 #include "kdenlive-config.h"
28 #include <mlt++/Mlt.h>
29 #include <framework/mlt_version.h>
31 #include <KStandardDirs>
34 #include <kmimetype.h>
37 #include <KMimeTypeTrader>
41 #include <QXmlStreamWriter>
44 // Recommanded MLT version
45 const int mltVersionMajor = 0;
46 const int mltVersionMinor = 7;
47 const int mltVersionRevision = 2;
49 static const char kdenlive_version[] = VERSION;
51 Wizard::Wizard(bool upgrade, QWidget *parent) :
53 m_systemCheckIsOk(false)
55 setWindowTitle(i18n("Config Wizard"));
56 setPixmap(QWizard::WatermarkPixmap, QPixmap(KStandardDirs::locate("appdata", "banner.png")));
58 QWizardPage *page1 = new QWizardPage;
59 page1->setTitle(i18n("Welcome"));
62 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)));
64 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..."));
65 label->setWordWrap(true);
66 m_startLayout = new QVBoxLayout;
67 m_startLayout->addWidget(label);
68 QPushButton *but = new QPushButton(KIcon("help-about"), i18n("Discover the features of this Kdenlive release"), this);
69 connect(but, SIGNAL(clicked()), this, SLOT(slotShowWebInfos()));
70 m_startLayout->addStretch();
71 m_startLayout->addWidget(but);
74 page1->setLayout(m_startLayout);
77 QWizardPage *page4 = new QWizardPage;
78 page4->setTitle(i18n("Checking MLT engine"));
79 m_mltCheck.setupUi(page4);
82 WizardDelegate *listViewDelegate = new WizardDelegate(m_mltCheck.programList);
83 m_mltCheck.programList->setItemDelegate(listViewDelegate);
85 QWizardPage *page2 = new QWizardPage;
86 page2->setTitle(i18n("Video Standard"));
87 m_standard.setupUi(page2);
89 m_okIcon = KIcon("dialog-ok");
90 m_badIcon = KIcon("dialog-close");
92 // build profiles lists
93 QMap<QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
94 QMap<QString, QString>::const_iterator i = profilesInfo.constBegin();
95 while (i != profilesInfo.constEnd()) {
96 QMap< QString, QString > profileData = ProfilesDialog::getSettingsFromFile(i.value());
97 if (profileData.value("width") == "720") m_dvProfiles.insert(i.key(), i.value());
98 else if (profileData.value("width").toInt() >= 1080) m_hdvProfiles.insert(i.key(), i.value());
99 else m_otherProfiles.insert(i.key(), i.value());
103 m_standard.button_all->setChecked(true);
104 connect(m_standard.button_all, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
105 connect(m_standard.button_hdv, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
106 connect(m_standard.button_dv, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
108 connect(m_standard.profiles_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckSelectedItem()));
110 // select default profile
111 if (!KdenliveSettings::default_profile().isEmpty()) {
112 for (int i = 0; i < m_standard.profiles_list->count(); i++) {
113 if (m_standard.profiles_list->item(i)->data(Qt::UserRole).toString() == KdenliveSettings::default_profile()) {
114 m_standard.profiles_list->setCurrentRow(i);
115 m_standard.profiles_list->scrollToItem(m_standard.profiles_list->currentItem());
123 QWizardPage *page3 = new QWizardPage;
124 page3->setTitle(i18n("Additional Settings"));
125 m_extra.setupUi(page3);
126 m_extra.projectfolder->setMode(KFile::Directory);
127 m_extra.projectfolder->setUrl(KUrl(KdenliveSettings::defaultprojectfolder()));
128 m_extra.videothumbs->setChecked(KdenliveSettings::videothumbnails());
129 m_extra.audiothumbs->setChecked(KdenliveSettings::audiothumbnails());
130 m_extra.autosave->setChecked(KdenliveSettings::crashrecovery());
131 connect(m_extra.videothumbs, SIGNAL(stateChanged(int)), this, SLOT(slotCheckThumbs()));
132 connect(m_extra.audiothumbs, SIGNAL(stateChanged(int)), this, SLOT(slotCheckThumbs()));
137 QWizardPage *page6 = new QWizardPage;
138 page6->setTitle(i18n("Webcam"));
139 m_capture.setupUi(page6);
140 connect(m_capture.button_reload, SIGNAL(clicked()), this, SLOT(slotDetectWebcam()));
141 connect(m_capture.v4l_devices, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateCaptureParameters()));
142 connect(m_capture.v4l_formats, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSaveCaptureFormat()));
143 m_capture.button_reload->setIcon(KIcon("view-refresh"));
148 QWizardPage *page5 = new QWizardPage;
149 page5->setTitle(i18n("Checking system"));
150 m_check.setupUi(page5);
153 listViewDelegate = new WizardDelegate(m_check.programList);
154 m_check.programList->setItemDelegate(listViewDelegate);
156 QTimer::singleShot(500, this, SLOT(slotCheckMlt()));
159 void Wizard::slotDetectWebcam()
161 #if !defined(Q_WS_MAC) && !defined(Q_OS_FREEBSD)
162 m_capture.v4l_devices->blockSignals(true);
163 m_capture.v4l_devices->clear();
165 // Video 4 Linux device detection
166 for (int i = 0; i < 10; i++) {
167 QString path = "/dev/video" + QString::number(i);
168 if (QFile::exists(path)) {
169 QStringList deviceInfo = V4lCaptureHandler::getDeviceName(path.toUtf8().constData());
170 if (!deviceInfo.isEmpty()) {
171 m_capture.v4l_devices->addItem(deviceInfo.at(0), path);
172 m_capture.v4l_devices->setItemData(m_capture.v4l_devices->count() - 1, deviceInfo.at(1), Qt::UserRole + 1);
176 if (m_capture.v4l_devices->count() > 0) {
177 m_capture.v4l_status->setText(i18n("Select your default video4linux device"));
178 // select default device
180 for (int i = 0; i < m_capture.v4l_devices->count(); i++) {
181 QString device = m_capture.v4l_devices->itemData(i).toString();
182 if (device == KdenliveSettings::video4vdevice()) {
183 m_capture.v4l_devices->setCurrentIndex(i);
188 slotUpdateCaptureParameters();
189 if (!found) m_capture.v4l_devices->setCurrentIndex(0);
190 } else m_capture.v4l_status->setText(i18n("No device found, plug your webcam and refresh."));
191 m_capture.v4l_devices->blockSignals(false);
195 void Wizard::slotUpdateCaptureParameters()
197 QString device = m_capture.v4l_devices->itemData(m_capture.v4l_devices->currentIndex()).toString();
198 if (!device.isEmpty()) KdenliveSettings::setVideo4vdevice(device);
200 QString formats = m_capture.v4l_devices->itemData(m_capture.v4l_devices->currentIndex(), Qt::UserRole + 1).toString();
202 m_capture.v4l_formats->blockSignals(true);
203 m_capture.v4l_formats->clear();
205 QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
206 if (QFile::exists(vl4ProfilePath)) {
207 MltVideoProfile profileInfo = ProfilesDialog::getVideoProfile(vl4ProfilePath);
208 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));
210 QStringList pixelformats = formats.split(">", QString::SkipEmptyParts);
213 QStringList itemRates;
214 for (int i = 0; i < pixelformats.count(); i++) {
215 QString format = pixelformats.at(i).section(':', 0, 0);
216 QStringList sizes = pixelformats.at(i).split(":", QString::SkipEmptyParts);
217 pixelFormat = sizes.takeFirst();
218 for (int j = 0; j < sizes.count(); j++) {
219 itemSize = sizes.at(j).section("=", 0, 0);
220 itemRates = sizes.at(j).section("=", 1, 1).split(",", QString::SkipEmptyParts);
221 for (int k = 0; k < itemRates.count(); k++) {
222 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));
226 if (!QFile::exists(vl4ProfilePath)) {
227 if (m_capture.v4l_formats->count() > 9) slotSaveCaptureFormat();
229 // No existing profile and no autodetected profiles
230 MltVideoProfile profileInfo;
231 profileInfo.width = 320;
232 profileInfo.height = 200;
233 profileInfo.frame_rate_num = 15;
234 profileInfo.frame_rate_den = 1;
235 profileInfo.display_aspect_num = 4;
236 profileInfo.display_aspect_den = 3;
237 profileInfo.sample_aspect_num = 1;
238 profileInfo.sample_aspect_den = 1;
239 profileInfo.progressive = 1;
240 profileInfo.colorspace = 601;
241 ProfilesDialog::saveProfile(profileInfo, vl4ProfilePath);
242 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));
245 m_capture.v4l_formats->blockSignals(false);
248 void Wizard::checkMltComponents()
250 QSize itemSize(20, fontMetrics().height() * 2.5);
251 m_mltCheck.programList->setColumnWidth(0, 30);
252 m_mltCheck.programList->setIconSize(QSize(24, 24));
255 QTreeWidgetItem *mltitem = new QTreeWidgetItem(m_mltCheck.programList);
257 QTreeWidgetItem *meltitem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Melt") + " (" + KdenliveSettings::rendererpath() + ')');
258 meltitem->setData(1, Qt::UserRole, i18n("Required for rendering (part of MLT package)"));
259 meltitem->setSizeHint(0, itemSize);
260 meltitem->setIcon(0, m_okIcon);
263 Mlt::Repository *repository = Mlt::Factory::init();
265 mltitem->setData(1, Qt::UserRole, i18n("Cannot start the MLT video backend!"));
266 mltitem->setIcon(0, m_badIcon);
267 m_systemCheckIsOk = false;
268 button(QWizard::NextButton)->setEnabled(false);
271 int mltVersion = (mltVersionMajor << 16) + (mltVersionMinor << 8) + mltVersionRevision;
272 mltitem->setText(1, i18n("MLT version: %1", mlt_version_get_string()));
273 mltitem->setSizeHint(0, itemSize);
274 if (mlt_version_get_int() < 1792) {
275 mltitem->setData(1, Qt::UserRole, i18n("Your MLT version is unsupported!!!"));
276 mltitem->setIcon(0, m_badIcon);
277 m_systemCheckIsOk = false;
278 button(QWizard::NextButton)->setEnabled(false);
280 else if (mlt_version_get_int() < mltVersion) {
281 mltitem->setData(1, Qt::UserRole, i18n("Please upgrade to MLT %1.%2.%3", mltVersionMajor, mltVersionMinor, mltVersionRevision));
282 mltitem->setIcon(0, m_badIcon);
285 mltitem->setData(1, Qt::UserRole, i18n("MLT video backend!"));
286 mltitem->setIcon(0, m_okIcon);
289 // Retrieve the list of available transitions.
290 Mlt::Properties *producers = repository->producers();
291 QStringList producersItemList;
292 for (int i = 0; i < producers->count(); ++i)
293 producersItemList << producers->get_name(i);
296 Mlt::Properties *consumers = repository->consumers();
297 QStringList consumersItemList;
298 for (int i = 0; i < consumers->count(); ++i)
299 consumersItemList << consumers->get_name(i);
303 QTreeWidgetItem *sdlItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("SDL module"));
304 sdlItem->setData(1, Qt::UserRole, i18n("Required for Kdenlive"));
305 sdlItem->setSizeHint(0, itemSize);
307 if (!consumersItemList.contains("sdl")) {
308 sdlItem->setIcon(0, m_badIcon);
309 m_systemCheckIsOk = false;
310 button(QWizard::NextButton)->setEnabled(false);
313 sdlItem->setIcon(0, m_okIcon);
317 QTreeWidgetItem *avformatItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Avformat module (FFmpeg)"));
318 avformatItem->setData(1, Qt::UserRole, i18n("Required to work with various video formats (hdv, mpeg, flash, ...)"));
319 avformatItem->setSizeHint(0, itemSize);
320 Mlt::Consumer *consumer = NULL;
322 if (consumersItemList.contains("avformat"))
323 consumer = new Mlt::Consumer(p, "avformat");
324 if (consumer == NULL || !consumer->is_valid()) {
325 avformatItem->setIcon(0, m_badIcon);
326 m_mltCheck.tabWidget->setTabEnabled(1, false);
329 avformatItem->setIcon(0, m_okIcon);
330 consumer->set("vcodec", "list");
331 consumer->set("acodec", "list");
332 consumer->set("f", "list");
335 Mlt::Properties vcodecs((mlt_properties) consumer->get_data("vcodec"));
336 for (int i = 0; i < vcodecs.count(); i++)
337 result << QString(vcodecs.get(i));
338 m_mltCheck.vcodecs_list->addItems(result);
340 Mlt::Properties acodecs((mlt_properties) consumer->get_data("acodec"));
341 for (int i = 0; i < acodecs.count(); i++)
342 result << QString(acodecs.get(i));
343 m_mltCheck.acodecs_list->addItems(result);
345 Mlt::Properties formats((mlt_properties) consumer->get_data("f"));
346 for (int i = 0; i < formats.count(); i++)
347 result << QString(formats.get(i));
348 m_mltCheck.formats_list->addItems(result);
353 QTreeWidgetItem *dvItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("DV module (libdv)"));
354 dvItem->setData(1, Qt::UserRole, i18n("Required to work with dv files if avformat module is not installed"));
355 dvItem->setSizeHint(0, itemSize);
356 if (!producersItemList.contains("libdv")) {
357 dvItem->setIcon(0, m_badIcon);
360 dvItem->setIcon(0, m_okIcon);
364 QTreeWidgetItem *imageItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("QImage module"));
365 imageItem->setData(1, Qt::UserRole, i18n("Required to work with images"));
366 imageItem->setSizeHint(0, itemSize);
367 if (!producersItemList.contains("qimage")) {
368 imageItem->setIcon(0, m_badIcon);
369 imageItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Pixbuf module"));
370 imageItem->setData(1, Qt::UserRole, i18n("Required to work with images"));
371 imageItem->setSizeHint(0, itemSize);
372 if (producersItemList.contains("pixbuf")) {
373 imageItem->setIcon(0, m_badIcon);
376 imageItem->setIcon(0, m_okIcon);
380 imageItem->setIcon(0, m_okIcon);
384 QTreeWidgetItem *titleItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Title module"));
385 titleItem->setData(1, Qt::UserRole, i18n("Required to work with titles"));
386 titleItem->setSizeHint(0, itemSize);
387 if (!producersItemList.contains("kdenlivetitle")) {
388 KdenliveSettings::setHastitleproducer(false);
389 titleItem->setIcon(0, m_badIcon);
391 titleItem->setIcon(0, m_okIcon);
392 KdenliveSettings::setHastitleproducer(true);
397 void Wizard::slotCheckPrograms()
399 QSize itemSize(20, fontMetrics().height() * 2.5);
400 m_check.programList->setColumnWidth(0, 30);
401 m_check.programList->setIconSize(QSize(24, 24));
403 QTreeWidgetItem *item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("FFmpeg & ffplay"));
404 item->setData(1, Qt::UserRole, i18n("Required for webcam capture"));
405 item->setSizeHint(0, itemSize);
406 QString exepath = KStandardDirs::findExe("ffmpeg");
407 if (exepath.isEmpty()) item->setIcon(0, m_badIcon);
408 else if (KStandardDirs::findExe("ffplay").isEmpty()) item->setIcon(0, m_badIcon);
409 else item->setIcon(0, m_okIcon);
412 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("recordmydesktop"));
413 item->setData(1, Qt::UserRole, i18n("Required for screen capture"));
414 item->setSizeHint(0, itemSize);
415 if (KStandardDirs::findExe("recordmydesktop").isEmpty()) item->setIcon(0, m_badIcon);
416 else item->setIcon(0, m_okIcon);
418 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("dvgrab"));
419 item->setData(1, Qt::UserRole, i18n("Required for firewire capture"));
420 item->setSizeHint(0, itemSize);
421 if (KStandardDirs::findExe("dvgrab").isEmpty()) item->setIcon(0, m_badIcon);
422 else item->setIcon(0, m_okIcon);
425 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("dvdauthor"));
426 item->setData(1, Qt::UserRole, i18n("Required for creation of DVD"));
427 item->setSizeHint(0, itemSize);
428 if (KStandardDirs::findExe("dvdauthor").isEmpty()) item->setIcon(0, m_badIcon);
429 else item->setIcon(0, m_okIcon);
432 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("genisoimage or mkisofs"));
433 item->setData(1, Qt::UserRole, i18n("Required for creation of DVD ISO images"));
434 item->setSizeHint(0, itemSize);
435 if (KStandardDirs::findExe("genisoimage").isEmpty()) {
436 // no GenIso, check for mkisofs
437 if (!KStandardDirs::findExe("mkisofs").isEmpty()) {
438 item->setIcon(0, m_okIcon);
439 } else item->setIcon(0, m_badIcon);
440 } else item->setIcon(0, m_okIcon);
442 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("xine"));
443 item->setData(1, Qt::UserRole, i18n("Required to preview your DVD"));
444 item->setSizeHint(0, itemSize);
445 if (KStandardDirs::findExe("xine").isEmpty()) item->setIcon(0, m_badIcon);
446 else item->setIcon(0, m_okIcon);
448 // set up some default applications
450 if (KdenliveSettings::defaultimageapp().isEmpty()) {
451 program = KStandardDirs::findExe("gimp");
452 if (program.isEmpty()) program = KStandardDirs::findExe("krita");
453 if (!program.isEmpty()) KdenliveSettings::setDefaultimageapp(program);
455 if (KdenliveSettings::defaultaudioapp().isEmpty()) {
456 program = KStandardDirs::findExe("audacity");
457 if (program.isEmpty()) program = KStandardDirs::findExe("traverso");
458 if (!program.isEmpty()) KdenliveSettings::setDefaultaudioapp(program);
460 if (KdenliveSettings::defaultplayerapp().isEmpty()) {
461 KService::Ptr offer = KMimeTypeTrader::self()->preferredService("video/mpeg");
463 KdenliveSettings::setDefaultplayerapp(KRun::binaryName(offer->exec(), true));
467 void Wizard::installExtraMimes(QString baseName, QStringList globs)
469 QString mimefile = baseName;
470 mimefile.replace('/', '-');
471 KMimeType::Ptr mime = KMimeType::mimeType(baseName);
473 kDebug() << "KMimeTypeTrader: mimeType " << baseName << " not found";
475 QStringList extensions = mime->patterns();
476 QString comment = mime->comment();
477 foreach(const QString & glob, globs) {
478 if (!extensions.contains(glob)) extensions << glob;
480 kDebug() << "EXTS: " << extensions;
481 QString packageFileName = KStandardDirs::locateLocal("xdgdata-mime", "packages/" + mimefile + ".xml");
482 kDebug() << "INSTALLING NEW MIME TO: " << packageFileName;
483 QFile packageFile(packageFileName);
484 if (!packageFile.open(QIODevice::WriteOnly)) {
485 kError() << "Couldn't open" << packageFileName << "for writing";
488 QXmlStreamWriter writer(&packageFile);
489 writer.setAutoFormatting(true);
490 writer.writeStartDocument();
492 const QString nsUri = "http://www.freedesktop.org/standards/shared-mime-info";
493 writer.writeDefaultNamespace(nsUri);
494 writer.writeStartElement("mime-info");
495 writer.writeStartElement(nsUri, "mime-type");
496 writer.writeAttribute("type", baseName);
498 if (!comment.isEmpty()) {
499 writer.writeStartElement(nsUri, "comment");
500 writer.writeCharacters(comment);
501 writer.writeEndElement(); // comment
504 foreach(const QString & pattern, extensions) {
505 writer.writeStartElement(nsUri, "glob");
506 writer.writeAttribute("pattern", pattern);
507 writer.writeEndElement(); // glob
510 writer.writeEndElement(); // mime-info
511 writer.writeEndElement(); // mime-type
512 writer.writeEndDocument();
516 void Wizard::runUpdateMimeDatabase()
518 const QString localPackageDir = KStandardDirs::locateLocal("xdgdata-mime", QString());
519 //Q_ASSERT(!localPackageDir.isEmpty());
521 proc << "update-mime-database";
522 proc << localPackageDir;
523 const int exitCode = proc.execute();
525 kWarning() << proc.program() << "exited with error code" << exitCode;
529 void Wizard::slotCheckThumbs()
531 QString pixname = "timeline_vthumbs.png";
532 if (!m_extra.audiothumbs->isChecked() && !m_extra.videothumbs->isChecked()) {
533 pixname = "timeline_nothumbs.png";
534 } else if (m_extra.audiothumbs->isChecked()) {
535 if (m_extra.videothumbs->isChecked())
536 pixname = "timeline_avthumbs.png";
537 else pixname = "timeline_athumbs.png";
540 m_extra.timeline_preview->setPixmap(QPixmap(KStandardDirs::locate("appdata", pixname)));
543 void Wizard::slotCheckStandard()
545 m_standard.profiles_list->clear();
546 QStringList profiles;
547 if (!m_standard.button_hdv->isChecked()) {
549 QMapIterator<QString, QString> i(m_dvProfiles);
550 while (i.hasNext()) {
552 QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
553 item->setData(Qt::UserRole, i.value());
556 if (!m_standard.button_dv->isChecked()) {
558 QMapIterator<QString, QString> i(m_hdvProfiles);
559 while (i.hasNext()) {
561 QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
562 item->setData(Qt::UserRole, i.value());
565 if (m_standard.button_all->isChecked()) {
566 QMapIterator<QString, QString> i(m_otherProfiles);
567 while (i.hasNext()) {
569 QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
570 item->setData(Qt::UserRole, i.value());
572 //m_standard.profiles_list->sortItems();
575 for (int i = 0; i < m_standard.profiles_list->count(); i++) {
576 QListWidgetItem *item = m_standard.profiles_list->item(i);
578 QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(item->data(Qt::UserRole).toString());
579 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"));
580 item->setToolTip(infoString);
583 m_standard.profiles_list->setSortingEnabled(true);
584 m_standard.profiles_list->setCurrentRow(0);
587 void Wizard::slotCheckSelectedItem()
589 // Make sure we always have an item highlighted
590 m_standard.profiles_list->setCurrentRow(m_standard.profiles_list->currentRow());
594 void Wizard::adjustSettings()
596 if (m_extra.installmimes->isChecked()) {
598 globs << "*.mts" << "*.m2t" << "*.mod" << "*.ts" << "*.m2ts";
599 installExtraMimes("video/mpeg", globs);
602 installExtraMimes("video/dv", globs);
603 runUpdateMimeDatabase();
605 KdenliveSettings::setAudiothumbnails(m_extra.audiothumbs->isChecked());
606 KdenliveSettings::setVideothumbnails(m_extra.videothumbs->isChecked());
607 KdenliveSettings::setCrashrecovery(m_extra.autosave->isChecked());
608 if (m_standard.profiles_list->currentItem()) {
609 QString selectedProfile = m_standard.profiles_list->currentItem()->data(Qt::UserRole).toString();
610 if (selectedProfile.isEmpty()) selectedProfile = "dv_pal";
611 KdenliveSettings::setDefault_profile(selectedProfile);
613 QString path = m_extra.projectfolder->url().path();
614 if (KStandardDirs::makeDir(path) == false) {
615 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
616 } else KdenliveSettings::setDefaultprojectfolder(path);
620 void Wizard::slotCheckMlt()
622 QString errorMessage;
623 if (KdenliveSettings::rendererpath().isEmpty()) {
624 errorMessage.append(i18n("Your MLT installation cannot be found. Install MLT and restart Kdenlive.\n"));
627 if (!errorMessage.isEmpty()) {
628 errorMessage.prepend(QString("<b>%1</b><br />").arg(i18n("Fatal Error")));
629 QLabel *pix = new QLabel();
630 pix->setPixmap(KIcon("dialog-error").pixmap(30));
631 QLabel *label = new QLabel(errorMessage);
632 label->setWordWrap(true);
633 m_startLayout->addSpacing(40);
634 m_startLayout->addWidget(pix);
635 m_startLayout->addWidget(label);
636 m_systemCheckIsOk = false;
637 button(QWizard::NextButton)->setEnabled(false);
638 } else m_systemCheckIsOk = true;
640 if (m_systemCheckIsOk) checkMltComponents();
644 bool Wizard::isOk() const
646 return m_systemCheckIsOk;
649 void Wizard::slotShowWebInfos()
651 KRun::runUrl(KUrl("http://kdenlive.org/discover/" + QString(kdenlive_version).section(' ', 0, 0)), "text/html", this);
654 void Wizard::slotSaveCaptureFormat()
656 QStringList format = m_capture.v4l_formats->itemData(m_capture.v4l_formats->currentIndex()).toStringList();
657 if (format.isEmpty()) return;
658 MltVideoProfile profile;
659 profile.description = "Video4Linux capture";
660 profile.colorspace = 601;
661 profile.width = format.at(1).toInt();
662 profile.height = format.at(2).toInt();
663 profile.sample_aspect_num = 1;
664 profile.sample_aspect_den = 1;
665 profile.display_aspect_num = format.at(1).toInt();
666 profile.display_aspect_den = format.at(2).toInt();
667 profile.frame_rate_num = format.at(3).toInt();
668 profile.frame_rate_den = format.at(4).toInt();
669 profile.progressive = 1;
670 QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
671 ProfilesDialog::saveProfile(profile, vl4ProfilePath);
674 #include "wizard.moc"