Permalink
Browse files

Add an "import settings" button onto the empty default session manage…

…r. Fixes issue #2749.

git-svn-id: http://heidisql.googlecode.com/svn/trunk@4118 560a3889-bb33-0410-9f33-43a8a102dc09
  • Loading branch information...
1 parent 682b0e7 commit b7192dfffc34006c577e1e47cde426f4992e3288 ansgar.becker committed Mar 29, 2012
Showing with 66 additions and 13 deletions.
  1. +18 −2 source/connections.dfm
  2. +48 −11 source/connections.pas
@@ -178,16 +178,26 @@ object connform: Tconnform
Left = 10
Top = 10
Width = 275
- Height = 245
+ Height = 161
Margins.Left = 10
Margins.Top = 10
Margins.Right = 10
Margins.Bottom = 10
- Align = alClient
+ Align = alTop
AutoSize = False
Caption = 'lblHelp'
WordWrap = True
end
+ object btnImportSettings: TButton
+ Left = 10
+ Top = 184
+ Width = 119
+ Height = 25
+ Caption = 'Import settings ...'
+ ImageIndex = 101
+ TabOrder = 0
+ OnClick = btnImportSettingsClick
+ end
end
object tabSettings: TTabSheet
Caption = 'Settings'
@@ -726,4 +736,10 @@ object connform: Tconnform
Left = 48
Top = 35
end
+ object timerSettingsImport: TTimer
+ Enabled = False
+ OnTimer = timerSettingsImportTimer
+ Left = 88
+ Top = 32
+ end
end
@@ -82,6 +82,8 @@ Tconnform = class(TForm)
tabStart: TTabSheet;
lblHelp: TLabel;
chkWantSSL: TCheckBox;
+ btnImportSettings: TButton;
+ timerSettingsImport: TTimer;
procedure FormCreate(Sender: TObject);
procedure btnOpenClick(Sender: TObject);
procedure FormShow(Sender: TObject);
@@ -120,12 +122,16 @@ Tconnform = class(TForm)
var NodeDataSize: Integer);
procedure comboNetTypeChange(Sender: TObject);
procedure splitterMainMoved(Sender: TObject);
+ procedure btnImportSettingsClick(Sender: TObject);
+ procedure timerSettingsImportTimer(Sender: TObject);
private
{ Private declarations }
FLoaded: Boolean;
FSessions: TObjectList<TConnectionParameters>;
FSessionModified, FOnlyPasswordModified, FSessionAdded: Boolean;
FServerVersion: String;
+ FSettingsImportWaitTime: Cardinal;
+ procedure SetSessions;
function SelectedSession: String;
function CurrentParams: TConnectionParameters;
procedure FinalizeModifications(var CanProceed: Boolean);
@@ -148,11 +154,9 @@ implementation
procedure Tconnform.FormCreate(Sender: TObject);
var
LastActiveSession: String;
- SessionNames, LastSessions: TStringList;
- Sess: TConnectionParameters;
+ LastSessions: TStringList;
PSess: PConnectionParameters;
hSysMenu: THandle;
- i: Integer;
nt: TNetType;
Node: PVirtualNode;
Params: TConnectionParameters;
@@ -169,6 +173,7 @@ procedure Tconnform.FormCreate(Sender: TObject);
ListSessions.OnCompareNodes := MainForm.AnyGridCompareNodes;
ListSessions.OnHeaderClick := MainForm.AnyGridHeaderClick;
ListSessions.OnHeaderDraggedOut := MainForm.AnyGridHeaderDraggedOut;
+ btnImportSettings.Caption := MainForm.actImportSettings.Caption;
FLoaded := False;
comboNetType.Clear;
@@ -178,14 +183,7 @@ procedure Tconnform.FormCreate(Sender: TObject);
Params.Free;
FSessions := TObjectList<TConnectionParameters>.Create;
- SessionNames := TStringList.Create;
- MainReg.OpenKey(RegPath + REGKEY_SESSIONS, True);
- MainReg.GetKeyNames(SessionNames);
- for i:=0 to SessionNames.Count-1 do begin
- Sess := TConnectionParameters.ReadFromRegistry(SessionNames[i]);
- FSessions.Add(Sess);
- end;
- ListSessions.RootNodeCount := FSessions.Count;
+ SetSessions;
// Focus last session
SelectNode(ListSessions, nil);
@@ -210,6 +208,24 @@ procedure Tconnform.FormCreate(Sender: TObject);
end;
+procedure Tconnform.SetSessions;
+var
+ SessionNames: TStringList;
+ i: Integer;
+ Sess: TConnectionParameters;
+begin
+ // Initialize session tree
+ SessionNames := TStringList.Create;
+ MainReg.OpenKey(RegPath + REGKEY_SESSIONS, True);
+ MainReg.GetKeyNames(SessionNames);
+ for i:=0 to SessionNames.Count-1 do begin
+ Sess := TConnectionParameters.ReadFromRegistry(SessionNames[i]);
+ FSessions.Add(Sess);
+ end;
+ ListSessions.RootNodeCount := FSessions.Count;
+end;
+
+
procedure Tconnform.FormDestroy(Sender: TObject);
begin
// Save GUI stuff
@@ -361,6 +377,27 @@ procedure Tconnform.btnSaveAsClick(Sender: TObject);
end;
+procedure Tconnform.btnImportSettingsClick(Sender: TObject);
+begin
+ MainForm.actImportSettings.Execute;
+ FSettingsImportWaitTime := 0;
+ timerSettingsImport.Enabled := True;
+end;
+
+
+procedure Tconnform.timerSettingsImportTimer(Sender: TObject);
+begin
+ Inc(FSettingsImportWaitTime, timerSettingsImport.Interval);
+ SetSessions;
+ if FSessions.Count > 0 then
+ timerSettingsImport.Enabled := False;
+ if FSettingsImportWaitTime >= 10000 then begin
+ timerSettingsImport.Enabled := False;
+ MessageDialog('Imported sessions could not be detected. Restarting HeidiSQL may solve that.', mtWarning, [mbOK]);
+ end;
+end;
+
+
procedure Tconnform.btnNewClick(Sender: TObject);
var
i: Integer;

0 comments on commit b7192df

Please sign in to comment.