File indexing completed on 2024-11-10 04:26:05
0001 /* 0002 SPDX-FileCopyrightText: 2010 Till Theato <root@ttill.de> 0003 0004 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QWidget> 0010 0011 class DragValue; 0012 0013 /** @class DoubleWidget 0014 @brief Widget to choose a double parameter (for a effect) with the help of a slider and a spinbox. 0015 The widget does only handle integers, so the parameter has to be converted into the proper double range afterwards. 0016 @author Till Theato 0017 */ 0018 class DoubleWidget : public QWidget 0019 { 0020 Q_OBJECT 0021 public: 0022 /** @brief Sets up the parameter's GUI. 0023 * @param name Name of the parameter 0024 * @param value Value of the parameter 0025 * @param min Minimum value 0026 * @param max maximum value 0027 * @param factor value, if we want a range 0-1000 for a 0-1 parameter, we can set a factor of 1000 0028 * @param defaultValue Value used when using reset functionality 0029 * @param comment A comment explaining the parameter. Will be shown in a tooltip. 0030 * @param suffix (optional) Suffix to display in spinbox 0031 * @param parent (optional) Parent Widget */ 0032 explicit DoubleWidget(const QString &name, double value, double min, double max, double factor, double defaultValue, const QString &comment, int id, 0033 const QString &suffix = QString(), int decimals = 0, bool oddOnly = false, QWidget *parent = nullptr); 0034 ~DoubleWidget() override; 0035 0036 /** @brief Gets the parameter's value. */ 0037 double getValue(); 0038 /** @brief Returns minimum size for QSpinBox, used to set all spinboxes to the same width. */ 0039 int spinSize(); 0040 void setSpinSize(int width); 0041 void enableEdit(bool enable); 0042 /** @brief Returns true if widget is currently being edited */ 0043 bool hasEditFocus() const; 0044 /** @brief Define dragValue object name */ 0045 void setDragObjectName(const QString &name); 0046 0047 public Q_SLOTS: 0048 /** @brief Sets the value to @param value. */ 0049 void setValue(double value); 0050 0051 /** @brief Sets value to m_default. */ 0052 void slotReset(); 0053 0054 /** @brief Shows/Hides the comment label. */ 0055 void slotShowComment(bool show); 0056 0057 private Q_SLOTS: 0058 0059 void slotSetValue(double value, bool final); 0060 0061 private: 0062 DragValue *m_dragVal; 0063 double m_factor; 0064 0065 Q_SIGNALS: 0066 void valueChanged(double); 0067 0068 // same signal as valueChanged, but add an extra boolean to tell if user is dragging value or not 0069 void valueChanging(double, bool); 0070 };