X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/5593c252e8d9638c86dcc2bb9edd394ea14f8ba1..43da84eefc7d:/src/search/dolphinsearchbox.cpp diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index 26ddd27f8..c6943c608 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -206,6 +207,13 @@ void DolphinSearchBox::showEvent(QShowEvent* event) } } +void DolphinSearchBox::hideEvent(QHideEvent* event) +{ + Q_UNUSED(event); + m_startedSearching = false; + m_startSearchTimer->stop(); +} + void DolphinSearchBox::keyReleaseEvent(QKeyEvent* event) { QWidget::keyReleaseEvent(event); @@ -222,8 +230,13 @@ bool DolphinSearchBox::eventFilter(QObject* obj, QEvent* event) { switch (event->type()) { case QEvent::FocusIn: - setActive(true); - setFocus(); + // #379135: we get the FocusIn event when we close a tab but we don't want to emit + // the activated() signal before the removeTab() call in DolphinTabWidget::closeTab() returns. + // To avoid this issue, we delay the activation of the search box. + QTimer::singleShot(0, this, [this] { + setActive(true); + setFocus(); + }); break; default: @@ -378,6 +391,20 @@ void DolphinSearchBox::init() searchLocationGroup->addButton(m_fromHereButton); searchLocationGroup->addButton(m_everywhereButton); + auto moreSearchToolsButton = new QToolButton(this); + moreSearchToolsButton->setAutoRaise(true); + moreSearchToolsButton->setPopupMode(QToolButton::InstantPopup); + moreSearchToolsButton->setIcon(QIcon::fromTheme("arrow-down-double")); + moreSearchToolsButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + moreSearchToolsButton->setText(i18n("More Search Tools")); + moreSearchToolsButton->setMenu(new QMenu(this)); + connect(moreSearchToolsButton->menu(), &QMenu::aboutToShow, moreSearchToolsButton->menu(), [this, moreSearchToolsButton]() + { + m_menuFactory.reset(new KMoreToolsMenuFactory("dolphin/search-tools")); + moreSearchToolsButton->menu()->clear(); + m_menuFactory->fillMenuFromGroupingNames(moreSearchToolsButton->menu(), { "files-find" }, this->m_searchPath); + } ); + // Create "Facets" widgets m_facetsToggleButton = new QToolButton(this); m_facetsToggleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); @@ -397,8 +424,10 @@ void DolphinSearchBox::init() optionsLayout->addWidget(m_separator); optionsLayout->addWidget(m_fromHereButton); optionsLayout->addWidget(m_everywhereButton); - optionsLayout->addStretch(1); + optionsLayout->addWidget(new KSeparator(Qt::Vertical, this)); optionsLayout->addWidget(m_facetsToggleButton); + optionsLayout->addWidget(moreSearchToolsButton); + optionsLayout->addStretch(1); // Put the options into a QScrollArea. This prevents increasing the view width // in case that not enough width for the options is available.