From d9a5b8feaf8ea1ef76251918902a5f904c9c0825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Thu, 5 Jan 2023 11:35:19 +0100 Subject: [PATCH] FileView: Do not forget to kill the preview background task is some cases. [GB.FORM] * NEW: FileView: EPub preview generator is more clever. * BUG: FileView: Do not forget to kill the preview background task is some cases. * BUG: FileView: Fix the refresh logic. --- comp/src/gb.form/.src/File/CTaskPreview.class | 32 +++++-- comp/src/gb.form/.src/File/FileView.class | 86 +++++++++---------- 2 files changed, 65 insertions(+), 53 deletions(-) diff --git a/comp/src/gb.form/.src/File/CTaskPreview.class b/comp/src/gb.form/.src/File/CTaskPreview.class index 3d970194a..3d011a742 100644 --- a/comp/src/gb.form/.src/File/CTaskPreview.class +++ b/comp/src/gb.form/.src/File/CTaskPreview.class @@ -102,7 +102,7 @@ Private Sub PrintIcon(hImage As Image, sThumb As String, Optional bVideo As Bool Dim iSizeBinding As Integer If nPage < 0 Then - iSizeBinding = 4 + iSizeBinding = $iSize \ 16 Else If nPage > 1 Then iSizeBinding = Min(Min($iSize / 8, Max(1, nPage / 512 * $iSize)), (nPage - 1)) Endif @@ -319,24 +319,40 @@ Private Sub PrintEPub(sPath As String, sThumb As String) As Rect Dim sData As String Dim hImage As Image Dim sCover As String - Dim sDir As String Dim iPos As Integer Dim iPos2 As Integer + Dim sContent As String If Not $sUnzip Then Return - For Each sDir In ["", "OEBPS", "Ops"] - Exec [$sUnzip, "-p", "-C", sPath, sDir &/ "content.opf"] To sData - Try sCover = Scan(sData, "*", iPos) + If iPos2 = 0 Then Return + Try sCover = Scan(Mid$(sData, iPos, iPos2 - iPos), "*id=\"*\"*")[1] + If Not sCover Then Return + + Endif If sCover Then iPos = InStr(sData, "id=\"" & sCover & "\"") If iPos Then iPos2 = InStr(sData, "/>", iPos) iPos = RInStr(sData, " GetIconSize() Then - $bRefreshIcon = True - RefreshView + RefreshViewLater(True) Endif Endif