1 /***************************************************************************
2 *                                                                         *
3 *   This program is free software; you can redistribute it and/or modify  *
4 *   it under the terms of the GNU General Public License as published by  *
5 *   the Free Software Foundation; either version 3 of the License, or     *
6 *   (at your option) any later version.                                   *
7 *                                                                         *
8 ***************************************************************************/
9 
10 #pragma once
11 
12 #include <QLineEdit>
13 #include <QLabel>
14 #include <QResizeEvent>
15 #include <QEvent>
16 #include <QPixmap>
17 #include <QMenu>
18 #include <QFocusEvent>
19 
20 class LineEdit : public QLineEdit
21 {
22 Q_OBJECT
23 public:
24     enum MenuRole{
25         InsertText=0,
26         EmitSignal
27     };
28 
29     explicit LineEdit(QWidget *parent = 0);
30     virtual ~LineEdit();
31 
32     virtual void setPixmap(const QPixmap&);
33     virtual void setMenu(QMenu*);
34     virtual void setMenuRole(LineEdit::MenuRole);
35 
36     virtual QSize sizeHint() const;
37     virtual QSizePolicy sizePolicy() const;
38 
39 protected:
40     virtual void resizeEvent(QResizeEvent *);
41     virtual void focusInEvent(QFocusEvent *);
42     virtual void focusOutEvent(QFocusEvent *);
43     virtual bool eventFilter(QObject *, QEvent *);
44 
45 signals:
46     void clearEdit();
47     void menuAction(QAction*);
48 
49 private slots:
50     void slotTextChanged();
51 
52 private:
53     void updateStyles();
54     void updateGeometry();
55 
56     QLabel *label;
57     QPixmap pxm;
58 
59     QMenu *menu;
60     MenuRole role;
61 
62     int parentHeight;
63 };
64