mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
ADD: DARWIN: add a WlxPlugin MacPreview (#603)
* ADD: DARWIN: add a WlxPlugin MacPreview, implemented using MacOS Native QuickLook Preview * UPD: Plugin name modified and authors added in the remarks
This commit is contained in:
parent
16c9b94fda
commit
5ea1a59cbb
2 changed files with 168 additions and 0 deletions
73
plugins/wlx/MacPreview/src/MacPreview.lpi
Normal file
73
plugins/wlx/MacPreview/src/MacPreview.lpi
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="12"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
<MainUnitHasScaledStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="MacPreview"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
</General>
|
||||
<BuildModes>
|
||||
<Item Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<UseFileFilters Value="True"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<Units>
|
||||
<Unit>
|
||||
<Filename Value="MacPreview.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../MacPreview.wlx" ApplyConventions="False"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="../../../../sdk"/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
<RelocatableUnit Value="True"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="3"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<ExecutableType Value="Library"/>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions>
|
||||
<Item>
|
||||
<Name Value="EAbort"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
95
plugins/wlx/MacPreview/src/MacPreview.lpr
Normal file
95
plugins/wlx/MacPreview/src/MacPreview.lpr
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
{
|
||||
Double commander
|
||||
-------------------------------------------------------------------------
|
||||
MacOS preview plugin
|
||||
|
||||
Copyright (C) 2022 Alexander Koblov (alexx2000@mail.ru)
|
||||
Copyright (C) 2022 Rich Chang (rich2014.git@outlook.com)
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
}
|
||||
|
||||
library MacPreview;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$modeswitch objectivec1}
|
||||
|
||||
uses
|
||||
SysUtils, WlxPlugin, CocoaAll, QuickLookUI;
|
||||
|
||||
type
|
||||
TQLPItem = objcclass(NSObject, QLPreviewItemProtocol)
|
||||
url: NSURL;
|
||||
function previewItemURL: NSURL;
|
||||
end;
|
||||
|
||||
function TQLPItem.previewItemURL: NSURL;
|
||||
begin
|
||||
Result:= url;
|
||||
end;
|
||||
|
||||
function StringToNSString(const S: String): NSString;
|
||||
begin
|
||||
Result:= NSString(NSString.stringWithUTF8String(PAnsiChar(S)));
|
||||
end;
|
||||
|
||||
procedure setFilepath( view:QLPreviewView; filepath:String );
|
||||
var
|
||||
item: TQLPItem;
|
||||
begin
|
||||
if filepath=EmptyStr then begin
|
||||
item:= nil;
|
||||
end else begin
|
||||
item:= TQLPItem.alloc.init;
|
||||
item.url:= NSURL.fileURLWithPath( StringToNSString(filepath) );
|
||||
end;
|
||||
view.setPreviewItem( item );
|
||||
end;
|
||||
|
||||
function ListLoad( ParentWin:THandle; FileToLoad:pchar; {%H-}ShowFlags{%H+}:integer):THandle; cdecl;
|
||||
var
|
||||
view: QLPreviewView;
|
||||
begin
|
||||
view:= QLPreviewView.alloc.init;
|
||||
view.setShouldCloseWithWindow( false );
|
||||
NSView(ParentWin).addSubview( view );
|
||||
setFilepath( view, FileToLoad );
|
||||
Result:= THandle(view);
|
||||
end;
|
||||
|
||||
function ListLoadNext( {%H-}ParentWin{%H+},PluginWin:THandle; FileToLoad:pchar; {%H-}ShowFlags{%H+}:integer):integer; cdecl;
|
||||
begin
|
||||
setFilepath( QLPreviewView(PluginWin), FileToLoad );
|
||||
Result:= LISTPLUGIN_OK;
|
||||
end;
|
||||
|
||||
procedure ListCloseWindow(ListWin:THandle); cdecl;
|
||||
begin
|
||||
QLPreviewView(ListWin).close;
|
||||
QLPreviewView(ListWin).removeFromSuperview;
|
||||
end;
|
||||
|
||||
procedure ListGetDetectString(DetectString:pchar;maxlen:integer); cdecl;
|
||||
begin
|
||||
StrLCopy(DetectString, '(EXT!="")', MaxLen);
|
||||
end;
|
||||
|
||||
exports
|
||||
ListLoad,
|
||||
ListLoadNext,
|
||||
ListCloseWindow,
|
||||
ListGetDetectString;
|
||||
|
||||
end.
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue