From 722a4b3a1829e3a443b8e3f5b976e142d18d2c3f Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Fri, 1 May 2020 23:25:05 +0200 Subject: [PATCH] show wordcount option --- src/be/nikiroo/fanfix/bundles/UiConfig.java | 3 + .../nikiroo/fanfix_swing/gui/BooksPanel.java | 5 +- .../nikiroo/fanfix_swing/gui/MainFrame.java | 55 +++++++++++++------ 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/src/be/nikiroo/fanfix/bundles/UiConfig.java b/src/be/nikiroo/fanfix/bundles/UiConfig.java index 37d4f0b7..11b3a871 100644 --- a/src/be/nikiroo/fanfix/bundles/UiConfig.java +++ b/src/be/nikiroo/fanfix/bundles/UiConfig.java @@ -43,6 +43,9 @@ public enum UiConfig { @Meta(description = "Show thumbnails by default in the books view",// format = Format.BOOLEAN, def = "false") SHOW_THUMBNAILS, // + @Meta(description = "Show a words/images count instead of the author by default in the books view",// + format = Format.BOOLEAN, def = "false") + SHOW_WORDCOUNT, // // // Deprecated // diff --git a/src/be/nikiroo/fanfix_swing/gui/BooksPanel.java b/src/be/nikiroo/fanfix_swing/gui/BooksPanel.java index a2e140c2..93eb361c 100644 --- a/src/be/nikiroo/fanfix_swing/gui/BooksPanel.java +++ b/src/be/nikiroo/fanfix_swing/gui/BooksPanel.java @@ -89,8 +89,9 @@ public class BooksPanel extends ListenerPanel { private ReloadData lastLoad = new ReloadData(); - public BooksPanel(boolean showThumbnails) { + public BooksPanel(boolean showThumbnails, boolean seeWordCount) { setLayout(new BorderLayout()); + this.seeWordCount = seeWordCount; final SearchBar search = new SearchBar(); add(search, BorderLayout.NORTH); @@ -230,6 +231,8 @@ public class BooksPanel extends ListenerPanel { */ public void setSeeWordCount(boolean seeWordCount) { if (this.seeWordCount != seeWordCount) { + this.seeWordCount = seeWordCount; + if (books != null) { for (BookLine book : books.values()) { book.setSeeWordCount(seeWordCount); diff --git a/src/be/nikiroo/fanfix_swing/gui/MainFrame.java b/src/be/nikiroo/fanfix_swing/gui/MainFrame.java index 7dd0760e..3dc4d80c 100644 --- a/src/be/nikiroo/fanfix_swing/gui/MainFrame.java +++ b/src/be/nikiroo/fanfix_swing/gui/MainFrame.java @@ -24,6 +24,7 @@ import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.bundles.Config; import be.nikiroo.fanfix.bundles.StringIdGui; import be.nikiroo.fanfix.bundles.UiConfig; +import be.nikiroo.fanfix.bundles.UiConfigBundle; import be.nikiroo.fanfix_swing.gui.book.BookInfo; import be.nikiroo.fanfix_swing.gui.importer.ImporterFrame; import be.nikiroo.fanfix_swing.gui.search.SearchFrame; @@ -62,9 +63,12 @@ public class MainFrame extends JFrame { } }); + UiConfigBundle bundle = Instance.getInstance().getUiConfig(); + browser = new BrowserPanel(); - books = new BooksPanel(Instance.getInstance().getUiConfig() - .getBoolean(UiConfig.SHOW_THUMBNAILS, false)); + books = new BooksPanel( + bundle.getBoolean(UiConfig.SHOW_THUMBNAILS, false), + bundle.getBoolean(UiConfig.SHOW_WORDCOUNT, false)); details = new DetailsPanel(); goBack = new BreadCrumbsPanel(); @@ -241,20 +245,6 @@ public class MainFrame extends JFrame { JMenu view = new JMenu("View"); view.setMnemonic(KeyEvent.VK_V); - final JMenuItem mnuListMode = new JCheckBoxMenuItem("Show thumbnails"); - mnuListMode.setMnemonic(KeyEvent.VK_T); - mnuListMode.setSelected(books.isShowThumbnails()); - mnuListMode.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - boolean newValue = !books.isShowThumbnails(); - books.setShowThumbnails(newValue); - mnuListMode.setSelected(newValue); - - saveConfig(UiConfig.SHOW_THUMBNAILS, newValue); - } - }); - final JMenuItem mnuSidePane = new JCheckBoxMenuItem( "Show story browser"); mnuSidePane.setMnemonic(KeyEvent.VK_B); @@ -285,9 +275,40 @@ public class MainFrame extends JFrame { } }); + final JMenuItem mnuThumbs = new JCheckBoxMenuItem("Show thumbnails"); + mnuThumbs.setMnemonic(KeyEvent.VK_T); + mnuThumbs.setSelected(books.isShowThumbnails()); + mnuThumbs.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + boolean newValue = !books.isShowThumbnails(); + books.setShowThumbnails(newValue); + mnuThumbs.setSelected(newValue); + + saveConfig(UiConfig.SHOW_THUMBNAILS, newValue); + } + }); + + final JMenuItem mnuWord = new JMenuItem( + books.isSeeWordCount() ? "Show author" : "Show word count"); + mnuWord.setMnemonic( + books.isSeeWordCount() ? KeyEvent.VK_A : KeyEvent.VK_W); + mnuWord.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + boolean newValue = !books.isSeeWordCount(); + books.setSeeWordCount(newValue); + mnuWord.setText(newValue ? "Show author" : "Show word count"); + mnuWord.setMnemonic(newValue ? KeyEvent.VK_A : KeyEvent.VK_W); + + saveConfig(UiConfig.SHOW_WORDCOUNT, newValue); + } + }); + view.add(mnuSidePane); view.add(mnuDetailsPane); - view.add(mnuListMode); + view.add(mnuThumbs); + view.add(mnuWord); // -- 2.27.0