2 ******************************************************************************
4 * @file fancylineedit.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
8 * @see The GNU Public License (GPL) Version 3
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef FANCYLINEEDIT_H
30 #define FANCYLINEEDIT_H
32 #include "utils_global.h"
37 class FancyLineEditPrivate
;
39 /* A line edit with an embedded pixmap on one side that is connected to
40 * a menu. Additionally, it can display a grayed hintText (like "Type Here to")
41 * when not focussed and empty. When connecting to the changed signals and
42 * querying text, one has to be aware that the text is set to that hint
43 * text if isShowingHintText() returns true (that is, does not contain
46 class QTCREATOR_UTILS_EXPORT FancyLineEdit
: public QLineEdit
{
47 Q_DISABLE_COPY(FancyLineEdit
)
48 Q_OBJECT
Q_ENUMS(Side
)
49 Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap DESIGNABLE
true)
50 Q_PROPERTY(Side side READ side WRITE setSide DESIGNABLE isSideStored STORED isSideStored
)
51 Q_PROPERTY(bool useLayoutDirection READ useLayoutDirection WRITE setUseLayoutDirection DESIGNABLE
true)
52 Q_PROPERTY(bool menuTabFocusTrigger READ hasMenuTabFocusTrigger WRITE setMenuTabFocusTrigger DESIGNABLE
true)
53 Q_PROPERTY(QString hintText READ hintText WRITE setHintText DESIGNABLE
true)
56 enum Side
{ Left
, Right
};
58 explicit FancyLineEdit(QWidget
*parent
= 0);
61 QPixmap
pixmap() const;
63 void setMenu(QMenu
*menu
);
66 void setSide(Side side
);
69 bool useLayoutDirection() const;
70 void setUseLayoutDirection(bool v
);
72 // Set whether tabbing in will trigger the menu.
73 bool hasMenuTabFocusTrigger() const;
74 void setMenuTabFocusTrigger(bool v
);
76 // Hint text that is displayed when no focus is set.
77 QString
hintText() const;
79 bool isShowingHintText() const;
81 // Convenience for accessing the text that returns "" in case of isShowingHintText().
82 QString
typedText() const;
85 void setPixmap(const QPixmap
&pixmap
);
86 void setHintText(const QString
&ht
);
91 virtual void resizeEvent(QResizeEvent
*e
);
92 virtual void focusInEvent(QFocusEvent
*e
);
93 virtual void focusOutEvent(QFocusEvent
*e
);
96 bool isSideStored() const;
97 void updateMenuLabel();
98 void positionMenuLabel();
99 void updateStyleSheet(Side side
);
101 FancyLineEditPrivate
*m_d
;
105 #endif // FANCYLINEEDIT_H