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"
24 #include "v4l/v4lcapture.h"
26 #include "config-kdenlive.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 // Recommended MLT version
45 const int mltVersionMajor = 0;
46 const int mltVersionMinor = 7;
47 const int mltVersionRevision = 6;
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()
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 QString formatDescription = "[" + format + "] " + itemSize + " (" + itemRates.at(k) + ")";
223 if (m_capture.v4l_formats->findText(formatDescription) == -1)
224 m_capture.v4l_formats->addItem(formatDescription, QStringList() << format << itemSize.section('x', 0, 0) << itemSize.section('x', 1, 1) << itemRates.at(k).section('/', 0, 0) << itemRates.at(k).section('/', 1, 1));
228 if (!QFile::exists(vl4ProfilePath)) {
229 if (m_capture.v4l_formats->count() > 9) slotSaveCaptureFormat();
231 // No existing profile and no autodetected profiles
232 MltVideoProfile profileInfo;
233 profileInfo.width = 320;
234 profileInfo.height = 200;
235 profileInfo.frame_rate_num = 15;
236 profileInfo.frame_rate_den = 1;
237 profileInfo.display_aspect_num = 4;
238 profileInfo.display_aspect_den = 3;
239 profileInfo.sample_aspect_num = 1;
240 profileInfo.sample_aspect_den = 1;
241 profileInfo.progressive = 1;
242 profileInfo.colorspace = 601;
243 ProfilesDialog::saveProfile(profileInfo, vl4ProfilePath);
244 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));
247 m_capture.v4l_formats->blockSignals(false);
250 void Wizard::checkMltComponents()
252 QSize itemSize(20, fontMetrics().height() * 2.5);
253 m_mltCheck.programList->setColumnWidth(0, 30);
254 m_mltCheck.programList->setIconSize(QSize(24, 24));
257 QTreeWidgetItem *mltitem = new QTreeWidgetItem(m_mltCheck.programList);
259 QTreeWidgetItem *meltitem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Melt") + " (" + KdenliveSettings::rendererpath() + ')');
260 meltitem->setData(1, Qt::UserRole, i18n("Required for rendering (part of MLT package)"));
261 meltitem->setSizeHint(0, itemSize);
262 meltitem->setIcon(0, m_okIcon);
265 Mlt::Repository *repository = Mlt::Factory::init();
267 mltitem->setData(1, Qt::UserRole, i18n("Cannot start the MLT video backend!"));
268 mltitem->setIcon(0, m_badIcon);
269 m_systemCheckIsOk = false;
270 button(QWizard::NextButton)->setEnabled(false);
273 int mltVersion = (mltVersionMajor << 16) + (mltVersionMinor << 8) + mltVersionRevision;
274 mltitem->setText(1, i18n("MLT version: %1", mlt_version_get_string()));
275 mltitem->setSizeHint(0, itemSize);
276 if (mlt_version_get_int() < 1792) {
277 mltitem->setData(1, Qt::UserRole, i18n("Your MLT version is unsupported!!!"));
278 mltitem->setIcon(0, m_badIcon);
279 m_systemCheckIsOk = false;
280 button(QWizard::NextButton)->setEnabled(false);
282 else if (mlt_version_get_int() < mltVersion) {
283 mltitem->setData(1, Qt::UserRole, i18n("Please upgrade to MLT %1.%2.%3", mltVersionMajor, mltVersionMinor, mltVersionRevision));
284 mltitem->setIcon(0, m_badIcon);
287 mltitem->setData(1, Qt::UserRole, i18n("MLT video backend!"));
288 mltitem->setIcon(0, m_okIcon);
291 // Retrieve the list of available transitions.
292 Mlt::Properties *producers = repository->producers();
293 QStringList producersItemList;
294 for (int i = 0; i < producers->count(); ++i)
295 producersItemList << producers->get_name(i);
298 Mlt::Properties *consumers = repository->consumers();
299 QStringList consumersItemList;
300 for (int i = 0; i < consumers->count(); ++i)
301 consumersItemList << consumers->get_name(i);
305 QTreeWidgetItem *sdlItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("SDL module"));
306 sdlItem->setData(1, Qt::UserRole, i18n("Required for Kdenlive"));
307 sdlItem->setSizeHint(0, itemSize);
309 if (!consumersItemList.contains("sdl")) {
310 sdlItem->setIcon(0, m_badIcon);
311 m_systemCheckIsOk = false;
312 button(QWizard::NextButton)->setEnabled(false);
315 sdlItem->setIcon(0, m_okIcon);
319 QTreeWidgetItem *avformatItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Avformat module (FFmpeg)"));
320 avformatItem->setData(1, Qt::UserRole, i18n("Required to work with various video formats (hdv, mpeg, flash, ...)"));
321 avformatItem->setSizeHint(0, itemSize);
322 Mlt::Consumer *consumer = NULL;
324 if (consumersItemList.contains("avformat"))
325 consumer = new Mlt::Consumer(p, "avformat");
326 if (consumer == NULL || !consumer->is_valid()) {
327 avformatItem->setIcon(0, m_badIcon);
328 m_mltCheck.tabWidget->setTabEnabled(1, false);
331 avformatItem->setIcon(0, m_okIcon);
332 consumer->set("vcodec", "list");
333 consumer->set("acodec", "list");
334 consumer->set("f", "list");
337 Mlt::Properties vcodecs((mlt_properties) consumer->get_data("vcodec"));
338 for (int i = 0; i < vcodecs.count(); i++)
339 result << QString(vcodecs.get(i));
340 m_mltCheck.vcodecs_list->addItems(result);
341 KdenliveSettings::setVideocodecs(result);
343 Mlt::Properties acodecs((mlt_properties) consumer->get_data("acodec"));
344 for (int i = 0; i < acodecs.count(); i++)
345 result << QString(acodecs.get(i));
346 m_mltCheck.acodecs_list->addItems(result);
347 KdenliveSettings::setAudiocodecs(result);
349 Mlt::Properties formats((mlt_properties) consumer->get_data("f"));
350 for (int i = 0; i < formats.count(); i++)
351 result << QString(formats.get(i));
352 m_mltCheck.formats_list->addItems(result);
353 KdenliveSettings::setSupportedformats(result);
358 QTreeWidgetItem *dvItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("DV module (libdv)"));
359 dvItem->setData(1, Qt::UserRole, i18n("Required to work with dv files if avformat module is not installed"));
360 dvItem->setSizeHint(0, itemSize);
361 if (!producersItemList.contains("libdv")) {
362 dvItem->setIcon(0, m_badIcon);
365 dvItem->setIcon(0, m_okIcon);
369 QTreeWidgetItem *imageItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("QImage module"));
370 imageItem->setData(1, Qt::UserRole, i18n("Required to work with images"));
371 imageItem->setSizeHint(0, itemSize);
372 if (!producersItemList.contains("qimage")) {
373 imageItem->setIcon(0, m_badIcon);
374 imageItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Pixbuf module"));
375 imageItem->setData(1, Qt::UserRole, i18n("Required to work with images"));
376 imageItem->setSizeHint(0, itemSize);
377 if (producersItemList.contains("pixbuf")) {
378 imageItem->setIcon(0, m_badIcon);
381 imageItem->setIcon(0, m_okIcon);
385 imageItem->setIcon(0, m_okIcon);
389 QTreeWidgetItem *titleItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Title module"));
390 titleItem->setData(1, Qt::UserRole, i18n("Required to work with titles"));
391 titleItem->setSizeHint(0, itemSize);
392 if (!producersItemList.contains("kdenlivetitle")) {
393 KdenliveSettings::setHastitleproducer(false);
394 titleItem->setIcon(0, m_badIcon);
396 titleItem->setIcon(0, m_okIcon);
397 KdenliveSettings::setHastitleproducer(true);
402 void Wizard::slotCheckPrograms()
404 QSize itemSize(20, fontMetrics().height() * 2.5);
405 m_check.programList->setColumnWidth(0, 30);
406 m_check.programList->setIconSize(QSize(24, 24));
408 QTreeWidgetItem *item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("FFmpeg & ffplay"));
409 item->setData(1, Qt::UserRole, i18n("Required for webcam capture"));
410 item->setSizeHint(0, itemSize);
411 QString exepath = KStandardDirs::findExe("ffmpeg");
412 if (exepath.isEmpty()) item->setIcon(0, m_badIcon);
413 else if (KStandardDirs::findExe("ffplay").isEmpty()) item->setIcon(0, m_badIcon);
414 else item->setIcon(0, m_okIcon);
417 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("recordmydesktop"));
418 item->setData(1, Qt::UserRole, i18n("Required for screen capture"));
419 item->setSizeHint(0, itemSize);
420 if (KStandardDirs::findExe("recordmydesktop").isEmpty()) item->setIcon(0, m_badIcon);
421 else item->setIcon(0, m_okIcon);
423 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("dvgrab"));
424 item->setData(1, Qt::UserRole, i18n("Required for firewire capture"));
425 item->setSizeHint(0, itemSize);
426 if (KStandardDirs::findExe("dvgrab").isEmpty()) item->setIcon(0, m_badIcon);
427 else item->setIcon(0, m_okIcon);
430 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("dvdauthor"));
431 item->setData(1, Qt::UserRole, i18n("Required for creation of DVD"));
432 item->setSizeHint(0, itemSize);
433 if (KStandardDirs::findExe("dvdauthor").isEmpty()) item->setIcon(0, m_badIcon);
434 else item->setIcon(0, m_okIcon);
437 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("genisoimage or mkisofs"));
438 item->setData(1, Qt::UserRole, i18n("Required for creation of DVD ISO images"));
439 item->setSizeHint(0, itemSize);
440 if (KStandardDirs::findExe("genisoimage").isEmpty()) {
441 // no GenIso, check for mkisofs
442 if (!KStandardDirs::findExe("mkisofs").isEmpty()) {
443 item->setIcon(0, m_okIcon);
444 } else item->setIcon(0, m_badIcon);
445 } else item->setIcon(0, m_okIcon);
447 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("xine"));
448 item->setData(1, Qt::UserRole, i18n("Required to preview your DVD"));
449 item->setSizeHint(0, itemSize);
450 if (KStandardDirs::findExe("xine").isEmpty()) item->setIcon(0, m_badIcon);
451 else item->setIcon(0, m_okIcon);
453 // set up some default applications
455 if (KdenliveSettings::defaultimageapp().isEmpty()) {
456 program = KStandardDirs::findExe("gimp");
457 if (program.isEmpty()) program = KStandardDirs::findExe("krita");
458 if (!program.isEmpty()) KdenliveSettings::setDefaultimageapp(program);
460 if (KdenliveSettings::defaultaudioapp().isEmpty()) {
461 program = KStandardDirs::findExe("audacity");
462 if (program.isEmpty()) program = KStandardDirs::findExe("traverso");
463 if (!program.isEmpty()) KdenliveSettings::setDefaultaudioapp(program);
465 if (KdenliveSettings::defaultplayerapp().isEmpty()) {
466 KService::Ptr offer = KMimeTypeTrader::self()->preferredService("video/mpeg");
468 KdenliveSettings::setDefaultplayerapp(KRun::binaryName(offer->exec(), true));
472 void Wizard::installExtraMimes(QString baseName, QStringList globs)
474 QString mimefile = baseName;
475 mimefile.replace('/', '-');
476 KMimeType::Ptr mime = KMimeType::mimeType(baseName);
478 kDebug() << "KMimeTypeTrader: mimeType " << baseName << " not found";
480 QStringList extensions = mime->patterns();
481 QString comment = mime->comment();
482 foreach(const QString & glob, globs) {
483 if (!extensions.contains(glob)) extensions << glob;
485 kDebug() << "EXTS: " << extensions;
486 QString packageFileName = KStandardDirs::locateLocal("xdgdata-mime", "packages/" + mimefile + ".xml");
487 kDebug() << "INSTALLING NEW MIME TO: " << packageFileName;
488 QFile packageFile(packageFileName);
489 if (!packageFile.open(QIODevice::WriteOnly)) {
490 kError() << "Couldn't open" << packageFileName << "for writing";
493 QXmlStreamWriter writer(&packageFile);
494 writer.setAutoFormatting(true);
495 writer.writeStartDocument();
497 const QString nsUri = "http://www.freedesktop.org/standards/shared-mime-info";
498 writer.writeDefaultNamespace(nsUri);
499 writer.writeStartElement("mime-info");
500 writer.writeStartElement(nsUri, "mime-type");
501 writer.writeAttribute("type", baseName);
503 if (!comment.isEmpty()) {
504 writer.writeStartElement(nsUri, "comment");
505 writer.writeCharacters(comment);
506 writer.writeEndElement(); // comment
509 foreach(const QString & pattern, extensions) {
510 writer.writeStartElement(nsUri, "glob");
511 writer.writeAttribute("pattern", pattern);
512 writer.writeEndElement(); // glob
515 writer.writeEndElement(); // mime-info
516 writer.writeEndElement(); // mime-type
517 writer.writeEndDocument();
521 void Wizard::runUpdateMimeDatabase()
523 const QString localPackageDir = KStandardDirs::locateLocal("xdgdata-mime", QString());
524 //Q_ASSERT(!localPackageDir.isEmpty());
526 proc << "update-mime-database";
527 proc << localPackageDir;
528 const int exitCode = proc.execute();
530 kWarning() << proc.program() << "exited with error code" << exitCode;
534 void Wizard::slotCheckThumbs()
536 QString pixname = "timeline_vthumbs.png";
537 if (!m_extra.audiothumbs->isChecked() && !m_extra.videothumbs->isChecked()) {
538 pixname = "timeline_nothumbs.png";
539 } else if (m_extra.audiothumbs->isChecked()) {
540 if (m_extra.videothumbs->isChecked())
541 pixname = "timeline_avthumbs.png";
542 else pixname = "timeline_athumbs.png";
545 m_extra.timeline_preview->setPixmap(QPixmap(KStandardDirs::locate("appdata", pixname)));
548 void Wizard::slotCheckStandard()
550 m_standard.profiles_list->clear();
551 QStringList profiles;
552 if (!m_standard.button_hdv->isChecked()) {
554 QMapIterator<QString, QString> i(m_dvProfiles);
555 while (i.hasNext()) {
557 QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
558 item->setData(Qt::UserRole, i.value());
561 if (!m_standard.button_dv->isChecked()) {
563 QMapIterator<QString, QString> i(m_hdvProfiles);
564 while (i.hasNext()) {
566 QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
567 item->setData(Qt::UserRole, i.value());
570 if (m_standard.button_all->isChecked()) {
571 QMapIterator<QString, QString> i(m_otherProfiles);
572 while (i.hasNext()) {
574 QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
575 item->setData(Qt::UserRole, i.value());
577 //m_standard.profiles_list->sortItems();
580 for (int i = 0; i < m_standard.profiles_list->count(); i++) {
581 QListWidgetItem *item = m_standard.profiles_list->item(i);
583 QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(item->data(Qt::UserRole).toString());
584 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"));
585 item->setToolTip(infoString);
588 m_standard.profiles_list->setSortingEnabled(true);
589 m_standard.profiles_list->setCurrentRow(0);
592 void Wizard::slotCheckSelectedItem()
594 // Make sure we always have an item highlighted
595 m_standard.profiles_list->setCurrentRow(m_standard.profiles_list->currentRow());
599 void Wizard::adjustSettings()
601 if (m_extra.installmimes->isChecked()) {
603 globs << "*.mts" << "*.m2t" << "*.mod" << "*.ts" << "*.m2ts";
604 installExtraMimes("video/mpeg", globs);
607 installExtraMimes("video/dv", globs);
608 runUpdateMimeDatabase();
610 KdenliveSettings::setAudiothumbnails(m_extra.audiothumbs->isChecked());
611 KdenliveSettings::setVideothumbnails(m_extra.videothumbs->isChecked());
612 KdenliveSettings::setCrashrecovery(m_extra.autosave->isChecked());
613 if (m_standard.profiles_list->currentItem()) {
614 QString selectedProfile = m_standard.profiles_list->currentItem()->data(Qt::UserRole).toString();
615 if (selectedProfile.isEmpty()) selectedProfile = "dv_pal";
616 KdenliveSettings::setDefault_profile(selectedProfile);
618 QString path = m_extra.projectfolder->url().path();
619 if (KStandardDirs::makeDir(path) == false) {
620 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
621 } else KdenliveSettings::setDefaultprojectfolder(path);
625 void Wizard::slotCheckMlt()
627 QString errorMessage;
628 if (KdenliveSettings::rendererpath().isEmpty()) {
629 errorMessage.append(i18n("Your MLT installation cannot be found. Install MLT and restart Kdenlive.\n"));
632 if (!errorMessage.isEmpty()) {
633 errorMessage.prepend(QString("<b>%1</b><br />").arg(i18n("Fatal Error")));
634 QLabel *pix = new QLabel();
635 pix->setPixmap(KIcon("dialog-error").pixmap(30));
636 QLabel *label = new QLabel(errorMessage);
637 label->setWordWrap(true);
638 m_startLayout->addSpacing(40);
639 m_startLayout->addWidget(pix);
640 m_startLayout->addWidget(label);
641 m_systemCheckIsOk = false;
642 button(QWizard::NextButton)->setEnabled(false);
643 } else m_systemCheckIsOk = true;
645 if (m_systemCheckIsOk) checkMltComponents();
649 bool Wizard::isOk() const
651 return m_systemCheckIsOk;
654 void Wizard::slotShowWebInfos()
656 KRun::runUrl(KUrl("http://kdenlive.org/discover/" + QString(kdenlive_version).section(' ', 0, 0)), "text/html", this);
659 void Wizard::slotSaveCaptureFormat()
661 QStringList format = m_capture.v4l_formats->itemData(m_capture.v4l_formats->currentIndex()).toStringList();
662 if (format.isEmpty()) return;
663 MltVideoProfile profile;
664 profile.description = "Video4Linux capture";
665 profile.colorspace = 601;
666 profile.width = format.at(1).toInt();
667 profile.height = format.at(2).toInt();
668 profile.sample_aspect_num = 1;
669 profile.sample_aspect_den = 1;
670 profile.display_aspect_num = format.at(1).toInt();
671 profile.display_aspect_den = format.at(2).toInt();
672 profile.frame_rate_num = format.at(3).toInt();
673 profile.frame_rate_den = format.at(4).toInt();
674 profile.progressive = 1;
675 QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
676 ProfilesDialog::saveProfile(profile, vl4ProfilePath);
679 #include "wizard.moc"