Skip to content

Commit f9297d4

Browse files
committed
Use the same hotkey (Ctrl+S) for saving a table/trigger/... as for saving a query file. Closes #1619
1 parent aa2e93a commit f9297d4

6 files changed

Lines changed: 40 additions & 15 deletions

File tree

source/event_editor.pas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ interface
44

55
uses
66
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms,
7-
Vcl.Dialogs, Vcl.StdCtrls, SynEdit, SynMemo, SynRegExpr, Vcl.ComCtrls, Vcl.ExtCtrls, System.WideStrUtils,
7+
Vcl.Dialogs, Vcl.StdCtrls, Vcl.Menus, SynEdit, SynMemo, SynRegExpr, Vcl.ComCtrls, Vcl.ExtCtrls, System.WideStrUtils,
88
apphelpers, dbconnection, dbstructures, gnugettext, extra_controls;
99

1010
type
@@ -81,6 +81,7 @@ constructor TfrmEventEditor.Create(AOwner: TComponent);
8181
'DAY_HOUR|DAY_MINUTE|DAY_SECOND|HOUR_MINUTE|HOUR_SECOND|MINUTE_SECOND');
8282
grpState.Items := Explode('|', 'Enable|Disable|Disable on slave');
8383
FMainSynMemo := SynMemoBody;
84+
btnSave.Hint := ShortCutToText(MainForm.actSaveSQL.ShortCut);
8485
end;
8586

8687

source/main.pas

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5023,18 +5023,37 @@ procedure TMainForm.actSaveSQLAsExecute(Sender: TObject);
50235023
procedure TMainForm.actSaveSQLExecute(Sender: TObject);
50245024
var
50255025
i: Integer;
5026+
ObjEditor: TDBObjectEditor;
5027+
Handled: Boolean;
50265028
begin
5027-
if QueryTabs.ActiveTab.MemoFilename <> '' then begin
5028-
QueryTabs.ActiveTab.SaveContents(QueryTabs.ActiveTab.MemoFilename, False);
5029-
for i:=0 to QueryTabs.Count-1 do begin
5030-
if QueryTabs[i] = QueryTabs.ActiveTab then
5031-
continue;
5032-
if QueryTabs[i].MemoFilename = QueryTabs.ActiveTab.MemoFilename then
5033-
QueryTabs[i].Memo.Modified := True;
5029+
Handled := False;
5030+
if QueryTabs.HasActiveTab then begin
5031+
// Save SQL tab contents to file
5032+
if QueryTabs.ActiveTab.MemoFilename <> '' then begin
5033+
QueryTabs.ActiveTab.SaveContents(QueryTabs.ActiveTab.MemoFilename, False);
5034+
for i:=0 to QueryTabs.Count-1 do begin
5035+
if QueryTabs[i] = QueryTabs.ActiveTab then
5036+
continue;
5037+
if QueryTabs[i].MemoFilename = QueryTabs.ActiveTab.MemoFilename then
5038+
QueryTabs[i].Memo.Modified := True;
5039+
end;
5040+
ValidateQueryControls(Sender);
5041+
end else
5042+
actSaveSQLAsExecute(Sender);
5043+
Handled := True;
5044+
end
5045+
else if PageControlMain.ActivePage = tabEditor then begin
5046+
// Save table, procedure, etc.
5047+
ObjEditor := ActiveObjectEditor;
5048+
if Assigned(ObjEditor) and ObjEditor.Modified then begin
5049+
ObjEditor.ApplyModifications;
5050+
Handled := True;
50345051
end;
5035-
ValidateQueryControls(Sender);
5036-
end else
5037-
actSaveSQLAsExecute(Sender);
5052+
end;
5053+
if not Handled then begin
5054+
MessageBeep(MB_ICONASTERISK);
5055+
end;
5056+
50385057
end;
50395058

50405059

@@ -6585,7 +6604,7 @@ procedure TMainForm.ValidateQueryControls(Sender: TObject);
65856604
NotEmpty, HasSelection, HasConnection: Boolean;
65866605
Tab: TQueryTab;
65876606
cap: String;
6588-
InQueryTab: Boolean;
6607+
InQueryTab, InEditorTab: Boolean;
65896608
Conn: TDBConnection;
65906609
begin
65916610
// Enable/disable TActions, according to the current window/connection state
@@ -6604,6 +6623,7 @@ procedure TMainForm.ValidateQueryControls(Sender: TObject);
66046623
SetTabCaption(Tab.TabSheet.PageIndex, cap);
66056624
end;
66066625
InQueryTab := QueryTabs.HasActiveTab;
6626+
InEditorTab := PageControlMain.ActivePage = tabEditor;
66076627
Tab := QueryTabs.ActiveTab;
66086628
NotEmpty := InQueryTab and (Tab.Memo.GetTextLen > 0);
66096629
HasSelection := InQueryTab and Tab.Memo.SelAvail;
@@ -6614,7 +6634,7 @@ procedure TMainForm.ValidateQueryControls(Sender: TObject);
66146634
actExecuteCurrentQuery.Enabled := actExecuteQuery.Enabled;
66156635
actExplainCurrentQuery.Enabled := actExecuteQuery.Enabled and (Conn.Parameters.NetTypeGroup in [ngMySQL, ngPgSQL, ngSQLite]);
66166636
actSaveSQLAs.Enabled := InQueryTab and NotEmpty;
6617-
actSaveSQL.Enabled := actSaveSQLAs.Enabled and Tab.Memo.Modified;
6637+
actSaveSQL.Enabled := (actSaveSQLAs.Enabled and Tab.Memo.Modified) or InEditorTab;
66186638
actSaveSQLselection.Enabled := InQueryTab and HasSelection;
66196639
actSaveSQLSnippet.Enabled := InQueryTab and NotEmpty;
66206640
actSaveSQLSelectionSnippet.Enabled := InQueryTab and HasSelection;

source/routine_editor.pas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ constructor TfrmRoutineEditor.Create(AOwner: TComponent);
116116
Parameters := TRoutineParamList.Create;
117117
editName.MaxLength := NAME_LEN;
118118
FMainSynMemo := SynMemoBody;
119+
btnSave.Hint := ShortCutToText(MainForm.actSaveSQL.ShortCut);
119120
end;
120121

121122

source/table_editor.pas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ constructor TfrmTableEditor.Create(AOwner: TComponent);
255255
FDeletedCheckConstraints.Duplicates := dupIgnore;
256256
editName.MaxLength := NAME_LEN;
257257
FAlterRestrictedMessageDisplayed := False;
258+
btnSave.Hint := ShortCutToText(MainForm.actSaveSQL.ShortCut);
258259
end;
259260

260261

source/trigger_editor.pas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
interface
44

55
uses
6-
Winapi.Windows, System.SysUtils, System.Classes, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, SynEdit, SynMemo,
6+
Winapi.Windows, System.SysUtils, System.Classes, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Menus, SynEdit, SynMemo,
77
SynCompletionProposal, SynRegExpr,
88
dbconnection, dbstructures, dbstructures.mysql, apphelpers, gnugettext, Vcl.ComCtrls, extra_controls;
99

@@ -78,6 +78,7 @@ constructor TfrmTriggerEditor.Create(AOwner: TComponent);
7878
SynCompletionProposalStatement.TimerInterval := Mainform.SynCompletionProposal.TimerInterval;
7979
SynCompletionProposalStatement.Margin := Mainform.SynCompletionProposal.Margin;
8080
FMainSynMemo := SynMemoBody;
81+
btnSave.Hint := ShortCutToText(MainForm.actSaveSQL.ShortCut);
8182
end;
8283

8384

source/view.pas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ interface
44

55
uses
66
Winapi.Windows, System.SysUtils, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, SynEdit, SynMemo,
7-
Vcl.ExtCtrls,
7+
Vcl.ExtCtrls, Vcl.Menus,
88
dbconnection, dbstructures, dbstructures.mysql, apphelpers, gnugettext, Vcl.ComCtrls, extra_controls;
99

1010
type
@@ -66,6 +66,7 @@ constructor TfrmView.Create(AOwner: TComponent);
6666
comboSecurity.Items.Add('Definer');
6767
comboSecurity.Items.Add('Invoker');
6868
FMainSynMemo := SynMemoBody;
69+
btnSave.Hint := ShortCutToText(MainForm.actSaveSQL.ShortCut);
6970
end;
7071

7172

0 commit comments

Comments
 (0)