mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Properly support file:// external links in the articles.
This commit is contained in:
parent
db9c6cd85e
commit
da991187ed
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
8
main.cc
8
main.cc
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue