diff --git a/src/qz/common/Constants.java b/src/qz/common/Constants.java index 014112961..8dfdb786c 100644 --- a/src/qz/common/Constants.java +++ b/src/qz/common/Constants.java @@ -93,6 +93,10 @@ public class Constants { public static final Color TRUSTED_COLOR_LITE = Color.BLUE; public static final Color WARNING_COLOR_DARK = Color.decode("#EB6261"); public static final Color TRUSTED_COLOR_DARK = Color.decode("#589DF6"); + public static final Color RUNNING_COLOR = Color.decode("#00AD47"); + public static final Color PENDING_COLOR = Color.decode("#B2B247"); + public static final Color STOPPED_COLOR = Color.decode("#AE4745"); + public static Color WARNING_COLOR = WARNING_COLOR_LITE; public static Color TRUSTED_COLOR = TRUSTED_COLOR_LITE; diff --git a/src/qz/common/TrayManager.java b/src/qz/common/TrayManager.java index 2808e503a..9f7b8c743 100644 --- a/src/qz/common/TrayManager.java +++ b/src/qz/common/TrayManager.java @@ -671,6 +671,7 @@ private void setIcon(final IconCache.Icon i) { public void refreshIcon(final Runnable whenDone) { SwingUtilities.invokeLater(() -> { tray.setIcon(shownIcon); + controlDialog.setRunningIndicator(shownIcon); if(whenDone != null) { whenDone.run(); } diff --git a/src/qz/ui/ControlDialog.java b/src/qz/ui/ControlDialog.java index d3dbf0463..359c5a9c9 100644 --- a/src/qz/ui/ControlDialog.java +++ b/src/qz/ui/ControlDialog.java @@ -1,5 +1,7 @@ package qz.ui; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import qz.common.Constants; import qz.ui.component.IconCache; @@ -14,6 +16,8 @@ * A container for all the System Tray menu items */ public class ControlDialog extends BasicDialog implements Themeable { + private static final Logger log = LogManager.getLogger(ControlDialog.class); + public enum Category { STATUS, GENERAL, @@ -24,10 +28,15 @@ public enum Category { private boolean persistent = false; private JPanel statusPanel; + private JPanel statusLeftPanel; + private JPanel statusRightPanel; private JPanel generalPanel; private JPanel advancedPanel; private JPanel diagnosticPanel; + private JLabel runningIndicator; + private JLabel runningLabel; + public ControlDialog(IconCache iconCache) { super(Constants.ABOUT_TITLE, iconCache); initComponents(); @@ -60,18 +69,22 @@ public void add(Component component, String text, Category category) { toAdd = button; } else if(component instanceof JSeparator){ toAdd = (JSeparator)component; + } else if (component instanceof JComponent){ + toAdd = (JComponent)component; + } else { + log.warn("Cannot add {}, not yet supported.", component.getClass().getSimpleName()); } if(toAdd != null) { switch(category) { + case STATUS: + statusRightPanel.add(toAdd); + break; case ADVANCED: advancedPanel.add(toAdd); break; case DIAGNOSTIC: diagnosticPanel.add(toAdd); break; - case STATUS: - statusPanel.add(toAdd); - break; case GENERAL: default: generalPanel.add(toAdd); @@ -86,7 +99,29 @@ private void initComponents() { mainPanel.setLayout(new BorderLayout()); mainPanel.setBorder(createPaddedLineBorder(5, SwingConstants.SOUTH)); - statusPanel = new JPanel(new FlowLayout()); + statusLeftPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + statusRightPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + + statusPanel = new JPanel(new GridLayout(1, 3)); + + // Running indicator + runningIndicator = new JLabel("•"); + runningIndicator.setFont(new Font("", Font.BOLD, 24)); + runningIndicator.setForeground(Constants.STOPPED_COLOR); + runningIndicator.setBorder(new EmptyBorder(0, 2, 2, 2)); + runningLabel = new JLabel("Stopped"); + runningLabel.setBorder(new EmptyBorder(0, 0, 0, 4)); + statusLeftPanel.add(runningIndicator); + statusLeftPanel.add(runningLabel); + statusPanel.add(statusLeftPanel); + + // Version label + JLabel versionLabel = new JLabel(Constants.ABOUT_TITLE + " " + Constants.VERSION); + versionLabel.setFont(runningLabel.getFont()); + statusPanel.add(versionLabel); + + // Additional controls added with .add() + statusPanel.add(statusRightPanel); Font headingFont = new JLabel().getFont().deriveFont(16f).deriveFont(Font.BOLD); @@ -170,6 +205,23 @@ public void refresh() { ThemeUtilities.refreshAll(this); } + public void setRunningIndicator(IconCache.Icon icon) { + switch(icon) { + case WARNING_ICON: + runningIndicator.setForeground(Constants.PENDING_COLOR); + runningLabel.setText("Pending"); + break; + case DANGER_ICON: + runningIndicator.setForeground(Constants.STOPPED_COLOR); + runningLabel.setText("Stopped"); + break; + case DEFAULT_ICON: + default: + runningIndicator.setForeground(Constants.RUNNING_COLOR); + runningLabel.setText("Running"); + } + } + /** * Sets persistent mode, window can't be closed unless shutdown */