- If you fail to load content try on a different timer (every 5 seconds by default). This fixes slow image loading at startup if you have a long timeout between pictures.
This commit is contained in:
@@ -14,7 +14,8 @@ ImageSwitcher::ImageSwitcher(MainWindow& w, unsigned int timeout, std::unique_pt
|
|||||||
window(w),
|
window(w),
|
||||||
timeout(timeout),
|
timeout(timeout),
|
||||||
selector(selector),
|
selector(selector),
|
||||||
timer(this)
|
timer(this),
|
||||||
|
timerNoContent(this)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,10 +25,12 @@ void ImageSwitcher::updateImage()
|
|||||||
if (filename == "")
|
if (filename == "")
|
||||||
{
|
{
|
||||||
window.warn("No image found.");
|
window.warn("No image found.");
|
||||||
|
timerNoContent.start(timeoutNoContent);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window.setImage(filename);
|
window.setImage(filename);
|
||||||
|
timerNoContent.stop(); // we have loaded content so stop the fast polling
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,5 +38,6 @@ void ImageSwitcher::start()
|
|||||||
{
|
{
|
||||||
updateImage();
|
updateImage();
|
||||||
connect(&timer, SIGNAL(timeout()), this, SLOT(updateImage()));
|
connect(&timer, SIGNAL(timeout()), this, SLOT(updateImage()));
|
||||||
|
connect(&timerNoContent, SIGNAL(timeout()), this, SLOT(updateImage()));
|
||||||
timer.start(timeout);
|
timer.start(timeout);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ private:
|
|||||||
unsigned int timeout;
|
unsigned int timeout;
|
||||||
std::unique_ptr<ImageSelector>& selector;
|
std::unique_ptr<ImageSelector>& selector;
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
|
const unsigned int timeoutNoContent = 5 * 1000; // 10 sec
|
||||||
|
QTimer timerNoContent;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // IMAGESWITCHER_H
|
#endif // IMAGESWITCHER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user