X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/64cfc43b97e0216caf8b7b71dd5168eaedb3068c..bff373d598c031cb1:/src/search/dolphinsearchbox.cpp diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index 345692008..9c41db9c5 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -21,52 +21,47 @@ #include "dolphin_searchsettings.h" #include "dolphinfacetswidget.h" +#include "panels/places/placesitemmodel.h" -#include - -#include -#include #include -#include #include +#include +#include +#ifdef HAVE_BALOO +#include +#include +#endif #include #include -#include +#include #include -#include +#include #include +#include #include #include #include -#include #include -#include -#ifdef HAVE_BALOO - #include - #include -#endif -#include - DolphinSearchBox::DolphinSearchBox(QWidget* parent) : QWidget(parent), m_startedSearching(false), m_active(true), - m_topLayout(0), - m_searchLabel(0), - m_searchInput(0), - m_saveSearchAction(0), - m_optionsScrollArea(0), - m_fileNameButton(0), - m_contentButton(0), - m_separator(0), - m_fromHereButton(0), - m_everywhereButton(0), - m_facetsToggleButton(0), - m_facetsWidget(0), + m_topLayout(nullptr), + m_searchLabel(nullptr), + m_searchInput(nullptr), + m_saveSearchAction(nullptr), + m_optionsScrollArea(nullptr), + m_fileNameButton(nullptr), + m_contentButton(nullptr), + m_separator(nullptr), + m_fromHereButton(nullptr), + m_everywhereButton(nullptr), + m_facetsToggleButton(nullptr), + m_facetsWidget(nullptr), m_searchPath(), - m_startSearchTimer(0) + m_startSearchTimer(nullptr) { } @@ -236,10 +231,14 @@ bool DolphinSearchBox::eventFilter(QObject* obj, QEvent* event) // #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(); - }); + // We also don't want to schedule the activation process if we are already active, + // otherwise we can enter in a loop of FocusIn/FocusOut events with the searchbox of another tab. + if (!isActive()) { + QTimer::singleShot(0, this, [this] { + setActive(true); + setFocus(); + }); + } break; default: @@ -310,11 +309,9 @@ void DolphinSearchBox::slotSearchSaved() if (searchURL.isValid()) { PlacesItemModel model; const QString label = i18n("Search for %1 in %2", text(), searchPath().fileName()); - PlacesItem* item = model.createPlacesItem(label, - searchURL, - QStringLiteral("folder-saved-search-symbolic")); - model.appendItemToGroup(item); - model.saveBookmarks(); + model.createPlacesItem(label, + searchURL, + QStringLiteral("folder-saved-search-symbolic")); } } @@ -385,7 +382,7 @@ void DolphinSearchBox::init() // Apply layout for the search input QHBoxLayout* searchInputLayout = new QHBoxLayout(); - searchInputLayout->setMargin(0); + searchInputLayout->setContentsMargins(0, 0, 0, 0); searchInputLayout->addWidget(closeButton); searchInputLayout->addWidget(m_searchLabel); searchInputLayout->addWidget(m_searchInput); @@ -445,7 +442,7 @@ void DolphinSearchBox::init() // Apply layout for the options QHBoxLayout* optionsLayout = new QHBoxLayout(); - optionsLayout->setMargin(0); + optionsLayout->setContentsMargins(0, 0, 0, 0); optionsLayout->addWidget(m_fileNameButton); optionsLayout->addWidget(m_contentButton); optionsLayout->addWidget(m_separator); @@ -471,7 +468,7 @@ void DolphinSearchBox::init() m_optionsScrollArea->setWidgetResizable(true); m_topLayout = new QVBoxLayout(this); - m_topLayout->setMargin(0); + m_topLayout->setContentsMargins(0, 0, 0, 0); m_topLayout->addLayout(searchInputLayout); m_topLayout->addWidget(m_optionsScrollArea); m_topLayout->addWidget(m_facetsWidget);