From ca7d4e2fe5a5ae4df2c6b07e6dedf5640d5b8650 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Thu, 19 Sep 2019 20:23:48 +0200 Subject: [PATCH] prefetch to cache --- changelog-fr.md | 1 + changelog.md | 1 + .../nikiroo/fanfix/bundles/StringIdGui.java | 2 + .../fanfix/bundles/resources_core.properties | 41 ++++++------ .../bundles/resources_core_fr.properties | 41 ++++++------ .../fanfix/bundles/resources_gui.properties | 44 +++++++------ .../bundles/resources_gui_fr.properties | 42 +++++++----- .../nikiroo/fanfix/reader/ui/GuiReader.java | 20 +++++- .../fanfix/reader/ui/GuiReaderBook.java | 2 + .../fanfix/reader/ui/GuiReaderBookInfo.java | 9 +++ .../fanfix/reader/ui/GuiReaderFrame.java | 25 +++++++ .../fanfix/reader/ui/GuiReaderMainPanel.java | 66 +++++++++++++++++++ 12 files changed, 215 insertions(+), 79 deletions(-) diff --git a/changelog-fr.md b/changelog-fr.md index 98ac1870..d242cab2 100644 --- a/changelog-fr.md +++ b/changelog-fr.md @@ -12,6 +12,7 @@ - gui: fix pour la couleur d'arrière plan - gui: fix pour la navigation au clavier (haut et bas) - gui: configuration beaucoup plus facile +- gui: peut maintenant télécharger toutes les histoires d'un groupe en cache en une fois - MangaLEL: site web changé - search: supporte MangaLEL - search: supporte Fanfiction.net diff --git a/changelog.md b/changelog.md index 7d4e9a9d..5173c25c 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ - gui: bg colour fix - gui: fix keyboard navigation support (up and down) - gui: configuration is now much easier +- gui: can now prefetch to cache all the sories of a group at once - MangaLEL: website has changed - search: Fanfiction.net support - search: MangaLEL support diff --git a/src/be/nikiroo/fanfix/bundles/StringIdGui.java b/src/be/nikiroo/fanfix/bundles/StringIdGui.java index 6bb774c1..2c9d222a 100644 --- a/src/be/nikiroo/fanfix/bundles/StringIdGui.java +++ b/src/be/nikiroo/fanfix/bundles/StringIdGui.java @@ -109,6 +109,8 @@ public enum StringIdGui { MENU_FILE_OPEN, // @Meta(def = "Edit", format = Format.STRING, description = "the edit menu") MENU_EDIT, // + @Meta(def = "Download to cache", format = Format.STRING, description = "the edit/send to cache menu button, to download the story into the cache if not already done") + MENU_EDIT_DOWNLOAD_TO_CACHE, // @Meta(def = "Clear cache", format = Format.STRING, description = "the clear cache menu button, to clear the cache for a single book") MENU_EDIT_CLEAR_CACHE, // @Meta(def = "Redownload", format = Format.STRING, description = "the edit/redownload menu button, to download the latest version of the book") diff --git a/src/be/nikiroo/fanfix/bundles/resources_core.properties b/src/be/nikiroo/fanfix/bundles/resources_core.properties index 1ebc3d59..d656ed66 100644 --- a/src/be/nikiroo/fanfix/bundles/resources_core.properties +++ b/src/be/nikiroo/fanfix/bundles/resources_core.properties @@ -1,4 +1,4 @@ -# United Kingdom (en_GB) resources translation file (UTF-8) +# United Kingdom (en_GB) resources_core translation file (UTF-8) # # Note that any key can be doubled with a _NOUTF suffix # to use when the NOUTF env variable is set to 1 @@ -8,7 +8,7 @@ # help message for the syntax -# (FORMAT: STRING) %s = supported input, %s = supported output +# (FORMAT: STRING) HELP_SYNTAX = Valid options:\n\ \t--import [URL]: import into library\n\ \t--export [id] [output_type] [target]: export story to target\n\ @@ -48,52 +48,53 @@ Supported input types:\n\ \n\ Supported output types:\n\ %s -# syntax error message (FORMAT: STRING) +# syntax error message +# (FORMAT: STRING) ERR_SYNTAX = Syntax error (try "--help") # an input or output support type description -# (FORMAT: STRING) %s = support name, %s = support desc +# (FORMAT: STRING) ERR_SYNTAX_TYPE = > %s: %s # Error when retrieving data -# (FORMAT: STRING) %s = input string +# (FORMAT: STRING) ERR_LOADING = Error when retrieving data from: %s # Error when saving to given target -# (FORMAT: STRING) %s = save target +# (FORMAT: STRING) ERR_SAVING = Error when saving to target: %s # Error when unknown output format -# (FORMAT: STRING) %s = bad output format +# (FORMAT: STRING) ERR_BAD_OUTPUT_TYPE = Unknown output type: %s # Error when converting input to URL/File -# (FORMAT: STRING) %s = input string +# (FORMAT: STRING) ERR_BAD_URL = Cannot understand file or protocol: %s # URL/File not supported -# (FORMAT: STRING) %s = input url +# (FORMAT: STRING) ERR_NOT_SUPPORTED = URL not supported: %s # Failed to download cover : %s -# (FORMAT: STRING) %s = cover URL +# (FORMAT: STRING) ERR_BS_NO_COVER = Failed to download cover: %s # Canonical OPEN SINGLE QUOTE char (for instance: ‘) -# (FORMAT: STRING) single char +# (FORMAT: STRING) OPEN_SINGLE_QUOTE = ‘ # Canonical CLOSE SINGLE QUOTE char (for instance: ’) -# (FORMAT: STRING) single char +# (FORMAT: STRING) CLOSE_SINGLE_QUOTE = ’ # Canonical OPEN DOUBLE QUOTE char (for instance: “) -# (FORMAT: STRING) single char +# (FORMAT: STRING) OPEN_DOUBLE_QUOTE = “ # Canonical CLOSE DOUBLE QUOTE char (for instance: ”) -# (FORMAT: STRING) single char +# (FORMAT: STRING) CLOSE_DOUBLE_QUOTE = ” # Name of the description fake chapter # (FORMAT: STRING) DESCRIPTION = Description # Name of a chapter with a name -# (FORMAT: STRING) %d = number, %s = name +# (FORMAT: STRING) CHAPTER_NAMED = Chapter %d: %s # Name of a chapter without name -# (FORMAT: STRING) %d = number, %s = name +# (FORMAT: STRING) CHAPTER_UNNAMED = Chapter %d # Default description when the type is not known by i18n -# (FORMAT: STRING) %s = type +# (FORMAT: STRING) INPUT_DESC = Unknown type: %s # Description of this input type # (FORMAT: STRING) @@ -142,7 +143,7 @@ INPUT_DESC_CBZ = CBZ files coming from this very program # (FORMAT: STRING) INPUT_DESC_HTML = HTML files coming from this very program # Default description when the type is not known by i18n -# (FORMAT: STRING) %s = type +# (FORMAT: STRING) OUTPUT_DESC = Unknown type: %s # Description of this output type # (FORMAT: STRING) @@ -177,7 +178,7 @@ OUTPUT_DESC_LATEX = A LaTeX file using the "book" template # (FORMAT: STRING) OUTPUT_DESC_SYSOUT = A simple DEBUG console output # Default description when the type is not known by i18n -#This item is used as a group, its content is not expected to be used. +# This item is used as a group, its content is not expected to be used. OUTPUT_DESC_SHORT = %s # Short description of this output type # (FORMAT: STRING) @@ -201,7 +202,7 @@ OUTPUT_DESC_SHORT_SYSOUT = Console output # (FORMAT: STRING) OUTPUT_DESC_SHORT_HTML = HTML files with resources (directory, .html) # Error message for unknown 2-letter LaTeX language code -# (FORMAT: STRING) %s = the unknown 2-code language +# (FORMAT: STRING) LATEX_LANG_UNKNOWN = Unknown language: %s # 'by' prefix before author name used to output the author, make sure it is covered by Config.BYS for input detection # (FORMAT: STRING) diff --git a/src/be/nikiroo/fanfix/bundles/resources_core_fr.properties b/src/be/nikiroo/fanfix/bundles/resources_core_fr.properties index e64651b3..9bf36263 100644 --- a/src/be/nikiroo/fanfix/bundles/resources_core_fr.properties +++ b/src/be/nikiroo/fanfix/bundles/resources_core_fr.properties @@ -1,4 +1,4 @@ -# français (fr) resources translation file (UTF-8) +# français (fr) resources_core translation file (UTF-8) # # Note that any key can be doubled with a _NOUTF suffix # to use when the NOUTF env variable is set to 1 @@ -8,7 +8,7 @@ # help message for the syntax -# (FORMAT: STRING) %s = supported input, %s = supported output +# (FORMAT: STRING) HELP_SYNTAX = Options reconnues :\n\ \t--import [URL]: importer une histoire dans la librairie\n\ \t--export [id] [output_type] [target]: exporter l'histoire "id" vers le fichier donné\n\ @@ -39,52 +39,53 @@ Types supportés en entrée :\n\ \n\ Types supportés en sortie :\n\ %s -# syntax error message (FORMAT: STRING) +# syntax error message +# (FORMAT: STRING) ERR_SYNTAX = Erreur de syntaxe (essayez "--help") # an input or output support type description -# (FORMAT: STRING) %s = support name, %s = support desc +# (FORMAT: STRING) ERR_SYNTAX_TYPE = > %s : %s # Error when retrieving data -# (FORMAT: STRING) %s = input string +# (FORMAT: STRING) ERR_LOADING = Erreur de récupération des données depuis : %s # Error when saving to given target -# (FORMAT: STRING) %s = save target +# (FORMAT: STRING) ERR_SAVING = Erreur lors de la sauvegarde sur : %s # Error when unknown output format -# (FORMAT: STRING) %s = bad output format +# (FORMAT: STRING) ERR_BAD_OUTPUT_TYPE = Type de sortie inconnu : %s # Error when converting input to URL/File -# (FORMAT: STRING) %s = input string +# (FORMAT: STRING) ERR_BAD_URL = Protocole ou type de fichier inconnu : %s # URL/File not supported -# (FORMAT: STRING) %s = input url +# (FORMAT: STRING) ERR_NOT_SUPPORTED = Site web non supporté : %s # Failed to download cover : %s -# (FORMAT: STRING) %s = cover URL +# (FORMAT: STRING) ERR_BS_NO_COVER = Échec de la récupération de la page de couverture : %s # Canonical OPEN SINGLE QUOTE char (for instance: ‘) -# (FORMAT: STRING) single char +# (FORMAT: STRING) OPEN_SINGLE_QUOTE = ‘ # Canonical CLOSE SINGLE QUOTE char (for instance: ’) -# (FORMAT: STRING) single char +# (FORMAT: STRING) CLOSE_SINGLE_QUOTE = ’ # Canonical OPEN DOUBLE QUOTE char (for instance: “) -# (FORMAT: STRING) single char +# (FORMAT: STRING) OPEN_DOUBLE_QUOTE = “ # Canonical CLOSE DOUBLE QUOTE char (for instance: ”) -# (FORMAT: STRING) single char +# (FORMAT: STRING) CLOSE_DOUBLE_QUOTE = ” # Name of the description fake chapter # (FORMAT: STRING) DESCRIPTION = Description # Name of a chapter with a name -# (FORMAT: STRING) %d = number, %s = name +# (FORMAT: STRING) CHAPTER_NAMED = Chapitre %d : %s # Name of a chapter without name -# (FORMAT: STRING) %d = number, %s = name +# (FORMAT: STRING) CHAPTER_UNNAMED = Chapitre %d # Default description when the type is not known by i18n -# (FORMAT: STRING) %s = type +# (FORMAT: STRING) INPUT_DESC = Type d'entrée inconnu : %s # Description of this input type # (FORMAT: STRING) @@ -125,7 +126,7 @@ INPUT_DESC_CBZ = Les fichiers .cbz (une collection d'images zipées), de préfé # (FORMAT: STRING) INPUT_DESC_HTML = Les fichiers HTML que vous pouvez ouvrir avec n'importe quel navigateur ; remarquez que Fanfix créera un répertoire pour y mettre les fichiers nécessaires, dont un fichier "index.html" pour afficher le tout -- nous ne supportons en entrée que les fichiers HTML créés par Fanfix # Default description when the type is not known by i18n -# (FORMAT: STRING) %s = type +# (FORMAT: STRING) OUTPUT_DESC = Type de sortie inconnu : %s # Description of this output type # (FORMAT: STRING) @@ -160,7 +161,7 @@ OUTPUT_DESC_LATEX = A LaTeX file using the "book" template # (FORMAT: STRING) OUTPUT_DESC_SYSOUT = A simple DEBUG console output # Default description when the type is not known by i18n -#This item is used as a group, its content is not expected to be used. +# This item is used as a group, its content is not expected to be used. OUTPUT_DESC_SHORT = %s # Short description of this output type # (FORMAT: STRING) @@ -184,7 +185,7 @@ OUTPUT_DESC_SHORT_SYSOUT = Console output # (FORMAT: STRING) OUTPUT_DESC_SHORT_HTML = HTML files with resources (directory, .html) # Error message for unknown 2-letter LaTeX language code -# (FORMAT: STRING) %s = the unknown 2-code language +# (FORMAT: STRING) LATEX_LANG_UNKNOWN = Unknown language: %s # 'by' prefix before author name used to output the author, make sure it is covered by Config.BYS for input detection # (FORMAT: STRING) diff --git a/src/be/nikiroo/fanfix/bundles/resources_gui.properties b/src/be/nikiroo/fanfix/bundles/resources_gui.properties index de44c18c..6d46af41 100644 --- a/src/be/nikiroo/fanfix/bundles/resources_gui.properties +++ b/src/be/nikiroo/fanfix/bundles/resources_gui.properties @@ -1,4 +1,4 @@ -# United States (en_US) resources_gui translation file (UTF-8) +# United Kingdom (en_GB) resources_gui translation file (UTF-8) # # Note that any key can be doubled with a _NOUTF suffix # to use when the NOUTF env variable is set to 1 @@ -8,10 +8,10 @@ # the title of the main window of Fanfix, the library -# (FORMAT: STRING) %s = current Fanfix version +# (FORMAT: STRING) TITLE_LIBRARY = Fanfix %s # the title of the main window of Fanfix, the library, when the library has a name (i.e., is not local) -# (FORMAT: STRING) %s = current Fanfix version, %s = library name +# (FORMAT: STRING) TITLE_LIBRARY_WITH_NAME = Fanfix %s # the title of the configuration window of Fanfix, also the name of the menu button # (FORMAT: STRING) @@ -38,7 +38,7 @@ SUBTITLE_MOVE_TO = Move to: # (FORMAT: STRING) TITLE_DELETE = Delete story # the subtitle of the 'delete' window of Fanfix -# (FORMAT: STRING) %s = LUID of the story, %s = title of the story +# (FORMAT: STRING) SUBTITLE_DELETE = Delete %s: %s # the title of the 'library error' dialogue # (FORMAT: STRING) @@ -53,27 +53,28 @@ SUBTITLE_IMPORT_URL = URL of the story to import: # (FORMAT: STRING) TITLE_ERROR = Error # the title of a story for the properties dialogue, the viewers... -# (FORMAT: STRING) %s = LUID of the story, %s = title of the story +# (FORMAT: STRING) TITLE_STORY = %s: %s # HTML text used to notify of a new version -# (FORMAT: STRING) %s = url link in HTML +# (FORMAT: STRING) NEW_VERSION_AVAILABLE = A new version of the program is available at %s # text used as title for the update dialogue # (FORMAT: STRING) NEW_VERSION_TITLE = Updates available # HTML text used to specify a newer version title and number, used for each version newer than the current one -# (FORMAT: STRING) %s = the newer version number +# (FORMAT: STRING) NEW_VERSION_VERSION = Version %s # show the number of words of a book -# (FORMAT: STRING) %s = the number +# (FORMAT: STRING) BOOK_COUNT_WORDS = %s words # show the number of images of a book -# (FORMAT: STRING) %s = the number +# (FORMAT: STRING) BOOK_COUNT_IMAGES = %s images # show the number of stories of a meta-book (a book representing allthe types/sources or all the authors present) -# (FORMAT: STRING) %s = the number +# (FORMAT: STRING) BOOK_COUNT_STORIES = %s stories -# the file menu (FORMAT: STRING) +# the file menu +# (FORMAT: STRING) MENU_FILE = File # the file/exit menu button # (FORMAT: STRING) @@ -108,8 +109,12 @@ MENU_FILE_PROPERTIES = Properties # the file/open menu item, that will open the story or fake-story (an author or a source/type) # (FORMAT: STRING) MENU_FILE_OPEN = Open -# the edit menu (FORMAT: STRING) +# the edit menu +# (FORMAT: STRING) MENU_EDIT = Edit +# the edit/send to cache menu button, to download the story into the cache if not already done +# (FORMAT: STRING) +MENU_EDIT_DOWNLOAD_TO_CACHE = Download to cache # the clear cache menu button, to clear the cache for a single book # (FORMAT: STRING) MENU_EDIT_CLEAR_CACHE = Clear cache @@ -128,7 +133,8 @@ MENU_EDIT_SET_COVER_FOR_AUTHOR = Set as cover for author # the search menu to open the earch stories on one of the searchable websites # (FORMAT: STRING) MENU_SEARCH = Search -# the view menu (FORMAT: STRING) +# the view menu +# (FORMAT: STRING) MENU_VIEW = View # the view/word_count menu button, to show the word/image/story count as secondary info # (FORMAT: STRING) @@ -158,7 +164,7 @@ MENU_AUTHORS_UNKNOWN = [unknown] # (FORMAT: STRING) PROGRESS_OUT_OF_UI_RELOAD_BOOKS = Reload books # progress bar caption for the 'change source' step of the ReDownload operation -# (FORMAT: STRING) %s = new source name +# (FORMAT: STRING) PROGRESS_CHANGE_SOURCE = Change the source of the book to %s # default description if the error is not known # (FORMAT: STRING) @@ -176,18 +182,18 @@ ERROR_LIB_STATUS_UNAVAILABLE = Library currently unavailable # (FORMAT: STRING) ERROR_CANNOT_OPEN = Cannot open the selected book # URL is not supported by Fanfix -# (FORMAT: STRING) %s = URL +# (FORMAT: STRING) ERROR_URL_NOT_SUPPORTED = URL not supported: %s # cannot import the URL -# (FORMAT: STRING) %s = URL, %s = reasons +# (FORMAT: STRING) ERROR_URL_IMPORT_FAILED = Failed to import %s:\n\ %s # (html) the chapter progression value used on the viewers -# (FORMAT: STRING) %d = chapter number, %d = total chapters +# (FORMAT: STRING) CHAPTER_HTML_UNNAMED =   Chapter %d/%d # (html) the chapter progression value used on the viewers -# (FORMAT: STRING) %d = chapter number, %d = total chapters, %s = chapter name +# (FORMAT: STRING) CHAPTER_HTML_NAMED =   Chapter %d/%d: %s # (NO html) the chapter progression value used on the viewers -# (FORMAT: STRING) %d = current image number, %d = total images +# (FORMAT: STRING) IMAGE_PROGRESSION = Image %d / %d diff --git a/src/be/nikiroo/fanfix/bundles/resources_gui_fr.properties b/src/be/nikiroo/fanfix/bundles/resources_gui_fr.properties index 2b6d1920..ee7c8871 100644 --- a/src/be/nikiroo/fanfix/bundles/resources_gui_fr.properties +++ b/src/be/nikiroo/fanfix/bundles/resources_gui_fr.properties @@ -8,10 +8,10 @@ # the title of the main window of Fanfix, the library -# (FORMAT: STRING) %s = current Fanfix version +# (FORMAT: STRING) TITLE_LIBRARY = Fanfix %s # the title of the main window of Fanfix, the library, when the library has a name (i.e., is not local) -# (FORMAT: STRING) %s = current Fanfix version, %s = library name +# (FORMAT: STRING) TITLE_LIBRARY_WITH_NAME = Fanfix %s # the title of the configuration window of Fanfix, also the name of the menu button # (FORMAT: STRING) @@ -38,7 +38,7 @@ SUBTITLE_MOVE_TO = Déplacer vers : # (FORMAT: STRING) TITLE_DELETE = Supprimer le livre # the subtitle of the 'delete' window of Fanfix -# (FORMAT: STRING) %s = LUID of the story, %s = title of the story +# (FORMAT: STRING) SUBTITLE_DELETE = Supprimer %s : %s # the title of the 'library error' dialogue # (FORMAT: STRING) @@ -53,27 +53,28 @@ SUBTITLE_IMPORT_URL = L'URL du livre à importer # (FORMAT: STRING) TITLE_ERROR = Error # the title of a story for the properties dialogue, the viewers... -# (FORMAT: STRING) %s = LUID of the story, %s = title of the story +# (FORMAT: STRING) TITLE_STORY = %s: %s # HTML text used to notify of a new version -# (FORMAT: STRING) %s = url link in HTML +# (FORMAT: STRING) NEW_VERSION_AVAILABLE = Une nouvelle version du programme est disponible sur %s # text used as title for the update dialogue # (FORMAT: STRING) NEW_VERSION_TITLE = Mise-à-jour disponible # HTML text used to specify a newer version title and number, used for each version newer than the current one -# (FORMAT: STRING) %s = the newer version number +# (FORMAT: STRING) NEW_VERSION_VERSION = Version %s # show the number of words of a book -# (FORMAT: STRING) %s = the number +# (FORMAT: STRING) BOOK_COUNT_WORDS = %s mots # show the number of images of a book -# (FORMAT: STRING) %s = the number +# (FORMAT: STRING) BOOK_COUNT_IMAGES = %s images # show the number of stories of a meta-book (a book representing allthe types/sources or all the authors present) -# (FORMAT: STRING) %s = the number +# (FORMAT: STRING) BOOK_COUNT_STORIES = %s livres -# the file menu (FORMAT: STRING) +# the file menu +# (FORMAT: STRING) MENU_FILE = Fichier # the file/exit menu button # (FORMAT: STRING) @@ -108,8 +109,12 @@ MENU_FILE_PROPERTIES = Propriétés # the file/open menu item, that will open the story or fake-story (an author or a source/type) # (FORMAT: STRING) MENU_FILE_OPEN = Ouvrir -# the edit menu (FORMAT: STRING) +# the edit menu +# (FORMAT: STRING) MENU_EDIT = Edition +# the edit/send to cache menu button, to download the story into the cache if not already done +# (FORMAT: STRING) +MENU_EDIT_DOWNLOAD_TO_CACHE = Charger en cache # the clear cache menu button, to clear the cache for a single book # (FORMAT: STRING) MENU_EDIT_CLEAR_CACHE = Nettoyer le cache @@ -128,7 +133,8 @@ MENU_EDIT_SET_COVER_FOR_AUTHOR = Utiliser comme cover pour l'auteur # the search menu to open the earch stories on one of the searchable websites # (FORMAT: STRING) MENU_SEARCH = Recherche -# the view menu (FORMAT: STRING) +# the view menu +# (FORMAT: STRING) MENU_VIEW = Affichage # the view/word_count menu button, to show the word/image/story count as secondary info # (FORMAT: STRING) @@ -158,7 +164,7 @@ MENU_AUTHORS_UNKNOWN = [inconnu] # (FORMAT: STRING) PROGRESS_OUT_OF_UI_RELOAD_BOOKS = Recharger les livres # progress bar caption for the 'change source' step of the ReDownload operation -# (FORMAT: STRING) %s = new source name +# (FORMAT: STRING) PROGRESS_CHANGE_SOURCE = Change la source du livre en %s # default description if the error is not known # (FORMAT: STRING) @@ -176,18 +182,18 @@ ERROR_LIB_STATUS_UNAVAILABLE = Librairie indisponible # (FORMAT: STRING) ERROR_CANNOT_OPEN = Impossible d'ouvrir le livre sélectionné # URL is not supported by Fanfix -# (FORMAT: STRING) %s = URL +# (FORMAT: STRING) ERROR_URL_NOT_SUPPORTED = URL non supportée : %s # cannot import the URL -# (FORMAT: STRING) %s = URL, %s = reasons +# (FORMAT: STRING) ERROR_URL_IMPORT_FAILED = Erreur lors de l'import de %s:\n\ %s # (html) the chapter progression value used on the viewers -# (FORMAT: STRING) %d = chapter number, %d = total chapters +# (FORMAT: STRING) CHAPTER_HTML_UNNAMED =   Chapitre %d / %d # (html) the chapter progression value used on the viewers -# (FORMAT: STRING) %d = chapter number, %d = total chapters, %s = chapter name +# (FORMAT: STRING) CHAPTER_HTML_NAMED =   Chapitre %d / %d: %s # (NO html) the chapter progression value used on the viewers -# (FORMAT: STRING) %d = current image number, %d = total images +# (FORMAT: STRING) IMAGE_PROGRESSION = Image %d / %d diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReader.java b/src/be/nikiroo/fanfix/reader/ui/GuiReader.java index b720af40..0205e114 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReader.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReader.java @@ -317,8 +317,6 @@ class GuiReader extends BasicReader { /** * "Open" the given {@link Story}. It usually involves starting an external * program adapted to the given file type. - *

- * Asynchronous method. * * @param luid * the luid of the {@link Story} to open @@ -362,6 +360,24 @@ class GuiReader extends BasicReader { } } + + /** + * "Prefetch" the given {@link Story}. + *

+ * Synchronous method. + * + * @param luid + * the luid of the {@link Story} to prefetch + * @param pg + * the optional progress (we may need to prepare the + * {@link Story} for reading + * + * @throws IOException + * in case of I/O errors + */ + void prefetch(String luid, Progress pg) throws IOException { + cacheLib.getFile(luid, pg); + } /** * Change the source of the given {@link Story} (the source is the main * information used to group the stories together). diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderBook.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderBook.java index 47b46236..73ccdaa0 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderBook.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderBook.java @@ -18,6 +18,8 @@ import be.nikiroo.fanfix.reader.Reader; /** * A book item presented in a {@link GuiReaderFrame}. + *

+ * Can be a story, or a comic or... a group. * * @author niki */ diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderBookInfo.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderBookInfo.java index f071be02..c163834f 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderBookInfo.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderBookInfo.java @@ -53,6 +53,15 @@ public class GuiReaderBookInfo { this.id = id; this.value = value; } + + /** + * The type of {@link GuiReaderBookInfo}. + * + * @return the type + */ + public Type getType() { + return type; + } /** * Get the main info to display for this book (a title, an author, a diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderFrame.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderFrame.java index fe11c810..0b9fe3cf 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderFrame.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderFrame.java @@ -103,6 +103,7 @@ class GuiReaderFrame extends JFrame implements FrameHelper { popup.add(createMenuItemSetCoverForSource()); popup.add(createMenuItemSetCoverForAuthor()); } + popup.add(createMenuItemDownloadToCache()); popup.add(createMenuItemClearCache()); if (status.isWritable()) { popup.add(createMenuItemRedownload()); @@ -184,6 +185,7 @@ class GuiReaderFrame extends JFrame implements FrameHelper { edit.add(createMenuItemSetCoverForSource()); edit.add(createMenuItemSetCoverForAuthor()); + edit.add(createMenuItemDownloadToCache()); edit.add(createMenuItemClearCache()); edit.add(createMenuItemRedownload()); edit.addSeparator(); @@ -771,6 +773,29 @@ class GuiReaderFrame extends JFrame implements FrameHelper { return refresh; } + + /** + * Create the download to cache menu item. + * + * @return the item + */ + private JMenuItem createMenuItemDownloadToCache() { + JMenuItem refresh = new JMenuItem( + GuiReader.trans(StringIdGui.MENU_EDIT_DOWNLOAD_TO_CACHE), + KeyEvent.VK_T); + refresh.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + final GuiReaderBook selectedBook = mainPanel.getSelectedBook(); + if (selectedBook != null) { + mainPanel.prefetchBook(selectedBook); + } + } + }); + + return refresh; + } + /** * Create the delete menu item. diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderMainPanel.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderMainPanel.java index bae27427..476e130b 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderMainPanel.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderMainPanel.java @@ -17,6 +17,7 @@ import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.net.UnknownHostException; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -42,6 +43,7 @@ import be.nikiroo.fanfix.library.BasicLibrary.Status; import be.nikiroo.fanfix.library.LocalLibrary; import be.nikiroo.fanfix.reader.BasicReader; import be.nikiroo.fanfix.reader.ui.GuiReaderBook.BookActionListener; +import be.nikiroo.fanfix.reader.ui.GuiReaderBookInfo.Type; import be.nikiroo.utils.Progress; import be.nikiroo.utils.ui.ProgressBar; @@ -414,6 +416,70 @@ class GuiReaderMainPanel extends JPanel { } }); } + + /** + * Prefetch a {@link GuiReaderBook} item (which can be a group, in which + * case we prefetch all its members). + * + * @param book + * the {@link GuiReaderBook} to open + */ + public void prefetchBook(final GuiReaderBook book) { + final List luids = new LinkedList(); + try { + switch (book.getInfo().getType()) { + case STORY: + luids.add(book.getInfo().getMeta().getLuid()); + break; + case SOURCE: + for (MetaData meta : helper.getReader().getLibrary() + .getListBySource(book.getInfo().getMainInfo())) { + luids.add(meta.getLuid()); + } + break; + case AUTHOR: + for (MetaData meta : helper.getReader().getLibrary() + .getListByAuthor(book.getInfo().getMainInfo())) { + luids.add(meta.getLuid()); + } + break; + } + } catch (IOException e) { + Instance.getTraceHandler().error(e); + } + + final Progress pg = new Progress(); + pg.setMax(luids.size()); + + outOfUi(pg, false, new Runnable() { + @Override + public void run() { + try { + for (String luid : luids) { + Progress pgStep = new Progress(); + pg.addProgress(pgStep, 1); + + helper.getReader().prefetch(luid, pgStep); + } + + // TODO: also set the green button on sources/authors? + // requires to do the same when all stories inside are green + if (book.getInfo().getType() == Type.STORY) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + book.setCached(true); + } + }); + } + } catch (IOException e) { + Instance.getTraceHandler().error(e); + error(GuiReader.trans(StringIdGui.ERROR_CANNOT_OPEN), + GuiReader.trans(StringIdGui.TITLE_ERROR), e); + } + } + }); + } /** * Process the given action out of the Swing UI thread and link the given -- 2.27.0