Commit a8279d49 authored by Pushkar Kukde's avatar Pushkar Kukde

Fixed titlewidget.cpp again

parents f8af6b85 4f51bc3e
......@@ -390,7 +390,7 @@ Name[tr]=Hata
Name[ug]=خاتالىق
Name[uk]=Помилка
Name[x-test]=xxErrorxx
Name[zh_CN]=误差
Name[zh_CN]=错误
Name[zh_TW]=錯誤
Comment=An error occurred in Kdenlive
Comment[ar]=حدث خطأ في «كدينلايڤ»
......
......@@ -292,6 +292,8 @@
</artifact>
</artifacts>
</release>
<release version="20.08.0" date="2020-08-13"/>
<release date="2020-04-15" version="20.07.70"/>
</releases>
<url type="homepage">https://kdenlive.org/</url>
<url type="bugtracker">https://bugs.kde.org</url>
......
......@@ -54,6 +54,7 @@ public:
/* @brief Delete a custom effect */
void deleteCustomEffect(const QModelIndex &index);
virtual void reloadCustomEffectIx(const QModelIndex &index) = 0;
/* @brief Returns the description of the asset given its model index */
QString getDescription(bool isEffect, const QModelIndex &index) const;
......
......@@ -283,9 +283,10 @@ Rectangle {
sel.setCurrentIndex(styleData.index, ItemSelectionModel.ClearAndSelect)
if (mouse.button === Qt.LeftButton) {
drag.target = parent
parent.grabToImage(function(result) {
// grabToImage does not work on QQuickWidget from AssetListWidget. We should use QQuickView + QWidget::createWindowContainer
/*parent.grabToImage(function(result) {
parent.Drag.imageSource = result.url
})
})*/
} else {
drag.target = undefined
assetContextMenu.isItemFavorite = assetThumb.isFavorite
......@@ -329,6 +330,14 @@ Rectangle {
assetlist.deleteCustomEffect(sel.currentIndex)
}
}
MenuItem {
id: reloadMenu
text: i18n("Reload custom effect")
visible: isEffectList && assetContextMenu.isCustom
onTriggered: {
assetlist.reloadCustomEffectIx(sel.currentIndex)
}
}
}
TableViewColumn { role: "identifier"; title: i18n("Name"); }
......
......@@ -25,6 +25,7 @@
#include <QMouseEvent>
#include <QApplication>
#include <QStylePainter>
#include <QtMath>
#include <KColorScheme>
#include <QFontDatabase>
......@@ -414,8 +415,8 @@ void KeyframeView::paintEvent(QPaintEvent *event)
int headOffset = m_lineHeight / 2;
int offset = pCore->getItemIn(m_model->getOwnerId());
m_zoomStart = m_zoomHandle.x() * maxWidth;
double zoomEnd = m_zoomHandle.y() * maxWidth;
m_zoomFactor = maxWidth / (zoomEnd - m_zoomStart);
m_zoomFactor = maxWidth / (m_zoomHandle.y() * maxWidth - m_zoomStart);
int zoomEnd = qCeil(m_zoomHandle.y() * maxWidth);
/* ticks */
double fps = pCore->getCurrentFps();
int displayedLength = m_duration / m_zoomFactor / fps;
......@@ -470,15 +471,15 @@ void KeyframeView::paintEvent(QPaintEvent *event)
for (const auto &keyframe : *m_model.get()) {
int pos = keyframe.first.frames(fps) - offset;
if (pos < 0) continue;
double scaledPos = pos * m_scale;
if (scaledPos < m_zoomStart || qFloor(scaledPos) > zoomEnd) {
continue;
}
if (pos == m_currentKeyframe || pos == m_hoverKeyframe) {
p.setBrush(m_colSelected);
} else {
p.setBrush(m_colKeyframe);
}
double scaledPos = pos * m_scale;
if (scaledPos < m_zoomStart || scaledPos > zoomEnd) {
continue;
}
scaledPos -= m_zoomStart;
scaledPos *= m_zoomFactor;
scaledPos += m_offset;
......@@ -515,7 +516,7 @@ void KeyframeView::paintEvent(QPaintEvent *event)
*/
if (m_position >= 0 && m_position < m_duration) {
double scaledPos = m_position * m_scale;
if (scaledPos >= m_zoomStart && scaledPos <= zoomEnd) {
if (scaledPos >= m_zoomStart && qFloor(scaledPos) <= zoomEnd) {
scaledPos -= m_zoomStart;
scaledPos *= m_zoomFactor;
scaledPos += m_offset;
......
......@@ -218,7 +218,11 @@ QSize WheelContainer::minimumSizeHint() const
void WheelContainer::wheelEvent(QWheelEvent *event)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
if (m_sliderRegion.contains(event->pos())) {
# else
if (m_sliderRegion.contains(event->position().toPoint())) {
#endif
double y = m_color.valueF();
if (event->modifiers() & Qt::ShiftModifier) {
y += event->angleDelta().y() > 0 ? 0.002 : -0.002;
......
......@@ -1333,7 +1333,7 @@ bool Bin::eventFilter(QObject *obj, QEvent *event)
if (event->type() == QEvent::Wheel) {
auto *e = static_cast<QWheelEvent *>(event);
if ((e != nullptr) && e->modifiers() == Qt::ControlModifier) {
wheelAccumulatedDelta += e->delta();
wheelAccumulatedDelta += e->angleDelta().y();
if (abs(wheelAccumulatedDelta) >= QWheelEvent::DefaultDeltasPerStep) {
slotZoomView(wheelAccumulatedDelta > 0);
}
......
......@@ -115,7 +115,11 @@ void MarkerDialog::slotUpdateThumb()
QImage MarkerDialog::markerImage() const
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
return clip_thumb->pixmap()->toImage();
#else
return clip_thumb->pixmap(Qt::ReturnByValue).toImage();
#endif
}
CommentedTime MarkerDialog::newMarker()
......
......@@ -72,7 +72,7 @@ ProfilesDialog::ProfilesDialog(const QString &profileDescription, QWidget *paren
void ProfilesDialog::connectDialog()
{
connect(m_view.profiles_list, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), this, [&]() { slotUpdateDisplay(); });
connect(m_view.profiles_list, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [&](int ix) { slotUpdateDisplay(m_view.profiles_list->itemText(ix)); });
connect(m_view.button_create, &QAbstractButton::clicked, this, &ProfilesDialog::slotCreateProfile);
connect(m_view.button_save, &QAbstractButton::clicked, this, &ProfilesDialog::slotSaveProfile);
connect(m_view.button_delete, &QAbstractButton::clicked, this, &ProfilesDialog::slotDeleteProfile);
......
......@@ -1214,7 +1214,7 @@ void RenderWidget::prepareRendering(bool delayedRendering, const QString &chapte
in = pMon->getZoneStart();
out = pMon->getZoneEnd() - 1;
} else {
out = pCore->projectDuration() - 2;
out = pCore->projectDuration() - 1;
}
QString playlistContent = pCore->projectManager()->projectSceneList(project->url().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toLocalFile());
......
......@@ -412,9 +412,9 @@ void DvdWizardMenu::changeProfile(DVDFORMAT format)
void DvdWizardMenu::updatePreview()
{
m_scene->setProfile(m_width, m_height);
QMatrix matrix;
QTransform matrix;
matrix.scale(0.5, 0.5);
m_view.menu_preview->setMatrix(matrix);
m_view.menu_preview->setTransform(matrix);
m_view.menu_preview->setMinimumSize(m_width / 2 + 4, m_height / 2 + 8);
if (m_color) {
......
......@@ -113,6 +113,16 @@ std::shared_ptr<EffectTreeModel> EffectTreeModel::construct(const QString &categ
return self;
}
void EffectTreeModel::reloadEffectFromIndex(const QModelIndex &index)
{
if (!index.isValid()) {
return;
}
std::shared_ptr<TreeItem> item = getItemById((int)index.internalId());
const QString path = EffectsRepository::get()->getCustomPath(item->dataColumn(idCol).toString());
reloadEffect(path);
}
void EffectTreeModel::reloadEffect(const QString &path)
{
QPair<QString, QString> asset = EffectsRepository::get()->reloadCustom(path);
......
......@@ -38,6 +38,7 @@ protected:
public:
static std::shared_ptr<EffectTreeModel> construct(const QString &categoryFile, QObject *parent);
void reloadEffect(const QString &path);
void reloadEffectFromIndex(const QModelIndex &index);
void reloadAssetMenu(QMenu *effectsMenu, KActionCategory *effectActions) override;
void setFavorite(const QModelIndex &index, bool favorite, bool isEffect) override;
void deleteEffect(const QModelIndex &index) override;
......
......@@ -84,6 +84,13 @@ QString EffectListWidget::getMimeType(const QString &assetId) const
return QStringLiteral("kdenlive/effect");
}
void EffectListWidget::reloadCustomEffectIx(const QModelIndex &index)
{
static_cast<EffectTreeModel *>(m_model.get())->reloadEffectFromIndex(m_proxyModel->mapToSource(index));
m_proxyModel->sort(0, Qt::AscendingOrder);
}
void EffectListWidget::reloadCustomEffect(const QString &path)
{
static_cast<EffectTreeModel *>(m_model.get())->reloadEffect(path);
......
......@@ -47,6 +47,7 @@ public:
QString getMimeType(const QString &assetId) const override;
void updateFavorite(const QModelIndex &index);
void reloadEffectMenu(QMenu *effectsMenu, KActionCategory *effectActions);
void reloadCustomEffectIx(const QModelIndex &index) override;
public slots:
void reloadCustomEffect(const QString &path);
......@@ -72,6 +73,7 @@ public:
}
Q_INVOKABLE QString getName(const QModelIndex &index) const { return q->getName(index); }
Q_INVOKABLE bool isFavorite(const QModelIndex &index) const { return q->isFavorite(index); }
Q_INVOKABLE void reloadCustomEffectIx(const QModelIndex &index) const { q->reloadCustomEffectIx(index); }
Q_INVOKABLE void setFavorite(const QModelIndex &index, bool favorite) const
{
q->setFavorite(index, favorite, true);
......
......@@ -231,6 +231,16 @@ bool EffectsRepository::hasInternalEffect(const QString &effectId) const
return false;
}
QString EffectsRepository::getCustomPath(const QString &id)
{
QString customAssetDir = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("effects"), QStandardPaths::LocateDirectory);
QPair <QStringList, QStringList> results;
QDir current_dir(customAssetDir);
qDebug()<<"==== FETCHING CUSTOM PATH FOR ID: "<<id;
return current_dir.absoluteFilePath(QString("%1.xml").arg(id));
}
QPair<QString, QString> EffectsRepository::reloadCustom(const QString &path)
{
std::unordered_map<QString, Info> customAssets;
......
......@@ -45,6 +45,7 @@ public:
/* @brief returns true if an effect exists in MLT (bypasses the blacklist/metadata parsing) */
bool hasInternalEffect(const QString &effectId) const;
QPair<QString, QString> reloadCustom(const QString &path);
QString getCustomPath(const QString &id);
/* @brief Returns whether this belongs to main effects */
bool isPreferred(const QString &effectId) const;
......
......@@ -217,6 +217,7 @@ bool AudioThumbJob::computeWithFFMPEG()
} else if (offset > 250) {
intraOffset = offset / 10;
}
long maxAudioLevel = 1;
if (!m_successful) {
m_done = true;
......@@ -313,6 +314,12 @@ bool AudioThumbJob::startJob()
return false;
}
m_lengthInFrames = m_prod->get_length(); // Multiply this if we want more than 1 sample per frame
if (m_lengthInFrames == INT_MAX) {
// This is a broken file or live feed, don't attempt to generate audio thumbnails
m_done = true;
m_successful = false;
return false;
}
m_frequency = m_binClip->audioInfo()->samplingRate();
m_frequency = m_frequency <= 0 ? 48000 : m_frequency;
......
......@@ -411,6 +411,32 @@ bool LoadJob::startJob()
m_errorMessage.append(i18n("ERROR: Could not load clip %1: producer is invalid", m_resource));
return false;
}
if (m_producer->get_length() == INT_MAX && m_producer->get("eof") == QLatin1String("loop")) {
// This is a live source or broken clip
m_done = true;
m_successful = false;
if (m_producer) {
m_producer.reset();
}
qDebug()<<"=== MAX DURATION: "<<INT_MAX<<", DURATION: "<<(INT_MAX / 25 / 60);
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Cannot get duration for file %1", m_resource)),
Q_ARG(int, (int)KMessageWidget::Warning));
m_errorMessage.append(i18n("ERROR: Could not load clip %1: producer is invalid", m_resource));
return false;
}
if (m_producer->get_length() == INT_MAX && m_producer->get("eof") == QLatin1String("loop")) {
// This is a live source or broken clip
m_done = true;
m_successful = false;
if (m_producer) {
m_producer.reset();
}
qDebug()<<"=== MAX DURATION: "<<INT_MAX<<", DURATION: "<<(INT_MAX / 25 / 60);
QMetaObject::invokeMethod(pCore.get(), "displayBinMessage", Qt::QueuedConnection, Q_ARG(QString, i18n("Cannot get duration for file %1", m_resource)),
Q_ARG(int, (int)KMessageWidget::Warning));
m_errorMessage.append(i18n("ERROR: Could not load clip %1: producer is invalid", m_resource));
return false;
}
processProducerProperties(m_producer, m_xml);
QString clipName = Xml::getXmlProperty(m_xml, QStringLiteral("kdenlive:clipname"));
if (clipName.isEmpty()) {
......
......@@ -189,7 +189,7 @@ bool ProxyJob::startJob()
if (exif > 1) {
// Rotate image according to exif data
QImage processed;
QMatrix matrix;
QTransform matrix;
switch (exif) {
case 2:
......
......@@ -1008,7 +1008,7 @@ QStringList Monitor::mimeTypes() const
// virtual
void Monitor::wheelEvent(QWheelEvent *event)
{
slotMouseSeek(event->delta(), event->modifiers());
slotMouseSeek(event->angleDelta().y(), event->modifiers());
event->accept();
}
......
......@@ -257,7 +257,7 @@ void SimpleTimelineWidget::mouseDoubleClickEvent(QMouseEvent *event)
void SimpleTimelineWidget::wheelEvent(QWheelEvent *event)
{
int change = event->delta() < 0 ? 1 : -1;
int change = event->angleDelta().y() < 0 ? 1 : -1;
/*if (m_currentKeyframe > 0) {
m_currentKeyframe = qBound(0, m_currentKeyframe + change, m_duration);
emit keyframeMoved(m_currentKeyframeOriginal, m_currentKeyframe);
......
......@@ -421,6 +421,7 @@ Rectangle {
if (sizeChanged) {
clipRoot.trimmedIn(clipRoot, shiftTrim, controlTrim)
sizeChanged = false
updateDrag()
}
}
onPositionChanged: {
......@@ -510,6 +511,7 @@ Rectangle {
if (sizeChanged) {
clipRoot.trimmedOut(clipRoot, shiftTrim, controlTrim)
sizeChanged = false
updateDrag()
}
}
onPositionChanged: {
......
......@@ -458,7 +458,6 @@ TitleWidget::TitleWidget(const QUrl &url, const Timecode &tc, QString projectTit
m_frameBorder->setPen(framepen);
m_frameBorder->setZValue(1000);
m_frameBorder->setBrush(Qt::transparent);
m_frameBorder->setFlags(nullptr);
m_frameBorder->setData(-1, -1);
graphicsView->scene()->addItem(m_frameBorder);
......@@ -478,18 +477,15 @@ TitleWidget::TitleWidget(const QUrl &url, const Timecode &tc, QString projectTit
QGraphicsRectItem *safe1 = new QGraphicsRectItem(QRectF(m_frameWidth * 0.05, m_frameHeight * 0.05, m_frameWidth * 0.9, m_frameHeight * 0.9), m_frameBorder);
safe1->setBrush(Qt::transparent);
safe1->setPen(framepen);
safe1->setFlags(nullptr);
safe1->setData(-1, -1);
QGraphicsRectItem *safe2 = new QGraphicsRectItem(QRectF(m_frameWidth * 0.1, m_frameHeight * 0.1, m_frameWidth * 0.8, m_frameHeight * 0.8), m_frameBorder);
safe2->setBrush(Qt::transparent);
safe2->setPen(framepen);
safe2->setFlags(nullptr);
safe2->setData(-1, -1);
m_frameBackground = new QGraphicsRectItem(QRectF(0, 0, m_frameWidth, m_frameHeight));
m_frameBackground->setZValue(-1100);
m_frameBackground->setBrush(Qt::transparent);
m_frameBackground->setFlags(nullptr);
graphicsView->scene()->addItem(m_frameBackground);
m_frameImage = new QGraphicsPixmapItem();
......@@ -497,7 +493,6 @@ TitleWidget::TitleWidget(const QUrl &url, const Timecode &tc, QString projectTit
qtrans.scale(2.0, 2.0);
m_frameImage->setTransform(qtrans);
m_frameImage->setZValue(-1200);
m_frameImage->setFlags(nullptr);
displayBackgroundFrame();
graphicsView->scene()->addItem(m_frameImage);
......@@ -928,8 +923,10 @@ void TitleWidget::initAnimation()
m_startViewport->setZValue(-1000);
m_endViewport->setZValue(-1000);
m_startViewport->setFlags(nullptr);
m_endViewport->setFlags(nullptr);
m_startViewport->setFlag(QGraphicsItem::ItemIsMovable, false);
m_startViewport->setFlag(QGraphicsItem::ItemIsSelectable, false);
m_endViewport->setFlag(QGraphicsItem::ItemIsMovable, false);
m_endViewport->setFlag(QGraphicsItem::ItemIsSelectable, false);
graphicsView->scene()->addItem(m_startViewport);
graphicsView->scene()->addItem(m_endViewport);
......@@ -965,7 +962,11 @@ void TitleWidget::slotAdjustZoom()
if (scalex > scaley) scalex = scaley;
int zoompos = (int)(scalex * 7 + 0.5);*/
graphicsView->fitInView(m_frameBorder, Qt::KeepAspectRatio);
int zoompos = graphicsView->transform().m11() * 100 ; //matrix().m11() * 100;
<<<<<<< HEAD
int zoompos = graphicsView->transform().m11() * 100 ;
=======
int zoompos = graphicsView->transform().m11() * 100 ;
>>>>>>> 4f51bc3e2baf25fccae8e1742bc992b92e89abbf
zoom_slider->setValue(zoompos);
graphicsView->centerOn(m_frameBorder);
}
......@@ -1833,7 +1834,11 @@ void TitleWidget::itemHCenter()
newPos += item->pos().x() - br.left(); // Check item transformation
item->setPos(newPos, item->pos().y());
updateCoordinates(item);
<<<<<<< HEAD
slotAdjustZoom();
=======
graphicsView->centerOn(m_frameBorder);
>>>>>>> 4f51bc3e2baf25fccae8e1742bc992b92e89abbf
}
}
......@@ -2398,7 +2403,8 @@ void TitleWidget::slotAnimEnd(bool anim)
} else {
m_endViewport->setZValue(-1000);
m_endViewport->setBrush(QBrush());
m_endViewport->setFlags(nullptr);
m_endViewport->setFlag(QGraphicsItem::ItemIsMovable, false);
m_endViewport->setFlag(QGraphicsItem::ItemIsSelectable, false);
if (!anim_start->isChecked()) {
deleteAnimInfoText();
}
......
......@@ -103,3 +103,7 @@ void TransitionListWidget::downloadNewLumas()
// TODO: refresh currently displayd trans ?
}
}
void TransitionListWidget::reloadCustomEffectIx(const QModelIndex &path)
{
}
......@@ -43,6 +43,7 @@ public:
QString getMimeType(const QString &assetId) const override;
void updateFavorite(const QModelIndex &index);
void downloadNewLumas();
void reloadCustomEffectIx(const QModelIndex &path) override;
private:
TransitionListWidgetProxy *m_proxy;
......@@ -65,6 +66,7 @@ public:
}
Q_INVOKABLE QString getName(const QModelIndex &index) const { return q->getName(index); }
Q_INVOKABLE bool isFavorite(const QModelIndex &index) const { return q->isFavorite(index); }
Q_INVOKABLE void reloadCustomEffectIx(const QModelIndex &index) const { q->reloadCustomEffectIx(index); }
Q_INVOKABLE void setFavorite(const QModelIndex &index, bool favorite) const
{
q->setFavorite(index, favorite, false);
......
......@@ -58,7 +58,7 @@
</widget>
</item>
<item>
<widget class="KUrlRequester" name="out_file" native="true"/>
<widget class="KUrlRequester" name="out_file"/>
</item>
</layout>
</item>
......@@ -341,13 +341,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="parallel_process">
<property name="text">
<string>Parallel processing</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
......@@ -488,7 +481,7 @@
<item>
<widget class="QLabel" name="threadsLabel">
<property name="text">
<string>Threads</string>
<string>Encoder threads</string>
</property>
</widget>
</item>
......@@ -523,6 +516,13 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="parallel_process">
<property name="text">
<string>Parallel processing (experimental!)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkTwoPass">
<property name="text">
......
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