Merge pull request #18 from mammonsama666/zjp-qtimer
feat(Searchbar): Add qtimer.
This commit is contained in:
commit
1111971861
|
@ -1,4 +1,5 @@
|
|||
#include "input-box.h"
|
||||
|
||||
/**
|
||||
* @brief ukui-search顶部搜索界面
|
||||
*/
|
||||
|
@ -62,12 +63,35 @@ UkuiSearchBarHLayout::UkuiSearchBarHLayout()
|
|||
this->setAlignment(m_queryLineEdit,Qt::AlignCenter);
|
||||
this->addWidget(m_queryLineEdit);
|
||||
|
||||
connect(m_queryLineEdit, SIGNAL(textChanged(QString)), SIGNAL(textChanged(QString)));
|
||||
// connect(m_queryLineEdit, SIGNAL(textChanged(QString)), SIGNAL(textChanged(QString)));
|
||||
m_timer = new QTimer;
|
||||
QObject::connect(m_timer, &QTimer::timeout, this, [ = ](){
|
||||
m_timer->stop();
|
||||
Q_EMIT this->textChanged(m_queryLineEdit->text());
|
||||
});
|
||||
connect(m_queryLineEdit, &UKuiSearchLineEdit::textChanged, this, [ = ](QString text) {
|
||||
if (m_isEmpty) {
|
||||
m_isEmpty = false;
|
||||
Q_EMIT this->textChanged(text);
|
||||
} else {
|
||||
if (text == "") {
|
||||
m_isEmpty = true;
|
||||
Q_EMIT this->textChanged(m_queryLineEdit->text());
|
||||
m_timer->stop();
|
||||
return;
|
||||
}
|
||||
m_timer->stop();
|
||||
m_timer->start(0.2 * 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
UkuiSearchBarHLayout::~UkuiSearchBarHLayout()
|
||||
{
|
||||
|
||||
if (m_timer) {
|
||||
delete m_timer;
|
||||
m_timer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <QtDBus/QtDBus>
|
||||
#include <QPainter>
|
||||
#include <QAction>
|
||||
#include <QTimer>
|
||||
|
||||
class UKuiSearchLineEdit;
|
||||
|
||||
|
@ -36,6 +37,8 @@ public:
|
|||
void clearText();
|
||||
private:
|
||||
void initUI();
|
||||
bool m_isEmpty = true;
|
||||
QTimer * m_timer = nullptr;
|
||||
|
||||
UKuiSearchLineEdit *m_queryLineEdit=nullptr;
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include <QStyleOption>
|
||||
#include <KWindowEffects>
|
||||
#include <QPixmap>
|
||||
#include "setting-match.h"
|
||||
#include "app-match.h"
|
||||
#include "kwindowsystem.h"
|
||||
|
||||
#include "file-utils.h"
|
||||
|
@ -221,6 +223,9 @@ void MainWindow::searchContent(QString searchcontent){
|
|||
// QVector<int> types;
|
||||
// QVector<QStringList> lists;
|
||||
|
||||
AppMatch * appMatchor = new AppMatch(this);
|
||||
SettingsMatch * settingMatchor = new SettingsMatch(this);
|
||||
|
||||
//测试用数据
|
||||
// QStringList list;
|
||||
// list<<"/usr/share/applications/peony.desktop"<<"/usr/share/applications/ukui-control-center.desktop"<<"/usr/share/applications/wps-office-pdf.desktop";
|
||||
|
|
Loading…
Reference in New Issue