diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,23 +46,39 @@ list(APPEND CMAKE_AUTOMOC_MACRO_NAMES "OKULAR_EXPORT_PLUGIN") endif() +set(optionalComponents) +if (ANDROID) +# we want to make sure that generally all components are found + + set(optionalComponents "OPTIONAL_COMPONENTS") +endif() + find_package(KF5 ${KF5_REQUIRED_VERSION} REQUIRED COMPONENTS Archive Bookmarks Completion Config ConfigWidgets CoreAddons Crash - DocTools IconThemes - JS KIO Parts ThreadWeaver - Wallet WindowSystem + ${optionalComponents} + DocTools + JS + 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 @@ -128,7 +144,9 @@ add_subdirectory( autotests ) add_subdirectory( conf/autotests ) -add_subdirectory(doc) +if(KF5DocTools_FOUND) + add_subdirectory(doc) +endif() include(OkularConfigureChecks.cmake) @@ -173,20 +191,9 @@ core/view.cpp core/fileprinter.cpp core/script/event.cpp - core/script/executor_kjs.cpp - core/script/kjs_app.cpp - core/script/kjs_console.cpp - core/script/kjs_data.cpp - core/script/kjs_document.cpp - core/script/kjs_event.cpp - core/script/kjs_fullscreen.cpp - core/script/kjs_field.cpp - core/script/kjs_spell.cpp - core/script/kjs_util.cpp core/synctex/synctex_parser.c core/synctex/synctex_parser_utils.c ) - qt5_add_resources(okularcore_SRCS core/script/builtin.qrc ) @@ -253,13 +260,10 @@ ${OKULAR_IOKIT} ${SHLWAPI} KF5::Archive - KF5::JS - KF5::JSApi KF5::KIOCore KF5::KIOWidgets KF5::I18n KF5::ThreadWeaver - KF5::Wallet KF5::Bookmarks Phonon::phonon4qt5 ${MATH_LIB} @@ -272,6 +276,27 @@ Qt5::Widgets ) + +if (KF5Wallet_FOUND) + target_link_libraries(okularcore PRIVATE KF5::Wallet) +endif() +if (KF5JS_FOUND) + target_sources(okularcore PRIVATE + core/script/executor_kjs.cpp + core/script/kjs_app.cpp + core/script/kjs_console.cpp + core/script/kjs_data.cpp + core/script/kjs_document.cpp + core/script/kjs_field.cpp + core/script/kjs_fullscreen.cpp + core/script/kjs_field.cpp + core/script/kjs_spell.cpp + core/script/kjs_util.cpp + core/script/kjs_event.cpp + ) + target_link_libraries(okularcore PRIVATE KF5::JS KF5::JSApi) +endif() + set_target_properties(okularcore PROPERTIES VERSION 9.0.0 SOVERSION 9 OUTPUT_NAME Okular5Core EXPORT_NAME Core) install(TARGETS okularcore EXPORT Okular5Targets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) @@ -378,10 +403,13 @@ KF5::KIOWidgets KF5::Parts KF5::Solid - KF5::Wallet KF5::WindowSystem ) +if(KF5Wallet_FOUND) + target_link_libraries(okularpart KF5::Wallet) +endif() + if (KDEExperimentalPurpose_FOUND) target_link_libraries(okularpart KDEExperimental::PurposeWidgets) endif() diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -64,7 +64,7 @@ LINK_LIBRARIES Qt5::Widgets Qt5::Test okularcore ) -if(NOT WIN32) +if(KF5Activities_FOUND) ecm_add_test(mainshelltest.cpp ../shell/okular_main.cpp ../shell/shellutils.cpp ../shell/shell.cpp TEST_NAME "mainshelltest" LINK_LIBRARIES Qt5::Test KF5::Activities okularpart okularcore diff --git a/core/generator.cpp b/core/generator.cpp --- a/core/generator.cpp +++ b/core/generator.cpp @@ -24,7 +24,10 @@ #include #include #include + +#ifdef WITH_KWALLET #include +#endif #include "document.h" #include "document_p.h" @@ -411,9 +414,11 @@ 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 --- a/core/scripter.cpp +++ b/core/scripter.cpp @@ -21,17 +21,18 @@ { public: ScripterPrivate( DocumentPrivate *doc ) - : m_doc( doc ), m_kjs( nullptr ), m_event( nullptr ) - { - } - - ~ScripterPrivate() + : m_doc( doc ) +#ifdef WITH_KJS + , m_kjs( nullptr ) +#endif + , m_event( nullptr ) { - delete m_kjs; } DocumentPrivate *m_doc; - ExecutorKJS *m_kjs; +#ifdef WITH_KJS + QScopedPointer m_kjs; +#endif Event *m_event; }; @@ -48,6 +49,7 @@ QString Scripter::execute( ScriptType type, const QString &script ) { qCDebug(OkularCoreDebug) << "executing the script:"; +#ifdef WITH_KJS #if 0 if ( script.length() < 1000 ) qDebug() << script; @@ -74,11 +76,12 @@ case JavaScript: if ( !d->m_kjs ) { - d->m_kjs = new ExecutorKJS( d->m_doc ); + d->m_kjs.reset(new ExecutorKJS( d->m_doc )); } d->m_kjs->execute( builtInScript + script, d->m_event ); break; } +#endif return QString(); } diff --git a/generators/ooo/CMakeLists.txt b/generators/ooo/CMakeLists.txt --- a/generators/ooo/CMakeLists.txt +++ b/generators/ooo/CMakeLists.txt @@ -29,9 +29,12 @@ okular_add_generator(okularGenerator_ooo ${okularGenerator_ooo_PART_SRCS}) -target_link_libraries(okularGenerator_ooo okularcore KF5::KIOCore KF5::Archive KF5::I18n KF5::Wallet ${MATH_LIB} Qt5::Xml) +target_link_libraries(okularGenerator_ooo okularcore KF5::KIOCore KF5::Archive KF5::I18n ${MATH_LIB} Qt5::Xml) if (Qca-qt5_FOUND) - target_link_libraries(okularGenerator_ooo okularcore qca-qt5) + target_link_libraries(okularGenerator_ooo qca-qt5) +endif () +if (KF5Wallet_FOUND) + target_link_libraries(okularGenerator_ooo KF5::Wallet) endif () ########### install files ############### diff --git a/generators/ooo/generator_ooo.cpp b/generators/ooo/generator_ooo.cpp --- a/generators/ooo/generator_ooo.cpp +++ b/generators/ooo/generator_ooo.cpp @@ -14,7 +14,9 @@ #include #include #include -#include +#ifdef WITH_KWALLET +# include +#endif OKULAR_EXPORT_PLUGIN(KOOOGenerator, "libokularGenerator_ooo.json") @@ -33,7 +35,9 @@ 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 --- a/part.cpp +++ b/part.cpp @@ -68,7 +68,9 @@ #include #include #include +#ifdef WITH_KWALLET #include +#endif #include #include @@ -1385,6 +1387,7 @@ } 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); @@ -1459,6 +1462,7 @@ } } } +#endif } if ( openResult == Document::OpenSuccess )