mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 11:17:57 +08:00
Issue #12: Provide file pick icon in SQLite database file edit box. Database file is created by sqlite3_open() silently if it does not yet exist. Show a confirmation message in such cases.
This commit is contained in:
@ -259,15 +259,19 @@ object connform: Tconnform
|
|||||||
OnChange = Modification
|
OnChange = Modification
|
||||||
OnExit = editTrim
|
OnExit = editTrim
|
||||||
end
|
end
|
||||||
object editHost: TEdit
|
object editHost: TButtonedEdit
|
||||||
Left = 120
|
Left = 120
|
||||||
Top = 73
|
Top = 73
|
||||||
Width = 294
|
Width = 294
|
||||||
Height = 21
|
Height = 21
|
||||||
Anchors = [akLeft, akTop, akRight]
|
Anchors = [akLeft, akTop, akRight]
|
||||||
|
Images = MainForm.VirtualImageListMain
|
||||||
|
RightButton.ImageIndex = 51
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
OnChange = editHostChange
|
OnChange = editHostChange
|
||||||
|
OnDblClick = editHostDblClick
|
||||||
OnExit = editTrim
|
OnExit = editTrim
|
||||||
|
OnRightButtonClick = PickFile
|
||||||
end
|
end
|
||||||
object comboNetType: TComboBox
|
object comboNetType: TComboBox
|
||||||
Left = 120
|
Left = 120
|
||||||
|
@ -37,7 +37,7 @@ type
|
|||||||
updownPort: TUpDown;
|
updownPort: TUpDown;
|
||||||
editPassword: TEdit;
|
editPassword: TEdit;
|
||||||
editUsername: TEdit;
|
editUsername: TEdit;
|
||||||
editHost: TEdit;
|
editHost: TButtonedEdit;
|
||||||
tabAdvanced: TTabSheet;
|
tabAdvanced: TTabSheet;
|
||||||
lblSSLPrivateKey: TLabel;
|
lblSSLPrivateKey: TLabel;
|
||||||
lblSSLCACertificate: TLabel;
|
lblSSLCACertificate: TLabel;
|
||||||
@ -176,6 +176,7 @@ type
|
|||||||
procedure editTrim(Sender: TObject);
|
procedure editTrim(Sender: TObject);
|
||||||
procedure editSearchChange(Sender: TObject);
|
procedure editSearchChange(Sender: TObject);
|
||||||
procedure editSearchRightButtonClick(Sender: TObject);
|
procedure editSearchRightButtonClick(Sender: TObject);
|
||||||
|
procedure editHostDblClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ Private declarations }
|
{ Private declarations }
|
||||||
FLoaded: Boolean;
|
FLoaded: Boolean;
|
||||||
@ -356,15 +357,29 @@ end;
|
|||||||
procedure Tconnform.btnOpenClick(Sender: TObject);
|
procedure Tconnform.btnOpenClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
Connection: TDBConnection;
|
Connection: TDBConnection;
|
||||||
|
Params: TConnectionParameters;
|
||||||
|
Msg: String;
|
||||||
|
DoCreateDb: Integer;
|
||||||
begin
|
begin
|
||||||
// Connect to selected session
|
// Connect to selected session
|
||||||
|
Params := CurrentParams;
|
||||||
|
|
||||||
|
if (CurrentParams.NetType = ntSQLite)
|
||||||
|
and (not FileExists(CurrentParams.Hostname))
|
||||||
|
then begin
|
||||||
|
Msg := f_('Database file "%s" does not exist. Shall it be created now?', [Params.Hostname]);
|
||||||
|
DoCreateDb := MessageDialog(Msg, mtConfirmation, [mbNo, mbYes]);
|
||||||
|
if DoCreateDb = mrNo then
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
if not btnOpen.Enabled then
|
if not btnOpen.Enabled then
|
||||||
Exit;
|
Exit;
|
||||||
btnOpen.Enabled := False;
|
btnOpen.Enabled := False;
|
||||||
FButtonAnimationStep := 0;
|
FButtonAnimationStep := 0;
|
||||||
TimerButtonAnimation.Enabled := True;
|
TimerButtonAnimation.Enabled := True;
|
||||||
Screen.Cursor := crHourglass;
|
Screen.Cursor := crHourglass;
|
||||||
if Mainform.InitConnection(CurrentParams, True, Connection) then
|
if Mainform.InitConnection(Params, True, Connection) then
|
||||||
ModalResult := mrOK
|
ModalResult := mrOK
|
||||||
else begin
|
else begin
|
||||||
TimerStatistics.OnTimer(Sender);
|
TimerStatistics.OnTimer(Sender);
|
||||||
@ -1004,6 +1019,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure Tconnform.editHostDblClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if CurrentParams.NetType = ntSQLite then
|
||||||
|
PickFile(Sender);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure Tconnform.editTrim(Sender: TObject);
|
procedure Tconnform.editTrim(Sender: TObject);
|
||||||
var
|
var
|
||||||
Edit: TCustomEdit;
|
Edit: TCustomEdit;
|
||||||
@ -1244,10 +1265,19 @@ begin
|
|||||||
|
|
||||||
if SessionFocused then begin
|
if SessionFocused then begin
|
||||||
// Validate session GUI stuff
|
// Validate session GUI stuff
|
||||||
if Params.NetType = ntMySQL_NamedPipe then
|
editHost.RightButton.Visible := False;
|
||||||
lblHost.Caption := _('Socket name:')
|
case Params.NetType of
|
||||||
else
|
ntMySQL_NamedPipe: begin
|
||||||
|
lblHost.Caption := _('Socket name:');
|
||||||
|
end;
|
||||||
|
ntSQLite: begin
|
||||||
|
lblHost.Caption := _('Database filename')+':';
|
||||||
|
editHost.RightButton.Visible := True;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
lblHost.Caption := _('Hostname / IP:');
|
lblHost.Caption := _('Hostname / IP:');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
chkWindowsAuth.Enabled := Params.IsMSSQL;
|
chkWindowsAuth.Enabled := Params.IsMSSQL;
|
||||||
chkCleartextPluginEnabled.Enabled := Params.IsMySQL;
|
chkCleartextPluginEnabled.Enabled := Params.IsMySQL;
|
||||||
lblUsername.Enabled := ((not chkLoginPrompt.Checked) or (not chkLoginPrompt.Enabled))
|
lblUsername.Enabled := ((not chkLoginPrompt.Checked) or (not chkLoginPrompt.Enabled))
|
||||||
@ -1329,7 +1359,9 @@ begin
|
|||||||
Edit := Sender as TButtonedEdit;
|
Edit := Sender as TButtonedEdit;
|
||||||
Selector := TOpenDialog.Create(Self);
|
Selector := TOpenDialog.Create(Self);
|
||||||
Selector.FileName := editStartupScript.Text;
|
Selector.FileName := editStartupScript.Text;
|
||||||
if Edit = editStartupScript then
|
if Edit = editHost then
|
||||||
|
Selector.Filter := 'SQLite databases (*.sqlite3;*.db;*.s3db)|*.sqlite3;*.db;*.s3db|'+_('All files')+' (*.*)|*.*'
|
||||||
|
else if Edit = editStartupScript then
|
||||||
Selector.Filter := _('SQL files')+' (*.sql)|*.sql|'+_('All files')+' (*.*)|*.*'
|
Selector.Filter := _('SQL files')+' (*.sql)|*.sql|'+_('All files')+' (*.*)|*.*'
|
||||||
else if Edit = editSSHPlinkExe then
|
else if Edit = editSSHPlinkExe then
|
||||||
Selector.Filter := _('Executables')+' (*.exe)|*.exe|'+_('All files')+' (*.*)|*.*'
|
Selector.Filter := _('Executables')+' (*.exe)|*.exe|'+_('All files')+' (*.*)|*.*'
|
||||||
@ -1345,6 +1377,8 @@ begin
|
|||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
if Edit = editHost then
|
||||||
|
Selector.Options := Selector.Options - [ofFileMustExist];
|
||||||
|
|
||||||
if Selector.Execute then begin
|
if Selector.Execute then begin
|
||||||
// Remove path if it's the application directory
|
// Remove path if it's the application directory
|
||||||
|
Reference in New Issue
Block a user