]> git.sesse.net Git - kdenlive/blobdiff - src/mainwindow.cpp
Fix template title clips & some other title issues
[kdenlive] / src / mainwindow.cpp
index 24d444c350e0a7a491d2407f0a70be4b61884548..e4e2bf04a91c89ac2c457239002ddbb3afbd99b3 100644 (file)
@@ -194,6 +194,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     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);
@@ -202,6 +203,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
 
     connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
     connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
+#endif
 
     m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
     m_undoViewDock->setObjectName("undo_history");
@@ -226,7 +228,9 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
 
 
     tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
+#ifndef Q_WS_MAC
     tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
+#endif
     setCentralWidget(m_timelineArea);
 
 
@@ -355,7 +359,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
     //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
     connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
-    connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
+    connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
     connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
 
     m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
@@ -384,6 +388,8 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
 void MainWindow::queryQuit()
 {
     if (queryClose()) {
+        if (m_projectMonitor) m_projectMonitor->stop();
+        if (m_clipMonitor) m_clipMonitor->stop();
         delete m_effectStack;
         delete m_activeTimeline;
         delete m_projectMonitor;
@@ -520,9 +526,12 @@ void MainWindow::readProperties(const KConfigGroup &config)
 
 void MainWindow::slotReloadEffects()
 {
-    initEffects::parseCustomEffectsFile();
+    kDebug() << "START RELOAD; COUNR: " << m_customEffectsMenu->actions().count();
     m_customEffectsMenu->clear();
+    kDebug() << "START RELOAD; CLR: " << m_customEffectsMenu->actions().count();
+    initEffects::parseCustomEffectsFile();
     const QStringList effects = customEffects.effectNames();
+    kDebug() << "NEW EFFS: " << effects;
     QAction *action;
     if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
     else m_customEffectsMenu->setEnabled(true);
@@ -596,14 +605,15 @@ void MainWindow::slotFullScreen()
     KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
 }
 
-void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track)
+void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
 {
     if (!m_activeDocument) return;
     if (effect.isNull()) {
         kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
         return;
     }
-    m_activeTimeline->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
+    QDomElement effectToAdd = effect.cloneNode().toElement();
+    m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
 }
 
 void MainWindow::slotRaiseMonitor(bool clipMonitor)
@@ -624,7 +634,7 @@ void MainWindow::slotConnectMonitors()
     m_projectList->setRenderer(m_projectMonitor->render);
     connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
     connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
-    connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &, bool)));
+    connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, bool)));
     connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
     connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)));
 
@@ -738,7 +748,11 @@ void MainWindow::setupActions()
     m_zoomSlider->setMaximumWidth(150);
     m_zoomSlider->setMinimumWidth(100);
 
+#ifdef Q_WS_MAC
+    const int contentHeight = QFontMetrics(w->font()).height() + 14;
+#else
     const int contentHeight = QFontMetrics(w->font()).height() + 8;
+#endif
 
     QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
     style.append("QSlider::handle:horizontal {  background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
@@ -838,19 +852,11 @@ void MainWindow::setupActions()
     collection->addAction("manage_profiles", profilesAction);
     connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
 
-#if KDE_IS_VERSION(4,3,63)
-    KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), QString("get_new_lumas"));
-
-    KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), QString("get_new_profiles"));
-
-    KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), QString("get_new_mlt_profiles"));
-#else
     KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
 
     KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
 
     KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
-#endif
 
     KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
     collection->addAction("run_wizard", wizAction);
@@ -1744,7 +1750,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
             disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
             disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
 
-
             disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
             disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
             disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
@@ -1803,6 +1808,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
     connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
     connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
+
     connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
     connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
     connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
@@ -1851,7 +1857,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     //doc->setRenderer(m_projectMonitor->render);
     m_commandStack->setActiveStack(doc->commandStack());
     KdenliveSettings::setProject_display_ratio(doc->dar());
-    m_projectList->updateAllClips();
     //doc->clipManager()->checkAudioThumbs();
 
     //m_overView->setScene(trackView->projectScene());
@@ -1862,6 +1867,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     m_saveAction->setEnabled(doc->isModified());
     m_activeDocument = doc;
     m_activeTimeline->updateProjectFps();
+    m_projectList->updateAllClips();
     if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
 
     // set tool to select tool
@@ -1897,7 +1903,9 @@ void MainWindow::slotPreferences(int page, int option)
     //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
     connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
     connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
+#ifndef Q_WS_MAC
     connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
+#endif
     //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
     dialog->show();
     if (page != -1) dialog->showPage(page, option);
@@ -2253,7 +2261,7 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
 {
     if (clip->clipType() == TEXT) {
         QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
-        if (!clip->getProperty("xmltemplate").isEmpty()) {
+        if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
             // template text clip
 
             // Get the list of existing templates
@@ -2265,7 +2273,7 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
             Ui::TemplateClip_UI dia_ui;
             dia_ui.setupUi(dia);
             int ix = -1;
-            const QString templatePath = clip->getProperty("xmltemplate");
+            const QString templatePath = clip->getProperty("resource");
             for (int i = 0; i < templateFiles.size(); ++i) {
                 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
                 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
@@ -2277,7 +2285,6 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
             KUrl startDir(titlepath);
             dia_ui.template_list->fileDialog()->setUrl(startDir);
             dia_ui.description->setText(clip->getProperty("description"));
-            dia_ui.clone_clip->setChecked(true);
             if (dia->exec() == QDialog::Accepted) {
                 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
                 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
@@ -2286,7 +2293,7 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
 
                 if (KUrl(textTemplate).path() != templatePath) {
                     // The template was changed
-                    newprops.insert("xmltemplate", textTemplate);
+                    newprops.insert("resource", textTemplate);
                 }
 
                 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
@@ -2299,11 +2306,9 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
                 // template modified we need to update xmldata
                 QString description = newprops.value("description");
                 if (description.isEmpty()) description = clip->getProperty("description");
-                newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
-                if (dia_ui.normal_clip->isChecked()) {
-                    // Switch clip to normal clip
-                    newprops.insert("xmltemplate", QString());
-                }
+                else newprops.insert("templatetext", description);
+                //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
+
                 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
                 m_activeDocument->commandStack()->push(command);
             }
@@ -2315,11 +2320,9 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
         doc.setContent(clip->getProperty("xmldata"));
         dia_ui->setXml(doc);
         if (dia_ui->exec() == QDialog::Accepted) {
-            QRect rect = dia_ui->renderedRect();
             QMap <QString, QString> newprops;
             newprops.insert("xmldata", dia_ui->xml().toString());
             newprops.insert("out", QString::number(dia_ui->duration()));
-            newprops.insert("frame_size", QString::number(rect.width()) + 'x' + QString::number(rect.height()));
             EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
             m_activeDocument->commandStack()->push(command);
             m_activeTimeline->projectView()->slotUpdateClip(clip->getId());