┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/search/dolphinsearchbox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/search/dolphinsearchbox.cpp')
-rw-r--r--src/search/dolphinsearchbox.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp
index c6943c608..345692008 100644
--- a/src/search/dolphinsearchbox.cpp
+++ b/src/search/dolphinsearchbox.cpp
@@ -22,6 +22,8 @@
#include "dolphin_searchsettings.h"
#include "dolphinfacetswidget.h"
+#include <panels/places/placesitemmodel.h>
+
#include <QIcon>
#include <QLineEdit>
#include <KLocalizedString>
@@ -54,6 +56,7 @@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
m_topLayout(0),
m_searchLabel(0),
m_searchInput(0),
+ m_saveSearchAction(0),
m_optionsScrollArea(0),
m_fileNameButton(0),
m_contentButton(0),
@@ -250,6 +253,7 @@ void DolphinSearchBox::emitSearchRequest()
{
m_startSearchTimer->stop();
m_startedSearching = true;
+ m_saveSearchAction->setEnabled(true);
emit searchRequest();
}
@@ -257,6 +261,7 @@ void DolphinSearchBox::emitCloseRequest()
{
m_startSearchTimer->stop();
m_startedSearching = false;
+ m_saveSearchAction->setEnabled(false);
emit closeRequest();
}
@@ -299,6 +304,20 @@ void DolphinSearchBox::slotFacetChanged()
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);
@@ -356,6 +375,14 @@ void DolphinSearchBox::init()
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);