]> git.sur5r.net Git - minitube/blob - src/exlineedit.h
Upload 2.5.2-2 to unstable
[minitube] / src / exlineedit.h
1 #ifndef EXLINEEDIT_H
2 #define EXLINEEDIT_H
3
4 #include <QtGui>
5 #if QT_VERSION >= 0x050000
6 #include <QtWidgets>
7 #endif
8
9 class ClearButton : public QAbstractButton {
10
11     Q_OBJECT
12
13 public:
14     ClearButton(QWidget *parent = 0);
15
16 public slots:
17     void textChanged(const QString &text);
18
19 protected:
20     void paintEvent(QPaintEvent *e);
21     void enterEvent(QEvent *e);
22     void leaveEvent(QEvent *e);
23     void mousePressEvent(QMouseEvent *e);
24     void mouseReleaseEvent(QMouseEvent *e);
25
26 private:
27     bool hovered;
28     bool mousePressed;
29 };
30
31 class ExLineEdit : public QWidget {
32
33     Q_OBJECT
34
35 public:
36     ExLineEdit(QWidget *parent = 0);
37     QLineEdit *lineEdit() const { return m_lineEdit; }
38     void setLeftWidget(QWidget *widget);
39     QWidget *leftWidget() const;
40     void clear();
41     QString text();
42     QSize sizeHint() const;
43     void updateGeometries();
44     void setFont(const QFont &font);
45
46 protected:
47     void focusInEvent(QFocusEvent *e);
48     void focusOutEvent(QFocusEvent *e);
49     void keyPressEvent(QKeyEvent *e);
50     void paintEvent(QPaintEvent *e);
51     void resizeEvent(QResizeEvent *e);
52     bool event(QEvent *e);
53     void initStyleOption(QStyleOptionFrameV2 *option) const;
54
55     QWidget *m_leftWidget;
56     QLineEdit *m_lineEdit;
57     ClearButton *m_clearButton;
58 };
59
60 #endif // EXLINEEDIT_H
61