]> git.sesse.net Git - kdenlive/blobdiff - src/dragvalue.h
Several small adjustments for monitor switching
[kdenlive] / src / dragvalue.h
index 0053405773064e69199e62d7962f90b6515a85b1..22e9916cf3b6a080691091ccd6b479ffb6ca11fe 100644 (file)
@@ -21,7 +21,8 @@
 
 #include <QWidget>
 #include <kselectaction.h>
-#include <KIntSpinBox>
+#include <QSpinBox>
+#include <QDoubleSpinBox>
 #include <QLabel>
 #include <QProgressBar>
 
@@ -37,7 +38,9 @@ class CustomLabel : public QProgressBar
 {
     Q_OBJECT
 public:
-    CustomLabel(const QString &label, bool showSlider = true, QWidget *parent = 0);
+    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);
@@ -51,15 +54,14 @@ private:
     QPoint m_dragStartPosition;
     QPoint m_dragLastPosition;
     bool m_dragMode;
-    double m_step;
     bool m_showSlider;
-    //QStyleOptionProgressBarV2 m_progressOptions;
-    void slotValueInc(int factor = 1);
-    void slotValueDec(int factor = 1);
-    void setNewValue(int, bool);
+    double m_step;
+    void slotValueInc(double factor = 1);
+    void slotValueDec(double factor = 1);
+    void setNewValue(double, bool);
     
 signals:
-    void valueChanged(int, bool);
+    void valueChanged(double, bool);
     void setInTimeline();
     void resetValue();
 };
@@ -73,7 +75,18 @@ class DragValue : public QWidget
     Q_OBJECT
 
 public:
-    DragValue(const QString &label, int defaultValue, int id, const QString suffix, bool showSlider = true, 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
+    */    
+    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 */
@@ -105,12 +118,13 @@ public:
     
 public slots:
     /** @brief Sets the value (forced to be in the valid range) and emits valueChanged. */
-    void setValue(int 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(int value, bool final = true);
+    void valueChanged(double value, bool final = true);
     void inTimeline(int);
 
 
@@ -137,20 +151,22 @@ private slots:
     void slotSetDirectUpdate(bool directUpdate);
     void slotShowContextMenu(const QPoint &pos);
     void slotSetValue(int value);
+    void slotSetValue(double value);
     void slotSetInTimeline();
 
 private:
-    int m_maximum;
-    int m_minimum;
-    int m_precision;
-    KIntSpinBox *m_edit;
-    int m_default;
+    double m_maximum;
+    double m_minimum;
+    int m_decimals;
+    double m_default;
+    int m_id;
+    QSpinBox *m_intEdit;
+    QDoubleSpinBox *m_doubleEdit;
 
     QMenu *m_menu;
     KSelectAction *m_scale;
     QAction *m_directUpdate;
     CustomLabel *m_label;
-    int m_id;
 };
 
 #endif