From 0ba0dd5673a94feb8341fe64afd9e0f7c57a31f0 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Thu, 14 Oct 2010 23:16:36 +0000 Subject: [PATCH] Allow to display several clip properties, force clip properties can be applied without closing properties dialog svn path=/trunk/kdenlive/; revision=5004 --- src/clipproperties.cpp | 67 ++++++++++++++++++++++++++++--- src/clipproperties.h | 6 ++- src/mainwindow.cpp | 68 +++++++++++++++++++------------- src/mainwindow.h | 6 +++ src/monitormanager.cpp | 5 +++ src/monitormanager.h | 3 ++ src/widgets/clipproperties_ui.ui | 2 +- 7 files changed, 123 insertions(+), 34 deletions(-) diff --git a/src/clipproperties.cpp b/src/clipproperties.cpp index 157250c0..f2e07813 100644 --- a/src/clipproperties.cpp +++ b/src/clipproperties.cpp @@ -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 props = m_clip->properties(); + connect(m_view.clip_description, SIGNAL(textChanged(QString)), this, SLOT(slotModified())); + QMap 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 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")); diff --git a/src/clipproperties.h b/src/clipproperties.h index d10dfb7e..8cac7e0c 100644 --- a/src/clipproperties.h +++ b/src/clipproperties.h @@ -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 , QMap , bool, bool); }; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9d56296f..c4ce5d22 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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 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 , QMap , bool, bool)), this, SLOT(slotApplyNewClipProperties(const QString, QMap , QMap , 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 props, QMap 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 docks = findChildren(); 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 list = findChildren(); + for (int i = 0; i < list.size(); ++i) { + list.at(i)->disableClipId(id); + } + m_projectList->slotDeleteClip(id); +} + #include "mainwindow.moc" diff --git a/src/mainwindow.h b/src/mainwindow.h index 1f3bcfb9..a637c40b 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -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 props, QMap 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*); diff --git a/src/monitormanager.cpp b/src/monitormanager.cpp index b482a92f..6da71c26 100644 --- a/src/monitormanager.cpp +++ b/src/monitormanager.cpp @@ -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" diff --git a/src/monitormanager.h b/src/monitormanager.h index 31bd5093..ae2bd95f 100644 --- a/src/monitormanager.h +++ b/src/monitormanager.h @@ -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; diff --git a/src/widgets/clipproperties_ui.ui b/src/widgets/clipproperties_ui.ui index 6b730429..a5cb70b6 100644 --- a/src/widgets/clipproperties_ui.ui +++ b/src/widgets/clipproperties_ui.ui @@ -85,7 +85,7 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Close|QDialogButtonBox::Ok -- 2.39.2