]> git.sesse.net Git - kdenlive/commitdiff
New wizard at first Kdenlive startup: allows user to select video standard (pal,...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 8 Aug 2008 21:11:47 +0000 (21:11 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 8 Aug 2008 21:11:47 +0000 (21:11 +0000)
svn path=/branches/KDE4/; revision=2367

src/CMakeLists.txt
src/mainwindow.cpp
src/projectlist.cpp
src/renderer.cpp
src/wizard.cpp [new file with mode: 0644]
src/wizard.h [new file with mode: 0644]

index 49ab15c3c0da6840a039b466894541fb9c9b2e79..cf9c73750229bb0f7c2950f3b527f79679f11f48 100644 (file)
@@ -56,6 +56,8 @@ kde4_add_ui_files(kdenlive_UI
   widgets/clipdurationdialog_ui.ui
   widgets/managecaptures_ui.ui
   widgets/geometryval_ui.ui
+  widgets/wizardstandard_ui.ui
+  widgets/wizardextra_ui.ui
 )
  
 set(kdenlive_SRCS 
@@ -127,6 +129,7 @@ set(kdenlive_SRCS
   managecapturesdialog.cpp
   changespeedcommand.cpp
   geometryval.cpp
+  wizard.cpp
 )
 
 kde4_add_kcfg_files(kdenlive_SRCS GENERATE_MOC kdenlivesettings.kcfgc )
index 99b255219cf8ae09d34f13fe10d95bd393d118ac..5c3f40e659359b9874829b1e72b159ad6c741e6f 100644 (file)
@@ -75,6 +75,7 @@
 #include "renderer.h"
 #include "jogshuttle.h"
 #include "clipproperties.h"
+#include "wizard.h"
 
 #define ID_STATUS_MSG 1
 #define ID_EDITMODE_MSG 2
@@ -96,8 +97,8 @@ MainWindow::MainWindow(QWidget *parent)
         : 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);
@@ -143,6 +144,10 @@ MainWindow::MainWindow(QWidget *parent)
     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");
@@ -679,9 +684,6 @@ void MainWindow::setupActions() {
     KStandardAction::open(this, SLOT(openFile()),
                           actionCollection());
 
-    m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
-                       actionCollection());
-
     KStandardAction::save(this, SLOT(saveFile()),
                           actionCollection());
 
@@ -716,8 +718,6 @@ void MainWindow::setupActions() {
             this, SLOT(slotDisplayActionMessage(QAction*)));
     //connect(actionCollection(), SIGNAL( clearStatusText() ),
     //statusBar(), SLOT( clear() ) );
-
-    readOptions();
 }
 
 void MainWindow::slotDisplayActionMessage(QAction *a) {
@@ -734,6 +734,16 @@ void MainWindow::saveOptions() {
 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() {
index 2b9744db3d95f35a2317e4d75c0686b106b41a27..982318a36c3c587953e0a9fb4817bf56fe330c77 100644 (file)
@@ -306,7 +306,7 @@ void ProjectList::slotAddClip(QUrl givenUrl, QString group) {
     if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!!  NO CMD STK";
     KUrl::List list;
     if (givenUrl.isEmpty()) {
-        list = KFileDialog::getOpenUrls(KUrl("kfiledialog:///clipfolder"), "application/vnd.kde.kdenlive application/vnd.westley.scenelist application/flv application/vnd.rn-realmedia video/x-dv video/x-msvideo video/mpeg video/x-ms-wmv audio/mpeg audio/x-mp3 audio/x-wav application/ogg video/mp4 video/quicktime image/gif image/jpeg image/png image/x-bmp image/svg+xml image/tiff image/x-xcf-gimp image/x-vnd.adobe.photoshop image/x-pcx image/x-exr\n*.m2t *.mts|HDV video\n*.dv|DV video", this);
+        list = KFileDialog::getOpenUrls(KUrl("kfiledialog:///clipfolder"), "application/vnd.kde.kdenlive application/vnd.westley.scenelist application/flv application/vnd.rn-realmedia video/x-dv video/dv video/x-msvideo video/mpeg video/x-ms-wmv audio/mpeg audio/x-mp3 audio/x-wav application/ogg video/mp4 video/quicktime image/gif image/jpeg image/png image/x-bmp image/svg+xml image/tiff image/x-xcf-gimp image/x-vnd.adobe.photoshop image/x-pcx image/x-exr", this);
     } else list.append(givenUrl);
     if (list.isEmpty()) return;
 
index c413b93199072452055038f065fdce58f30b15a8..8cceccd391e9c7bfd80df5ae25bfae5e27a0bdfa 100644 (file)
@@ -112,12 +112,25 @@ void Render::buildConsumer() {
     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);
@@ -125,17 +138,10 @@ void Render::buildConsumer() {
         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();
@@ -153,6 +159,11 @@ void Render::buildConsumer() {
 
 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();
diff --git a/src/wizard.cpp b/src/wizard.cpp
new file mode 100644 (file)
index 0000000..3a16b88
--- /dev/null
@@ -0,0 +1,191 @@
+/***************************************************************************
+ *   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"
diff --git a/src/wizard.h b/src/wizard.h
new file mode 100644 (file)
index 0000000..ba9fa42
--- /dev/null
@@ -0,0 +1,50 @@
+/***************************************************************************
+ *   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
+