2018-02-27 18:06:05 +01:00
|
|
|
#ifndef QSEARCHFIELD_H
|
|
|
|
#define QSEARCHFIELD_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QPointer>
|
2018-07-01 22:26:46 +02:00
|
|
|
#include <QMenu>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
class QSearchFieldPrivate;
|
2018-09-04 22:55:38 +02:00
|
|
|
class QSearchField : public QWidget {
|
|
|
|
Q_OBJECT
|
2018-07-01 22:26:46 +02:00
|
|
|
|
2019-09-15 20:27:32 +02:00
|
|
|
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true)
|
|
|
|
Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
|
2018-07-01 22:26:46 +02:00
|
|
|
|
2020-06-29 01:09:02 +02:00
|
|
|
public:
|
2018-09-04 22:55:38 +02:00
|
|
|
explicit QSearchField(QWidget *parent);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-29 01:09:02 +02:00
|
|
|
void setIconSize(const int iconsize);
|
|
|
|
|
2018-09-04 22:55:38 +02:00
|
|
|
QString text() const;
|
|
|
|
QString placeholderText() const;
|
|
|
|
void setFocus(Qt::FocusReason);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-29 01:09:02 +02:00
|
|
|
public slots:
|
2018-09-04 22:55:38 +02:00
|
|
|
void setText(const QString &text);
|
|
|
|
void setPlaceholderText(const QString &text);
|
|
|
|
void clear();
|
|
|
|
void selectAll();
|
|
|
|
void setFocus();
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-29 01:09:02 +02:00
|
|
|
signals:
|
2018-09-04 22:55:38 +02:00
|
|
|
void textChanged(const QString &text);
|
|
|
|
void editingFinished();
|
|
|
|
void returnPressed();
|
2018-07-01 22:26:46 +02:00
|
|
|
|
2020-06-29 01:09:02 +02:00
|
|
|
protected:
|
2020-06-15 21:55:05 +02:00
|
|
|
void resizeEvent(QResizeEvent*) override;
|
|
|
|
bool eventFilter(QObject*, QEvent*) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-29 01:09:02 +02:00
|
|
|
private:
|
2018-09-04 22:55:38 +02:00
|
|
|
friend class QSearchFieldPrivate;
|
|
|
|
QPointer <QSearchFieldPrivate> pimpl;
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QSEARCHFIELD_H
|