2021-05-22 21:29:43 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: zhangjiaping <zhangjiaping@kylinos.cn>
|
|
|
|
*
|
|
|
|
*/
|
2021-07-21 17:01:34 +08:00
|
|
|
#ifndef SEARCHLINEEDIT_H
|
|
|
|
#define SEARCHLINEEDIT_H
|
2021-05-22 21:29:43 +08:00
|
|
|
#include <QWidget>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QtDBus/QtDBus>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QStringListModel>
|
|
|
|
#include <QCompleter>
|
|
|
|
#include <QAbstractItemView>
|
|
|
|
#include <QVector4D>
|
|
|
|
#include <QListView>
|
2021-07-21 17:01:34 +08:00
|
|
|
#include <QProxyStyle>
|
2021-05-22 21:29:43 +08:00
|
|
|
#include "global-settings.h"
|
|
|
|
|
|
|
|
namespace Zeeker {
|
|
|
|
|
2021-07-21 17:01:34 +08:00
|
|
|
class SearchLineEdit : public QLineEdit {
|
|
|
|
Q_OBJECT
|
2021-05-22 21:29:43 +08:00
|
|
|
public:
|
2021-07-21 17:01:34 +08:00
|
|
|
SearchLineEdit(QWidget *parent = nullptr);
|
|
|
|
// void record();
|
|
|
|
~SearchLineEdit();
|
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *);
|
|
|
|
Q_SIGNALS:
|
|
|
|
void requestSearchKeyword(QString text);
|
2021-05-22 21:29:43 +08:00
|
|
|
private:
|
2021-07-21 17:01:34 +08:00
|
|
|
QHBoxLayout *m_ly;
|
|
|
|
QLabel *m_queryIcon;
|
|
|
|
QTimer *m_timer;
|
|
|
|
bool m_isEmpty = true;
|
2021-05-22 21:29:43 +08:00
|
|
|
};
|
|
|
|
|
2021-07-21 17:01:34 +08:00
|
|
|
class SeachBarWidget: public QWidget {
|
2021-05-22 21:29:43 +08:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-07-21 17:01:34 +08:00
|
|
|
SeachBarWidget(QWidget *parent = nullptr);
|
|
|
|
~SeachBarWidget();
|
2021-05-22 21:29:43 +08:00
|
|
|
|
2021-07-21 17:01:34 +08:00
|
|
|
void clear();
|
2021-08-06 10:54:48 +08:00
|
|
|
void reSearch();
|
2021-05-22 21:29:43 +08:00
|
|
|
protected:
|
2021-07-21 17:01:34 +08:00
|
|
|
void paintEvent(QPaintEvent *e);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void requestSearchKeyword(QString text);
|
|
|
|
|
|
|
|
private:
|
2021-07-21 17:01:34 +08:00
|
|
|
SearchLineEdit *m_searchLineEdit;
|
|
|
|
QHBoxLayout *m_ly;
|
2021-05-22 21:29:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-07-21 17:01:34 +08:00
|
|
|
class LineEditStyle : public QProxyStyle
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LineEditStyle() {}
|
|
|
|
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override;
|
2021-05-22 21:29:43 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-21 17:01:34 +08:00
|
|
|
#endif //SEARCHLINEEDIT_H
|