From 9c5eb86128da46899e719209a92a65df012c6d8e Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <andreas.sturmlechner@gmail.com>
Date: Tue, 1 Jan 2019 19:19:19 +0100
Subject: [PATCH] Re-add accidentally removed test for QCA, KF5Wallet is
 optional

---
 CMakeLists.txt                | 18 +++++++++++++++++-
 src/libs/store/CMakeLists.txt | 15 +++++++--------
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index eed9d3c..3cb4b63 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -128,7 +128,6 @@ find_package(KF5 ${REQUIRED_KF5_VERSION} REQUIRED
             Parts
 #             Sonnet
             TextWidgets
-            Wallet
             WidgetsAddons
             WindowSystem
             XmlGui
@@ -260,6 +259,23 @@ set_package_properties(KChart PROPERTIES
         TYPE REQUIRED
     )
 
+##
+## Test for QCA2
+##
+macro_optional_find_package(Qca-qt5 2.1.0 QUIET)
+set_package_properties(Qca-qt5 PROPERTIES
+    DESCRIPTION "Qt Cryptographic Architecture"
+    URL "https:/download.kde.org/stable/qca-qt5"
+    PURPOSE "Required for encrypted OpenDocument files and encrypted xls files support"
+    TYPE OPTIONAL
+)
+
+find_package(KF5Wallet ${REQUIRED_KF5_VERSION})
+
+if(Qca-qt5_FOUND AND KF5Wallet_FOUND)
+    add_definitions( -DQCA2 )
+endif()
+
     find_package(Perl REQUIRED)
     find_package(ZLIB REQUIRED)
 
diff --git a/src/libs/store/CMakeLists.txt b/src/libs/store/CMakeLists.txt
index 2c96fa7..f998264 100644
--- a/src/libs/store/CMakeLists.txt
+++ b/src/libs/store/CMakeLists.txt
@@ -4,14 +4,8 @@ endif()
 
 ########### libkostore ###############
 
-if( Qca-qt5_FOUND )
-    add_definitions( -DQCA2 )
-endif()
-
 set(kostore_LIB_SRCS
     KoDirectoryStore.cpp
-    KoEncryptedStore.cpp
-    KoEncryptionChecker.cpp
     KoLZF.cpp
     KoStore.cpp
     KoStoreDevice.cpp
@@ -23,6 +17,12 @@ set(kostore_LIB_SRCS
     StoreDebug.cpp
     KoNetAccess.cpp # temporary while porting
 )
+if( Qca-qt5_FOUND )
+    set(kostore_LIB_SRCS ${kostore_LIB_SRCS}
+        KoEncryptedStore.cpp
+        KoEncryptionChecker.cpp
+    )
+endif()
 
 add_library(planstore SHARED ${kostore_LIB_SRCS})
 generate_export_header(planstore BASE_NAME kostore)
@@ -35,12 +35,11 @@ target_link_libraries(planstore
     PRIVATE
         Qt5::Gui
         KF5::Archive
-        KF5::Wallet
         KF5::KIOWidgets
         KF5::I18n
 )
 if( Qca-qt5_FOUND )
-    target_link_libraries(planstore PRIVATE qca-qt5)
+    target_link_libraries(planstore PRIVATE qca-qt5 KF5::Wallet)
 endif()
 
 set_target_properties(planstore PROPERTIES
diff --git a/src/libs/widgets/KoDocumentInfoDlg.cpp b/src/libs/widgets/KoDocumentInfoDlg.cpp
index 1615a61..55e2c32 100644
--- a/src/libs/widgets/KoDocumentInfoDlg.cpp
+++ b/src/libs/widgets/KoDocumentInfoDlg.cpp
@@ -26,7 +26,9 @@
 #include "KoDocumentInfo.h"
 #include "KoDocumentBase.h"
 #include "KoGlobal.h"
+#ifdef QCA2
 #include <KoEncryptionChecker.h>
+#endif
 #include "KoPageWidgetItem.h"
 //#include <KoDocumentRdfBase.h>
 #include <KoIcon.h>
@@ -105,12 +107,16 @@ KoDocumentInfoDlg::KoDocumentInfoDlg(QWidget* parent, KoDocumentInfo* docInfo)
     d->aboutUi = new Ui::KoDocumentInfoAboutWidget();
     QWidget *infodlg = new QWidget();
     d->aboutUi->setupUi(infodlg);
+#ifdef QCA2
     if (!KoEncryptionChecker::isEncryptionSupported()) {
+#endif
         d->aboutUi->lblEncryptedDesc->setVisible(false);
         d->aboutUi->lblEncrypted->setVisible(false);
         d->aboutUi->pbEncrypt->setVisible(false);
         d->aboutUi->lblEncryptedPic->setVisible(false);
+#ifdef QCA2
     }
+#endif
     d->aboutUi->cbLanguage->addItems(KoGlobal::listOfLanguages());
     d->aboutUi->cbLanguage->setCurrentIndex(-1);
 
-- 
2.20.1

