mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Feature [0000124] "Close tab at double click"
ADD: Create new tab by double click at empty space under Qt
This commit is contained in:
parent
0e382d38d6
commit
be34d417ef
2 changed files with 29 additions and 24 deletions
|
|
@ -747,9 +747,7 @@ procedure TfrmMain.FormCreate(Sender: TObject);
|
|||
{$ELSE}
|
||||
Result.OnPageChanged := @nbPageChanged;
|
||||
{$ENDIF}
|
||||
{$IF DEFINED(LCLGTK2)}
|
||||
Result.OnDblClick := @pnlLeftRightDblClick;
|
||||
{$ENDIF}
|
||||
end;
|
||||
function GenerateTitle():String;
|
||||
begin
|
||||
|
|
@ -3081,11 +3079,11 @@ end;
|
|||
procedure TfrmMain.pnlLeftRightDblClick(Sender: TObject);
|
||||
var
|
||||
APanel: TPanel;
|
||||
FileViewNotebook: TFileViewNotebook;
|
||||
{$IF DEFINED(LCLGTK2)}
|
||||
X, ArrowWidth: Integer;
|
||||
arrow_spacing: gint = 0;
|
||||
scroll_arrow_hlength: gint = 16;
|
||||
FileViewNotebook: TFileViewNotebook;
|
||||
{$ENDIF}
|
||||
begin
|
||||
if Sender is TPanel then
|
||||
|
|
@ -3096,20 +3094,25 @@ begin
|
|||
else if APanel = pnlRight then
|
||||
Commands.DoNewTab(nbRight);
|
||||
end;
|
||||
{$IF DEFINED(LCLGTK2)}
|
||||
if Sender is TFileViewNotebook then
|
||||
begin
|
||||
FileViewNotebook:= Sender as TFileViewNotebook;
|
||||
gtk_widget_style_get(PGtkWidget(FileViewNotebook.Handle),
|
||||
'arrow-spacing', @arrow_spacing,
|
||||
'scroll-arrow-hlength', @scroll_arrow_hlength,
|
||||
nil);
|
||||
ArrowWidth:= arrow_spacing + scroll_arrow_hlength;
|
||||
X:= FileViewNotebook.ScreenToClient(Mouse.CursorPos).X;
|
||||
if (X > ArrowWidth) and (X < FileViewNotebook.ClientWidth - ArrowWidth) then
|
||||
Commands.DoNewTab(FileViewNotebook);
|
||||
end;
|
||||
if FileViewNotebook.DoubleClickPageIndex >= 0 then
|
||||
Commands.DoRemoveTab(FileViewNotebook, FileViewNotebook.DoubleClickPageIndex)
|
||||
else
|
||||
begin
|
||||
{$IF DEFINED(LCLGTK2)}
|
||||
gtk_widget_style_get(PGtkWidget(FileViewNotebook.Handle),
|
||||
'arrow-spacing', @arrow_spacing,
|
||||
'scroll-arrow-hlength', @scroll_arrow_hlength,
|
||||
nil);
|
||||
ArrowWidth:= arrow_spacing + scroll_arrow_hlength;
|
||||
X:= FileViewNotebook.ScreenToClient(Mouse.CursorPos).X;
|
||||
if (X > ArrowWidth) and (X < FileViewNotebook.ClientWidth - ArrowWidth) then
|
||||
{$ENDIF}
|
||||
Commands.DoNewTab(FileViewNotebook);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.pnlNotebooksResize(Sender: TObject);
|
||||
|
|
|
|||
|
|
@ -93,9 +93,8 @@ type
|
|||
FNotebookSide: TFilePanelSelect;
|
||||
FStartDrag: Boolean;
|
||||
FDraggedPageIndex: Integer;
|
||||
{$IF DEFINED(LCLGTK2)}
|
||||
FLastMouseDownTime: TDateTime;
|
||||
{$ENDIF}
|
||||
FLastMouseDownPageIndex: Integer;
|
||||
|
||||
function GetActivePage: TFileViewPage;
|
||||
function GetActiveView: TFileView;
|
||||
|
|
@ -128,6 +127,7 @@ type
|
|||
|
||||
property ActivePage: TFileViewPage read GetActivePage;
|
||||
property ActiveView: TFileView read GetActiveView;
|
||||
property DoubleClickPageIndex: Integer read FLastMouseDownPageIndex;
|
||||
property Page[Index: Integer]: TFileViewPage read GetPage;
|
||||
property View[Index: Integer]: TFileView read GetFileViewOnPage; default;
|
||||
property Side: TFilePanelSelect read FNotebookSide;
|
||||
|
|
@ -144,12 +144,10 @@ type
|
|||
implementation
|
||||
|
||||
uses
|
||||
LCLIntf,
|
||||
LCLProc,
|
||||
DCStrUtils,
|
||||
uGlobs
|
||||
{$IF DEFINED(LCLGTK2)}
|
||||
, GTK2Globals // for DblClickTime
|
||||
{$ENDIF}
|
||||
{$IF DEFINED(LCLQT) and (LCL_FULLVERSION < 093100)}
|
||||
, qt4, qtwidgets
|
||||
{$ENDIF}
|
||||
|
|
@ -494,18 +492,22 @@ begin
|
|||
FDraggedPageIndex := TabIndexAtClientPos(Classes.Point(X, Y));
|
||||
FStartDrag := (FDraggedPageIndex <> -1);
|
||||
end;
|
||||
{$IF DEFINED(LCLGTK2)} // emulate double click under GTK2
|
||||
if (Button = mbLeft) and Assigned(OnDblClick) and (FDraggedPageIndex < 0) then
|
||||
// Emulate double click
|
||||
if (Button = mbLeft) and Assigned(OnDblClick) then
|
||||
begin
|
||||
if ((Now - FLastMouseDownTime) > ((1/86400)*(DblClickTime/1000))) then
|
||||
FLastMouseDownTime:= Now
|
||||
else
|
||||
if ((Now - FLastMouseDownTime) > ((1/86400)*(GetDoubleClickTime/1000))) then
|
||||
begin
|
||||
FLastMouseDownTime:= Now;
|
||||
FLastMouseDownPageIndex:= FDraggedPageIndex;
|
||||
end
|
||||
else if (FDraggedPageIndex = FLastMouseDownPageIndex) then
|
||||
begin
|
||||
OnDblClick(Self);
|
||||
FStartDrag:= False;
|
||||
FLastMouseDownTime:= 0;
|
||||
FLastMouseDownPageIndex:= -1;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TFileViewNotebook.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue