summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CHURLAUD <olivier@churlaud.com>2016-08-03 14:01:30 (GMT)
committerOlivier CHURLAUD <olivier@churlaud.com>2016-08-03 14:01:30 (GMT)
commit411bdee0ebaf67d603b2c8c9eab81768939e1bd5 (patch)
treef0c998bddc4dbd9f4b2a69e184a2716ef970dc3d
parent09a99ba96bd7aafaf9d377d34ab52e2ea3d64eb6 (diff)
Open relative path again
REVIEW: 128507
-rw-r--r--CMakeLists.txt4
-rw-r--r--core/document.cpp37
2 files changed, 22 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0d1b2d1..eb2008e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -310,6 +310,10 @@ target_link_libraries(okularpart okularcore
KF5::IconThemes
KF5::ItemViews
KF5::KDELibs4Support
+ KF5::KIOCore
+ KF5::KIOFileWidgets
+ KF5::KIOWidgets
+ KF5::KIONTLM
KF5::Parts
KF5::Solid
KF5::Wallet
diff --git a/core/document.cpp b/core/document.cpp
index 5f2224e..848aadd 100644
--- a/core/document.cpp
+++ b/core/document.cpp
@@ -48,7 +48,7 @@
#include <kmessagebox.h>
#include <kmimetypetrader.h>
#include <kprocess.h>
-#include <krun.h>
+#include <KRun>
#include <kshell.h>
#include <kzip.h>
#include <KIO/Global>
@@ -3999,8 +3999,10 @@ void Document::processAction( const Action * action )
QString lilySource;
int lilyRow = 0, lilyCol = 0;
// if the url is a mailto one, invoke mailer
- if ( browse->url().scheme().compare(QLatin1String("mailto")) )
+ if ( browse->url().scheme() == QLatin1String("mailto") )
+ {
QDesktopServices::openUrl( browse->url() );
+ }
else if ( extractLilyPondSourceReference( browse->url(), &lilySource, &lilyRow, &lilyCol ) )
{
const SourceReference ref( lilySource, lilyRow, lilyCol );
@@ -4008,25 +4010,22 @@ void Document::processAction( const Action * action )
}
else
{
- QUrl url = browse->url();
+ const QUrl url = browse->url();
-#pragma message("KF5 fix this mess - relative urls should probably be resolved earlier")
// fix for #100366, documents with relative links that are the form of http:foo.pdf
-// if (url.indexOf("http:") == 0 && url.indexOf("http://") == -1 && url.right(4) == ".pdf")
-// {
-// d->openRelativeFile(url.mid(5));
-// return;
-// }
-
-// FIXME
-// // handle documents with relative path
-// if ( d->m_url.isValid() )
-// {
-// realUrl = KUrl( d->m_url.upUrl(), url );
-// }
-
-// // Albert: this is not a leak!
-// new KRun( realUrl, d->m_widget );
+ if ((url.scheme() == "http") && url.host().isEmpty() && url.fileName().endsWith("pdf"))
+ {
+ d->openRelativeFile(url.fileName());
+ return;
+ }
+
+ // handle documents with relative path
+ if ( d->m_url.isValid() )
+ {
+ const QUrl realUrl = KIO::upUrl(d->m_url).resolved(url);
+ // KRun autodeletes
+ new KRun( realUrl, d->m_widget );
+ }
}
} break;