Commit df840cdf authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Merge branch '17.04'

parents d0753238 d961c39b
......@@ -255,9 +255,9 @@ Item {
var newwidth = framerect.width - delta
var newheight = newwidth / root.lockratio
framesize.x = (framerect.x + (framerect.width - newwidth) - frame.x) / root.scalex;
framesize.width = newwidth / root.scalex;
framesize.width = Math.round(newwidth / root.scalex);
framesize.y = (framerect.y + (framerect.height - newheight) - frame.y) / root.scaley;
framesize.height = newheight / root.scaley;
framesize.height = Math.round(framesize.width / root.lockratio)
} else {
framesize.x = (framerect.x + (mouseX - oldMouseX) - frame.x) / root.scalex;
framesize.width = (framerect.width - (mouseX - oldMouseX)) / root.scalex;
......@@ -314,8 +314,8 @@ Item {
var newheight = framerect.height - delta
var newwidth = newheight * root.lockratio
framesize.y = (framerect.y + (framerect.height - newheight) - frame.y) / root.scaley;
framesize.width = newwidth / root.scalex;
framesize.height = newheight / root.scaley;
framesize.width = Math.round(newwidth / root.scalex);
framesize.height = Math.round(framesize.width / root.lockratio)
} else {
framesize.width = (framerect.width + (mouseX - oldMouseX)) / root.scalex;
framesize.y = (framerect.y + (mouseY - oldMouseY) - frame.y) / root.scaley;
......@@ -358,10 +358,9 @@ Item {
if (root.lockratio > 0) {
var delta = Math.max(mouseX - oldMouseX, oldMouseY - mouseY)
var newwidth = framerect.width - delta
var newheight = newwidth / root.lockratio
framesize.x = (framerect.x + (framerect.width - newwidth) - frame.x) / root.scalex;
framesize.width = newwidth / root.scalex;
framesize.height = newheight / root.scaley;
framesize.width = Math.round(newwidth / root.scalex);
framesize.height = Math.round(framesize.width / root.lockratio)
} else {
framesize.x = (framerect.x + (mouseX - oldMouseX) - frame.x) / root.scalex;
framesize.width = (framerect.width - (mouseX - oldMouseX)) / root.scalex;
......@@ -404,9 +403,8 @@ Item {
if (root.lockratio > 0) {
var delta = Math.max(oldMouseX - mouseX, oldMouseY - mouseY)
var newwidth = framerect.width - delta
var newheight = newwidth / root.lockratio
framesize.width = newwidth / root.scalex;
framesize.height = newheight / root.scaley;
framesize.width = Math.round(newwidth / root.scalex);
framesize.height = Math.round(framesize.width / root.lockratio)
} else {
framesize.width = (framerect.width + (mouseX - oldMouseX)) / root.scalex;
framesize.height = (framerect.height + (mouseY - oldMouseY)) / root.scaley;
......
......@@ -63,10 +63,12 @@ bool DocumentValidator::validate(const double currentVersion)
if (rootDir == QLatin1String("$CURRENTPATH")) {
// The document was extracted from a Kdenlive archived project, fix root directory
QString playlist = m_doc.toString();
playlist.replace(QLatin1String("$CURRENTPATH"), m_url.adjusted(QUrl::RemoveFilename).toLocalFile());
playlist.replace(QLatin1String("$CURRENTPATH"), m_url.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toLocalFile());
m_doc.setContent(playlist);
mlt = m_doc.firstChildElement(QStringLiteral("mlt"));
kdenliveDoc = mlt.firstChildElement(QStringLiteral("kdenlivedoc"));
} else if (rootDir.isEmpty()) {
mlt.setAttribute(QStringLiteral("root"), m_url.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toLocalFile());
}
// Previous MLT / Kdenlive versions used C locale by default
......
......@@ -509,6 +509,18 @@ void AnimationWidget::slotPositionChanged(int pos, bool seek)
updateSlider(pos - m_offset);
m_previous->setEnabled(pos > 0);
m_next->setEnabled(pos < (m_outPoint - m_inPoint - 1));
// scene ratio lock
if (m_spinWidth && m_spinWidth->isEnabled()) {
double ratio = m_originalSize->isChecked() ? (double)m_frameSize.x() / m_frameSize.y() : (double)m_monitor->render->frameRenderWidth() / m_monitor->render->renderHeight();
bool lockRatio = m_spinHeight->value() == (int) (m_spinWidth->value() / ratio + 0.5);
qDebug()<<"CALCULATED: "<<m_spinHeight->value()<<" = "<<(int) (m_spinWidth->value() / ratio + 0.5);
m_lockRatio->blockSignals(true);
m_lockRatio->setChecked(lockRatio);
m_lockRatio->blockSignals(false);
m_monitor->setEffectSceneProperty(QStringLiteral("lockratio"), m_lockRatio->isChecked() ? ratio : -1);
}
if (seek) {
emit seekToPos(pos);
}
......@@ -794,12 +806,11 @@ void AnimationWidget::buildRectWidget(const QString &paramTag, const QDomElement
horLayout->addWidget(m_spinWidth);
// Lock ratio stuff
QAction *lockRatio = new QAction(KoIconUtils::themedIcon(QStringLiteral("link")), i18n("Lock aspect ratio"), this);
lockRatio->setCheckable(true);
lockRatio->setChecked(KdenliveSettings::lock_ratio());
connect(lockRatio, &QAction::triggered, this, &AnimationWidget::slotLockRatio);
m_lockRatio = new QAction(KoIconUtils::themedIcon(QStringLiteral("link")), i18n("Lock aspect ratio"), this);
m_lockRatio->setCheckable(true);
connect(m_lockRatio, &QAction::triggered, this, &AnimationWidget::slotLockRatio);
QToolButton *ratioButton = new QToolButton;
ratioButton->setDefaultAction(lockRatio);
ratioButton->setDefaultAction(m_lockRatio);
horLayout->addWidget(ratioButton);
m_spinHeight = new DragValue(i18nc("Frame height", "H"), m_monitor->render->renderHeight(), 0, 1, 99000, -1, QString(), false, this);
......@@ -1313,9 +1324,6 @@ void AnimationWidget::connectMonitor(bool activate)
m_originalSize->blockSignals(false);
}
}
if (KdenliveSettings::lock_ratio()) {
m_monitor->setEffectSceneProperty(QStringLiteral("lockratio"), m_originalSize->isChecked() ? (double)m_frameSize.x() / m_frameSize.y() : (double)m_monitor->render->frameRenderWidth() / m_monitor->render->renderHeight());
}
} else {
disconnect(m_monitor, &Monitor::effectChanged, this, &AnimationWidget::slotUpdateGeometryRect);
disconnect(m_monitor, &Monitor::effectPointsChanged, this, &AnimationWidget::slotUpdateCenters);
......@@ -1447,7 +1455,7 @@ void AnimationWidget::slotAdjustToSource()
m_spinWidth->blockSignals(false);
m_spinHeight->blockSignals(false);
slotAdjustRectKeyframeValue();
if (KdenliveSettings::lock_ratio()) {
if (m_lockRatio->isChecked()) {
m_monitor->setEffectSceneProperty(QStringLiteral("lockratio"), m_originalSize->isChecked() ? (double)m_frameSize.x() / m_frameSize.y() : (double)m_monitor->render->frameRenderWidth() / m_monitor->render->renderHeight());
}
}
......@@ -1562,7 +1570,6 @@ void AnimationWidget::slotImportKeyframes()
void AnimationWidget::slotLockRatio()
{
QAction *lockRatio = qobject_cast<QAction*> (QObject::sender());
KdenliveSettings::setLock_ratio(lockRatio->isChecked());
if (lockRatio->isChecked()) {
m_monitor->setEffectSceneProperty(QStringLiteral("lockratio"), m_originalSize->isChecked() ? (double)m_frameSize.x() / m_frameSize.y() : (double)m_monitor->render->frameRenderWidth() / m_monitor->render->renderHeight());
} else {
......@@ -1572,7 +1579,7 @@ void AnimationWidget::slotLockRatio()
void AnimationWidget::slotAdjustRectWidth()
{
if (KdenliveSettings::lock_ratio()) {
if (m_lockRatio->isChecked()) {
m_spinHeight->blockSignals(true);
if (m_originalSize->isChecked()) {
m_spinHeight->setValue((int) (m_spinWidth->value() * m_frameSize.y() / m_frameSize.x() + 0.5));
......@@ -1586,7 +1593,7 @@ void AnimationWidget::slotAdjustRectWidth()
void AnimationWidget::slotAdjustRectHeight()
{
if (KdenliveSettings::lock_ratio()) {
if (m_lockRatio->isChecked()) {
m_spinWidth->blockSignals(true);
if (m_originalSize->isChecked()) {
m_spinWidth->setValue((int) (m_spinHeight->value() * m_frameSize.x() / m_frameSize.y() + 0.5));
......
......@@ -97,6 +97,7 @@ private:
DragValue *m_spinSize;
DragValue *m_spinOpacity;
QAction *m_originalSize;
QAction *m_lockRatio;
int m_offset;
void parseKeyframes();
void rebuildKeyframes();
......
......@@ -98,12 +98,11 @@ GeometryWidget::GeometryWidget(EffectMetaInfo *info, int clipPos, bool showRotat
m_ui.horizontalLayout->addWidget(m_spinWidth, 0, 2);
// Lock ratio stuff
QAction *lockRatio = new QAction(KoIconUtils::themedIcon(QStringLiteral("link")), i18n("Lock aspect ratio"), this);
lockRatio->setCheckable(true);
lockRatio->setChecked(KdenliveSettings::lock_ratio());
connect(lockRatio, &QAction::triggered, this, &GeometryWidget::slotLockRatio);
m_lockRatio = new QAction(KoIconUtils::themedIcon(QStringLiteral("link")), i18n("Lock aspect ratio"), this);
m_lockRatio->setCheckable(true);
connect(m_lockRatio, &QAction::triggered, this, &GeometryWidget::slotLockRatio);
QToolButton *ratioButton = new QToolButton;
ratioButton->setDefaultAction(lockRatio);
ratioButton->setDefaultAction(m_lockRatio);
m_ui.horizontalLayout->addWidget(ratioButton, 0, 3);
m_spinHeight = new DragValue(i18nc("Frame height", "H"), m_monitor->render->renderHeight(), 0, 1, 99000, -1, QString(), false, this);
......@@ -501,6 +500,17 @@ void GeometryWidget::slotPositionChanged(int pos, bool seek)
}
m_monitor->setUpEffectGeometry(r, calculateCenters());
slotUpdateProperties(r);
// scene ratio lock
if (m_ui.widgetGeometry->isEnabled()) {
double ratio = m_originalSize->isChecked() ? (double)m_frameSize.x() / m_frameSize.y() : (double)m_monitor->render->frameRenderWidth() / m_monitor->render->renderHeight();
bool lockRatio = m_spinHeight->value() == (int) (m_spinWidth->value() / ratio + 0.5);
m_lockRatio->blockSignals(true);
m_lockRatio->setChecked(lockRatio);
m_lockRatio->blockSignals(false);
m_monitor->setEffectSceneProperty(QStringLiteral("lockratio"), m_lockRatio->isChecked() ? ratio : -1);
}
if (seek && KdenliveSettings::transitionfollowcursor()) {
emit seekToPos(pos);
}
......@@ -519,16 +529,13 @@ void GeometryWidget::slotInitScene(int pos)
m_originalSize->blockSignals(false);
}
}
// scene ratio lock
if (KdenliveSettings::lock_ratio()) {
m_monitor->setEffectSceneProperty(QStringLiteral("lockratio"), m_originalSize->isChecked() ? (double)m_frameSize.x() / m_frameSize.y() : (double)m_monitor->render->frameRenderWidth() / m_monitor->render->renderHeight());
}
}
void GeometryWidget::slotKeyframeMoved(int pos)
{
slotPositionChanged(pos);
slotUpdateGeometry();
QTimer::singleShot(100, this, &GeometryWidget::valueChanged);
}
......@@ -832,7 +839,7 @@ void GeometryWidget::slotSetY(double value)
void GeometryWidget::slotSetWidth(double value)
{
if (KdenliveSettings::lock_ratio()) {
if (m_lockRatio->isChecked()) {
m_spinHeight->blockSignals(true);
if (m_originalSize->isChecked()) {
m_spinHeight->setValue((int) (value * m_frameSize.y() / m_frameSize.x() + 0.5));
......@@ -848,7 +855,7 @@ void GeometryWidget::slotSetWidth(double value)
void GeometryWidget::slotSetHeight(double value)
{
if (KdenliveSettings::lock_ratio()) {
if (m_lockRatio->isChecked()) {
m_spinWidth->blockSignals(true);
if (m_originalSize->isChecked()) {
m_spinWidth->setValue((int) (value * m_frameSize.x() / m_frameSize.y() + 0.5));
......@@ -943,7 +950,7 @@ void GeometryWidget::setFrameSize(const QPoint &size)
} else {
m_originalSize->setEnabled(true);
}
if (KdenliveSettings::lock_ratio()) {
if (m_lockRatio->isChecked()) {
m_monitor->setEffectSceneProperty(QStringLiteral("lockratio"), m_originalSize->isChecked() ? (double)m_frameSize.x() / m_frameSize.y() : (double)m_monitor->render->frameRenderWidth() / m_monitor->render->renderHeight());
} else {
m_monitor->setEffectSceneProperty(QStringLiteral("lockratio"), -1);
......@@ -966,7 +973,7 @@ void GeometryWidget::slotAdjustToSource()
m_spinWidth->blockSignals(false);
m_spinHeight->blockSignals(false);
updateMonitorGeometry();
if (KdenliveSettings::lock_ratio()) {
if (m_lockRatio->isChecked()) {
m_monitor->setEffectSceneProperty(QStringLiteral("lockratio"), m_originalSize->isChecked() ? (double)m_frameSize.x() / m_frameSize.y() : (double)m_monitor->render->frameRenderWidth() / m_monitor->render->renderHeight());
}
}
......@@ -1192,7 +1199,6 @@ void GeometryWidget::slotUpdateRange(int inPoint, int outPoint)
void GeometryWidget::slotLockRatio()
{
QAction *lockRatio = qobject_cast<QAction*> (QObject::sender());
KdenliveSettings::setLock_ratio(lockRatio->isChecked());
if (lockRatio->isChecked()) {
m_monitor->setEffectSceneProperty(QStringLiteral("lockratio"), m_originalSize->isChecked() ? (double)m_frameSize.x() / m_frameSize.y() : (double)m_monitor->render->frameRenderWidth() / m_monitor->render->renderHeight());
} else {
......
......@@ -106,6 +106,8 @@ private:
QPoint m_frameSize;
/** @brief Action switching between profile and source size. */
QAction *m_originalSize;
/** @brief Action locking image ratio. */
QAction *m_lockRatio;
/** @brief True if this is a fixed parameter (no kexframes allowed). */
bool m_fixedGeom;
/** @brief True if there is only one keyframe in this geometry. */
......
......@@ -948,10 +948,4 @@
<default>false</default>
</entry>
</group>
<group name="effects">
<entry name="lock_ratio" type="Bool">
<label>Lock size ratio in effects.</label>
<default>true</default>
</entry>
</group>
</kcfg>
......@@ -125,7 +125,7 @@ ArchiveWidget::ArchiveWidget(const QString &projectName, const QDomDocument &doc
else if (t == QText) {
allFonts << clip->property(QStringLiteral("family"));
}
else if (t == Text) {
else if (t == Text || t == TextTemplate) {
QStringList imagefiles = TitleWidget::extractImageList(clip->property(QStringLiteral("xmldata")));
QStringList fonts = TitleWidget::extractFontList(clip->property(QStringLiteral("xmldata")));
extraImageUrls << imagefiles;
......@@ -444,20 +444,16 @@ void ArchiveWidget::generateItems(QTreeWidgetItem *parentItem, const QMap<QStrin
// pattern url (like clip%.3d.png)
QStringList result = dir.entryList(QDir::Files);
QString filter = slideUrl.fileName();
QString ext = filter.section(QLatin1Char('.'), -1);
QString ext = filter.section(QLatin1Char('.'), -1).section(QLatin1Char('?'), 0, 0);
filter = filter.section(QLatin1Char('%'), 0, -2);
QString regexp = QLatin1Char('^') + filter + QStringLiteral("\\d+\\.") + ext + QLatin1Char('$');
QRegExp rx(regexp);
QStringList slideImages;
qint64 totalSize = 0;
QString directory = dir.absolutePath();
if (!directory.endsWith(QLatin1Char('/'))) {
directory.append(QLatin1Char('/'));
}
foreach (const QString &path, result) {
if (rx.exactMatch(path)) {
totalSize += QFileInfo(directory + path).size();
slideImages << directory + path;
totalSize += QFileInfo(dir.absoluteFilePath(path)).size();
slideImages << dir.absoluteFilePath(path);
}
}
item->setData(0, Qt::UserRole + 1, slideImages);
......@@ -699,18 +695,18 @@ bool ArchiveWidget::processProjectFile()
for (int i = 0; i < files_list->topLevelItemCount(); ++i) {
QTreeWidgetItem *parentItem = files_list->topLevelItem(i);
if (parentItem->childCount() > 0) {
destUrl = QUrl::fromLocalFile(archive_url->url().toLocalFile() + QDir::separator() + parentItem->data(0, Qt::UserRole).toString());
QDir destFolder(archive_url->url().toLocalFile() + QDir::separator() + parentItem->data(0, Qt::UserRole).toString());
bool isSlideshow = parentItem->data(0, Qt::UserRole).toString() == QLatin1String("slideshows");
for (int j = 0; j < parentItem->childCount(); ++j) {
item = parentItem->child(j);
QUrl src = QUrl::fromLocalFile(item->text(0));
QUrl dest = destUrl;
QUrl dest = QUrl::fromLocalFile(destFolder.absolutePath());
if (isSlideshow) {
dest = QUrl::fromLocalFile(destUrl.toLocalFile() + QDir::separator() + item->data(0, Qt::UserRole).toString() + QLatin1Char('/') + src.fileName());
dest = QUrl::fromLocalFile(parentItem->data(0, Qt::UserRole).toString() + QLatin1Char('/') + item->data(0, Qt::UserRole).toString() + QLatin1Char('/') + src.fileName());
} else if (item->data(0, Qt::UserRole).isNull()) {
dest = QUrl::fromLocalFile(destUrl.toLocalFile() + QDir::separator() + src.fileName());
dest = QUrl::fromLocalFile(parentItem->data(0, Qt::UserRole).toString() + QLatin1Char('/') + src.fileName());
} else {
dest = QUrl::fromLocalFile(destUrl.toLocalFile() + QLatin1Char('/') + item->data(0, Qt::UserRole).toString());
dest = QUrl::fromLocalFile(parentItem->data(0, Qt::UserRole).toString() + QLatin1Char('/') + item->data(0, Qt::UserRole).toString());
}
m_replacementList.insert(src, dest);
}
......@@ -728,11 +724,10 @@ bool ArchiveWidget::processProjectFile()
if (isArchive) {
basePath = QStringLiteral("$CURRENTPATH");
} else {
basePath = archive_url->url().adjusted(QUrl::StripTrailingSlash).toLocalFile();
basePath = archive_url->url().adjusted(QUrl::StripTrailingSlash | QUrl::StripTrailingSlash).toLocalFile();
}
mlt.setAttribute(QStringLiteral("root"), basePath);
QDomElement project = mlt.firstChildElement(QStringLiteral("kdenlivedoc"));
project.setAttribute(QStringLiteral("projectfolder"), basePath);
// Switch to relative path
mlt.removeAttribute(QStringLiteral("root"));
// process kdenlive producers
QDomNodeList prods = mlt.elementsByTagName(QStringLiteral("kdenlive_producer"));
......@@ -775,6 +770,30 @@ bool ArchiveWidget::processProjectFile()
EffectsList::setProperty(e, QStringLiteral("resource"), dest.toLocalFile());
}
}
src = EffectsList::property(e, QStringLiteral("xmldata"));
bool found = false;
if (!src.isEmpty() && (src.contains(QLatin1String("QGraphicsPixmapItem")) || src.contains(QLatin1String("QGraphicsSvgItem")))) {
// Title with images, replace paths
QDomDocument titleXML;
titleXML.setContent(src);
QDomNodeList images = titleXML.documentElement().elementsByTagName(QLatin1String("item"));
for (int i = 0; i < images.count(); i++) {
QDomNode n = images.at(i);
QDomElement url = n.firstChildElement(QLatin1String("content"));
if (!url.isNull() && url.hasAttribute(QLatin1String("url"))) {
QUrl srcUrl = QUrl::fromLocalFile(url.attribute(QLatin1String("url")));
QUrl dest = m_replacementList.value(srcUrl);
if (dest.isValid()) {
url.setAttribute(QLatin1String("url"), dest.toLocalFile());
found = true;
}
}
}
if (found) {
// replace content
EffectsList::setProperty(e, QStringLiteral("xmldata"), titleXML.toString());
}
}
}
// process mlt transitions (for luma files)
......@@ -849,10 +868,14 @@ bool ArchiveWidget::processProjectFile()
void ArchiveWidget::createArchive()
{
QString archiveName(archive_url->url().toLocalFile() + QDir::separator() + m_name + QStringLiteral(".tar.gz"));
if (QFile::exists(archiveName) && KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", archiveName)) == KMessageBox::No) {
return;
}
QFileInfo dirInfo(archive_url->url().toLocalFile());
QString user = dirInfo.owner();
QString group = dirInfo.group();
KTar archive(archive_url->url().toLocalFile() + QDir::separator() + m_name + QStringLiteral(".tar.gz"), QStringLiteral("application/x-gzip"));
KTar archive(archiveName, QStringLiteral("application/x-gzip"));
archive.open(QIODevice::WriteOnly);
// Create folders
......
......@@ -214,8 +214,6 @@ public:
/** @brief Returns last requested seeking pos, or current cursor position. */
int seekPosition() const;
/** @brief Trigger a monitor refresh. */
void monitorRefresh(const QList<ItemInfo> &range, bool invalidateRange = false);
void monitorRefresh(bool invalidateRange = false);
/** @brief Trigger a monitor refresh if timeline cursor is inside range. */
void monitorRefresh(const ItemInfo &range, bool invalidateRange = false);
......@@ -365,6 +363,8 @@ public slots:
void slotUpdateAllThumbs();
void slotCheckPositionScrolling();
void slotInsertTrack(int ix);
/** @brief Trigger a monitor refresh. */
void monitorRefresh(const QList<ItemInfo> &range, bool invalidateRange = false);
/** @brief Shows a dialog for selecting a track to delete.
* @param ix Number of the track, which should be pre-selected in the dialog */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment