-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Search: save queries across restarts, related tweaks & fixes #4458
Conversation
+102 −6 |
Yes, I was surprised how easy it is to save and load the queries. So easy that I'm afraid I overlooked a fundamental mistake... |
Thank you for fixing the bug of disappearing queries, I was wondering where that came frome. |
I think this quick hack of using mixxx.cfg is adequate. AFAIK there isn't a technical reason this couldn't work as well as storing this data in the SQLite database, but this seems much simpler. When we replace the library with Aoide we'll probably have a completely different system for storing queries persistently. Considering how useful this feature is and the low complexity of the code being added here, I agree that it is worth it to have this now even if the user data may be incompatible with the future system. |
@@ -146,9 +149,15 @@ WSearchLineEdit::WSearchLineEdit(QWidget* pParent) | |||
clearButtonSize.width() + m_frameWidth + kClearButtonClearence, | |||
layoutDirection())); | |||
|
|||
loadQueriesFromConfig(); |
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.
This will cause strange behaviour if there is more then 1 searchbar, but I don't know if this is even supported.
If there is a shared store for the queries there must be some sort of sync between the boxes and the config file, at least the object updated.
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.
when a searchbar widget is created from the skin parser it's bound to the library widget.
So, if there is more than one searchbar only the last one is bound. didn't try that though. Edit both are bound and could work, but the queries are not sync'ed. Nothing to worry about since that is not a supported use case.
There's another WSearchLineEdit in the dev tools, but it's created without passing the settings pointer, thus no queries are stored for that.
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.
Considering we will not be doing a major redesign of the QWidgets library to add a second WSearchLineEdit, I am willing to accept something kinda hacky.
Limiting the storage sounds reasonable. That could happen in WSearchLineEdit itself by setting |
src/widget/wsearchlineedit.cpp
Outdated
for (int index = 0; index < count(); index++) { | ||
m_pConfig->setValue( | ||
ConfigKey(kSavedQueriesConfigGroup, QString::number(index)), | ||
this->itemText(index)); |
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.
this->itemText(index)); | |
itemText(index)); |
src/widget/wsearchlineedit.cpp
Outdated
@@ -297,6 +331,11 @@ bool WSearchLineEdit::eventFilter(QObject* obj, QEvent* event) { | |||
slotSaveSearch(); | |||
} | |||
} | |||
} else { | |||
if (keyEvent->key() == Qt::Key_Backspace) { |
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.
Please add a comment, how this works, it is not obvious when reading the code.
Doesn't it interfere with the backspace when editing the querry?
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.
Ah got it.
The issue is that we have the check if the popup is visible twice.
Maybe two functions for each case makes it obvious.
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.
The is just a readability issue.
The rest looks good.
Thank you.
@@ -439,6 +481,30 @@ void WSearchLineEdit::slotMoveSelectedHistory(int steps) { | |||
m_saveTimer.stop(); | |||
} | |||
|
|||
void WSearchLineEdit::slotDeleteCurrentItem() { |
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.
The name is misleading, because it deletes the current item or the highlighted item.
Since we gave the Chech in the calling code in the backspace case anyway I think the best solution is to make two functions and move the check into the valueChanged callback.
Alternative would be a better function name.
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 turned this into deleteSelectedListItem()
and deleteSelectedComboboxItem()
, and slotDeleteCurrentItem()
which is connected to the CO which would pick one of the two depending on isVisible()
src/widget/wsearchlineedit.cpp
Outdated
@@ -297,6 +331,11 @@ bool WSearchLineEdit::eventFilter(QObject* obj, QEvent* event) { | |||
slotSaveSearch(); | |||
} | |||
} | |||
} else { | |||
if (keyEvent->key() == Qt::Key_Backspace) { |
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.
Ah got it.
The issue is that we have the check if the popup is visible twice.
Maybe two functions for each case makes it obvious.
What about 50? |
e1297fe
to
966c0c0
Compare
@daschuer I implemented your suggestions. Please take a look. btw I just discovered a bug (also in main):
I'll check if |
ahemm, |
Thank you. I have just tested this and can confirm the issue:
Another thing is that I was tempted to use the del key instead of backspace more than once during the test. Can we add it as well? |
Sure we could do that. |
I fixed the duplicate bug, but I'll also need to fix the writing to the config to avoid duplicates there, probably wipe all entries before saving. |
f47176a
to
e9055d9
Compare
Done. |
Further optimization would be to set QKey constants and use them for the tooltip and the key event filter. |
45c0a1d
to
d13e847
Compare
I think it is sufficient to just add the del key. I have just checked how Firefox and Chrome works. Backspace starts immediately to edit the highlighted entry. It can be deleted by Shift+del and Shift +CMD+ Backspace.. Not sure if this patter is relevant for us. |
d13e847
to
c78d9a4
Compare
c78d9a4
to
a93b621
Compare
suggestions addded & squashed. |
Thank you, I will do a final check. In general, you should not rebase a PR under review. This creates untested commits and makes it hard for the reviewer to review the changes compared to the last review. See: https://github.com/mixxxdj/mixxx/blob/main/CONTRIBUTING.md#all-contributors |
Sorry, won't happen again. I'd like to avoid formatting one-line commits, and since I merged main I couldn't ammend anymore. |
Ok, no big deal in this case. Just ask before. |
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.
This works like a charm. Thank you.
Store queries to mixxx.cfg when WSearchLineEdit is destroyed (shutdown or skin change), load when it's created.
(only for the library searchbar, not the control searchbar in the developer tools dialog)
Currently only the selected query is stored on skin change, others are lost.
Delete
andBackspace
in the popup delete the selected itemThis allows cleaning up the history, which I consider a rare maintenance job thus I did not add a delete shortcut for the combobox view.
I also added a control
[Library], delete_search_query
to delete the current item from the popup or the combobox view.tweaks & fixes:
When index -1 is selected in the combobox and the list view is opened index 0 is auto-set but not highlighted.
Select first index manually (only in the list).
https://bugs.launchpad.net/mixxx/+bug/1943084
https://bugs.launchpad.net/mixxx/+bug/1947479