IDE: implement Copy/Paste for paths in PathEditor dialog. Related to issue #25903.

git-svn-id: trunk@46035 -
This commit is contained in:
juha 2014-08-11 20:05:51 +00:00
parent 2f8dffb465
commit be876071b9
2 changed files with 101 additions and 37 deletions

View File

@ -13,10 +13,10 @@ object PathEditorDialog: TPathEditorDialog
OnResize = FormResize OnResize = FormResize
OnShow = FormShow OnShow = FormShow
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '1.1' LCLVersion = '1.3'
object PathGroupBox: TGroupBox object PathGroupBox: TGroupBox
Left = 6 Left = 6
Height = 216 Height = 214
Top = 6 Top = 6
Width = 541 Width = 541
Align = alClient Align = alClient
@ -25,7 +25,7 @@ object PathEditorDialog: TPathEditorDialog
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'PathGroupBox' Caption = 'PathGroupBox'
ClientHeight = 195 ClientHeight = 195
ClientWidth = 533 ClientWidth = 537
Constraints.MinHeight = 194 Constraints.MinHeight = 194
Constraints.MinWidth = 488 Constraints.MinWidth = 488
TabOrder = 0 TabOrder = 0
@ -35,7 +35,7 @@ object PathEditorDialog: TPathEditorDialog
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = PathGroupBox AnchorSideBottom.Control = PathGroupBox
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 502 Left = 506
Height = 25 Height = 25
Top = 45 Top = 45
Width = 25 Width = 25
@ -54,7 +54,7 @@ object PathEditorDialog: TPathEditorDialog
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = PathGroupBox AnchorSideBottom.Control = PathGroupBox
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 502 Left = 506
Height = 25 Height = 25
Top = 84 Top = 84
Width = 25 Width = 25
@ -70,10 +70,10 @@ object PathEditorDialog: TPathEditorDialog
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = PathGroupBox AnchorSideBottom.Control = PathGroupBox
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 206 Left = 203
Height = 28 Height = 26
Top = 161 Top = 163
Width = 99 Width = 97
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -91,13 +91,14 @@ object PathEditorDialog: TPathEditorDialog
Left = 6 Left = 6
Height = 127 Height = 127
Top = 6 Top = 6
Width = 490 Width = 494
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
ItemHeight = 0 ItemHeight = 0
OnDrawItem = PathListBoxDrawItem OnDrawItem = PathListBoxDrawItem
OnKeyDown = PathListBoxKeyDown OnKeyDown = PathListBoxKeyDown
OnSelectionChange = PathListBoxSelectionChange OnSelectionChange = PathListBoxSelectionChange
PopupMenu = PopupMenu1
Style = lbOwnerDrawFixed Style = lbOwnerDrawFixed
TabOrder = 0 TabOrder = 0
end end
@ -106,9 +107,9 @@ object PathEditorDialog: TPathEditorDialog
AnchorSideBottom.Control = PathGroupBox AnchorSideBottom.Control = PathGroupBox
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 6 Left = 6
Height = 28 Height = 26
Top = 161 Top = 163
Width = 106 Width = 105
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -124,10 +125,10 @@ object PathEditorDialog: TPathEditorDialog
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = PathGroupBox AnchorSideBottom.Control = PathGroupBox
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 118 Left = 117
Height = 28 Height = 26
Top = 161 Top = 163
Width = 82 Width = 80
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -143,10 +144,10 @@ object PathEditorDialog: TPathEditorDialog
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = PathGroupBox AnchorSideBottom.Control = PathGroupBox
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 311 Left = 306
Height = 28 Height = 26
Top = 161 Top = 163
Width = 174 Width = 171
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -163,8 +164,8 @@ object PathEditorDialog: TPathEditorDialog
AnchorSideBottom.Control = ReplaceButton AnchorSideBottom.Control = ReplaceButton
Left = 6 Left = 6
Height = 25 Height = 25
Top = 130 Top = 132
Width = 490 Width = 494
OnAcceptDirectory = DirectoryEditAcceptDirectory OnAcceptDirectory = DirectoryEditAcceptDirectory
ShowHidden = False ShowHidden = False
ButtonWidth = 23 ButtonWidth = 23
@ -179,14 +180,14 @@ object PathEditorDialog: TPathEditorDialog
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 164 Height = 164
Top = 239 Top = 237
Width = 541 Width = 541
Align = alBottom Align = alBottom
Anchors = [] Anchors = []
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'TemplateGroupBox' Caption = 'TemplateGroupBox'
ClientHeight = 143 ClientHeight = 145
ClientWidth = 533 ClientWidth = 537
TabOrder = 1 TabOrder = 1
object TemplatesListBox: TListBox object TemplatesListBox: TListBox
AnchorSideLeft.Control = TemplateGroupBox AnchorSideLeft.Control = TemplateGroupBox
@ -195,9 +196,9 @@ object PathEditorDialog: TPathEditorDialog
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = AddTemplateButton AnchorSideBottom.Control = AddTemplateButton
Left = 6 Left = 6
Height = 97 Height = 101
Top = 6 Top = 6
Width = 521 Width = 525
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
ItemHeight = 0 ItemHeight = 0
@ -211,9 +212,9 @@ object PathEditorDialog: TPathEditorDialog
AnchorSideBottom.Control = TemplateGroupBox AnchorSideBottom.Control = TemplateGroupBox
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 6 Left = 6
Height = 28 Height = 26
Top = 109 Top = 113
Width = 140 Width = 136
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -226,8 +227,8 @@ object PathEditorDialog: TPathEditorDialog
end end
object ButtonPanel1: TButtonPanel object ButtonPanel1: TButtonPanel
Left = 6 Left = 6
Height = 31 Height = 33
Top = 409 Top = 407
Width = 541 Width = 541
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True
@ -245,7 +246,7 @@ object PathEditorDialog: TPathEditorDialog
Cursor = crVSplit Cursor = crVSplit
Left = 0 Left = 0
Height = 5 Height = 5
Top = 228 Top = 226
Width = 553 Width = 553
Align = alBottom Align = alBottom
ResizeAnchor = akBottom ResizeAnchor = akBottom
@ -255,4 +256,16 @@ object PathEditorDialog: TPathEditorDialog
left = 504 left = 504
top = 32 top = 32
end end
object PopupMenu1: TPopupMenu
left = 504
top = 168
object CopyMenuItem: TMenuItem
Caption = 'Copy All'
OnClick = CopyMenuItemClick
end
object PasteMenuItem: TMenuItem
Caption = 'Paste'
OnClick = PasteMenuItemClick
end
end
end end

View File

@ -21,9 +21,9 @@ unit PathEditorDlg;
interface interface
uses uses
Classes, SysUtils, Forms, Controls, Buttons, StdCtrls, Dialogs, Classes, SysUtils, types, Forms, Controls, Buttons, StdCtrls, Dialogs,
FileUtil, ButtonPanel, ExtCtrls, EditBtn, MacroIntf, LCLType, Graphics, FileUtil, ButtonPanel, ExtCtrls, EditBtn, MacroIntf, LCLType, Graphics, Menus,
types, TransferMacros, LazarusIDEStrConsts, shortpathedit; TransferMacros, LazarusIDEStrConsts, shortpathedit, Clipbrd, LCLProc;
type type
@ -32,6 +32,9 @@ type
TPathEditorDialog = class(TForm) TPathEditorDialog = class(TForm)
AddTemplateButton: TBitBtn; AddTemplateButton: TBitBtn;
ButtonPanel1: TButtonPanel; ButtonPanel1: TButtonPanel;
CopyMenuItem: TMenuItem;
PasteMenuItem: TMenuItem;
PopupMenu1: TPopupMenu;
ReplaceButton: TBitBtn; ReplaceButton: TBitBtn;
AddButton: TBitBtn; AddButton: TBitBtn;
DeleteInvalidPathsButton: TBitBtn; DeleteInvalidPathsButton: TBitBtn;
@ -47,6 +50,8 @@ type
BrowseDialog: TSelectDirectoryDialog; BrowseDialog: TSelectDirectoryDialog;
procedure AddButtonClick(Sender: TObject); procedure AddButtonClick(Sender: TObject);
procedure AddTemplateButtonClick(Sender: TObject); procedure AddTemplateButtonClick(Sender: TObject);
procedure CopyMenuItemClick(Sender: TObject);
procedure PasteMenuItemClick(Sender: TObject);
procedure DeleteInvalidPathsButtonClick(Sender: TObject); procedure DeleteInvalidPathsButtonClick(Sender: TObject);
procedure DeleteButtonClick(Sender: TObject); procedure DeleteButtonClick(Sender: TObject);
procedure DirectoryEditAcceptDirectory(Sender: TObject; var Value: String); procedure DirectoryEditAcceptDirectory(Sender: TObject; var Value: String);
@ -214,6 +219,49 @@ begin
end; end;
end; end;
procedure TPathEditorDialog.CopyMenuItemClick(Sender: TObject);
var
Paths: TStringList;
i: integer;
begin
Paths := TStringList.Create;
try
for i := 0 to PathListBox.Count-1 do
Paths.Add(PathAsAbsolute(PathListBox.Items[i]));
Clipboard.AsText := Paths.Text;
finally
Paths.Free;
end;
end;
procedure TPathEditorDialog.PasteMenuItemClick(Sender: TObject);
var
Paths: TStringList;
s: string;
y, i: integer;
begin
Paths := TStringList.Create;
try
y := PathListBox.ItemIndex;
if y = -1 then
y := PathListBox.Count-1;
Paths.Text := Clipboard.AsText;
for i := 0 to Paths.Count-1 do
begin
s := Trim(Paths[i]);
if s <> '' then
begin
Inc(y);
PathListBox.Items.InsertObject(y, BaseRelative(s), PathMayExist(s));
end;
end;
//PathListBox.ItemIndex := y;
UpdateButtons;
finally
Paths.Free;
end;
end;
procedure TPathEditorDialog.DirectoryEditChange(Sender: TObject); procedure TPathEditorDialog.DirectoryEditChange(Sender: TObject);
begin begin
UpdateButtons; UpdateButtons;
@ -264,6 +312,9 @@ begin
AddTemplateButton.Caption:=lisCodeTemplAdd; AddTemplateButton.Caption:=lisCodeTemplAdd;
AddTemplateButton.Hint:=lisPathEditorTemplAddHint; AddTemplateButton.Hint:=lisPathEditorTemplAddHint;
CopyMenuItem.Caption:=lisCopyAllItemsToClipboard;
PasteMenuItem.Caption:=lisPaste;
MoveUpButton.LoadGlyphFromResourceName(HInstance, 'arrow_up'); MoveUpButton.LoadGlyphFromResourceName(HInstance, 'arrow_up');
MoveDownButton.LoadGlyphFromResourceName(HInstance, 'arrow_down'); MoveDownButton.LoadGlyphFromResourceName(HInstance, 'arrow_down');
ReplaceButton.LoadGlyphFromResourceName(HInstance, 'menu_reportingbug'); ReplaceButton.LoadGlyphFromResourceName(HInstance, 'menu_reportingbug');