diff --git a/CMakeLists.txt b/CMakeLists.txt index 878f34831..232038aae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,6 +112,13 @@ find_package(KF5 ${KF5_REQUIRED_VERSION} REQUIRED COMPONENTS Wallet ) +if(KF5Wallet_FOUND) + add_definitions(-DWITH_KWALLET=1) +endif() +if(KF5JS_FOUND) + add_definitions(-DWITH_KJS=1) +endif() + if(NOT WIN32 AND NOT ANDROID) find_package(KF5 ${KF5_REQUIRED_VERSION} REQUIRED COMPONENTS Activities diff --git a/core/generator.cpp b/core/generator.cpp index c88b4b225..67cefe062 100644 --- a/core/generator.cpp +++ b/core/generator.cpp @@ -25,7 +25,9 @@ #include #include +#ifdef WITH_KWALLET #include +#endif #include "document.h" #include "document_p.h" @@ -396,9 +398,11 @@ bool Generator::exportTo(const QString &, const ExportFormat &) void Generator::walletDataForFile(const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey) const { +#ifdef WITH_KWALLET *walletKey = fileName.section(QLatin1Char('/'), -1, -1); *walletName = KWallet::Wallet::NetworkWallet(); *walletFolder = QStringLiteral("KPdf"); +#endif } bool Generator::hasFeature(GeneratorFeature feature) const diff --git a/core/scripter.cpp b/core/scripter.cpp index cd1789666..16c679449 100644 --- a/core/scripter.cpp +++ b/core/scripter.cpp @@ -22,13 +22,17 @@ class Okular::ScripterPrivate public: ScripterPrivate(DocumentPrivate *doc) : m_doc(doc) +#ifdef WITH_KJS , m_kjs(nullptr) +#endif , m_event(nullptr) { } DocumentPrivate *m_doc; +#ifdef WITH_KJS QScopedPointer m_kjs; +#endif Event *m_event; }; @@ -45,6 +49,7 @@ Scripter::~Scripter() void Scripter::execute(ScriptType type, const QString &script) { qCDebug(OkularCoreDebug) << "executing the script:"; +#ifdef WITH_KJS #if 0 if ( script.length() < 1000 ) qDebug() << script; @@ -69,6 +74,7 @@ void Scripter::execute(ScriptType type, const QString &script) } d->m_kjs->execute(builtInScript + script, d->m_event); } +#endif } void Scripter::setEvent(Event *event) diff --git a/generators/ooo/generator_ooo.cpp b/generators/ooo/generator_ooo.cpp index f15d62b0a..c065a8567 100644 --- a/generators/ooo/generator_ooo.cpp +++ b/generators/ooo/generator_ooo.cpp @@ -14,7 +14,9 @@ #include #include #include +#ifdef WITH_KWALLET #include +#endif OKULAR_EXPORT_PLUGIN(KOOOGenerator, "libokularGenerator_ooo.json") @@ -33,7 +35,9 @@ void KOOOGenerator::addPages(KConfigDialog *dlg) void KOOOGenerator::walletDataForFile(const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey) const { *walletKey = fileName + QStringLiteral("/opendocument"); +#ifdef WITH_KWALLET *walletName = KWallet::Wallet::LocalWallet(); *walletFolder = KWallet::Wallet::PasswordFolder(); +#endif } #include "generator_ooo.moc" diff --git a/part.cpp b/part.cpp index cfa2d0a43..76fa567e8 100644 --- a/part.cpp +++ b/part.cpp @@ -67,11 +67,13 @@ #include #include #include +#include +#include +#ifdef WITH_KWALLET #include +#endif #include #include -#include -#include #if PURPOSE_FOUND #include @@ -1372,6 +1374,7 @@ Document::OpenResult Part::doOpenFile(const QMimeType &mimeA, const QString &fil } m_documentOpenWithPassword = false; +#ifdef WITH_KWALLET // if the file didn't open correctly it might be encrypted, so ask for a pass QString walletName, walletFolder, walletKey; m_document->walletDataForFile(fileNameToOpen, &walletName, &walletFolder, &walletKey); @@ -1437,6 +1440,7 @@ Document::OpenResult Part::doOpenFile(const QMimeType &mimeA, const QString &fil } } } +#endif } if (openResult == Document::OpenSuccess) {