X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fdragvalue.h;h=2ca950ed668124506310b2b0b75c6f330b363eec;hb=c3302003093710ee247ad84c0fe2ef3c579d417f;hp=9fc3543cc065904357176f0873c8f86255c6f1fc;hpb=54f47cb8edb4bdf1d0b9e8d6c71ec93ec3e8c89e;p=kdenlive diff --git a/src/dragvalue.h b/src/dragvalue.h index 9fc3543c..2ca950ed 100644 --- a/src/dragvalue.h +++ b/src/dragvalue.h @@ -20,12 +20,50 @@ #define DRAGVALUE_H_ #include +#include +#include +#include +#include +#include -class QValidator; -class QToolButton; -class QLineEdit; class QAction; class QMenu; +class KSelectAction; + + +class CustomLabel : public QProgressBar +{ + Q_OBJECT +public: + explicit CustomLabel(const QString &label, bool showSlider = true, int range = 1000, QWidget *parent = 0); + void setProgressValue(double value); + void setStep(double step); + +protected: + //virtual void mouseDoubleClickEvent(QMouseEvent * event); + void mousePressEvent(QMouseEvent * event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + //virtual void paintEvent(QPaintEvent *event); + void wheelEvent(QWheelEvent * event); + void focusInEvent(QFocusEvent *e); + void focusOutEvent(QFocusEvent *e); + +private: + QPoint m_dragStartPosition; + QPoint m_dragLastPosition; + bool m_dragMode; + bool m_showSlider; + double m_step; + void slotValueInc(double factor = 1); + void slotValueDec(double factor = 1); + void setNewValue(double, bool); + +signals: + void valueChanged(double, bool); + void setInTimeline(); + void resetValue(); +}; /** * @brief A widget for modifing numbers by dragging, using the mouse wheel or entering them with the keyboard. @@ -36,7 +74,18 @@ class DragValue : public QWidget Q_OBJECT public: - DragValue(QWidget* parent = 0); + /** + * @brief Default constructor. + * @param label The label that will be displayed in the progress bar + * @param defaultValue The default value + * @param decimals The number of decimals for the parameter. 0 means it is an integer + * @param min The minimum value + * @param max The maximum value + * @param id Used to identify this widget. If this parameter is set, "Show in Timeline" will be available in context menu. + * @param suffix The suffix that will be displayed in the spinbox (for example '%') + * @param showSlider If disabled, user can still drag on the label but no progress bar is shown + */ + explicit DragValue(const QString &label, double defaultValue, int decimals, double min = 0, double max = 100, int id = -1, const QString &suffix = QString(), bool showSlider = true, QWidget* parent = 0); virtual ~DragValue(); /** @brief Returns the precision = number of decimals */ @@ -59,14 +108,23 @@ public: /** @brief Returns the current value */ qreal value() const; + /** @brief Change the "inTimeline" property to paint the intimeline widget differently. */ + void setInTimelineProperty(bool intimeline); + /** @brief Returns minimum size for QSpinBox, used to set all spinboxes to the same width. */ + int spinSize(); + /** @brief Sets the minimum size for QSpinBox, used to set all spinboxes to the same width. */ + void setSpinSize(int width); public slots: /** @brief Sets the value (forced to be in the valid range) and emits valueChanged. */ - void setValue(qreal value, bool final = true); + void setValue(double value, bool final = true); + void setValueFromProgress(double value, bool final); + /** @brief Resets to default value */ + void slotReset(); signals: - void valueChanged(qreal value, bool final); - + void valueChanged(double value, bool final = true); + void inTimeline(int); @@ -75,39 +133,40 @@ signals: */ protected: - virtual void mousePressEvent(QMouseEvent *e); + /*virtual void mousePressEvent(QMouseEvent *e); virtual void mouseMoveEvent(QMouseEvent *e); - virtual void mouseReleaseEvent(QMouseEvent *e); + virtual void mouseReleaseEvent(QMouseEvent *e);*/ /** @brief Forwards tab focus to lineedit since it is disabled. */ virtual void focusInEvent(QFocusEvent *e); + virtual void focusOutEvent(QFocusEvent *e); //virtual void keyPressEvent(QKeyEvent *e); - virtual void wheelEvent(QWheelEvent *e); + //virtual void wheelEvent(QWheelEvent *e); + //virtual void paintEvent( QPaintEvent * event ); private slots: - void slotValueInc(); - void slotValueDec(); + void slotEditingFinished(); - void slotSetNonlinearScale(bool nonlinear); + void slotSetScaleMode(int mode); void slotSetDirectUpdate(bool directUpdate); void slotShowContextMenu(const QPoint &pos); + void slotSetValue(int value); + void slotSetValue(double value); + void slotSetInTimeline(); private: - qreal m_maximum; - qreal m_minimum; - int m_precision; - qreal m_step; - QLineEdit *m_edit; - QPoint m_dragStartPosition; - QPoint m_dragLastPosition; - bool m_dragMode; + double m_maximum; + double m_minimum; + int m_decimals; + double m_default; + int m_id; + QSpinBox *m_intEdit; + QDoubleSpinBox *m_doubleEdit; QMenu *m_menu; - QAction *m_nonlinearScale; + KSelectAction *m_scale; QAction *m_directUpdate; - - /** @brief Sets the maximum width of the widget so that there is enough space for the widest possible value. */ - void updateMaxWidth(); + CustomLabel *m_label; }; #endif