#include "renderer.h"
#include "jogshuttle.h"
#include "clipproperties.h"
+#include "wizard.h"
#define ID_STATUS_MSG 1
#define ID_EDITMODE_MSG 2
: KXmlGuiWindow(parent),
m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL), m_jogProcess(NULL), m_findActivated(false), m_initialized(false) {
setlocale(LC_NUMERIC, "POSIX");
- parseProfiles();
setFont(KGlobalSettings::toolBarFont());
+ parseProfiles();
m_commandStack = new QUndoGroup;
m_timelineArea = new KTabWidget(this);
m_timelineArea->setTabReorderingEnabled(true);
transitionConfigDock->setWidget(transitionConfig);
addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
+ KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
+ m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
+ actionCollection());
+ readOptions();
clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
clipMonitorDock->setObjectName("clip_monitor");
KStandardAction::open(this, SLOT(openFile()),
actionCollection());
- m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
- actionCollection());
-
KStandardAction::save(this, SLOT(saveFile()),
actionCollection());
this, SLOT(slotDisplayActionMessage(QAction*)));
//connect(actionCollection(), SIGNAL( clearStatusText() ),
//statusBar(), SLOT( clear() ) );
-
- readOptions();
}
void MainWindow::slotDisplayActionMessage(QAction *a) {
void MainWindow::readOptions() {
KSharedConfigPtr config = KGlobal::config();
m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
+ KConfigGroup initialGroup(config, "version");
+ if (!initialGroup.exists()) {
+ // this is our first run, show Wizard
+ Wizard *w = new Wizard(this);
+ if (w->exec() == QDialog::Accepted) {
+ w->adjustSettings();
+ initialGroup.writeEntry("version", "0.7");
+ }
+ delete w;
+ }
}
void MainWindow::newFile() {
tmp = decodedString(KdenliveSettings::current_profile());
m_mltProfile = new Mlt::Profile(tmp);
delete[] tmp;
+
+
+ QString videoDriver = KdenliveSettings::videodrivername();
+ if (!videoDriver.isEmpty()) {
+ if (videoDriver == "x11_noaccel") {
+ setenv("SDL_VIDEO_YUV_HWACCEL", "0", 1);
+ videoDriver = "x11";
+ } else {
+ unsetenv("SDL_VIDEO_YUV_HWACCEL");
+ }
+ }
+
m_mltConsumer = new Mlt::Consumer(*m_mltProfile , "sdl_preview");
m_mltConsumer->set("resize", 1);
m_mltConsumer->set("window_id", m_winid);
m_mltConsumer->set("terminate_on_pause", 1);
m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
m_mltConsumer->set("rescale", "nearest");
+
QString audioDevice = KdenliveSettings::audiodevicename();
if (!audioDevice.isEmpty()) {
tmp = decodedString(audioDevice);
delete[] tmp;
}
- QString videoDriver = KdenliveSettings::videodrivername();
if (!videoDriver.isEmpty()) {
- if (videoDriver == "x11_noaccel") {
- setenv("SDL_VIDEO_YUV_HWACCEL", "0", 1);
- m_mltConsumer->set("video_driver", "x11");
- } else {
- unsetenv("SDL_VIDEO_YUV_HWACCEL");
- tmp = decodedString(videoDriver);
- m_mltConsumer->set("video_driver", tmp);
- delete[] tmp;
- }
+ tmp = decodedString(videoDriver);
+ m_mltConsumer->set("video_driver", tmp);
+ delete[] tmp;
}
QString audioDriver = KdenliveSettings::audiodrivername();
int Render::resetProfile() {
if (!m_mltConsumer) return 0;
+ QString currentProfile = getenv("MLT_PROFILE");
+ if (currentProfile == KdenliveSettings::current_profile()) {
+ kDebug() << "reset to same profile, nothing to do";
+ return 1;
+ }
if (m_isSplitView) slotSplitView(false);
if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
m_mltConsumer->purge();
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#include <QLabel>
+#include <QVBoxLayout>
+#include <QFile>
+#include <QXmlStreamWriter>
+
+#include <KStandardDirs>
+#include <KLocale>
+#include <KProcess>
+#include <kmimetype.h>
+
+#include "kdenlivesettings.h"
+#include "profilesdialog.h"
+#include "wizard.h"
+
+Wizard::Wizard(QWidget *parent): QWizard(parent) {
+ setPixmap(QWizard::WatermarkPixmap, QPixmap(KStandardDirs::locate("appdata", "banner.png")));
+
+ QWizardPage *page1 = new QWizardPage;
+ page1->setTitle("Welcome");
+ QLabel *label = new QLabel("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...");
+ label->setWordWrap(true);
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(label);
+ page1->setLayout(layout);
+ addPage(page1);
+
+ QWizardPage *page2 = new QWizardPage;
+ page2->setTitle("Video Standard");
+ m_standard.setupUi(page2);
+ m_standard.profiles_list->setMaximumHeight(100);
+ connect(m_standard.button_pal, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
+ connect(m_standard.button_dv, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
+ slotCheckStandard();
+ connect(m_standard.profiles_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckSelectedItem()));
+ addPage(page2);
+
+ QWizardPage *page3 = new QWizardPage;
+ page3->setTitle("Additional Settings");
+ m_extra.setupUi(page3);
+ m_extra.videothumbs->setChecked(KdenliveSettings::videothumbnails());
+ m_extra.audiothumbs->setChecked(KdenliveSettings::audiothumbnails());
+ m_extra.autosave->setChecked(KdenliveSettings::crashrecovery());
+ connect(m_extra.videothumbs, SIGNAL(stateChanged(int)), this, SLOT(slotCheckThumbs()));
+ connect(m_extra.audiothumbs, SIGNAL(stateChanged(int)), this, SLOT(slotCheckThumbs()));
+ slotCheckThumbs();
+ addPage(page3);
+}
+
+void Wizard::installExtraMimes(QString baseName, QStringList globs) {
+ QString mimefile = baseName;
+ mimefile.replace('/', '-');
+ KMimeType::Ptr mime = KMimeType::mimeType(baseName);
+ if (!mime) {
+ kDebug() << "KMimeTypeTrader: mimeType " << baseName << " not found";
+ } else {
+ QStringList extensions = mime->patterns();
+ QString comment = mime->comment();
+ foreach(const QString &glob, globs) {
+ if (!extensions.contains(glob)) extensions << glob;
+ }
+ kDebug() << "EXTS: " << extensions;
+ QString packageFileName = KStandardDirs::locateLocal("xdgdata-mime", "packages/" + mimefile + ".xml");
+ kDebug() << "INSTALLING NEW MIME TO: " << packageFileName;
+ QFile packageFile(packageFileName);
+ if (!packageFile.open(QIODevice::WriteOnly)) {
+ kError() << "Couldn't open" << packageFileName << "for writing";
+ return;
+ }
+ QXmlStreamWriter writer(&packageFile);
+ writer.setAutoFormatting(true);
+ writer.writeStartDocument();
+
+ const QString nsUri = "http://www.freedesktop.org/standards/shared-mime-info";
+ writer.writeDefaultNamespace(nsUri);
+ writer.writeStartElement("mime-info");
+ writer.writeStartElement(nsUri, "mime-type");
+ writer.writeAttribute("type", baseName);
+
+ if (!comment.isEmpty()) {
+ writer.writeStartElement(nsUri, "comment");
+ writer.writeCharacters(comment);
+ writer.writeEndElement(); // comment
+ }
+
+ foreach(const QString& pattern, extensions) {
+ writer.writeStartElement(nsUri, "glob");
+ writer.writeAttribute("pattern", pattern);
+ writer.writeEndElement(); // glob
+ }
+
+ writer.writeEndElement(); // mime-info
+ writer.writeEndElement(); // mime-type
+ writer.writeEndDocument();
+ }
+}
+
+void Wizard::runUpdateMimeDatabase() {
+ const QString localPackageDir = KStandardDirs::locateLocal("xdgdata-mime", QString());
+ Q_ASSERT(!localPackageDir.isEmpty());
+ KProcess proc;
+ proc << "update-mime-database";
+ proc << localPackageDir;
+ const int exitCode = proc.execute();
+ if (exitCode) {
+ kWarning() << proc.program() << "exited with error code" << exitCode;
+ }
+}
+
+void Wizard::slotCheckThumbs() {
+ QString pixname = "timeline_vthumbs.png";
+ if (!m_extra.audiothumbs->isChecked() && !m_extra.videothumbs->isChecked()) {
+ pixname = "timeline_nothumbs.png";
+ } else if (m_extra.audiothumbs->isChecked()) {
+ if (m_extra.videothumbs->isChecked())
+ pixname = "timeline_avthumbs.png";
+ else pixname = "timeline_athumbs.png";
+ }
+
+ m_extra.timeline_preview->setPixmap(QPixmap(KStandardDirs::locate("appdata", pixname)));
+}
+
+void Wizard::slotCheckStandard() {
+ QStringList profiles;
+ if (m_standard.button_pal->isChecked()) {
+ // PAL standard
+ if (m_standard.button_dv->isChecked()) {
+ profiles << "dv_pal" << "dv_pal_wide";
+ } else {
+ profiles << "hdv_720_25p" << "hdv_1080_50i";
+ }
+ } else {
+ // NTSC standard
+ if (m_standard.button_dv->isChecked()) {
+ profiles << "dv_ntsc" << "dv_ntsc_wide";
+ } else {
+ profiles << "hdv_720_30p" << "hdv_1080_60i" << "atsc_720p_30" << "atsc_1080i_60";
+ }
+ }
+ m_standard.profiles_list->clear();
+ QStringList profilesDescription;
+ foreach(const QString &prof, profiles) {
+ QListWidgetItem *item = new QListWidgetItem(ProfilesDialog::getProfileDescription(prof), m_standard.profiles_list);
+ item->setData(Qt::UserRole, prof);
+ }
+ m_standard.profiles_list->setCurrentRow(0);
+}
+
+void Wizard::slotCheckSelectedItem() {
+ // Make sure we always have an item highlighted
+ m_standard.profiles_list->setCurrentRow(m_standard.profiles_list->currentRow());
+}
+
+
+void Wizard::adjustSettings() {
+ if (m_extra.installmimes->isChecked()) {
+ QStringList globs;
+ globs << "*.mts" << "*.m2t";
+ installExtraMimes("video/mpeg", globs);
+ globs.clear();
+ globs << "*.dv";
+ installExtraMimes("video/dv", globs);
+ runUpdateMimeDatabase();
+ }
+ KdenliveSettings::setAudiothumbnails(m_extra.audiothumbs->isChecked());
+ KdenliveSettings::setVideothumbnails(m_extra.videothumbs->isChecked());
+ KdenliveSettings::setCrashrecovery(m_extra.autosave->isChecked());
+ if (m_standard.profiles_list->currentItem()) {
+ KdenliveSettings::setDefault_profile(m_standard.profiles_list->currentItem()->data(Qt::UserRole).toString());
+ }
+}
+
+#include "wizard.moc"
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+
+#ifndef WIZARD_H
+#define WIZARD_H
+
+#include <QWizard>
+#include <KDebug>
+
+#include "ui_wizardstandard_ui.h"
+#include "ui_wizardextra_ui.h"
+
+
+class Wizard : public QWizard {
+ Q_OBJECT
+public:
+ Wizard(QWidget * parent = 0);
+ void installExtraMimes(QString baseName, QStringList globs);
+ void runUpdateMimeDatabase();
+ void adjustSettings();
+
+private:
+ Ui::WizardStandard_UI m_standard;
+ Ui::WizardExtra_UI m_extra;
+
+private slots:
+ void slotCheckThumbs();
+ void slotCheckStandard();
+ void slotCheckSelectedItem();
+};
+
+#endif
+