From b49e3262d34740052f570b001a742201fe6c8db7 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Wed, 6 May 2020 17:25:11 +0200 Subject: [PATCH] new kiosk mode --- src/be/nikiroo/fanfix_swing/Main.java | 33 +++++++++++++++++-- .../nikiroo/fanfix_swing/gui/MainFrame.java | 14 ++++++++ .../gui/book/BookCoverImager.java | 7 ++-- .../fanfix_swing/gui/book/BookLine.java | 2 +- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/be/nikiroo/fanfix_swing/Main.java b/src/be/nikiroo/fanfix_swing/Main.java index 3164196a..5efbc248 100644 --- a/src/be/nikiroo/fanfix_swing/Main.java +++ b/src/be/nikiroo/fanfix_swing/Main.java @@ -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 & Feel) or will be passed to Fanfix) */ public static void main(String[] args) { new Main().start(args); } + @Override + public void start(String[] args) { + List argsList = new ArrayList(); + 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() { @@ -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); } diff --git a/src/be/nikiroo/fanfix_swing/gui/MainFrame.java b/src/be/nikiroo/fanfix_swing/gui/MainFrame.java index c560e9a8..fb8e15ef 100644 --- a/src/be/nikiroo/fanfix_swing/gui/MainFrame.java +++ b/src/be/nikiroo/fanfix_swing/gui/MainFrame.java @@ -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); // diff --git a/src/be/nikiroo/fanfix_swing/gui/book/BookCoverImager.java b/src/be/nikiroo/fanfix_swing/gui/book/BookCoverImager.java index ca166d57..93d492dc 100644 --- a/src/be/nikiroo/fanfix_swing/gui/book/BookCoverImager.java +++ b/src/be/nikiroo/fanfix_swing/gui/book/BookCoverImager.java @@ -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); } } diff --git a/src/be/nikiroo/fanfix_swing/gui/book/BookLine.java b/src/be/nikiroo/fanfix_swing/gui/book/BookLine.java index 6e4b6c2d..a1dadedc 100644 --- a/src/be/nikiroo/fanfix_swing/gui/book/BookLine.java +++ b/src/be/nikiroo/fanfix_swing/gui/book/BookLine.java @@ -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(); -- 2.27.0