mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 15:28:14 +02:00
IconViewer: Support TAB key. Focus keyword filter by default.
This commit is contained in:
parent
302eaa8325
commit
da931797db
@ -6,7 +6,8 @@ object IconFinderForm: TIconFinderForm
|
||||
Caption = 'Icon Finder'
|
||||
ClientHeight = 396
|
||||
ClientWidth = 681
|
||||
LCLVersion = '3.99.0.0'
|
||||
LCLVersion = '4.99.0.0'
|
||||
OnActivate = FormActivate
|
||||
OnCreate = FormCreate
|
||||
object Panel1: TPanel
|
||||
Left = 6
|
||||
@ -30,6 +31,7 @@ object IconFinderForm: TIconFinderForm
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Right = 6
|
||||
Caption = 'Select'
|
||||
Enabled = False
|
||||
ModalResult = 6
|
||||
TabOrder = 0
|
||||
OnClick = btnSelectClick
|
||||
@ -48,4 +50,12 @@ object IconFinderForm: TIconFinderForm
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
object Bevel1: TBevel
|
||||
Left = 0
|
||||
Height = 8
|
||||
Top = 351
|
||||
Width = 681
|
||||
Align = alBottom
|
||||
Shape = bsBottomLine
|
||||
end
|
||||
end
|
||||
|
@ -13,17 +13,21 @@ type
|
||||
{ TIconFinderForm }
|
||||
|
||||
TIconFinderForm = class(TForm)
|
||||
Bevel1:TBevel;
|
||||
btnSelect: TButton;
|
||||
btnCancel: TButton;
|
||||
Panel1: TPanel;
|
||||
procedure btnSelectClick(Sender: TObject);
|
||||
procedure FormActivate(Sender:TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
private
|
||||
FViewer: TIconViewerFrame;
|
||||
FImageList: TCustomImageList;
|
||||
FImageIndex: Integer;
|
||||
FActivated: Boolean;
|
||||
procedure SetImageIndex(AValue: Integer);
|
||||
procedure IconDblClickHandler(Sender: TObject);
|
||||
procedure IconViewerChangeHandler(Sender: TObject);
|
||||
public
|
||||
property ImageList: TCustomImageList read FImageList write FImageList;
|
||||
property ImageIndex: Integer read FImageIndex write SetImageIndex;
|
||||
@ -38,27 +42,16 @@ implementation
|
||||
{$R *.lfm}
|
||||
|
||||
const
|
||||
// Please adjust LAZ_DIR to the location of your Lazarus installation
|
||||
{$IFDEF MSWINDOWS}
|
||||
GENERAL_PURPOSE_IMAGES = 'C:\Lazarus\lazarus-main_fpc3.2.2\images\general_purpose';
|
||||
LAZ_DIR = 'C:\Lazarus\lazarus-main_fpc3.2.2\';
|
||||
{$ELSE}
|
||||
GENERAL_PURPOSE_IMAGES = '/home/werner/Laz-main/images/general_purpose';
|
||||
LAZ_DIR = '/home/werner/Laz-main/';
|
||||
{$ENDIF}
|
||||
GENERAL_PURPOSE_IMAGES = LAZ_DIR + 'images/general_purpose';
|
||||
|
||||
{ TIconFinderForm }
|
||||
|
||||
procedure TIconFinderForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
FImageIndex := -1;
|
||||
FViewer := TIconViewerFrame.Create(self);
|
||||
FViewer.Parent := Self;
|
||||
FViewer.Align := alClient;
|
||||
FViewer.BorderSpacing.Top := 6;
|
||||
FViewer.OnIconDblClick := @IconDblClickHandler;
|
||||
FViewer.AddIconFolder(GENERAL_PURPOSE_IMAGES);
|
||||
FViewer.IconViewer.FilterByIconSize := '16 x 16';
|
||||
FViewer.cmbFilterBySize.ItemIndex := FViewer.cmbFilterBySize.Items.IndexOf(FViewer.IconViewer.FilterByIconSize);
|
||||
end;
|
||||
|
||||
procedure TIconFinderForm.btnSelectClick(Sender: TObject);
|
||||
var
|
||||
item: TIconItem;
|
||||
@ -73,12 +66,42 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TIconFinderForm.FormActivate(Sender:TObject);
|
||||
begin
|
||||
if not FActivated then
|
||||
begin
|
||||
FActivated := true;
|
||||
FViewer.FocusKeywordFilter;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TIconFinderForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
FImageIndex := -1;
|
||||
FViewer := TIconViewerFrame.Create(self);
|
||||
FViewer.Parent := Self;
|
||||
FViewer.Align := alClient;
|
||||
FViewer.BorderSpacing.Top := 6;
|
||||
FViewer.OnChange := @IconViewerChangeHandler;
|
||||
FViewer.OnIconDblClick := @IconDblClickHandler;
|
||||
FViewer.AddIconFolder(GENERAL_PURPOSE_IMAGES);
|
||||
FViewer.IconViewer.FilterByIconSize := '16 x 16';
|
||||
FViewer.cmbFilterBySize.ItemIndex := FViewer.cmbFilterBySize.Items.IndexOf(FViewer.IconViewer.FilterByIconSize);
|
||||
FViewer.TabStop := true;
|
||||
FViewer.TabOrder := 0;
|
||||
end;
|
||||
|
||||
procedure TIconFinderForm.IconDblClickHandler(Sender: TObject);
|
||||
begin
|
||||
btnSelectClick(nil);
|
||||
Modalresult := mrYes;
|
||||
end;
|
||||
|
||||
procedure TIconFinderForm.IconViewerChangeHandler(Sender: TObject);
|
||||
begin
|
||||
btnSelect.Enabled := FViewer.SelectedIcon <> nil;
|
||||
end;
|
||||
|
||||
procedure TIconFinderForm.SetImageIndex(AValue: Integer);
|
||||
begin
|
||||
if AValue<> FImageIndex then
|
||||
|
@ -162,6 +162,7 @@ begin
|
||||
|
||||
HorzScrollbar.Tracking := true;
|
||||
VertScrollbar.Tracking := true;
|
||||
TabStop := true;
|
||||
end;
|
||||
|
||||
destructor TBasicThumbnailviewer.Destroy;
|
||||
@ -387,6 +388,8 @@ begin
|
||||
else
|
||||
SelectedIndex := SelectedIndex + (ThumbnailCount - 1 - SelectedIndex) div FColCount * FColCount;
|
||||
end;
|
||||
VK_TAB:
|
||||
exit;
|
||||
end;
|
||||
Key := 0; // discard key... not handled in TWinControl or handled here
|
||||
end;
|
||||
|
@ -2,9 +2,9 @@ object IconViewerFrame: TIconViewerFrame
|
||||
Left = 0
|
||||
Height = 291
|
||||
Top = 0
|
||||
Width = 468
|
||||
Width = 606
|
||||
ClientHeight = 291
|
||||
ClientWidth = 468
|
||||
ClientWidth = 606
|
||||
TabOrder = 0
|
||||
DesignLeft = 319
|
||||
DesignTop = 171
|
||||
@ -12,66 +12,69 @@ object IconViewerFrame: TIconViewerFrame
|
||||
Left = 0
|
||||
Height = 31
|
||||
Top = 0
|
||||
Width = 468
|
||||
Width = 606
|
||||
Align = alTop
|
||||
AutoSize = True
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 31
|
||||
ClientWidth = 468
|
||||
ClientWidth = 606
|
||||
ParentBackground = False
|
||||
ParentColor = False
|
||||
TabOrder = 0
|
||||
object cmbFilterBySize: TComboBox
|
||||
AnchorSideLeft.Control = FilterPanel
|
||||
AnchorSideTop.Control = FilterPanel
|
||||
AnchorSideRight.Control = cmbFilterByStyle
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 6
|
||||
Left = 318
|
||||
Height = 23
|
||||
Top = 2
|
||||
Width = 150
|
||||
Width = 134
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 2
|
||||
DropDownCount = 24
|
||||
ItemHeight = 15
|
||||
Style = csDropDownList
|
||||
TabOrder = 0
|
||||
TabOrder = 1
|
||||
OnChange = cmbFilterBySizeChange
|
||||
end
|
||||
object cmbFilterByStyle: TComboBox
|
||||
AnchorSideLeft.Control = cmbFilterBySize
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = cmbFilterBySize
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = FilterPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 162
|
||||
Left = 458
|
||||
Height = 23
|
||||
Top = 2
|
||||
Width = 150
|
||||
Width = 142
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Right = 6
|
||||
DropDownCount = 24
|
||||
ItemHeight = 15
|
||||
Style = csDropDownList
|
||||
TabOrder = 1
|
||||
TabOrder = 2
|
||||
OnChange = cmbFilterByStyleChange
|
||||
end
|
||||
object cmbFilterByKeywords: TComboBox
|
||||
AnchorSideLeft.Control = cmbFilterByStyle
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideLeft.Control = FilterPanel
|
||||
AnchorSideTop.Control = cmbFilterBySize
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = btnKeywordEditor
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 318
|
||||
Left = 6
|
||||
Height = 23
|
||||
Top = 2
|
||||
Width = 66
|
||||
Width = 228
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Right = 2
|
||||
BorderSpacing.Bottom = 6
|
||||
DropDownCount = 24
|
||||
ItemHeight = 15
|
||||
TabOrder = 2
|
||||
TabOrder = 0
|
||||
TextHint = 'Enter keywords here'
|
||||
OnEditingDone = cmbFilterByKeywordsEditingDone
|
||||
end
|
||||
@ -79,7 +82,7 @@ object IconViewerFrame: TIconViewerFrame
|
||||
AnchorSideTop.Control = cmbFilterByKeywords
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = btnClearFilter
|
||||
Left = 386
|
||||
Left = 236
|
||||
Height = 24
|
||||
Top = 1
|
||||
Width = 24
|
||||
@ -91,9 +94,8 @@ object IconViewerFrame: TIconViewerFrame
|
||||
object btnExecuteFilter: TSpeedButton
|
||||
AnchorSideTop.Control = cmbFilterByKeywords
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = FilterPanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 438
|
||||
AnchorSideRight.Control = cmbFilterBySize
|
||||
Left = 288
|
||||
Height = 24
|
||||
Top = 1
|
||||
Width = 24
|
||||
@ -105,7 +107,7 @@ object IconViewerFrame: TIconViewerFrame
|
||||
AnchorSideTop.Control = cmbFilterByKeywords
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = btnExecuteFilter
|
||||
Left = 412
|
||||
Left = 262
|
||||
Height = 24
|
||||
Top = 1
|
||||
Width = 24
|
||||
@ -118,7 +120,7 @@ object IconViewerFrame: TIconViewerFrame
|
||||
Left = 6
|
||||
Height = 68
|
||||
Top = 223
|
||||
Width = 456
|
||||
Width = 594
|
||||
Align = alBottom
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 6
|
||||
@ -126,7 +128,7 @@ object IconViewerFrame: TIconViewerFrame
|
||||
BorderSpacing.Right = 6
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 68
|
||||
ClientWidth = 456
|
||||
ClientWidth = 594
|
||||
TabOrder = 1
|
||||
OnResize = IconDetailsPanelResize
|
||||
object CaptionPanel: TPanel
|
||||
@ -238,7 +240,7 @@ object IconViewerFrame: TIconViewerFrame
|
||||
Left = 66
|
||||
Height = 15
|
||||
Top = 51
|
||||
Width = 390
|
||||
Width = 528
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 2
|
||||
Caption = 'infoKeywords'
|
||||
@ -249,7 +251,7 @@ object IconViewerFrame: TIconViewerFrame
|
||||
Left = 0
|
||||
Height = 4
|
||||
Top = 213
|
||||
Width = 468
|
||||
Width = 606
|
||||
Align = alBottom
|
||||
Shape = bsBottomLine
|
||||
end
|
||||
@ -257,7 +259,7 @@ object IconViewerFrame: TIconViewerFrame
|
||||
Left = 0
|
||||
Height = 2
|
||||
Top = 31
|
||||
Width = 468
|
||||
Width = 606
|
||||
Align = alTop
|
||||
Shape = bsBottomLine
|
||||
end
|
||||
|
@ -20,6 +20,7 @@ unit IconViewer;
|
||||
interface
|
||||
|
||||
uses
|
||||
// RTL/FCL
|
||||
Classes, SysUtils,
|
||||
// LazUtils
|
||||
LazFileUtils, LazLoggerBase,
|
||||
@ -61,6 +62,7 @@ type
|
||||
procedure IconDetailsPanelResize(Sender: TObject);
|
||||
private
|
||||
FIconViewer: TIconThumbnailViewer;
|
||||
FOnChange: TNotifyEvent;
|
||||
FOnFilter: TNotifyEvent;
|
||||
FOnIconDblClick: TNotifyEvent;
|
||||
function GetFilteredCount: Integer;
|
||||
@ -88,6 +90,7 @@ type
|
||||
procedure AddIconFolder(AFolder: String; Hidden: Boolean = false);
|
||||
procedure CopyMetadataToNameBase(AIcon: TIconItem);
|
||||
procedure DeleteSelectedIcon;
|
||||
procedure FocusKeywordFilter;
|
||||
procedure GetKeywordsHistory(AList: TStrings);
|
||||
procedure ReadIconFolders(AList: TStrings);
|
||||
procedure SetKeywordsHistory(AList: TStrings);
|
||||
@ -104,6 +107,7 @@ type
|
||||
property SizeFilter: String read GetSizeFilter write SetSizeFilter;
|
||||
property StyleFilter: String read GetStyleFilter write SetStyleFilter;
|
||||
property TotalCount: Integer read GetTotalCount;
|
||||
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||
property OnFilter: TNotifyEvent read FOnFilter write FOnFilter;
|
||||
property OnIconDblClick: TNotifyEvent read FOnIconDblClick write FOnIconDblClick;
|
||||
|
||||
@ -267,6 +271,14 @@ end;
|
||||
procedure TIconViewerFrame.DoIconViewerSelect(Sender: TObject);
|
||||
begin
|
||||
UpdateIconDetails;
|
||||
if Assigned(FOnChange) then
|
||||
FOnChange(self);
|
||||
end;
|
||||
|
||||
procedure TIconViewerFrame.FocusKeywordFilter;
|
||||
begin
|
||||
if HandleAllocated and cmbFilterByKeywords.CanFocus then
|
||||
cmbFilterByKeywords.SetFocus;
|
||||
end;
|
||||
|
||||
function TIconViewerFrame.GetFilteredCount: Integer;
|
||||
|
@ -6,7 +6,8 @@ object IconFinderForm: TIconFinderForm
|
||||
Caption = 'Icon Finder'
|
||||
ClientHeight = 600
|
||||
ClientWidth = 800
|
||||
LCLVersion = '3.99.0.0'
|
||||
LCLVersion = '4.99.0.0'
|
||||
OnActivate = FormActivate
|
||||
OnCloseQuery = FormCloseQuery
|
||||
OnCreate = FormCreate
|
||||
object ButtonPanel: TButtonPanel
|
||||
|
@ -33,6 +33,7 @@ type
|
||||
|
||||
TIconFinderForm = class(TForm)
|
||||
ButtonPanel: TButtonPanel;
|
||||
procedure FormActivate(Sender:TObject);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure OKButtonClick(Sender: TObject);
|
||||
@ -41,8 +42,10 @@ type
|
||||
FOnIconSelectClick: TNotifyEvent;
|
||||
FOnIconDblClick: TNotifyEvent;
|
||||
FSettingsNodeName: String;
|
||||
FActivated: Boolean;
|
||||
protected
|
||||
procedure AddDefaultIconFolder;
|
||||
procedure IconViewerChangeHandler(Sender: TObject);
|
||||
procedure IconViewerDblClickHandler(Sender: TObject);
|
||||
procedure IconViewerFilterHandler(Sender: TObject);
|
||||
procedure IconSelectHandler(Sender: TObject);
|
||||
@ -62,6 +65,15 @@ implementation
|
||||
|
||||
{ TIconFinderForm }
|
||||
|
||||
procedure TIconFinderForm.FormActivate(Sender:TObject);
|
||||
begin
|
||||
if not FActivated then
|
||||
begin
|
||||
FActivated := true;
|
||||
FViewer.FocusKeywordFilter;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TIconFinderForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
FViewer := TIconViewerFrame.Create(self);
|
||||
@ -75,6 +87,8 @@ begin
|
||||
FViewer.BorderSpacing.Top := 6;
|
||||
FViewer.OnIconDblClick := @IconViewerDblClickHandler;
|
||||
FViewer.OnFilter := @IconViewerFilterHandler;
|
||||
FViewer.OnChange := @IconViewerChangeHandler;
|
||||
ButtonPanel.OKButton.Enabled := false;
|
||||
ButtonPanel.OKButton.Caption := RSIconFinderIDE_Select;
|
||||
end;
|
||||
|
||||
@ -100,6 +114,11 @@ begin
|
||||
FOnIconSelectClick(Sender);
|
||||
end;
|
||||
|
||||
procedure TIconFinderForm.IconViewerChangeHandler(Sender: TObject);
|
||||
begin
|
||||
ButtonPanel.OKButton.Enabled := FViewer.SelectedIcon <> nil;
|
||||
end;
|
||||
|
||||
procedure TIconFinderForm.IconViewerDblClickHandler(Sender: TObject);
|
||||
begin
|
||||
if Assigned(FOnIconDblClick) then
|
||||
|
@ -43,6 +43,15 @@ inherited ImageListEditorDlgEx: TImageListEditorDlgEx
|
||||
end
|
||||
inherited ToolBar: TToolBar
|
||||
Width = 592
|
||||
inherited tbSeparator1: TToolButton
|
||||
Height = 40
|
||||
end
|
||||
inherited tbSeparator2: TToolButton
|
||||
Height = 40
|
||||
end
|
||||
inherited tbSeparator3: TToolButton
|
||||
Height = 40
|
||||
end
|
||||
end
|
||||
inherited Splitter1: TSplitter
|
||||
Height = 389
|
||||
|
Loading…
Reference in New Issue
Block a user