-
Notifications
You must be signed in to change notification settings - Fork 1
/
mibitlineedit.h
89 lines (77 loc) · 3.13 KB
/
mibitlineedit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/***************************************************************************
* Copyright (C) 2009 by Miguel Chavez Gamboa *
* *
* This is based on the KLineEdit class *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef MIBITLINEEDIT_H
#define MIBITLINEEDIT_H
#include <QLineEdit>
class QTimer;
class MibitLineEdit : public QLineEdit
{
Q_OBJECT
public:
explicit MibitLineEdit( const QString &string, QWidget *parent = 0 );
explicit MibitLineEdit( QWidget *parent = 0 );
virtual ~MibitLineEdit();
/**
* This makes the line edit display a grayed-out hinting text as long as
* the user didn't enter any text. It is often used as indication about
* the purpose of the line edit.
*/
void setEmptyMessage( const QString &msg );
/**
* @return the message set with setEmptyMessage
*/
QString getEmptyMessage() const;
/**
* sets background color to indicate an error on input.
*/
void setError( const QString& msg );
/**
* sets automatic clear of errors
*/
void setAutoClearError( const bool& state );
protected:
virtual void paintEvent( QPaintEvent *ev );
virtual void focusInEvent( QFocusEvent *ev );
virtual void focusOutEvent( QFocusEvent *ev );
virtual void keyPressEvent( QKeyEvent * event );
private:
QString emptyMessage;
bool drawEmptyMsg;
bool drawError;
bool autoClear;
int actualColor;
QTimer *timer;
QTimer *shakeTimer;
int shakeTimeToLive;
bool par;
unsigned int parTimes;
private slots:
void onTextChange(const QString &text);
void clearError();
void stepColors();
void shakeIt();
public slots:
void shake();
signals:
void plusKeyPressed();
};
#endif // MibitLineEdit_H