|
From: | Daniel J Sebald |
Subject: | Re: opening unknown file types in external applications |
Date: | Wed, 24 Apr 2013 01:46:43 -0500 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16 |
On 04/23/2013 04:06 PM, John W. Eaton wrote:
On 04/23/2013 02:58 PM, Torsten wrote:This one should do the job: QDesktopServices::openUrl ( QUrl::fromLocalFile ( const QString& localFile ) );OK, that works great to open files with their default applications, but what's the best way to recognize the files that should be opened in the Octave GUI's built-in editor? I don't see a general way to override the default editor or disable editing of text files so that openURL will return some kind of "sorry, I don't know how to open that file" status so that we can handle them internally in Octave. So it seems that we need to recognize the files we want to handle first, then call openURL. But nothing that I can think of (lists of filename patterns, binary vs. ASCII text, the Unix file program) really seems like a complete or reliable solution. Any ideas?
The description for the QDesktopServices object sounds like the feature to use, but it sure is skimpy as far as class members. When I think of desktop services I think of the printer manager, etc. That must not be the case.
There is a sample program that shows how to filter by extension and create menu groups:
http://qt-project.org/doc/qt-4.8/demos-embedded-desktopservices.html http://qt-project.org/doc/qt-4.8/demos-embedded-desktopservices-contenttab-cpp.html There is this method that will accept "file" as a scheme:void QDesktopServices::setUrlHandler ( "file", QObject * receiver, const char * method )
"Sets the handler for the given scheme to be the handler method provided by the receiver object."
I'm not sure what that means though. Can one write a method that will check the file name extension and if not of interest call the normal system openUrl()?
Dan
[Prev in Thread] | Current Thread | [Next in Thread] |