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

View File

@ -21,9 +21,9 @@ unit PathEditorDlg;
interface
uses
Classes, SysUtils, Forms, Controls, Buttons, StdCtrls, Dialogs,
FileUtil, ButtonPanel, ExtCtrls, EditBtn, MacroIntf, LCLType, Graphics,
types, TransferMacros, LazarusIDEStrConsts, shortpathedit;
Classes, SysUtils, types, Forms, Controls, Buttons, StdCtrls, Dialogs,
FileUtil, ButtonPanel, ExtCtrls, EditBtn, MacroIntf, LCLType, Graphics, Menus,
TransferMacros, LazarusIDEStrConsts, shortpathedit, Clipbrd, LCLProc;
type
@ -32,6 +32,9 @@ type
TPathEditorDialog = class(TForm)
AddTemplateButton: TBitBtn;
ButtonPanel1: TButtonPanel;
CopyMenuItem: TMenuItem;
PasteMenuItem: TMenuItem;
PopupMenu1: TPopupMenu;
ReplaceButton: TBitBtn;
AddButton: TBitBtn;
DeleteInvalidPathsButton: TBitBtn;
@ -47,6 +50,8 @@ type
BrowseDialog: TSelectDirectoryDialog;
procedure AddButtonClick(Sender: TObject);
procedure AddTemplateButtonClick(Sender: TObject);
procedure CopyMenuItemClick(Sender: TObject);
procedure PasteMenuItemClick(Sender: TObject);
procedure DeleteInvalidPathsButtonClick(Sender: TObject);
procedure DeleteButtonClick(Sender: TObject);
procedure DirectoryEditAcceptDirectory(Sender: TObject; var Value: String);
@ -214,6 +219,49 @@ begin
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);
begin
UpdateButtons;
@ -264,6 +312,9 @@ begin
AddTemplateButton.Caption:=lisCodeTemplAdd;
AddTemplateButton.Hint:=lisPathEditorTemplAddHint;
CopyMenuItem.Caption:=lisCopyAllItemsToClipboard;
PasteMenuItem.Caption:=lisPaste;
MoveUpButton.LoadGlyphFromResourceName(HInstance, 'arrow_up');
MoveDownButton.LoadGlyphFromResourceName(HInstance, 'arrow_down');
ReplaceButton.LoadGlyphFromResourceName(HInstance, 'menu_reportingbug');