Browse Source

Reimplementing "Close and Do Not Show Automatically Again" command from 6bfdad18 with "Do not automatically show this dialog box again" checkbox that works even when logging in

Source commit: facee5087c22adc67bb5f299b63a76ea02f34bbd
Martin Prikryl 6 years ago
parent
commit
0c4a1f7a9f
3 changed files with 58 additions and 67 deletions
  1. 10 13
      source/forms/Login.cpp
  2. 45 47
      source/forms/Login.dfm
  3. 3 7
      source/forms/Login.h

+ 10 - 13
source/forms/Login.cpp

@@ -109,12 +109,6 @@ void __fastcall TLoginDialog::Init(TStoredSessionList *SessionList, TForm * Link
   UnicodeString Dummy;
   RunPageantAction->Visible = FindTool(PageantTool, Dummy);
   RunPuttygenAction->Visible = FindTool(PuttygenTool, Dummy);
-  // Bit of a hack: Assume an auto open, when we are linked to the main form
-  if (LinkedForm != NULL)
-  {
-    DebugAssert(WinConfiguration->ShowLoginWhenNoSession);
-    CloseButton->Style = TCustomButton::bsSplitButton;
-  }
   UpdateControls();
 }
 //---------------------------------------------------------------------
@@ -714,6 +708,9 @@ void __fastcall TLoginDialog::FormShow(TObject * /*Sender*/)
   ManageButton->Top = ManageButton->Top + Offset;
   SessionTree->Height = SessionTree->Height + Offset;
 
+  // Bit of a hack: Assume an auto open, when we are linked to the main form
+  ShowAgainPanel->Visible = (FLinkedForm != NULL);
+
   // among other this makes the expanded nodes look like expanded,
   // because the LoadState call in Execute would be too early,
   // and some stray call to collapsed event during showing process,
@@ -1311,6 +1308,12 @@ bool __fastcall TLoginDialog::Execute(TList * DataList)
     SaveConfiguration();
     // DataList saved already from FormCloseQuery
   }
+
+  if (!ShowAgainCheck->Checked)
+  {
+    WinConfiguration->ShowLoginWhenNoSession = false;
+  }
+
   return Result;
 }
 //---------------------------------------------------------------------------
@@ -3085,14 +3088,8 @@ void __fastcall TLoginDialog::ChangeScale(int M, int D)
   FNoteGroupOffset = MulDiv(FNoteGroupOffset, M, D);
 }
 //---------------------------------------------------------------------------
-void __fastcall TLoginDialog::ButtonPanelMouseDown(TObject *, TMouseButton, TShiftState, int, int)
+void __fastcall TLoginDialog::PanelMouseDown(TObject *, TMouseButton, TShiftState, int, int)
 {
   CountClicksForWindowPrint(this);
 }
 //---------------------------------------------------------------------------
-void __fastcall TLoginDialog::NeverShowAgainActionExecute(TObject *)
-{
-  WinConfiguration->ShowLoginWhenNoSession = false;
-  ModalResult = mrCancel;
-}
-//---------------------------------------------------------------------------

+ 45 - 47
source/forms/Login.dfm

@@ -5,10 +5,10 @@ object LoginDialog: TLoginDialog
   HelpKeyword = 'ui_login'
   BorderIcons = [biSystemMenu, biMinimize, biHelp]
   Caption = 'Login'
-  ClientHeight = 575
+  ClientHeight = 599
   ClientWidth = 630
   Color = clBtnFace
-  Constraints.MinHeight = 375
+  Constraints.MinHeight = 399
   Constraints.MinWidth = 600
   ParentFont = True
   KeyPreview = True
@@ -365,7 +365,7 @@ object LoginDialog: TLoginDialog
       Align = alBottom
       BevelOuter = bvNone
       TabOrder = 2
-      OnMouseDown = ButtonPanelMouseDown
+      OnMouseDown = PanelMouseDown
       DesignSize = (
         361
         41)
@@ -391,7 +391,6 @@ object LoginDialog: TLoginDialog
         Anchors = [akRight, akBottom]
         Cancel = True
         Caption = 'Close'
-        DropDownMenu = CloseDropDownMenu
         ModalResult = 2
         TabOrder = 1
       end
@@ -414,7 +413,7 @@ object LoginDialog: TLoginDialog
     Height = 334
     Align = alClient
     BevelOuter = bvNone
-    TabOrder = 1
+    TabOrder = 2
     DesignSize = (
       269
       334)
@@ -491,20 +490,42 @@ object LoginDialog: TLoginDialog
   end
   object ComponentsPanel: TPanel
     Left = 0
-    Top = 334
+    Top = 358
     Width = 630
     Height = 241
     Align = alBottom
     BevelOuter = bvNone
     Color = clWindow
     ParentBackground = False
-    TabOrder = 2
+    TabOrder = 3
+  end
+  object ShowAgainPanel: TPanel
+    Left = 0
+    Top = 334
+    Width = 630
+    Height = 24
+    Align = alBottom
+    BevelOuter = bvNone
+    TabOrder = 1
+    OnMouseDown = PanelMouseDown
+    object ShowAgainCheck: TCheckBox
+      Left = 12
+      Top = 0
+      Width = 333
+      Height = 17
+      Caption = 
+        '&Show Login dialog on startup and when the last session is close' +
+        'd'
+      Checked = True
+      State = cbChecked
+      TabOrder = 0
+    end
   end
   object ActionList: TActionList
     Images = ActionImageList
     OnUpdate = ActionListUpdate
     Left = 36
-    Top = 341
+    Top = 365
     object EditSessionAction: TAction
       Category = 'Sessions'
       Caption = '&Edit'
@@ -672,16 +693,6 @@ object LoginDialog: TLoginDialog
       Caption = 'All &Major Site Fields'
       OnExecute = SearchSiteActionExecute
     end
-    object CloseAction: TAction
-      Category = 'Other'
-      Caption = 'Close'
-    end
-    object NeverShowAgainAction: TAction
-      Category = 'Other'
-      AutoCheck = True
-      Caption = 'Close and Do Not Show Automatically Again'
-      OnExecute = NeverShowAgainActionExecute
-    end
     object SessionRawAction: TAction
       Category = 'Session'
       Caption = 'Edit &Raw Settings...'
@@ -690,7 +701,7 @@ object LoginDialog: TLoginDialog
   end
   object ToolsPopupMenu: TPopupMenu
     Left = 144
-    Top = 397
+    Top = 421
     object Import1: TMenuItem
       Action = ImportSessionsAction
     end
@@ -1110,12 +1121,12 @@ object LoginDialog: TLoginDialog
           E40000000049454E44AE426082}
       end>
     Left = 36
-    Top = 461
+    Top = 485
     Bitmap = {}
   end
   object SaveDropDownMenu: TPopupMenu
     Left = 268
-    Top = 341
+    Top = 365
     object SaveSessionMenuItem: TMenuItem
       Action = SaveSessionAction
       Default = True
@@ -1133,7 +1144,7 @@ object LoginDialog: TLoginDialog
   object ManageSitePopupMenu: TPopupMenu
     Images = ActionImageList
     Left = 396
-    Top = 341
+    Top = 365
     object Shellicon1: TMenuItem
       Caption = 'Site'
       Enabled = False
@@ -1211,7 +1222,7 @@ object LoginDialog: TLoginDialog
   object ManageFolderPopupMenu: TPopupMenu
     Images = ActionImageList
     Left = 398
-    Top = 397
+    Top = 421
     object MenuItem1: TMenuItem
       Caption = 'Site Folder'
       Enabled = False
@@ -1268,7 +1279,7 @@ object LoginDialog: TLoginDialog
   object ManageNewSitePopupMenu: TPopupMenu
     Images = ActionImageList
     Left = 543
-    Top = 341
+    Top = 365
     object MenuItem12: TMenuItem
       Caption = 'New Site'
       Enabled = False
@@ -1332,7 +1343,7 @@ object LoginDialog: TLoginDialog
   object ManageWorkspacePopupMenu: TPopupMenu
     Images = ActionImageList
     Left = 542
-    Top = 397
+    Top = 421
     object MenuItem2: TMenuItem
       Caption = 'Workspace'
       Enabled = False
@@ -1382,7 +1393,7 @@ object LoginDialog: TLoginDialog
   end
   object SessionAdvancedPopupMenu: TPopupMenu
     Left = 144
-    Top = 341
+    Top = 365
     object Session1: TMenuItem
       Caption = 'Session'
       Enabled = False
@@ -1864,13 +1875,13 @@ object LoginDialog: TLoginDialog
           AE426082}
       end>
     Left = 33
-    Top = 525
+    Top = 549
     Bitmap = {}
   end
   object LoginDropDownMenu: TPopupMenu
     Images = ActionImageList
     Left = 270
-    Top = 397
+    Top = 421
     object Login1: TMenuItem
       Action = LoginAction
       Default = True
@@ -2196,7 +2207,7 @@ object LoginDialog: TLoginDialog
           49454E44AE426082}
       end>
     Left = 143
-    Top = 461
+    Top = 485
     Bitmap = {}
   end
   object ActionImageList120: TPngImageList
@@ -2599,7 +2610,7 @@ object LoginDialog: TLoginDialog
           399E6C933D3B0000000049454E44AE426082}
       end>
     Left = 145
-    Top = 525
+    Top = 549
     Bitmap = {}
   end
   object SessionImageList144: TPngImageList
@@ -2947,7 +2958,7 @@ object LoginDialog: TLoginDialog
           62FAB43A0000000049454E44AE426082}
       end>
     Left = 271
-    Top = 461
+    Top = 485
     Bitmap = {}
   end
   object SessionImageList192: TPngImageList
@@ -3249,7 +3260,7 @@ object LoginDialog: TLoginDialog
           44AE426082}
       end>
     Left = 399
-    Top = 461
+    Top = 485
     Bitmap = {}
   end
   object ActionImageList144: TPngImageList
@@ -3760,7 +3771,7 @@ object LoginDialog: TLoginDialog
           7E020EF8EA5A9F9886D50000000049454E44AE426082}
       end>
     Left = 270
-    Top = 525
+    Top = 549
     Bitmap = {}
   end
   object ActionImageList192: TPngImageList
@@ -4313,20 +4324,7 @@ object LoginDialog: TLoginDialog
           00000049454E44AE426082}
       end>
     Left = 398
-    Top = 525
+    Top = 549
     Bitmap = {}
   end
-  object CloseDropDownMenu: TPopupMenu
-    Images = ActionImageList
-    Left = 36
-    Top = 397
-    object MenuItem15: TMenuItem
-      Action = CloseAction
-      Default = True
-    end
-    object MenuItem20: TMenuItem
-      Action = NeverShowAgainAction
-      AutoCheck = True
-    end
-  end
 end

+ 3 - 7
source/forms/Login.h

@@ -206,13 +206,10 @@ __published:
   TPngImageList *SessionImageList192;
   TPngImageList *ActionImageList144;
   TPngImageList *ActionImageList192;
-  TPopupMenu *CloseDropDownMenu;
-  TMenuItem *MenuItem15;
-  TMenuItem *MenuItem20;
-  TAction *CloseAction;
-  TAction *NeverShowAgainAction;
   TAction *SessionRawAction;
   TMenuItem *EditRawSettings1;
+  TPanel *ShowAgainPanel;
+  TCheckBox *ShowAgainCheck;
   void __fastcall DataChange(TObject *Sender);
   void __fastcall FormShow(TObject *Sender);
   void __fastcall SessionTreeDblClick(TObject *Sender);
@@ -289,8 +286,7 @@ __published:
   void __fastcall SearchSiteNameStartOnlyActionExecute(TObject *Sender);
   void __fastcall SearchSiteNameActionExecute(TObject *Sender);
   void __fastcall SearchSiteActionExecute(TObject *Sender);
-  void __fastcall ButtonPanelMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y);
-  void __fastcall NeverShowAgainActionExecute(TObject *Sender);
+  void __fastcall PanelMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y);
 
 private:
   int NoUpdate;