File indexing completed on 2024-05-12 04:52:53

0001 /*
0002     SPDX-FileCopyrightText: 2016 Jean-Baptiste Mardelle <jb@kdenlive.org>
0003     SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 */
0005 
0006 #pragma once
0007 
0008 #include <QDialog>
0009 #include <QDoubleSpinBox>
0010 #include <QLabel>
0011 
0012 #include "assets/model/assetparametermodel.hpp"
0013 #include "definitions.h"
0014 #include "utils/timecode.h"
0015 
0016 class PositionWidget;
0017 class QComboBox;
0018 class QCheckBox;
0019 class QSpinBox;
0020 
0021 namespace Mlt {
0022 }
0023 
0024 class KeyframeImport : public QDialog
0025 {
0026     Q_OBJECT
0027 public:
0028     explicit KeyframeImport(const QString &animData, std::shared_ptr<AssetParameterModel> model, const QList<QPersistentModelIndex> &indexes, int parentIn, int parentDuration, QWidget *parent = nullptr);
0029     ~KeyframeImport() override;
0030     QString selectedData() const;
0031     void importSelectedData();
0032     QString selectedTarget() const;
0033     int getImportType() const;
0034 
0035 private:
0036     std::shared_ptr<AssetParameterModel> m_model;
0037     QMap <QPersistentModelIndex, QString> m_originalParams;
0038     QList<QPersistentModelIndex> m_indexes;
0039     bool m_supportsAnim;
0040     QComboBox *m_dataCombo;
0041     QLabel *m_previewLabel;
0042     PositionWidget *m_inPoint;
0043     PositionWidget *m_outPoint;
0044     PositionWidget *m_offsetPoint;
0045     QCheckBox *m_limitRange;
0046     QCheckBox *m_limitKeyframes;
0047     QSpinBox *m_limitNumber;
0048     QComboBox *m_sourceCombo;
0049     QComboBox *m_targetCombo;
0050     QComboBox *m_alignSourceCombo;
0051     QComboBox *m_alignTargetCombo;
0052     QLabel *m_sourceRangeLabel;
0053     QList<QPoint> m_maximas;
0054     QDoubleSpinBox m_destMin;
0055     QDoubleSpinBox m_destMax;
0056     QSpinBox m_offsetX;
0057     QSpinBox m_offsetY;
0058     /** @brief Contains the 4 dimensional (x,y,w,h) target parameter names / tag **/
0059     QMap<QString, QModelIndex> m_geometryTargets;
0060     /** @brief Contains the 1 dimensional target parameter names / tag **/
0061     QMap<QString, QModelIndex> m_simpleTargets;
0062     bool m_isReady;
0063     void drawKeyFrameChannels(QPixmap &pix, int in, int out, int limitKeyframes, const QColor &textColor);
0064 
0065 protected:
0066     enum ImportRoles {
0067         SimpleValue,
0068         RotoData,
0069         FullGeometry,
0070         Position,
0071         InvertedPosition,
0072         OffsetPosition,
0073         XOnly,
0074         YOnly,
0075         WidthOnly,
0076         HeightOnly
0077     };
0078     enum { ValueRole = Qt::UserRole, TypeRole, MinRole, MaxRole, OpacityRole };
0079     mutable QReadWriteLock m_lock; // This is a lock that ensures safety in case of concurrent access
0080     void resizeEvent(QResizeEvent *ev) override;
0081 
0082 private Q_SLOTS:
0083     void updateDataDisplay();
0084     void updateDisplay();
0085     void updateRange();
0086     void updateDestinationRange();
0087     void updateView();
0088 
0089 public Q_SLOTS:
0090     virtual void accept() override;
0091     virtual void reject() override;
0092 
0093 Q_SIGNALS:
0094     void updateQmlView();
0095 };