File indexing completed on 2024-05-12 04:52:54
0001 /* 0002 SPDX-FileCopyrightText: 2011 Till Theato <root@ttill.de> 0003 SPDX-FileCopyrightText: 2017 Nicolas Carion 0004 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include "abstractparamwidget.hpp" 0010 0011 #include "definitions.h" 0012 #include <QPersistentModelIndex> 0013 #include <memory> 0014 #include <unordered_map> 0015 0016 class AssetParameterModel; 0017 class DoubleWidget; 0018 class KeyframeView; 0019 class KeyframeModelList; 0020 class QVBoxLayout; 0021 class QToolButton; 0022 class QToolBar; 0023 class TimecodeDisplay; 0024 class KSelectAction; 0025 class KeyframeMonitorHelper; 0026 class KDualAction; 0027 0028 class KeyframeWidget : public AbstractParamWidget 0029 { 0030 Q_OBJECT 0031 0032 public: 0033 explicit KeyframeWidget(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QSize frameSize, QWidget *parent = nullptr); 0034 ~KeyframeWidget() override; 0035 0036 /** @brief Add a new parameter to be managed using the same keyframe viewer */ 0037 void addParameter(const QPersistentModelIndex &index); 0038 int getPosition() const; 0039 /** @brief Returns the monitor scene required for this asset 0040 */ 0041 MonitorSceneType requiredScene() const; 0042 /** @brief Show / hide keyframe related widgets 0043 */ 0044 void showKeyframes(bool enable); 0045 /** @brief Returns true if keyframes options are visible 0046 */ 0047 bool keyframesVisible() const; 0048 void resetKeyframes(); 0049 0050 public Q_SLOTS: 0051 void slotRefresh() override; 0052 /** @brief initialize qml overlay 0053 */ 0054 void slotInitMonitor(bool active) override; 0055 /** @brief Activate a standard action passed from the mainwindow, like copy or paste */ 0056 void sendStandardCommand(int command); 0057 0058 public Q_SLOTS: 0059 void slotSetPosition(int pos = -1, bool update = true); 0060 0061 private Q_SLOTS: 0062 /** @brief Update the value of the widgets to reflect keyframe change */ 0063 void slotRefreshParams(); 0064 void slotAtKeyframe(bool atKeyframe, bool singleKeyframe); 0065 void slotEditKeyframeType(QAction *action); 0066 void slotUpdateKeyframesFromMonitor(const QPersistentModelIndex &index, const QVariant &res); 0067 /** @brief Paste a keyframe from clipboard */ 0068 void slotPasteKeyframeFromClipBoard(); 0069 void slotCopySelectedKeyframes(); 0070 void slotCopyKeyframes(); 0071 void slotCopyValueAtCursorPos(); 0072 void slotImportKeyframes(); 0073 void slotRemoveNextKeyframes(); 0074 void slotSeekToKeyframe(int ix); 0075 void monitorSeek(int pos); 0076 void disconnectEffectStack(); 0077 0078 private: 0079 QVBoxLayout *m_lay; 0080 QToolBar *m_toolbar; 0081 std::shared_ptr<KeyframeModelList> m_keyframes; 0082 KeyframeView *m_keyframeview; 0083 KeyframeMonitorHelper *m_monitorHelper; 0084 KDualAction *m_addDeleteAction; 0085 QAction *m_centerAction; 0086 QAction *m_copyAction; 0087 QAction *m_pasteAction; 0088 KSelectAction *m_selectType; 0089 TimecodeDisplay *m_time; 0090 MonitorSceneType m_neededScene; 0091 QSize m_sourceFrameSize; 0092 void connectMonitor(bool active); 0093 std::unordered_map<QPersistentModelIndex, QWidget *> m_parameters; 0094 int m_baseHeight; 0095 int m_addedHeight; 0096 0097 Q_SIGNALS: 0098 void addIndex(QPersistentModelIndex ix); 0099 void setKeyframes(const QString &); 0100 void updateEffectKeyframe(bool); 0101 void goToNext(); 0102 void goToPrevious(); 0103 void addRemove(); 0104 };