diff --git a/src/UserInterface/full_mainwindow.cpp b/src/UserInterface/full_mainwindow.cpp index 826dc1d..d58f714 100755 --- a/src/UserInterface/full_mainwindow.cpp +++ b/src/UserInterface/full_mainwindow.cpp @@ -317,7 +317,7 @@ bool FullMainWindow::eventFilter(QObject *watched, QEvent *event) if (event->type() == QEvent::KeyPress) { QKeyEvent *ke = (QKeyEvent *)event; - if (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return) { + if (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Down) { Q_EMIT sendSetFocusToResult(); } } @@ -371,6 +371,23 @@ void FullMainWindow::iconAnimationFinished() -Style::DropMenuWidth, 45))); } +void FullMainWindow::keyPressEvent(QKeyEvent *e) +{ + if (e->type() == QEvent::KeyPress) { + if ((e->key() >= Qt::Key_0 && e->key() <= Qt::Key_9) || (e->key() >= Qt::Key_A && e->key() <= Qt::Key_Z)) { + qDebug() << "void MainWindow::keyPressEvent(QKeyEvent *e)" << e->text(); + m_lineEdit->setFocus(); + m_lineEdit->setText(e->text()); + } + + if (e->key() == Qt::Key_Backspace) { + if (!m_lineEdit->text().isEmpty()) { + m_lineEdit->setText(""); + } + } + } +} + void FullMainWindow::selectIconAnimation(const bool &flag) { iconAnimation = new QPropertyAnimation(m_fullSelectMenuButton, "rotation", this); @@ -452,6 +469,7 @@ bool FullMainWindow::event(QEvent *event) } if (keyEvent->key() == Qt::Key_Escape) { + m_lineEdit->clear(); this->hide(); } } diff --git a/src/UserInterface/full_mainwindow.h b/src/UserInterface/full_mainwindow.h index 34a91ca..9592169 100755 --- a/src/UserInterface/full_mainwindow.h +++ b/src/UserInterface/full_mainwindow.h @@ -63,6 +63,7 @@ protected: void initLayout(); void selectIconAnimation(const bool &flag); void iconAnimationFinished(); + void keyPressEvent(QKeyEvent *e); private: QAction *m_allAction = nullptr; diff --git a/src/UserInterface/mainwindow.cpp b/src/UserInterface/mainwindow.cpp index 05f2f05..8614bc5 100755 --- a/src/UserInterface/mainwindow.cpp +++ b/src/UserInterface/mainwindow.cpp @@ -319,6 +319,7 @@ void MainWindow::initSearchUi() m_lineEdit->setStyleSheet(QString::fromUtf8("border-radius: 13px; border:1px solid rgba(5, 151, 255, 1); background: transparent;")); m_lineEdit->setFrame(false); m_lineEdit->setPlaceholderText(tr("Search")); + m_lineEdit->installEventFilter(this); m_cancelSearchPushButton = new QPushButton(m_minSearchPage); m_cancelSearchPushButton->setFixedSize(QSize(26, 26)); // m_cancelSearchPushButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); @@ -1012,6 +1013,13 @@ bool MainWindow::eventFilter(QObject *target, QEvent *event) } } + if (target == m_lineEdit) { + if (ke->key() == Qt::Key_Down) { + m_minSearchResultListView->setFocus(); + return true; + } + } + if (target == m_minSelectButton) { if (ke->key() == Qt::Key_Down) { if (m_state == 0) { @@ -1099,6 +1107,7 @@ void MainWindow::recvSearchResult(QVector arg) m_searchAppThread->quit(); QVector m_data; m_data.clear(); + m_minSearchResultListView->verticalScrollBar()->setSliderPosition(0); m_minSearchResultListView->addData(m_data, 3); Q_FOREACH (QStringList appinfo, arg) {