File indexing completed on 2024-05-19 04:36:36
0001 /* This file is part of the TikZKit project. 0002 * 0003 * Copyright (C) 2014 Dominik Haumann <dhaumann@kde.org> 0004 * 0005 * This library is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU Library General Public License as published 0007 * by the Free Software Foundation, either version 2 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, see 0017 * <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #ifndef TIKZ_UI_VALUE_SPINBOX_H 0021 #define TIKZ_UI_VALUE_SPINBOX_H 0022 0023 #include <QDoubleSpinBox> 0024 #include <tikz/core/Value.h> 0025 0026 namespace tikz { 0027 namespace ui { 0028 0029 class ValueSpinBoxPrivate; 0030 0031 class ValueSpinBox : public QDoubleSpinBox 0032 { 0033 Q_OBJECT 0034 public: 0035 ValueSpinBox(QWidget * parent = nullptr); 0036 ~ValueSpinBox(); 0037 0038 /** 0039 * Set the unit of this spin box to @p unit. 0040 */ 0041 void setUnit(tikz::Unit unit); 0042 0043 /** 0044 * Returns the current value as tikz::Value. 0045 */ 0046 tikz::Value valueWithUnit() const; 0047 0048 /** 0049 * Set the value to @p value. 0050 */ 0051 void setValueWithUnit(const tikz::Value & value); 0052 0053 QString textFromValue(double value) const override; 0054 double valueFromText(const QString &text) const override; 0055 void fixup(QString & input) const override; 0056 QValidator::State validate(QString & text, int & pos) const override; 0057 0058 Q_SIGNALS: 0059 /** 0060 * This signal is emitted whenever the value of the spin box changed. 0061 */ 0062 void valueChanged(const tikz::Value & value); 0063 0064 protected Q_SLOTS: 0065 /** 0066 * This slot forwards @p value through the signal valueChanged(const tikz::Value &). 0067 */ 0068 void slotValueChanged(double value); 0069 0070 private: 0071 ValueSpinBoxPrivate * const d; 0072 }; 0073 0074 } 0075 } 0076 0077 #endif // TIKZ_UI_VALUE_SPINBOX_H 0078 0079 // kate: indent-width 4; replace-tabs on;