Make Saved Search feature discoverable
ClosedPublic

Authored by ngraham on Oct 24 2017, 7:13 PM.

Details

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:

Diff Detail

Repository
R318 Dolphin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
There are a very large number of changes, so older changes are hidden. Show Older Changes
ngraham edited the summary of this revision. (Show Details)
ngraham updated this revision to Diff 21256.Oct 24 2017, 7:16 PM

Remove debug line

ngraham edited the summary of this revision. (Show Details)Oct 24 2017, 7:17 PM

+1 for the idea (I wish we could actually create "virtual folders", perhaps .desktop files with a search URL in them)

Not too happy with the button's placement. Perhaps put it in the search bar, definitely add a save icon, perhaps "Save" is enough, or "Add [search] to Places" ?

Yeah I thought about that, but the clear search button already appears inside the search bar and I was worried that it would get too crowded in there. Also, adding it inline would require probably subclassing QLineEdit and making this a much bigger patch.

ngraham added a comment.EditedOct 24 2017, 7:26 PM

I could also make the button actually not appear at all until needed, like this:

ngraham updated this revision to Diff 21257.Oct 24 2017, 7:34 PM

Make the button a QToolBUtton so we can have icon+text, and also make it disappear instead of disabling when it can't be pushed

ngraham edited the summary of this revision. (Show Details)Oct 24 2017, 7:36 PM
ngraham edited the test plan for this revision. (Show Details)
cfeck added a subscriber: cfeck.Oct 24 2017, 7:56 PM
cfeck added inline comments.
src/search/dolphinsearchbox.cpp
384

Adjust the connection from QPushButton

ngraham updated this revision to Diff 21258.Oct 24 2017, 7:58 PM

Update the signal to account for using a QPushButton now

ngraham marked an inline comment as done.Oct 24 2017, 7:58 PM

Yeah I thought about that, but the clear search button already appears inside the search bar and I was worried that it would get too crowded in there. Also, adding it inline would require probably subclassing QLineEdit and making this a much bigger patch.

Nope, we could just use QLineEdit::addAction()

ngraham updated this revision to Diff 21264.Oct 24 2017, 11:39 PM

Put the button *inside* the text field

ngraham edited the summary of this revision. (Show Details)Oct 24 2017, 11:40 PM
ngraham edited the test plan for this revision. (Show Details)

Okay, I put it inside the text field:

Personally this isn't my favorite since now it's just a tiny icon which presents a challenging click target; there's no longer a nice clickable button with icon and text. But there is a certain minimalistic elegance to having it inside the text field, and this is certainly better than having no visible UI at all.

ngraham updated this revision to Diff 21265.Oct 24 2017, 11:44 PM

QPushButton -> QAction in one more place

ngraham updated this revision to Diff 21266.Oct 24 2017, 11:54 PM

Actually I guess we don't need to #include QAction at all for some reason

I have one question: right now I seem to be able to compile and run this code just fine without having #include-ed QAction anywhere, even though I'm using it. Is this... expected?

I think this is a great feature. I just want to bring a suggestion and a discussion point:

  1. Perhaps it would look better if a different icon were to be used. All the icons in the sidebar at that resolution are "flat"(if that is even the right word) and the one this patch currently uses is different and may look out of place.
  2. Does this perhaps need it's own category? "Saved Searches" or something of the sort in the places panel?

Also, the save button inside looks so good now that the "cross" icon which closes the search looks out of place.

ngraham added a comment.EditedOct 25 2017, 1:26 PM

@emateli

  1. I agree that the icon isn't quite right. It appears to be using the baloo icon when it should be using folder-saved-search-symbolic. However, that's the way it already is; I didn't change that, and it doesn't seem to be set in Dolphin. It looks like KIO::iconNameForUrl() is giving us the wrong icon, so the fix is elsewhere and out of scope for this patch (though I do want and plan to fix that soon).
  1. Same thing: for this patch, I didn't actually want to change anything about how saved searches are handled, just make the feature discoverable.
  1. The red close button is standard throughout KDE software, so I'm not sure we should change that. There is an outstanding request to make the toolbar's Find button a toggle (https://bugs.kde.org/show_bug.cgi?id=353227) which could eliminate the need for a separate close button as long as the Find button is on the toolbar, but if you remove it, then there is no only GUI method to hide the Find bar.
markg accepted this revision.Oct 25 2017, 4:22 PM
markg added a subscriber: markg.

Ohhh! Nice addition!
+1 for the idea. Code looks OK in my opinion.
Don't push it right away, wait at least a few days or till someone else also gives a +1.

src/dolphincontextmenu.cpp
309

A really minor nitpick..
Remove 1 space after the =
:)

This revision is now accepted and ready to land.Oct 25 2017, 4:22 PM
ngraham updated this revision to Diff 21325.Oct 25 2017, 4:45 PM

Fixed icon and erroneous double space

ngraham edited the test plan for this revision. (Show Details)Oct 25 2017, 4:47 PM
ngraham marked an inline comment as done.Oct 25 2017, 4:49 PM

@emateli I found a way to fix the icon in Dolphin itself for the purpose of this feature, and also filed a bug to fix KIO::iconNameForUrl() or its data source: https://bugs.kde.org/show_bug.cgi?id=386182

@emateli, if you like it, would you mind adding yourself as a reviewer and accepting it? I'm going to wait a bit as @markg suggests, but more approval should help it get through. :)

emateli accepted this revision.Oct 25 2017, 8:10 PM
markg accepted this revision.Oct 25 2017, 8:15 PM
elvisangelaccio requested changes to this revision.Oct 26 2017, 10:27 AM

I have one question: right now I seem to be able to compile and run this code just fine without having #include-ed QAction anywhere, even though I'm using it. Is this... expected?

Yes, the QAction header might be included indirectly by something else.

src/search/dolphinsearchbox.cpp
32

seems unused

264

Do we really need to disable the action? If the searchbox is not visible we don't really care, no?

309

const

379

Missing this as parent (it will leak otherwise)

This revision now requires changes to proceed.Oct 26 2017, 10:27 AM
ngraham updated this revision to Diff 21405.Oct 27 2017, 1:56 AM

Addressing @elvisangelaccio's comments

ngraham updated this revision to Diff 21406.Oct 27 2017, 1:57 AM
ngraham marked 3 inline comments as done.

One more

ngraham marked an inline comment as done.Oct 27 2017, 1:58 AM
ngraham added inline comments.
src/search/dolphinsearchbox.cpp
264

We actually do, because otherwise when you close the search panel and then re-open it, the save button will start out enabled even when there's no search term.

ngraham marked an inline comment as done.Oct 27 2017, 1:58 AM

All done, @elvisangelaccio!

There is some small stuff that perhaps are worth discussing.

  1. I still feel that this needs it's own category on the places panel
  2. The search text can be a bit misleading

Eg: Searching for "Images" with period of "This month" will produce "Images this month in <folder>".

However, the "this month" is not contextual. Next month it will still show searches from October, because during the time it was made "This month" referred to October so to say. I'm not proposing changes to make it aware of this, but I hope I get my point across on how it can be a bit misleading for some users.

  1. I still feel that this needs it's own category on the places panel

Not sure I agree; the "Search For" section seems like the right category here. You are searching for things, after all. :)

  1. The search text can be a bit misleading

    Eg: Searching for "Images" with period of "This month" will produce "Images this month in <folder>".

    However, the "this month" is not contextual. Next month it will still show searches from October, because during the time it was made "This month" referred to October so to say. I'm not proposing changes to make it aware of this, but I hope I get my point across on how it can be a bit misleading for some users.

That's a good point, and I agree that this should be made relative, not absolute. It looks like Baloo doesn't have the ability to store relative dates, only absolute ones, so a bit of work will probably be needed there. I'll follow up in the following bugs:

Not sure that's worth blocking this on since it only affects date searches. But yes, we need to fix that.

@elvisangelaccio, is this approve-able now?

anthonyfieroni added inline comments.
src/dolphincontextmenu.cpp
313

You can use again "folder-saved-search-symbolic" to be consistant with places icon. I don't think it's KIO or KProtocolInfo bug because from searching url it can't determine what icon to return, search or save.

ngraham added inline comments.Oct 29 2017, 4:36 PM
src/dolphincontextmenu.cpp
313

I don't think I can make it always return "folder-saved-search-symbolic", because this function is called from many other contexts, and often needs to return other icons. If I add a specific check for "baloosearch:" URLs, I'm just needlessly re-implementing part of KIO::iconNameForUrl().

IMHO the real fix is indeed to fix KIO::iconNameForUrl() since the non-symbolic icon it returns for all "search:" and "baloosearch:" URLs is out of place in other contexts too. For example, open another tab; in one, go to "timeline:/today", and in the other, go to "search:/documents". Observe how the first tab icon is an appropriate symbolic magnifying glass icon, while the second one is an inappropriate blue document icon.

I plan on fixing KIO::iconNameForUrl() soon, don't worry. :)

ngraham marked 2 inline comments as done.Oct 29 2017, 4:36 PM
ngraham added inline comments.Oct 29 2017, 10:11 PM
src/dolphincontextmenu.cpp
313

Hmm, maybe I can make something work here anyway...

ngraham updated this revision to Diff 21540.Oct 30 2017, 12:45 AM

Set the icon correctly when the feature is invoked from the viewport context menu

ngraham updated this revision to Diff 21541.Oct 30 2017, 12:47 AM
ngraham marked an inline comment as done.

Call container from the local variable we set

src/dolphincontextmenu.cpp
313

Yup, fixed now.

ngraham marked an inline comment as done.Oct 30 2017, 12:47 AM

@elvisangelaccio and @anthonyfieroni, any remaining concerns?

Any remaining concerns? @elvisangelaccio?

src/dolphincontextmenu.cpp
377

Don't we need the FIXME comment also here?

ngraham marked an inline comment as done.Nov 1 2017, 1:56 PM
ngraham added inline comments.
src/dolphincontextmenu.cpp
377

We actually don't since we're no longer using KIO::iconNameForUrl() to get the icon for saved searches. Instead, as @anthonyfieroni suggested, we always hardcode the "folder-saved-search-symbolic" icon for saved searches, because even if KIO::iconNameForUrl() were fixed, it would still return a different icon (probably "file-search-symbolic") which may be inappropriate in certain icon themes.

ngraham marked 2 inline comments as done.Nov 1 2017, 1:58 PM
elvisangelaccio added inline comments.Nov 1 2017, 2:41 PM
src/dolphincontextmenu.cpp
377

Then we should remove the FIXME comment below? (dolphinsearchbox.cpp line 313)

ngraham updated this revision to Diff 21701.Nov 1 2017, 2:44 PM

Don't need this FIXME comment since there's no longer anything here that needs fixing

ngraham marked an inline comment as done.Nov 1 2017, 2:44 PM
ngraham added inline comments.
src/dolphincontextmenu.cpp
377

Ah yes, most certainly.

ngraham marked 2 inline comments as done.Nov 1 2017, 2:44 PM
elvisangelaccio added inline comments.
src/dolphincontextmenu.cpp
372–373

const here

This revision is now accepted and ready to land.Nov 1 2017, 2:56 PM
ngraham updated this revision to Diff 21704.Nov 1 2017, 2:58 PM

Constify this QUrl

ngraham marked an inline comment as done.Nov 1 2017, 2:58 PM
This revision was automatically updated to reflect the committed changes.