show wordcount option
authorNiki Roo <niki@nikiroo.be>
Fri, 1 May 2020 21:25:05 +0000 (23:25 +0200)
committerNiki Roo <niki@nikiroo.be>
Fri, 1 May 2020 21:25:05 +0000 (23:25 +0200)
src/be/nikiroo/fanfix/bundles/UiConfig.java
src/be/nikiroo/fanfix_swing/gui/BooksPanel.java
src/be/nikiroo/fanfix_swing/gui/MainFrame.java

index 37d4f0b7d53c7d542783e7d00737c5c1b0975f96..11b3a871c572fd558ae4c66c61598062ea24930c 100644 (file)
@@ -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
        //
index a2e140c2e6ad477747514fd0f1e0989812c5b45a..93eb361c6f6c078bc0f067fe8056f4762bbb55b9 100644 (file)
@@ -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);
index 7dd0760eff39f4e7188c8e4279bbd11e264694d8..3dc4d80c17738c1f16f44858b586fc221c852384 100644 (file)
@@ -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);
 
                //