📄 util.java
字号:
pop.add(Config.getResource("Util.relativeLyric")).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { JOptionPane.showMessageDialog(lp, Config.getResource("Util.relativeTip")); } }); pop.add(Config.getResource("Util.undoLyric")).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { lp.getPlayer().getCurrentItem().setLyricFile(null); lp.getLyric().setEnabled(false); } }); pop.add(Config.getResource("Util.reloadLyric")).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { Lyric ly = new Lyric(lp.getPlayer().getCurrentItem()); lp.getPlayer().setLyric(ly); lp.setLyric(ly); } }); ButtonGroup bg = new ButtonGroup(); JRadioButtonMenuItem showH = new JRadioButtonMenuItem(Config.getResource("lyric.showLyricH"), config.getLpState() == LyricPanel.H); JRadioButtonMenuItem showV = new JRadioButtonMenuItem(Config.getResource("lyric.showLyricV"), config.getLpState() == LyricPanel.V); bg.add(showH); bg.add(showV); showType.add(showH); showType.add(showV); showType.addSeparator(); showH.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { lp.setState(LyricPanel.H); config.setLpState(LyricPanel.H); } }); showV.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { lp.setState(LyricPanel.V); config.setLpState(LyricPanel.V); } }); final JCheckBoxMenuItem isAuto = new JCheckBoxMenuItem(Config.getResource("lyric.isAutoResize"), config.isAutoResize()); isAuto.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { config.setAutoResize(isAuto.isSelected()); if (isAuto.isSelected()) { lp.setResized(false); } } }); final JCheckBoxMenuItem isKaraoke = new JCheckBoxMenuItem(Config.getResource("lyric.isKaraoke"), config.isKaraoke()); isKaraoke.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { config.setKaraoke(isKaraoke.isSelected()); } }); final JCheckBoxMenuItem isAnti = new JCheckBoxMenuItem(Config.getResource("Util.textAnti"), config.isAntiAliasing()); isAnti.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { config.setAntiAliasing(isAnti.isSelected()); } }); final JCheckBoxMenuItem trans = new JCheckBoxMenuItem(Config.getResource("Util.bgTrans"), config.isTransparency()); trans.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { config.setTransparency(trans.isSelected()); if (trans.isSelected()) { lp.getPlayer().getLyricUI().setBorderEnabled(config.isShowLrcBorder()); JDialog jd = lp.getPlayer().getLoader().changeLrcDialog(); WindowUtils.setWindowTransparent(jd, true); lp.start(); } else { lp.getPlayer().getLyricUI().setBorderEnabled(true); WindowUtils.setWindowTransparent(config.getLrcWindow(), false); } } }); final JCheckBoxMenuItem showBorder = new JCheckBoxMenuItem(Config.getResource("Util.showBorder"), config.isShowLrcBorder()); showBorder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { boolean b = showBorder.isSelected(); config.setShowLrcBorder(b); lp.getPlayer().getLyricUI().setBorderEnabled(b); } }); showBorder.setEnabled(config.isTransparency()); if (config.isLinux()) { trans.setEnabled(false); showBorder.setEnabled(false); } showType.add(isAuto); showType.add(isKaraoke); showType.add(isAnti); showType.add(trans); showType.add(showBorder); pop.add(adjust); pop.add(showType); final JCheckBoxMenuItem topShow = new JCheckBoxMenuItem(Config.getResource("Util.showOnTop"), config.isLyricTopShow()); topShow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { config.setLyricTopShow(topShow.isSelected()); config.getLrcWindow().setAlwaysOnTop(topShow.isSelected()); } }); pop.add(topShow); pop.add(Config.getResource("Util.option")).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { OptionDialog jd = config.getOptionDialog(); jd.setSelected(Config.getResource("Util.lyric")); jd.setVisible(true); } }); } /** * 快速地生成歌词秀上下文菜单的方法 * @param pop 菜单 * @param lp 歌词面板 */ public static void generateLyricMenu(JPopupMenu pop, final LyricPanel lp) { final Config config = Config.getConfig(); JMenu adjust = new JMenu(Config.getResource("Util.adjustLyric")); JMenu showType = new JMenu(Config.getResource("Util.displayMode"));// JMenu set = new JMenu("设置"); adjust.add(Config.getResource("Util.ff0.5")).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { lp.getLyric().adjustTime(-500); } }); adjust.add(Config.getResource("Util.ss0.5")).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { lp.getLyric().adjustTime(500); } }); adjust.add(Config.getResource("Util.adjustAll")).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String s = JOptionPane.showInputDialog(Config.getResource("Util.inputAdjustTime") + Config.getResource("Util.adjustTip")); if (s != null) { try { int time = Integer.parseInt(s); lp.getLyric().adjustTime(time); } catch (Exception exe) { } } } }); adjust.addSeparator(); final JCheckBoxMenuItem check = new JCheckBoxMenuItem(Config.getResource("Util.mouseWheelAdjust")); check.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { config.setMouseScrollAjustTime(check.isSelected()); } }); check.setSelected(config.isMouseScrollAjustTime()); adjust.add(check); pop.add(Config.getResource("lyric.hideLyric")).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { lp.hideMe(); } }); pop.add(Config.getResource("Util.searchOnline")).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new WebSearchDialog(lp.getPlayer().getCurrentItem(), lp).setVisible(true); } }); pop.add(Config.getResource("Util.relativeLyric")).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { JOptionPane.showMessageDialog(lp, Config.getResource("Util.relativeTip")); } }); pop.add(Config.getResource("Util.undoLyric")).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { lp.getPlayer().getCurrentItem().setLyricFile(null); lp.getLyric().setEnabled(false); } }); pop.add(Config.getResource("Util.reloadLyric")).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { Lyric ly = new Lyric(lp.getPlayer().getCurrentItem()); lp.getPlayer().setLyric(ly); lp.setLyric(ly); } }); ButtonGroup bg = new ButtonGroup(); JRadioButtonMenuItem showH = new JRadioButtonMenuItem(Config.getResource("lyric.showLyricH"), config.getLpState() == LyricPanel.H); JRadioButtonMenuItem showV = new JRadioButtonMenuItem(Config.getResource("lyric.showLyricV"), config.getLpState() == LyricPanel.V); bg.add(showH); bg.add(showV); showType.add(showH); showType.add(showV); showType.addSeparator(); showH.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { lp.setState(LyricPanel.H); config.setLpState(LyricPanel.H); } }); showV.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { lp.setState(LyricPanel.V); config.setLpState(LyricPanel.V); } }); final JCheckBoxMenuItem isAuto = new JCheckBoxMenuItem(Config.getResource("lyric.isAutoResize"), config.isAutoResize()); isAuto.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { config.setAutoResize(isAuto.isSelected()); if (isAuto.isSelected()) { lp.setResized(false); } } }); final JCheckBoxMenuItem isKaraoke = new JCheckBoxMenuItem(Config.getResource("lyric.isKaraoke"), config.isKaraoke()); isKaraoke.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { config.setKaraoke(isKaraoke.isSelected()); } }); final JCheckBoxMenuItem isAnti = new JCheckBoxMenuItem(Config.getResource("Util.textAnti"), config.isAntiAliasing()); isAnti.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { config.setAntiAliasing(isAnti.isSelected()); } }); final JCheckBoxMenuItem trans = new JCheckBoxMenuItem(Config.getResource("Util.bgTrans"), config.isTransparency()); trans.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { config.setTransparency(trans.isSelected()); if (trans.isSelected()) { lp.getPlayer().getLyricUI().setBorderEnabled(config.isShowLrcBorder()); JDialog jd = lp.getPlayer().getLoader().changeLrcDialog(); WindowUtils.setWindowTransparent(jd, true); lp.start(); } else { lp.getPlayer().getLyricUI().setBorderEnabled(true); WindowUtils.setWindowTransparent(config.getLrcWindow(), false); } } }); final JCheckBoxMenuItem showBorder = new JCheckBoxMenuItem(Config.getResource("Util.showBorder"), config.isShowLrcBorder()); showBorder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { boolean b = showBorder.isSelected(); config.setShowLrcBorder(b); lp.getPlayer().getLyricUI().setBorderEnabled(b); } }); showBorder.setEnabled(config.isTransparency()); if (config.isLinux()) { trans.setEnabled(false); showBorder.setEnabled(false); } showType.add(isAuto); showType.add(isKaraoke); showType.add(isAnti); showType.add(trans); showType.add(showBorder); pop.add(adjust); pop.add(showType); final JCheckBoxMenuItem topShow = new JCheckBoxMenuItem(Config.getResource("Util.showOnTop"), config.isLyricTopShow()); topShow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { config.setLyricTopShow(topShow.isSelected()); config.getLrcWindow().setAlwaysOnTop(topShow.isSelected()); } }); pop.add(topShow); pop.add(Config.getResource("Util.option")).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { OptionDialog jd = config.getOptionDialog(); jd.setSelected(Config.getResource("Util.lyric")); jd.setVisible(true); } }); } /** * 一个简单的方法,得到传进去的歌手和标题的 * 歌词搜索结果,以一个列表形式返回 * @param artist 歌手名,可能为空 * @param title 歌名,不能为空 * @return */ public static List<SearchResult> getSearchResults(String artist, String title) { List<SearchResult> list = new ArrayList<SearchResult>(); try { HttpClient http = new HttpClient();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -