File indexing completed on 2024-05-19 04:54:25
0001 /* 0002 SPDX-FileCopyrightText: 2017 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 "definitions.h" 0009 #include <QMutex> 0010 #include <QStyledItemDelegate> 0011 #include <QTimer> 0012 #include <QWidget> 0013 #include <memory> 0014 0015 class QVBoxLayout; 0016 class QTreeView; 0017 class CollapsibleEffectView; 0018 class AssetParameterModel; 0019 class EffectStackModel; 0020 class EffectItemModel; 0021 class AssetIconProvider; 0022 class BuiltStack; 0023 class AssetPanel; 0024 0025 class WidgetDelegate : public QStyledItemDelegate 0026 { 0027 Q_OBJECT 0028 public: 0029 explicit WidgetDelegate(QObject *parent = nullptr); 0030 void setHeight(const QModelIndex &index, int height); 0031 int height(const QModelIndex &index) const; 0032 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0033 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0034 0035 private: 0036 QMap<QModelIndex, int> m_height; 0037 }; 0038 0039 class EffectStackView : public QWidget 0040 { 0041 Q_OBJECT 0042 0043 public: 0044 EffectStackView(AssetPanel *parent); 0045 ~EffectStackView() override; 0046 void setModel(std::shared_ptr<EffectStackModel> model, const QSize frameSize); 0047 void unsetModel(bool reset = true); 0048 ObjectId stackOwner() const; 0049 /** @brief Add an effect to the current stack 0050 */ 0051 bool addEffect(const QString &effectId); 0052 /** @brief Returns true if effectstack is empty 0053 */ 0054 bool isEmpty() const; 0055 /** @brief Enables / disables the stack 0056 */ 0057 void enableStack(bool enable); 0058 bool isStackEnabled() const; 0059 /** @brief Collapse / expand current effect 0060 */ 0061 void switchCollapsed(); 0062 /** @brief Go to next keyframe in current effect 0063 */ 0064 void slotGoToKeyframe(bool next); 0065 void addRemoveKeyframe(); 0066 /** @brief Used to pass a standard action like copy or paste to the effect stack widget */ 0067 void sendStandardCommand(int command); 0068 0069 public Q_SLOTS: 0070 /** @brief Save current effect stack 0071 */ 0072 void slotSaveStack(); 0073 0074 protected: 0075 void dragEnterEvent(QDragEnterEvent *event) override; 0076 void dragLeaveEvent(QDragLeaveEvent *event) override; 0077 void dragMoveEvent(QDragMoveEvent *event) override; 0078 void dropEvent(QDropEvent *event) override; 0079 void resizeEvent(QResizeEvent *event) override; 0080 void paintEvent(QPaintEvent *event) override; 0081 0082 private: 0083 QMutex m_mutex; 0084 QVBoxLayout *m_lay; 0085 // BuiltStack *m_builtStack; 0086 QTreeView *m_effectsTree; 0087 std::shared_ptr<EffectStackModel> m_model; 0088 std::vector<CollapsibleEffectView *> m_widgets; 0089 AssetIconProvider *m_thumbnailer; 0090 QTimer m_scrollTimer; 0091 QTimer m_timerHeight; 0092 0093 /** @brief the frame size of the original clip this effect is applied on 0094 */ 0095 QSize m_sourceFrameSize; 0096 const QString getStyleSheet(); 0097 0098 private Q_SLOTS: 0099 void refresh(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles); 0100 void slotAdjustDelegate(const std::shared_ptr<EffectItemModel> &effectModel, int height); 0101 void slotStartDrag(const QPixmap pix, const QString assetId, ObjectId sourceObject, int row); 0102 void loadEffects(); 0103 void updateTreeHeight(); 0104 void slotFocusEffect(); 0105 /** @brief Refresh the enabled state on widgets 0106 */ 0107 void changeEnabledState(); 0108 /** @brief Activate an effect in the view 0109 */ 0110 void activateEffect(const QModelIndex &ix, bool active); 0111 0112 // void switchBuiltStack(bool show); 0113 0114 Q_SIGNALS: 0115 void switchCollapsedView(int row); 0116 void seekToPos(int); 0117 void reloadEffect(const QString &path); 0118 void updateEnabledState(); 0119 void removeCurrentEffect(); 0120 void blockWheelEvent(bool block); 0121 void checkScrollBar(); 0122 void scrollView(QRect); 0123 };