aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-04-20 21:29:22 +0200
committerJean-Baptiste Mardelle <[email protected]>2015-04-20 21:29:22 +0200
commit06b6ce8b30e7fdad16ece6b615db99239f27fd1a (patch)
tree830fa273f4b669f3d750d15af30ed21c5fc441a2
parentd95adf6f85b5d5871f935ab5ca1dacbf900f3e1a (diff)
Reintroduce title clip editing, fix osx compile warnings
-rw-r--r--src/bin/bin.cpp50
-rw-r--r--src/bin/bin.h1
-rw-r--r--src/bin/projectclip.cpp20
-rw-r--r--src/bin/projectclip.h1
-rw-r--r--src/timeline/customtrackview.cpp5
-rw-r--r--src/timeline/track.cpp2
6 files changed, 75 insertions, 4 deletions
diff --git a/src/bin/bin.cpp b/src/bin/bin.cpp
index b1ca1bb..3973565 100644
--- a/src/bin/bin.cpp
+++ b/src/bin/bin.cpp
@@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "monitor/monitor.h"
#include "doc/kdenlivedoc.h"
#include "dialogs/clipcreationdialog.h"
+#include "titler/titlewidget.h"
#include "core.h"
#include "mltcontroller/clipcontroller.h"
#include "mltcontroller/clippropertiescontroller.h"
@@ -1043,6 +1044,16 @@ void Bin::slotSwitchClipProperties(const QModelIndex &ix)
void Bin::showClipProperties(ProjectClip *clip)
{
closeEditing();
+ // Special case: text clips open title widget
+ if (clip->clipType() == Text) {
+ // Cleanup widget for new content
+ foreach (QWidget * w, m_propertiesPanel->findChildren<ClipPropertiesController*>()) {
+ delete w;
+ }
+ showTitleWidget(clip);
+ m_collapser->collapse();
+ return;
+ }
QString panelId = m_propertiesPanel->property("clipId").toString();
if (!clip || m_propertiesPanel->width() == 0) {
m_propertiesPanel->setProperty("clipId", QVariant());
@@ -1061,6 +1072,7 @@ void Bin::showClipProperties(ProjectClip *clip)
delete w;
}
m_propertiesPanel->setProperty("clipId", clip->clipId());
+
QVBoxLayout *lay = (QVBoxLayout*) m_propertiesPanel->layout();
if (lay == 0) {
lay = new QVBoxLayout(m_propertiesPanel);
@@ -1949,3 +1961,41 @@ void Bin::deleteAllClipMarkers(const QString &id)
else delete command;
}
+// TODO: move title editing into a better place...
+void Bin::showTitleWidget(ProjectClip *clip)
+{
+ QString path = clip->getProducerProperty("resource");
+ QString titlepath = m_doc->projectFolder().path() + QDir::separator() + "titles/";
+ QPointer<TitleWidget> dia_ui = new TitleWidget(QUrl(), m_doc->timecode(), titlepath, pCore->monitorManager()->projectMonitor()->render, pCore->window());
+ QDomDocument doc;
+ doc.setContent(clip->getProducerProperty("xmldata"));
+ dia_ui->setXml(doc);
+ if (dia_ui->exec() == QDialog::Accepted) {
+ QMap <QString, QString> newprops;
+ newprops.insert("xmldata", dia_ui->xml().toString());
+ if (dia_ui->duration() != clip->duration().frames(m_doc->fps())) {
+ // duration changed, we need to update duration
+ newprops.insert("out", QString::number(dia_ui->duration() - 1));
+ int currentLength = clip->getProducerIntProperty("length");
+ if (currentLength <= dia_ui->duration()) {
+ newprops.insert("length", QString::number(dia_ui->duration()));
+ } else {
+ newprops.insert("length", clip->getProducerProperty("length"));
+ }
+ }
+ // trigger producer reload
+ newprops.insert("force_reload", "2");
+ if (!path.isEmpty()) {
+ // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
+ if (KMessageBox::questionYesNo(pCore->window(), i18n("You are editing an external title clip (%1). Do you want to save your changes to the title file or save the changes for this project only?", path), i18n("Save Title"), KGuiItem(i18n("Save to title file")), KGuiItem(i18n("Save in project only"))) == KMessageBox::Yes) {
+ // save to external file
+ dia_ui->saveTitle(QUrl::fromLocalFile(path));
+ } else {
+ newprops.insert("resource", QString());
+ }
+ }
+ slotEditClipCommand(clip->clipId(), clip->currentProperties(newprops), newprops);
+ }
+ delete dia_ui;
+}
+
diff --git a/src/bin/bin.h b/src/bin/bin.h
index c43b7a6..206bf4d 100644
--- a/src/bin/bin.h
+++ b/src/bin/bin.h
@@ -525,6 +525,7 @@ private:
/** @brief Get the QModelIndex value for an item in the Bin. */
QModelIndex getIndexForId(const QString &id, bool folderWanted) const;
ProjectClip *getFirstSelectedClip();
+ void showTitleWidget(ProjectClip *clip);
signals:
void itemUpdated(AbstractProjectItem*);
diff --git a/src/bin/projectclip.cpp b/src/bin/projectclip.cpp
index 6ec4550..745a0b4 100644
--- a/src/bin/projectclip.cpp
+++ b/src/bin/projectclip.cpp
@@ -330,6 +330,20 @@ void ProjectClip::setProducerProperty(const QString &name, const QString &data)
}
}
+QMap <QString, QString> ProjectClip::currentProperties(const QMap <QString, QString> &props)
+{
+ QMap <QString, QString> currentProps;
+ if (!m_controller) {
+ return currentProps;
+ }
+ QMap<QString, QString>::const_iterator i = props.constBegin();
+ while (i != props.constEnd()) {
+ currentProps.insert(i.key(), m_controller->property(i.key()));
+ ++i;
+ }
+ return currentProps;
+}
+
QColor ProjectClip::getProducerColorProperty(const QString &key) const
{
if (m_controller) {
@@ -442,10 +456,13 @@ void ProjectClip::setProperties(QMap <QString, QString> properties, bool refresh
//reloadProducer(true);
}
else {
- reloadProducer(true);
+ reloadProducer();
}
refreshProducer = true;
}
+ if (properties.contains("xmldata")) {
+ refreshProducer = true;
+ }
if (properties.contains("length")) {
m_duration = m_controller->getStringDuration();
bin()->emitItemUpdated(this);
@@ -547,6 +564,7 @@ bool ProjectClip::deleteClipMarkers(QUndoCommand *command)
newMarkers << marker;
}
new AddMarkerCommand(this, markers, newMarkers, command);
+ return true;
}
void ProjectClip::addMarkers(QList <CommentedTime> &markers)
diff --git a/src/bin/projectclip.h b/src/bin/projectclip.h
index 11a92ed..6f02173 100644
--- a/src/bin/projectclip.h
+++ b/src/bin/projectclip.h
@@ -159,6 +159,7 @@ public:
void resetProducerProperty(const QString &name);
/** @brief Get a property from the MLT producer. */
+ QMap <QString, QString> currentProperties(const QMap <QString, QString> &props);
QString getProducerProperty(const QString &key) const;
int getProducerIntProperty(const QString &key) const;
QColor getProducerColorProperty(const QString &key) const;
diff --git a/src/timeline/customtrackview.cpp b/src/timeline/customtrackview.cpp
index 94eea62..4824c47 100644
--- a/src/timeline/customtrackview.cpp
+++ b/src/timeline/customtrackview.cpp
@@ -4946,12 +4946,13 @@ void CustomTrackView::resizeClip(const ItemInfo &start, const ItemInfo &end, boo
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
- if (resizeClipStart)
+ if (resizeClipStart) {
if (m_timeline->track(start.track)->resize(start.startPos.seconds(), (end.startPos - start.startPos).seconds(), false))
item->resizeStart((int) end.startPos.frames(m_document->fps()));
- else
+ } else {
if (m_timeline->track(start.track)->resize(start.startPos.seconds(), (end.endPos - start.endPos).seconds(), true))
item->resizeEnd((int) end.endPos.frames(m_document->fps()));
+ }
if (!resizeClipStart && end.cropStart != start.cropStart) {
//qDebug() << "// RESIZE CROP, DIFF: " << (end.cropStart - start.cropStart).frames(25);
diff --git a/src/timeline/track.cpp b/src/timeline/track.cpp
index c1bc204..2554461 100644
--- a/src/timeline/track.cpp
+++ b/src/timeline/track.cpp
@@ -65,7 +65,7 @@ void Track::setFps(qreal fps)
bool Track::add(Mlt::Producer *cut, qreal t)
{
// /!\ getProducerForTrack
- m_playlist.insert_at(frame(t), cut, 1); //mode?
+ return (m_playlist.insert_at(frame(t), cut, 1) == 0); //mode? // warning, MLT functions return true on error
}
bool Track::del(qreal t)