Fix :The input box has no focus after press win+s sometimes.

This commit is contained in:
iaom 2021-09-16 14:58:07 +08:00
parent 58905ea83d
commit c74c9ba781
3 changed files with 8 additions and 4 deletions

View File

@ -102,6 +102,7 @@ SeachBarWidget::SeachBarWidget(QWidget *parent): QWidget(parent) {
this->setFixedSize(m_searchLineEdit->width()+20, m_searchLineEdit->height()+20);
m_ly->setContentsMargins(0,0,0,0);
m_ly->addWidget(m_searchLineEdit);
this->setFocusProxy(m_searchLineEdit);
connect(m_searchLineEdit, &SearchLineEdit::requestSearchKeyword, this, &SeachBarWidget::requestSearchKeyword);
}

View File

@ -66,7 +66,6 @@ MainWindow::MainWindow(QWidget *parent) :
this->setWindowFlag(Qt::FramelessWindowHint);
this->setAutoFillBackground(false);
this->setFocusPolicy(Qt::StrongFocus);
this->setFocusProxy(this);
this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
this->setWindowTitle(tr("ukui-search"));
initUi();
@ -127,6 +126,7 @@ void MainWindow::initUi() {
m_searchResultPage = new SearchResultPage(this);
m_searchResultPage->hide();
m_searchResultPage->move(0, 58);
this->setFocusProxy(m_searchBarWidget);
// m_searchResultPage->show();
// m_searchWidget = new SeachBarWidget(this);
@ -183,9 +183,10 @@ void MainWindow::bootOptionsFilter(QString opt) {
if(opt == "-s" || opt == "--show") {
clearSearchResult();
centerToScreen(this);
this->show();
// this->m_searchLineEdit->focusIn();
this->raise();
if(this->isHidden()) {
this->show();
}
this->m_searchBarWidget->setFocus();
this->activateWindow();
}
}
@ -543,6 +544,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::ActivationChange) {
qDebug() << "QEvent::ActivationChange!!!!" << "active" << (QApplication::activeWindow() == this) << "isVisble" << (this->isVisible());
if(QApplication::activeWindow() != this) {
tryHideMainwindow();
}

View File

@ -2,6 +2,7 @@
using namespace Zeeker;
void UkuiSearchDbusServices::showWindow(){
qDebug() << "showWindow called";
m_mainWindow->bootOptionsFilter("-s");
}