Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI for selecting the book to be used for title search #1218

Merged
merged 11 commits into from
Nov 4, 2024

Conversation

ShaopengLin
Copy link
Collaborator

@ShaopengLin ShaopengLin commented Sep 28, 2024

Fixes (part of) #315

Relies on #1189

Changes:

  • Added MultiZim button to SearchBar. Ctrl + Shift + L to open popup.
  • Searching is now allowed on library, settings, and blank tabs.
  • Popup shows a list of Zims that could be searched. The selection is singular as we do not have *true multi-zim search (yet).
  • Users can now search a different zim than the current tab.
  • Added placeholder UI for 'select-all' button. Hidden for now until *true multi-zim search is implemented.

@ShaopengLin ShaopengLin changed the title Issue#413 multizim Introduce Multi-Zim Search Sep 28, 2024
@kelson42 kelson42 added this to the 2.4.0 milestone Oct 3, 2024
@ShaopengLin ShaopengLin force-pushed the Issue#413-search-UI-improvement branch 4 times, most recently from 8246c5c to c3f4a1e Compare October 28, 2024 17:32
Base automatically changed from Issue#413-search-UI-improvement to main October 28, 2024 18:46
@kelson42
Copy link
Collaborator

@ShaopengLin I guess this is the next one to complete the work on the new searchbar?

@ShaopengLin
Copy link
Collaborator Author

@kelson42 This is the next change.

@veloman-yunkan Depending on how #1230 discussion goes we can combine them here.

@veloman-yunkan
Copy link
Collaborator

@veloman-yunkan Depending on how #1230 discussion goes we can combine them here.

@ShaopengLin This PR is about Multi-ZIM search which has nothing to do with #1230. Please provide a bugfix for #1230 as a separate PR.

@ShaopengLin ShaopengLin force-pushed the Issue#413-multizim branch 3 times, most recently from cc6d952 to 3f282b4 Compare October 30, 2024 07:31
@ShaopengLin
Copy link
Collaborator Author

@veloman-yunkan The code ios ready for review.

@veloman-yunkan
Copy link
Collaborator

veloman-yunkan commented Oct 31, 2024

Before looking at the code I tested the new feature and here is my feedback:

  1. The most obvious new possibility that could be enabled by the new button is not working - searching while on the library page.
  2. The list of ZIMs doesn't seem to be sorted in any particular order.
  3. The new UI (like probably a lot of our old UI) requires a mouse - it cannot be used via keyboard only
  4. Are there plans to support filtering the list of ZIMs shown in the ZIM selector for search? Currently it shows the full list of ZIMs. Maybe it should be in sync with the library ZIM file filter?

@veloman-yunkan
Copy link
Collaborator

Fixes (part of) #413

#413 is unrelated to multi-zim search (and probably can already be closed). Doesn't this PR rather address part of #315?

@ShaopengLin
Copy link
Collaborator Author

@veloman-yunkan Kelson decided to merge the two together back here #413 (comment). What we have here isn't true multi-Zim, since we can only search one zim at a time.

  1. That particular problem has been there since the search bar introduction. Searching also doesn't work on blank tabs, which I believe was mentioned in some issues but not sure where. Likely need to do this fix separately.

  2. Sure I can sort it. Currently, it's ordered in the same way it appears in the Local Files library.

  3. I will investigate and re-commit.

  4. One problem I see is there isn't a strong correlation for users to think library tab filters are applied to multi-zim. It can be hard to comprehend and create bad UX. Adding filters will likely need to be done within multi-zim.

@veloman-yunkan
Copy link
Collaborator

  1. That particular problem has been there since the search bar introduction. Searching also doesn't work on blank tabs, which I believe was mentioned in some issues but not sure where. Likely need to do this fix separately.

Then it made sense because search was supposed to work only for the current book and there was no current book in the library view. Now that you can select the book to search in via dedicated UI such behavior is no longer justified.

@veloman-yunkan
Copy link
Collaborator

@veloman-yunkan Kelson decided to merge the two together back here #413 (comment). What we have here isn't true multi-Zim, since we can only search one zim at a time.

#413 and #315 are about completely different features. This PR is definitely a step toward #315 rather than the final touch of #413.

@ShaopengLin
Copy link
Collaborator Author

ShaopengLin commented Oct 31, 2024

@kelson42 We should mark this PR for #315 instead if we would like to keep that Issue.

@kelson42
Copy link
Collaborator

@kelson42 We should mark this PR for #315 instead if we would like to keep that Issue.

Sorry but I'm really lost now about what fixes what. As long as the issues are implemented at the end, I'm fine with it.

@ShaopengLin ShaopengLin force-pushed the Issue#413-multizim branch 2 times, most recently from 1400fff to 0c08a9e Compare November 1, 2024 03:38
@ShaopengLin
Copy link
Collaborator Author

@veloman-yunkan

  • Keyboard controls should be available for the MultiZim popup now.
  • searching in library page is now working.
  • Sorted by alphabetic order.

resources/i18n/qqq.json Outdated Show resolved Hide resolved
src/multizimbutton.h Outdated Show resolved Hide resolved
src/multizimbutton.h Outdated Show resolved Hide resolved
src/searchbar.h Outdated Show resolved Hide resolved
const auto library = KiwixApp::instance()->getLibrary();
for (const auto& bookId : library->getBookIds())
{
std::shared_ptr<zim::Archive> archive;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the entire try{}catch(){} statement? My understanding was that you wanted to exclude those books that didn't have a valid ZIM archive associated with them (e.g. books that are still being downloaded, or books with ZIM archives on absent removable media).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, my bad forgot about the check.

src/multizimbutton.cpp Outdated Show resolved Hide resolved
src/multizimbutton.cpp Outdated Show resolved Hide resolved
resources/i18n/qqq.json Outdated Show resolved Hide resolved
src/multizimbutton.cpp Outdated Show resolved Hide resolved
Comment on lines 168 to 182
const int labelWidth = menu->width() - contentWidthExcludeText;
textLabel->setFixedWidth(labelWidth);

QFontMetrics metrics(textLabel->font());
const int elideMarkerLength = metrics.tightBoundingRect("(...)").width();
const int textLength = labelWidth - elideMarkerLength;
QString elidedText = metrics.elidedText(text, Qt::ElideRight, textLength);
if (elidedText != text)
{
/* Remove built-in elide marker */
elidedText.chop(1);
textLabel->setText(elidedText.trimmed() + "(...)");
}
else
textLabel->setText(text);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there code duplication with custom elision of suggestions?

Copy link
Collaborator Author

@ShaopengLin ShaopengLin Nov 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the if statement yes. The handling of elide is different since Qt handles LineEdit differently among other text displaying widget (quite a pain)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@veloman-yunkan
Copy link
Collaborator

I changed the title of this PR. Can we also rename the button from "Multi-Zim search" to "Search Options"?

@veloman-yunkan veloman-yunkan changed the title Introduce Multi-Zim Search UI for selecting the book to be used for title search Nov 3, 2024
@ShaopengLin
Copy link
Collaborator Author

ShaopengLin commented Nov 3, 2024

@ShaopengLin
Copy link
Collaborator Author

I just realized the shortcut I gave search options is supposed to be used by #42. Let me change it to another one.

Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Probably it would be better to get rid of the MultiZim (in source code) vs "Search options" (as presented to the user) inconsistency but that's not a sound enough reason to delay the merging of this PR.

src/kiwixapp.cpp Outdated
@@ -438,6 +438,8 @@ void KiwixApp::createActions()
CREATE_ACTION_SHORTCUT(ToggleTOCAction, gt("table-of-content"), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_1));
HIDE_ACTION(ToggleTOCAction);

CREATE_ACTION_ICON_SHORTCUT(OpenMultiZimAction, "filter", gt("search-options"), QKeySequence(Qt::CTRL | Qt::Key_M));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kelson42 Is the CTRL+M shortcut OK for a button named "Search options"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was aware of this as well. I will look around to find an appropriate one or what is the usual shortcut for this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, switched to Ctrl + Shift + L which is a common shortcut for opening and closing search options.

User can search zim other than the current tab.
Shortcut and Icon for MultiZim. Since window is popup, toggle is not possible.
Decouple complex item creation from button. Used later for styling.
Missing this reason cause completer to do nothing
Previously only checks when clicking Radiobutton
Set height&padding for list&items and stretch to menu width.
Helper function to retrieve text content that can fit inside a length given a custom "(...)" elide.
Add Custom elide marker
With MultiZim, searching on library, settings, and blank tabs are reasonable.
@kelson42 kelson42 merged commit 2365249 into main Nov 4, 2024
6 checks passed
@kelson42 kelson42 deleted the Issue#413-multizim branch November 4, 2024 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: DONE
Development

Successfully merging this pull request may close these issues.

3 participants