Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WHY: On devices with slower I/O, loading images to QPixmap may take a long time (in my case the image directory is mapped to cloud storage). And since the timer is in its separate thread and fires signal to update the image with the configured timeout, adding image loading/processing time to the total images rotation duration negatively impacts the experience of the slide show by:
WHAT:
MainWindow::setImage
) to its own function inImageSwitcher
that can be parallelized to the main window image update thread.imageUpdated
signal, emitted whenMainWindow::setImage
finished executing. It fetches the next filename and loads the image into memory in the background while the QWidget is being repainted, so that when the timeout timer fires, the main window update don't need to wait for the image to load.NOTE:
C++ is not my expertise, and I'm not sure the threaded solution I chose ( a combination of
QFuture
,QFutureWatcher
andQtConcurrent
) is ideal.One caveat is that if the image is not successfully loaded whenImageSwitcher::updateImage
is being invoked by the timer, the same (old) image will be displayed, effectively double the duration for that image and skipping the failed-to-load image (because the image update action will trigger another image load action), but with the original logic the same behavior would also be expected (but worse because of the added image processing time).One potential workaround is to block on
ImageSwitcher::updateImage
to update the image only when a new image is successfully loaded, but my lack of C++ knowledge makes it hard for me to have it implemented.The main drawing thread can block on image loading with
QFutureWatcher.isRunning()
.This PR also includes changes from configurable transition time #42 and skip overlay processing when no overlay is specified #43, and those should be reviewed prior to this one.I was able to refactor the PR and remove unrelated changes.