restore last selected library feature/playlist/crate on restart - #15460
restore last selected library feature/playlist/crate on restart#15460mxmilkiib wants to merge 2 commits into
Conversation
daschuer
left a comment
There was a problem hiding this comment.
Thank you for this nice feature.
|
Why not simply store the number of the selected row + childrow? would be the 4th Playlist item. |
| QModelIndex found = findChild(childIndex); | ||
| if (found.isValid()) { | ||
| return found; | ||
| } |
There was a problem hiding this comment.
No need to iterate over children manually, just use pChildModel::match() and stop at first match.
There was a problem hiding this comment.
I'd still prefer the row+childrow approach btw.
Note: both name- and index-based lookup will fail for Computer as the tree is created on demand / on expand.
For History it may fail if auto-cleanup deleted the selected playlist.
|
it can be changed if you think it would be less brittle for all/most cases |
|
Well, there's no way to make it work for Computer and obviously auto-removed History items can't be selected. |
| pFeature->activateChild(savedIndex); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Why not use SidebarModel::clicked(index)?
Looks it does the exact same thing.
|
I'm curious, did you use ai to code this? |
|
my preference would be for it to have that wider scope but with the graceful fallback/degradation thanks, I'll check/use the suggestions later yes, I used Claude Sonnet 4.5 thinking it feels like Claude 4+, and GPT-5, are half-way around turning the not-slop corner. afaiu, this relates to the context window embiggening (Windsurf currently has reduced rates for both, which is one facet of the bubble right now tbqf. I can't afford pro-level-spec-taking project-building Claude Opus) quality depending on the correct promoting and process used; for recent context, the two big polarised HN stories about curl & AI (and stories like this and related comments) (this aside from the relatively complex proof-is-in-the-pudding LPP3 script I've put together, lots of time being mindful of code smells, 8100+ LOC that I'll eventually modularise) I'm thinking of getting together a RULES txt file guide for working with Mixxx, to collate patterns and preferences from the project (beyond just pointing to the wiki, which I forgot last night) it's also helping me greatly with git and feature-branch/PR management all (plus I've also recently finally massively refactored many dotconfigs, including making several AwesomeWM Lua modules) |
e76622b to
b2bde95
Compare
| QString featureIconName; | ||
| QString childData; |
There was a problem hiding this comment.
| QString featureIconName; | |
| QString childData; | |
| QString featureName; | |
| QString childName; |
|
This is currently failing because the value |
|
Besides, we need to use Here's a fixup 6582dc2 Tested with playlists and Quick Links items. |
b2bde95 to
28ec3de
Compare
b1a8f86 to
f188d9a
Compare
f188d9a to
5eb6c5a
Compare
5eb6c5a to
ad5067a
Compare
|
it now stores the positioning of the sidebar view after each change so, instead of trying to have the selected entry be bottom-most or centre, it just restores where the user had the scroll position beforehand I think the requests were folded in properly any other failure modes I should add protection for? |
| // this event. | ||
| stopPressedUntilClickedTimer(); | ||
| if (index.isValid()) { | ||
| // save the selection for restoration on restart |
There was a problem hiding this comment.
I think we need to store the selection only on shutdown, ie. in the destructor, not on every click?
| connect(verticalScrollBar(), | ||
| &QScrollBar::valueChanged, | ||
| this, | ||
| &WLibrarySidebar::saveScrollPosition); |
There was a problem hiding this comment.
Let's not write to config for every scroll.
And not remove comments unless there's a real reason.
| if (rowCount() == 0) { | ||
| return; | ||
| } | ||
|
|
There was a problem hiding this comment.
why do we need this?
does this prevent repainting a child model if we for example removed all History playlists?
| // Start a timer to auto-expand sections the user hovers on. | ||
| void WLibrarySidebar::dragMoveEvent(QDragMoveEvent* event) { | ||
| // qDebug() << "dragMoveEvent" << event->mimeData()->formats(); | ||
| // Start a timer to auto-expand sections the user hovers on. |
There was a problem hiding this comment.
| // Start a timer to auto-expand sections the user hovers on. | |
| // Start a timer to auto-expand sections the user hovers on. |
|
|
||
| if (!scrollToIndex) { | ||
| // restore saved scroll position after tree expansion completes | ||
| QTimer::singleShot(100, this, &WLibrarySidebar::restoreScrollPosition); |
There was a problem hiding this comment.
why do we need this?
IIUC this also a no-op in most cases (click), but requires reading from config
a914597 to
ff6507a
Compare
|
oops how do I github 🐾 |
ronso0
left a comment
There was a problem hiding this comment.
It looks like you added some minor bugfixes. Please create separate commits for those and explain what's wrong with the previous implementation.
| m_pKeyNotation.reset( | ||
| new ControlObject(mixxx::library::prefs::kKeyNotationConfigKey)); |
There was a problem hiding this comment.
Why reset?
And this is a std::unique_ptr, not a plain ControlObject*
| // feature not found, can't search for child | ||
| if (featureRow < 0) { | ||
| return {}; | ||
| } |
There was a problem hiding this comment.
This can be moved up, below for (int i = 0; i < m_sFeatures.size(); ++i) {
| 1, // stop at first match | ||
| Qt::MatchExactly | Qt::MatchRecursive); | ||
|
|
||
| if (!matches.isEmpty() && matches.first().isValid()) { |
There was a problem hiding this comment.
results of QAbstractItemModel::match() should never be invalid.
If you think we need to ensure validity, use
VERIFY_OR_DEBUG_ASSERT(matches.first().isValid()) {
// some qWarning()
return {};
}
|
|
||
| void WLibrarySidebar::setup(UserSettingsPointer pConfig) { | ||
| m_pConfig = pConfig; | ||
| // removed: connection to save on every scroll - now saves on shutdown only |
There was a problem hiding this comment.
irrelevant for devs touching this in the future, please remove
84a1e8e to
d36954a
Compare
|
CI is failing. Both pre-commit and the build jobs. |
d36954a to
398eecf
Compare
|
rebased and restructured into 4 commits addressing ronso0's feedback. also fixed several bugs in the original implementation:
also extended the feature to save/restore the selected track row within the table (via TrackId persisted to config, consumed in loadTrackModel). |
557302a to
a78ea19
Compare
|
FYI CI builds failed |
|
.. and unrelated changes slipped in |
a78ea19 to
6ee9eff
Compare
50837a2 to
03d7fca
Compare
03d7fca to
bb0ffce
Compare
|
why it this stale again? I'm not "developing", just catching up I think it's stale because the implementation was switched out halfway through the PR and it was too much to follow at the time, but afair the later commit set neatened things up |
bb0ffce to
3bf3c18
Compare
3bf3c18 to
e322da9
Compare
|
redone, actually confirmed working, still testing now as two commits. the track reselection needed a bit extra workflow hopefully it's methods are now concise and respectful enough of existing Mixxx systems |
implements #10125
persists the currently selected sidebar item (feature or child) to user settings and restores it on next mixxx startup.
uses feature title + child data for robust matching across sessions. gracefully falls back to default selection if saved item not found.
config keys: