فهرست منبع

ADD: Search results PopupMenu items: Open in new tab, Open in Editor(need locale); UPD: Search results selection

meteu 9 سال پیش
والد
کامیت
9fceb69ef2
3فایلهای تغییر یافته به همراه173 افزوده شده و 89 حذف شده
  1. 74 66
      src/fFindDlg.lfm
  2. 2 0
      src/fFindDlg.lrt
  3. 97 23
      src/fFindDlg.pas

+ 74 - 66
src/fFindDlg.lfm

@@ -1,7 +1,7 @@
 object frmFindDlg: TfrmFindDlg
-  Left = 294
+  Left = 413
   Height = 397
-  Top = 232
+  Top = 226
   Width = 839
   Caption = 'Find files'
   ClientHeight = 397
@@ -489,8 +489,8 @@ object frmFindDlg: TfrmFindDlg
         Caption = 'Advanced'
         ChildSizing.LeftRightSpacing = 3
         ChildSizing.TopBottomSpacing = 3
-        ClientHeight = 352
-        ClientWidth = 717
+        ClientHeight = 363
+        ClientWidth = 716
         ImageIndex = 1
         object cbDateFrom: TCheckBox
           AnchorSideLeft.Control = tsAdvanced
@@ -531,7 +531,7 @@ object frmFindDlg: TfrmFindDlg
           Left = 3
           Height = 23
           Top = 37
-          Width = 79
+          Width = 83
           Anchors = [akTop, akLeft, akRight, akBottom]
           MaxValue = 999999999
           OnChange = seNotOlderThanChange
@@ -543,10 +543,10 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideTop.Side = asrBottom
           AnchorSideRight.Control = ZVDateTo
           AnchorSideRight.Side = asrBottom
-          Left = 112
+          Left = 116
           Height = 23
           Top = 37
-          Width = 79
+          Width = 83
           Anchors = [akTop, akLeft, akRight]
           Enabled = False
           ItemHeight = 15
@@ -570,7 +570,7 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideLeft.Control = ZVDateTo
           AnchorSideTop.Control = cbDateFrom
           AnchorSideTop.Side = asrCenter
-          Left = 112
+          Left = 116
           Height = 19
           Top = 127
           Width = 61
@@ -582,7 +582,7 @@ object frmFindDlg: TfrmFindDlg
         object cbFileSizeTo: TCheckBox
           AnchorSideLeft.Control = ZVDateTo
           AnchorSideTop.Control = cbFileSizeFrom
-          Left = 112
+          Left = 116
           Height = 19
           Top = 72
           Width = 57
@@ -601,7 +601,7 @@ object frmFindDlg: TfrmFindDlg
           Left = 3
           Height = 23
           Top = 91
-          Width = 79
+          Width = 83
           Anchors = [akTop, akLeft, akRight, akBottom]
           MaxValue = 2147483647
           OnChange = seFileSizeFromChange
@@ -615,10 +615,10 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideRight.Side = asrBottom
           AnchorSideBottom.Control = cmbFileSizeUnit
           AnchorSideBottom.Side = asrBottom
-          Left = 112
+          Left = 116
           Height = 23
           Top = 91
-          Width = 79
+          Width = 83
           Anchors = [akTop, akLeft, akRight, akBottom]
           MaxValue = 2147483647
           OnChange = seFileSizeToChange
@@ -630,7 +630,7 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideTop.Side = asrBottom
           AnchorSideRight.Control = ZVTimeTo
           AnchorSideRight.Side = asrBottom
-          Left = 221
+          Left = 229
           Height = 23
           Top = 91
           Width = 160
@@ -644,7 +644,7 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideLeft.Control = ZVTimeFrom
           AnchorSideTop.Control = cbDateFrom
           AnchorSideTop.Side = asrCenter
-          Left = 221
+          Left = 229
           Height = 19
           Top = 127
           Width = 79
@@ -657,7 +657,7 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideLeft.Control = ZVTimeTo
           AnchorSideTop.Control = cbDateFrom
           AnchorSideTop.Side = asrCenter
-          Left = 316
+          Left = 324
           Height = 19
           Top = 127
           Width = 64
@@ -689,7 +689,7 @@ object frmFindDlg: TfrmFindDlg
           Left = 3
           Height = 23
           Top = 146
-          Width = 79
+          Width = 83
           CenturyFrom = 1941
           MaxDate = 2958465
           MinDate = -53780
@@ -712,10 +712,10 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideLeft.Side = asrBottom
           AnchorSideTop.Control = ZVDateFrom
           AnchorSideTop.Side = asrCenter
-          Left = 112
+          Left = 116
           Height = 23
           Top = 146
-          Width = 79
+          Width = 83
           CenturyFrom = 1941
           MaxDate = 2958465
           MinDate = -53780
@@ -739,7 +739,7 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideTop.Control = ZVDateFrom
           AnchorSideBottom.Control = ZVDateFrom
           AnchorSideBottom.Side = asrBottom
-          Left = 221
+          Left = 229
           Height = 23
           Top = 146
           Width = 65
@@ -767,7 +767,7 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideTop.Control = ZVDateFrom
           AnchorSideBottom.Control = ZVDateFrom
           AnchorSideBottom.Side = asrBottom
-          Left = 316
+          Left = 324
           Height = 23
           Top = 146
           Width = 65
@@ -794,9 +794,9 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideTop.Control = Bevel2
           AnchorSideTop.Side = asrBottom
           Left = 3
-          Height = 16
+          Height = 15
           Top = 193
-          Width = 53
+          Width = 52
           BorderSpacing.Left = 3
           BorderSpacing.Top = 8
           Caption = 'Attri&butes'
@@ -810,7 +810,7 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideRight.Control = btnAddAttribute
           Left = 3
           Height = 23
-          Top = 213
+          Top = 212
           Width = 600
           HelpType = htKeyword
           HelpKeyword = '/findfiles.html#attributes'
@@ -830,7 +830,7 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideRight.Control = btnAttrsHelp
           Left = 606
           Height = 26
-          Top = 211
+          Top = 210
           Width = 48
           Anchors = [akTop, akRight]
           AutoSize = True
@@ -849,7 +849,7 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideBottom.Side = asrBottom
           Left = 657
           Height = 27
-          Top = 211
+          Top = 210
           Width = 53
           Anchors = [akTop, akRight]
           AutoSize = True
@@ -865,16 +865,16 @@ object frmFindDlg: TfrmFindDlg
         Caption = 'Plugins'
         ChildSizing.LeftRightSpacing = 3
         ChildSizing.TopBottomSpacing = 3
-        ClientHeight = 352
-        ClientWidth = 717
+        ClientHeight = 363
+        ClientWidth = 716
         object cbUsePlugin: TCheckBox
           AnchorSideLeft.Control = tsPlugins
           AnchorSideTop.Control = cmbPlugin
           AnchorSideTop.Side = asrCenter
           Left = 3
-          Height = 21
-          Top = 13
-          Width = 131
+          Height = 19
+          Top = 12
+          Width = 116
           Caption = '&Use search plugin:'
           OnChange = cbUsePluginChange
           TabOrder = 0
@@ -885,10 +885,10 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideTop.Control = tsPlugins
           AnchorSideRight.Control = tsPlugins
           AnchorSideRight.Side = asrBottom
-          Left = 137
+          Left = 122
           Height = 23
           Top = 10
-          Width = 577
+          Width = 591
           Anchors = [akTop, akLeft, akRight]
           BorderSpacing.Left = 3
           BorderSpacing.Top = 10
@@ -905,42 +905,42 @@ object frmFindDlg: TfrmFindDlg
           AnchorSideBottom.Control = tsPlugins
           AnchorSideBottom.Side = asrBottom
           Left = 6
-          Height = 303
-          Top = 43
-          Width = 705
+          Height = 318
+          Top = 39
+          Width = 704
           Anchors = [akTop, akLeft, akRight, akBottom]
           BorderSpacing.Left = 6
           BorderSpacing.Top = 6
           BorderSpacing.Right = 6
           BorderSpacing.Bottom = 6
-          ClientHeight = 303
-          ClientWidth = 705
+          ClientHeight = 318
+          ClientWidth = 704
           TabOrder = 2
           inherited pnlTable: TScrollBox
-            Height = 186
-            Width = 705
+            Height = 203
+            Width = 704
           end
           inherited pnlButtons: TPanel
-            Top = 253
-            Width = 705
-            ClientWidth = 705
+            Top = 268
+            Width = 704
+            ClientWidth = 704
           end
           inherited HeaderControl: THeaderControl
-            Width = 705
+            Width = 704
           end
           inherited pnlHeader: TPanel
-            Width = 705
-            ClientWidth = 705
+            Width = 704
+            ClientWidth = 704
             inherited chkUsePlugins: TCheckBox
-              Width = 297
+              Width = 300
             end
             inherited rbAnd: TRadioButton
-              Left = 303
+              Left = 306
               Width = 198
             end
             inherited rbOr: TRadioButton
-              Left = 507
-              Width = 198
+              Left = 510
+              Width = 194
             end
           end
         end
@@ -949,14 +949,14 @@ object frmFindDlg: TfrmFindDlg
         Caption = 'Load/Save'
         ChildSizing.LeftRightSpacing = 3
         ChildSizing.TopBottomSpacing = 3
-        ClientHeight = 352
-        ClientWidth = 717
+        ClientHeight = 363
+        ClientWidth = 716
         OnShow = tsLoadSaveShow
         object lblTemplateHeader: TLabel
           Left = 3
-          Height = 13
+          Height = 15
           Top = 3
-          Width = 715
+          Width = 710
           Align = alTop
           BorderSpacing.Left = 3
           BorderSpacing.Top = 3
@@ -967,9 +967,9 @@ object frmFindDlg: TfrmFindDlg
         end
         object lbSearchTemplates: TListBox
           Left = 3
-          Height = 275
-          Top = 16
-          Width = 715
+          Height = 279
+          Top = 18
+          Width = 710
           Align = alClient
           BorderSpacing.Left = 3
           BorderSpacing.Right = 3
@@ -983,8 +983,8 @@ object frmFindDlg: TfrmFindDlg
         object lblSearchContents: TPanel
           Left = 3
           Height = 21
-          Top = 297
-          Width = 715
+          Top = 303
+          Width = 710
           Align = alBottom
           Alignment = taLeftJustify
           AutoSize = True
@@ -998,26 +998,26 @@ object frmFindDlg: TfrmFindDlg
         object pnlLoadSaveBottom: TPanel
           Left = 3
           Height = 30
-          Top = 324
-          Width = 715
+          Top = 330
+          Width = 710
           Align = alBottom
           AutoSize = True
           BorderSpacing.Around = 3
           BevelOuter = bvNone
           ClientHeight = 30
-          ClientWidth = 715
+          ClientWidth = 710
           TabOrder = 2
           object pnlLoadSaveBottomButtons: TPanel
-            Left = 332
+            Left = 300
             Height = 30
             Top = 0
-            Width = 383
+            Width = 410
             Align = alRight
             AutoSize = True
             BevelOuter = bvNone
             ChildSizing.Layout = cclTopToBottomThenLeftToRight
             ClientHeight = 30
-            ClientWidth = 383
+            ClientWidth = 410
             TabOrder = 0
             object btnSearchLoad: TButton
               Left = 0
@@ -1049,7 +1049,7 @@ object frmFindDlg: TfrmFindDlg
               Height = 30
               Hint = 'If saved then "Start in directory" will be restored when loading template. Use it if you want to fix searching to a certain directory'
               Top = 0
-              Width = 149
+              Width = 176
               AutoSize = True
               BorderSpacing.Left = 3
               BorderSpacing.Right = 3
@@ -1061,7 +1061,7 @@ object frmFindDlg: TfrmFindDlg
               TabOrder = 2
             end
             object btnSearchDelete: TButton
-              Left = 308
+              Left = 335
               Height = 30
               Top = 0
               Width = 75
@@ -1356,10 +1356,18 @@ object frmFindDlg: TfrmFindDlg
   end
   object PopupMenuFind: TPopupMenu
     left = 336
+    object miOpenInNewTab: TMenuItem
+      Caption = 'Open In New Tab(s)'
+      OnClick = miOpenInNewTabClick
+    end
     object miShowInViewer: TMenuItem
       Caption = 'Show In Viewer'
       OnClick = miShowInViewerClick
     end
+    object miShowInEditor: TMenuItem
+      Caption = 'Show In Editor'
+      OnClick = miShowInEditorClick
+    end
     object miRemoveFromLlist: TMenuItem
       Caption = 'Remove from list'
       OnClick = miRemoveFromLlistClick

+ 2 - 0
src/fFindDlg.lrt

@@ -55,6 +55,8 @@ TFRMFINDDLG.BTNSTOP.CAPTION=C&ancel
 TFRMFINDDLG.BTNCLOSE.CAPTION=&Close
 TFRMFINDDLG.BTNNEWSEARCH.CAPTION=&New search
 TFRMFINDDLG.BTNLASTSEARCH.CAPTION=&Last search
+TFRMFINDDLG.MIOPENINNEWTAB.CAPTION=Open In New Tab(s)
 TFRMFINDDLG.MISHOWINVIEWER.CAPTION=Show In Viewer
+TFRMFINDDLG.MISHOWINEDITOR.CAPTION=Show In Editor
 TFRMFINDDLG.MIREMOVEFROMLLIST.CAPTION=Remove from list
 TFRMFINDDLG.MISHOWALLFOUND.CAPTION=Show all found items

+ 97 - 23
src/fFindDlg.pas

@@ -33,7 +33,8 @@ uses
   Graphics, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls, ComCtrls,
   ExtCtrls, Menus, EditBtn, Spin, Buttons, ZVDateTimePicker, KASComboBox,
   fAttributesEdit, uDsxModule, DsxPlugin, uFindThread, uFindFiles,
-  uSearchTemplate, fSearchPlugin, uFileView, types;
+  uSearchTemplate, fSearchPlugin, uFileView, types, DCStrUtils,ShellCtrls,
+  uOSForms,uShellContextMenu,uExceptions,uFileSystemFileSource;
 
 type
 
@@ -102,6 +103,8 @@ type
     lblEncoding: TLabel;
     lsFoundedFiles: TListBox;
     CheksPanel: TPanel;
+    miOpenInNewTab: TMenuItem;
+    miShowInEditor: TMenuItem;
     miShowAllFound: TMenuItem;
     miRemoveFromLlist: TMenuItem;
     pnlDirectoriesDepth: TPanel;
@@ -188,8 +191,10 @@ type
       MousePos: TPoint; var Handled: Boolean);
     procedure lsFoundedFilesMouseWheelUp(Sender: TObject; Shift: TShiftState;
       MousePos: TPoint; var Handled: Boolean);
+    procedure miOpenInNewTabClick(Sender: TObject);
     procedure miRemoveFromLlistClick(Sender: TObject);
     procedure miShowAllFoundClick(Sender: TObject);
+    procedure miShowInEditorClick(Sender: TObject);
     procedure miShowInViewerClick(Sender: TObject);
     procedure pgcSearchChange(Sender: TObject);
     procedure seFileSizeFromChange(Sender: TObject);
@@ -229,6 +234,9 @@ type
   public
     class function Instance: TfrmFindDlg;
   public
+
+    LastClickResultsPath:string;
+
     constructor Create(TheOwner: TComponent); override;
     destructor Destroy; override;
     procedure ClearFilter;
@@ -259,7 +267,7 @@ implementation
 uses
   LCLProc, LCLType, LConvEncoding, StrUtils, HelpIntfs, fViewer, fMain,
   uLng, uGlobs, uShowForm, uDCUtils, uFileSource, uFileSourceUtil,
-  uSearchResultFileSource, uFile, uFileSystemFileSource,
+  uSearchResultFileSource, uFile,
   uFileViewNotebook, uKeyboard, uOSUtils, uArchiveFileSourceUtil,
   DCOSUtils, SynRegExpr;
 
@@ -1463,44 +1471,75 @@ var
 begin
   i:=lsFoundedFiles.ItemAtPos(Point(X,Y),False);
 
-  if Button=mbRight then
+  if (i>=0) then
   begin
-    if Shift=[ssCtrl] then lsFoundedFiles.ClearSelection;
-    if i>=0 then lsFoundedFiles.Selected[i]:=True;
+    LastClickResultsPath:=GetDeepestExistingPath(lsFoundedFiles.Items[i]);
+
+    if (Button=mbRight)and(lsFoundedFiles.Selected[i]<>True) then
+    begin
+         lsFoundedFiles.ClearSelection;
+         lsFoundedFiles.Selected[i]:=True;
+    end;
   end;
 end;
 
 procedure TfrmFindDlg.lsFoundedFilesMouseUp(Sender: TObject;
   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
+var
+  i:integer;
+  sPath:string;
+  AFile: TFile;
+  AFiles: TFiles;
+
+  Panel:TFileView;
+  FileList :TFileTree;
+
+  pt: TPoint;
 begin
   if Button=mbRight then
   begin
 
-    if Shift=[ssCtrl] then
+    if Shift=[ssCtrl] then    // Show System context menu
     begin
+
       {$IF DEFINED(MSWINDOWS)}
-      {
-      try
-        AFile:= TFileSystemFileSource.CreateFileFromFile(ShellTreeView.Path);
         try
-          AFiles:= TFiles.Create(AFile.Path);
-          AFiles.Add(AFile);
-          APoint := ShellTreeView.ClientToScreen(Classes.Point(X, Y));
-          ShowContextMenu(ShellTreeView, AFiles, APoint.X, APoint.Y, False, nil);
-        finally
-          FreeAndNil(AFiles);
+          AFiles:= TFiles.Create(LastClickResultsPath);
+          AFiles.Path:=LastClickResultsPath;
+
+          i:=0;
+          while i<lsFoundedFiles.Count do
+          begin
+           if lsFoundedFiles.Selected[i] then
+           begin
+             sPath:=lsFoundedFiles.Items[i];
+             AFile:= TFileSystemFileSource.CreateFile(sPath);
+             AFiles.Add(aFile);
+           end;
+          inc(i);
+          end;
+
+          try
+            pt.X := X;
+            pt.Y := Y;
+            pt := ClientToScreen(pt);
+            ShowContextMenu(lsFoundedFiles, AFiles, pt.X, pt.Y, True, nil);
+          finally
+            FreeAndNil(AFiles);
+          end;
+
+
+        except
+          on E: EContextMenuException do
+            ShowException(E)
+          else;
         end;
-      except
-        on E: EContextMenuException do
-          ShowException(E)
-        else;
-      end;
-      }
+
       {$ENDIF}
 
     end else
     begin
-      PopupMenuFind.PopUp;
+      PopupMenuFind.PopUp;  // Show DC menu
     end;
 
   end;
@@ -1524,7 +1563,7 @@ procedure TfrmFindDlg.lsFoundedFilesMouseWheelUp(Sender: TObject;
 begin
   if (Shift=[ssCtrl])and(gFonts[dcfEditor].Size<MAX_FONT_SIZE_EDITOR) then
   begin
-    //gFonts[dcfEditor].Size:=gFonts[dcfEditor].Size+1;
+    //gFonts[dcfFileSearchResults].Size:=gFonts[dcfFileSearchResults].Size+1;
     //FontOptionsToFont(gFonts[dcfEditor], Editor.Font);
 
     lsFoundedFiles.Font.Size:=lsFoundedFiles.Font.Size+1;
@@ -1532,6 +1571,35 @@ begin
   end;
 end;
 
+procedure TfrmFindDlg.miOpenInNewTabClick(Sender: TObject);
+var
+  i,ind:integer;
+  sPath:string;
+
+  Notebook: TFileViewNotebook;
+  NewPage: TFileViewPage;
+
+begin
+  ind:=lsFoundedFiles.ItemIndex;
+  Notebook := frmMain.ActiveNotebook;
+
+  i:=0;
+  while i<lsFoundedFiles.Count do
+  begin
+    if lsFoundedFiles.Selected[i] then
+    begin
+      sPath :=lsFoundedFiles.Items[i];
+      sPath := GetDeepestExistingPath(sPath);
+
+      NewPage := Notebook.NewPage(Notebook.ActiveView);
+      NewPage.FileView.CurrentPath:=sPath;
+      NewPage.FileView.SetActiveFile(ExtractFileName(lsFoundedFiles.Items[i]));
+    end;
+  inc(i);
+  end;
+
+end;
+
 procedure TfrmFindDlg.miRemoveFromLlistClick(Sender: TObject);
 var
   i:Integer;
@@ -1554,6 +1622,12 @@ begin
   miShowAllFound.Enabled:=False;
 end;
 
+procedure TfrmFindDlg.miShowInEditorClick(Sender: TObject);
+begin
+  if lsFoundedFiles.ItemIndex>=0 then
+     ShowEditorByGlob(lsFoundedFiles.Items[lsFoundedFiles.ItemIndex]);
+end;
+
 procedure TfrmFindDlg.miShowInViewerClick(Sender: TObject);
 var
   sl:TStringList;