#include "dolphin_searchsettings.h"
#include "dolphinfacetswidget.h"
+#include <panels/places/placesitemmodel.h>
+
#include <QIcon>
#include <QLineEdit>
#include <KLocalizedString>
m_topLayout(0),
m_searchLabel(0),
m_searchInput(0),
+ m_saveSearchAction(0),
m_optionsScrollArea(0),
m_fileNameButton(0),
m_contentButton(0),
{
m_startSearchTimer->stop();
m_startedSearching = true;
+ m_saveSearchAction->setEnabled(true);
emit searchRequest();
}
{
m_startSearchTimer->stop();
m_startedSearching = false;
+ m_saveSearchAction->setEnabled(false);
emit closeRequest();
}
emit searchRequest();
}
+void DolphinSearchBox::slotSearchSaved()
+{
+ const QUrl searchURL = urlForSearching();
+ 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();
+ }
+}
+
void DolphinSearchBox::initButton(QToolButton* button)
{
button->installEventFilter(this);
this, &DolphinSearchBox::slotSearchTextChanged);
setFocusProxy(m_searchInput);
+ // Add "Save search" button inside search box
+ m_saveSearchAction = new QAction(this);
+ m_saveSearchAction->setIcon (QIcon::fromTheme(QStringLiteral("document-save-symbolic")));
+ m_saveSearchAction->setText(i18nc("action:button", "Save this search to quickly access it again in the future"));
+ m_saveSearchAction->setEnabled(false);
+ m_searchInput->addAction(m_saveSearchAction, QLineEdit::TrailingPosition);
+ connect(m_saveSearchAction, &QAction::triggered, this, &DolphinSearchBox::slotSearchSaved);
+
// Apply layout for the search input
QHBoxLayout* searchInputLayout = new QHBoxLayout();
searchInputLayout->setMargin(0);