X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fkeyframeedit.h;h=b804da41a1f7b80bd2bab06bc86f28472fc19217;hb=16e43620d9ff9e432ea91ded529f1e365d03fd52;hp=e9bca17bf76d55d9f1e011a4a1af922854198749;hpb=87eb54779133d012c59b642f7634391155e0c314;p=kdenlive diff --git a/src/keyframeedit.h b/src/keyframeedit.h index e9bca17b..b804da41 100644 --- a/src/keyframeedit.h +++ b/src/keyframeedit.h @@ -21,38 +21,113 @@ #include #include +#include +#include +#include +class QButtonGroup; #include "ui_keyframeeditor_ui.h" #include "definitions.h" #include "keyframehelper.h" -//class QGraphicsScene; +class KeyItemDelegate: public QItemDelegate +{ + Q_OBJECT +public: + KeyItemDelegate(int min, int max, QAbstractItemView* parent = 0): QItemDelegate(parent), m_min(min), m_max(max) { + } + + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { + if (index.column() == 1) { + QSpinBox *spin = new QSpinBox(parent); + connect(spin, SIGNAL(valueChanged(int)), this, SLOT(commitEditorData())); + connect(spin, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor())); + return spin; + } else { + return QItemDelegate::createEditor(parent, option, index); + } + } + -class KeyframeEdit : public QWidget + void setEditorData(QWidget *editor, const QModelIndex &index) const { + if (index.column() == 1) { + QSpinBox *spin = qobject_cast< QSpinBox* >(editor); + spin->setRange(m_min, m_max); + spin->setValue(index.model()->data(index).toInt()); + } else { + QItemDelegate::setEditorData(editor, index); + } + } + +private slots: + void commitAndCloseEditor() { + QSpinBox *spin = qobject_cast< QSpinBox* >(sender()); + emit closeEditor(spin); + } + + void commitEditorData() { + QSpinBox *spin = qobject_cast< QSpinBox* >(sender()); + emit commitData(spin); + } + +private: + int m_min; + int m_max; +}; + +class KeyframeEdit : public QWidget, public Ui::KeyframeEditor_UI { Q_OBJECT public: - explicit KeyframeEdit(QDomElement e, int max, Timecode tc, QWidget* parent = 0); - void setupParam(QDomElement e = QDomElement()); + explicit KeyframeEdit(QDomElement e, int minFrame, int maxFrame, Timecode tc, int activeKeyframe, QWidget* parent = 0); + virtual ~KeyframeEdit(); + void addParameter(QDomElement e, int activeKeyframe = -1); + const QString getValue(const QString &name); + /** @brief Updates the timecode display according to settings (frame number or hh:mm:ss:ff) */ + void updateTimecodeFormat(); + + /** @brief Returns true if the parameter @param name should be shown on the clip in timeline. */ + bool isVisibleParam(const QString &name); + + /** @brief Makes the first parameter visible in timeline if no parameter is selected. */ + void checkVisibleParam(); private: - Ui::KeyframeEditor_UI m_ui; - QDomElement m_param; + QList m_params; + int m_min; int m_max; Timecode m_timecode; - int m_previousPos; - -public slots: + QGridLayout *m_slidersLayout; + QButtonGroup *m_showButtons; + void generateAllParams(); + /** @brief Gets the position of a keyframe from the table. + * @param row Row of the keyframe in the table */ + int getPos(int row); + /** @brief Converts a frame value to timecode considering the frames vs. HH:MM:SS:FF setting. + * @return timecode */ + QString getPosString(int pos); private slots: void slotDeleteKeyframe(); void slotAddKeyframe(); - void slotGenerateParams(QTreeWidgetItem *item = NULL, int column = -1); - void slotAdjustKeyframeInfo(); + void slotGenerateParams(int row, int column); + void slotAdjustKeyframeInfo(bool seek = true); + void slotAdjustKeyframePos(int value); void slotAdjustKeyframeValue(int value); - void slotSaveCurrentParam(QTreeWidgetItem *item, int column); + /** @brief Turns the seek to keyframe position setting on/off. + * @param seek true = seeking on */ + void slotSetSeeking(bool seek); + + /** @brief Shows the keyframe table and adds a second keyframe. */ + void slotKeyframeMode(); + + /** @brief Resets all parameters of the selected keyframe to their default values. */ + void slotResetKeyframe(); + + /** @brief Makes the parameter at column @param id the visible (in timeline) one. */ + void slotUpdateVisibleParameter(int id, bool update = true); signals: void parameterChanged();