Inform user when something goes wrong with a filter

parent 7a1f66d4
Pipeline #12290 passed with stage
in 15 minutes and 25 seconds
......@@ -28,6 +28,7 @@
#include "kdenlivesettings.h"
#include "model/assetparametermodel.hpp"
#include "transitions/transitionsrepository.hpp"
#include "effects/effectsrepository.hpp"
#include "transitions/view/transitionstackview.hpp"
#include "view/assetparameterview.hpp"
......@@ -36,6 +37,7 @@
#include <KColorUtils>
#include <KDualAction>
#include <KSqueezedTextLabel>
#include <KMessageWidget>
#include <QApplication>
#include <QToolBar>
#include <QToolButton>
......@@ -128,6 +130,9 @@ AssetPanel::AssetPanel(QWidget *parent)
m_sc->setWidgetResizable(true);
m_lay->addWidget(m_sc);
m_infoMessage = new KMessageWidget(this);
m_lay->addWidget(m_infoMessage);
m_infoMessage->hide();
m_sc->setWidget(m_container);
m_transitionWidget->setVisible(false);
m_effectStackWidget->setVisible(false);
......@@ -404,3 +409,20 @@ void AssetPanel::slotCheckWheelEventFilter()
}
m_effectStackWidget->blockWheenEvent(blockWheel);
}
void AssetPanel::assetPanelWarning(const QString service, const QString id, const QString message)
{
QString finalMessage;
if (!service.isEmpty() && EffectsRepository::get()->exists(service)) {
QString effectName = EffectsRepository::get()->getName(service);
if (!effectName.isEmpty()) {
finalMessage = QStringLiteral("<b>") + effectName + QStringLiteral("</b><br />");
}
}
finalMessage.append(message);
m_infoMessage->setText(finalMessage);
m_infoMessage->setWordWrap(message.length() > 35);
m_infoMessage->setCloseButtonVisible(true);
m_infoMessage->setMessageType(KMessageWidget::Warning);
m_infoMessage->animatedShow();
}
......@@ -30,6 +30,7 @@
class KSqueezedTextLabel;
class KDualAction;
class KMessageWidget;
class QToolButton;
class QComboBox;
class QScrollArea;
......@@ -71,6 +72,7 @@ public:
public slots:
/** @brief Clear panel if displaying itemId */
void clearAssetPanel(int itemId);
void assetPanelWarning(const QString service, const QString id, const QString message);
void deleteCurrentEffect();
void slotCheckWheelEventFilter();
......@@ -92,6 +94,7 @@ private:
KDualAction *m_enableStackButton;
KDualAction *m_timelineButton;
QScrollArea *m_sc;
KMessageWidget *m_infoMessage;
private slots:
void processSplitEffect(bool enable);
......
......@@ -811,3 +811,8 @@ int Core::getDurationFromString(const QString &time)
const QString duration = currentDoc()->timecode().reformatSeparators(time);
return currentDoc()->timecode().getFrameCount(duration);
}
void Core::processInvalidFilter(const QString service, const QString id, const QString message)
{
if (m_guiConstructed) m_mainWindow->assetPanelWarning(service, id, message);
}
......@@ -199,6 +199,8 @@ public:
QString getTimelineClipBinId(int cid);
/** @brief Returns a frame duration from a timecode */
int getDurationFromString(const QString &time);
/** @brief An error occured within a filter, inform user */
void processInvalidFilter(const QString service, const QString id, const QString message);
private:
explicit Core();
......
......@@ -339,6 +339,7 @@ void MainWindow::init()
// m_effectStackDock->raise();
});
connect(this, &MainWindow::clearAssetPanel, m_assetPanel, &AssetPanel::clearAssetPanel);
connect(this, &MainWindow::assetPanelWarning, m_assetPanel, &AssetPanel::assetPanelWarning);
connect(m_assetPanel, &AssetPanel::seekToPos, [this](int pos) {
ObjectId oId = m_assetPanel->effectStackOwner();
switch (oId.first) {
......
......@@ -485,6 +485,7 @@ signals:
void updateRenderWidgetProfile();
/** @brief Clear asset view if itemId is displayed. */
void clearAssetPanel(int itemId = -1);
void assetPanelWarning(const QString service, const QString id, const QString message);
void adjustAssetPanelRange(int itemId, int in, int out);
/** @brief Enable or disable the undo stack. For example undo/redo should not be enabled when dragging a clip in timeline or we risk corruption. */
void enableUndo(bool enable);
......
......@@ -24,6 +24,60 @@ the Free Software Foundation, either version 3 of the License, or
#include <QStandardPaths>
#include <mlt++/MltFactory.h>
#include <mlt++/MltRepository.h>
#include <framework/mlt_log.h>
static void mlt_log_handler(void *service, int mlt_level, const char *format, va_list args)
{
if (mlt_level > mlt_log_get_level())
return;
/*enum Logger::LogLevel cuteLoggerLevel = Logger::Fatal;
switch (mlt_level) {
case MLT_LOG_DEBUG:
cuteLoggerLevel = Logger::Trace;
break;
case MLT_LOG_ERROR:
case MLT_LOG_FATAL:
case MLT_LOG_PANIC:
cuteLoggerLevel = Logger::Error;
break;
case MLT_LOG_INFO:
cuteLoggerLevel = Logger::Info;
break;
case MLT_LOG_VERBOSE:
cuteLoggerLevel = Logger::Debug;
break;
case MLT_LOG_WARNING:
cuteLoggerLevel = Logger::Warning;
break;
}*/
QString message;
mlt_properties properties = service? MLT_SERVICE_PROPERTIES((mlt_service) service) : NULL;
if (properties) {
char *mlt_type = mlt_properties_get(properties, "mlt_type");
char *service_name = mlt_properties_get(properties, "mlt_service");
char *resource = mlt_properties_get(properties, "resource");
char *id = mlt_properties_get(properties, "id");
if (!resource || resource[0] != '<' || resource[strlen(resource) - 1] != '>')
mlt_type = mlt_properties_get(properties, "mlt_type" );
if (service_name)
message = QString("[%1 %2 %3] ").arg(mlt_type).arg(service_name).arg(id);
else
message = QString().sprintf("[%s %p] ", mlt_type, service);
if (resource)
message.append(QString("\"%1\" ").arg(resource));
message.append(QString().vsprintf(format, args));
message.replace('\n', "");
if (!strcmp(mlt_type, "filter")) {
pCore->processInvalidFilter(service_name, id, message);
}
} else {
message = QString().vsprintf(format, args);
message.replace('\n', "");
}
qDebug()<<"==========\n\nMLT ERROR:\n"<<message<<"\n";
}
std::unique_ptr<MltConnection> MltConnection::m_self;
MltConnection::MltConnection(const QString &mltPath)
......@@ -43,7 +97,8 @@ MltConnection::MltConnection(const QString &mltPath)
producersList << producers->get_name(i);
}
KdenliveSettings::setProducerslist(producersList);
mlt_log_set_level(MLT_LOG_WARNING);
mlt_log_set_callback(mlt_log_handler);
refreshLumas();
}
......
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