Properly support file:// external links in the articles.

This commit is contained in:
Konstantin Isakov 2010-06-30 20:43:08 +04:00
parent db9c6cd85e
commit da991187ed
2 changed files with 12 additions and 4 deletions

View file

@ -386,7 +386,8 @@ bool ArticleView::isFramedArticle( QString const & ca )
bool ArticleView::isExternalLink( QUrl const & url )
{
return url.scheme() == "http" || url.scheme() == "https" ||
url.scheme() == "ftp" || url.scheme() == "mailto";
url.scheme() == "ftp" || url.scheme() == "mailto" ||
url.scheme() == "file";
}
void ArticleView::tryMangleWebsiteClickedUrl( QUrl & url, Contexts & contexts )
@ -720,10 +721,9 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref,
resourceDownloadFinished(); // Check any requests finished already
}
else
if ( url.scheme() == "http" || url.scheme() == "https" ||
url.scheme() == "ftp" || url.scheme() == "mailto" )
if ( isExternalLink( url ) )
{
// Use the system handler for the conventional internet links
// Use the system handler for the conventional external links
QDesktopServices::openUrl( url );
}
}

View file

@ -17,6 +17,8 @@
#include "termination.hh"
#include <QWebSecurityOrigin>
int main( int argc, char ** argv )
{
// The following clause fixes a race in the MinGW runtime where throwing
@ -163,6 +165,12 @@ int main( int argc, char ** argv )
// and with the main window closed.
app.setQuitOnLastWindowClosed( false );
#if QT_VERSION >= 0x040600
// Add the dictionary scheme we use as local, so that the file:// links would
// work in the articles. The function was introduced in Qt 4.6.
QWebSecurityOrigin::addLocalScheme( "gdlookup" );
#endif
MainWindow m( cfg );
app.addDataCommiter( m );