Commit d19834f2 authored by Julian Wolff's avatar Julian Wolff Committed by Albert Astals Cid

Make Part::openUrl not discard OpenUrlArguments

Applications using Okular as a KPart might set a file's mime type in the OpenUrlArguments.
Okular currently clears the arguments while opening a document. This revision fixes this, allowing
applications to actually pass a file's mime type to Okular.

BUG: 386600
parent b9bc49fb
......@@ -20,6 +20,7 @@
#include "../ui/pageview.h"
#include <KConfigDialog>
#include <KParts/OpenUrlArguments>
#include <QClipboard>
#include <QMessageBox>
......@@ -86,6 +87,7 @@ class PartTest
void testGeneratorPreferences();
void testSelectText();
void testClickInternalLink();
void testOpenUrlArguments();
void testSaveAs();
void testSaveAs_data();
void testSaveAsUndoStackAnnotations();
......@@ -1205,6 +1207,21 @@ void PartTest::testSaveAsUndoStackForms_data()
QTest::newRow("pdfarchive") << KDESRCDIR "data/formSamples.pdf" << "okular" << true;
}
void PartTest::testOpenUrlArguments()
{
QVariantList dummyArgs;
Okular::Part part(NULL, NULL, dummyArgs);
KParts::OpenUrlArguments args;
args.setMimeType(QStringLiteral("text/rtf"));
part.setArguments(args);
part.openUrl(QStringLiteral(KDESRCDIR "data/file1.pdf"));
QCOMPARE( part.arguments().mimeType(), QStringLiteral("text/rtf") );
}
}
int main(int argc, char *argv[])
......
......@@ -1659,10 +1659,16 @@ bool Part::openUrl( const QUrl &_url, bool swapInsteadOfOpening )
* to read it */
m_swapInsteadOfOpening = swapInsteadOfOpening;
// The subsequent call to closeUrl clears the arguments.
// We want to save them and restore them later.
const KParts::OpenUrlArguments args = arguments();
// Close current document if any
if ( !closeUrl() )
return false;
setArguments(args);
QUrl url( _url );
if ( url.hasFragment() )
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment