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;
|
2021-09-27 21:42:30 +02:00
|
|
|
|
|
|
|
#ifndef Q_OS_MACOS
|
|
|
|
bool hasFocus() const;
|
|
|
|
#endif
|
2018-09-04 22:55:38 +02:00
|
|
|
void setFocus(Qt::FocusReason);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-29 01:09:02 +02:00
|
|
|
public slots:
|
2021-09-13 20:49:33 +02:00
|
|
|
void setText(const QString &new_text);
|
2018-09-04 22:55:38 +02:00
|
|
|
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:
|
2023-04-09 20:23:42 +02:00
|
|
|
void textChanged(const QString &text);
|
2018-09-04 22:55:38 +02:00
|
|
|
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;
|
2021-07-11 09:49:38 +02:00
|
|
|
QPointer<QSearchFieldPrivate> pimpl;
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
2021-07-11 09:49:38 +02:00
|
|
|
#endif // QSEARCHFIELD_H
|