msl
I would like to add a progress bar for the image download function in the user tab. Is there a way to get informations about the progress and the total number of files from the cli functions 'imdl' and 'mdl'?
Not from the CLI command, but it should be possible using the underlying chdku functions, possibly with minor changes.
If you look at cli.lua imdl, it uses con:imglist to get a list of files, so you can get the total number. It includes stat values, so you could get size too.
imglist_download accepts an opt value called info_fn. This is normally used in verbose mode to display the file names, but you could provide your own. For a download, it will be called like
opts.info_fn('%s->%s\n',src,dst)
but it may also be called with other values, so you'd have to do some fiddling to get the file download.
Adding a new callback like progress_fn() would probably be better.
chdku mdownload doesn't use a separate function to make the file list, so it would need additional changes. A simple way to do it would be to add a callback to opts that gets called with files after the ff_mdownload call. Splitting it to work like imdl might be better.
You might also run into issues actually updating the GUI: If you call chdku code directly the gui will be blocked until the entire operation completes. If you use the cli:execute, it uses a coroutine that yields to the gui when chdku code sleeps. You might be able to work around this by calling your code through the exec (!) cli command. However, I don't think the current code yields while it's actually downloading the files anyway, so that might need to be done in the progress function.
This is something I would like to have, so I'd be willing to help add the necessary hooks if the above is more than you want to get into.
If you make major changes outside of the gui_user file, I'd prefer to have a patch to look at before it gets checked in.