]> git.sesse.net Git - kdenlive/blobdiff - src/mainwindow.cpp
Implement document notes:
[kdenlive] / src / mainwindow.cpp
index 54c2a03cad36f2f79731a56303273dbf8f1edf3f..dd8e2d01637be992ec1202efd5fe6e623fc36251 100644 (file)
@@ -120,15 +120,15 @@ EffectsList MainWindow::audioEffects;
 EffectsList MainWindow::customEffects;
 EffectsList MainWindow::transitions;
 
-MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
-        KXmlGuiWindow(parent),
-        m_activeDocument(NULL),
-        m_activeTimeline(NULL),
-        m_renderWidget(NULL),
+MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
+    KXmlGuiWindow(parent),
+    m_activeDocument(NULL),
+    m_activeTimeline(NULL),
+    m_renderWidget(NULL),
 #ifndef NO_JOGSHUTTLE
-        m_jogProcess(NULL),
+    m_jogProcess(NULL),
 #endif /* NO_JOGSHUTTLE */
-        m_findActivated(false)
+    m_findActivated(false)
 {
 
     // Create DBus interface
@@ -172,41 +172,49 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
 
     m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
     m_projectListDock->setObjectName("project_tree");
-    m_projectList = new ProjectList(this);
+    m_projectList = new ProjectList();
     m_projectListDock->setWidget(m_projectList);
     addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
 
     m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
     m_clipMonitorDock->setObjectName("clip_monitor");
-    m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), this);
+    m_clipMonitor = new Monitor("clip", m_monitorManager, QString());
     m_clipMonitorDock->setWidget(m_clipMonitor);
     addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
 
     m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
     m_projectMonitorDock->setObjectName("project_monitor");
-    m_projectMonitor = new Monitor("project", m_monitorManager, QString(), this);
+    m_projectMonitor = new Monitor("project", m_monitorManager, QString());
     m_projectMonitorDock->setWidget(m_projectMonitor);
     addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
 
 #ifndef Q_WS_MAC
     m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
     m_recMonitorDock->setObjectName("record_monitor");
-    m_recMonitor = new RecMonitor("record", this);
+    m_recMonitor = new RecMonitor("record");
     m_recMonitorDock->setWidget(m_recMonitor);
     addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
     connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
     connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
 #endif
 
+    m_notesDock = new QDockWidget(i18n("Project Notes"), this);
+    m_notesDock->setObjectName("notes_widget");
+    m_notesWidget = new KTextEdit();
+    m_notesWidget->setTabChangesFocus(true);
+    m_notesWidget->setClickMessage(i18n("Enter your project notes here..."));
+    m_notesDock->setWidget(m_notesWidget);
+    addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
+
     m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
     m_effectStackDock->setObjectName("effect_stack");
-    m_effectStack = new EffectStackView(m_projectMonitor, this);
+    m_effectStack = new EffectStackView(m_projectMonitor);
     m_effectStackDock->setWidget(m_effectStack);
     addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
 
     m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
     m_transitionConfigDock->setObjectName("transition");
-    m_transitionConfig = new TransitionSettings(m_projectMonitor, this);
+    m_transitionConfig = new TransitionSettings(m_projectMonitor);
     m_transitionConfigDock->setWidget(m_transitionConfig);
     addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
 
@@ -216,7 +224,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     m_effectListDock->setWidget(m_effectList);
     addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
 
-    m_vectorscope = new Vectorscope(m_projectMonitor, m_clipMonitor, this);
+    m_vectorscope = new Vectorscope(m_projectMonitor, m_clipMonitor);
     m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
     m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
     m_vectorscopeDock->setWidget(m_vectorscope);
@@ -226,7 +234,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
     m_scopesList.append(m_vectorscopeDock);
 
-    m_waveform = new Waveform(m_projectMonitor, m_clipMonitor, this);
+    m_waveform = new Waveform(m_projectMonitor, m_clipMonitor);
     m_waveformDock = new QDockWidget(i18n("Waveform"), this);
     m_waveformDock->setObjectName(m_waveform->widgetName());
     m_waveformDock->setWidget(m_waveform);
@@ -236,7 +244,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
     m_scopesList.append(m_waveformDock);
 
-    m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor, this);
+    m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor);
     m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
     m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
     m_RGBParadeDock->setWidget(m_RGBParade);
@@ -246,7 +254,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
     m_scopesList.append(m_RGBParadeDock);
 
-    m_histogram = new Histogram(m_projectMonitor, m_clipMonitor, this);
+    m_histogram = new Histogram(m_projectMonitor, m_clipMonitor);
     m_histogramDock = new QDockWidget(i18n("Histogram"), this);
     m_histogramDock->setObjectName(m_histogram->widgetName());
     m_histogramDock->setWidget(m_histogram);
@@ -259,7 +267,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
 
     m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
     m_undoViewDock->setObjectName("undo_history");
-    m_undoView = new QUndoView(this);
+    m_undoView = new QUndoView();
     m_undoView->setCleanIcon(KIcon("edit-clear"));
     m_undoView->setEmptyLabel(i18n("Clean"));
     m_undoViewDock->setWidget(m_undoView);
@@ -301,6 +309,16 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
     m_fileRevert->setEnabled(false);
 
+    // Prepare layout actions
+    KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
+    for (int i = 1; i < 5; i++) {
+        KAction *load = new KAction(KIcon(), i18n("Load Layout %1").arg(i), this);
+        load->setData("_" + QString::number(i));
+        layoutActions->addAction("load_layout" + QString::number(i), load);
+        KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
+        save->setData("_" + QString::number(i));
+        layoutActions->addAction("save_layout" + QString::number(i), save);
+    }
 
     setupGUI();
 
@@ -315,6 +333,18 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
     guiFactory()->addClient(sp);*/
 
+
+    QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
+    if (loadLayout)
+        connect(loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
+    QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
+    if (saveLayout)
+        connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
+
+
+    // Load layout names from config file
+    loadLayouts();
+
     loadPlugins();
     loadTranscoders();
     //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
@@ -433,7 +463,6 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     m_timelineContextClipMenu->addMenu(m_transitionsMenu);
     m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
     m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
-    //TODO: re-enable custom effects menu when it is implemented
     m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
 
     m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
@@ -469,6 +498,16 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
         newFile(false);
     }
 
+    if (!clipsToLoad.isEmpty() && m_activeDocument) {
+        QStringList list = clipsToLoad.split(',');
+        QList <QUrl> urls;
+        foreach(QString path, list) {
+            kDebug() << QDir::current().absoluteFilePath(path);
+            urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
+        }
+        m_projectList->slotAddClip(urls);
+    }
+
 #ifndef NO_JOGSHUTTLE
     activateShuttleDevice();
 #endif /* NO_JOGSHUTTLE */
@@ -549,17 +588,17 @@ bool MainWindow::queryClose()
 
 void MainWindow::loadPlugins()
 {
-    foreach(QObject *plugin, QPluginLoader::staticInstances()) {
+    foreach(QObject * plugin, QPluginLoader::staticInstances()) {
         populateMenus(plugin);
     }
 
     QStringList directories = KGlobal::dirs()->findDirs("module", QString());
     QStringList filters;
     filters << "libkdenlive*";
-    foreach(const QString &folder, directories) {
+    foreach(const QString & folder, directories) {
         kDebug() << "Parsing plugin folder: " << folder;
         QDir pluginsDir(folder);
-        foreach(const QString &fileName,
+        foreach(const QString & fileName,
                 pluginsDir.entryList(filters, QDir::Files)) {
             /*
              * Avoid loading the same plugin twice when there is more than one
@@ -593,7 +632,7 @@ void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
                            QActionGroup *actionGroup)
 {
     kDebug() << "// ADD to MENU" << texts;
-    foreach(const QString &text, texts) {
+    foreach(const QString & text, texts) {
         QAction *action = new QAction(text, plugin);
         action->setData(text);
         connect(action, SIGNAL(triggered()), this, member);
@@ -657,7 +696,7 @@ void MainWindow::slotReloadEffects()
     else
         m_customEffectsMenu->setEnabled(true);
 
-    foreach(const QStringList &value, effectsList) {
+    foreach(const QStringList & value, effectsList) {
         action = new QAction(value.at(0), this);
         action->setData(value);
         m_customEffectsMenu->addAction(action);
@@ -726,7 +765,7 @@ void MainWindow::slotFullScreen()
     KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
 }
 
-void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
+void MainWindow::slotAddEffect(const QDomElement effect)
 {
     if (!m_activeDocument) return;
     if (effect.isNull()) {
@@ -734,7 +773,10 @@ void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
         return;
     }
     QDomElement effectToAdd = effect.cloneNode().toElement();
-    m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
+    bool ok;
+    int ix = m_effectStack->isTrackMode(&ok);
+    if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
+    else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
 }
 
 void MainWindow::slotRaiseMonitor(bool clipMonitor)
@@ -805,8 +847,12 @@ void MainWindow::setupActions()
 
     KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
     toolbar->setMovable(false);
+    KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
+    QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
+    QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
+    QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
     statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
-    QString style1 = "QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid #999999;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:checked { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}";
+    QString style1 = QString("QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid transparent;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:hover { background: rgb(%7, %8, %9);border-style: inset; border:1px solid rgb(%7, %8, %9);border-radius: 3px;} QToolButton:checked { background-color: rgb(%1, %2, %3); border-style: inset; border:1px solid rgb(%4, %5, %6);border-radius: 3px;}").arg(buttonBg.red()).arg(buttonBg.green()).arg(buttonBg.blue()).arg(buttonBord.red()).arg(buttonBord.green()).arg(buttonBord.blue()).arg(buttonBord2.red()).arg(buttonBord2.green()).arg(buttonBord2.blue());
     QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
 
     //create edit mode buttons
@@ -1054,6 +1100,10 @@ void MainWindow::setupActions()
     collection->addAction("project_clean", projectClean);
     connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
 
+    KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
+    collection->addAction("project_adjust_profile", projectAdjust);
+    connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
+
     KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
     KShortcut playShortcut;
     playShortcut.setPrimary(Qt::Key_Space);
@@ -1361,6 +1411,9 @@ void MainWindow::setupActions()
     showTitleBar->setChecked(KdenliveSettings::showtitlebars());
     slotShowTitleBars(KdenliveSettings::showtitlebars());
 
+
+    //const QByteArray state = layoutGroup.readEntry("layout1", QByteArray());
+
     /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
     collection->addAction("maximize_current", maxCurrent);
     maxCurrent->setCheckable(true);
@@ -1510,6 +1563,71 @@ void MainWindow::slotDisplayActionMessage(QAction *a)
     statusBar()->showMessage(a->data().toString(), 3000);
 }
 
+void MainWindow::loadLayouts()
+{
+    QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
+    QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
+    if (loadLayout == NULL || saveLayout == NULL) return;
+    KSharedConfigPtr config = KGlobal::config();
+    KConfigGroup layoutGroup(config, "Layouts");
+    QStringList entries = layoutGroup.keyList();
+    QList<QAction *> loadActions = loadLayout->actions();
+    QList<QAction *> saveActions = saveLayout->actions();
+    for (int i = 1; i < 5; i++) {
+        // Rename the layouts actions
+        foreach(const QString & key, entries) {
+            if (key.endsWith(QString("_%1").arg(i))) {
+                // Found previously saved layout
+                QString layoutName = key.section("_", 0, -2);
+                for (int j = 0; j < loadActions.count(); j++) {
+                    if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
+                        loadActions[j]->setText(layoutName);
+                        loadActions[j]->setData(key);
+                        break;
+                    }
+                }
+                for (int j = 0; j < saveActions.count(); j++) {
+                    if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
+                        saveActions[j]->setText(layoutName);
+                        saveActions[j]->setData(key);
+                        break;
+                    }
+                }
+            }
+        }
+    }
+}
+
+void MainWindow::slotLoadLayout(QAction *action)
+{
+    if (!action) return;
+    QString layoutId = action->data().toString();
+    if (layoutId.isEmpty()) return;
+    KSharedConfigPtr config = KGlobal::config();
+    KConfigGroup layouts(config, "Layouts");
+    //QByteArray geom = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
+    QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
+    //restoreGeometry(geom);
+    restoreState(state);
+}
+
+void MainWindow::slotSaveLayout(QAction *action)
+{
+    QString originallayoutName = action->data().toString();
+    int layoutId = originallayoutName.section('_', -1).toInt();
+
+    QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
+    if (layoutName.isEmpty()) return;
+    KSharedConfigPtr config = KGlobal::config();
+    KConfigGroup layouts(config, "Layouts");
+    layouts.deleteEntry(originallayoutName);
+
+    QByteArray st = saveState();
+    layoutName.append("_" + QString::number(layoutId));
+    layouts.writeEntry(layoutName, st.toBase64());
+    loadLayouts();
+}
+
 void MainWindow::saveOptions()
 {
     KdenliveSettings::self()->writeConfig();
@@ -1571,21 +1689,27 @@ void MainWindow::slotRunWizard()
 
 void MainWindow::newFile(bool showProjectSettings, bool force)
 {
-    if (!m_timelineArea->isEnabled() && !force) return;
+    if (!m_timelineArea->isEnabled() && !force)
+        return;
     m_fileRevert->setEnabled(false);
-    QString profileName;
-    KUrl projectFolder;
+    QString profileName = KdenliveSettings::default_profile();
+    KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
     QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
     if (!showProjectSettings) {
-        if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
-        profileName = KdenliveSettings::default_profile();
-        projectFolder = KdenliveSettings::defaultprojectfolder();
+        if (!KdenliveSettings::activatetabs())
+            if (!closeCurrentDocument())
+                return;
     } else {
         ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
-        if (w->exec() != QDialog::Accepted) return;
-        if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
-        if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
-        if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
+        if (w->exec() != QDialog::Accepted)
+            return;
+        if (!KdenliveSettings::activatetabs())
+            if (!closeCurrentDocument())
+                return;
+        if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
+            slotSwitchVideoThumbs();
+        if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
+            slotSwitchAudioThumbs();
         profileName = w->selectedProfile();
         projectFolder = w->selectedFolder();
         projectTracks = w->tracks();
@@ -1593,7 +1717,7 @@ void MainWindow::newFile(bool showProjectSettings, bool force)
     }
     m_timelineArea->setEnabled(true);
     m_projectList->setEnabled(true);
-    KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
+    KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, m_notesWidget, this);
     doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
     bool ok;
     TrackView *trackView = new TrackView(doc, &ok, this);
@@ -1608,7 +1732,8 @@ void MainWindow::newFile(bool showProjectSettings, bool force)
     if (m_timelineArea->count() == 1) {
         connectDocumentInfo(doc);
         connectDocument(trackView, doc);
-    } else m_timelineArea->setTabBarHidden(false);
+    } else
+        m_timelineArea->setTabBarHidden(false);
     m_monitorManager->activateMonitor("clip");
     m_closeAction->setEnabled(m_timelineArea->count() > 1);
 }
@@ -1783,7 +1908,7 @@ void MainWindow::openFile(const KUrl &url)
             return;
         } else {
             // remove the stale files
-            foreach(KAutoSaveFile *stale, staleFiles) {
+            foreach(KAutoSaveFile * stale, staleFiles) {
                 stale->open(QIODevice::ReadWrite);
                 delete stale;
             }
@@ -1798,7 +1923,7 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
 {
     if (!m_timelineArea->isEnabled()) return;
     m_fileRevert->setEnabled(true);
-    KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
+    KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this);
     if (stale == NULL) {
         stale = new KAutoSaveFile(url, doc);
         doc->m_autosave = stale;
@@ -1833,7 +1958,7 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
 
 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
 {
-    foreach(KAutoSaveFile *stale, staleFiles) {
+    foreach(KAutoSaveFile * stale, staleFiles) {
         /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
                   // show an error message; we could not steal the lockfile
                   // maybe another application got to the file before us?
@@ -1959,41 +2084,42 @@ void MainWindow::slotEditProjectSettings()
         if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
         if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
         if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
-        if (m_activeDocument->profilePath() != profile) {
-            // Profile was changed
-            double dar = m_activeDocument->dar();
-
-            // Deselect current effect / transition
-            m_effectStack->slotClipItemSelected(NULL, 0);
-            m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
-            m_clipMonitor->slotSetXml(NULL);
-            bool updateFps = m_activeDocument->setProfilePath(profile);
-            KdenliveSettings::setCurrent_profile(profile);
-            KdenliveSettings::setProject_fps(m_activeDocument->fps());
-            setCaption(m_activeDocument->description(), m_activeDocument->isModified());
-
-            m_activeDocument->clipManager()->clearUnusedProducers();
-            m_monitorManager->resetProfiles(m_activeDocument->timecode());
-
-            m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
-            m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
-            m_projectList->updateProjectFormat(m_activeDocument->timecode());
-            if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
-            m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
-            //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
-            if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
-            if (updateFps) m_activeTimeline->updateProjectFps();
-            m_activeDocument->setModified(true);
-            m_commandStack->activeStack()->clear();
-            //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
-            slotUpdateMousePosition(0);
-            // We need to desactivate & reactivate monitors to get a refresh
-            //m_monitorManager->switchMonitors();
-        }
+        if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
     }
     delete w;
 }
 
+void MainWindow::slotUpdateProjectProfile(const QString &profile)
+{
+    double dar = m_activeDocument->dar();
+
+    // Deselect current effect / transition
+    m_effectStack->slotClipItemSelected(NULL, 0);
+    m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
+    m_clipMonitor->slotSetXml(NULL);
+    bool updateFps = m_activeDocument->setProfilePath(profile);
+    KdenliveSettings::setCurrent_profile(profile);
+    KdenliveSettings::setProject_fps(m_activeDocument->fps());
+    setCaption(m_activeDocument->description(), m_activeDocument->isModified());
+
+    m_activeDocument->clipManager()->clearUnusedProducers();
+    m_monitorManager->resetProfiles(m_activeDocument->timecode());
+    m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
+    m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
+    m_projectList->updateProjectFormat(m_activeDocument->timecode());
+    if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
+    m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
+    //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
+    if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
+    if (updateFps) m_activeTimeline->updateProjectFps();
+    m_activeDocument->setModified(true);
+    m_commandStack->activeStack()->clear();
+    //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
+    slotUpdateMousePosition(0);
+    // We need to desactivate & reactivate monitors to get a refresh
+    //m_monitorManager->switchMonitors();
+}
+
 
 void MainWindow::slotRenderProject()
 {
@@ -2094,8 +2220,11 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
             disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
             disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
             disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
+            disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
             disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
             disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
+            disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
+
             disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
 
             disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
@@ -2150,6 +2279,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
 
     connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
+    connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
     connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
 
     connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
@@ -2179,7 +2309,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
     connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
     connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
-
+    connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
 
     connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
     connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
@@ -2709,6 +2839,9 @@ void MainWindow::slotFitZoom()
 
 void MainWindow::slotSetZoom(int value)
 {
+    value = qMax(m_zoomSlider->minimum(), value);
+    value = qMin(m_zoomSlider->maximum(), value);
+
     if (m_activeTimeline)
         m_activeTimeline->slotChangeZoom(value);
 
@@ -2835,6 +2968,8 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
         //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
         return;
     }
+
+    // any type of clip but a title
     ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
     connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
     if (dia.exec() == QDialog::Accepted) {
@@ -2842,6 +2977,7 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
         if (newprops.isEmpty()) return;
         EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
         m_activeDocument->commandStack()->push(command);
+        m_activeDocument->setModified();
 
         if (dia.needsTimelineRefresh()) {
             // update clip occurences in timeline
@@ -3229,7 +3365,7 @@ int MainWindow::getNewStuff(const QString &configFile)
     KNS3::DownloadDialog dialog(configFile);
     dialog.exec();
     entries = dialog.changedEntries();
-    foreach(const KNS3::Entry &entry, entries) {
+    foreach(const KNS3::Entry & entry, entries) {
         if (entry.status() == KNS3::Entry::Installed)
             kDebug() << "// Installed files: " << entry.installedFiles();
     }
@@ -3237,7 +3373,7 @@ int MainWindow::getNewStuff(const QString &configFile)
     KNS::Engine engine(0);
     if (engine.init(configFile))
         entries = engine.downloadDialogModal(this);
-    foreach(KNS::Entry *entry, entries) {
+    foreach(KNS::Entry * entry, entries) {
         if (entry->status() == KNS::Entry::Installed)
             kDebug() << "// Installed files: " << entry->installedFiles();
     }
@@ -3549,17 +3685,18 @@ void MainWindow::slotChangePalette(QAction *action, const QString &themename)
     kapp->setPalette(plt);
     const QObjectList children = statusBar()->children();
 
-    foreach(QObject *child, children) {
+    foreach(QObject * child, children) {
         if (child->isWidgetType())
             ((QWidget*)child)->setPalette(plt);
         const QObjectList subchildren = child->children();
-        foreach(QObject *subchild, subchildren) {
+        foreach(QObject * subchild, subchildren) {
             if (subchild->isWidgetType())
                 ((QWidget*)subchild)->setPalette(plt);
         }
     }
-    if (m_activeTimeline)
+    if (m_activeTimeline) {
         m_activeTimeline->projectView()->updatePalette();
+    }
 }