Summary:
FEATURE: 269332
Make Dolphin's Saved Search feature discoverable by adding a button inside the search field. The button only becomes enabled when there is a valid search term. When pushed, it saves the search to the Places panel, providing a visible-by-default way to do this to complement the existing implementation that is only visible in the context menu.
Also harmonized the label text so that it's consistent no matter how you create a saved search (button or context menu)
Test Plan:
Tested in KDE Neon. Works great:
{
F5449508}
Reviewers: #dolphin, broulik, dfaure, markg, emateli, elvisangelaccio
Reviewed By: #dolphin, markg, emateli, elvisangelaccio
Subscribers: anthonyfieroni, markg, emateli, elvisangelaccio, cfeck, #dolphin
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D8454
QAction* action = exec(m_pos);
if (addToPlacesAction && (action == addToPlacesAction)) {
const DolphinViewContainer* container = m_mainWindow->activeViewContainer();
QAction* action = exec(m_pos);
if (addToPlacesAction && (action == addToPlacesAction)) {
const DolphinViewContainer* container = m_mainWindow->activeViewContainer();
- if (container->url().isValid()) {
+ const QUrl url = container->url();
+ if (url.isValid()) {
- PlacesItem* item = model.createPlacesItem(container->placesText(),
- container->url(),
- KIO::iconNameForUrl(container->url()));
+ QString icon;
+ if (container->isSearchModeEnabled()) {
+ icon = QStringLiteral("folder-saved-search-symbolic");
+ } else {
+ icon = KIO::iconNameForUrl(url);
+ }
+ PlacesItem* item = model.createPlacesItem(container->placesText(), url, icon);
model.appendItemToGroup(item);
model.saveBookmarks();
}
model.appendItemToGroup(item);
model.saveBookmarks();
}
QString text;
if (isSearchModeEnabled()) {
QString text;
if (isSearchModeEnabled()) {
- text = m_searchBox->searchPath().fileName() + QLatin1String(": ") + m_searchBox->text();
+ text = i18n("Search for %1 in %2", m_searchBox->text(), m_searchBox->searchPath().fileName());
} else {
text = url().fileName();
if (text.isEmpty()) {
} else {
text = url().fileName();
if (text.isEmpty()) {
#include "dolphin_searchsettings.h"
#include "dolphinfacetswidget.h"
#include "dolphin_searchsettings.h"
#include "dolphinfacetswidget.h"
+#include <panels/places/placesitemmodel.h>
+
#include <QIcon>
#include <QLineEdit>
#include <KLocalizedString>
#include <QIcon>
#include <QLineEdit>
#include <KLocalizedString>
m_topLayout(0),
m_searchLabel(0),
m_searchInput(0),
m_topLayout(0),
m_searchLabel(0),
m_searchInput(0),
m_optionsScrollArea(0),
m_fileNameButton(0),
m_contentButton(0),
m_optionsScrollArea(0),
m_fileNameButton(0),
m_contentButton(0),
{
m_startSearchTimer->stop();
m_startedSearching = true;
{
m_startSearchTimer->stop();
m_startedSearching = true;
+ m_saveSearchAction->setEnabled(true);
{
m_startSearchTimer->stop();
m_startedSearching = false;
{
m_startSearchTimer->stop();
m_startedSearching = false;
+ m_saveSearchAction->setEnabled(false);
+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);
void DolphinSearchBox::initButton(QToolButton* button)
{
button->installEventFilter(this);
this, &DolphinSearchBox::slotSearchTextChanged);
setFocusProxy(m_searchInput);
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);
// Apply layout for the search input
QHBoxLayout* searchInputLayout = new QHBoxLayout();
searchInputLayout->setMargin(0);
void slotReturnPressed();
void slotFacetsButtonToggled();
void slotFacetChanged();
void slotReturnPressed();
void slotFacetsButtonToggled();
void slotFacetChanged();
+ void slotSearchSaved();
private:
void initButton(QToolButton* button);
private:
void initButton(QToolButton* button);
QLabel* m_searchLabel;
QLineEdit* m_searchInput;
QLabel* m_searchLabel;
QLineEdit* m_searchInput;
+ QAction* m_saveSearchAction;
QScrollArea* m_optionsScrollArea;
QToolButton* m_fileNameButton;
QToolButton* m_contentButton;
QScrollArea* m_optionsScrollArea;
QToolButton* m_fileNameButton;
QToolButton* m_contentButton;