mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
UPD: i18n for the folder name in Modern Form style
This commit is contained in:
parent
8e5ddb0d7d
commit
83d6e44848
1 changed files with 44 additions and 29 deletions
|
|
@ -86,6 +86,24 @@ begin
|
|||
end;
|
||||
|
||||
|
||||
|
||||
const
|
||||
COMMON_FOLDERS: TStringArray = (
|
||||
'~/Documents',
|
||||
'~/Desktop',
|
||||
'~',
|
||||
'~/Pictures',
|
||||
'~/Movies',
|
||||
'~/Music',
|
||||
'/Applications/Utilities',
|
||||
|
||||
'~/Downloads',
|
||||
'~/Library',
|
||||
'/Applications',
|
||||
|
||||
'~/.Trash'
|
||||
);
|
||||
|
||||
type
|
||||
|
||||
{ TToolBarMenuHandler }
|
||||
|
|
@ -117,39 +135,36 @@ begin
|
|||
end;
|
||||
|
||||
procedure TToolBarMenuHandler.goToFolder(Sender: TObject);
|
||||
const
|
||||
folders: TStringArray = (
|
||||
'~/Documents',
|
||||
'~/Desktop',
|
||||
'~',
|
||||
'~/Pictures',
|
||||
'~/Movies',
|
||||
'~/Music',
|
||||
|
||||
'~/Downloads',
|
||||
'~/Library',
|
||||
'/Applications',
|
||||
'/Applications/Utilities',
|
||||
|
||||
'~/.Trash'
|
||||
);
|
||||
var
|
||||
menuItem: TMenuItem absolute Sender;
|
||||
path: String;
|
||||
begin
|
||||
path:= uDCUtils.ReplaceTilde( folders[menuItem.Tag] );
|
||||
path:= uDCUtils.ReplaceTilde( COMMON_FOLDERS[menuItem.Tag] );
|
||||
frmMain.Commands.cm_ChangeDir( [path] );
|
||||
end;
|
||||
|
||||
function getMacOSDisplayNameFromPath(const path: String): String;
|
||||
var
|
||||
cocoaPath: NSString;
|
||||
displayName: NSString;
|
||||
begin
|
||||
cocoaPath:= StringToNSString( uDCUtils.ReplaceTilde(path) );
|
||||
displayName:= NSFileManager.defaultManager.displayNameAtPath( cocoaPath );
|
||||
Result:= displayName.UTF8String;
|
||||
end;
|
||||
|
||||
function onGetFolderMenu: TMenuItem;
|
||||
var
|
||||
menu: TMenuItem;
|
||||
tag: PtrInt = 0;
|
||||
|
||||
function newItem( caption: String ): TMenuItem;
|
||||
var
|
||||
folderName: String;
|
||||
begin
|
||||
folderName:= getMacOSDisplayNameFromPath( COMMON_FOLDERS[tag] );
|
||||
Result:= TMenuItem.Create( menu );
|
||||
Result.Caption:= caption;
|
||||
Result.Caption:= caption + ' ' + folderName;
|
||||
Result.onClick:= @toolBarMenuHandler.goToFolder;
|
||||
Result.Tag:= tag;
|
||||
inc( tag );
|
||||
|
|
@ -157,19 +172,19 @@ var
|
|||
|
||||
begin
|
||||
menu:= TMenuItem.Create( frmMain );
|
||||
menu.Add( newItem(' Documents') );
|
||||
menu.Add( newItem(' Desktop') );
|
||||
menu.Add( newItem(' Home') );
|
||||
menu.Add( newItem(' Pictures') );
|
||||
menu.Add( newItem(' Movies') );
|
||||
menu.Add( newItem(' Music') );
|
||||
menu.Add( newItem(' Utilities') );
|
||||
menu.Add( newItem('') );
|
||||
menu.Add( newItem('') );
|
||||
menu.Add( newItem('') );
|
||||
menu.Add( newItem('') );
|
||||
menu.Add( newItem('') );
|
||||
menu.Add( newItem('') );
|
||||
menu.Add( newItem('') );
|
||||
menu.AddSeparator;
|
||||
menu.Add( newItem(' Downloads') );
|
||||
menu.Add( newItem(' Library') );
|
||||
menu.Add( newItem(' Applications') );
|
||||
menu.Add( newItem(' ') );
|
||||
menu.Add( newItem(' ') );
|
||||
menu.Add( newItem(' ') );
|
||||
menu.AddSeparator;
|
||||
menu.Add( newItem(' Trash') );
|
||||
menu.Add( newItem(' ') );
|
||||
Result:= menu;
|
||||
end;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue