Merge branch 'master' of github.com:nikiroo/fanfix
authorNiki Roo <niki@nikiroo.be>
Thu, 19 Sep 2019 19:28:22 +0000 (21:28 +0200)
committerNiki Roo <niki@nikiroo.be>
Thu, 19 Sep 2019 19:28:22 +0000 (21:28 +0200)
1  2 
src/be/nikiroo/fanfix/reader/ui/GuiReaderFrame.java

index c0e8ec6fc430444788f26f03263d696e580d7744,0b9fe3cf1f599d4840194aeac13983615499af33..f3748218fcbbcd1b25b70816454cd0d56d2870ac
@@@ -36,7 -36,7 +36,7 @@@ import be.nikiroo.fanfix.library.LocalL
  import be.nikiroo.fanfix.output.BasicOutput.OutputType;
  import be.nikiroo.fanfix.reader.BasicReader;
  import be.nikiroo.fanfix.reader.ui.GuiReaderMainPanel.FrameHelper;
- import be.nikiroo.fanfix.reader.ui.GuiReaderMainPanel.StoryRunnable;
+ import be.nikiroo.fanfix.reader.ui.GuiReaderMainPanel.MetaDataRunnable;
  import be.nikiroo.fanfix.searchable.BasicSearchable;
  import be.nikiroo.fanfix.supported.SupportType;
  import be.nikiroo.utils.Progress;
@@@ -103,6 -103,7 +103,7 @@@ class GuiReaderFrame extends JFrame imp
                        popup.add(createMenuItemSetCoverForSource());
                        popup.add(createMenuItemSetCoverForAuthor());
                }
+               popup.add(createMenuItemDownloadToCache());
                popup.add(createMenuItemClearCache());
                if (status.isWritable()) {
                        popup.add(createMenuItemRedownload());
  
                edit.add(createMenuItemSetCoverForSource());
                edit.add(createMenuItemSetCoverForAuthor());
+               edit.add(createMenuItemDownloadToCache());
                edit.add(createMenuItemClearCache());
                edit.add(createMenuItemRedownload());
                edit.addSeparator();
                                                                .trans(StringIdGui.SUBTITLE_CONFIG));
                                JFrame frame = new JFrame(title);
                                frame.add(ed);
 -                              frame.setSize(800, 600);
 +                              frame.setSize(850, 600);
                                frame.setVisible(true);
                        }
                });
                                final GuiReaderBook selectedBook = mainPanel.getSelectedBook();
                                if (selectedBook != null) {
                                        final MetaData meta = selectedBook.getInfo().getMeta();
-                                       mainPanel.imprt(meta.getUrl(), new StoryRunnable() {
+                                       mainPanel.imprt(meta.getUrl(), new MetaDataRunnable() {
                                                @Override
-                                               public void run(Story story) {
-                                                       MetaData newMeta = story.getMeta();
+                                               public void run(MetaData newMeta) {
                                                        if (!newMeta.getSource().equals(meta.getSource())) {
                                                                reader.changeSource(newMeta.getLuid(),
                                                                                meta.getSource());
  
                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.