forked from mltframework/shotcut
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblipproducerwidget.cpp
More file actions
88 lines (78 loc) · 2.59 KB
/
blipproducerwidget.cpp
File metadata and controls
88 lines (78 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* Copyright (c) 2020 Meltytech, LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "shotcut_mlt_properties.h"
#include "blipproducerwidget.h"
#include "ui_blipproducerwidget.h"
#include "util.h"
#include <MltProfile.h>
BlipProducerWidget::BlipProducerWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::BlipProducerWidget)
{
ui->setupUi(this);
Util::setColorsToHighlight(ui->nameLabel);
ui->preset->saveDefaultPreset(getPreset());
ui->preset->loadPresets();
on_periodSpinBox_valueChanged(ui->periodSpinBox->value());
}
BlipProducerWidget::~BlipProducerWidget()
{
delete ui;
}
Mlt::Producer *BlipProducerWidget::newProducer(Mlt::Profile &profile)
{
Mlt::Producer *p = new Mlt::Producer(profile, "blipflash:");
p->set("period", ui->periodSpinBox->value());
p->set("force_seekable", 1);
p->set(kShotcutCaptionProperty, ui->nameLabel->text().toUtf8().constData());
p->set(kShotcutDetailProperty, detail().toUtf8().constData());
return p;
}
Mlt::Properties BlipProducerWidget::getPreset() const
{
Mlt::Properties p;
p.set("period", ui->periodSpinBox->value());
return p;
}
void BlipProducerWidget::loadPreset(Mlt::Properties &p)
{
ui->periodSpinBox->setValue(p.get_int("period"));
p.set(kShotcutDetailProperty, detail().toUtf8().constData());
}
void BlipProducerWidget::on_periodSpinBox_valueChanged(int value)
{
ui->periodSpinBox->setSuffix(tr(" second(s)", nullptr, value));
if (m_producer) {
m_producer->set("period", value);
m_producer->set(kShotcutDetailProperty, detail().toUtf8().constData());
emit producerChanged(producer());
}
}
void BlipProducerWidget::on_preset_selected(void *p)
{
Mlt::Properties *properties = (Mlt::Properties *) p;
loadPreset(*properties);
delete properties;
}
void BlipProducerWidget::on_preset_saveClicked()
{
ui->preset->savePreset(getPreset());
}
QString BlipProducerWidget::detail() const
{
return QString(tr("Period: %1s")).arg(ui->periodSpinBox->value());
}