From bfb893ad8e132c9b2dc2a2a7fae1d227667d58f8 Mon Sep 17 00:00:00 2001 From: Shaun Date: Tue, 19 Jan 2016 18:58:42 +1100 Subject: [PATCH] use standard progress dialog for progress and add cancel --- resources/lib/artwork.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/resources/lib/artwork.py b/resources/lib/artwork.py index 25860bb4..fd746a55 100644 --- a/resources/lib/artwork.py +++ b/resources/lib/artwork.py @@ -170,10 +170,9 @@ class Artwork(): if not xbmcgui.Dialog().yesno("Image Texture Cache", "Running the image cache process can take some time.", "Are you sure you want continue?"): return - self.logMsg("Doing Image Cache Sync", 1) - dialog = xbmcgui.DialogProgressBG() + dialog = xbmcgui.DialogProgress() dialog.create("Emby for Kodi", "Image Cache Sync") # ask to rest all existing or not @@ -213,9 +212,11 @@ class Artwork(): percentage = 0 self.logMsg("Image cache sync about to process " + str(total) + " images", 1) for url in result: + if dialog.iscanceled(): + break percentage = int((float(count) / float(total))*100) textMessage = str(count) + " of " + str(total) + " (" + str(len(self.imageCacheThreads)) + ")" - dialog.update(percentage, message="Updating Image Cache: " + textMessage) + dialog.update(percentage, "Updating Image Cache: " + textMessage) self.CacheTexture(url[0]) count += 1 cursor.close() @@ -230,20 +231,22 @@ class Artwork(): percentage = 0 self.logMsg("Image cache sync about to process " + str(total) + " images", 1) for url in result: + if dialog.iscanceled(): + break percentage = int((float(count) / float(total))*100) textMessage = str(count) + " of " + str(total) - dialog.update(percentage, message="Updating Image Cache: " + textMessage) + dialog.update(percentage, "Updating Image Cache: " + textMessage) self.CacheTexture(url[0]) count += 1 cursor.close() - dialog.update(100, message="Waiting for all threads to exit: " + str(len(self.imageCacheThreads))) + dialog.update(100, "Waiting for all threads to exit: " + str(len(self.imageCacheThreads))) self.logMsg("Waiting for all threads to exit", 1) while len(self.imageCacheThreads) > 0: for thread in self.imageCacheThreads: if thread.isFinished: self.imageCacheThreads.remove(thread) - dialog.update(100, message="Waiting for all threads to exit: " + str(len(self.imageCacheThreads))) + dialog.update(100, "Waiting for all threads to exit: " + str(len(self.imageCacheThreads))) self.logMsg("Waiting for all threads to exit: " + str(len(self.imageCacheThreads)), 1) xbmc.sleep(500)