1 #pragma once 2 3 #ifndef LINEEDIT_H 4 #define LINEEDIT_H 5 6 #include "tcommon.h" 7 8 #include <QLineEdit> 9 10 #undef DVAPI 11 #undef DVVAR 12 #ifdef TOONZQT_EXPORTS 13 #define DVAPI DV_EXPORT_API 14 #define DVVAR DV_EXPORT_VAR 15 #else 16 #define DVAPI DV_IMPORT_API 17 #define DVVAR DV_IMPORT_VAR 18 #endif 19 20 //============================================================================= 21 22 namespace DVGui { 23 24 //============================================================================= 25 /*! \brief It is a \b QLineEdit which lost focus when enter is pressed and emit 26 focusIn signal when line edit take 27 focus. 28 29 Inherits \b QLineEdit. 30 */ 31 class DVAPI LineEdit : public QLineEdit { 32 Q_OBJECT 33 34 bool m_isReturnPressed; 35 bool m_forbiddenSpecialChars; 36 bool m_mouseDragEditing = false; 37 38 public: 39 LineEdit(QWidget *parent = 0, bool forbiddenSpecialChars = false); 40 LineEdit(const QString &contents, QWidget *parent = 0, 41 bool forbiddenSpecialChars = false); 42 isReturnPressed()43 bool isReturnPressed() const { return m_isReturnPressed; } 44 ~LineEdit()45 ~LineEdit() {} 46 47 // In the function editor, ctrl + dragging on the lineedit 48 // can adjust the value. getMouseDragEditing()49 bool getMouseDragEditing() { return m_mouseDragEditing; } setMouseDragEditing(bool status)50 void setMouseDragEditing(bool status) { m_mouseDragEditing = status; } 51 52 protected: 53 void focusInEvent(QFocusEvent *event) override; 54 void keyPressEvent(QKeyEvent *event) override; 55 void mouseMoveEvent(QMouseEvent *) override; 56 57 signals: 58 void focusIn(); 59 void returnPressedNow(); 60 // this signal is only used for mouse drag value editing in the function 61 // panel. 62 void mouseMoved(QMouseEvent *); 63 }; 64 65 //----------------------------------------------------------------------------- 66 } // namespace DVGui 67 //----------------------------------------------------------------------------- 68 69 #endif // LINEEDIT_H 70