-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Conversation
8246c5c
to
c3f4a1e
Compare
@ShaopengLin I guess this is the next one to complete the work on the new searchbar? |
@kelson42 This is the next change. @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. |
cc6d952
to
3f282b4
Compare
@veloman-yunkan The code ios ready for review. |
3f282b4
to
c26fd20
Compare
c26fd20
to
9b2c81a
Compare
Before looking at the code I tested the new feature and here is my feedback:
|
@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.
|
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. |
#413 and #315 are about completely different features. This PR is definitely a step toward #315 rather than the final touch of #413. |
1400fff
to
0c08a9e
Compare
|
src/multizimbutton.cpp
Outdated
const auto library = KiwixApp::instance()->getLibrary(); | ||
for (const auto& bookId : library->getBookIds()) | ||
{ | ||
std::shared_ptr<zim::Archive> archive; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
0c08a9e
to
9e0b37a
Compare
I changed the title of this PR. Can we also rename the button from "Multi-Zim search" to "Search Options"? |
9e0b37a
to
7fe06f5
Compare
I just realized the shortcut I gave search options is supposed to be used by #42. Let me change it to another one. |
There was a problem hiding this 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)); |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
7fe06f5
to
1d533a3
Compare
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.
1d533a3
to
5922f38
Compare
Fixes (part of) #315
Relies on #1189
Changes: