1 /******************************************************************************* 2 ** 3 ** Photivo 4 ** 5 ** Copyright (C) 2008 Jos De Laender <jos.de_laender@telenet.be> 6 ** Copyright (C) 2010 Michael Munzert <mail@mm-log.com> 7 ** Copyright (C) 2012 Bernd Schoeler <brjohn@brother-john.net> 8 ** 9 ** This file is part of Photivo. 10 ** 11 ** Photivo is free software: you can redistribute it and/or modify 12 ** it under the terms of the GNU General Public License version 3 13 ** as published by the Free Software Foundation. 14 ** 15 ** Photivo is distributed in the hope that it will be useful, 16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 ** GNU General Public License for more details. 19 ** 20 ** You should have received a copy of the GNU General Public License 21 ** along with Photivo. If not, see <http://www.gnu.org/licenses/>. 22 ** 23 *******************************************************************************/ 24 /*! 25 \class ptInput 26 \brief \c ptInput is a object showing a input element with associated widgets 27 */ 28 29 #ifndef PTINPUT_H 30 #define PTINPUT_H 31 32 //============================================================================== 33 34 #include "ptSlider.h" 35 #include "ptWidget.h" 36 37 #include <QLabel> 38 39 class ptCfgItem; 40 41 //============================================================================== 42 43 class ptInput: public ptWidget { 44 Q_OBJECT 45 46 public: 47 ptInput(const QWidget* MainWindow, 48 const QString ObjectName, 49 const QString ParentName, 50 const short HasSlider, 51 const short ColorSetting, 52 const short HasDefaultValue, 53 const QVariant Default, 54 const QVariant Minimum, 55 const QVariant Maximum, 56 const QVariant Step, 57 const int Decimals, 58 const QString LabelText, 59 const QString ToolTip, 60 const int TimeOut); 61 ptInput(const ptCfgItem &ACfgItem, QWidget *AParent); 62 ptInput(QWidget *AParent); 63 ~ptInput(); 64 65 /*! Reimplemented from base class. 66 For compatibility with the new GUI structure. Just calls SetValue(). 67 */ 68 void setValue(const QVariant &AValue); 69 70 void init(const ptCfgItem &ACfgItem); 71 72 // BlockSignal avoids a signal emitted on programmatic update. 73 void SetValue(const QVariant Value, const short BlockSignal = 1); 74 void SetMaximum(const QVariant Value); 75 void SetMinimum(const QVariant Value); 76 void SetEnabled(const short Enabled); 77 void Show(const short Show); 78 void Reset(); GetName()79 QString GetName() {return m_SettingsName;} 80 81 //------------------------------------- 82 83 protected: 84 bool eventFilter(QObject *obj, QEvent *event); 85 86 //------------------------------------- 87 88 private: 89 void CheckTypes(const QVariant &Default, const QVariant &Minimum, const QVariant &Maximum, 90 const QVariant &Step); 91 void createGUI(const QVariant &Minimum, const QVariant &Maximum, const QVariant &Step, 92 const int Decimals, const QString &ToolTip, const QString &LabelText, 93 const short ColorSetting, const int TimeOut); 94 95 QVariant m_Value; 96 QVariant m_DefaultValue; 97 int m_TimeOut; 98 short m_HaveDefault; 99 short m_HaveSlider; 100 int m_KeyTimeOut; 101 int m_Emited; 102 103 QWidget* m_Parent; 104 QVariant::Type m_Type; // All values (and determines spinbox f.i.) 105 QAbstractSpinBox* m_SpinBox; // Common base for int and double. 106 ptSlider* m_Slider; 107 //QToolButton* m_Button; 108 QLabel* m_Label; 109 QTimer* m_Timer; 110 QString m_SettingsName; 111 112 //------------------------------------- 113 114 signals: 115 void valueChanged(QVariant Value); 116 117 //------------------------------------- 118 119 private slots: 120 void OnSpinBoxChanged(int Value); 121 void OnSpinBoxChanged(double Value); 122 //void OnSliderChanged(int Value); 123 void OnSliderChanged(QVariant Value); 124 void OnButtonClicked(); 125 void OnValueChanged(int Value); 126 void OnValueChanged(double Value); 127 void OnValueChangedTimerExpired(); 128 void EditingFinished(); 129 130 }; 131 132 #endif // PTINPUT_H 133