Deprecate videostab and videostab2, only keep vidstab filter.

Remember last settings and allow reset to default
parent 42135fe9
Pipeline #7396 passed with stage
in 13 minutes and 32 seconds
......@@ -140,7 +140,12 @@ void AssetParameterView::resetValues()
{
const QVector<QPair<QString, QVariant>> values = getDefaultValues();
auto *command = new AssetUpdateCommand(m_model, values);
pCore->pushUndo(command);
if (m_model->getOwnerId().second != -1) {
pCore->pushUndo(command);
} else {
command->redo();
delete command;
}
// Unselect preset if any
QAction *ac = m_presetGroup->checkedAction();
if (ac) {
......
......@@ -76,7 +76,7 @@ void StabilizeJob::configureFilter()
// static
std::unordered_set<QString> StabilizeJob::supportedFilters()
{
return {QLatin1String("vidstab"), QLatin1String("videostab2"), QLatin1String("videostab")};
return {QLatin1String("vidstab")};
}
// static
......@@ -84,7 +84,7 @@ int StabilizeJob::prepareJob(const std::shared_ptr<JobManager> &ptr, const std::
const QString &filterName)
{
Q_ASSERT(supportedFilters().count(filterName) > 0);
if (filterName == QLatin1String("vidstab") || filterName == QLatin1String("videostab2") || filterName == QLatin1String("videostab")) {
if (filterName == QLatin1String("vidstab")) {
// vidstab
QScopedPointer<ClipStabilize> d(new ClipStabilize(binIds, filterName, 100000));
if (d->exec() == QDialog::Accepted) {
......
......@@ -3046,7 +3046,7 @@ void MainWindow::buildDynamicActions()
Mlt::Profile profile;
std::unique_ptr<Mlt::Filter> filter;
for (const QString &stab : {QStringLiteral("vidstab"), QStringLiteral("videostab2"), QStringLiteral("videostab")}) {
for (const QString &stab : {QStringLiteral("vidstab")}) {
filter = std::make_unique<Mlt::Filter>(profile, stab.toUtf8().constData());
if ((filter != nullptr) && filter->is_valid()) {
QAction *action = new QAction(i18n("Stabilize (%1)", stab), m_extraFactory->actionCollection());
......
......@@ -63,17 +63,25 @@ ClipStabilize::ClipStabilize(const std::vector<QString> &binIds, QString filterN
dest_url->setUrl(QUrl(firstUrl).adjusted(QUrl::RemoveFilename));
}
m_vbox = new QVBoxLayout(optionsbox);
if (m_filtername == QLatin1String("vidstab") || m_filtername == QLatin1String("videostab2")) {
AssetParameterView *view = new AssetParameterView(this);
if (m_filtername == QLatin1String("vidstab")) {
m_view.reset(new AssetParameterView(this));
qDebug()<<"// Fetching effect: "<<m_filtername;
std::unique_ptr<Mlt::Filter> asset = EffectsRepository::get()->getEffect(m_filtername);
auto prop = std::make_unique<Mlt::Properties>(asset->get_properties());
QDomElement xml = EffectsRepository::get()->getXml(m_filtername);
m_assetModel.reset(new AssetParameterModel(std::move(prop), xml, m_filtername, {ObjectType::NoItem, -1}));
view->setModel(m_assetModel, QSize(1920, 1080));
m_vbox->addWidget(view);
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"));
if (!params.isEmpty()) {
m_assetModel->setParameters(params);
}
m_view->setModel(m_assetModel, QSize(1920, 1080));
m_vbox->addWidget(m_view.get());
}
connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &ClipStabilize::slotValidate);
connect(button_reset, &QPushButton::clicked, this, &ClipStabilize::resetValues);
adjustSize();
}
......@@ -151,5 +159,23 @@ 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"));
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);*/
}
......@@ -28,6 +28,7 @@
#include <unordered_map>
class AssetParameterModel;
class AssetParameterView;
class ClipStabilize : public QDialog, public Ui::ClipStabilize_UI
{
......@@ -49,13 +50,15 @@ public:
QString filterName() const;
private slots:
void slotValidate();
void resetValues();
private:
QString m_filtername;
std::vector<QString> m_binIds;
QVBoxLayout *m_vbox;
Timecode m_tc;
std::shared_ptr<AssetParameterModel>m_assetModel;
std::shared_ptr<AssetParameterModel> m_assetModel;
std::unique_ptr<AssetParameterView> m_view;
signals:
void addClip(const QUrl &url);
......
......@@ -6,21 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>304</width>
<height>125</height>
<width>349</width>
<height>160</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_dest">
<property name="text">
<string>Destination</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="KUrlRequester" name="dest_url"/>
</item>
......@@ -31,6 +24,13 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_dest">
<property name="text">
<string>Destination</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QWidget" name="optionsbox" native="true">
<property name="sizePolicy">
......@@ -41,24 +41,27 @@
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QDialogButtonBox" name="buttonBox">
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Abort|QDialogButtonBox::Ok</set>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</widget>
</spacer>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="auto_add">
<item row="5" column="0">
<widget class="QPushButton" name="button_reset">
<property name="text">
<string>Add clip to project</string>
<string>Reset</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="5" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -71,18 +74,22 @@
</property>
</spacer>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<item row="5" column="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<property name="standardButtons">
<set>QDialogButtonBox::Abort|QDialogButtonBox::Ok</set>
</property>
</spacer>
</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>
......@@ -91,6 +98,7 @@
<class>KUrlRequester</class>
<extends>QFrame</extends>
<header>kurlrequester.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
......
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