Skip to content

Commit

Permalink
fix: xdg-open is used in Call extra data window to open open the atta…
Browse files Browse the repository at this point in the history
…chments
  • Loading branch information
ok2cqr committed Feb 7, 2021
1 parent a909fd3 commit ccac764
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -13,6 +13,7 @@ Legend:
- ADIF import duplicate check fixed, form layout fixed (Saku, OH1KH)
- New QSO window layout fixes (Saku, OH1KH)
- workaround for 'TRegExpr exec: empty input string' error in fpc compiler on arm64
- xdg-open is used in Call extra data window to open open the attachments

2.5.1 (2021-01-24)
- Winkeyer didn't work (Saku, OH1KH)
Expand Down
26 changes: 6 additions & 20 deletions src/fCallAttachment.pas
Expand Up @@ -51,31 +51,17 @@ procedure TfrmCallAttachment.FormClose(Sender: TObject;

procedure TfrmCallAttachment.btnViewClick(Sender: TObject);
var
ext : String = '';
prg : String = '';
dir : String = '';
CurrentDir : String = '';
begin
if flAttach.FileName = '' then exit;
dir := GetCurrentDir;

CurrentDir := GetCurrentDir;
try
SetCurrentDir(flAttach.Directory);
ext := LowerCase(ExtractFileExt(flAttach.FileName));
if ext = '.pdf' then
prg := cqrini.ReadString('ExtView','pdf','evince')
else if ext = '.txt' then
prg := cqrini.ReadString('ExtView','txt','gedit')
else if ((ext = '.html') or (ext = '.htm')) then
prg := cqrini.ReadString('ExtView','html',dmUtils.MyDefaultBrowser)
else
prg := cqrini.ReadString('ExtView','img','eog');
if prg = '' then
dmUtils.RunOnBackgroud(cqrini.ReadString('Program', 'WebBrowser', dmUtils.MyDefaultBrowser) +
' ' + flAttach.FileName)
else
dmUtils.RunOnBackgroud(prg + ' ' + flAttach.FileName)
dmUtils.RunOnBackgroud('/usr/bin/xdg-open' + ' "' + flAttach.FileName + '"');
finally
SetCurrentDir(dir)
end
SetCurrentDir(CurrentDir)
end;
end;

procedure TfrmCallAttachment.flAttachDblClick(Sender: TObject);
Expand Down

2 comments on commit ccac764

@OH1KH
Copy link
Contributor

@OH1KH OH1KH commented on ccac764 Feb 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/usr/bin/xdg-open script has nasty way to drop parts of URL after hastag # because it is a script comment prefix. I think it does not matter in this case when question is plain filenames, but for help files it is fatal and it is good to keep in mind.

And another question: Does xdg-open exist in all linux distributions? Is it always in /usr/bin ?
xdg-open makes living simple for user (no settings) but can we trust the existence?

Just thoughts...

@ok2cqr
Copy link
Owner Author

@ok2cqr ok2cqr commented on ccac764 Feb 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the reason why I added the param to the quotes. It should pass the param as it is.

I hope it exists in all distributions. As far as I know it's prefered way to open default applications assigned to specifix extensions like music, pdf, html etc.

Please sign in to comment.