Changeset View
Changeset View
Standalone View
Standalone View
src/assets/view/widgets/animationwidget.cpp
Show First 20 Lines • Show All 798 Lines • ▼ Show 20 Line(s) | 798 | new DoubleWidget(paramName, 0, m_model->data(ix, AssetParameterModel::MinRole).toDouble(), m_model->data(ix, AssetParameterModel::MaxRole).toDouble(), | |||
---|---|---|---|---|---|
799 | m_model->data(ix, AssetParameterModel::DefaultRole).toDouble() * factor, comment, index, | 799 | m_model->data(ix, AssetParameterModel::DefaultRole).toDouble() * factor, comment, index, | ||
800 | m_model->data(ix, AssetParameterModel::SuffixRole).toString(), m_model->data(ix, AssetParameterModel::DecimalsRole).toInt(), this); | 800 | m_model->data(ix, AssetParameterModel::SuffixRole).toString(), m_model->data(ix, AssetParameterModel::DecimalsRole).toInt(), this); | ||
801 | doubleparam->setObjectName(paramTag); | 801 | doubleparam->setObjectName(paramTag); | ||
802 | doubleparam->setProperty("index", ix); | 802 | doubleparam->setProperty("index", ix); | ||
803 | doubleparam->factor = factor; | 803 | doubleparam->factor = factor; | ||
804 | connect(doubleparam, &DoubleWidget::valueChanged, this, &AnimationWidget::slotAdjustKeyframeValue); | 804 | connect(doubleparam, &DoubleWidget::valueChanged, this, &AnimationWidget::slotAdjustKeyframeValue); | ||
805 | layout()->addWidget(doubleparam); | 805 | layout()->addWidget(doubleparam); | ||
806 | 806 | | |||
807 | m_monitor->setEffectSceneProperty(QStringLiteral("showRotation"), true); | ||||
808 | m_rotationWidget = DoubleWidget *doubleparam; | ||||
807 | // TODO: in timeline | 809 | // TODO: in timeline | ||
808 | /*if ((!e.hasAttribute(QStringLiteral("intimeline")) || e.attribute(QStringLiteral("intimeline")) == QLatin1String("1")) && | 810 | /*if ((!e.hasAttribute(QStringLiteral("intimeline")) || e.attribute(QStringLiteral("intimeline")) == QLatin1String("1")) && | ||
809 | !e.hasAttribute(QStringLiteral("notintimeline"))) {*/ | 811 | !e.hasAttribute(QStringLiteral("notintimeline"))) {*/ | ||
810 | { | 812 | { | ||
811 | m_inTimeline = paramTag; | 813 | m_inTimeline = paramTag; | ||
812 | m_animController = m_animProperties.get_animation(m_inTimeline.toUtf8().constData()); | 814 | m_animController = m_animProperties.get_animation(m_inTimeline.toUtf8().constData()); | ||
813 | } | 815 | } | ||
814 | m_doubleWidgets.insert(paramTag, doubleparam); | 816 | m_doubleWidgets.insert(paramTag, doubleparam); | ||
Show All 39 Lines | 820 | { | |||
854 | m_spinSize->setStep(10); | 856 | m_spinSize->setStep(10); | ||
855 | connect(m_spinSize, &DragValue::valueChanged, this, &AnimationWidget::slotResize); | 857 | connect(m_spinSize, &DragValue::valueChanged, this, &AnimationWidget::slotResize); | ||
856 | horLayout2->addWidget(m_spinSize); | 858 | horLayout2->addWidget(m_spinSize); | ||
857 | if (m_model->data(ix, AssetParameterModel::OpacityRole).toBool()) { | 859 | if (m_model->data(ix, AssetParameterModel::OpacityRole).toBool()) { | ||
858 | m_spinOpacity = new DragValue(i18n("Opacity"), 100, 0, 0, 100, -1, i18n("%"), true, this); | 860 | m_spinOpacity = new DragValue(i18n("Opacity"), 100, 0, 0, 100, -1, i18n("%"), true, this); | ||
859 | connect(m_spinOpacity, &DragValue::valueChanged, this, &AnimationWidget::slotAdjustRectKeyframeValue); | 861 | connect(m_spinOpacity, &DragValue::valueChanged, this, &AnimationWidget::slotAdjustRectKeyframeValue); | ||
860 | horLayout2->addWidget(m_spinOpacity); | 862 | horLayout2->addWidget(m_spinOpacity); | ||
861 | } | 863 | } | ||
862 | 864 | m_monitor->setEffectSceneProperty(QStringLiteral("showOpacity"),m_spinOpacity!=nullptr); | |||
863 | // Build buttons | 865 | // Build buttons | ||
864 | m_originalSize = new QAction(KoIconUtils::themedIcon(QStringLiteral("zoom-original")), i18n("Adjust to original size"), this); | 866 | m_originalSize = new QAction(KoIconUtils::themedIcon(QStringLiteral("zoom-original")), i18n("Adjust to original size"), this); | ||
865 | connect(m_originalSize, &QAction::triggered, this, &AnimationWidget::slotAdjustToSource); | 867 | connect(m_originalSize, &QAction::triggered, this, &AnimationWidget::slotAdjustToSource); | ||
866 | m_originalSize->setCheckable(true); | 868 | m_originalSize->setCheckable(true); | ||
867 | QAction *adjustSize = new QAction(KoIconUtils::themedIcon(QStringLiteral("zoom-fit-best")), i18n("Adjust and center in frame"), this); | 869 | QAction *adjustSize = new QAction(KoIconUtils::themedIcon(QStringLiteral("zoom-fit-best")), i18n("Adjust and center in frame"), this); | ||
868 | connect(adjustSize, &QAction::triggered, this, &AnimationWidget::slotAdjustToFrameSize); | 870 | connect(adjustSize, &QAction::triggered, this, &AnimationWidget::slotAdjustToFrameSize); | ||
869 | QAction *fitToWidth = new QAction(KoIconUtils::themedIcon(QStringLiteral("zoom-fit-width")), i18n("Fit to width"), this); | 871 | QAction *fitToWidth = new QAction(KoIconUtils::themedIcon(QStringLiteral("zoom-fit-width")), i18n("Fit to width"), this); | ||
870 | connect(fitToWidth, &QAction::triggered, this, &AnimationWidget::slotFitToWidth); | 872 | connect(fitToWidth, &QAction::triggered, this, &AnimationWidget::slotFitToWidth); | ||
▲ Show 20 Lines • Show All 466 Lines • ▼ Show 20 Line(s) | 1335 | { | |||
1337 | m_active = activate; | 1339 | m_active = activate; | ||
1338 | if (!m_spinX) { | 1340 | if (!m_spinX) { | ||
1339 | // No animated rect displayed in monitor, return | 1341 | // No animated rect displayed in monitor, return | ||
1340 | return; | 1342 | return; | ||
1341 | } | 1343 | } | ||
1342 | if (activate) { | 1344 | if (activate) { | ||
1343 | connect(m_monitor, &Monitor::effectChanged, this, &AnimationWidget::slotUpdateGeometryRect, Qt::UniqueConnection); | 1345 | connect(m_monitor, &Monitor::effectChanged, this, &AnimationWidget::slotUpdateGeometryRect, Qt::UniqueConnection); | ||
1344 | connect(m_monitor, &Monitor::effectPointsChanged, this, &AnimationWidget::slotUpdateCenters, Qt::UniqueConnection); | 1346 | connect(m_monitor, &Monitor::effectPointsChanged, this, &AnimationWidget::slotUpdateCenters, Qt::UniqueConnection); | ||
1347 | connect(m_monitor, &Monitor::opacityChanged, this, &AnimationWidget::slotUpdateOpacity, Qt::UniqueConnection); | ||||
1348 | connect(m_monitor, &Monitor::angleChanged, this, &AnimationWidget::slotUpdateRotation, Qt::UniqueConnection); | ||||
1345 | connect(m_monitor, &Monitor::seekToKeyframe, this, &AnimationWidget::slotSeekToKeyframe, Qt::UniqueConnection); | 1349 | connect(m_monitor, &Monitor::seekToKeyframe, this, &AnimationWidget::slotSeekToKeyframe, Qt::UniqueConnection); | ||
1346 | connect(m_monitor, &Monitor::seekToNextKeyframe, this, &AnimationWidget::slotNext, Qt::UniqueConnection); | 1350 | connect(m_monitor, &Monitor::seekToNextKeyframe, this, &AnimationWidget::slotNext, Qt::UniqueConnection); | ||
1347 | connect(m_monitor, &Monitor::seekToPreviousKeyframe, this, &AnimationWidget::slotPrevious, Qt::UniqueConnection); | 1351 | connect(m_monitor, &Monitor::seekToPreviousKeyframe, this, &AnimationWidget::slotPrevious, Qt::UniqueConnection); | ||
1348 | connect(m_monitor, SIGNAL(addKeyframe()), this, SLOT(slotAddKeyframe()), Qt::UniqueConnection); | 1352 | connect(m_monitor, SIGNAL(addKeyframe()), this, SLOT(slotAddKeyframe()), Qt::UniqueConnection); | ||
1349 | connect(m_monitor, SIGNAL(deleteKeyframe()), this, SLOT(slotDeleteKeyframe()), Qt::UniqueConnection); | 1353 | connect(m_monitor, SIGNAL(deleteKeyframe()), this, SLOT(slotDeleteKeyframe()), Qt::UniqueConnection); | ||
1350 | int framePos = qBound<int>(0, m_monitor->position() - m_inPoint, m_timePos->maximum()); | 1354 | int framePos = qBound<int>(0, m_monitor->position() - m_inPoint, m_timePos->maximum()); | ||
1351 | slotPositionChanged(framePos, false); | 1355 | slotPositionChanged(framePos, false); | ||
1352 | double ratio = (double)m_spinWidth->value() / m_spinHeight->value(); | 1356 | double ratio = (double)m_spinWidth->value() / m_spinHeight->value(); | ||
1353 | if (m_frameSize.width() != m_monitorSize.width() || m_frameSize.height() != m_monitorSize.height()) { | 1357 | if (m_frameSize.width() != m_monitorSize.width() || m_frameSize.height() != m_monitorSize.height()) { | ||
1354 | // Source frame size different than project frame size, enable original size option accordingly | 1358 | // Source frame size different than project frame size, enable original size option accordingly | ||
1355 | bool isOriginalSize = | 1359 | bool isOriginalSize = | ||
1356 | qAbs((double)m_frameSize.width() / m_frameSize.height() - ratio) < qAbs((double)m_monitorSize.width() / m_monitorSize.height() - ratio); | 1360 | qAbs((double)m_frameSize.width() / m_frameSize.height() - ratio) < qAbs((double)m_monitorSize.width() / m_monitorSize.height() - ratio); | ||
1357 | if (isOriginalSize) { | 1361 | if (isOriginalSize) { | ||
1358 | m_originalSize->blockSignals(true); | 1362 | m_originalSize->blockSignals(true); | ||
1359 | m_originalSize->setChecked(true); | 1363 | m_originalSize->setChecked(true); | ||
1360 | m_originalSize->blockSignals(false); | 1364 | m_originalSize->blockSignals(false); | ||
1361 | } | 1365 | } | ||
1362 | } | 1366 | } | ||
1363 | } else { | 1367 | } else { | ||
1364 | disconnect(m_monitor, &Monitor::effectChanged, this, &AnimationWidget::slotUpdateGeometryRect); | 1368 | disconnect(m_monitor, &Monitor::effectChanged, this, &AnimationWidget::slotUpdateGeometryRect); | ||
1365 | disconnect(m_monitor, &Monitor::effectPointsChanged, this, &AnimationWidget::slotUpdateCenters); | 1369 | disconnect(m_monitor, &Monitor::effectPointsChanged, this, &AnimationWidget::slotUpdateCenters); | ||
1370 | disconnect(m_monitor, &Monitor::opacityChanged, this, &AnimationWidget::slotUpdateOpacity, Qt::UniqueConnection); | ||||
1371 | disconnect(m_monitor, &Monitor::angleChanged, this, &AnimationWidget::slotUpdateRotation, Qt::UniqueConnection); | ||||
1366 | disconnect(m_monitor, SIGNAL(addKeyframe()), this, SLOT(slotAddKeyframe())); | 1372 | disconnect(m_monitor, SIGNAL(addKeyframe()), this, SLOT(slotAddKeyframe())); | ||
1367 | disconnect(m_monitor, SIGNAL(deleteKeyframe()), this, SLOT(slotDeleteKeyframe())); | 1373 | disconnect(m_monitor, SIGNAL(deleteKeyframe()), this, SLOT(slotDeleteKeyframe())); | ||
1368 | disconnect(m_monitor, &Monitor::seekToNextKeyframe, this, &AnimationWidget::slotNext); | 1374 | disconnect(m_monitor, &Monitor::seekToNextKeyframe, this, &AnimationWidget::slotNext); | ||
1369 | disconnect(m_monitor, &Monitor::seekToPreviousKeyframe, this, &AnimationWidget::slotPrevious); | 1375 | disconnect(m_monitor, &Monitor::seekToPreviousKeyframe, this, &AnimationWidget::slotPrevious); | ||
1370 | disconnect(m_monitor, &Monitor::seekToKeyframe, this, &AnimationWidget::slotSeekToKeyframe); | 1376 | disconnect(m_monitor, &Monitor::seekToKeyframe, this, &AnimationWidget::slotSeekToKeyframe); | ||
1371 | } | 1377 | } | ||
1372 | } | 1378 | } | ||
1373 | 1379 | | |||
▲ Show 20 Lines • Show All 313 Lines • ▼ Show 20 Line(s) | |||||
1687 | void AnimationWidget::slotSetRange(QPair<int, int> range) | 1693 | void AnimationWidget::slotSetRange(QPair<int, int> range) | ||
1688 | { | 1694 | { | ||
1689 | m_inPoint = range.first; | 1695 | m_inPoint = range.first; | ||
1690 | m_outPoint = range.second; | 1696 | m_outPoint = range.second; | ||
1691 | m_offset = m_model->data(m_index, AssetParameterModel::InRole).toInt(); | 1697 | m_offset = m_model->data(m_index, AssetParameterModel::InRole).toInt(); | ||
1692 | m_ruler->setRange(0, m_outPoint - m_inPoint); | 1698 | m_ruler->setRange(0, m_outPoint - m_inPoint); | ||
1693 | m_timePos->setRange(0, m_outPoint - m_inPoint - 1); | 1699 | m_timePos->setRange(0, m_outPoint - m_inPoint - 1); | ||
1694 | } | 1700 | } | ||
1701 | | ||||
1702 | void AnimationWidget::slotUpdateOpacity(qreal value) | ||||
1703 | { | ||||
1704 | m_spinOpacity->setValue(value); | ||||
1705 | } | ||||
1706 | | ||||
1707 | void AnimationWidget::slotUpdateRotation(qreal value) | ||||
1708 | { | ||||
1709 | m_rotationWidget->setValue(value); | ||||
1710 | } |