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 <KStandardDirs>
31 #include <kmimetype.h>
34 #include <KMimeTypeTrader>
38 #include <QXmlStreamWriter>
41 const double recommendedMltVersion = 510;
42 static const char kdenlive_version[] = VERSION;
44 Wizard::Wizard(bool upgrade, QWidget *parent) :
47 setWindowTitle(i18n("Config Wizard"));
48 setPixmap(QWizard::WatermarkPixmap, QPixmap(KStandardDirs::locate("appdata", "banner.png")));
50 QWizardPage *page1 = new QWizardPage;
51 page1->setTitle(i18n("Welcome"));
54 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)));
56 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..."));
57 label->setWordWrap(true);
58 m_startLayout = new QVBoxLayout;
59 m_startLayout->addWidget(label);
60 QPushButton *but = new QPushButton(KIcon("help-about"), i18n("Discover the features of this Kdenlive release"), this);
61 connect(but, SIGNAL(clicked()), this, SLOT(slotShowWebInfos()));
62 m_startLayout->addStretch();
63 m_startLayout->addWidget(but);
66 page1->setLayout(m_startLayout);
69 QWizardPage *page4 = new QWizardPage;
70 page4->setTitle(i18n("Checking MLT engine"));
71 m_mltCheck.setupUi(page4);
74 WizardDelegate *listViewDelegate = new WizardDelegate(m_mltCheck.programList);
75 m_mltCheck.programList->setItemDelegate(listViewDelegate);
77 QWizardPage *page2 = new QWizardPage;
78 page2->setTitle(i18n("Video Standard"));
79 m_standard.setupUi(page2);
81 m_okIcon = KIcon("dialog-ok");
82 m_badIcon = KIcon("dialog-close");
84 // build profiles lists
85 QMap<QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
86 QMap<QString, QString>::const_iterator i = profilesInfo.constBegin();
87 while (i != profilesInfo.constEnd()) {
88 QMap< QString, QString > profileData = ProfilesDialog::getSettingsFromFile(i.value());
89 if (profileData.value("width") == "720") m_dvProfiles.insert(i.key(), i.value());
90 else if (profileData.value("width").toInt() >= 1080) m_hdvProfiles.insert(i.key(), i.value());
91 else m_otherProfiles.insert(i.key(), i.value());
95 m_standard.button_all->setChecked(true);
96 connect(m_standard.button_all, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
97 connect(m_standard.button_hdv, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
98 connect(m_standard.button_dv, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
100 connect(m_standard.profiles_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckSelectedItem()));
102 // select default profile
103 if (!KdenliveSettings::default_profile().isEmpty()) {
104 for (int i = 0; i < m_standard.profiles_list->count(); i++) {
105 if (m_standard.profiles_list->item(i)->data(Qt::UserRole).toString() == KdenliveSettings::default_profile()) {
106 m_standard.profiles_list->setCurrentRow(i);
107 m_standard.profiles_list->scrollToItem(m_standard.profiles_list->currentItem());
115 QWizardPage *page3 = new QWizardPage;
116 page3->setTitle(i18n("Additional Settings"));
117 m_extra.setupUi(page3);
118 m_extra.projectfolder->setMode(KFile::Directory);
119 m_extra.projectfolder->setUrl(KUrl(KdenliveSettings::defaultprojectfolder()));
120 m_extra.videothumbs->setChecked(KdenliveSettings::videothumbnails());
121 m_extra.audiothumbs->setChecked(KdenliveSettings::audiothumbnails());
122 m_extra.autosave->setChecked(KdenliveSettings::crashrecovery());
123 connect(m_extra.videothumbs, SIGNAL(stateChanged(int)), this, SLOT(slotCheckThumbs()));
124 connect(m_extra.audiothumbs, SIGNAL(stateChanged(int)), this, SLOT(slotCheckThumbs()));
129 QWizardPage *page6 = new QWizardPage;
130 page6->setTitle(i18n("Webcam"));
131 m_capture.setupUi(page6);
132 connect(m_capture.button_reload, SIGNAL(clicked()), this, SLOT(slotDetectWebcam()));
133 connect(m_capture.v4l_devices, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateCaptureParameters()));
134 connect(m_capture.v4l_formats, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSaveCaptureFormat()));
135 m_capture.button_reload->setIcon(KIcon("view-refresh"));
140 QWizardPage *page5 = new QWizardPage;
141 page5->setTitle(i18n("Checking system"));
142 m_check.setupUi(page5);
145 listViewDelegate = new WizardDelegate(m_check.programList);
146 m_check.programList->setItemDelegate(listViewDelegate);
148 QTimer::singleShot(500, this, SLOT(slotCheckMlt()));
151 void Wizard::slotDetectWebcam()
153 #if !defined(Q_WS_MAC) && !defined(Q_OS_FREEBSD)
154 m_capture.v4l_devices->blockSignals(true);
155 m_capture.v4l_devices->clear();
157 // Video 4 Linux device detection
158 for (int i = 0; i < 10; i++) {
159 QString path = "/dev/video" + QString::number(i);
160 if (QFile::exists(path)) {
161 QStringList deviceInfo = V4lCaptureHandler::getDeviceName(path.toUtf8().constData());
162 if (!deviceInfo.isEmpty()) {
163 m_capture.v4l_devices->addItem(deviceInfo.at(0), path);
164 m_capture.v4l_devices->setItemData(m_capture.v4l_devices->count() - 1, deviceInfo.at(1), Qt::UserRole + 1);
168 if (m_capture.v4l_devices->count() > 0) {
169 m_capture.v4l_status->setText(i18n("Select your default video4linux device"));
170 // select default device
172 for (int i = 0; i < m_capture.v4l_devices->count(); i++) {
173 QString device = m_capture.v4l_devices->itemData(i).toString();
174 if (device == KdenliveSettings::video4vdevice()) {
175 m_capture.v4l_devices->setCurrentIndex(i);
180 slotUpdateCaptureParameters();
181 if (!found) m_capture.v4l_devices->setCurrentIndex(0);
182 } else m_capture.v4l_status->setText(i18n("No device found, plug your webcam and refresh."));
183 m_capture.v4l_devices->blockSignals(false);
187 void Wizard::slotUpdateCaptureParameters()
189 QString device = m_capture.v4l_devices->itemData(m_capture.v4l_devices->currentIndex()).toString();
190 if (!device.isEmpty()) KdenliveSettings::setVideo4vdevice(device);
192 QString formats = m_capture.v4l_devices->itemData(m_capture.v4l_devices->currentIndex(), Qt::UserRole + 1).toString();
194 m_capture.v4l_formats->blockSignals(true);
195 m_capture.v4l_formats->clear();
197 QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
198 if (QFile::exists(vl4ProfilePath)) {
199 MltVideoProfile profileInfo = ProfilesDialog::getVideoProfile(vl4ProfilePath);
200 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));
202 QStringList pixelformats = formats.split(">", QString::SkipEmptyParts);
205 QStringList itemRates;
206 for (int i = 0; i < pixelformats.count(); i++) {
207 QString format = pixelformats.at(i).section(':', 0, 0);
208 QStringList sizes = pixelformats.at(i).split(":", QString::SkipEmptyParts);
209 pixelFormat = sizes.takeFirst();
210 for (int j = 0; j < sizes.count(); j++) {
211 itemSize = sizes.at(j).section("=", 0, 0);
212 itemRates = sizes.at(j).section("=", 1, 1).split(",", QString::SkipEmptyParts);
213 for (int k = 0; k < itemRates.count(); k++) {
214 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));
218 if (!QFile::exists(vl4ProfilePath)) {
219 if (m_capture.v4l_formats->count() > 9) slotSaveCaptureFormat();
221 // No existing profile and no autodetected profiles
222 MltVideoProfile profileInfo;
223 profileInfo.width = 320;
224 profileInfo.height = 200;
225 profileInfo.frame_rate_num = 15;
226 profileInfo.frame_rate_den = 1;
227 profileInfo.display_aspect_num = 4;
228 profileInfo.display_aspect_den = 3;
229 profileInfo.sample_aspect_num = 1;
230 profileInfo.sample_aspect_den = 1;
231 profileInfo.progressive = 1;
232 profileInfo.colorspace = 601;
233 ProfilesDialog::saveProfile(profileInfo, vl4ProfilePath);
234 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));
237 m_capture.v4l_formats->blockSignals(false);
240 void Wizard::checkMltComponents()
242 QSize itemSize(20, fontMetrics().height() * 2.5);
243 m_mltCheck.programList->setColumnWidth(0, 30);
244 m_mltCheck.programList->setIconSize(QSize(24, 24));
247 QTreeWidgetItem *mltitem = new QTreeWidgetItem(m_mltCheck.programList);
249 QTreeWidgetItem *meltitem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Melt") + " (" + KdenliveSettings::rendererpath() + ')');
250 meltitem->setData(1, Qt::UserRole, i18n("Required for rendering (part of MLT package)"));
251 meltitem->setSizeHint(0, itemSize);
252 meltitem->setIcon(0, m_okIcon);
254 // Check MLT's installed producers
255 QProcess checkProcess;
256 checkProcess.start(KdenliveSettings::rendererpath(), QStringList() << "-query" << "producer");
257 if (!checkProcess.waitForStarted()) {
258 meltitem->setIcon(0, m_badIcon);
259 meltitem->setData(1, Qt::UserRole, i18n("Error starting MLT's command line player (melt)"));
260 button(QWizard::NextButton)->setEnabled(false);
262 checkProcess.waitForFinished();
263 QByteArray result = checkProcess.readAllStandardError();
265 // Check MLT avformat module
266 QTreeWidgetItem *avformatItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Avformat module (FFmpeg)"));
267 avformatItem->setData(1, Qt::UserRole, i18n("Required to work with various video formats (hdv, mpeg, flash, ...)"));
268 avformatItem->setSizeHint(0, itemSize);
269 if (!result.contains("- avformat")) {
270 avformatItem->setIcon(0, m_badIcon);
271 m_mltCheck.tabWidget->setTabEnabled(1, false);
273 avformatItem->setIcon(0, m_okIcon);
274 // Make sure we have MLT > 0.3.4
277 QString exepath = KStandardDirs::findExe("pkg-config");
278 if (!exepath.isEmpty()) {
279 checkProcess.start(exepath, QStringList() << "--variable=version" << "mlt++");
280 if (!checkProcess.waitForStarted()) {
281 kDebug() << "// Error querying MLT's version";
283 checkProcess.waitForFinished();
284 mltVersion = checkProcess.readAllStandardOutput();
285 version = 1000 * mltVersion.section('.', 0, 0).toInt() + 100 * mltVersion.section('.', 1, 1).toInt() + mltVersion.section('.', 2, 2).toInt();
286 kDebug() << "// FOUND MLT's pkgconfig version: " << version;
290 checkProcess.start(KdenliveSettings::rendererpath(), QStringList() << "--version");
291 if (!checkProcess.waitForStarted()) {
292 kDebug() << "// Error querying MLT's version";
294 checkProcess.waitForFinished();
295 mltVersion = checkProcess.readAllStandardError();
296 mltVersion = mltVersion.section('\n', 0, 0).simplified();
297 mltVersion = mltVersion.section(' ', -1).simplified();
298 version = 1000 * mltVersion.section('.', 0, 0).toInt() + 100 * mltVersion.section('.', 1, 1).toInt() + mltVersion.section('.', 2, 2).toInt();
299 kDebug() << "// FOUND MLT version: " << version;
303 mltitem->setText(1, i18n("MLT version: %1", mltVersion.simplified()));
304 mltitem->setSizeHint(0, itemSize);
306 mltitem->setData(1, Qt::UserRole, i18n("Your MLT version is unsupported!!!"));
307 mltitem->setIcon(0, m_badIcon);
309 if (version < recommendedMltVersion) {
310 mltitem->setData(1, Qt::UserRole, i18n("Please upgrade to the latest MLT version"));
311 mltitem->setIcon(0, m_badIcon);
313 mltitem->setData(1, Qt::UserRole, i18n("MLT version is correct"));
314 mltitem->setIcon(0, m_okIcon);
316 // Check installed audio codecs
317 QProcess checkProcess2;
318 checkProcess2.start(KdenliveSettings::rendererpath(), QStringList() << "noise:" << "-consumer" << "avformat" << "acodec=list");
319 if (!checkProcess2.waitForStarted()) {
320 m_mltCheck.tabWidget->setTabEnabled(1, false);
321 kDebug() << "// Error parsing MLT's avformat codecs";
323 checkProcess2.waitForFinished();
324 QByteArray codecList = checkProcess2.readAllStandardError();
325 QString acodecList(codecList);
327 QStringList alist = acodecList.split('\n', QString::SkipEmptyParts);
328 for (int i = 0; i < alist.count(); i++) {
329 if (alist.at(i).contains("- ")) result.append(alist.at(i).section("- ", 1).simplified().toLower());
331 m_mltCheck.acodecs_list->addItems(result);
332 KdenliveSettings::setAudiocodecs(result);
333 //kDebug()<<"// FOUND LIST:\n\n"<<m_audioCodecs<<"\n\n++++++++++++++++++++";
335 // Check video codecs
336 checkProcess2.start(KdenliveSettings::rendererpath(), QStringList() << "noise:" << "-consumer" << "avformat" << "vcodec=list");
337 if (!checkProcess2.waitForStarted()) {
338 kDebug() << "// Error parsing MLT's avformat codecs";
340 checkProcess2.waitForFinished();
341 QByteArray codecList = checkProcess2.readAllStandardError();
342 QString vcodecList(codecList);
344 QStringList vlist = vcodecList.split('\n', QString::SkipEmptyParts);
345 for (int i = 0; i < vlist.count(); i++) {
346 if (vlist.at(i).contains("- ")) result.append(vlist.at(i).section("- ", 1).simplified().toLower());
348 m_mltCheck.vcodecs_list->addItems(result);
349 KdenliveSettings::setVideocodecs(result);
350 //kDebug()<<"// FOUND LIST:\n\n"<<m_videoCodecs<<"\n\n++++++++++++++++++++";
353 checkProcess2.start(KdenliveSettings::rendererpath(), QStringList() << "noise:" << "-consumer" << "avformat" << "f=list");
354 if (!checkProcess2.waitForStarted()) {
355 kDebug() << "// Error parsing MLT's avformat codecs";
357 checkProcess2.waitForFinished();
358 QByteArray codecList = checkProcess2.readAllStandardError();
359 QString vcodecList(codecList);
361 QStringList vlist = vcodecList.split('\n', QString::SkipEmptyParts);
362 for (int i = 0; i < vlist.count(); i++) {
363 if (vlist.at(i).contains("- ")) {
364 QString format = vlist.at(i).section("- ", 1).simplified().toLower();
365 if (format.contains(',')) {
366 QStringList sub = format.split(',', QString::SkipEmptyParts);
367 for (int j = 0; j < sub.count(); j++)
368 result.append(sub.at(j));
369 } else result.append(format);
372 m_mltCheck.formats_list->addItems(result);
373 KdenliveSettings::setSupportedformats(result);
374 //kDebug()<<"// FOUND LIST:\n\n"<<m_videoCodecs<<"\n\n++++++++++++++++++++";
380 // Check MLT dv module
381 QTreeWidgetItem *dvItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("DV module (libdv)"));
382 dvItem->setData(1, Qt::UserRole, i18n("Required to work with dv files if avformat module is not installed"));
383 dvItem->setSizeHint(0, itemSize);
384 if (!result.contains("- libdv")) {
385 dvItem->setIcon(0, m_badIcon);
387 dvItem->setIcon(0, m_okIcon);
390 // Check MLT image format module
391 QTreeWidgetItem *imageItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("QImage module"));
392 imageItem->setData(1, Qt::UserRole, i18n("Required to work with images"));
393 imageItem->setSizeHint(0, itemSize);
394 if (!result.contains("- qimage")) {
395 imageItem->setIcon(0, m_badIcon);
396 imageItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Pixbuf module"));
397 imageItem->setData(1, Qt::UserRole, i18n("Required to work with images"));
398 imageItem->setSizeHint(0, itemSize);
399 if (!result.contains("- pixbuf")) imageItem->setIcon(0, m_badIcon);
400 else imageItem->setIcon(0, m_okIcon);
402 imageItem->setIcon(0, m_okIcon);
405 // Check MLT title module
406 QTreeWidgetItem *titleItem = new QTreeWidgetItem(m_mltCheck.programList, QStringList() << QString() << i18n("Title module"));
407 titleItem->setData(1, Qt::UserRole, i18n("Required to work with titles"));
408 titleItem->setSizeHint(0, itemSize);
409 if (!result.contains("- kdenlivetitle")) {
410 KdenliveSettings::setHastitleproducer(false);
411 titleItem->setIcon(0, m_badIcon);
413 titleItem->setIcon(0, m_okIcon);
414 KdenliveSettings::setHastitleproducer(true);
419 void Wizard::slotCheckPrograms()
421 QSize itemSize(20, fontMetrics().height() * 2.5);
422 m_check.programList->setColumnWidth(0, 30);
423 m_check.programList->setIconSize(QSize(24, 24));
425 QTreeWidgetItem *item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("FFmpeg & ffplay"));
426 item->setData(1, Qt::UserRole, i18n("Required for webcam capture"));
427 item->setSizeHint(0, itemSize);
428 QString exepath = KStandardDirs::findExe("ffmpeg");
429 if (exepath.isEmpty()) item->setIcon(0, m_badIcon);
430 else if (KStandardDirs::findExe("ffplay").isEmpty()) item->setIcon(0, m_badIcon);
431 else item->setIcon(0, m_okIcon);
434 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("recordmydesktop"));
435 item->setData(1, Qt::UserRole, i18n("Required for screen capture"));
436 item->setSizeHint(0, itemSize);
437 if (KStandardDirs::findExe("recordmydesktop").isEmpty()) item->setIcon(0, m_badIcon);
438 else item->setIcon(0, m_okIcon);
440 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("dvgrab"));
441 item->setData(1, Qt::UserRole, i18n("Required for firewire capture"));
442 item->setSizeHint(0, itemSize);
443 if (KStandardDirs::findExe("dvgrab").isEmpty()) item->setIcon(0, m_badIcon);
444 else item->setIcon(0, m_okIcon);
447 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("dvdauthor"));
448 item->setData(1, Qt::UserRole, i18n("Required for creation of DVD"));
449 item->setSizeHint(0, itemSize);
450 if (KStandardDirs::findExe("dvdauthor").isEmpty()) item->setIcon(0, m_badIcon);
451 else item->setIcon(0, m_okIcon);
454 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("genisoimage or mkisofs"));
455 item->setData(1, Qt::UserRole, i18n("Required for creation of DVD ISO images"));
456 item->setSizeHint(0, itemSize);
457 if (KStandardDirs::findExe("genisoimage").isEmpty()) {
458 // no GenIso, check for mkisofs
459 if (!KStandardDirs::findExe("mkisofs").isEmpty()) {
460 item->setIcon(0, m_okIcon);
461 } else item->setIcon(0, m_badIcon);
462 } else item->setIcon(0, m_okIcon);
464 item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("xine"));
465 item->setData(1, Qt::UserRole, i18n("Required to preview your DVD"));
466 item->setSizeHint(0, itemSize);
467 if (KStandardDirs::findExe("xine").isEmpty()) item->setIcon(0, m_badIcon);
468 else item->setIcon(0, m_okIcon);
470 // set up some default applications
472 if (KdenliveSettings::defaultimageapp().isEmpty()) {
473 program = KStandardDirs::findExe("gimp");
474 if (program.isEmpty()) program = KStandardDirs::findExe("krita");
475 if (!program.isEmpty()) KdenliveSettings::setDefaultimageapp(program);
477 if (KdenliveSettings::defaultaudioapp().isEmpty()) {
478 program = KStandardDirs::findExe("audacity");
479 if (program.isEmpty()) program = KStandardDirs::findExe("traverso");
480 if (!program.isEmpty()) KdenliveSettings::setDefaultaudioapp(program);
482 if (KdenliveSettings::defaultplayerapp().isEmpty()) {
483 KService::Ptr offer = KMimeTypeTrader::self()->preferredService("video/mpeg");
485 KdenliveSettings::setDefaultplayerapp(KRun::binaryName(offer->exec(), true));
489 void Wizard::installExtraMimes(QString baseName, QStringList globs)
491 QString mimefile = baseName;
492 mimefile.replace('/', '-');
493 KMimeType::Ptr mime = KMimeType::mimeType(baseName);
495 kDebug() << "KMimeTypeTrader: mimeType " << baseName << " not found";
497 QStringList extensions = mime->patterns();
498 QString comment = mime->comment();
499 foreach(const QString & glob, globs) {
500 if (!extensions.contains(glob)) extensions << glob;
502 kDebug() << "EXTS: " << extensions;
503 QString packageFileName = KStandardDirs::locateLocal("xdgdata-mime", "packages/" + mimefile + ".xml");
504 kDebug() << "INSTALLING NEW MIME TO: " << packageFileName;
505 QFile packageFile(packageFileName);
506 if (!packageFile.open(QIODevice::WriteOnly)) {
507 kError() << "Couldn't open" << packageFileName << "for writing";
510 QXmlStreamWriter writer(&packageFile);
511 writer.setAutoFormatting(true);
512 writer.writeStartDocument();
514 const QString nsUri = "http://www.freedesktop.org/standards/shared-mime-info";
515 writer.writeDefaultNamespace(nsUri);
516 writer.writeStartElement("mime-info");
517 writer.writeStartElement(nsUri, "mime-type");
518 writer.writeAttribute("type", baseName);
520 if (!comment.isEmpty()) {
521 writer.writeStartElement(nsUri, "comment");
522 writer.writeCharacters(comment);
523 writer.writeEndElement(); // comment
526 foreach(const QString & pattern, extensions) {
527 writer.writeStartElement(nsUri, "glob");
528 writer.writeAttribute("pattern", pattern);
529 writer.writeEndElement(); // glob
532 writer.writeEndElement(); // mime-info
533 writer.writeEndElement(); // mime-type
534 writer.writeEndDocument();
538 void Wizard::runUpdateMimeDatabase()
540 const QString localPackageDir = KStandardDirs::locateLocal("xdgdata-mime", QString());
541 //Q_ASSERT(!localPackageDir.isEmpty());
543 proc << "update-mime-database";
544 proc << localPackageDir;
545 const int exitCode = proc.execute();
547 kWarning() << proc.program() << "exited with error code" << exitCode;
551 void Wizard::slotCheckThumbs()
553 QString pixname = "timeline_vthumbs.png";
554 if (!m_extra.audiothumbs->isChecked() && !m_extra.videothumbs->isChecked()) {
555 pixname = "timeline_nothumbs.png";
556 } else if (m_extra.audiothumbs->isChecked()) {
557 if (m_extra.videothumbs->isChecked())
558 pixname = "timeline_avthumbs.png";
559 else pixname = "timeline_athumbs.png";
562 m_extra.timeline_preview->setPixmap(QPixmap(KStandardDirs::locate("appdata", pixname)));
565 void Wizard::slotCheckStandard()
567 m_standard.profiles_list->clear();
568 QStringList profiles;
569 if (!m_standard.button_hdv->isChecked()) {
571 QMapIterator<QString, QString> i(m_dvProfiles);
572 while (i.hasNext()) {
574 QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
575 item->setData(Qt::UserRole, i.value());
578 if (!m_standard.button_dv->isChecked()) {
580 QMapIterator<QString, QString> i(m_hdvProfiles);
581 while (i.hasNext()) {
583 QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
584 item->setData(Qt::UserRole, i.value());
587 if (m_standard.button_all->isChecked()) {
588 QMapIterator<QString, QString> i(m_otherProfiles);
589 while (i.hasNext()) {
591 QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
592 item->setData(Qt::UserRole, i.value());
594 //m_standard.profiles_list->sortItems();
597 for (int i = 0; i < m_standard.profiles_list->count(); i++) {
598 QListWidgetItem *item = m_standard.profiles_list->item(i);
600 QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(item->data(Qt::UserRole).toString());
601 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"));
602 item->setToolTip(infoString);
605 m_standard.profiles_list->setSortingEnabled(true);
606 m_standard.profiles_list->setCurrentRow(0);
609 void Wizard::slotCheckSelectedItem()
611 // Make sure we always have an item highlighted
612 m_standard.profiles_list->setCurrentRow(m_standard.profiles_list->currentRow());
616 void Wizard::adjustSettings()
618 if (m_extra.installmimes->isChecked()) {
620 globs << "*.mts" << "*.m2t" << "*.mod" << "*.ts" << "*.m2ts";
621 installExtraMimes("video/mpeg", globs);
624 installExtraMimes("video/dv", globs);
625 runUpdateMimeDatabase();
627 KdenliveSettings::setAudiothumbnails(m_extra.audiothumbs->isChecked());
628 KdenliveSettings::setVideothumbnails(m_extra.videothumbs->isChecked());
629 KdenliveSettings::setCrashrecovery(m_extra.autosave->isChecked());
630 if (m_standard.profiles_list->currentItem()) {
631 QString selectedProfile = m_standard.profiles_list->currentItem()->data(Qt::UserRole).toString();
632 if (selectedProfile.isEmpty()) selectedProfile = "dv_pal";
633 KdenliveSettings::setDefault_profile(selectedProfile);
635 QString path = m_extra.projectfolder->url().path();
636 if (KStandardDirs::makeDir(path) == false) {
637 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
638 } else KdenliveSettings::setDefaultprojectfolder(path);
642 void Wizard::slotCheckMlt()
644 QString errorMessage;
645 if (KdenliveSettings::rendererpath().isEmpty()) {
646 errorMessage.append(i18n("Your MLT installation cannot be found. Install MLT and restart Kdenlive.\n"));
648 /*QProcess checkProcess;
649 checkProcess.start(KdenliveSettings::rendererpath(), QStringList() << "-query" << "producer");
650 if (!checkProcess.waitForStarted())
651 errorMessage.append(i18n("Error starting MLT's command line player (melt)") + ".\n");
653 checkProcess.waitForFinished();
655 QByteArray result = checkProcess.readAllStandardError();
656 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");*/
658 QProcess checkProcess2;
659 checkProcess2.start(KdenliveSettings::rendererpath(), QStringList() << "-query" << "consumer");
660 if (!checkProcess2.waitForStarted())
661 errorMessage.append(i18n("Error starting MLT's command line player (melt).") + '\n');
663 checkProcess2.waitForFinished();
665 QByteArray result = checkProcess2.readAllStandardError();
666 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');
668 if (!errorMessage.isEmpty()) {
669 errorMessage.prepend(QString("<b>%1</b><br />").arg(i18n("Fatal Error")));
670 QLabel *pix = new QLabel();
671 pix->setPixmap(KIcon("dialog-error").pixmap(30));
672 QLabel *label = new QLabel(errorMessage);
673 label->setWordWrap(true);
674 m_startLayout->addSpacing(40);
675 m_startLayout->addWidget(pix);
676 m_startLayout->addWidget(label);
677 m_systemCheckIsOk = false;
678 button(QWizard::NextButton)->setEnabled(false);
679 } else m_systemCheckIsOk = true;
681 if (m_systemCheckIsOk) checkMltComponents();
685 bool Wizard::isOk() const
687 return m_systemCheckIsOk;
690 void Wizard::slotShowWebInfos()
692 KRun::runUrl(KUrl("http://kdenlive.org/discover/" + QString(kdenlive_version).section(' ', 0, 0)), "text/html", this);
695 void Wizard::slotSaveCaptureFormat()
697 QStringList format = m_capture.v4l_formats->itemData(m_capture.v4l_formats->currentIndex()).toStringList();
698 if (format.isEmpty()) return;
699 MltVideoProfile profile;
700 profile.description = "Video4Linux capture";
701 profile.colorspace = 601;
702 profile.width = format.at(1).toInt();
703 profile.height = format.at(2).toInt();
704 profile.sample_aspect_num = 1;
705 profile.sample_aspect_den = 1;
706 profile.display_aspect_num = format.at(1).toInt();
707 profile.display_aspect_den = format.at(2).toInt();
708 profile.frame_rate_num = format.at(3).toInt();
709 profile.frame_rate_den = format.at(4).toInt();
710 profile.progressive = 1;
711 QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
712 ProfilesDialog::saveProfile(profile, vl4ProfilePath);
715 #include "wizard.moc"