2 * \file fancylineedit.h
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Nokia Corporation (qt-info@nokia.com)
8 * Full author contact details are available in file CREDITS.
12 // Code taken from the Qt Creator project and customized a little
14 #ifndef FANCYLINEEDIT_H
15 #define FANCYLINEEDIT_H
18 #include <QAbstractButton>
23 class FancyLineEditPrivate;
25 #if QT_VERSION >= 0x040600
26 class IconButton: public QAbstractButton
29 Q_PROPERTY(float iconOpacity READ iconOpacity WRITE setIconOpacity)
30 Q_PROPERTY(bool autoHide READ hasAutoHide WRITE setAutoHide)
31 Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
33 explicit IconButton(QWidget *parent = 0);
34 void paintEvent(QPaintEvent *event);
35 void setPixmap(const QPixmap &pixmap) { m_pixmap = pixmap; update(); }
36 QPixmap pixmap() const { return m_pixmap; }
37 float iconOpacity() { return m_iconOpacity; }
38 void setIconOpacity(float value) { m_iconOpacity = value; update(); }
39 void animateShow(bool visible);
41 void setAutoHide(bool hide) { m_autoHide = hide; }
42 bool hasAutoHide() const { return m_autoHide; }
50 /* A line edit with an embedded pixmap on one side that is connected to
51 * a menu. Additionally, it can display a grayed hintText (like "Type Here to")
52 * when not focused and empty. When connecting to the changed signals and
53 * querying text, one has to be aware that the text is set to that hint
54 * text if isShowingHintText() returns true (that is, does not contain
57 class FancyLineEdit : public QLineEdit
59 Q_DISABLE_COPY(FancyLineEdit)
64 enum Side {Left = 0, Right = 1};
67 void buttonClicked(Side side);
68 void leftButtonClicked();
69 void rightButtonClicked();
71 #if QT_VERSION >= 0x040600
73 explicit FancyLineEdit(QWidget *parent = 0);
76 QPixmap buttonPixmap(Side side) const;
77 void setButtonPixmap(Side side, const QPixmap &pixmap);
79 QMenu *buttonMenu(Side side) const;
80 void setButtonMenu(Side side, QMenu *menu);
82 void setButtonVisible(Side side, bool visible);
83 bool isButtonVisible(Side side) const;
85 void setButtonToolTip(Side side, const QString &);
86 void setButtonFocusPolicy(Side side, Qt::FocusPolicy policy);
88 // Set whether tabbing in will trigger the menu.
89 void setMenuTabFocusTrigger(Side side, bool v);
90 bool hasMenuTabFocusTrigger(Side side) const;
92 // Set if icon should be hidden when text is empty
93 void setAutoHideButton(Side side, bool h);
94 bool hasAutoHideButton(Side side) const;
97 void checkButtons(const QString &);
101 virtual void resizeEvent(QResizeEvent *e);
104 void updateMargins();
105 void updateButtonPositions();
107 FancyLineEditPrivate *m_d;
111 explicit FancyLineEdit(QWidget *parent = 0)
114 #endif // QT_VERSION >= 0x040600*/
120 #endif // FANCYLINEEDIT_H