Update KDE Frameworks to 5.24.0 and add KArchive
[gpg4win.git] / patches / kconfigwidgets / 0001-Make-QDbus-optional.patch
1 #! /bin/sh
2 patch -p1 -l -f $* < $0
3 exit $?
4
5 From 438f98aed2dd8857c6ea73b3b93b9cd0abaf6993 Mon Sep 17 00:00:00 2001
6 From: Andre Heinecke <aheinecke@intevation.de>
7 Date: Thu, 28 Jan 2016 15:27:54 +0100
8 Subject: [PATCH 1/2] Make QDbus optional
9
10 This removes the Klipper integration of KPasteAction if QDBus
11 is not available.
12 ---
13  CMakeLists.txt                    | 11 ++++++++++-
14  src/CMakeLists.txt                |  7 ++++++-
15  src/config-kconfigwidgets.h.cmake |  2 ++
16  src/kpastetextaction.cpp          | 14 ++++++++++++--
17  4 files changed, 30 insertions(+), 4 deletions(-)
18  create mode 100644 src/config-kconfigwidgets.h.cmake
19
20 diff --git a/CMakeLists.txt b/CMakeLists.txt
21 index bed53d1..87f976c 100644
22 --- a/CMakeLists.txt
23 +++ b/CMakeLists.txt
24 @@ -10,7 +10,16 @@
25  set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
26
27  set(REQUIRED_QT_VERSION 5.4.0)
28 -find_package(Qt5 "${REQUIRED_QT_VERSION}" CONFIG REQUIRED Widgets DBus)
29 +if (UNIX)
30 +    find_package(Qt5 "${REQUIRED_QT_VERSION}" CONFIG REQUIRED Widgets DBus)
31 +#else()
32 +#    find_package(Qt5DBus "${REQUIRED_QT_VERSION}" CONFIG)
33 +#    set_package_properties(Qt5DBus PROPERTIES DESCRIPTION "Qt DBus Library"
34 +#                           PURPOSE "KPasteAction klipper integration."
35 +#                           URL "https://doc.qt.io/qt-5/qdbus.html"
36 +#                           TYPE OPTIONAL)
37 +endif()
38 +set (HAVE_QDBUS ${Qt5DBus_FOUND})
39  include(KDEInstallDirs)
40  include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
41  include(KDECMakeSettings)
42 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
43 index 97837b3..104b118 100644
44 --- a/src/CMakeLists.txt
45 +++ b/src/CMakeLists.txt
46 @@ -1,3 +1,8 @@
47 +if (HAVE_QDBUS)
48 +    set (KCONFIGWIDGETS_QDBUS_LIBS Qt5::DBus)
49 +endif ()
50 +configure_file(config-kconfigwidgets.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kconfigwidgets.h )
51 +
52  set(kconfigwidgets_SRCS
53    kcodecaction.cpp
54    kcolorscheme.cpp
55 @@ -29,7 +34,7 @@ target_link_libraries(KF5ConfigWidgets
56      KF5::ConfigGui # KStandardAction uses KStandardShortcut
57      KF5::Auth # KCModule uses KAuth::Action
58    PRIVATE
59 -    Qt5::DBus # KPasteTextAction talks to Klipper via DBus
60 +    ${KCONFIGWIDGETS_QDBUS_LIBS} # KPasteTextAction talks to Klipper via DBus
61      KF5::CoreAddons # KCModule uses KAboutData, KTipDialog uses KRandom
62      KF5::GuiAddons # KColorScheme uses KColorUtils
63      KF5::I18n # For action and widget texts
64 diff --git a/src/config-kconfigwidgets.h.cmake b/src/config-kconfigwidgets.h.cmake
65 new file mode 100644
66 index 0000000..4a933fa
67 --- /dev/null
68 +++ b/src/config-kconfigwidgets.h.cmake
69 @@ -0,0 +1,2 @@
70 +/* Qt5DBus available */
71 +#cmakedefine01 HAVE_QDBUS
72 diff --git a/src/kpastetextaction.cpp b/src/kpastetextaction.cpp
73 index a38aa0c..3c5a614 100644
74 --- a/src/kpastetextaction.cpp
75 +++ b/src/kpastetextaction.cpp
76 @@ -27,11 +27,15 @@
77
78  #include "kpastetextaction.h"
79
80 +#include "config-kconfigwidgets.h"
81 +
82  #include <QApplication>
83  #include <QClipboard>
84  #include <QMenu>
85 -#include <QDBusInterface>
86 -#include <QDBusReply>
87 +#if HAVE_QDBUS
88 +# include <QDBusInterface>
89 +# include <QDBusReply>
90 +#endif
91
92  class KPasteTextActionPrivate
93  {
94 @@ -97,6 +101,7 @@ void KPasteTextActionPrivate::_k_menuAboutToShow()
95  {
96      m_popup->clear();
97      QStringList list;
98 +#if HAVE_QDBUS
99      QDBusInterface klipper(QStringLiteral("org.kde.klipper"), QStringLiteral("/klipper"), QStringLiteral("org.kde.klipper.klipper"));
100      if (klipper.isValid()) {
101          QDBusReply<QStringList> reply = klipper.call(QStringLiteral("getClipboardHistoryMenu"));
102 @@ -104,6 +109,7 @@ void KPasteTextActionPrivate::_k_menuAboutToShow()
103              list = reply;
104          }
105      }
106 +#endif
107      QString clipboardText = qApp->clipboard()->text(QClipboard::Clipboard);
108      if (list.isEmpty()) {
109          list << clipboardText;
110 @@ -123,6 +129,7 @@ void KPasteTextActionPrivate::_k_menuAboutToShow()
111
112  void KPasteTextActionPrivate::_k_slotTriggered(QAction *action)
113  {
114 +#if HAVE_QDBUS
115      QDBusInterface klipper(QStringLiteral("org.kde.klipper"), QStringLiteral("/klipper"), QStringLiteral("org.kde.klipper.klipper"));
116      if (klipper.isValid()) {
117          QDBusReply<QString> reply = klipper.call(QStringLiteral("getClipboardHistoryItem"),
118 @@ -135,6 +142,9 @@ void KPasteTextActionPrivate::_k_slotTriggered(QAction *action)
119          //if (reply.isValid())
120          //  qDebug() << "Clipboard: " << qApp->clipboard()->text(QClipboard::Clipboard);
121      }
122 +#else
123 +    Q_UNUSED(action);
124 +#endif
125  }
126
127  #include "moc_kpastetextaction.cpp"
128 --
129 2.1.4