added editable options to mini explorer, close #4

This commit is contained in:
Basile Burg 2016-01-19 22:53:11 +01:00
parent 2bbd854fc8
commit 64f38ecc87
2 changed files with 121 additions and 5 deletions

View File

@ -3,6 +3,7 @@ inherited CEMiniExplorerWidget: TCEMiniExplorerWidget
Height = 598 Height = 598
Top = 4 Top = 4
Width = 343 Width = 343
ActiveControl = lstFav
Caption = 'Mini explorer' Caption = 'Mini explorer'
ClientHeight = 598 ClientHeight = 598
ClientWidth = 343 ClientWidth = 343
@ -28,7 +29,7 @@ inherited CEMiniExplorerWidget: TCEMiniExplorerWidget
AutoWidthLastColumn = True AutoWidthLastColumn = True
Columns = < Columns = <
item item
Width = 314 Width = 330
end> end>
ReadOnly = True ReadOnly = True
ShowColumnHeaders = False ShowColumnHeaders = False
@ -90,7 +91,7 @@ inherited CEMiniExplorerWidget: TCEMiniExplorerWidget
AutoWidthLastColumn = True AutoWidthLastColumn = True
Columns = < Columns = <
item item
Width = 314 Width = 330
end> end>
ReadOnly = True ReadOnly = True
ShowColumnHeaders = False ShowColumnHeaders = False

View File

@ -8,22 +8,49 @@ uses
Classes, SysUtils, FileUtil, ListFilterEdit, Forms, Controls, Graphics, Classes, SysUtils, FileUtil, ListFilterEdit, Forms, Controls, Graphics,
ExtCtrls, Menus, ComCtrls, Buttons, lcltype, strutils, ce_widget, ce_sharedres, ExtCtrls, Menus, ComCtrls, Buttons, lcltype, strutils, ce_widget, ce_sharedres,
ce_common, ce_interfaces, ce_observer, ce_writableComponent, ce_dubproject, ce_common, ce_interfaces, ce_observer, ce_writableComponent, ce_dubproject,
ce_nativeproject, EditBtn, ce_dialogs; ce_nativeproject, EditBtn, ce_dialogs, ce_synmemo;
type type
TExplorerDoubleClick = (openInside, openOutside);
TCEMiniExplorerWidget = class;
TCEMiniExplorerEditableOptions = class(TPersistent, ICEEditableOptions)
private
fDblClick: TExplorerDoubleClick;
fContextExpand: boolean;
fExplorer: TCEMiniExplorerWidget;
function optionedWantCategory(): string;
function optionedWantEditorKind: TOptionEditorKind;
function optionedWantContainer: TPersistent;
procedure optionedEvent(anEvent: TOptionEditorEvent);
function optionedOptionsModified: boolean;
procedure apply;
published
property doubleClick: TExplorerDoubleClick read fDblClick write fDblClick;
property contextExpand: boolean read fContextExpand write fContextExpand;
public
constructor create(miniexpl: TCEMiniExplorerWidget);
destructor destroy; override;
end;
TCEMiniExplorerOptions = class(TWritableLfmTextComponent) TCEMiniExplorerOptions = class(TWritableLfmTextComponent)
private private
fFavoriteFolders: TStringList; fFavoriteFolders: TStringList;
fSplitter1Position: integer; fSplitter1Position: integer;
fSplitter2Position: integer; fSplitter2Position: integer;
fLastFolder: string; fLastFolder: string;
fDblClick: TExplorerDoubleClick;
fContextExpand: boolean;
procedure setFavoriteFolders(aValue: TStringList); procedure setFavoriteFolders(aValue: TStringList);
published published
property splitter1Position: integer read fSplitter1Position write fSplitter1Position; property splitter1Position: integer read fSplitter1Position write fSplitter1Position;
property splitter2Position: integer read fSplitter2Position write fSplitter2Position; property splitter2Position: integer read fSplitter2Position write fSplitter2Position;
property lastFolder: string read fLastFolder write fLastFolder; property lastFolder: string read fLastFolder write fLastFolder;
property favoriteFolders: TStringList read fFavoriteFolders write setFavoriteFolders; property favoriteFolders: TStringList read fFavoriteFolders write setFavoriteFolders;
property doubleClick: TExplorerDoubleClick read fDblClick write fDblClick;
property contextExpand: boolean read fContextExpand write fContextExpand;
public public
constructor create(aOwner: TComponent); override; constructor create(aOwner: TComponent); override;
destructor destroy; override; destructor destroy; override;
@ -33,7 +60,7 @@ type
{ TCEMiniExplorerWidget } { TCEMiniExplorerWidget }
TCEMiniExplorerWidget = class(TCEWidget, ICEProjectObserver) TCEMiniExplorerWidget = class(TCEWidget, ICEProjectObserver, ICEMultiDocObserver)
btnAddFav: TBitBtn; btnAddFav: TBitBtn;
btnEdit: TBitBtn; btnEdit: TBitBtn;
btnShellOpen: TBitBtn; btnShellOpen: TBitBtn;
@ -60,6 +87,9 @@ type
fFavorites: TStringList; fFavorites: TStringList;
fLastFold: string; fLastFold: string;
fLastListOrTree: TControl; fLastListOrTree: TControl;
fDblClick: TExplorerDoubleClick;
fContextExpand: boolean;
fEditableOptions: TCEMiniExplorerEditableOptions;
procedure lstFavDblClick(Sender: TObject); procedure lstFavDblClick(Sender: TObject);
procedure updateFavorites; procedure updateFavorites;
procedure treeSetRoots; procedure treeSetRoots;
@ -82,6 +112,11 @@ type
procedure projClosing(aProject: ICECommonProject); procedure projClosing(aProject: ICECommonProject);
procedure projFocused(aProject: ICECommonProject); procedure projFocused(aProject: ICECommonProject);
procedure projCompiling(aProject: ICECommonProject); procedure projCompiling(aProject: ICECommonProject);
//
procedure docNew(aDoc: TCESynMemo);
procedure docFocused(aDoc: TCESynMemo);
procedure docChanged(aDoc: TCESynMemo);
procedure docClosing(aDoc: TCESynMemo);
public public
constructor create(aIwner: TComponent); override; constructor create(aIwner: TComponent); override;
destructor destroy; override; destructor destroy; override;
@ -95,6 +130,52 @@ implementation
const const
OptsFname = 'miniexplorer.txt'; OptsFname = 'miniexplorer.txt';
{$REGION TCEMiniExplorerEditableOptions}
constructor TCEMiniExplorerEditableOptions.create(miniexpl: TCEMiniExplorerWidget);
begin
fExplorer := miniexpl;
EntitiesConnector.addObserver(self);
end;
destructor TCEMiniExplorerEditableOptions.destroy;
begin
EntitiesConnector.removeObserver(self);
inherited;
end;
procedure TCEMiniExplorerEditableOptions.apply;
begin
fExplorer.fContextExpand:= fContextExpand;
fExplorer.fDblClick:= fDblClick;
end;
function TCEMiniExplorerEditableOptions.optionedWantCategory(): string;
begin
exit('Mini explorer');
end;
function TCEMiniExplorerEditableOptions.optionedWantEditorKind: TOptionEditorKind;
begin
exit(oekGeneric);
end;
function TCEMiniExplorerEditableOptions.optionedWantContainer: TPersistent;
begin
exit(self);
end;
procedure TCEMiniExplorerEditableOptions.optionedEvent(anEvent: TOptionEditorEvent);
begin
apply;
end;
function TCEMiniExplorerEditableOptions.optionedOptionsModified: boolean;
begin
exit(false);
end;
{$ENDREGION}
{$REGION TCEMiniExplorerOptions ------------------------------------------------} {$REGION TCEMiniExplorerOptions ------------------------------------------------}
constructor TCEMiniExplorerOptions.create(aOwner: TComponent); constructor TCEMiniExplorerOptions.create(aOwner: TComponent);
begin begin
@ -119,6 +200,8 @@ begin
fLastFolder := widg.fLastFold; fLastFolder := widg.fLastFold;
fSplitter1Position := widg.Splitter1.GetSplitterPosition; fSplitter1Position := widg.Splitter1.GetSplitterPosition;
fSplitter2Position := widg.Splitter2.GetSplitterPosition; fSplitter2Position := widg.Splitter2.GetSplitterPosition;
fDblClick:= widg.fDblClick;
fContextExpand:=widg.fContextExpand;
end end
else inherited; else inherited;
end; end;
@ -134,6 +217,10 @@ begin
widg.fLastFold:=fLastFolder; widg.fLastFold:=fLastFolder;
widg.Splitter1.SetSplitterPosition(fSplitter1Position); widg.Splitter1.SetSplitterPosition(fSplitter1Position);
widg.Splitter2.SetSplitterPosition(fSplitter2Position); widg.Splitter2.SetSplitterPosition(fSplitter2Position);
widg.fDblClick := fDblClick;
widg.fEditableOptions.fDblClick := fDblClick;
widg.fContextExpand := fContextExpand;
widg.fEditableOptions.fContextExpand := fContextExpand;
widg.updateFavorites; widg.updateFavorites;
if widg.fLastFold.dirExists then if widg.fLastFold.dirExists then
widg.expandPath(fLastFolder); widg.expandPath(fLastFolder);
@ -154,6 +241,8 @@ var
begin begin
inherited; inherited;
// //
fEditableOptions:= TCEMiniExplorerEditableOptions.create(self);
//
AssignPng(btnAddFav, 'folder_add'); AssignPng(btnAddFav, 'folder_add');
AssignPng(btnRemFav, 'folder_delete'); AssignPng(btnRemFav, 'folder_delete');
AssignPng(btnShellOpen, 'flash'); AssignPng(btnShellOpen, 'flash');
@ -200,6 +289,7 @@ begin
free; free;
end; end;
// //
fEditableOptions.Free;
fFavorites.Free; fFavorites.Free;
inherited; inherited;
end; end;
@ -230,6 +320,8 @@ end;
procedure TCEMiniExplorerWidget.projFocused(aProject: ICECommonProject); procedure TCEMiniExplorerWidget.projFocused(aProject: ICECommonProject);
begin begin
fProj := aProject; fProj := aProject;
if visible and aProject.fileName.fileExists and fContextExpand then
expandPath(aProject.fileName.extractFilePath);
end; end;
procedure TCEMiniExplorerWidget.projCompiling(aProject: ICECommonProject); procedure TCEMiniExplorerWidget.projCompiling(aProject: ICECommonProject);
@ -237,6 +329,26 @@ begin
end; end;
{$ENDREGION} {$ENDREGION}
{$REGION ICEMultidocObserver ---------------------------------------------------}
procedure TCEMiniExplorerWidget.docNew(aDoc: TCESynMemo);
begin
end;
procedure TCEMiniExplorerWidget.docFocused(aDoc: TCESynMemo);
begin
if visible and aDoc.fileName.fileExists and fContextExpand then
expandPath(aDoc.fileName.extractFilePath);
end;
procedure TCEMiniExplorerWidget.docChanged(aDoc: TCESynMemo);
begin
end;
procedure TCEMiniExplorerWidget.docClosing(aDoc: TCESynMemo);
begin
end;
{$ENDREGION}
{$REGION Favorites -------------------------------------------------------------} {$REGION Favorites -------------------------------------------------------------}
procedure TCEMiniExplorerWidget.favStringsChange(sender: TObject); procedure TCEMiniExplorerWidget.favStringsChange(sender: TObject);
begin begin
@ -380,7 +492,10 @@ end;
procedure TCEMiniExplorerWidget.lstFilesDblClick(Sender: TObject); procedure TCEMiniExplorerWidget.lstFilesDblClick(Sender: TObject);
begin begin
shellOpenSelected; case fDblClick of
openInside: btnEditClick(nil);
openOutside: shellOpenSelected;
end;
end; end;
procedure TCEMiniExplorerWidget.lstFilesEnter(Sender: TObject); procedure TCEMiniExplorerWidget.lstFilesEnter(Sender: TObject);