use openURL from LCLIntf, close #295

This commit is contained in:
Basile Burg 2018-04-15 11:49:03 +02:00
parent e0368618f0
commit feec564a35
3 changed files with 3 additions and 61 deletions

View File

@ -312,12 +312,6 @@ type
*)
procedure deleteDups(strings: TStrings);
(**
* like LCLIntf eponymous function but includes a woraround that's gonna
* be in Lazarus from version 1.8 (anchor + file:/// protocol under win).
*)
function openUrl(const value: string): boolean;
procedure tryRaiseFromStdErr(proc: TProcess);
// Converts all leading whites to spaces. Tabs takes width * spaces.
@ -1323,58 +1317,6 @@ begin
end;
end;
function openUrl(const value: string): boolean;
{$IFDEF WINDOWS}
function GetDefaultBrowserForCurrentUser: String;
begin
result := '';
with TRegistry.Create do
try
RootKey := HKEY_CURRENT_USER;
if OpenKeyReadOnly('Software\Classes\http\shell\open\command') then
begin
result := ReadString('');
CloseKey;
end;
finally
Free;
end;
end;
var
browser: string;
i: integer = 2;
{$ENDIF}
begin
{$IFNDEF WINDOWS}
result := LCLIntf.OpenURL(value);
{$ELSE}
if pos('file://', value) = 0 then
result := LCLIntf.OpenURL(value)
else
begin
browser := GetDefaultBrowserForCurrentUser;
if browser.isEmpty then
result := LCLIntf.OpenURL(value)
else
begin
if browser[1] = '"' then
begin
while browser[i] <> '"' do
begin
if i > browser.length then
break;
i += 1;
end;
if i <= browser.length then
browser := browser[1..i];
end;
result := ShellExecuteW(0, 'open', PWideChar(WideString(browser)),
PWideChar(WideString(value)), nil, SW_SHOWNORMAL) > 32;
end;
end;
{$ENDIF}
end;
procedure tryRaiseFromStdErr(proc: TProcess);
var
str: string = '';

View File

@ -9,7 +9,7 @@ uses
StdCtrls, AnchorDocking, AnchorDockStorage, AnchorDockOptionsDlg, Controls,
Graphics, strutils, Dialogs, Menus, ActnList, ExtCtrls, process,
{$IFDEF WINDOWS}Windows, {$ENDIF} XMLPropStorage, SynExportHTML, fphttpclient,
fpjson, jsonparser, jsonscanner,
fpjson, jsonparser, jsonscanner, LCLIntf,
ce_common, ce_ceproject, ce_synmemo, ce_writableComponent,
ce_widget, ce_messages, ce_interfaces, ce_editor, ce_projinspect, ce_ceprojeditor,
ce_search, ce_miniexplorer, ce_libman, ce_libmaneditor, ce_todolist, ce_observer,
@ -2007,7 +2007,7 @@ begin
begin
if dlgYesNo('An new release is available, do you wish to visit the release page ?' +
lineEnding + '(' + url +')') = mrYes then
openUrl(url);
OpenURL(url);
end;
end;
end;

View File

@ -9,7 +9,7 @@ uses
SynEdit, SynPluginSyncroEdit, SynCompletion, SynEditKeyCmds, LazSynEditText,
SynHighlighterLFM, SynEditHighlighter, SynEditMouseCmds, SynEditFoldedView,
SynEditMarks, SynEditTypes, SynHighlighterJScript, SynBeautifier, dialogs,
md5, Spin,
md5, Spin, LCLIntf,
//SynEditMarkupFoldColoring,
Clipbrd, fpjson, jsonparser, LazUTF8, LazUTF8Classes, Buttons, StdCtrls,
ce_common, ce_writableComponent, ce_d2syn, ce_txtsyn, ce_dialogs, ce_dastworx,