]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/FancyLineEdit.h
Improve wording (#10670)
[lyx.git] / src / frontends / qt4 / FancyLineEdit.h
index dbf216fdf2a2f37a67624dd93c539db3a2fcee04..ef6b45aa5fc7f6efe0a6bde78b66b458a0522f77 100644 (file)
-/**\r
- * \file fancylineedit.h\r
- * This file is part of LyX, the document processor.\r
- * Licence details can be found in the file COPYING.\r
- *\r
- * \author Nokia Corporation (qt-info@nokia.com)\r
- *\r
- * Full author contact details are available in file CREDITS.\r
- *\r
- */\r
-\r
-// Code taken from the Qt Creator project and customized a little\r
-\r
-#ifndef FANCYLINEEDIT_H\r
-#define FANCYLINEEDIT_H\r
-\r
-#include <QtGui/QLineEdit>\r
-#include <QtGui/QAbstractButton>\r
-\r
-namespace lyx {\r
-namespace frontend {\r
-\r
-class FancyLineEditPrivate;\r
-\r
-class IconButton: public QAbstractButton\r
-{\r
-       Q_OBJECT\r
-       Q_PROPERTY(float iconOpacity READ iconOpacity WRITE setIconOpacity)\r
-       Q_PROPERTY(bool autoHide READ hasAutoHide WRITE setAutoHide)\r
-       Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)\r
-public:\r
-    explicit IconButton(QWidget *parent = 0);\r
-    void paintEvent(QPaintEvent *event);\r
-    void setPixmap(const QPixmap &pixmap) { m_pixmap = pixmap; update(); }\r
-    QPixmap pixmap() const { return m_pixmap; }\r
-    float iconOpacity() { return m_iconOpacity; }\r
-    void setIconOpacity(float value) { m_iconOpacity = value; update(); }\r
-    void animateShow(bool visible);\r
-\r
-    void setAutoHide(bool hide) { m_autoHide = hide; }\r
-    bool hasAutoHide() const { return m_autoHide; }\r
-private:\r
-    float m_iconOpacity;\r
-    bool m_autoHide;\r
-    QPixmap m_pixmap;\r
-};\r
-\r
-\r
-/* A line edit with an embedded pixmap on one side that is connected to\r
- * a menu. Additionally, it can display a grayed hintText (like "Type Here to")\r
- * when not focused and empty. When connecting to the changed signals and\r
- * querying text, one has to be aware that the text is set to that hint\r
- * text if isShowingHintText() returns true (that is, does not contain\r
- * valid user input).\r
- */\r
-class FancyLineEdit : public QLineEdit\r
-{\r
-       Q_DISABLE_COPY(FancyLineEdit)\r
-       Q_OBJECT\r
-       Q_ENUMS(Side)\r
-\r
-public:\r
-    enum Side {Left = 0, Right = 1};\r
-\r
-    explicit FancyLineEdit(QWidget *parent = 0);\r
-    ~FancyLineEdit();\r
-\r
-    QPixmap buttonPixmap(Side side) const;\r
-    void setButtonPixmap(Side side, const QPixmap &pixmap);\r
-\r
-    QMenu *buttonMenu(Side side) const;\r
-    void setButtonMenu(Side side, QMenu *menu);\r
-\r
-    void setButtonVisible(Side side, bool visible);\r
-    bool isButtonVisible(Side side) const;\r
-\r
-    void setButtonToolTip(Side side, const QString &);\r
-    void setButtonFocusPolicy(Side side, Qt::FocusPolicy policy);\r
-\r
-    // Set whether tabbing in will trigger the menu.\r
-    void setMenuTabFocusTrigger(Side side, bool v);\r
-    bool hasMenuTabFocusTrigger(Side side) const;\r
-\r
-    // Set if icon should be hidden when text is empty\r
-    void setAutoHideButton(Side side, bool h);\r
-    bool hasAutoHideButton(Side side) const;\r
-\r
-Q_SIGNALS:\r
-       void buttonClicked(Side side);\r
-    void leftButtonClicked();\r
-    void rightButtonClicked();\r
-\r
-private Q_SLOTS:\r
-    void checkButtons(const QString &);\r
-    void iconClicked();\r
-\r
-protected:\r
-    virtual void resizeEvent(QResizeEvent *e);\r
-\r
-private:\r
-    void updateMargins();\r
-       void updateButtonPositions();\r
-\r
-    FancyLineEditPrivate *m_d;\r
-    QString m_oldText;\r
-};\r
-\r
-}\r
-}\r
-\r
-#endif // FANCYLINEEDIT_H\r
+/**
+ * \file fancylineedit.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Nokia Corporation (qt-info@nokia.com)
+ *
+ * Full author contact details are available in file CREDITS.
+ *
+ */
+
+// Code taken from the Qt Creator project and customized a little
+
+#ifndef FANCYLINEEDIT_H
+#define FANCYLINEEDIT_H
+
+#include <QLineEdit>
+#include <QAbstractButton>
+
+namespace lyx {
+namespace frontend {
+
+class FancyLineEditPrivate;
+
+class IconButton: public QAbstractButton
+{
+       Q_OBJECT
+       Q_PROPERTY(float iconOpacity READ iconOpacity WRITE setIconOpacity)
+       Q_PROPERTY(bool autoHide READ hasAutoHide WRITE setAutoHide)
+       Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
+public:
+       explicit IconButton(QWidget *parent = 0);
+       void paintEvent(QPaintEvent *event);
+       void setPixmap(const QPixmap &pixmap) { m_pixmap = pixmap; update(); }
+       QPixmap pixmap() const { return m_pixmap; }
+       float iconOpacity() { return m_iconOpacity; }
+       void setIconOpacity(float value) { m_iconOpacity = value; update(); }
+       void animateShow(bool visible);
+
+       void setAutoHide(bool hide) { m_autoHide = hide; }
+       bool hasAutoHide() const { return m_autoHide; }
+private:
+       float m_iconOpacity;
+       bool m_autoHide;
+       QPixmap m_pixmap;
+};
+
+/* A line edit with an embedded pixmap on one side that is connected to
+ * a menu. Additionally, it can display a grayed hintText (like "Type Here to")
+ * when not focused and empty. When connecting to the changed signals and
+ * querying text, one has to be aware that the text is set to that hint
+ * text if isShowingHintText() returns true (that is, does not contain
+ * valid user input).
+ */
+class FancyLineEdit : public QLineEdit
+{
+       Q_DISABLE_COPY(FancyLineEdit)
+       Q_OBJECT
+       Q_ENUMS(Side)
+
+public:
+       enum Side {Left = 0, Right = 1};
+
+Q_SIGNALS:
+       void buttonClicked(Side side);
+       void leftButtonClicked();
+       void rightButtonClicked();
+       void downPressed();
+
+public:
+       explicit FancyLineEdit(QWidget *parent = 0);
+       ~FancyLineEdit();
+
+       QPixmap buttonPixmap(Side side) const;
+       void setButtonPixmap(Side side, const QPixmap &pixmap);
+
+       QMenu *buttonMenu(Side side) const;
+       void setButtonMenu(Side side, QMenu *menu);
+
+       void setButtonVisible(Side side, bool visible);
+       bool isButtonVisible(Side side) const;
+
+       void setButtonToolTip(Side side, const QString &);
+       void setButtonFocusPolicy(Side side, Qt::FocusPolicy policy);
+
+       // Set whether tabbing in will trigger the menu.
+       void setMenuTabFocusTrigger(Side side, bool v);
+       bool hasMenuTabFocusTrigger(Side side) const;
+
+       // Set if icon should be hidden when text is empty
+       void setAutoHideButton(Side side, bool h);
+       bool hasAutoHideButton(Side side) const;
+
+private Q_SLOTS:
+       void checkButtons(const QString &);
+       void iconClicked();
+
+protected:
+       virtual void resizeEvent(QResizeEvent *e);
+       virtual void keyPressEvent(QKeyEvent *e);
+
+private:
+       void updateMargins();
+       void updateButtonPositions();
+
+       FancyLineEditPrivate *m_d;
+       QString m_oldText;
+};
+
+}
+}
+
+#endif // FANCYLINEEDIT_H