From: Brian Hinz Date: Thu, 18 Aug 2011 01:09:19 +0000 (+0000) Subject: add support for "hidden" compression levels 0,7,8,9 in the gui (JComboBox is now... X-Git-Tag: v1.1.90~171 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=849cfbe473a987d34e2e00cc73bfd2173dd36c0f;p=tigervnc.git add support for "hidden" compression levels 0,7,8,9 in the gui (JComboBox is now editable). Also addded some sanity checks to make sure only 0-9 can be passed in via the gui or the command line. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4636 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/java/src/com/tigervnc/vncviewer/CConn.java b/java/src/com/tigervnc/vncviewer/CConn.java index 2d4276ec..27f9dc60 100644 --- a/java/src/com/tigervnc/vncviewer/CConn.java +++ b/java/src/com/tigervnc/vncviewer/CConn.java @@ -681,7 +681,11 @@ public class CConn extends CConnection options.customCompressLevel.setSelected(viewer.customCompressLevel.getValue()); digit = 0 + viewer.compressLevel.getValue(); - options.compressLevel.setSelectedItem(digit); + if (digit >= 0 && digit <= 9) { + options.compressLevel.setSelectedItem(digit); + } else { + options.compressLevel.setSelectedItem(Integer.parseInt(viewer.compressLevel.getDefaultStr())); + } options.noJpeg.setSelected(!viewer.noJpeg.getValue()); digit = 0 + viewer.qualityLevel.getValue(); options.qualityLevel.setSelectedItem(digit); @@ -815,7 +819,12 @@ public class CConn extends CConnection cp.customCompressLevel = viewer.customCompressLevel.getValue(); encodingChange = true; } - viewer.compressLevel.setParam(options.compressLevel.getSelectedItem().toString()); + if (Integer.parseInt(options.compressLevel.getSelectedItem().toString()) >= 0 && + Integer.parseInt(options.compressLevel.getSelectedItem().toString()) <= 9) { + viewer.compressLevel.setParam(options.compressLevel.getSelectedItem().toString()); + } else { + viewer.compressLevel.setParam(viewer.compressLevel.getDefaultStr()); + } if (cp.compressLevel != viewer.compressLevel.getValue()) { cp.compressLevel = viewer.compressLevel.getValue(); encodingChange = true; diff --git a/java/src/com/tigervnc/vncviewer/OptionsDialog.java b/java/src/com/tigervnc/vncviewer/OptionsDialog.java index 65af744e..9b73cc47 100644 --- a/java/src/com/tigervnc/vncviewer/OptionsDialog.java +++ b/java/src/com/tigervnc/vncviewer/OptionsDialog.java @@ -89,12 +89,23 @@ class OptionsDialog extends Dialog implements customCompressLevel.addItemListener(this); Object[] compressionLevels = { 1, 2, 3, 4, 5, 6 }; compressLevel = new JComboBox(compressionLevels); + compressLevel.setEditable(true); JLabel compressionLabel = new JLabel("Level (1=fast, 6=best [4-6 are rarely useful])"); noJpeg = new JCheckBox("Allow JPEG Compression"); noJpeg.addItemListener(this); Object[] qualityLevels = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; qualityLevel = new JComboBox(qualityLevels); JLabel qualityLabel = new JLabel("Level (1=poor, 9=best)"); + compressLevel.setPreferredSize(qualityLevel.getPreferredSize()); + // Hack to set the left inset on editable JComboBox + if (UIManager.getLookAndFeel().getID() == "Windows") { + compressLevel.setBorder(BorderFactory.createCompoundBorder(compressLevel.getBorder(), + BorderFactory.createEmptyBorder(0,1,0,0))); + } else { + ComboBoxEditor editor = compressLevel.getEditor(); + JTextField jtf = (JTextField)editor.getEditorComponent(); + jtf.setBorder(new CompoundBorder(jtf.getBorder(), new EmptyBorder(0,1,0,0))); + } addGBComponent(customCompressLevel, tightPanel, 0, 0, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(0,2,0,0)); addGBComponent(compressLevel, tightPanel, 0, 1, 1, 1, 2, 2, 0, 0, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(0,20,0,0)); addGBComponent(compressionLabel, tightPanel, 1, 1, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(0,5,0,0));