new kiosk mode
authorNiki Roo <niki@nikiroo.be>
Wed, 6 May 2020 15:25:11 +0000 (17:25 +0200)
committerNiki Roo <niki@nikiroo.be>
Wed, 6 May 2020 15:25:11 +0000 (17:25 +0200)
src/be/nikiroo/fanfix_swing/Main.java
src/be/nikiroo/fanfix_swing/gui/MainFrame.java
src/be/nikiroo/fanfix_swing/gui/book/BookCoverImager.java
src/be/nikiroo/fanfix_swing/gui/book/BookLine.java

index 3164196aafa793ac276be7e9578c26aab442bd45..5efbc248db7dd071077935742baded74ec08460e 100644 (file)
@@ -3,6 +3,8 @@ package be.nikiroo.fanfix_swing;
 import java.awt.Desktop;
 import java.io.IOException;
 import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.concurrent.ExecutionException;
 
 import javax.swing.JEditorPane;
@@ -28,6 +30,7 @@ import be.nikiroo.utils.ui.UIUtils;
  */
 public class Main extends be.nikiroo.fanfix.Main {
        private boolean busy;
+       private boolean kiosk;
 
        /**
         * The main entry point of the application.
@@ -35,12 +38,27 @@ public class Main extends be.nikiroo.fanfix.Main {
         * It overrides some function of Fanfix's Main.
         * 
         * @param args
-        *            the arguments (none, or will be passed to Fanfix)
+        *            the arguments (none, "--kiosk" (fullceen, no decorations,
+        *            Nimbus Look &amp; Feel) or will be passed to Fanfix)
         */
        public static void main(String[] args) {
                new Main().start(args);
        }
 
+       @Override
+       public void start(String[] args) {
+               List<String> argsList = new ArrayList<String>();
+               for (String arg : args) {
+                       if ("--kiosk".equals(arg)) {
+                               kiosk = true;
+                       } else {
+                               argsList.add(arg);
+                       }
+               }
+
+               super.start(argsList.toArray(new String[0]));
+       }
+
        @Override
        protected VersionCheck checkUpdates() {
                new SwingWorker<VersionCheck, Void>() {
@@ -88,10 +106,21 @@ public class Main extends be.nikiroo.fanfix.Main {
 
        @Override
        protected void start() throws IOException {
-               UIUtils.setLookAndFeel();
+               if (kiosk) {
+                       UIUtils.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
+               } else {
+                       UIUtils.setLookAndFeel();
+               }
+
                Instance.init();
 
                JFrame main = new MainFrame();
+
+               if (kiosk) {
+                       main.setUndecorated(kiosk);
+                       main.setExtendedState(JFrame.MAXIMIZED_BOTH);
+               }
+
                main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                main.setVisible(true);
        }
index c560e9a86df67cf60e573521e2651ae68a64bd5b..fb8e15eff933d8a4adfc6cea9a6e8c7cc672dc08 100644 (file)
@@ -5,6 +5,7 @@ import java.awt.BorderLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.KeyEvent;
+import java.awt.event.WindowEvent;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
@@ -16,6 +17,7 @@ import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
 import javax.swing.JPanel;
+import javax.swing.JSeparator;
 import javax.swing.JSplitPane;
 import javax.swing.JTabbedPane;
 import javax.swing.SwingUtilities;
@@ -264,9 +266,20 @@ public class MainFrame extends JFrame {
                        }
                });
 
+               JMenuItem mnuExit = new JMenuItem("Exit", KeyEvent.VK_X);
+               mnuExit.addActionListener(new ActionListener() {
+                       @Override
+                       public void actionPerformed(ActionEvent e) {
+                               MainFrame.this.dispatchEvent(new WindowEvent(MainFrame.this,
+                                               WindowEvent.WINDOW_CLOSING));
+                       }
+               });
+
                file.add(mnuDownload);
                file.add(mnuImprtFile);
                file.add(mnuSearch);
+               file.add(new JSeparator());
+               file.add(mnuExit);
 
                // EDIT
 
@@ -367,6 +380,7 @@ public class MainFrame extends JFrame {
                view.add(mnuSidePane);
                view.add(mnuDetailsPane);
                view.add(mnuThumbs);
+               view.add(new JSeparator());
                view.add(mnuWord);
 
                //
index ca166d579dce705d56d478af1611937af04ac792..93d492dce8e9180864fea65c70cecdfd4cc2ba2a 100644 (file)
@@ -25,8 +25,8 @@ class BookCoverImager {
        static final Color SPINE_COLOR_RIGHT = new Color(100, 100, 100);
        static final Color BORDER = Color.black;
 
-       public static final Color UNCACHED_ICON_COLOR = Color.green.darker();
-       // new Color(0, 80, 220);
+       public static final Color UNCACHED_ICON_COLOR = Color.gray;
+       public static final Color CACHED_ICON_COLOR = Color.green.darker();
 
        public static final int TEXT_HEIGHT = 50;
        public static final int TEXT_WIDTH = COVER_WIDTH + 40;
@@ -87,7 +87,8 @@ class BookCoverImager {
                g.setColor(color);
                g.fillRect(clip.x, clip.y, clip.width, clip.height);
 
-               UIUtils.drawEllipse3D(g, UNCACHED_ICON_COLOR,
+               UIUtils.drawEllipse3D(g,
+                               cached ? CACHED_ICON_COLOR : UNCACHED_ICON_COLOR,
                                COVER_WIDTH + HOFFSET + 30, 10, 20, 20, cached);
        }
 }
index 6e4b6c2d5c44fd71532878658875566e827b54bb..a1dadedcd003a53bde761c32e6511e1a88283c02 100644 (file)
@@ -61,7 +61,7 @@ public class BookLine extends JPanel {
                iconNotCached = new JLabel(" ○ ");
 
                iconNotCached.setForeground(BookCoverImager.UNCACHED_ICON_COLOR);
-               iconCached.setForeground(BookCoverImager.UNCACHED_ICON_COLOR);
+               iconCached.setForeground(BookCoverImager.CACHED_ICON_COLOR);
                iconCached.setPreferredSize(iconNotCached.getPreferredSize());
 
                title = new JLabel();