Cleanup stabilize presets and job cancelation

parent 5767bbf2
Pipeline #7473 passed with stage
in 19 minutes and 51 seconds
......@@ -689,6 +689,7 @@ void AssetParameterModel::deletePreset(const QString &presetFile, const QString
if (!loadFile.open(QIODevice::WriteOnly)) {
// TODO: error message
}
//TODO: delete file if there are no more presets in it
loadFile.write(QJsonDocument(array).toJson());
}
......
......@@ -302,13 +302,20 @@ void AssetParameterView::slotDeletePreset()
if (!ac) {
return;
}
slotDeletePreset(ac->data().toString());
}
void AssetParameterView::slotDeletePreset(const QString &presetName)
{
if (presetName.isEmpty()) {
return;
}
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/effects/presets/"));
if (!dir.exists()) {
dir.mkpath(QStringLiteral("."));
if (dir.exists()) {
const QString presetFile = dir.absoluteFilePath(QString("%1.json").arg(m_model->getAssetId()));
m_model->deletePreset(presetFile, presetName);
emit updatePresets();
}
const QString presetFile = dir.absoluteFilePath(QString("%1.json").arg(m_model->getAssetId()));
m_model->deletePreset(presetFile, ac->data().toString());
emit updatePresets();
}
void AssetParameterView::slotUpdatePreset()
......
......@@ -77,6 +77,7 @@ public slots:
void slotLoadPreset();
void slotUpdatePreset();
void slotDeletePreset();
void slotDeletePreset(const QString &presetName);
protected:
/** @brief This is a handler for the dataChanged slot of the model.
......
......@@ -42,7 +42,7 @@ JobManager::JobManager(QObject *parent)
JobManager::~JobManager()
{
slotCancelJobs();
//slotCancelJobs();
}
int JobManager::getBlockingJobId(const QString &id, AbstractClipJob::JOBTYPE type)
......
......@@ -247,6 +247,10 @@ bool MeltJob::startJob()
}
m_showFrameEvent.reset(m_consumer->listen("consumer-frame-render", this, (mlt_listener)consumer_frame_render));
m_producer->set_speed(1);
connect(this, &MeltJob::jobCanceled, [&] () {
m_consumer->stop();
return false;
});
m_consumer->run();
/*
......
......@@ -72,16 +72,19 @@ ClipStabilize::ClipStabilize(const std::vector<QString> &binIds, QString filterN
m_assetModel.reset(new AssetParameterModel(std::move(prop), xml, m_filtername, {ObjectType::NoItem, -1}));
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/effects/presets/"));
const QString presetFile = dir.absoluteFilePath(QString("%1.json").arg(m_assetModel->getAssetId()));
const QVector<QPair<QString, QVariant>> params = m_assetModel->loadPreset(presetFile, QStringLiteral("lastsetting"));
const QVector<QPair<QString, QVariant>> params = m_assetModel->loadPreset(presetFile, i18n("Last setting"));
if (!params.isEmpty()) {
m_assetModel->setParameters(params);
}
m_view->setModel(m_assetModel, QSize(1920, 1080));
m_vbox->addWidget(m_view.get());
// Presets
preset_button->setIcon(QIcon::fromTheme(QStringLiteral("adjustlevels")));
preset_button->setMenu(m_view->presetMenu());
preset_button->setToolTip(i18n("Presets"));
}
connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &ClipStabilize::slotValidate);
connect(button_reset, &QPushButton::clicked, this, &ClipStabilize::resetValues);
adjustSize();
}
......@@ -159,23 +162,7 @@ void ClipStabilize::slotValidate()
}
}
}
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/effects/presets/"));
if (!dir.exists()) {
dir.mkpath(QStringLiteral("."));
}
const QString presetFile = dir.absoluteFilePath(QString("%1.json").arg(m_assetModel->getAssetId()));
m_assetModel->savePreset(presetFile, QStringLiteral("lastsetting"));
m_view->slotSavePreset(i18n("Last setting"));
accept();
}
void ClipStabilize::resetValues()
{
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/effects/presets/"));
if (dir.exists()) {
const QString presetFile = dir.absoluteFilePath(QString("%1.json").arg(m_assetModel->getAssetId()));
m_assetModel->deletePreset(presetFile, QStringLiteral("lastsetting"));
}
m_view->resetValues();
/*const QVector<QPair<QString, QVariant>> values = m_view->getDefaultValues();
m_assetModel->setParameters(values);*/
}
......@@ -50,7 +50,6 @@ public:
QString filterName() const;
private slots:
void slotValidate();
void resetValues();
private:
QString m_filtername;
......
......@@ -239,6 +239,7 @@ bool ProjectManager::closeCurrentDocument(bool saveChanges, bool quit)
break;
}
}
pCore->jobManager()->slotCancelJobs();
disconnect(pCore->window()->getMainTimeline()->controller(), &TimelineController::durationChanged, this, &ProjectManager::adjustProjectDuration);
pCore->window()->getMainTimeline()->controller()->clipActions.clear();
pCore->window()->getMainTimeline()->controller()->prepareClose();
......
......@@ -14,10 +14,7 @@
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1" colspan="2">
<widget class="KUrlRequester" name="dest_url"/>
</item>
<item row="1" column="0" colspan="3">
<item row="1" column="0" colspan="4">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Options</string>
......@@ -31,13 +28,10 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QWidget" name="optionsbox" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="4" column="0" colspan="4">
<widget class="QCheckBox" name="auto_add">
<property name="text">
<string>Add clip to project</string>
</property>
</widget>
</item>
......@@ -54,14 +48,40 @@
</property>
</spacer>
</item>
<item row="0" column="2" colspan="2">
<widget class="KUrlRequester" name="dest_url"/>
</item>
<item row="5" column="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Abort|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="2" column="0" colspan="4">
<widget class="QWidget" name="optionsbox" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="button_reset">
<widget class="QToolButton" name="preset_button">
<property name="text">
<string>Reset</string>
<string>...</string>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="5" column="1" colspan="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -74,23 +94,6 @@
</property>
</spacer>
</item>
<item row="5" column="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Abort|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="auto_add">
<property name="text">
<string>Add clip to project</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......
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