Verified Commit 57b1d5a8 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Use static lib for plugins instead of deprecated plugin loading

Those KCMs are not loaded externally, only in the internal settings
view.

Considering that the KCMMultiDialog has no overload for a KCModule* we
can just use the class which is used in case kleopatra is builded without KCMUtils.
parent de7fe071
......@@ -9,7 +9,6 @@ if (NOT RELEASE_SERVICE_VERSION)
set (RELEASE_SERVICE_VERSION "21.07.40")
endif()
option(FORCE_DISABLE_KCMUTILS "Force building Kleopatra without KCMUtils. Doing this will disable configuration KCM Plugins. [default=OFF]" OFF)
option(DISABLE_KWATCHGNUPG "Don't build the kwatchgnupg tool [default=OFF]" OFF)
# Standalone build. Find / include everything necessary.
......@@ -47,9 +46,6 @@ include(ECMAddAppIcon)
include(ECMQtDeclareLoggingCategory)
# Find KF5 packages
if (NOT FORCE_DISABLE_KCMUTILS)
find_package(KF5KCMUtils ${KF5_WANT_VERSION} CONFIG REQUIRED)
endif()
find_package(KF5WidgetsAddons ${KF5_WANT_VERSION} CONFIG REQUIRED)
find_package(KF5ConfigWidgets ${KF5_WANT_VERSION} CONFIG REQUIRED)
find_package(KF5CoreAddons ${KF5_WANT_VERSION} CONFIG REQUIRED)
......@@ -101,7 +97,6 @@ find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test Network Pri
find_package(Assuan2 REQUIRED)
set(HAVE_KCMUTILS ${KF5KCMUtils_FOUND})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
......
......@@ -293,11 +293,7 @@ if(WIN32)
set(_kleopatra_SRCS ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc ${_kleopatra_SRCS})
endif()
if(HAVE_KCMUTILS)
set (_kleopatra_extra_libs KF5::KCMUtils)
else()
set (_kleopatra_SRCS conf/kleopageconfigdialog.cpp ${_kleopatra_SRCS})
endif()
set (_kleopatra_SRCS conf/kleopageconfigdialog.cpp ${_kleopatra_SRCS})
ecm_qt_declare_logging_category(_kleopatra_SRCS HEADER kleopatra_debug.h IDENTIFIER KLEOPATRA_LOG CATEGORY_NAME org.kde.pim.kleopatra
DESCRIPTION "kleopatra (kleopatra)"
......@@ -342,6 +338,10 @@ file(GLOB ICONS_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/icons/*-apps-kleopatra.png")
ecm_add_app_icon(_kleopatra_SRCS ICONS ${ICONS_SRCS})
add_executable(kleopatra_bin ${_kleopatra_SRCS} ${_kleopatra_uiserver_SRCS})
# For the ConfigureDialog & KCMs
target_link_libraries(kleopatra_bin kcm_kleopatra_static)
#if (COMPILE_WITH_UNITY_CMAKE_SUPPORT)
# set_target_properties(kleopatra_bin PROPERTIES UNITY_BUILD ON)
#endif()
......
......@@ -55,13 +55,9 @@ kconfig_add_kcfg_files(kcm_kleopatra_PART_SRCS
${kleopatra_SOURCE_DIR}/src/kcfg/settings.kcfgc
)
add_library(kcm_kleopatra MODULE ${kcm_kleopatra_PART_SRCS})
add_library(kcm_kleopatra_static STATIC ${kcm_kleopatra_PART_SRCS})
if(HAVE_KCMUTILS)
set (_kcm_kleopatra_extra_libs KF5::KCMUtils)
endif()
target_link_libraries(kcm_kleopatra
target_link_libraries(kcm_kleopatra_static
KF5::Libkleo
KF5::IconThemes
KF5::I18n
......@@ -71,17 +67,3 @@ target_link_libraries(kcm_kleopatra
${_kleopatra_dbusaddons_libs}
${_kcm_kleopatra_libkleopatraclient_extra_LIBS}
)
if (COMPILE_WITH_UNITY_CMAKE_SUPPORT)
set_target_properties(kcm_kleopatra PROPERTIES UNITY_BUILD ON)
endif()
install(TARGETS kcm_kleopatra DESTINATION ${KDE_INSTALL_PLUGINDIR})
########### install files ###############
install(FILES
kleopatra_config_dirserv.desktop
kleopatra_config_appear.desktop
kleopatra_config_gnupgsystem.desktop
${_kcm_kleopatra_libkleopatraclient_extra_install_FILES}
DESTINATION ${KDE_INSTALL_KSERVICES5DIR}
)
......@@ -20,26 +20,43 @@
#include <KConfigGroup>
#include <KSharedConfig>
#if HAVE_KCMUTILS
# include <KCMultiDialog>
#else
# include "kleopageconfigdialog.h"
#endif
#include "conf/appearanceconfigpage.h"
#include "conf/cryptooperationsconfigpage.h"
#include "conf/dirservconfigpage.h"
#include "conf/gnupgsystemconfigurationpage.h"
#include "conf/smimevalidationconfigurationpage.h"
ConfigureDialog::ConfigureDialog(QWidget *parent)
#if HAVE_KCMUTILS
: KCMultiDialog(parent)
#else
: KleoPageConfigDialog(parent)
#endif
{
setFaceType(KPageDialog::List);
setWindowTitle(i18nc("@title:window", "Configure"));
addModule(QStringLiteral("kleopatra_config_dirserv"));
addModule(QStringLiteral("kleopatra_config_appear"));
addModule(QStringLiteral("kleopatra_config_cryptooperations"));
addModule(QStringLiteral("kleopatra_config_smimevalidation"));
addModule(QStringLiteral("kleopatra_config_gnupgsystem"));
addModule(i18n("Directory Services"),
i18n("Configuration of directory services"),
QStringLiteral("kleopatra/configuration.html#configuration-directory-services"),
QStringLiteral("view-certificate-server-configure"),
new DirectoryServicesConfigurationPage(this));
addModule(i18n("Appearance"),
i18n("Colors & Fonts Configuration"),
QStringLiteral("kleopatra/configuration-appearance.html"),
QStringLiteral("applications-graphics"),
new Kleo::Config::AppearanceConfigurationPage(this));
addModule(i18n("Crypto Operations"),
i18n("Configuration of Crypto Operations"),
QStringLiteral("kleopatra/configuration-cryptooperations.html"),
QStringLiteral("document-encrypt"),
new Kleo::Config::CryptoOperationsConfigurationPage(this));
addModule(i18n("S/MIME Validation"),
i18n("Configuration of S/MIME certificate validation options"),
QStringLiteral("kleopatra/configuration.html#configuration-smime-validation"),
QStringLiteral("preferences-system-network"),
new Kleo::Config::SMimeValidationConfigurationPage(this));
addModule(i18n("GnuPG System"),
i18n("Configuration of GnuPG System options"),
QStringLiteral("kleopatra/configuration.html#configuration-gnupgsystem"),
QStringLiteral("document-encrypt"),
new Kleo::Config::GnuPGSystemConfigurationPage(this));
// We store the minimum size of the dialog on hide, because otherwise
// the KCMultiDialog starts with the size of the first kcm, not
// the largest one. This way at least after the first showing of
......@@ -58,11 +75,7 @@ void ConfigureDialog::hideEvent(QHideEvent *e)
KConfigGroup geometry(KSharedConfig::openStateConfig(), "Geometry");
geometry.writeEntry("ConfigureDialogWidth", minSize.width());
geometry.writeEntry("ConfigureDialogHeight", minSize.height());
#if HAVE_KCMUTILS
KCMultiDialog::hideEvent(e);
#else
KleoPageConfigDialog::hideEvent(e);
#endif
}
ConfigureDialog::~ConfigureDialog()
......
......@@ -22,13 +22,9 @@
* and the KleoPageConfigDialog. Which is just a KPageView
* with the necessary bits of the KCMultiDialog behavior.
*/
#if HAVE_KCMUTILS
# include <KCMultiDialog>
class ConfigureDialog : public KCMultiDialog
#else
# include "kleopageconfigdialog.h"
class ConfigureDialog : public KleoPageConfigDialog
#endif
{
Q_OBJECT
public:
......
......@@ -120,7 +120,7 @@ void KleoPageConfigDialog::apply()
{
QPushButton *applyButton = buttonBox()->button(QDialogButtonBox::Apply);
applyButton->setFocus();
foreach (KCModule *module, mChangedModules) {
for (KCModule *module : mChangedModules) {
module->save();
}
mChangedModules.clear();
......@@ -193,58 +193,17 @@ void KleoPageConfigDialog::slotHelpClicked()
}
}
static KCModule *loadModule(const QString &name)
void KleoPageConfigDialog::addModule(const QString &name, const QString &comment, const QString &docPath, const QString &icon, KCModule *module)
{
QLibrary lib(KPluginLoader::findPlugin(QStringLiteral(KCM_LIBRARY_NAME)));
if (lib.load()) {
KCModule *(*create)(QWidget *, const char *);
QByteArray factorymethod("create_");
factorymethod += name.toLatin1();
create = reinterpret_cast<KCModule *(*)(QWidget *, const char *)>(lib.resolve(factorymethod.constData()));
if (create) {
return create(nullptr, name.toLatin1().constData());
} else {
qCWarning(KLEOPATRA_LOG) << "Failed to load config module: " << name;
return nullptr;
}
}
qCWarning(KLEOPATRA_LOG) << "Failed to load library: " << KCM_LIBRARY_NAME;
return nullptr;
}
void KleoPageConfigDialog::addModule(const QString &name)
{
// We use a path relative to our installation location
const QString path = qApp->applicationDirPath() +
QLatin1String("/../share/kservices5/") +
name + QLatin1String(".desktop");
if (!QFile::exists(path)) {
qCDebug(KLEOPATRA_LOG) << "Ignoring module for:" << name
<< "because the corresponding desktop file does not exist.";
return;
}
KDesktopFile desktopModule(path);
if (desktopModule.noDisplay()) {
qCDebug(KLEOPATRA_LOG) << "Ignoring module for:" << name
<< "because it has no display set.";
return;
}
KCModule *mod = loadModule(name);
mModules << mod;
const QString dName = desktopModule.readName();
mModules << module;
KPageWidgetItem *item = addPage(mod, dName);
item->setIcon(QIcon::fromTheme(desktopModule.readIcon()));
item->setHeader(desktopModule.readComment());
KPageWidgetItem *item = addPage(module, name);
item->setIcon(QIcon::fromTheme(icon));
item->setHeader(comment);
connect(mod, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
connect(module, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
mHelpUrls.insert(dName, desktopModule.readDocPath());
mHelpUrls.insert(name, docPath);
}
void KleoPageConfigDialog::moduleChanged(bool state)
......
......@@ -12,8 +12,8 @@
#include <KPageDialog>
#include <QList>
#include <KCModule>
class KCModule;
class KPageWidgetItem;
/**
......@@ -25,7 +25,7 @@ class KleoPageConfigDialog : public KPageDialog
public:
explicit KleoPageConfigDialog(QWidget *parent = nullptr);
void addModule(const QString &module);
void addModule(const QString &name, const QString &comment, const QString &docPath, const QString &icon, KCModule *module);
Q_SIGNALS:
void configCommitted();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment