]> source.dussan.org Git - tigervnc.git/commitdiff
add support for "hidden" compression levels 0,7,8,9 in the gui (JComboBox is now...
authorBrian Hinz <bphinz@users.sourceforge.net>
Thu, 18 Aug 2011 01:09:19 +0000 (01:09 +0000)
committerBrian Hinz <bphinz@users.sourceforge.net>
Thu, 18 Aug 2011 01:09:19 +0000 (01:09 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4636 3789f03b-4d11-0410-bbf8-ca57d06f2519

java/src/com/tigervnc/vncviewer/CConn.java
java/src/com/tigervnc/vncviewer/OptionsDialog.java

index 2d4276ecb30a6108d426359d6cae75a3b78bd9fa..27f9dc60cef5d6ec70e0cf7aa2a8275d6ac410f3 100644 (file)
@@ -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;
index 65af744e39571983c322d8a1f2faeb52c5626fba..9b73cc47c5ce7751c493ed96c97dc3aedeb9c090 100644 (file)
@@ -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));