瀏覽代碼

Less prominent (and nicer) drop down selector for SSH protocol version

Source commit: 2d52a7151b8d7ce71c1124b2901fda94d0224f67
Martin Prikryl 9 年之前
父節點
當前提交
0cdb59e113
共有 3 個文件被更改,包括 36 次插入85 次删除
  1. 19 41
      source/forms/SiteAdvanced.cpp
  2. 16 40
      source/forms/SiteAdvanced.dfm
  3. 1 4
      source/forms/SiteAdvanced.h

+ 19 - 41
source/forms/SiteAdvanced.cpp

@@ -219,14 +219,7 @@ void __fastcall TSiteAdvancedDialog::LoadSession()
     // SSH page
     Ssh2LegacyDESCheck->Checked = FSessionData->Ssh2DES;
     CompressionCheck->Checked = FSessionData->Compression;
-
-    switch (FSessionData->SshProt)
-    {
-      case ssh1only:  SshProt1onlyButton->Checked = true; break;
-      case ssh1:      SshProt1Button->Checked = true; break;
-      case ssh2:      SshProt2Button->Checked = true; break;
-      case ssh2only:  SshProt2onlyButton->Checked = true; break;
-    }
+    SshProtCombo->ItemIndex = FSessionData->SshProt;
 
     CipherListBox->Items->Clear();
     DebugAssert(CIPHER_NAME_WARN+CIPHER_COUNT-1 == CIPHER_NAME_CHACHA20);
@@ -400,22 +393,7 @@ void __fastcall TSiteAdvancedDialog::LoadSession()
 //---------------------------------------------------------------------
 TSshProt __fastcall TSiteAdvancedDialog::GetSshProt()
 {
-  if (SshProt1onlyButton->Checked)
-  {
-    return ssh1only;
-  }
-  else if (SshProt1Button->Checked)
-  {
-    return ssh1;
-  }
-  else if (SshProt2Button->Checked)
-  {
-    return ssh2;
-  }
-  else
-  {
-    return ssh2only;
-  }
+  return (TSshProt)SshProtCombo->ItemIndex;
 }
 //---------------------------------------------------------------------
 void __fastcall TSiteAdvancedDialog::SaveSession()
@@ -791,17 +769,17 @@ void __fastcall TSiteAdvancedDialog::UpdateControls()
 
     // ssh/authentication sheet
     AuthSheet->Enabled = SshProtocol;
-    EnableControl(SshNoUserAuthCheck, !SshProt1onlyButton->Checked);
+    EnableControl(SshNoUserAuthCheck, (GetSshProt() != ssh1only));
     EnableControl(AuthenticationGroup,
       !SshNoUserAuthCheck->Enabled || !SshNoUserAuthCheck->Checked);
-    EnableControl(AuthTISCheck, AuthenticationGroup->Enabled && !SshProt2onlyButton->Checked);
-    EnableControl(AuthKICheck, AuthenticationGroup->Enabled && !SshProt1onlyButton->Checked);
+    EnableControl(AuthTISCheck, AuthenticationGroup->Enabled && (GetSshProt() != ssh2only));
+    EnableControl(AuthKICheck, AuthenticationGroup->Enabled && (GetSshProt() != ssh1only));
     EnableControl(AuthKIPasswordCheck,
       AuthenticationGroup->Enabled &&
       ((AuthTISCheck->Enabled && AuthTISCheck->Checked) ||
        (AuthKICheck->Enabled && AuthKICheck->Checked)));
     EnableControl(AuthGSSAPICheck3,
-      AuthenticationGroup->Enabled && !SshProt1onlyButton->Checked);
+      AuthenticationGroup->Enabled && (GetSshProt() != ssh1only));
     EnableControl(GSSAPIFwdTGTCheck,
       AuthGSSAPICheck3->Enabled && AuthGSSAPICheck3->Checked);
 
@@ -810,10 +788,10 @@ void __fastcall TSiteAdvancedDialog::UpdateControls()
     EnableControl(CipherUpButton, CipherListBox->ItemIndex > 0);
     EnableControl(CipherDownButton, CipherListBox->ItemIndex >= 0 &&
       CipherListBox->ItemIndex < CipherListBox->Items->Count-1);
-    EnableControl(Ssh2LegacyDESCheck, !SshProt1onlyButton->Checked);
+    EnableControl(Ssh2LegacyDESCheck, (GetSshProt() != ssh1only));
 
     // ssh/kex sheet
-    KexSheet->Enabled = SshProtocol && !SshProt1onlyButton->Checked &&
+    KexSheet->Enabled = SshProtocol && (GetSshProt() != ssh1only) &&
       (BugRekey2Combo->ItemIndex != 2);
     EnableControl(KexUpButton, KexListBox->ItemIndex > 0);
     EnableControl(KexDownButton, KexListBox->ItemIndex >= 0 &&
@@ -821,27 +799,27 @@ void __fastcall TSiteAdvancedDialog::UpdateControls()
 
     // ssh/bugs sheet
     BugsSheet->Enabled = SshProtocol;
-    EnableControl(BugIgnore1Combo, !SshProt2onlyButton->Checked);
+    EnableControl(BugIgnore1Combo, (GetSshProt() != ssh2only));
     EnableControl(BugIgnore1Label, BugIgnore1Combo->Enabled);
-    EnableControl(BugPlainPW1Combo, !SshProt2onlyButton->Checked);
+    EnableControl(BugPlainPW1Combo, (GetSshProt() != ssh2only));
     EnableControl(BugPlainPW1Label, BugPlainPW1Combo->Enabled);
-    EnableControl(BugRSA1Combo, !SshProt2onlyButton->Checked);
+    EnableControl(BugRSA1Combo, (GetSshProt() != ssh2only));
     EnableControl(BugRSA1Label, BugRSA1Combo->Enabled);
-    EnableControl(BugHMAC2Combo, !SshProt1onlyButton->Checked);
+    EnableControl(BugHMAC2Combo, (GetSshProt() != ssh1only));
     EnableControl(BugHMAC2Label, BugHMAC2Combo->Enabled);
-    EnableControl(BugDeriveKey2Combo, !SshProt1onlyButton->Checked);
+    EnableControl(BugDeriveKey2Combo, (GetSshProt() != ssh1only));
     EnableControl(BugDeriveKey2Label, BugDeriveKey2Combo->Enabled);
-    EnableControl(BugRSAPad2Combo, !SshProt1onlyButton->Checked);
+    EnableControl(BugRSAPad2Combo, (GetSshProt() != ssh1only));
     EnableControl(BugRSAPad2Label, BugRSAPad2Combo->Enabled);
-    EnableControl(BugPKSessID2Combo, !SshProt1onlyButton->Checked);
+    EnableControl(BugPKSessID2Combo, (GetSshProt() != ssh1only));
     EnableControl(BugPKSessID2Label, BugPKSessID2Combo->Enabled);
-    EnableControl(BugRekey2Combo, !SshProt1onlyButton->Checked);
+    EnableControl(BugRekey2Combo, (GetSshProt() != ssh1only));
     EnableControl(BugRekey2Label, BugRekey2Combo->Enabled);
-    EnableControl(BugMaxPkt2Combo, !SshProt1onlyButton->Checked);
+    EnableControl(BugMaxPkt2Combo, (GetSshProt() != ssh1only));
     EnableControl(BugMaxPkt2Label, BugMaxPkt2Combo->Enabled);
-    EnableControl(BugIgnore2Combo, !SshProt1onlyButton->Checked);
+    EnableControl(BugIgnore2Combo, (GetSshProt() != ssh1only));
     EnableControl(BugIgnore2Label, BugIgnore2Combo->Enabled);
-    EnableControl(BugWinAdjCombo, !SshProt1onlyButton->Checked);
+    EnableControl(BugWinAdjCombo, (GetSshProt() != ssh1only));
     EnableControl(BugWinAdjLabel, BugWinAdjCombo->Enabled);
 
     // connection/proxy sheet

+ 16 - 40
source/forms/SiteAdvanced.dfm

@@ -1698,38 +1698,19 @@ object SiteAdvancedDialog: TSiteAdvancedDialog
           Left = 0
           Top = 6
           Width = 393
-          Height = 87
+          Height = 71
           Anchors = [akLeft, akTop, akRight]
           Caption = 'Protocol options'
           TabOrder = 0
           DesignSize = (
             393
-            87)
+            71)
           object Label7: TLabel
             Left = 12
             Top = 42
             Width = 152
             Height = 13
             Caption = 'Preferred SSH protocol version:'
-            FocusControl = SshProt1onlyButton
-          end
-          object SshProt1Button: TRadioButton
-            Left = 96
-            Top = 59
-            Width = 74
-            Height = 17
-            Caption = '&1'
-            TabOrder = 2
-            OnClick = DataChange
-          end
-          object SshProt2Button: TRadioButton
-            Left = 176
-            Top = 59
-            Width = 74
-            Height = 17
-            Caption = '&2'
-            TabOrder = 3
-            OnClick = DataChange
           end
           object CompressionCheck: TCheckBox
             Left = 16
@@ -1741,30 +1722,25 @@ object SiteAdvancedDialog: TSiteAdvancedDialog
             TabOrder = 0
             OnClick = DataChange
           end
-          object SshProt1onlyButton: TRadioButton
-            Left = 16
-            Top = 59
-            Width = 74
-            Height = 17
-            Caption = '1 on&ly'
-            Checked = True
+          object SshProtCombo: TComboBox
+            Left = 303
+            Top = 37
+            Width = 80
+            Height = 21
+            Style = csDropDownList
+            Anchors = [akTop, akRight]
             TabOrder = 1
-            TabStop = True
-            OnClick = DataChange
-          end
-          object SshProt2onlyButton: TRadioButton
-            Left = 256
-            Top = 59
-            Width = 74
-            Height = 17
-            Caption = '2 o&nly'
-            TabOrder = 4
-            OnClick = DataChange
+            OnChange = DataChange
+            Items.Strings = (
+              '1 only'
+              '1 preferred'
+              '2 preferred'
+              '2 only')
           end
         end
         object EncryptionGroup: TGroupBox
           Left = 0
-          Top = 100
+          Top = 83
           Width = 393
           Height = 171
           Anchors = [akLeft, akTop, akRight]

+ 1 - 4
source/forms/SiteAdvanced.h

@@ -30,8 +30,6 @@ __published:
   TTabSheet *AdvancedSheet;
   TGroupBox *ProtocolGroup;
   TLabel *Label7;
-  TRadioButton *SshProt1Button;
-  TRadioButton *SshProt2Button;
   TCheckBox *CompressionCheck;
   TTabSheet *EnvironmentSheet;
   TTabSheet *ScpSheet;
@@ -76,8 +74,6 @@ __published:
   TComboBox *BugDeriveKey2Combo;
   TLabel *BugRSAPad2Label;
   TComboBox *BugRSAPad2Combo;
-  TRadioButton *SshProt1onlyButton;
-  TRadioButton *SshProt2onlyButton;
   TTabSheet *AuthSheet;
   TGroupBox *AuthenticationGroup;
   TCheckBox *AuthTISCheck;
@@ -256,6 +252,7 @@ __published:
   TLabel *Label4;
   TFilenameEdit *TlsCertificateFileEdit;
   TCheckBox *TrimVMSVersionsCheck;
+  TComboBox *SshProtCombo;
   void __fastcall DataChange(TObject *Sender);
   void __fastcall FormShow(TObject *Sender);
   void __fastcall PageControlChange(TObject *Sender);