From dd81a122f978dd0f7f74348fdab122d19fadd159 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 24 Mar 2019 18:38:07 +0100 Subject: [PATCH] add option for internal viewer, by def --- src/be/nikiroo/fanfix/bundles/UiConfig.java | 4 +++ .../fanfix/bundles/resources.properties | 5 +--- .../fanfix/bundles/resources_fr.properties | 3 --- src/be/nikiroo/fanfix/bundles/ui.properties | 6 +++++ .../fanfix/bundles/ui_description.properties | 8 +++++- .../nikiroo/fanfix/reader/ui/GuiReader.java | 25 ++++++++++++++----- 6 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/be/nikiroo/fanfix/bundles/UiConfig.java b/src/be/nikiroo/fanfix/bundles/UiConfig.java index b6be9cb..0fac116 100644 --- a/src/be/nikiroo/fanfix/bundles/UiConfig.java +++ b/src/be/nikiroo/fanfix/bundles/UiConfig.java @@ -17,8 +17,12 @@ public enum UiConfig { GUI_NON_IMAGES_DOCUMENT_TYPE, // @Meta(format = Format.COMBO_LIST, list = { "CBZ", "HTML" }, description = "The type of output for the GUI Reader for images documents") GUI_IMAGES_DOCUMENT_TYPE, // + @Meta(format = Format.BOOLEAN, description = "Use the internal reader for images documents -- this is TRUE by default") + IMAGES_DOCUMENT_USE_INTERNAL_READER, // @Meta(info = "A command to start", description = "The command launched for images documents -- default to the system default for the current file type") IMAGES_DOCUMENT_READER, // + @Meta(format = Format.BOOLEAN, description = "Use the internal reader for non images documents -- this is TRUE by default") + NON_IMAGES_DOCUMENT_USE_INTERNAL_READER, // @Meta(info = "A command to start", description = "The command launched for non images documents -- default to the system default for the current file type") NON_IMAGES_DOCUMENT_READER, // @Meta(format = Format.COLOR, description = "The background colour if you don't want the default system one") diff --git a/src/be/nikiroo/fanfix/bundles/resources.properties b/src/be/nikiroo/fanfix/bundles/resources.properties index a4b674b..62fd158 100644 --- a/src/be/nikiroo/fanfix/bundles/resources.properties +++ b/src/be/nikiroo/fanfix/bundles/resources.properties @@ -1,4 +1,4 @@ -# United States (en_US) resources translation file (UTF-8) +# United Kingdom (en_GB) resources 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 @@ -122,9 +122,6 @@ INPUT_DESC_E621 = Furry website supporting comics, including MLP INPUT_DESC_E_HENTAI = Website offering many comics/mangas, mostly but not always NSFW # Description of this input type # (FORMAT: STRING) -INPUT_DESC_MANGA_LEL = Website offering many mangas, in French -# Description of this input type -# (FORMAT: STRING) INPUT_DESC_YIFFSTAR = A Furry website, story-oriented # Description of this input type # (FORMAT: STRING) diff --git a/src/be/nikiroo/fanfix/bundles/resources_fr.properties b/src/be/nikiroo/fanfix/bundles/resources_fr.properties index 9438c75..092bd33 100644 --- a/src/be/nikiroo/fanfix/bundles/resources_fr.properties +++ b/src/be/nikiroo/fanfix/bundles/resources_fr.properties @@ -109,9 +109,6 @@ INPUT_DESC_E621 = Un site Furry proposant des comics, y compris de MLP INPUT_DESC_E_HENTAI = Un site web proposant beaucoup de comics/mangas, souvent mais pas toujours NSFW # Description of this input type # (FORMAT: STRING) -INPUT_DESC_MANGA_LEL = Un site web proposant beaucoup de mangas, en Français -# Description of this input type -# (FORMAT: STRING) INPUT_DESC_YIFFSTAR = Un site web Furry, orienté sur les histoires plutôt que les images # Description of this input type # (FORMAT: STRING) diff --git a/src/be/nikiroo/fanfix/bundles/ui.properties b/src/be/nikiroo/fanfix/bundles/ui.properties index da9fdf9..238e574 100644 --- a/src/be/nikiroo/fanfix/bundles/ui.properties +++ b/src/be/nikiroo/fanfix/bundles/ui.properties @@ -13,9 +13,15 @@ GUI_NON_IMAGES_DOCUMENT_TYPE = HTML # (FORMAT: COMBO_LIST) # ALLOWED VALUES: "CBZ" "HTML" GUI_IMAGES_DOCUMENT_TYPE = CBZ +# Use the internal reader for images documents -- this is TRUE by default +# (FORMAT: BOOLEAN) +IMAGES_DOCUMENT_USE_INTERNAL_READER = # The command launched for images documents -- default to the system default for the current file type # (FORMAT: STRING) A command to start IMAGES_DOCUMENT_READER = +# Use the internal reader for non images documents -- this is TRUE by default +# (FORMAT: BOOLEAN) +NON_IMAGES_DOCUMENT_USE_INTERNAL_READER = # The command launched for non images documents -- default to the system default for the current file type # (FORMAT: STRING) A command to start NON_IMAGES_DOCUMENT_READER = diff --git a/src/be/nikiroo/fanfix/bundles/ui_description.properties b/src/be/nikiroo/fanfix/bundles/ui_description.properties index 413dbf4..5cb2a9f 100644 --- a/src/be/nikiroo/fanfix/bundles/ui_description.properties +++ b/src/be/nikiroo/fanfix/bundles/ui_description.properties @@ -7,7 +7,7 @@ # -# The directory where to store temporary files, defaults to directory 'tmp.reader' in the conig directory (usually $HOME/.fanfix) +# The directory where to store temporary files, defaults to directory 'tmp.reader' in the config directory (usually $HOME/.fanfix) # (FORMAT: DIRECTORY) absolute path, $HOME variable supported, / is always accepted as dir separator CACHE_DIR_LOCAL_READER = The directory where to store temporary files, defaults to directory 'tmp.reader' in the config directory (usually $HOME/.fanfix) -- this is an absolute path, $HOME variable supported, / is always accepted as dir separator # The type of output for the GUI Reader for non-images documents @@ -18,9 +18,15 @@ GUI_NON_IMAGES_DOCUMENT_TYPE = # (FORMAT: COMBO_LIST) # ALLOWED VALUES: "CBZ" "HTML" GUI_IMAGES_DOCUMENT_TYPE = +# Use the internal reader for images documents -- this is TRUE by default +# (FORMAT: BOOLEAN) +IMAGES_DOCUMENT_USE_INTERNAL_READER = # The command launched for images documents -- default to the system default for the current file type # (FORMAT: STRING) A command to start IMAGES_DOCUMENT_READER = +# Use the internal reader for non images documents -- this is TRUE by default +# (FORMAT: BOOLEAN) +NON_IMAGES_DOCUMENT_USE_INTERNAL_READER = # The command launched for non images documents -- default to the system default for the current file type # (FORMAT: STRING) A command to start NON_IMAGES_DOCUMENT_READER = diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReader.java b/src/be/nikiroo/fanfix/reader/ui/GuiReader.java index f97ffdd..c6c8413 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReader.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReader.java @@ -17,6 +17,7 @@ import javax.swing.event.HyperlinkListener; import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.VersionCheck; +import be.nikiroo.fanfix.bundles.UiConfig; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Story; import be.nikiroo.fanfix.library.BasicLibrary; @@ -266,20 +267,32 @@ class GuiReader extends BasicReader { * in case of I/O errors */ void read(String luid, boolean sync, Progress pg) throws IOException { - File file = cacheLib.getFile(luid, pg); + MetaData meta = cacheLib.getInfo(luid); - GuiReaderViewer viewer = new GuiReaderViewer(cacheLib, - cacheLib.getStory(luid, null)); + boolean textInternal = Instance.getUiConfig().getBoolean( + UiConfig.NON_IMAGES_DOCUMENT_USE_INTERNAL_READER, true); + boolean imageInternal = Instance.getUiConfig().getBoolean( + UiConfig.IMAGES_DOCUMENT_USE_INTERNAL_READER, true); - // TODO: testing internal story viewer: - if (false) { + boolean useInternalViewer = true; + if (meta.isImageDocument() && !imageInternal) { + useInternalViewer = false; + } + if (!meta.isImageDocument() && !textInternal) { + useInternalViewer = false; + } + + if (useInternalViewer) { + GuiReaderViewer viewer = new GuiReaderViewer(cacheLib, + cacheLib.getStory(luid, null)); if (sync) { sync(viewer); } else { viewer.setVisible(true); } } else { - openExternal(getLibrary().getInfo(luid), file, sync); + File file = cacheLib.getFile(luid, pg); + openExternal(meta, file, sync); } } -- 2.27.0