1
0
mirror of https://github.com/mitb-archive/filebot synced 2025-03-09 13:59:49 -04:00

Fix text color (especially on Linux with dark GTK theme)

This commit is contained in:
Reinhard Pointner 2018-06-20 19:29:46 +07:00
parent 28edf9af8d
commit 5fe8383917
3 changed files with 20 additions and 42 deletions

View File

@ -11,7 +11,6 @@ import static net.filebot.util.ExceptionUtilities.*;
import static net.filebot.util.FileUtilities.*; import static net.filebot.util.FileUtilities.*;
import static net.filebot.util.ui.SwingUI.*; import static net.filebot.util.ui.SwingUI.*;
import java.awt.Font;
import java.awt.Window; import java.awt.Window;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.io.File; import java.io.File;
@ -32,7 +31,6 @@ import java.util.stream.Stream;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JLabel;
import net.filebot.HistorySpooler; import net.filebot.HistorySpooler;
import net.filebot.LicenseError; import net.filebot.LicenseError;
@ -253,11 +251,7 @@ class RenameAction extends AbstractAction {
openURI(getPurchaseURL()); openURI(getPurchaseURL());
})); }));
actionPopup.addSeparator(); actionPopup.setStatus(message);
JLabel label = new JLabel(message, ResourceManager.getIcon("status.error"), JLabel.CENTER);
label.setFont(label.getFont().deriveFont(9f).deriveFont(Font.BOLD));
actionPopup.addDescription(label);
return actionPopup; return actionPopup;
} }

View File

@ -38,7 +38,6 @@ import javax.swing.Icon;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -440,7 +439,7 @@ public class RenamePanel extends JComponent {
private ActionPopup createFetchPopup() { private ActionPopup createFetchPopup() {
ActionPopup actionPopup = new ActionPopup("Fetch & Match Data", ResourceManager.getIcon("action.fetch")); ActionPopup actionPopup = new ActionPopup("Fetch & Match Data", ResourceManager.getIcon("action.fetch"));
actionPopup.addDescription(new JLabel("Episode Mode:")); actionPopup.addDescription("Episode Mode:");
// create actions for match popup episode list completion // create actions for match popup episode list completion
for (EpisodeListProvider db : WebServices.getEpisodeListProviders()) { for (EpisodeListProvider db : WebServices.getEpisodeListProviders()) {
@ -448,7 +447,7 @@ public class RenamePanel extends JComponent {
} }
actionPopup.addSeparator(); actionPopup.addSeparator();
actionPopup.addDescription(new JLabel("Movie Mode:")); actionPopup.addDescription("Movie Mode:");
// create action for movie name completion // create action for movie name completion
for (MovieIdentificationService it : WebServices.getMovieIdentificationServices()) { for (MovieIdentificationService it : WebServices.getMovieIdentificationServices()) {
@ -456,17 +455,17 @@ public class RenamePanel extends JComponent {
} }
actionPopup.addSeparator(); actionPopup.addSeparator();
actionPopup.addDescription(new JLabel("Music Mode:")); actionPopup.addDescription("Music Mode:");
for (MusicIdentificationService it : WebServices.getMusicIdentificationServices()) { for (MusicIdentificationService it : WebServices.getMusicIdentificationServices()) {
actionPopup.add(new AutoCompleteAction(it.getName(), it.getIcon(), () -> new MusicMatcher(it))); actionPopup.add(new AutoCompleteAction(it.getName(), it.getIcon(), () -> new MusicMatcher(it)));
} }
actionPopup.addSeparator(); actionPopup.addSeparator();
actionPopup.addDescription(new JLabel("Smart Mode:")); actionPopup.addDescription("Smart Mode:");
actionPopup.add(new AutoCompleteAction("Autodetect", ResourceManager.getIcon("action.auto"), AutoDetectMatcher::new)); actionPopup.add(new AutoCompleteAction("Autodetect", ResourceManager.getIcon("action.auto"), AutoDetectMatcher::new));
actionPopup.addSeparator(); actionPopup.addSeparator();
actionPopup.addDescription(new JLabel("Options:")); actionPopup.addDescription("Options:");
actionPopup.add(newAction("Edit Format", ResourceManager.getIcon("action.format"), evt -> showFormatEditor(null))); actionPopup.add(newAction("Edit Format", ResourceManager.getIcon("action.format"), evt -> showFormatEditor(null)));
@ -539,13 +538,13 @@ public class RenamePanel extends JComponent {
private ActionPopup createSettingsPopup() { private ActionPopup createSettingsPopup() {
ActionPopup actionPopup = new ActionPopup("Rename Options", ResourceManager.getIcon("action.settings")); ActionPopup actionPopup = new ActionPopup("Rename Options", ResourceManager.getIcon("action.settings"));
actionPopup.addDescription(new JLabel("Extension:")); actionPopup.addDescription("Extension:");
actionPopup.add(new SetRenameMode(false, "Preserve", ResourceManager.getIcon("action.extension.preserve"))); actionPopup.add(new SetRenameMode(false, "Preserve", ResourceManager.getIcon("action.extension.preserve")));
actionPopup.add(new SetRenameMode(true, "Override", ResourceManager.getIcon("action.extension.override"))); actionPopup.add(new SetRenameMode(true, "Override", ResourceManager.getIcon("action.extension.override")));
actionPopup.addSeparator(); actionPopup.addSeparator();
actionPopup.addDescription(new JLabel("Action:")); actionPopup.addDescription("Action:");
for (StandardRenameAction action : Preset.getSupportedActions()) { for (StandardRenameAction action : Preset.getSupportedActions()) {
actionPopup.add(new SetRenameAction(action)); actionPopup.add(new SetRenameAction(action));
} }

View File

@ -1,12 +1,10 @@
package net.filebot.util.ui; package net.filebot.util.ui;
import java.awt.Color; import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -24,7 +22,11 @@ public class ActionPopup extends JPopupMenu {
protected final JPanel actionPanel = new JPanel(new MigLayout("nogrid, insets 0, fill")); protected final JPanel actionPanel = new JPanel(new MigLayout("nogrid, insets 0, fill"));
public ActionPopup(String label, Icon icon) { public ActionPopup(String label, Icon icon) {
// fix text color (especially on Linux with dark GTK theme)
setForeground(new JMenuItem().getForeground());
headerLabel.setText(label); headerLabel.setText(label);
headerLabel.setForeground(getForeground());
headerLabel.setIcon(icon); headerLabel.setIcon(icon);
headerLabel.setIconTextGap(5); headerLabel.setIconTextGap(5);
@ -45,12 +47,14 @@ public class ActionPopup extends JPopupMenu {
setLightWeightPopupEnabled(false); setLightWeightPopupEnabled(false);
} }
public void addDescription(JComponent component) { protected JLabel createLabel(String text) {
actionPanel.add(component, "gapx 4px 4px, growx, wrap 3px"); JLabel label = new JLabel(text);
label.setForeground(getForeground());
return label;
} }
public void addAction(JComponent component) { public void addDescription(String text) {
actionPanel.add(component, "gapx 12px 12px, growx, wrap"); actionPanel.add(createLabel(text), "gapx 4px 4px, growx, wrap 3px");
} }
@Override @Override
@ -72,19 +76,10 @@ public class ActionPopup extends JPopupMenu {
// close popup when action is triggered // close popup when action is triggered
link.addActionListener(closeListener); link.addActionListener(closeListener);
addAction(link); actionPanel.add(link, "gapx 12px 12px, growx, wrap");
return null; return null;
} }
public void clear() {
actionPanel.removeAll();
}
@Override
public void setLabel(String label) {
headerLabel.setText(label);
}
@Override @Override
public String getLabel() { public String getLabel() {
return headerLabel.getText(); return headerLabel.getText();
@ -94,16 +89,6 @@ public class ActionPopup extends JPopupMenu {
statusLabel.setText(string); statusLabel.setText(string);
} }
public String getStatus() { private final ActionListener closeListener = evt -> setVisible(false);
return statusLabel.getText();
}
private final ActionListener closeListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
};
} }