}
query.addQueryItem(QStringLiteral("url"), searchPath().url());
+ query.addQueryItem(QStringLiteral("title"), queryTitle(m_searchInput->text()));
url.setQuery(query);
}
void DolphinSearchBox::fromSearchUrl(const QUrl& url)
{
- if (url.scheme() == QLatin1String("baloosearch")) {
- const DolphinQuery query = DolphinQuery::fromBalooSearchUrl(url);
+ if (DolphinQuery::supportsScheme(url.scheme())) {
+ const DolphinQuery query = DolphinQuery::fromSearchUrl(url);
updateFromQuery(query);
} else if (url.scheme() == QLatin1String("filenamesearch")) {
const QUrlQuery query(url);
void DolphinSearchBox::init()
{
- // Create close button
- QToolButton* closeButton = new QToolButton(this);
- closeButton->setAutoRaise(true);
- closeButton->setIcon(QIcon::fromTheme(QStringLiteral("dialog-close")));
- closeButton->setToolTip(i18nc("@info:tooltip", "Quit searching"));
- connect(closeButton, &QToolButton::clicked, this, &DolphinSearchBox::emitCloseRequest);
-
// Create search box
m_searchInput = new QLineEdit(this);
m_searchInput->setPlaceholderText(i18n("Search..."));
m_searchInput->addAction(m_saveSearchAction, QLineEdit::TrailingPosition);
connect(m_saveSearchAction, &QAction::triggered, this, &DolphinSearchBox::slotSearchSaved);
+ // Create close button
+ QToolButton* closeButton = new QToolButton(this);
+ closeButton->setAutoRaise(true);
+ closeButton->setIcon(QIcon::fromTheme(QStringLiteral("dialog-close")));
+ closeButton->setToolTip(i18nc("@info:tooltip", "Quit searching"));
+ connect(closeButton, &QToolButton::clicked, this, &DolphinSearchBox::emitCloseRequest);
+
// Apply layout for the search input
QHBoxLayout* searchInputLayout = new QHBoxLayout();
searchInputLayout->setContentsMargins(0, 0, 0, 0);
- searchInputLayout->addWidget(closeButton);
searchInputLayout->addWidget(m_searchInput);
+ searchInputLayout->addWidget(closeButton);
// Create "Filename" and "Content" button
m_fileNameButton = new QToolButton(this);
connect(m_startSearchTimer, &QTimer::timeout, this, &DolphinSearchBox::emitSearchRequest);
}
+QString DolphinSearchBox::queryTitle(const QString& text) const
+{
+ return i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.",
+ "Query Results from '%1'", text);
+}
+
QUrl DolphinSearchBox::balooUrlForSearching() const
{
#ifdef HAVE_BALOO
query.setSearchString(queryStrings.join(QLatin1Char(' ')));
- return query.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.",
- "Query Results from '%1'", text));
+ return query.toSearchUrl(queryTitle(text));
#else
return QUrl();
#endif
setSearchPath(QUrl::fromLocalFile(QDir::homePath()));
}
- setText(query.text());
+ // If the input box has focus, do not update to avoid messing with user typing
+ if (!m_searchInput->hasFocus()) {
+ setText(query.text());
+ }
if (query.hasContentSearch()) {
m_contentButton->setChecked(true);