mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
ADD: Inplace rename button
This commit is contained in:
parent
a2e3cf234f
commit
bc65e818d7
5 changed files with 62 additions and 4 deletions
|
|
@ -556,6 +556,9 @@ begin
|
|||
if gShowIcons <> sim_none then
|
||||
Inc(ARect.Left, gIconsSize + 2);
|
||||
|
||||
if gInplaceRenameButton and (ARect.Right + edtRename.ButtonWidth < dgPanel.ClientWidth) then
|
||||
Inc(ARect.Right, edtRename.ButtonWidth);
|
||||
|
||||
edtRename.SetBounds(ARect.Left, ARect.Top, ARect.Right - ARect.Left, ARect.Bottom - ARect.Top);
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -496,6 +496,9 @@ begin
|
|||
if Succ(FFileNameColumn) = FExtensionColumn then
|
||||
Inc(ARect.Right, dgPanel.ColWidths[FExtensionColumn]);
|
||||
|
||||
if gInplaceRenameButton and (ARect.Right + edtRename.ButtonWidth < dgPanel.ClientWidth) then
|
||||
Inc(ARect.Right, edtRename.ButtonWidth);
|
||||
|
||||
edtRename.SetBounds(ARect.Left, ARect.Top, ARect.Right - ARect.Left, ARect.Bottom - ARect.Top);
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ unit uFileViewWithMainCtrl;
|
|||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Controls, ExtCtrls, StdCtrls, LCLType, LMessages,
|
||||
Classes, SysUtils, Controls, ExtCtrls, StdCtrls, LCLType, LMessages, EditBtn,
|
||||
Graphics,
|
||||
uFile,
|
||||
uFileViewWorker,
|
||||
uOrderedFileView,
|
||||
|
|
@ -50,6 +51,19 @@ type
|
|||
LastAction:TRenameFileActionType; // need for organize correct cycle Name-FullName-Ext (or FullName-Name-Ext)
|
||||
end;
|
||||
|
||||
{ TEditButtonEx }
|
||||
|
||||
TEditButtonEx = class(TEditButton)
|
||||
private
|
||||
function GetFont: TFont;
|
||||
procedure SetFont(AValue: TFont);
|
||||
protected
|
||||
function CalcButtonVisible: Boolean; override;
|
||||
function GetDefaultGlyphName: String; override;
|
||||
public
|
||||
property Font: TFont read GetFont write SetFont;
|
||||
end;
|
||||
|
||||
{ TFileViewWithMainCtrl }
|
||||
|
||||
TFileViewWithMainCtrl = class(TOrderedFileView)
|
||||
|
|
@ -77,11 +91,12 @@ type
|
|||
|
||||
procedure edtRenameEnter(Sender: TObject);
|
||||
procedure edtRenameExit(Sender: TObject);
|
||||
procedure edtRenameButtonClick(Sender: TObject);
|
||||
procedure edtRenameKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||
procedure edtRenameMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
|
||||
|
||||
protected
|
||||
edtRename: TEdit;
|
||||
edtRename: TEditButtonEx;
|
||||
FRenameFile: TFile;
|
||||
FRenFile:TRenameFileEditInfo;
|
||||
FRenTags:string; // rename separators
|
||||
|
|
@ -209,7 +224,7 @@ uses
|
|||
Gtk2Proc, // for ReleaseMouseCapture
|
||||
GTK2Globals, // for DblClickTime
|
||||
{$ENDIF}
|
||||
LCLIntf, LCLProc, LazUTF8, Forms, Dialogs, DCOSUtils,
|
||||
LCLIntf, LCLProc, LazUTF8, Forms, Dialogs, Buttons, DCOSUtils,
|
||||
fMain, uShowMsg, uLng, uFileProperty, uFileSource, uFileSourceOperationTypes,
|
||||
uGlobs, uInfoToolTip, uDisplayFile, uFileSystemFileSource, uFileSourceUtil,
|
||||
uArchiveFileSourceUtil, uFormCommands, uKeyboard, uFileSourceSetFilePropertyOperation;
|
||||
|
|
@ -218,6 +233,28 @@ type
|
|||
TControlHandlersHack = class(TWinControl)
|
||||
end;
|
||||
|
||||
{ TEditButtonEx }
|
||||
|
||||
function TEditButtonEx.GetFont: TFont;
|
||||
begin
|
||||
Result:= BaseEditor.Font;
|
||||
end;
|
||||
|
||||
procedure TEditButtonEx.SetFont(AValue: TFont);
|
||||
begin
|
||||
BaseEditor.Font:= AValue;
|
||||
end;
|
||||
|
||||
function TEditButtonEx.GetDefaultGlyphName: String;
|
||||
begin
|
||||
Result:= BitBtnResNames[idButtonOk];
|
||||
end;
|
||||
|
||||
function TEditButtonEx.CalcButtonVisible: Boolean;
|
||||
begin
|
||||
Result:= (inherited CalcButtonVisible) and gInplaceRenameButton;
|
||||
end;
|
||||
|
||||
{ TFileViewWithMainCtrl }
|
||||
|
||||
procedure TFileViewWithMainCtrl.ClearAfterDragDrop;
|
||||
|
|
@ -273,7 +310,7 @@ begin
|
|||
|
||||
inherited CreateDefault(AOwner);
|
||||
|
||||
edtRename := TEdit.Create(Self);
|
||||
edtRename := TEditButtonEx.Create(Self);
|
||||
edtRename.Visible := False;
|
||||
edtRename.TabStop := False;
|
||||
edtRename.AutoSize := False;
|
||||
|
|
@ -281,6 +318,7 @@ begin
|
|||
edtRename.OnMouseDown:=@edtRenameMouseDown;
|
||||
edtRename.OnEnter := @edtRenameEnter;
|
||||
edtRename.OnExit := @edtRenameExit;
|
||||
edtRename.OnButtonClick := @edtRenameButtonClick;
|
||||
|
||||
tmMouseScroll := TTimer.Create(Self);
|
||||
tmMouseScroll.Enabled := False;
|
||||
|
|
@ -1362,6 +1400,13 @@ begin
|
|||
FMainControl.OnEnter(Self);
|
||||
end;
|
||||
|
||||
procedure TFileViewWithMainCtrl.edtRenameButtonClick(Sender: TObject);
|
||||
var
|
||||
Key: Word = VK_RETURN;
|
||||
begin
|
||||
edtRenameKeyDown(Sender, Key, []);
|
||||
end;
|
||||
|
||||
procedure TFileViewWithMainCtrl.edtRenameKeyDown(Sender: TObject;
|
||||
var Key: Word; Shift: TShiftState);
|
||||
var
|
||||
|
|
|
|||
|
|
@ -691,6 +691,9 @@ begin
|
|||
ARect := dgPanel.CellRect(dgPanel.Col, dgPanel.Row);
|
||||
ARect.Top := ARect.Bottom - dgPanel.Canvas.TextHeight('Wg') - 4;
|
||||
|
||||
if gInplaceRenameButton and (ARect.Right + edtRename.ButtonWidth < dgPanel.ClientWidth) then
|
||||
Inc(ARect.Right, edtRename.ButtonWidth);
|
||||
|
||||
edtRename.SetBounds(ARect.Left, ARect.Top, ARect.Right - ARect.Left, ARect.Bottom - ARect.Top);
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -520,6 +520,7 @@ var
|
|||
gShowWarningMessages,
|
||||
gDirBrackets,
|
||||
gInplaceRename,
|
||||
gInplaceRenameButton,
|
||||
gDblClickToParent,
|
||||
gGoToRoot: Boolean;
|
||||
gActiveRight: Boolean;
|
||||
|
|
@ -1757,6 +1758,7 @@ begin
|
|||
gSpaceMovesDown := False;
|
||||
gDirBrackets := True;
|
||||
gInplaceRename := False;
|
||||
gInplaceRenameButton := False;
|
||||
gDblClickToParent := False;
|
||||
gHotDirAddTargetOrNot := False;
|
||||
gHotDirFullExpandOrNot:=False;
|
||||
|
|
@ -2748,6 +2750,7 @@ begin
|
|||
gSpaceMovesDown := GetValue(Node, 'SpaceMovesDown', gSpaceMovesDown);
|
||||
gDirBrackets := GetValue(Node, 'DirBrackets', gDirBrackets);
|
||||
gInplaceRename := GetValue(Node, 'InplaceRename', gInplaceRename);
|
||||
gInplaceRenameButton := GetValue(Node, 'InplaceRenameButton', gInplaceRenameButton);
|
||||
gDblClickToParent := GetValue(Node, 'DblClickToParent', gDblClickToParent);
|
||||
gHotDirAddTargetOrNot:=GetValue(Node, 'HotDirAddTargetOrNot', gHotDirAddTargetOrNot);
|
||||
gHotDirFullExpandOrNot:=GetValue(Node, 'HotDirFullExpandOrNot', gHotDirFullExpandOrNot);
|
||||
|
|
@ -3327,6 +3330,7 @@ begin
|
|||
SetValue(Node, 'SpaceMovesDown', gSpaceMovesDown);
|
||||
SetValue(Node, 'DirBrackets', gDirBrackets);
|
||||
SetValue(Node, 'InplaceRename', gInplaceRename);
|
||||
SetValue(Node, 'InplaceRenameButton', gInplaceRenameButton);
|
||||
SetValue(Node, 'DblClickToParent', gDblClickToParent);
|
||||
SetValue(Node, 'HotDirAddTargetOrNot',gHotDirAddTargetOrNot);
|
||||
SetValue(Node, 'HotDirFullExpandOrNot', gHotDirFullExpandOrNot);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue