*Fix crash on reset lift/gain effect

*Use right click to reset effect param to default
*Refactor thumbnail creator to use code similar to shotcut
parent ace58022
......@@ -207,7 +207,7 @@ void AssetParameterView::refresh(const QModelIndex &topLeft, const QModelIndex &
if (m_mainKeyframeWidget) {
m_mainKeyframeWidget->slotRefresh();
} else {
auto type = m_model->data(m_model->index(bottomRight.row(), 0), AssetParameterModel::TypeRole).value<ParamType>();
auto type = m_model->data(m_model->index(topLeft.row(), 0), AssetParameterModel::TypeRole).value<ParamType>();
if (type == ParamType::ColorWheel) {
// Some special widgets, like colorwheel handle multiple params so we can have cases where param index row is greater than the number of widgets.
// Should be better managed
......@@ -215,8 +215,10 @@ void AssetParameterView::refresh(const QModelIndex &topLeft, const QModelIndex &
return;
}
Q_ASSERT(bottomRight.row() < (int)m_widgets.size());
for (int i = topLeft.row(); i <= bottomRight.row(); ++i) {
m_widgets[(uint)i]->slotRefresh();
for (uint i = topLeft.row(); i <= bottomRight.row(); ++i) {
if (m_widgets.size() < i) {
m_widgets[i]->slotRefresh();
}
}
}
}
......
......@@ -155,7 +155,7 @@ void ColorWheel::mousePressEvent(QMouseEvent *event)
if (m_wheelRegion.contains(m_lastPoint)) {
m_isInWheel = true;
m_isInSquare = false;
if (event->button() != Qt::MidButton) {
if (event->button() == Qt::LeftButton) {
changeColor(colorForPoint(m_lastPoint));
} else {
// reset to default on middle button
......
......@@ -458,9 +458,24 @@ std::shared_ptr<Mlt::Producer> ProjectClip::thumbProducer()
Mlt::Filter converter(*prod->profile(), "avcolor_space");
m_thumbsProducer->attach(converter);
} else {
m_thumbsProducer = cloneProducer(pCore->thumbProfile(), true);
Mlt::Filter converter(*pCore->thumbProfile(), "avcolor_space");
m_thumbsProducer->attach(converter);
QString mltService = m_masterProducer->get("mlt_service");
const QString mltResource = m_masterProducer->get("resource");
if (mltService == QLatin1String("avformat")) {
mltService = QStringLiteral("avformat-novalidate");
}
m_thumbsProducer.reset(new Mlt::Producer(*pCore->thumbProfile(), mltService.toUtf8().constData(), mltResource.toUtf8().constData()));
if (m_thumbsProducer->is_valid()) {
Mlt::Properties original(m_masterProducer->get_properties());
Mlt::Properties cloneProps(m_thumbsProducer->get_properties());
cloneProps.pass_list(original, ClipController::getPassPropertiesList());
Mlt::Filter scaler(*pCore->thumbProfile(), "swscale");
Mlt::Filter padder(*pCore->thumbProfile(), "resize");
Mlt::Filter converter(*pCore->thumbProfile(), "avcolor_space");
m_thumbsProducer->set("audio_index", -1);
m_thumbsProducer->attach(scaler);
m_thumbsProducer->attach(padder);
m_thumbsProducer->attach(converter);
}
}
return m_thumbsProducer;
}
......
......@@ -182,7 +182,7 @@ void ColorWheelItem::mousePressEvent(QMouseEvent *event)
NegQColor color = colorForPoint(m_lastPoint);
setColor(color);
}
} else if (event->button() == Qt::MidButton) {
} else if (event->button() == Qt::RightButton) {
NegQColor color = NegQColor::fromRgbF(m_defaultValue / m_sizeFactor, m_defaultValue / m_sizeFactor, m_defaultValue / m_sizeFactor);
setColor(color);
event->accept();
......
......@@ -157,7 +157,7 @@ void ColorWheel::mousePressEvent(QMouseEvent *event)
if (m_wheelRegion.contains(m_lastPoint)) {
m_isInWheel = true;
m_isInSquare = false;
if (event->button() != Qt::MidButton) {
if (event->button() == Qt::LeftButton) {
changeColor(colorForPoint(m_lastPoint));
} else {
// reset to default on middle button
......@@ -171,7 +171,7 @@ void ColorWheel::mousePressEvent(QMouseEvent *event)
} else if (m_sliderRegion.contains(m_lastPoint)) {
m_isInWheel = false;
m_isInSquare = true;
if (event->button() != Qt::MidButton) {
if (event->button() == Qt::LeftButton) {
changeColor(colorForPoint(m_lastPoint));
} else {
NegQColor c;
......
......@@ -38,7 +38,7 @@ ThumbnailProvider::~ThumbnailProvider() {}
void ThumbnailProvider::resetProject()
{
m_producers.clear();
//m_producers.clear();
}
QImage ThumbnailProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
......@@ -127,16 +127,19 @@ QImage ThumbnailProvider::makeThumbnail(std::shared_ptr<Mlt::Producer> producer,
if (frame == nullptr || !frame->is_valid()) {
return QImage();
}
int ow = 0;//requestedSize.width();
int oh = 0;//requestedSize.height();
/*if (ow > 0 && oh > 0) {
frame->set("rescale.interp", "fastest");
frame->set("deinterlace_method", "onefield");
frame->set("top_field_first", -1);
}*/
mlt_image_format format = mlt_image_rgb24a;
int ow = 0;
int oh = 0;
const uchar *imagedata = frame->get_image(format, ow, oh);
if (imagedata) {
QImage result(ow, oh, QImage::Format_RGBA8888);
memcpy(result.bits(), imagedata, (unsigned)(ow * oh * 4));
if (!result.isNull()) {
return result;
}
const uchar *image = frame->get_image(format, ow, oh);
if (image) {
QImage temp(ow, oh, QImage::Format_ARGB32);
memcpy(temp.scanLine(0), image, (unsigned)(ow * oh * 4));
return temp.rgbSwapped();
}
return QImage();
}
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