]> git.sesse.net Git - kdenlive/commitdiff
Allow to display several clip properties, force clip properties can be applied withou...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 14 Oct 2010 23:16:36 +0000 (23:16 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 14 Oct 2010 23:16:36 +0000 (23:16 +0000)
svn path=/trunk/kdenlive/; revision=5004

src/clipproperties.cpp
src/clipproperties.h
src/mainwindow.cpp
src/mainwindow.h
src/monitormanager.cpp
src/monitormanager.h
src/widgets/clipproperties_ui.ui

index 157250c0e03c04eae8a48dfc2185f345a7ba3133..f2e07813d53b84bf7a6615b2d6d004ef81fb8db0 100644 (file)
@@ -47,15 +47,18 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
     m_fps(fps),
     m_count(0),
     m_clipNeedsRefresh(false),
-    m_clipNeedsReLoad(false)
+    m_clipNeedsReLoad(false),
+    m_propsDelegate(NULL)
 {
+    setAttribute(Qt::WA_DeleteOnClose, true);
     setFont(KGlobalSettings::toolBarFont());
     m_view.setupUi(this);
     KUrl url = m_clip->fileURL();
     m_view.clip_path->setText(url.path());
     m_view.clip_description->setText(m_clip->description());
-    QMap <QString, QString> props = m_clip->properties();
+    connect(m_view.clip_description, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
 
+    QMap <QString, QString> props = m_clip->properties();
     m_view.clip_force_out->setHidden(true);
     m_view.clip_out->setHidden(true);
 
@@ -63,37 +66,49 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
         m_view.clip_force_ar->setChecked(true);
         m_view.clip_ar->setEnabled(true);
         m_view.clip_ar->setValue(props.value("force_aspect_ratio").toDouble());
-    }
+    } else if (props.contains("aspect_ratio")) m_view.clip_ar->setValue(props.value("aspect_ratio").toDouble());
+    connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+    connect(m_view.clip_ar, SIGNAL(valueChanged(double)), this, SLOT(slotModified()));
 
     if (props.contains("force_fps") && props.value("force_fps").toDouble() > 0) {
         m_view.clip_force_framerate->setChecked(true);
         m_view.clip_framerate->setEnabled(true);
         m_view.clip_framerate->setValue(props.value("force_fps").toDouble());
     }
+    connect(m_view.clip_force_framerate, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+    connect(m_view.clip_framerate, SIGNAL(valueChanged(double)), this, SLOT(slotModified()));
 
     if (props.contains("force_progressive")) {
         m_view.clip_force_progressive->setChecked(true);
         m_view.clip_progressive->setEnabled(true);
         m_view.clip_progressive->setValue(props.value("force_progressive").toInt());
     }
+    connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+    connect(m_view.clip_progressive, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
 
     if (props.contains("threads") && props.value("threads").toInt() != 1) {
         m_view.clip_force_threads->setChecked(true);
         m_view.clip_threads->setEnabled(true);
         m_view.clip_threads->setValue(props.value("threads").toInt());
     }
+    connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+    connect(m_view.clip_threads, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
 
     if (props.contains("video_index") && props.value("video_index").toInt() != 0) {
         m_view.clip_force_vindex->setChecked(true);
         m_view.clip_vindex->setEnabled(true);
         m_view.clip_vindex->setValue(props.value("video_index").toInt());
     }
+    connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+    connect(m_view.clip_vindex, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
 
     if (props.contains("audio_index") && props.value("audio_index").toInt() != 0) {
         m_view.clip_force_aindex->setChecked(true);
         m_view.clip_aindex->setEnabled(true);
         m_view.clip_aindex->setValue(props.value("audio_index").toInt());
     }
+    connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+    connect(m_view.clip_aindex, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
 
     if (props.contains("audio_max")) {
         m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
@@ -147,6 +162,7 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
             m_view.image_size->setText(props.value("frame_size"));
         if (props.contains("transparency"))
             m_view.image_transparency->setChecked(props.value("transparency").toInt());
+        connect(m_view.image_transparency, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
         int width = 180.0 * KdenliveSettings::project_display_ratio();
         if (width % 2 == 1) width++;
         m_view.clip_thumb->setPixmap(QPixmap(url.path()).scaled(QSize(width, 180), Qt::KeepAspectRatio));
@@ -159,6 +175,7 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
         m_view.tabWidget->removeTab(VIDEOTAB);
         m_view.clip_thumb->setHidden(true);
         m_view.clip_color->setColor(QColor('#' + props.value("colour").right(8).left(6)));
+        connect(m_view.clip_color, SIGNAL(changed(QColor)), this, SLOT(slotModified()));
     } else if (t == SLIDESHOW) {
         bool isMime = true;
         if (url.fileName().startsWith(".all.")) {
@@ -254,10 +271,23 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
         } else m_view.luma_file->setEnabled(false);
         slotEnableLuma(m_view.slide_fade->checkState());
         slotEnableLumaFile(m_view.slide_luma->checkState());
+
+        connect(m_view.slide_fade, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+        connect(m_view.slide_luma, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+        connect(m_view.slide_loop, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+        connect(m_view.slide_crop, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+        connect(m_view.slide_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
+        connect(m_view.slide_duration_frames, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
+        connect(m_view.luma_duration, SIGNAL(textChanged(QString)), this, SLOT(slotModified()));
+        connect(m_view.luma_softness, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
+        connect(m_view.luma_file, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
+        connect(m_view.animation, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
+
+
         connect(m_view.slide_fade, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLuma(int)));
         connect(m_view.slide_luma, SIGNAL(stateChanged(int)), this, SLOT(slotEnableLumaFile(int)));
-
         connect(m_view.image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(parseFolder()));
+
     } else if (t != AUDIO) {
         m_view.tabWidget->removeTab(IMAGETAB);
         m_view.tabWidget->removeTab(SLIDETAB);
@@ -330,6 +360,9 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
     connect(m_view.marker_delete, SIGNAL(clicked()), this, SLOT(slotDeleteMarker()));
     connect(m_view.markers_list, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotEditMarker()));
 
+    connect(this, SIGNAL(accepted()), this, SLOT(slotApplyProperties()));
+    connect(m_view.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotApplyProperties()));
+    m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
     //adjustSize();
 }
 
@@ -433,9 +466,32 @@ ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap
 
 ClipProperties::~ClipProperties()
 {
-    delete m_propsDelegate;
+    if (m_propsDelegate) delete m_propsDelegate;
 }
 
+void ClipProperties::slotApplyProperties()
+{
+    if (m_clip != NULL)
+        emit applyNewClipProperties(m_clip->getId(), m_clip->properties(), properties(), needsTimelineRefresh(), needsTimelineReload());
+    m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
+}
+
+void ClipProperties::disableClipId(const QString &id)
+{
+    if (m_clip && m_view.buttonBox->button(QDialogButtonBox::Ok)->isEnabled()) {
+        if (m_clip->getId() == id) {
+            // clip was removed from project, close this properties dialog
+            close();
+        }
+    }
+}
+
+void ClipProperties::slotModified()
+{
+    m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
+}
+
+
 void ClipProperties::slotEnableLuma(int state)
 {
     bool enable = false;
@@ -725,6 +781,7 @@ void ClipProperties::parseFolder()
     }
 
     m_count = result.count();
+    m_view.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(m_count > 0);
     if (m_count == 0) {
         // no images, do not accept that
         m_view.slide_info->setText(i18n("No image found"));
index d10dfb7eb90e07ee3f63171468bc6bd769e62113..8cac7e0c67267320ecc4bf0641126131e2c02097 100644 (file)
@@ -54,7 +54,8 @@ public:
     const QString &clipId() const;
     bool needsTimelineRefresh() const;
     bool needsTimelineReload() const;
-
+    void disableClipId(const QString &id);
+    
 private slots:
     void parseFolder();
     void slotAddMarker();
@@ -65,6 +66,8 @@ private slots:
     void slotEnableLuma(int state);
     void slotEnableLumaFile(int state);
     void slotUpdateDurationFormat(int ix);
+    void slotApplyProperties();
+    void slotModified();
 
 private:
     Ui::ClipProperties_UI m_view;
@@ -83,6 +86,7 @@ private:
 
 signals:
     void addMarker(const QString &, GenTime, QString);
+    void applyNewClipProperties(const QString, QMap <QString, QString> , QMap <QString, QString> , bool, bool);
 };
 
 
index 9d56296f13737b8e0b4b5b78da859563ea06ab9a..c4ce5d220a871aed7e4223bf2b88d5625c14bc66 100644 (file)
@@ -276,11 +276,11 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
     m_audiosignalDock->setObjectName("audiosignal");
     m_audiosignalDock->setWidget(m_audiosignal);
     addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
-    if (m_projectMonitor){
-       connect(m_projectMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)) );
+    if (m_projectMonitor) {
+        connect(m_projectMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
     }
-    if (m_clipMonitor){
-       connect(m_clipMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)) );
+    if (m_clipMonitor) {
+        connect(m_clipMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
     }
     //connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
     //connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
@@ -2297,7 +2297,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
             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()));
-            disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
+            disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
             disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
             disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
             disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
@@ -2334,7 +2334,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
         }
         //m_activeDocument->setRenderer(NULL);
         disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
-        disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
+        disconnect(m_projectList, SIGNAL(refreshClip()), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
         m_clipMonitor->stop();
     }
     KdenliveSettings::setCurrent_profile(doc->profilePath());
@@ -2344,7 +2344,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
     m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
     connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
-    connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
+    connect(m_projectList, SIGNAL(refreshClip()), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
     connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
 
     connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
@@ -2371,7 +2371,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
 
     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 &)));
+    connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
     connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
     connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
 
@@ -3075,19 +3075,23 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
     }
 
     // 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) {
-        QMap <QString, QString> newprops = dia.properties();
-        if (newprops.isEmpty()) return;
-        EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
-        m_activeDocument->commandStack()->push(command);
-        m_activeDocument->setModified();
+    ClipProperties *dia = new ClipProperties(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)));
+    connect(dia, SIGNAL(applyNewClipProperties(const QString, QMap <QString, QString> , QMap <QString, QString> , bool, bool)), this, SLOT(slotApplyNewClipProperties(const QString, QMap <QString, QString> , QMap <QString, QString> , bool, bool)));
+    dia->show();
+}
 
-        if (dia.needsTimelineRefresh()) {
-            // update clip occurences in timeline
-            m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
-        }
+
+void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
+{
+    if (newprops.isEmpty()) return;
+    EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
+    m_activeDocument->commandStack()->push(command);
+    m_activeDocument->setModified();
+
+    if (refresh) {
+        // update clip occurences in timeline
+        m_activeTimeline->projectView()->slotUpdateClip(id, reload);
     }
 }
 
@@ -3890,11 +3894,11 @@ void MainWindow::slotShowTitleBars(bool show)
 {
     QList <QDockWidget *> docks = findChildren<QDockWidget *>();
     for (int i = 0; i < docks.count(); i++) {
-        QDockWidget* dock=docks.at(i);
-        if (show){
-            dock->setTitleBarWidget(0);        
-        }else{
-            if (!dock->isFloating()){
+        QDockWidget* dock = docks.at(i);
+        if (show) {
+            dock->setTitleBarWidget(0);
+        } else {
+            if (!dock->isFloating()) {
                 dock->setTitleBarWidget(new QWidget);
             }
         }
@@ -3977,11 +3981,21 @@ void MainWindow::slotUpdateColorScopes()
 void MainWindow::slotOpenStopmotion()
 {
     if (m_stopmotion == NULL) {
-       m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), this);
-       connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
+        m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), this);
+        connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
     }
     m_stopmotion->show();
 }
 
+
+void MainWindow::slotDeleteClip(const QString &id)
+{
+    QList <ClipProperties *> list = findChildren<ClipProperties *>();
+    for (int i = 0; i < list.size(); ++i) {
+        list.at(i)->disableClipId(id);
+    }
+    m_projectList->slotDeleteClip(id);
+}
+
 #include "mainwindow.moc"
 
index 1f3bcfb9ea88f22548aac38ffa9f545640285bfd..a637c40b07c001ae14e5eec3ef5991a634da6c98 100644 (file)
@@ -492,6 +492,12 @@ private slots:
     /** @brief Update the capture folder if user asked a change. */
     void slotUpdateCaptureFolder();
 
+    /** @brief Apply new properties to a clip */
+    void slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload);
+
+    /** @brief Delete a clip from current project */
+    void slotDeleteClip(const QString &id);
+
     /** @brief Saves the widgets layout */
     void slotSaveLayout(QAction*);
     void slotLoadLayout(QAction*);
index b482a92f5e73b0649b7ff455c4d598c3aec84467..6da71c26a0e20eab430326ebb4478cb21a1b68d3 100644 (file)
@@ -169,5 +169,10 @@ void MonitorManager::slotResetProfiles()
     activateMonitor(active);
 }
 
+void MonitorManager::slotRefreshCurrentMonitor()
+{
+    if (m_clipMonitor->isActive()) m_clipMonitor->refreshMonitor();
+    else m_projectMonitor->refreshMonitor();
+}
 
 #include "monitormanager.moc"
index 31bd5093e9e61eb95cf6cd4c30e24d2c284129b8..ae2bd95fb8dcae74f7bd4b10e23e9487253efceb 100644 (file)
@@ -60,6 +60,9 @@ public slots:
      * @param activateClip whether to activate the clip monitor */
     void slotSwitchMonitors(bool activateClip);
 
+private slots:
+    void slotRefreshCurrentMonitor();
+
 private:
     Monitor *m_clipMonitor;
     Monitor *m_projectMonitor;
index 6b7304297391d3f0ae08080ab6c75c7a409f3532..a5cb70b6a614a20595116c30dd386faddc58d5f0 100644 (file)
@@ -85,7 +85,7 @@
       <enum>Qt::Horizontal</enum>
      </property>
      <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+      <set>QDialogButtonBox::Apply|QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
      </property>
     </widget>
    </item>