diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,10 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) set(REQUIRED_QT_VERSION 5.10.0) -find_package(Qt5 "${REQUIRED_QT_VERSION}" CONFIG REQUIRED Widgets DBus) +find_package(Qt5 "${REQUIRED_QT_VERSION}" CONFIG REQUIRED Widgets) +if (NOT ANDROID) + find_package(Qt5 "${REQUIRED_QT_VERSION}" CONFIG REQUIRED DBus) +endif() include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) @@ -31,7 +34,9 @@ PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5ConfigWidgetsConfigVersion.cmake" SOVERSION 5) -find_package(KF5Auth ${KF5_DEP_VERSION} REQUIRED) +if (NOT ANDROID) + find_package(KF5Auth ${KF5_DEP_VERSION} REQUIRED) +endif() find_package(KF5CoreAddons ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Codecs ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Config ${KF5_DEP_VERSION} REQUIRED) @@ -84,6 +89,10 @@ include(CMakePackageConfigHelpers) +set(HAVE_KAUTH FALSE) +if (TARGET KF5::Auth) + set(HAVE_KAUTH TRUE) +endif() configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5ConfigWidgetsConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5ConfigWidgetsConfig.cmake" diff --git a/KF5ConfigWidgetsConfig.cmake.in b/KF5ConfigWidgetsConfig.cmake.in --- a/KF5ConfigWidgetsConfig.cmake.in +++ b/KF5ConfigWidgetsConfig.cmake.in @@ -1,7 +1,9 @@ @PACKAGE_INIT@ include(CMakeFindDependencyMacro) -find_dependency(KF5Auth "@KF5_DEP_VERSION@") +if (@HAVE_KAUTH@) + find_dependency(KF5Auth "@KF5_DEP_VERSION@") +endif() find_dependency(KF5Codecs "@KF5_DEP_VERSION@") find_dependency(KF5Config "@KF5_DEP_VERSION@") find_dependency(KF5WidgetsAddons "@KF5_DEP_VERSION@") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,12 +9,14 @@ khelpclient.cpp klanguagebutton.cpp klanguagename.cpp - kpastetextaction.cpp krecentfilesaction.cpp kstandardaction.cpp ktipdialog.cpp ) ecm_qt_declare_logging_category(kconfigwidgets_SRCS HEADER kconfigwidgets_debug.h IDENTIFIER KCONFIG_WIDGETS_LOG CATEGORY_NAME kf5.kconfigwidgets) +if (TARGET Qt5::DBus) + list(APPEND kconfigwidgets_SRCS kpastetextaction.cpp) +endif() qt5_add_resources(kconfigwidgets_SRCS kconfigwidgets.qrc) @@ -29,13 +31,19 @@ KF5::Codecs # KCodecActions uses KCharsets, KEncodingProber KF5::WidgetsAddons # For K*Action, KPage*, KViewStateSerializer, KAcceleratorManager, K*GuiItem KF5::ConfigGui # KStandardAction uses KStandardShortcut - KF5::Auth # KCModule uses KAuth::Action PRIVATE - Qt5::DBus # KPasteTextAction talks to Klipper via DBus KF5::CoreAddons # KCModule uses KAboutData, KTipDialog uses KRandom KF5::GuiAddons # KColorScheme uses KColorUtils KF5::I18n # For action and widget texts ) +if (TARGET KF5::Auth) + target_link_libraries(KF5ConfigWidgets PUBLIC KF5::Auth) # KCModule uses KAuth::Action +else() + target_compile_definitions(KF5ConfigWidgets PUBLIC -DKCONFIGWIDGETS_NO_KAUTH) +endif() +if (TARGET Qt5::DBus) + target_link_libraries(KF5ConfigWidgets PRIVATE Qt5::DBus) # KPasteTextAction talks to Klipper via DBus +endif() set_target_properties(KF5ConfigWidgets PROPERTIES VERSION ${KCONFIGWIDGETS_VERSION_STRING} SOVERSION ${KCONFIGWIDGETS_SOVERSION} diff --git a/src/kcmodule.h b/src/kcmodule.h --- a/src/kcmodule.h +++ b/src/kcmodule.h @@ -25,7 +25,9 @@ #include +#ifndef KCONFIGWIDGETS_NO_KAUTH #include +#endif #include #include @@ -225,6 +227,7 @@ */ bool needsAuthorization() const; +#ifndef KCONFIGWIDGETS_NO_KAUTH /** * @brief Set if the module's save() method requires authorization to be executed * @@ -243,6 +246,7 @@ * @return The action that has to be authorized to execute the save() method. */ KAuth::Action authAction() const; +#endif /** * Returns the value set by setExportText(); @@ -382,10 +386,12 @@ */ void widgetChanged(); +#ifndef KCONFIGWIDGETS_NO_KAUTH /** * The status of the auth action, if one, has changed */ void authStatusChanged(KAuth::Action::AuthStatus status); +#endif protected: diff --git a/src/kcmodule.cpp b/src/kcmodule.cpp --- a/src/kcmodule.cpp +++ b/src/kcmodule.cpp @@ -33,7 +33,9 @@ #include #include #include +#ifndef KCONFIGWIDGETS_NO_KAUTH #include +#endif class KCModulePrivate { @@ -44,7 +46,6 @@ _useRootOnlyMessage(false), _firstshow(true), _needsAuthorization(false), - _authAction(), _unmanagedWidgetChangeState(false) { } @@ -60,7 +61,9 @@ bool _firstshow : 1; bool _needsAuthorization : 1; +#ifndef KCONFIGWIDGETS_NO_KAUTH KAuth::Action _authAction; +#endif // this member is used to record the state on non-automatically // managed widgets, allowing for mixed KConfigXT-drive and manual @@ -122,6 +125,7 @@ void KCModule::setNeedsAuthorization(bool needsAuth) { d->_needsAuthorization = needsAuth; +#ifndef KCONFIGWIDGETS_NO_KAUTH if (needsAuth && d->_about) { d->_authAction = KAuth::Action(QStringLiteral("org.kde.kcontrol.") + d->_about->componentName() + QStringLiteral(".save")); d->_needsAuthorization = d->_authAction.isValid(); @@ -131,13 +135,15 @@ } else { d->_authAction = KAuth::Action(); } +#endif } bool KCModule::needsAuthorization() const { return d->_needsAuthorization; } +#ifndef KCONFIGWIDGETS_NO_KAUTH void KCModule::setAuthAction(const KAuth::Action &action) { if (!action.isValid()) { @@ -174,6 +180,7 @@ qCDebug(KCONFIG_WIDGETS_LOG) << useRootOnlyMessage(); } +#endif KCModule::~KCModule() { diff --git a/src/kstandardaction.cpp b/src/kstandardaction.cpp --- a/src/kstandardaction.cpp +++ b/src/kstandardaction.cpp @@ -232,7 +232,7 @@ pAction = new KToggleFullScreenAction(parent); pAction->setCheckable(true); break; -#ifndef KDE_NO_DEPRECATED +#if !defined(KDE_NO_DEPRECATED) && defined(QT_DBUS_LIB) case PasteText: pAction = new KPasteTextAction(parent); break;