2
0
Эх сурвалжийг харах

ADD: Capability to choose queue number from copy/move dialog
UPD: Cleanup old defines

Alexander Koblov 11 жил өмнө
parent
commit
47126fa17f

+ 60 - 31
src/fcopymovedlg.lfm

@@ -42,7 +42,7 @@ object frmCopyDlg: TfrmCopyDlg
     AnchorSideRight.Control = Owner
     AnchorSideRight.Side = asrBottom
     Left = 8
-    Height = 28
+    Height = 21
     Top = 34
     Width = 596
     Anchors = [akTop, akLeft, akRight]
@@ -61,7 +61,7 @@ object frmCopyDlg: TfrmCopyDlg
     AnchorSideRight.Side = asrBottom
     Left = 8
     Height = 38
-    Top = 70
+    Top = 63
     Width = 596
     Anchors = [akTop, akLeft, akRight]
     BorderSpacing.Top = 8
@@ -75,19 +75,19 @@ object frmCopyDlg: TfrmCopyDlg
     AnchorSideRight.Control = edtDst
     AnchorSideRight.Side = asrBottom
     Left = 8
-    Height = 36
-    Top = 112
+    Height = 34
+    Top = 105
     Width = 596
     Anchors = [akTop, akLeft, akRight]
     AutoSize = True
     BorderSpacing.Top = 4
     BevelOuter = bvNone
-    ClientHeight = 36
+    ClientHeight = 34
     ClientWidth = 596
     TabOrder = 2
     object btnOptions: TButton
       Left = 0
-      Height = 36
+      Height = 34
       Top = 0
       Width = 100
       Align = alLeft
@@ -95,14 +95,13 @@ object frmCopyDlg: TfrmCopyDlg
       Caption = 'O&ptions'
       Constraints.MinWidth = 100
       OnClick = btnOptionsClick
-      OnMouseUp = btnOptionsMouseUp
       TabOrder = 0
     end
     object btnAddToQueue: TBitBtn
-      Left = 251
-      Height = 36
+      Left = 264
+      Height = 34
       Top = 0
-      Width = 128
+      Width = 119
       Align = alRight
       AutoSize = True
       BorderSpacing.InnerBorder = 2
@@ -146,27 +145,31 @@ object frmCopyDlg: TfrmCopyDlg
         0000000000000000000000000000000000000000000000000000
       }
       ModalResult = 1
-      OnClick = btnAddToQueueClick
-      OnMouseUp = btnAddToQueueMouseUp
       TabOrder = 1
     end
-    object btnCreateSpecialQueue: TButton
-      Left = 379
-      Height = 36
+    object btnCreateSpecialQueue: TBitBtn
+      Left = 383
+      Height = 34
       Top = 0
-      Width = 25
+      Width = 23
       Align = alRight
-      AutoSize = True
       BorderSpacing.Right = 12
-      Caption = '...'
+      Glyph.Data = {
+        72000000424D7200000000000000360000002800000005000000030000000100
+        2000000000003C00000064000000640000000000000000000000000000000000
+        0000000000FF000000000000000000000000000000FF000000FF000000FF0000
+        0000000000FF000000FF000000FF000000FF000000FF
+      }
+      Layout = blGlyphBottom
+      OnClick = btnCreateSpecialQueueClick
+      PopupMenu = pmQueuePopup
       TabOrder = 2
-      Visible = False
     end
     object btnCancel: TBitBtn
-      Left = 416
-      Height = 36
+      Left = 418
+      Height = 34
       Top = 0
-      Width = 84
+      Width = 82
       Align = alRight
       AutoSize = True
       BorderSpacing.Left = 12
@@ -176,12 +179,11 @@ object frmCopyDlg: TfrmCopyDlg
       Caption = '&Cancel'
       Kind = bkCancel
       ModalResult = 2
-      OnMouseUp = btnCancelMouseUp
       TabOrder = 3
     end
     object btnOK: TBitBtn
       Left = 508
-      Height = 36
+      Height = 34
       Top = 0
       Width = 88
       Align = alRight
@@ -228,7 +230,6 @@ object frmCopyDlg: TfrmCopyDlg
       }
       ModalResult = 1
       OnClick = btnOKClick
-      OnMouseUp = btnOKMouseUp
       TabOrder = 4
     end
   end
@@ -239,14 +240,14 @@ object frmCopyDlg: TfrmCopyDlg
     AnchorSideRight.Control = edtDst
     AnchorSideRight.Side = asrBottom
     Left = 8
-    Height = 43
-    Top = 152
+    Height = 35
+    Top = 143
     Width = 596
     Anchors = [akTop, akLeft, akRight]
     AutoSize = True
     BorderSpacing.Top = 4
     BevelOuter = bvNone
-    ClientHeight = 43
+    ClientHeight = 35
     ClientWidth = 596
     TabOrder = 3
     OnResize = pnlOptionsResize
@@ -268,10 +269,10 @@ object frmCopyDlg: TfrmCopyDlg
       AnchorSideLeft.Side = asrCenter
       AnchorSideTop.Control = grpOptions
       AnchorSideTop.Side = asrBottom
-      Left = 197
-      Height = 31
+      Left = 214
+      Height = 23
       Top = 12
-      Width = 203
+      Width = 169
       AutoSize = True
       BorderSpacing.Top = 8
       Caption = 'Sa&ve these options as default'
@@ -279,4 +280,32 @@ object frmCopyDlg: TfrmCopyDlg
       TabOrder = 1
     end
   end
+  object pmQueuePopup: TPopupMenu
+    left = 296
+    top = 184
+    object mnuNewQueue: TMenuItem
+      Caption = 'New queue'
+      OnClick = mnuNewQueueClick
+    end
+    object mnuQueue1: TMenuItem
+      Caption = 'Queue 1'
+      OnClick = mnuQueueNumberClick
+    end
+    object mnuQueue2: TMenuItem
+      Caption = 'Queue 2'
+      OnClick = mnuQueueNumberClick
+    end
+    object mnuQueue3: TMenuItem
+      Caption = 'Queue 3'
+      OnClick = mnuQueueNumberClick
+    end
+    object mnuQueue4: TMenuItem
+      Caption = 'Queue 4'
+      OnClick = mnuQueueNumberClick
+    end
+    object mnuQueue5: TMenuItem
+      Caption = 'Queue 5'
+      OnClick = mnuQueueNumberClick
+    end
+  end
 end

+ 6 - 1
src/fcopymovedlg.lrt

@@ -1,6 +1,11 @@
 TFRMCOPYDLG.CAPTION=Copy file(s)
 TFRMCOPYDLG.BTNOPTIONS.CAPTION=O&ptions
 TFRMCOPYDLG.BTNADDTOQUEUE.CAPTION=A&dd To Queue
-TFRMCOPYDLG.BTNCREATESPECIALQUEUE.CAPTION=...
 TFRMCOPYDLG.BTNCANCEL.CAPTION=&Cancel
 TFRMCOPYDLG.BTNSAVEOPTIONS.CAPTION=Sa&ve these options as default
+TFRMCOPYDLG.MNUNEWQUEUE.CAPTION=New queue
+TFRMCOPYDLG.MNUQUEUE1.CAPTION=Queue 1
+TFRMCOPYDLG.MNUQUEUE2.CAPTION=Queue 2
+TFRMCOPYDLG.MNUQUEUE3.CAPTION=Queue 3
+TFRMCOPYDLG.MNUQUEUE4.CAPTION=Queue 4
+TFRMCOPYDLG.MNUQUEUE5.CAPTION=Queue 5

+ 58 - 89
src/fcopymovedlg.pas

@@ -28,38 +28,39 @@ type
     edtDst: TKASPathEdit;
     grpOptions: TGroupBox;
     lblCopySrc: TLabel;
+    mnuQueue2: TMenuItem;
+    mnuQueue3: TMenuItem;
+    mnuQueue4: TMenuItem;
+    mnuQueue5: TMenuItem;
+    mnuQueue1: TMenuItem;
+    mnuNewQueue: TMenuItem;
+    pmQueuePopup: TPopupMenu;
     pnlButtons: TPanel;
     pnlOptions: TPanel;
     pnlSelector: TPanel;
-    btnCreateSpecialQueue: TButton;
-    procedure btnAddToQueueClick(Sender: TObject);
-    procedure btnCancelMouseUp(Sender: TObject; Button: TMouseButton;
-      Shift: TShiftState; X, Y: Integer);
-    procedure btnAddToQueueMouseUp(Sender: TObject; Button: TMouseButton;
-      Shift: TShiftState; X, Y: Integer);
+    btnCreateSpecialQueue: TBitBtn;
+    procedure btnCreateSpecialQueueClick(Sender: TObject);
     procedure btnOKClick(Sender: TObject);
-    procedure btnOKMouseUp(Sender: TObject; Button: TMouseButton;
-      Shift: TShiftState; X, Y: Integer);
     procedure btnOptionsClick(Sender: TObject);
-    procedure btnOptionsMouseUp(Sender: TObject; Button: TMouseButton;
-      Shift: TShiftState; X, Y: Integer);
     procedure btnSaveOptionsClick(Sender: TObject);
     procedure btnStartModeClick(Sender: TObject);
     procedure FormCreate(Sender: TObject);
     procedure FormDestroy(Sender: TObject);
     procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
     procedure frmCopyDlgShow(Sender: TObject);
+    procedure mnuNewQueueClick(Sender: TObject);
+    procedure mnuQueueNumberClick(Sender: TObject);
     procedure pnlOptionsResize(Sender: TObject);
 
   private
     FCommands: TFormCommands;
     FDialogType: TCopyMoveDlgType;
-    FQueueIdentifier: TOperationsManagerQueueIdentifier;
     noteb: TFileViewNotebook;
     FFileSource: IFileSource;
     FOperationOptionsUIClass: TFileSourceOperationOptionsUIClass;
     FOperationOptionsUI: TFileSourceOperationOptionsUI;
 
+    function GetQueueIdentifier: TOperationsManagerQueueIdentifier;
     function ShowTabsSelector: integer;
     procedure TabsSelector(Sender: TObject);
     procedure TabsSelectorMouseDown(Sender: TObject; Button: TMouseButton;
@@ -67,7 +68,7 @@ type
     procedure ShowOptions(bShow: Boolean);
     procedure UpdateSize;
 
-    property Commands: TFormCommands read FCommands{$IF FPC_FULLVERSION >= 020501} implements IFormCommands{$ENDIF};
+    property Commands: TFormCommands read FCommands implements IFormCommands;
 
   public
     constructor Create(TheOwner: TComponent; DialogType: TCopyMoveDlgType;
@@ -76,14 +77,7 @@ type
     constructor Create(TheOwner: TComponent); override;
     procedure SetOperationOptions(Operation: TFileSourceOperation);
 
-    property QueueIdentifier: TOperationsManagerQueueIdentifier read FQueueIdentifier;
-
-    {$IF FPC_FULLVERSION < 020501}
-    // "implements" does not work in FPC < 2.5.1
-    function ExecuteCommand(Command: string; const Params: array of String): TCommandFuncResult;
-    function GetCommandCaption(Command: String; CaptionType: TCommandCaptionType): String;
-    procedure GetCommandsList(List: TStrings);
-    {$ENDIF}
+    property QueueIdentifier: TOperationsManagerQueueIdentifier read GetQueueIdentifier;
 
   published
     procedure cm_AddToQueue(const Params: array of String);
@@ -100,6 +94,9 @@ uses
 const
   HotkeysCategory = 'Copy/Move Dialog';
 
+var
+  FQueueIdentifier: TOperationsManagerQueueIdentifier = SingleQueueId;
+
 constructor TfrmCopyDlg.Create(TheOwner: TComponent; DialogType: TCopyMoveDlgType;
                                AFileSource: IFileSource;
                                AOperationOptionsUIClass: TFileSourceOperationOptionsUIClass);
@@ -107,7 +104,6 @@ begin
   FDialogType := DialogType;
   FFileSource := AFileSource;
   FOperationOptionsUIClass := AOperationOptionsUIClass;
-  FQueueIdentifier := FreeOperationsQueueId;
   FCommands := TFormCommands.Create(Self);
   inherited Create(TheOwner);
 end;
@@ -129,7 +125,12 @@ var
   sQueueId: String;
 begin
   if GetParamValue(Params, 'queueid', sQueueId) and TryStrToInt(sQueueId, Value) then
-    FQueueIdentifier := Value
+    begin
+      if Value < 0 then
+        mnuNewQueue.Click
+      else
+        FQueueIdentifier := Value
+    end
   else
     FQueueIdentifier := SingleQueueId;
   ModalResult := btnAddToQueue.ModalResult;
@@ -213,6 +214,11 @@ begin
   end;
 end;
 
+function TfrmCopyDlg.GetQueueIdentifier: TOperationsManagerQueueIdentifier;
+begin
+  Result:= FQueueIdentifier;
+end;
+
 procedure TfrmCopyDlg.frmCopyDlgShow(Sender: TObject);
 begin
   case FDialogType of
@@ -234,6 +240,33 @@ begin
   edtDst.SetFocus;
 end;
 
+procedure TfrmCopyDlg.mnuNewQueueClick(Sender: TObject);
+var
+  NewQueueId: TOperationsManagerQueueIdentifier;
+begin
+  for NewQueueId := Succ(FreeOperationsQueueId) to MaxInt do
+  with OperationsManager do
+  begin
+    if not Assigned(QueueByIdentifier[NewQueueId]) then
+    begin
+      FQueueIdentifier := NewQueueId;
+      ModalResult := btnAddToQueue.ModalResult;
+      Break;
+    end;
+  end;
+end;
+
+procedure TfrmCopyDlg.mnuQueueNumberClick(Sender: TObject);
+var
+  NewQueueNumber: TOperationsManagerQueueIdentifier;
+begin
+  if TryStrToInt(Copy((Sender as TMenuItem).Name, 9, 1), NewQueueNumber) then
+  begin
+    FQueueIdentifier := NewQueueNumber;
+    ModalResult := btnAddToQueue.ModalResult;
+  end;
+end;
+
 procedure TfrmCopyDlg.pnlOptionsResize(Sender: TObject);
 begin
   UpdateSize;
@@ -262,66 +295,19 @@ begin
   {$ENDIF}
 end;
 
-procedure TfrmCopyDlg.btnCancelMouseUp(Sender: TObject; Button: TMouseButton;
-  Shift: TShiftState; X, Y: Integer);
-begin
-{$IF (DEFINED(LCLGTK) or DEFINED(LCLGTK2)) and (lcl_fullversion < 093100)}
-  if (Button = mbLeft) and (Sender = FindLCLControl(Mouse.CursorPos)) then
-    ModalResult := btnCancel.ModalResult;
-{$ENDIF}
-end;
-
-procedure TfrmCopyDlg.btnAddToQueueClick(Sender: TObject);
-begin
-{$IF NOT ((DEFINED(LCLGTK) or DEFINED(LCLGTK2)) and (lcl_fullversion < 093100))}
-  FQueueIdentifier := SingleQueueId;
-{$ENDIF}
-end;
-
-procedure TfrmCopyDlg.btnAddToQueueMouseUp(Sender: TObject; Button: TMouseButton;
-  Shift: TShiftState; X, Y: Integer);
+procedure TfrmCopyDlg.btnCreateSpecialQueueClick(Sender: TObject);
 begin
-{$IF (DEFINED(LCLGTK) or DEFINED(LCLGTK2)) and (lcl_fullversion < 093100)}
-  if (Button = mbLeft) and (Sender = FindLCLControl(Mouse.CursorPos)) then
-  begin
-    cm_AddToQueue([]);
-  end;
-{$ENDIF}
+  btnCreateSpecialQueue.PopupMenu.PopUp;
 end;
 
 procedure TfrmCopyDlg.btnOKClick(Sender: TObject);
 begin
-{$IF NOT ((DEFINED(LCLGTK) or DEFINED(LCLGTK2)) and (lcl_fullversion < 093100))}
   FQueueIdentifier := FreeOperationsQueueId;
-{$ENDIF}
-end;
-
-procedure TfrmCopyDlg.btnOkMouseUp(Sender: TObject; Button: TMouseButton;
-  Shift: TShiftState; X, Y: Integer);
-begin
-{$IF (DEFINED(LCLGTK) or DEFINED(LCLGTK2)) and (lcl_fullversion < 093100)}
-  if (Button = mbLeft) and (Sender = FindLCLControl(Mouse.CursorPos)) then
-  begin
-     FQueueIdentifier := FreeOperationsQueueId;
-     ModalResult := btnOk.ModalResult;
-  end;
-{$ENDIF}
 end;
 
 procedure TfrmCopyDlg.btnOptionsClick(Sender: TObject);
 begin
-{$IF NOT ((DEFINED(LCLGTK) or DEFINED(LCLGTK2)) and (lcl_fullversion < 093100))}
   ShowOptions(not pnlOptions.Visible);
-{$ENDIF}
-end;
-
-procedure TfrmCopyDlg.btnOptionsMouseUp(Sender: TObject; Button: TMouseButton;
-  Shift: TShiftState; X, Y: Integer);
-begin
-{$IF (DEFINED(LCLGTK) or DEFINED(LCLGTK2)) and (lcl_fullversion < 093100)}
-  if (Button = mbLeft) and (Sender = FindLCLControl(Mouse.CursorPos)) then
-    ShowOptions(not pnlOptions.Visible);
-{$ENDIF}
 end;
 
 procedure TfrmCopyDlg.btnSaveOptionsClick(Sender: TObject);
@@ -361,7 +347,7 @@ begin
   ShowOptions(False);
 
   btnOK.Caption := rsDlgOpStart;
-  FQueueIdentifier := FreeOperationsQueueId;
+  btnAddToQueue.Caption:= btnAddToQueue.Caption + ' #' + IntToStr(FQueueIdentifier);
 
   HMForm := HotMan.Register(Self, HotkeysCategory);
   Hotkey := HMForm.Hotkeys.FindByCommand('cm_AddToQueue');
@@ -390,23 +376,6 @@ begin
     Self.Height := pnlOptions.Top;
 end;
 
-{$IF FPC_FULLVERSION < 020501}
-function TfrmCopyDlg.ExecuteCommand(Command: string; const Params: array of String): TCommandFuncResult;
-begin
-  Result := FCommands.ExecuteCommand(Command, Params);
-end;
-
-function TfrmCopyDlg.GetCommandCaption(Command: String; CaptionType: TCommandCaptionType): String;
-begin
-  Result := FCommands.GetCommandCaption(Command, CaptionType);
-end;
-
-procedure TfrmCopyDlg.GetCommandsList(List: TStrings);
-begin
-  FCommands.GetCommandsList(List);
-end;
-{$ENDIF}
-
 initialization
   TFormCommands.RegisterCommandsForm(TfrmCopyDlg, HotkeysCategory, @rsHotkeyCategoryCopyMoveDialog);