Commit d49a9b6d authored by Daniel Dreibrodt's avatar Daniel Dreibrodt

Config: Saves window position & maximization state & last used directory. Look...

Config: Saves window position & maximization state & last used directory. Look & feel can be customized
Language: Included ActionEditor.java, PreviewWindow.java & SubBitmapEditWindow.java
Minor improvements of ActionEditor
parent 3a985b40
......@@ -82,7 +82,71 @@ WELCOME_QUIT|Quit
#Preferences window
WIN_PREFS_TITLE|Preferences
WIN_PREFS_UPDATE_L|Enable auto-update:
WIN_PREFS_LANG_L|Language (takes effect on next start):
WIN_PREFS_LANG_L|Language:
WIN_PREFS_LAF_L|Program look-and-feel:
WIN_PREFS_RESTART_L|<html><i>Some settings only take effect when the program is restarted.</i></html>
#SubBitmap Edit and Skin Preview window
WIN_SBMP_EDIT_TITLE|Edit SubBitmap
ZOOM_FACTOR|Zoom factor:
#Action Editor
WIN_ACTIONS_TITLE|Edit action sequence
ACTIONS_PU|Actions
ACTIONS_DIALOGS|Show a dialog
ACTIONS_PLAYLIST|Playlist
ACTIONS_DVD|DVD
ACTIONS_WINDOWS|Skin
ACTIONS_VLC_PLAY|Play
ACTIONS_VLC_PAUSE|Pause
ACTIONS_VLC_STOP|Stop
ACTIONS_VLC_FASTER|Play faster
ACTIONS_VLC_SLOWER|Play slower
ACTIONS_VLC_MUTE|Mute the volume
ACTIONS_VLC_VOLUMEUP|Increase the volume
ACTIONS_VLC_VOLUMEDOWN|Reduce the volume
ACTIONS_VLC_FULLSCREEN|Toggle fullscreen mode
ACTIONS_VLC_SNAPSHOT|Take a snapshot
ACTIONS_VLC_ONTOP|Toggle always on top
ACTIONS_VLC_MINIMIZE|Minimize VLC
ACTIONS_VLC_QUIT|Quit VLC
ACTIONS_EQ_ENABLE|Enable Equalizer
ACTIONS_EQ_DISABLE|Disable Equalizer
ACTIONS_DIALOGS_CHANGESKIN|Change skin
ACTIONS_DIALOGS_FILESIMPLE|Open file (simple)
ACTIONS_DIALOGS_FILE|Open file (extended)
ACTIONS_DIALOGS_DIRECTORY|Open directory
ACTIONS_DIALOGS_DISC|Open disc
ACTIONS_DIALOGS_NET|Open network stream
ACTIONS_DIALOGS_MESSAGES|Message log
ACTIONS_DIALOGS_PREFS|Preferences
ACTIONS_DIALOGS_FILEINFO|File information
ACTIONS_DIALOGS_PLAYLIST|Unskinned playlist
ACTIONS_DIALOGS_STREAMINGWIZARD|Streaming Wizard
ACTIONS_DIALOGS_POPUP|Full popup menu
ACTIONS_DIALOGS_AUDIOPOPUP|Audio settings popup menu
ACTIONS_DIALOGS_VIDEOPOPUP|Video settings popup menu
ACTIONS_DIALOGS_MISCPOPUP|Miscellaneous settings popup menu
ACTIONS_PLAYLIST_ADD|Add a new item
ACTIONS_PLAYLIST_DEL|Remove selected item
ACTIONS_PLAYLIST_NEXT|Play next item
ACTIONS_PLAYLIST_PREVIOUS|Play previous item
ACTIONS_PLAYLIST_SETRANDOM|Play in random/normal order
ACTIONS_PLAYLIST_SETLOOP|Loop playlist/play it once
ACTIONS_PLAYLIST_SETREPEAT|Enable/disable repetition of current item
ACTIONS_PLAYLIST_SORT|Sort alphabetically
ACTIONS_PLAYLIST_LOAD|Load from file
ACTIONS_PLAYLIST_SAVE|Save to file
ACTIONS_DVD_NEXTTITLE|Next title
ACTIONS_DVD_PREVIOUSTITLE|Previous title
ACTIONS_DVD_NEXTCHAPTER|Next chapter
ACTIONS_DVD_PREVIOUSCHAPTER|Previous chapter
ACTIONS_DVD_ROOTMENU|Main menu
ACTIONS_WINDOWS_SHOW|Show a window
ACTIONS_WINDOWS_HIDE|Hide a window
ACTIONS_WINDOWS_MAXIMIZE|Maximize a window
ACTIONS_WINDOWS_UNMAXIMIZE|Unmaximize a window
ACTIONS_WINDOWS_SETLAYOUT|Change the layout of a window
#Messages
ABOUT_TITLE|About VLC Skin Editor
......@@ -133,4 +197,6 @@ ERROR_RES_DEL_TITLE|Could not delete resource
ERROR_RES_DEL_INUSE|Resource is still used in the skin, thus it cannot be deleted.
ERROR_ADD_LAYOUT_TITLE|Could not add layout
ERROR_ADD_LAYOUT_MSG|No parent window selected!
ERROR_UPDATE_TITLE|Error while updating!
\ No newline at end of file
ERROR_UPDATE_TITLE|Error while updating!
ERROR_SAVEPNG_TITLE|Error while saving preview image
ERROR_SAVEPNG_MSG|Could not save preview image.
\ No newline at end of file
......@@ -48,70 +48,70 @@ public class ActionEditor extends JFrame implements ActionListener{
JPanel actions_p = new JPanel();
//Opens a PopupMenu from which the user can add an action to the end of the chain
JButton add_btn = new JButton(add_icon);
JButton ok_btn = new JButton("OK");
JButton ok_btn = new JButton(Language.get("BUTTON_OK"));
JPopupMenu actions_pu = new JPopupMenu("Actions");
JMenu actions_dialogs = new JMenu("Show a dialog");
JMenu actions_playlist = new JMenu("Playlist");
JMenu actions_dvd = new JMenu("DVD");
JMenu actions_windows = new JMenu("Skin");
JMenuItem actions_vlc_play = new JMenuItem("Play");
JMenuItem actions_vlc_pause = new JMenuItem("Pause");
JMenuItem actions_vlc_stop = new JMenuItem("Stop");
JMenuItem actions_vlc_faster = new JMenuItem("Play faster");
JMenuItem actions_vlc_slower = new JMenuItem("Play slower");
JMenuItem actions_vlc_mute = new JMenuItem("Mute the volume");
JMenuItem actions_vlc_volumeUp = new JMenuItem("Increase the volume");
JMenuItem actions_vlc_volumeDown = new JMenuItem("Reduce the volume");
JMenuItem actions_vlc_fullscreen = new JMenuItem("Toggle fullscreen mode");
JMenuItem actions_vlc_snapshot = new JMenuItem("Take a snapshot");
JMenuItem actions_vlc_onTop = new JMenuItem("Toggle always on top");
JMenuItem actions_vlc_minimize = new JMenuItem("Minimize VLC");
JMenuItem actions_vlc_quit = new JMenuItem("Quit VLC");
JMenuItem actions_eq_enable = new JMenuItem("Enable the equalizer");
JMenuItem actions_eq_disable = new JMenuItem("Disable the equalizer");
JMenuItem actions_dialogs_changeSkin = new JMenuItem("Change skin");
JMenuItem actions_dialogs_fileSimple = new JMenuItem("Open file (simple)");
JMenuItem actions_dialogs_file = new JMenuItem("Open file (extended)");
JMenuItem actions_dialogs_directory = new JMenuItem("Open directory");
JMenuItem actions_dialogs_disc = new JMenuItem("Open disc");
JMenuItem actions_dialogs_net = new JMenuItem("Open network stream");
JMenuItem actions_dialogs_messages = new JMenuItem("Message log");
JMenuItem actions_dialogs_prefs = new JMenuItem("Preferences");
JMenuItem actions_dialogs_fileInfo = new JMenuItem("File information");
JMenuItem actions_dialogs_playlist = new JMenuItem("Unskinned playlist");
JMenuItem actions_dialogs_streamingWizard = new JMenuItem("Streaming Wizard");
JMenuItem actions_dialogs_popup = new JMenuItem("Full popup menu");
JMenuItem actions_dialogs_audioPopup = new JMenuItem("Audio settings popup menu");
JMenuItem actions_dialogs_videoPopup = new JMenuItem("Video settings popup menu");
JMenuItem actions_dialogs_miscPopup = new JMenuItem("Miscellaneous settings popup menu");
JMenuItem actions_playlist_add = new JMenuItem("Add a new item");
JMenuItem actions_playlist_del = new JMenuItem("Remove selected items");
JMenuItem actions_playlist_next = new JMenuItem("Play next item");
JMenuItem actions_playlist_previous = new JMenuItem("Play previous item");
JMenuItem actions_playlist_setRandom = new JMenuItem("Play in random/normal order");
JMenuItem actions_playlist_setLoop = new JMenuItem("Loop playlist/play it once");
JMenuItem actions_playlist_setRepeat = new JMenuItem("Repeat current item/play it once");
JMenuItem actions_playlist_sort = new JMenuItem("Sort alphabetically");
JMenuItem actions_playlist_load = new JMenuItem("Load from file");
JMenuItem actions_playlist_save = new JMenuItem("Save to file");
JMenuItem actions_dvd_nextTitle = new JMenuItem("Next title");
JMenuItem actions_dvd_previousTitle = new JMenuItem("Previous title");
JMenuItem actions_dvd_nextChapter = new JMenuItem("Next chapter");
JMenuItem actions_dvd_previousChapter = new JMenuItem("Previous Chapter");
JMenuItem actions_dvd_rootMenu = new JMenuItem("Main menu");
JMenuItem actions_windows_show = new JMenuItem("Show a window");
JMenuItem actions_windows_hide = new JMenuItem("Hide a window");
JMenuItem actions_windows_maximize = new JMenuItem("Maximize a window");
JMenuItem actions_windows_unmaximize = new JMenuItem("Unmaximize a window");
JMenuItem actions_windows_setLayout = new JMenuItem("Change the layout of a window");
JPopupMenu actions_pu = new JPopupMenu(Language.get("ACTIONS_PU"));
JMenu actions_dialogs = new JMenu(Language.get("ACTIONS_DIALOGS"));
JMenu actions_playlist = new JMenu(Language.get("ACTIONS_PLAYLIST"));
JMenu actions_dvd = new JMenu(Language.get("ACTIONS_DVD"));
JMenu actions_windows = new JMenu(Language.get("ACTIONS_WINDOWS"));
JMenuItem actions_vlc_play = new JMenuItem(Language.get("ACTIONS_VLC_PLAY"));
JMenuItem actions_vlc_pause = new JMenuItem(Language.get("ACTIONS_VLC_PAUSE"));
JMenuItem actions_vlc_stop = new JMenuItem(Language.get("ACTIONS_VLC_STOP"));
JMenuItem actions_vlc_faster = new JMenuItem(Language.get("ACTIONS_VLC_FASTER"));
JMenuItem actions_vlc_slower = new JMenuItem(Language.get("ACTIONS_VLC_SLOWER"));
JMenuItem actions_vlc_mute = new JMenuItem(Language.get("ACTIONS_VLC_MUTE"));
JMenuItem actions_vlc_volumeUp = new JMenuItem(Language.get("ACTIONS_VLC_VOLUMEUP"));
JMenuItem actions_vlc_volumeDown = new JMenuItem(Language.get("ACTIONS_VLC_VOLUMEDOWN"));
JMenuItem actions_vlc_fullscreen = new JMenuItem(Language.get("ACTIONS_VLC_FULLSCREEN"));
JMenuItem actions_vlc_snapshot = new JMenuItem(Language.get("ACTIONS_VLC_SNAPSHOT"));
JMenuItem actions_vlc_onTop = new JMenuItem(Language.get("ACTIONS_VLC_ONTOP"));
JMenuItem actions_vlc_minimize = new JMenuItem(Language.get("ACTIONS_VLC_MINIMIZE"));
JMenuItem actions_vlc_quit = new JMenuItem(Language.get("ACTIONS_VLC_QUIT"));
JMenuItem actions_eq_enable = new JMenuItem(Language.get("ACTIONS_EQ_ENABLE"));
JMenuItem actions_eq_disable = new JMenuItem(Language.get("ACTIONS_EQ_DISABLE"));
JMenuItem actions_dialogs_changeSkin = new JMenuItem(Language.get("ACTIONS_DIALOGS_CHANGESKIN"));
JMenuItem actions_dialogs_fileSimple = new JMenuItem(Language.get("ACTIONS_DIALOGS_FILESIMPLE"));
JMenuItem actions_dialogs_file = new JMenuItem(Language.get("ACTIONS_DIALOGS_FILE"));
JMenuItem actions_dialogs_directory = new JMenuItem(Language.get("ACTIONS_DIALOGS_DIRECTORY"));
JMenuItem actions_dialogs_disc = new JMenuItem(Language.get("ACTIONS_DIALOGS_DISC"));
JMenuItem actions_dialogs_net = new JMenuItem(Language.get("ACTIONS_DIALOGS_NET"));
JMenuItem actions_dialogs_messages = new JMenuItem(Language.get("ACTIONS_DIALOGS_MESSAGES"));
JMenuItem actions_dialogs_prefs = new JMenuItem(Language.get("ACTIONS_DIALOGS_PREFS"));
JMenuItem actions_dialogs_fileInfo = new JMenuItem(Language.get("ACTIONS_DIALOGS_FILEINFO"));
JMenuItem actions_dialogs_playlist = new JMenuItem(Language.get("ACTIONS_DIALOGS_PLAYLIST"));
JMenuItem actions_dialogs_streamingWizard = new JMenuItem(Language.get("ACTIONS_DIALOGS_STREAMINGWIZARD"));
JMenuItem actions_dialogs_popup = new JMenuItem(Language.get("ACTIONS_DIALOGS_POPUP"));
JMenuItem actions_dialogs_audioPopup = new JMenuItem(Language.get("ACTIONS_DIALOGS_AUDIOPOPUP"));
JMenuItem actions_dialogs_videoPopup = new JMenuItem(Language.get("ACTIONS_DIALOGS_VIDEOPOPUP"));
JMenuItem actions_dialogs_miscPopup = new JMenuItem(Language.get("ACTIONS_DIALOGS_MISCPOPUP"));
JMenuItem actions_playlist_add = new JMenuItem(Language.get("ACTIONS_PLAYLIST_ADD"));
JMenuItem actions_playlist_del = new JMenuItem(Language.get("ACTIONS_PLAYLIST_DEL"));
JMenuItem actions_playlist_next = new JMenuItem(Language.get("ACTIONS_PLAYLIST_NEXT"));
JMenuItem actions_playlist_previous = new JMenuItem(Language.get("ACTIONS_PLAYLIST_PREVIOUS"));
JMenuItem actions_playlist_setRandom = new JMenuItem(Language.get("ACTIONS_PLAYLIST_SETRANDOM"));
JMenuItem actions_playlist_setLoop = new JMenuItem(Language.get("ACTIONS_PLAYLIST_SETLOOP"));
JMenuItem actions_playlist_setRepeat = new JMenuItem(Language.get("ACTIONS_PLAYLIST_SETREPEAT"));
JMenuItem actions_playlist_sort = new JMenuItem(Language.get("ACTIONS_PLAYLIST_SORT"));
JMenuItem actions_playlist_load = new JMenuItem(Language.get("ACTIONS_PLAYLIST_LOAD"));
JMenuItem actions_playlist_save = new JMenuItem(Language.get("ACTIONS_PLAYLIST_SAVE"));
JMenuItem actions_dvd_nextTitle = new JMenuItem(Language.get("ACTIONS_DVD_NEXTTITLE"));
JMenuItem actions_dvd_previousTitle = new JMenuItem(Language.get("ACTIONS_DVD_PREVIOUSTITLE"));
JMenuItem actions_dvd_nextChapter = new JMenuItem(Language.get("ACTIONS_DVD_NEXTCHAPTER"));
JMenuItem actions_dvd_previousChapter = new JMenuItem(Language.get("ACTIONS_DVD_PREVIOUSCHAPTER"));
JMenuItem actions_dvd_rootMenu = new JMenuItem(Language.get("ACTIONS_DVD_ROOTMENU"));
JMenuItem actions_windows_show = new JMenuItem(Language.get("ACTIONS_WINDOWS_SHOW"));
JMenuItem actions_windows_hide = new JMenuItem(Language.get("ACTIONS_WINDOWS_HIDE"));
JMenuItem actions_windows_maximize = new JMenuItem(Language.get("ACTIONS_WINDOWS_MAXIMIZE"));
JMenuItem actions_windows_unmaximize = new JMenuItem(Language.get("ACTIONS_WINDOWS_UNMAXIMIZE"));
JMenuItem actions_windows_setLayout = new JMenuItem(Language.get("ACTIONS_WINDOWS_SETLAYOUT"));
//The skin item to which the represented action chain belongs
Item parent;
/** Creates a new instance of ActionEditor */
public ActionEditor(Item p) {
super("Edit action sequence");
super(Language.get("WIN_ACTIONS_TITLE"));
setLayout(null);
setIconImage(Toolkit.getDefaultToolkit().createImage(this.getClass().getResource("icons/editor.png")));
......@@ -304,6 +304,7 @@ public class ActionEditor extends JFrame implements ActionListener{
public String getCode() {
String code = "";
for(ActionPanel act:aPanels) code+=act.getActionCode()+";";
if(code.equals("")) code = "none";
return code;
}
/**
......@@ -322,6 +323,8 @@ public class ActionEditor extends JFrame implements ActionListener{
* @param act The action string
*/
public void addAction(String act) {
//If the first action is to do nothing, it is removed
if(aPanels.size()>0 && aPanels.get(0).action.equals("none")) actions_p.remove(aPanels.remove(0));
act=act.trim();
act=act.replaceAll(";","");
aPanels.add(new ActionPanel(act,this));
......@@ -377,15 +380,18 @@ public class ActionEditor extends JFrame implements ActionListener{
* For testing purposes
*/
public static void main (String[] args) {
Config.load();
Language.load(new java.io.File("lang"+java.io.File.separator+Config.get("language")+".txt"));
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
}
catch (Exception e) {
}
JFrame.setDefaultLookAndFeelDecorated(true);
ActionEditor ae = new ActionEditor(null);
ae.setDefaultCloseOperation(ae.EXIT_ON_CLOSE);
ae.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
/*ae.editAction("none;dialogs.changeSkin();dialogs.fileSimple();dialogs.file();dialogs.directory();dialogs.disc();dialogs.net();dialogs.messages();dialogs.prefs();dialogs.fileInfo();dialogs.playlist();dialogs.streamingWizard();dialogs.popup();dialogs.audioPopup();dialogs.videoPopup();dialogs.miscPopup();equalizer.enable();equalizer.disable();vlc.play();vlc.pause();vlc.stop();vlc.faster();vlc.slower();vlc.mute();" +
"vlc.volumeUp();vlc.volumeDown();vlc.fullscreen();vlc.snapshot();vlc.onTop();vlc.minimize();vlc.quit();playlist.add();playlist.del();playlist.next();playlist.previous();playlist.sort();playlist.setRandom(true);playlist.setLoop(true);playlist.setRepeat(true);playlist.load();playlist.save();dvd.nextTitle();dvd.previousTitle();dvd.nextChapter();dvd.previousChapter();dvd.rootMenu();WindowID.show();WindowID.hide();" +
"WindowID.maximize();WindowID.unmaximize();WindowID.setLayout(LayoutID)");
......
......@@ -47,11 +47,14 @@ public class ActionPanel extends JPanel {
windowid_tf = new JTextField();
layoutid_tf = new JTextField();
setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
//A dynamic action is an action whose parameters can be changed
if(act.indexOf(".set")!=-1) action_type="dynamic"; // all playlist.setXXXX(boolean)
else if (act.indexOf(".show()")!=-1) action_type="dynamic"; // show a window
else if (act.indexOf(".hide()")!=-1) action_type="dynamic"; // hide a window
else if (act.indexOf("maximize()")!=-1) action_type="dynamic"; // un-/maximize a window
else if (act.indexOf(".setLayout")!=-1) action_type="dynamic"; //change window layout
else if (act.indexOf(".setLayout")!=-1) action_type="dynamic"; //change window layout
if(action_type.equals("static")) { //static => the action has no parameters
JLabel desc = new JLabel(action);
if (action.equals("none")) desc.setText("Do nothing");
......
......@@ -46,6 +46,7 @@ public class Config {
strings.put("language", "English");
strings.put("win.main.width","800");
strings.put("win.main.height","600");
strings.put("win.main.maximized","false");
strings.put("win.res.x","0");
strings.put("win.res.y","0");
strings.put("win.res.width","190");
......@@ -58,6 +59,7 @@ public class Config {
strings.put("win.items.y","350");
strings.put("win.items.width","190");
strings.put("win.items.height","200");
strings.put("swing.laf","System");
}
/**
......@@ -94,8 +96,7 @@ public class Config {
* @return The key's value
*/
public static String get(String key) {
String s = strings.get(key);
return (s!=null)?s:key;
return strings.get(key);
}
/**
* Gets the configured value of a certain key as an integer
......@@ -165,11 +166,19 @@ public class Config {
final JComboBox lang_cb = new JComboBox(lang_choices);
lang_cb.setSelectedIndex(sel);
JLabel laf_l = new JLabel(Language.get("WIN_PREFS_LAF_L"));
String[] lafs = { "System" , "Metal: Steel", "Metal: Ocean" };
final JComboBox laf_cb = new JComboBox(lafs);
laf_cb.setSelectedItem(Config.get("swing.laf"));
JLabel restart_l = new JLabel(Language.get("WIN_PREFS_RESTART_L"));
JButton ok_btn = new JButton(Language.get("BUTTON_OK"));
ok_btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
strings.put("autoupdate", String.valueOf(update_cb.isSelected()));
strings.put("language", (String)lang_cb.getSelectedItem());
strings.put("language", (String)lang_cb.getSelectedItem());
strings.put("swing.laf", (String)laf_cb.getSelectedItem());
frame.setVisible(false);
frame.dispose();
}
......@@ -187,13 +196,19 @@ public class Config {
frame.add(lang_cb);
frame.add(update_l);
frame.add(update_cb);
frame.add(laf_l);
frame.add(laf_cb);
frame.add(restart_l);
frame.add(ok_btn);
frame.add(cancel_btn);
Component[] labels = { lang_l, update_l};
int tf_dx = Helper.maxWidth(labels)+10;
Component[] labels = { lang_l, update_l, laf_l};
int tf_dx = Helper.maxWidth(labels)+10;
lang_cb.setPreferredSize(new Dimension(200,lang_cb.getPreferredSize().height));
int tf_wd = restart_l.getPreferredSize().width+5 - tf_dx;
if(tf_wd < lang_cb.getPreferredSize().width) tf_wd = lang_cb.getPreferredSize().width;
lang_cb.setPreferredSize(new Dimension(tf_wd,lang_cb.getPreferredSize().height));
SpringLayout layout = new SpringLayout();
layout.putConstraint(SpringLayout.NORTH, lang_l, 5, SpringLayout.NORTH, frame.getContentPane());
......@@ -208,7 +223,16 @@ public class Config {
layout.putConstraint(SpringLayout.WEST, update_cb, tf_dx, SpringLayout.WEST, frame.getContentPane());
layout.putConstraint(SpringLayout.EAST, update_cb, 0, SpringLayout.EAST, lang_cb);
layout.putConstraint(SpringLayout.NORTH, ok_btn, 10, SpringLayout.SOUTH, update_l);
layout.putConstraint(SpringLayout.NORTH, laf_l, 10, SpringLayout.SOUTH, update_l);
layout.putConstraint(SpringLayout.WEST, laf_l, 5, SpringLayout.WEST, frame.getContentPane());
layout.putConstraint(SpringLayout.VERTICAL_CENTER, laf_cb, 0, SpringLayout.VERTICAL_CENTER, laf_l);
layout.putConstraint(SpringLayout.WEST, laf_cb, tf_dx, SpringLayout.WEST, frame.getContentPane());
layout.putConstraint(SpringLayout.EAST, laf_cb, 0, SpringLayout.EAST, lang_cb);
layout.putConstraint(SpringLayout.NORTH, restart_l, 10, SpringLayout.SOUTH, laf_l);
layout.putConstraint(SpringLayout.WEST, restart_l, 5, SpringLayout.WEST, frame.getContentPane());
layout.putConstraint(SpringLayout.NORTH, ok_btn, 10, SpringLayout.SOUTH, restart_l);
layout.putConstraint(SpringLayout.WEST, ok_btn, 5, SpringLayout.WEST, frame.getContentPane());
layout.putConstraint(SpringLayout.WEST, cancel_btn, 5, SpringLayout.EAST, ok_btn);
layout.putConstraint(SpringLayout.NORTH, cancel_btn, 0, SpringLayout.NORTH, ok_btn);
......@@ -219,7 +243,7 @@ public class Config {
frame.setLayout(layout);
frame.pack();
//frame.setResizable(false);
frame.setResizable(false);
frame.setVisible(true);
}
......
......@@ -35,6 +35,7 @@ import java.util.zip.*;
import vlcskineditor.items.*;
import com.ice.tar.*;
import com.ice.jni.registry.*;
import javax.swing.plaf.metal.*;
import vlcskineditor.history.*;
import vlcskineditor.resources.Bitmap;
import vlcskineditor.resources.SubBitmap;
......@@ -121,12 +122,7 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele
* @param args Command line arguments passed by the console.
* If there exist one or more arguments, the first argument is intepreted as a file locator for a skin to be loaded.
*/
public Main(String[] args) {
Config.load();
Language.load(new File("lang"+File.separator+Config.get("language")+".txt"));
public Main(String[] args) {
setTitle("VLC Skin Editor "+VERSION);
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(this);
......@@ -574,9 +570,17 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele
jdesk.setMinimumSize(new Dimension(800,600));
add(jdesk);
setSize(Config.getInt("win.main.width"),Config.getInt("win.main.height"));
if(Config.get("win.main.x")==null) setLocationRelativeTo(null);
else {
setLocation(Config.getInt("win.main.x"),Config.getInt("win.main.y"));
}
if(Boolean.parseBoolean(Config.get("win.main.maximized"))) {
setExtendedState(JFrame.MAXIMIZED_BOTH);
}
setVisible(true);
setSize(Config.getInt("win.main.width"),Config.getInt("win.main.height"));
update();
......@@ -606,12 +610,12 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele
}
}
else if(System.getProperty("os.name").indexOf("Linux")!=-1){
vlc_skins_dir = "~/.vlc/skins2/";
}
vlc_skins_dir = "~/.local/share/vlc/skins2/";
}
if(base_fc==null) base_fc = new JFileChooser();
base_fc.setCurrentDirectory(new File(vlc_skins_dir));
if(Config.get("open.folder")==null) base_fc.setCurrentDirectory(new File(vlc_skins_dir));
else base_fc.setCurrentDirectory(new File(Config.get("open.folder")));
}
/**
......@@ -1736,8 +1740,8 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele
Object[] options= { Language.get("CHOICE_YES"), Language.get("CHOICE_NO"), Language.get("CHOICE_CANCEL") };
int n = JOptionPane.showOptionDialog(
this,
Language.get("CONFIRM_EXIT_MSG"),
Language.get("CONFIRM_EXIT_TITLE"),
Language.get("EXIT_CONFIRM_MSG"),
Language.get("EXIT_CONFIRM_TITLE"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
......@@ -1761,8 +1765,15 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele
}
private void doExit() {
Config.set("win.main.width", getWidth());
Config.set("win.main.height", getHeight());
if(getExtendedState()!=JFrame.MAXIMIZED_BOTH) {
Config.set("win.main.x",getX());
Config.set("win.main.y",getY());
Config.set("win.main.width", getWidth());
Config.set("win.main.height", getHeight());
Config.set("win.main.maximized","false");
} else {
Config.set("win.main.maximized","true");
}
Config.set("win.res.x",resources.getX());
Config.set("win.res.y",resources.getY());
Config.set("win.res.width",resources.getWidth());
......@@ -1775,6 +1786,7 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele
Config.set("win.items.y",items.getY());
Config.set("win.items.width",items.getWidth());
Config.set("win.items.height",items.getHeight());
if(base_fc!=null) Config.set("open.folder",base_fc.getCurrentDirectory().getAbsolutePath());
Config.save();
System.exit(0);
}
......@@ -1784,12 +1796,30 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele
* @param args the command line arguments
*/
public static void main(String[] args) {
Config.load();
Language.load(new File("lang"+File.separator+Config.get("language")+".txt"));
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
String laf = Config.get("swing.laf");
String lafClass = laf;
if(laf!=null) {
if(laf.equals("System")) {
lafClass = UIManager.getSystemLookAndFeelClassName();
}
if(laf.equals("Metal: Steel")) {
lafClass = UIManager.getCrossPlatformLookAndFeelClassName();
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
} else if(laf.equals("Metal: Ocean")) {
lafClass = UIManager.getCrossPlatformLookAndFeelClassName();
MetalLookAndFeel.setCurrentTheme(new OceanTheme());
}
}
UIManager.setLookAndFeel(lafClass);
}
catch (Exception e) {
catch (Exception ex) {
ex.printStackTrace();
}
JFrame.setDefaultLookAndFeelDecorated(true);
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "VLC Skin Editor");
......
......@@ -64,14 +64,14 @@ public class PreviewWindow extends JPanel implements MouseListener, MouseMotionL
*/
public PreviewWindow(Main m_) {
m = m_;
frame = new JInternalFrame("No Layout selected");
frame = new JInternalFrame();
frame.setLayout(new BorderLayout());
zoom_panel = new JPanel();
zoom_panel.setLayout(new FlowLayout());
zoom_less = new JButton("-");
zoom_less.addActionListener(this);
zoom_panel.add(zoom_less);
zoom_label = new JLabel("Zoom factor: 1x");
zoom_label = new JLabel(Language.get("ZOOM_FACTOR")+" 1x");
zoom_panel.add(zoom_label);
zoom_more = new JButton("+");
zoom_more.addActionListener(this);
......@@ -171,13 +171,13 @@ public class PreviewWindow extends JPanel implements MouseListener, MouseMotionL
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(zoom_less)) {
if(z>1) z--;
zoom_label.setText("Zoom factor: "+z+"x");
zoom_label.setText(Language.get("ZOOM_FACTOR")+" "+z+"x");
setSize(l.width*z, l.height*z);
setPreferredSize(new Dimension(l.width*z, l.height*z));
}
else if(e.getSource().equals(zoom_more)) {
if(z<16) z++;
zoom_label.setText("Zoom factor: "+z+"x");
zoom_label.setText(Language.get("ZOOM_FACTOR")+" "+z+"x");
setSize(l.width*z, l.height*z);
setPreferredSize(new Dimension(l.width*z, l.height*z));
}
......@@ -282,7 +282,7 @@ public class PreviewWindow extends JPanel implements MouseListener, MouseMotionL
ImageIO.write(bi, "png", f);
}
catch (Exception e) {
JOptionPane.showMessageDialog(m,"Could not save image!\n"+e.toString(),"Exception caught!",JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(m,Language.get("ERROR_SAVEPNG_MSG")+"\n"+e.toString(),Language.get("ERROR_SAVEPNG_TITLE"),JOptionPane.ERROR_MESSAGE);
return;
}
}
......
......@@ -54,6 +54,7 @@ public class TreeRenderer extends DefaultTreeCellRenderer {
public TreeRenderer() {
}
/** Returns how a given leaf should be rendered */
@Override
public Component getTreeCellRendererComponent(JTree tree,Object value,boolean sel,boolean expanded,boolean leaf,int row,boolean hasFocus) {
String name = value.toString();
value = value.toString().substring(value.toString().indexOf(": ")+2);
......@@ -86,7 +87,7 @@ public class TreeRenderer extends DefaultTreeCellRenderer {
else if(name.startsWith("SliderBackground:")) return sliderbackground_icon;
else if(name.startsWith("Video:")) return video_icon;
else if(name.startsWith("Text:")) return text_icon;
else return (ImageIcon)getDefaultLeafIcon();
else return null;
}
/**
......
......@@ -26,6 +26,7 @@ import java.awt.*;
import java.awt.event.*;
import vlcskineditor.FrameUpdater;
import javax.swing.*;
import vlcskineditor.Language;
/**
* Gives the user the possibilty to edit a SubBitmap visually
......@@ -58,14 +59,14 @@ public class SubBitmapEditWindow extends JPanel implements ActionListener, Mouse
y1_org = y1 = sb.y;
x2_org = x2 = sb.x+sb.width;
y2_org = y2 = sb.y+sb.height;
frame = new JFrame("Edit SubBitmap");
frame = new JFrame(Language.get("WIN_SBMP_EDIT_TITLE"));
frame.setLayout(new BorderLayout());
zoom_panel = new JPanel();
zoom_panel.setLayout(new FlowLayout());
zoom_less = new JButton("-");
zoom_less.addActionListener(this);
zoom_panel.add(zoom_less);
zoom_label = new JLabel("Zoom factor: 1x");
zoom_label = new JLabel(Language.get("ZOOM_FACTOR")+" 1x");
zoom_panel.add(zoom_label);
zoom_more = new JButton("+");
zoom_more.addActionListener(this);
......@@ -202,13 +203,13 @@ public class SubBitmapEditWindow extends JPanel implements ActionListener, Mouse
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(zoom_less)) {
if(z_fact>1) z_fact--;
zoom_label.setText("Zoom factor: "+z_fact+"x");
zoom_label.setText(Language.get("ZOOM_FACTOR")+" "+z_fact+"x");
setSize(p_width*z_fact, p_height*z_fact);
setPreferredSize(new Dimension(p_width*z_fact, p_height*z_fact));
}
else if(e.getSource().equals(zoom_more)) {
if(z_fact<16) z_fact++;
zoom_label.setText("Zoom factor: "+z_fact+"x");
zoom_label.setText(Language.get("ZOOM_FACTOR")+" "+z_fact+"x");
setSize(p_width*z_fact, p_height*z_fact);
setPreferredSize(new Dimension(p_width*z_fact, p_height*z_fact));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment