Changeset View
Changeset View
Standalone View
Standalone View
src/assets/view/widgets/keyframewidget.cpp
Show All 30 Lines | |||||
31 | 31 | | |||
32 | #include <KSelectAction> | 32 | #include <KSelectAction> | ||
33 | #include <QToolButton> | 33 | #include <QToolButton> | ||
34 | #include <QVBoxLayout> | 34 | #include <QVBoxLayout> | ||
35 | #include <klocalizedstring.h> | 35 | #include <klocalizedstring.h> | ||
36 | 36 | | |||
37 | KeyframeWidget::KeyframeWidget(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QWidget *parent) | 37 | KeyframeWidget::KeyframeWidget(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QWidget *parent) | ||
38 | : AbstractParamWidget(model, index, parent) | 38 | : AbstractParamWidget(model, index, parent) | ||
39 | , m_rotationWidget(nullptr) | ||||
39 | { | 40 | { | ||
40 | m_keyframes = model->getKeyframeModel(); | 41 | m_keyframes = model->getKeyframeModel(); | ||
41 | 42 | | |||
42 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); | 43 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); | ||
43 | 44 | | |||
44 | m_lay = new QVBoxLayout(this); | 45 | m_lay = new QVBoxLayout(this); | ||
45 | 46 | | |||
46 | bool ok = false; | 47 | bool ok = false; | ||
Show All 11 Lines | |||||
58 | m_buttonPrevious->setAutoRaise(true); | 59 | m_buttonPrevious->setAutoRaise(true); | ||
59 | m_buttonPrevious->setIcon(KoIconUtils::themedIcon(QStringLiteral("media-skip-backward"))); | 60 | m_buttonPrevious->setIcon(KoIconUtils::themedIcon(QStringLiteral("media-skip-backward"))); | ||
60 | m_buttonPrevious->setToolTip(i18n("Go to previous keyframe")); | 61 | m_buttonPrevious->setToolTip(i18n("Go to previous keyframe")); | ||
61 | 62 | | |||
62 | m_buttonNext = new QToolButton(this); | 63 | m_buttonNext = new QToolButton(this); | ||
63 | m_buttonNext->setAutoRaise(true); | 64 | m_buttonNext->setAutoRaise(true); | ||
64 | m_buttonNext->setIcon(KoIconUtils::themedIcon(QStringLiteral("media-skip-forward"))); | 65 | m_buttonNext->setIcon(KoIconUtils::themedIcon(QStringLiteral("media-skip-forward"))); | ||
65 | m_buttonNext->setToolTip(i18n("Go to next keyframe")); | 66 | m_buttonNext->setToolTip(i18n("Go to next keyframe")); | ||
67 | m_defaultSize = pCore->getCurrentFrameSize(); | ||||
66 | 68 | | |||
67 | // Keyframe type widget | 69 | // Keyframe type widget | ||
68 | m_selectType = new KSelectAction(KoIconUtils::themedIcon(QStringLiteral("keyframes")), i18n("Keyframe interpolation"), this); | 70 | m_selectType = new KSelectAction(KoIconUtils::themedIcon(QStringLiteral("keyframes")), i18n("Keyframe interpolation"), this); | ||
69 | QAction *linear = new QAction(KoIconUtils::themedIcon(QStringLiteral("linear")), i18n("Linear"), this); | 71 | QAction *linear = new QAction(KoIconUtils::themedIcon(QStringLiteral("linear")), i18n("Linear"), this); | ||
70 | linear->setData((int)mlt_keyframe_linear); | 72 | linear->setData((int)mlt_keyframe_linear); | ||
71 | linear->setCheckable(true); | 73 | linear->setCheckable(true); | ||
72 | m_selectType->addAction(linear); | 74 | m_selectType->addAction(linear); | ||
73 | QAction *discrete = new QAction(KoIconUtils::themedIcon(QStringLiteral("discrete")), i18n("Discrete"), this); | 75 | QAction *discrete = new QAction(KoIconUtils::themedIcon(QStringLiteral("discrete")), i18n("Discrete"), this); | ||
▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Line(s) | 266 | } else { | |||
267 | double max = m_model->data(index, AssetParameterModel::MaxRole).toDouble(); | 269 | double max = m_model->data(index, AssetParameterModel::MaxRole).toDouble(); | ||
268 | double defaultValue = locale.toDouble(m_model->data(index, AssetParameterModel::DefaultRole).toString()); | 270 | double defaultValue = locale.toDouble(m_model->data(index, AssetParameterModel::DefaultRole).toString()); | ||
269 | int decimals = m_model->data(index, AssetParameterModel::DecimalsRole).toInt(); | 271 | int decimals = m_model->data(index, AssetParameterModel::DecimalsRole).toInt(); | ||
270 | double factor = m_model->data(index, AssetParameterModel::FactorRole).toDouble(); | 272 | double factor = m_model->data(index, AssetParameterModel::FactorRole).toDouble(); | ||
271 | auto doubleWidget = new DoubleWidget(name, value, min, max, defaultValue, comment, -1, suffix, decimals, this); | 273 | auto doubleWidget = new DoubleWidget(name, value, min, max, defaultValue, comment, -1, suffix, decimals, this); | ||
272 | doubleWidget->factor = factor; | 274 | doubleWidget->factor = factor; | ||
273 | connect(doubleWidget, &DoubleWidget::valueChanged, | 275 | connect(doubleWidget, &DoubleWidget::valueChanged, | ||
274 | [this, index](double v) { m_keyframes->updateKeyframe(GenTime(getPosition(), pCore->getCurrentFps()), QVariant(v), index); }); | 276 | [this, index](double v) { m_keyframes->updateKeyframe(GenTime(getPosition(), pCore->getCurrentFps()), QVariant(v), index); }); | ||
277 | if (m_model->data(index, AssetParameterModel::NameRole).toString() == QLatin1String("rotation")) { | ||||
278 | m_rotationWidget = doubleWidget; | ||||
279 | qDebug()<<"/// FOUND ROTATION PARAMETER; CONNECTING"; | ||||
280 | Monitor *monitor = pCore->getMonitor(m_model->monitorId); | ||||
281 | connect(monitor, &Monitor::angleChanged, | ||||
282 | [this, doubleWidget] (const double &angle) { | ||||
283 | doubleWidget->setValue(angle); | ||||
284 | doubleWidget->valueChanged(angle); | ||||
285 | }); | ||||
286 | } | ||||
275 | paramWidget = doubleWidget; | 287 | paramWidget = doubleWidget; | ||
276 | } | 288 | } | ||
277 | if (paramWidget) { | 289 | if (paramWidget) { | ||
278 | m_parameters[index] = paramWidget; | 290 | m_parameters[index] = paramWidget; | ||
279 | m_lay->addWidget(paramWidget); | 291 | m_lay->addWidget(paramWidget); | ||
280 | } | 292 | } | ||
281 | } | 293 | } |