IDE: Improved Search Results dialog behavior:

1. Always bring Search Results to front on Ctrl-Alt-F (or if called via menu).
     2. Bring Search Results to front if Search Progress dialog was active (had focus).
     3. Do not bring Search Results to front if Search Progress dialog was not active.

git-svn-id: trunk@39520 -
This commit is contained in:
maxim 2012-12-12 19:51:53 +00:00
parent 48fa6760da
commit fce81aa63d
4 changed files with 41 additions and 22 deletions

View File

@ -969,7 +969,7 @@ type
// search results // search results
function DoJumpToSearchResult(FocusEditor: boolean): boolean; function DoJumpToSearchResult(FocusEditor: boolean): boolean;
procedure DoShowSearchResultsView(Show: boolean); override; procedure DoShowSearchResultsView(Show: boolean; BringToFront: boolean = False); override;
// form editor and designer // form editor and designer
procedure DoBringToFrontFormOrUnit; procedure DoBringToFrontFormOrUnit;
@ -3960,7 +3960,8 @@ end;
procedure TMainIDE.mnuViewSearchResultsClick(Sender: TObject); procedure TMainIDE.mnuViewSearchResultsClick(Sender: TObject);
Begin Begin
DoShowSearchResultsView(true); // show and bring to front
DoShowSearchResultsView(true, true);
End; End;
procedure TMainIDE.mnuNewProjectClicked(Sender: TObject); procedure TMainIDE.mnuNewProjectClicked(Sender: TObject);
@ -9143,7 +9144,7 @@ begin
SourceEditorManager.ShowActiveWindowOnTop(False); SourceEditorManager.ShowActiveWindowOnTop(False);
end; end;
procedure TMainIDE.DoShowSearchResultsView(Show: boolean); procedure TMainIDE.DoShowSearchResultsView(Show: boolean; BringToFront: boolean = False);
begin begin
if SearchresultsView=Nil then begin if SearchresultsView=Nil then begin
SearchresultsView:=TSearchResultsView.Create(OwningComponent); SearchresultsView:=TSearchResultsView.Create(OwningComponent);
@ -9152,7 +9153,8 @@ begin
if Show then begin if Show then begin
IDEWindowCreators.ShowForm(SearchresultsView,Show); IDEWindowCreators.ShowForm(SearchresultsView,Show);
// the sourcenotebook is more interesting than the search results // the sourcenotebook is more interesting than the search results
SourceEditorManager.ShowActiveWindowOnTop(False); if BringToFront = false then
SourceEditorManager.ShowActiveWindowOnTop(False);
end; end;
end; end;

View File

@ -7,8 +7,10 @@ object SearchProgressForm: TSearchProgressForm
ClientHeight = 167 ClientHeight = 167
ClientWidth = 700 ClientWidth = 700
Constraints.MinWidth = 700 Constraints.MinWidth = 700
OnClose = FormClose
OnCreate = SearchFormCREATE OnCreate = SearchFormCREATE
OnDestroy = SearchFormDESTROY OnDestroy = SearchFormDESTROY
OnShow = FormShow
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '1.1' LCLVersion = '1.1'
Visible = True Visible = True
@ -29,7 +31,7 @@ object SearchProgressForm: TSearchProgressForm
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 121 Left = 121
Height = 1 Height = 1
Top = 98 Top = 88
Width = 1 Width = 1
ParentColor = False ParentColor = False
ShowAccelChar = False ShowAccelChar = False
@ -38,9 +40,9 @@ object SearchProgressForm: TSearchProgressForm
AnchorSideTop.Control = SearchingLabel AnchorSideTop.Control = SearchingLabel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 Left = 16
Height = 17 Height = 13
Top = 90 Top = 82
Width = 54 Width = 40
BorderSpacing.Top = 18 BorderSpacing.Top = 18
Caption = 'Matches' Caption = 'Matches'
ParentColor = False ParentColor = False
@ -50,7 +52,7 @@ object SearchProgressForm: TSearchProgressForm
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 121 Left = 121
Height = 1 Height = 1
Top = 63 Top = 57
Width = 1 Width = 1
ParentColor = False ParentColor = False
ShowAccelChar = False ShowAccelChar = False
@ -59,9 +61,9 @@ object SearchProgressForm: TSearchProgressForm
AnchorSideTop.Control = SearchTextLabel AnchorSideTop.Control = SearchTextLabel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 Left = 16
Height = 17 Height = 13
Top = 55 Top = 51
Width = 68 Width = 51
BorderSpacing.Top = 18 BorderSpacing.Top = 18
Caption = 'Searching:' Caption = 'Searching:'
ParentColor = False ParentColor = False
@ -69,9 +71,9 @@ object SearchProgressForm: TSearchProgressForm
object SearchTextLabel: TLabel object SearchTextLabel: TLabel
AnchorSideTop.Control = Panel2 AnchorSideTop.Control = Panel2
Left = 16 Left = 16
Height = 17 Height = 13
Top = 20 Top = 20
Width = 78 Width = 62
BorderSpacing.Top = 18 BorderSpacing.Top = 18
Caption = 'Search Text:' Caption = 'Search Text:'
ParentColor = False ParentColor = False
@ -81,7 +83,7 @@ object SearchProgressForm: TSearchProgressForm
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 121 Left = 121
Height = 1 Height = 1
Top = 28 Top = 26
Width = 1 Width = 1
ParentColor = False ParentColor = False
ShowAccelChar = False ShowAccelChar = False
@ -93,10 +95,10 @@ object SearchProgressForm: TSearchProgressForm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel2 AnchorSideBottom.Control = Panel2
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 306 Left = 312
Height = 31 Height = 26
Top = 128 Top = 133
Width = 89 Width = 77
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Top = 12 BorderSpacing.Top = 12

View File

@ -54,6 +54,8 @@ type
lblProgress: TLABEL; lblProgress: TLABEL;
lblSearchText: TLABEL; lblSearchText: TLABEL;
Panel2: TPANEL; Panel2: TPANEL;
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormShow(Sender: TObject);
procedure OnAddMatch(const Filename: string; const StartPos, EndPos: TPoint; procedure OnAddMatch(const Filename: string; const StartPos, EndPos: TPoint;
const Lines: string); const Lines: string);
procedure SearchFormCREATE(Sender: TObject); procedure SearchFormCREATE(Sender: TObject);
@ -81,6 +83,7 @@ type
fSearchProject: boolean; fSearchProject: boolean;
fAborting: boolean; fAborting: boolean;
fLastUpdateProgress: DWORD; fLastUpdateProgress: DWORD;
fWasActive: boolean;
procedure DoFindInFiles(ADirectory: string); procedure DoFindInFiles(ADirectory: string);
procedure DoFindInSearchList; procedure DoFindInSearchList;
procedure SetResultsList(const AValue: TStrings); procedure SetResultsList(const AValue: TStrings);
@ -639,6 +642,7 @@ begin
fSearchProject:= false; fSearchProject:= false;
fSearchOpen:= false; fSearchOpen:= false;
fSearchFiles:= false; fSearchFiles:= false;
fWasActive:= false;
end; end;
procedure TSearchProgressForm.OnAddMatch(const Filename: string; const StartPos, procedure TSearchProgressForm.OnAddMatch(const Filename: string; const StartPos,
@ -661,6 +665,17 @@ begin
UpdateMatches; UpdateMatches;
end; end;
procedure TSearchProgressForm.FormClose(Sender: TObject; var CloseAction:
TCloseAction);
begin
fWasActive:= Active;
end;
procedure TSearchProgressForm.FormShow(Sender: TObject);
begin
fWasActive:= true;
end;
procedure TSearchProgressForm.SearchFormDESTROY(Sender: TObject); procedure TSearchProgressForm.SearchFormDESTROY(Sender: TObject);
begin begin
FreeAndNil(fProgress); FreeAndNil(fProgress);
@ -926,8 +941,8 @@ begin
finally finally
ListPage.Caption:= Format('%s (%d)',[ListPage.Caption,Cnt]); ListPage.Caption:= Format('%s (%d)',[ListPage.Caption,Cnt]);
SearchResultsView.EndUpdate(ListPage.PageIndex); SearchResultsView.EndUpdate(ListPage.PageIndex);
// bring to front // show, but bring to front only if Search Progress dialog was active
IDEWindowCreators.ShowForm(SearchResultsView,true); LazarusIDE.DoShowSearchResultsView(True, fWasActive);
end; end;
end; end;

View File

@ -299,7 +299,7 @@ type
procedure AbortBuild; virtual; abstract; procedure AbortBuild; virtual; abstract;
// search results // search results
procedure DoShowSearchResultsView(Show: boolean); virtual; abstract; procedure DoShowSearchResultsView(Show: boolean; BringToFront: boolean = False); virtual; abstract;
// designer // designer
function GetDesignerForProjectEditor(AEditor: TSourceEditorInterface; function GetDesignerForProjectEditor(AEditor: TSourceEditorInterface;