diff --git a/CMakeLists.txt b/CMakeLists.txt index b43687c..36eaef6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,96 +1,96 @@ cmake_minimum_required(VERSION 3.5) -set(PIM_VERSION "5.10.41") +set(PIM_VERSION "5.10.42") project(pimcommon VERSION ${PIM_VERSION}) set(KF5_MIN_VERSION "5.53.0") find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED) set(LIBRARY_NAMELINK) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH}) include(GenerateExportHeader) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMGeneratePriFile) include(ECMSetupVersion) include(FeatureSummary) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(ECMQtDeclareLoggingCategory) include(ECMAddTests) include(ECMInstallIcons) set(PIMCOMMON_LIB_VERSION ${PIM_VERSION}) set(AKONADICONTACT_LIB_VERSION "5.10.40") set(LIBKDEPIM_LIB_VERSION "5.10.40") set(QT_REQUIRED_VERSION "5.10.0") set(KMIME_LIB_VERSION "5.10.40") set(KIMAP_LIB_VERSION "5.10.40") set(KCONTACTS_LIB_VERSION "5.10.40") set(KPIMTEXTEDIT_LIB_VERSION "5.10.40") set(AKONADI_VERSION "5.10.40") find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets DBus Network Test Xml PrintSupport) find_package(KF5Archive ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Codecs ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Completion ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Config ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5ConfigWidgets ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5DBusAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5I18n ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5IconThemes ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5ItemModels ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5JobWidgets ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5NewStuff ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Service ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5WidgetsAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5XmlGui ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiContact ${AKONADICONTACT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Contacts ${KCONTACTS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5IMAP ${KIMAP_LIB_VERSION} CONFIG REQUIRED) find_package(KF5LibkdepimAkonadi ${LIBKDEPIM_LIB_VERSION} CONFIG REQUIRED) find_package(KF5PimTextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED) find_package(Grantlee5 "5.1" CONFIG REQUIRED) find_package(KF5Purpose CONFIG QUIET) set_package_properties(KF5Purpose PROPERTIES DESCRIPTION "Support for sharing file" TYPE OPTIONAL ) if (KF5Purpose_FOUND) message(STATUS "Found KF5 Purpose, filesharing enabled") set(KF5_USE_PURPOSE true) add_definitions(-DKF5_USE_PURPOSE) else() message(STATUS "KF5 Purpose not found, filesharing disabled") endif() find_package(KF5DesignerPlugin ${KF5_MIN_VERSION} CONFIG) set_package_properties(KF5DesignerPlugin PROPERTIES DESCRIPTION "KF5 designer plugin" TYPE OPTIONAL) find_package(Xsltproc) set_package_properties(Xsltproc PROPERTIES DESCRIPTION "XSLT processor from libxslt" TYPE REQUIRED PURPOSE "Required to generate D-Bus interfaces for all Akonadi resources.") if(BUILD_TESTING) find_package(KF5Mime ${KMIME_LIB_VERSION} CONFIG REQUIRED) add_definitions(-DBUILD_TESTING) endif(BUILD_TESTING) ########### Targets ########### add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000) add_subdirectory(src) install( FILES pimcommon.renamecategories pimcommon.categories DESTINATION ${KDE_INSTALL_CONFDIR} ) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/pimcommon/CMakeLists.txt b/src/pimcommon/CMakeLists.txt index 2e34ef5..2e4952e 100644 --- a/src/pimcommon/CMakeLists.txt +++ b/src/pimcommon/CMakeLists.txt @@ -1,446 +1,447 @@ set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5PimCommon") configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5PimCommonConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5PimCommonConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) ecm_setup_version(PROJECT VARIABLE_PREFIX PIMCOMMON VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/pimcommon_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5PimCommonConfigVersion.cmake" SOVERSION 5 ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5PimCommonConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5PimCommonConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5PimCommonTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5PimCommonTargets.cmake NAMESPACE KF5::) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pimcommon_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel ) configure_file(config-pimcommon.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-pimcommon.h) set(libpimcommon_autocorrection_SRCS autocorrection/autocorrection.cpp autocorrection/autocorrectionwidget.cpp autocorrection/autocorrectionlistwidget.cpp autocorrection/autocorrectiontreewidget.cpp autocorrection/autocorrectionlanguage.cpp autocorrection/import/importlibreofficeautocorrection.cpp autocorrection/import/importkmailautocorrection.cpp autocorrection/import/importabstractautocorrection.cpp autocorrection/widgets/lineeditwithautocorrection.cpp autocorrection/widgets/richtexteditwithautocorrection.cpp ) set(libpimcommon_generericplugin_SRCS genericplugins/pluginutil.cpp genericplugins/genericpluginmanager.cpp genericplugins/genericplugin.cpp genericplugins/abstractgenericplugin.cpp genericplugins/abstractgenericplugininterface.cpp ) set(libpimcommon_configure_plugins_SRCS configureplugins/configurepluginslistwidget.cpp configureplugins/configurepluginswidget.cpp configureplugins/configureplugindialog.cpp ) set(libpimcommon_translator_SRCS translator/translatorutil.cpp translator/translatorwidget.cpp translator/translatordebugdialog.cpp translator/googletranslator.cpp ) set(libpimcommon_templatewidgets_SRCS templatewidgets/templatelistwidget.cpp templatewidgets/templateeditdialog.cpp templatewidgets/templatemanager.cpp ) set(libpimcommon_widgets_SRCS widgets/minimumcombobox.cpp widgets/renamefiledialog.cpp widgets/simplestringlisteditor.cpp widgets/customtreeview.cpp widgets/configureimmutablewidgetutils.cpp widgets/kactionmenuchangecase.cpp widgets/spellchecklineedit.cpp widgets/kpimprintpreviewdialog.cpp widgets/lineeditwithcompleterng.cpp widgets/purposemenuwidget.cpp ) set(libpimcommon_customtools_SRCS customtools/customtoolsplugin.cpp customtools/customtoolspluginmanager.cpp customtools/customtoolswidgetng.cpp customtools/customtoolsviewinterface.cpp ) set(libpimcommon_util_SRCS util/pimutil.cpp util/networkutil.cpp ) set(libpimcommon_migrate_SRCS migration/migrateapplicationfiles.cpp migration/migratefileinfo.cpp ) set(libpimcommon_shareserviceurl_SRCS shareserviceurl/shareserviceurlmanager.cpp ) set(libpimcommon_logactivities_SRCS logactivities/logactivitiesmanager.cpp logactivities/logactivitiesdialog.cpp logactivities/logactivitieswidget.cpp logactivities/logactivitiespurposemenuwidget.cpp ) set(libpimcommon_genericgrantlee_SRCS genericgrantlee/genericgrantleeformatter.cpp ) set(libpimcommon_networkmanager_SRCS network/networkmanager.cpp ) set(libpimcommon_SRCS settings/pimcommonsettings.cpp ${libpimcommon_configure_plugins_SRCS} ${libpimcommon_networkmanager_SRCS} ${libpimcommon_configure_plugins_SRCS} ${libpimcommon_genericgrantlee_SRCS} ${libpimcommon_shareserviceurl_SRCS} ${libpimcommon_migrate_SRCS} ${libpimcommon_util_SRCS} ${libpimcommon_texteditor_SRCS} ${libpimcommon_storageservice_SRCS} ${libpimcommon_autocorrection_SRCS} ${libpimcommon_translator_SRCS} ${libpimcommon_templatewidgets_SRCS} ${libpimcommon_widgets_SRCS} ${libpimcommon_customtools_SRCS} ${libpimcommon_logactivities_SRCS} ${libpimcommon_generericplugin_SRCS} ) qt5_add_resources(libpimcommon_SRCS widgets/icons.qrc) ecm_qt_declare_logging_category(libpimcommon_SRCS HEADER pimcommon_debug.h IDENTIFIER PIMCOMMON_LOG CATEGORY_NAME org.kde.pim.pimcommon) ki18n_wrap_ui(libpimcommon_SRCS autocorrection/ui/autocorrectionwidget.ui ) macro(add_resource_iface _kcfgFile _ifaceName _className _fileName) kcfg_generate_dbus_interface(${CMAKE_CURRENT_SOURCE_DIR}/${_kcfgFile} ${_ifaceName}) qt5_add_dbus_interface(libpimcommon_SRCS ${CMAKE_CURRENT_BINARY_DIR}/${_ifaceName}.xml ${_fileName} ${_className} ) endmacro() add_resource_iface(util/imapresource.kcfg org.kde.Akonadi.Imap.Settings ImapSettings imapresourcesettings) kconfig_add_kcfg_files(libpimcommon_SRCS settings/pimcommonsetting_base.kcfgc ) add_library(KF5PimCommon ${libpimcommon_SRCS}) generate_export_header(KF5PimCommon BASE_NAME pimcommon) add_library(KF5::PimCommon ALIAS KF5PimCommon) target_link_libraries(KF5PimCommon PUBLIC Qt5::Network KF5::KIOCore KF5::ConfigWidgets PRIVATE KF5::I18n KF5::Libkdepim KF5::Archive KF5::NewStuff KF5::PimTextEdit KF5::XmlGui KF5::PimTextEdit KF5::IconThemes KF5::Completion KF5::KIOWidgets Qt5::PrintSupport Grantlee5::Templates ) if (KF5_USE_PURPOSE) target_link_libraries(KF5PimCommon PRIVATE KF5::Purpose KF5::PurposeWidgets) endif() target_include_directories(KF5PimCommon INTERFACE "$") target_include_directories(KF5PimCommon PUBLIC "$") set_target_properties(KF5PimCommon PROPERTIES VERSION ${PIMCOMMON_VERSION_STRING} SOVERSION ${PIMCOMMON_SOVERSION} EXPORT_NAME PimCommon ) install(TARGETS KF5PimCommon EXPORT KF5PimCommonTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS} ${LIBRARY_NAMELINK} ) if (BUILD_TESTING) add_subdirectory(translator/autotests) add_subdirectory(autocorrection/autotests) add_subdirectory(widgets/autotests) add_subdirectory(migration/autotests) add_subdirectory(util/autotests) add_subdirectory(shareserviceurl/autotests) add_subdirectory(translator/tests) add_subdirectory(widgets/tests) add_subdirectory(autocorrection/tests) add_subdirectory(customtools/autotests) add_subdirectory(autotests) add_subdirectory(logactivities/autotests) add_subdirectory(logactivities/tests) add_subdirectory(configureplugins/autotests) add_subdirectory(genericplugins/autotests) endif() ecm_generate_headers(PimCommon_CamelCasegenericplugins_HEADERS HEADER_NAMES PluginUtil GenericPluginManager GenericPlugin AbstractGenericPlugin AbstractGenericPluginInterface REQUIRED_HEADERS PimCommon_genericplugins_HEADERS PREFIX PimCommon RELATIVE genericplugins ) ecm_generate_headers(PimCommon_CamelCasegenericgrantlee_HEADERS HEADER_NAMES GenericGrantleeFormatter REQUIRED_HEADERS PimCommon_genericgrantlee_HEADERS PREFIX PimCommon RELATIVE genericgrantlee ) ecm_generate_headers(PimCommon_CamelCasenetworkmanager_HEADERS HEADER_NAMES NetworkManager REQUIRED_HEADERS PimCommon_networkmanager_HEADERS PREFIX PimCommon RELATIVE network ) ecm_generate_headers(PimCommon_CamelCase_HEADERS HEADER_NAMES PimUtil NetworkUtil REQUIRED_HEADERS PimCommon_HEADERS PREFIX PimCommon RELATIVE util ) ecm_generate_headers(PimCommon_Camelcasesettings_HEADERS HEADER_NAMES PimCommonSettings REQUIRED_HEADERS PimCommon_settings_HEADERS PREFIX PimCommon RELATIVE settings ) ecm_generate_headers(PimCommon_Camelcaselogactivities_HEADERS HEADER_NAMES LogActivitiesManager REQUIRED_HEADERS PimCommon_logactivities_HEADERS PREFIX PimCommon RELATIVE logactivities ) ecm_generate_headers(PimCommon_Camelcaseshareserviceurl_HEADERS HEADER_NAMES ShareServiceUrlManager REQUIRED_HEADERS PimCommon_shareserviceurl_HEADERS PREFIX PimCommon RELATIVE shareserviceurl ) ecm_generate_headers(PimCommon_Camelcasetranslator_HEADERS HEADER_NAMES TranslatorWidget REQUIRED_HEADERS PimCommon_translator_HEADERS PREFIX PimCommon RELATIVE translator ) ecm_generate_headers(PimCommon_Camelcasecustomtools_HEADERS HEADER_NAMES CustomToolsWidgetng CustomToolsPlugin CustomToolsViewInterface + CustomToolsPluginManager REQUIRED_HEADERS PimCommon_customtools_HEADERS PREFIX PimCommon RELATIVE customtools ) ecm_generate_headers(PimCommon_Camelcasemigrate_HEADERS HEADER_NAMES MigrateApplicationFiles MigrateFileInfo REQUIRED_HEADERS PimCommon_migrate_HEADERS PREFIX PimCommon RELATIVE migration ) ecm_generate_headers(PimCommon_Camelcaseautocorrectionwidgets_HEADERS HEADER_NAMES RichTexteditWithAutoCorrection LineEditWithAutoCorrection REQUIRED_HEADERS PimCommon_autocorrectionwidgets_HEADERS PREFIX PimCommon RELATIVE autocorrection/widgets/ ) ecm_generate_headers(PimCommon_Camelcaseautocorrection_HEADERS HEADER_NAMES AutoCorrectionWidget AutoCorrectionLanguage AutoCorrection REQUIRED_HEADERS PimCommon_autocorrection_HEADERS PREFIX PimCommon RELATIVE autocorrection/ ) ecm_generate_headers(PimCommon_Camelcasetemplatelist_HEADERS HEADER_NAMES TemplateListWidget TemplateManager REQUIRED_HEADERS PimCommon_templatelist_HEADERS PREFIX PimCommon RELATIVE templatewidgets ) ecm_generate_headers(PimCommon_Camelcasewidgets_HEADERS HEADER_NAMES CustomTreeView SpellCheckLineEdit MinimumComboBox ConfigureImmutableWidgetUtils RenameFileDialog SimpleStringListEditor KActionMenuChangeCase KPimPrintPreviewDialog LineEditWithCompleterNg PurposeMenuWidget REQUIRED_HEADERS PimCommon_widgets_HEADERS PREFIX PimCommon RELATIVE widgets ) ecm_generate_headers(PimCommon_Camelcaseconfigureplugins_HEADERS HEADER_NAMES ConfigurePluginsListWidget ConfigurePluginsWidget ConfigurePluginDialog REQUIRED_HEADERS PimCommon_configureplugins_HEADERS PREFIX PimCommon RELATIVE configureplugins ) ecm_generate_pri_file(BASE_NAME PimCommon LIB_NAME KF5PimCommon DEPS "Network KIOCore ConfigWidgets" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/PimCommon ) install(FILES ${PimCommon_Camelcaseconfigureplugins_HEADERS} ${PimCommon_CamelCasegenericplugins_HEADERS} ${PimCommon_Camelcaselogactivities_HEADERS} ${PimCommon_CamelCasenetworkmanager_HEADERS} ${PimCommon_CamelCase_HEADERS} ${PimCommon_CamelCasegenericgrantlee_HEADERS} ${PimCommon_CamelCasejob_HEADERS} ${PimCommon_Camelcaseautocorrection_HEADERS} ${PimCommon_Camelcaseautocorrectionwidgets_HEADERS} ${PimCommon_Camelcasecustomtools_HEADERS} ${PimCommon_Camelcasemanagerserversidesubscription_HEADERS} ${PimCommon_Camelcasemigrate_HEADERS} ${PimCommon_Camelcaseplaintexteditor_HEADERS} ${PimCommon_Camelcaserichtexteditor_HEADERS} ${PimCommon_Camelcasescript_HEADERS} ${PimCommon_Camelcasesettings_HEADERS} ${PimCommon_Camelcaseshareserviceurl_HEADERS} ${PimCommon_Camelcasestorageservice_HEADERS} ${PimCommon_Camelcasestorageservicedialog_HEADERS} ${PimCommon_Camelcasestorageserviceinterface_HEADERS} ${PimCommon_Camelcasestorageservicesettings_HEADERS} ${PimCommon_Camelcasestorageservicewidgets_HEADERS} ${PimCommon_Camelcasetemplatelist_HEADERS} ${PimCommon_Camelcasetexteditor_commonwidget_HEADERS} ${PimCommon_Camelcasetranslator_HEADERS} ${PimCommon_Camelcasewidgets_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/PimCommon COMPONENT Devel ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/imapresourcesettings.h ${CMAKE_CURRENT_BINARY_DIR}/pimcommon_debug.h ${CMAKE_CURRENT_BINARY_DIR}/pimcommon_export.h ${CMAKE_CURRENT_BINARY_DIR}/pimcommonsetting_base.h ${CMAKE_CURRENT_BINARY_DIR}/config-pimcommon.h ${PimCommon_HEADERS} ${PimCommon_genericplugins_HEADERS} ${PimCommon_configureplugins_HEADERS} ${PimCommon_networkmanager_HEADERS} ${PimCommon_autocorrection_HEADERS} ${PimCommon_autocorrectionwidgets_HEADERS} ${PimCommon_customtools_HEADERS} ${PimCommon_genericgrantlee_HEADERS} ${PimCommon_job_HEADERS} ${PimCommon_managerserversidesubscription_HEADERS} ${PimCommon_migrate_HEADERS} ${PimCommon_plaintexteditor_HEADERS} ${PimCommon_richtexteditor_HEADERS} ${PimCommon_settings_HEADERS} ${PimCommon_shareserviceurl_HEADERS} ${PimCommon_storageservice_HEADERS} ${PimCommon_storageservicedialog_HEADERS} ${PimCommon_storageserviceinterface_HEADERS} ${PimCommon_storageservicesettings_HEADERS} ${PimCommon_storageservicewidgets_HEADERS} ${PimCommon_templatelist_HEADERS} ${PimCommon_texteditor_commonwidget_HEADERS} ${PimCommon_translator_HEADERS} ${PimCommon_widgets_HEADERS} ${PimCommon_logactivities_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/pimcommon COMPONENT Devel ) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) add_subdirectory(designer) diff --git a/src/pimcommon/customtools/autotests/customtoolswidgetngtest.cpp b/src/pimcommon/customtools/autotests/customtoolswidgetngtest.cpp index 7b70fbe..6155c40 100644 --- a/src/pimcommon/customtools/autotests/customtoolswidgetngtest.cpp +++ b/src/pimcommon/customtools/autotests/customtoolswidgetngtest.cpp @@ -1,44 +1,44 @@ /* Copyright (c) 2015-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "customtoolswidgetngtest.h" #include "customtools/customtoolswidgetng.h" #include #include #include #include CustomToolsWidgetNgTest::CustomToolsWidgetNgTest(QObject *parent) : QObject(parent) { QStandardPaths::setTestModeEnabled(true); } CustomToolsWidgetNgTest::~CustomToolsWidgetNgTest() { } void CustomToolsWidgetNgTest::shouldHaveDefaultValue() { - PimCommon::CustomToolsWidgetNg widget(new KActionCollection(this)); + PimCommon::CustomToolsWidgetNg widget; widget.show(); QStackedWidget *stackWidget = widget.findChild(QStringLiteral("stackedwidget")); QVERIFY(stackWidget); } QTEST_MAIN(CustomToolsWidgetNgTest) diff --git a/src/pimcommon/customtools/customtoolsplugin.cpp b/src/pimcommon/customtools/customtoolsplugin.cpp index dfb1fec..fff49a4 100644 --- a/src/pimcommon/customtools/customtoolsplugin.cpp +++ b/src/pimcommon/customtools/customtoolsplugin.cpp @@ -1,40 +1,67 @@ /* Copyright (c) 2015-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "customtoolsplugin.h" using namespace PimCommon; class PimCommon::CustomToolsPluginPrivate { public: CustomToolsPluginPrivate() { } + bool enabled = false; }; CustomToolsPlugin::CustomToolsPlugin(QObject *parent) : QObject(parent) , d(new PimCommon::CustomToolsPluginPrivate) { } CustomToolsPlugin::~CustomToolsPlugin() { delete d; } + + +bool CustomToolsPlugin::hasConfigureDialog() const +{ + return false; +} + +void CustomToolsPlugin::showConfigureDialog(QWidget *parent) +{ + Q_UNUSED(parent); +} + +QString CustomToolsPlugin::description() const +{ + return {}; +} + +void CustomToolsPlugin::setIsEnabled(bool enabled) +{ + d->enabled = enabled; +} + +bool CustomToolsPlugin::isEnabled() const +{ + return d->enabled; +} diff --git a/src/pimcommon/customtools/customtoolsplugin.h b/src/pimcommon/customtools/customtoolsplugin.h index 014fa1c..b813836 100644 --- a/src/pimcommon/customtools/customtoolsplugin.h +++ b/src/pimcommon/customtools/customtoolsplugin.h @@ -1,43 +1,53 @@ /* Copyright (c) 2015-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CUSTOMTOOLSPLUGIN_H #define CUSTOMTOOLSPLUGIN_H #include "pimcommon_export.h" #include class KActionCollection; namespace PimCommon { class CustomToolsWidgetNg; class CustomToolsViewInterface; class CustomToolsPluginPrivate; class PIMCOMMON_EXPORT CustomToolsPlugin : public QObject { Q_OBJECT public: explicit CustomToolsPlugin(QObject *parent = nullptr); ~CustomToolsPlugin(); virtual PimCommon::CustomToolsViewInterface *createView(KActionCollection *ac, CustomToolsWidgetNg *parent = nullptr) = 0; - virtual QString customToolName() const = 0; + Q_REQUIRED_RESULT virtual QString customToolName() const = 0; + + Q_REQUIRED_RESULT virtual bool hasConfigureDialog() const; + virtual void showConfigureDialog(QWidget *parent); + + void emitConfigChanged(); + + Q_REQUIRED_RESULT virtual QString description() const; + + void setIsEnabled(bool enabled); + Q_REQUIRED_RESULT bool isEnabled() const; private: CustomToolsPluginPrivate *const d; }; } #endif // CUSTOMTOOLSPLUGIN_H diff --git a/src/pimcommon/customtools/customtoolspluginmanager.h b/src/pimcommon/customtools/customtoolspluginmanager.h index 066c7df..51c1173 100644 --- a/src/pimcommon/customtools/customtoolspluginmanager.h +++ b/src/pimcommon/customtools/customtoolspluginmanager.h @@ -1,41 +1,41 @@ /* Copyright (c) 2015-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CUSTOMTOOLSPLUGINMANAGER_H #define CUSTOMTOOLSPLUGINMANAGER_H #include -#include "pimcommon_private_export.h" +#include "pimcommon_export.h" namespace PimCommon { class CustomToolsPlugin; class CustomToolsPluginManagerPrivate; -class PIMCOMMON_TESTS_EXPORT CustomToolsPluginManager : public QObject +class PIMCOMMON_EXPORT CustomToolsPluginManager : public QObject { Q_OBJECT public: static CustomToolsPluginManager *self(); explicit CustomToolsPluginManager(QObject *parent = nullptr); ~CustomToolsPluginManager(); Q_REQUIRED_RESULT QVector pluginsList() const; private: CustomToolsPluginManagerPrivate *const d; }; } #endif // CUSTOMTOOLSPLUGINMANAGER_H diff --git a/src/pimcommon/customtools/customtoolswidgetng.cpp b/src/pimcommon/customtools/customtoolswidgetng.cpp index 4630a49..12810db 100644 --- a/src/pimcommon/customtools/customtoolswidgetng.cpp +++ b/src/pimcommon/customtools/customtoolswidgetng.cpp @@ -1,114 +1,112 @@ /* Copyright (c) 2015-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "customtoolswidgetng.h" #include "customtoolsplugin.h" #include "customtoolspluginmanager.h" #include "customtoolsviewinterface.h" #include #include #include using namespace PimCommon; class PimCommon::CustomToolsWidgetNgPrivate { public: CustomToolsWidgetNgPrivate() { } QStackedWidget *mStackedWidget = nullptr; QList mListInterfaceView; }; -CustomToolsWidgetNg::CustomToolsWidgetNg(KActionCollection *ac, QWidget *parent) +CustomToolsWidgetNg::CustomToolsWidgetNg(QWidget *parent) : QWidget(parent) , d(new PimCommon::CustomToolsWidgetNgPrivate) { QHBoxLayout *lay = new QHBoxLayout(this); d->mStackedWidget = new QStackedWidget; d->mStackedWidget->setObjectName(QStringLiteral("stackedwidget")); lay->addWidget(d->mStackedWidget); - initializeView(ac); hide(); } CustomToolsWidgetNg::~CustomToolsWidgetNg() { delete d; } -void CustomToolsWidgetNg::initializeView(KActionCollection *ac) +void CustomToolsWidgetNg::initializeView(KActionCollection *ac, const QVector &localPluginsList) { - const QVector localPluginsList = PimCommon::CustomToolsPluginManager::self()->pluginsList(); for (CustomToolsPlugin *plugin : localPluginsList) { PimCommon::CustomToolsViewInterface *localCreateView = plugin->createView(ac, this); d->mListInterfaceView.append(localCreateView); d->mStackedWidget->addWidget(localCreateView); } } void CustomToolsWidgetNg::slotToolsWasClosed() { for (PimCommon::CustomToolsViewInterface *interface : qAsConst(d->mListInterfaceView)) { interface->action()->setChecked(false); } hide(); } void CustomToolsWidgetNg::slotActivateView(QWidget *w) { if (w) { d->mStackedWidget->setCurrentWidget(w); setVisible(true); for (PimCommon::CustomToolsViewInterface *interface : qAsConst(d->mListInterfaceView)) { if (interface != w) { interface->action()->setChecked(false); } } Q_EMIT toolActivated(); } else { setVisible(false); slotToolsWasClosed(); } } QList CustomToolsWidgetNg::actionList() const { QList lstActions; lstActions.reserve(d->mListInterfaceView.count()); for (PimCommon::CustomToolsViewInterface *interface : qAsConst(d->mListInterfaceView)) { lstActions << interface->action(); } return lstActions; } void CustomToolsWidgetNg::setText(const QString &text) { if (isVisible()) { for (PimCommon::CustomToolsViewInterface *interface : qAsConst(d->mListInterfaceView)) { if (interface == d->mStackedWidget->currentWidget()) { interface->setText(text); break; } } } } diff --git a/src/pimcommon/customtools/customtoolswidgetng.h b/src/pimcommon/customtools/customtoolswidgetng.h index 9c6cb3d..2783c10 100644 --- a/src/pimcommon/customtools/customtoolswidgetng.h +++ b/src/pimcommon/customtools/customtoolswidgetng.h @@ -1,52 +1,53 @@ /* Copyright (c) 2015-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CUSTOMTOOLSWIDGETNG_H #define CUSTOMTOOLSWIDGETNG_H #include #include "pimcommon_export.h" class KToggleAction; class KActionCollection; namespace PimCommon { class CustomToolsWidgetNgPrivate; +class CustomToolsPlugin; class PIMCOMMON_EXPORT CustomToolsWidgetNg : public QWidget { Q_OBJECT public: - explicit CustomToolsWidgetNg(KActionCollection *ac, QWidget *parent = nullptr); + explicit CustomToolsWidgetNg(QWidget *parent = nullptr); ~CustomToolsWidgetNg(); Q_REQUIRED_RESULT QList actionList() const; + void initializeView(KActionCollection *ac, const QVector &localPluginsList); void setText(const QString &text); public Q_SLOTS: void slotToolsWasClosed(); void slotActivateView(QWidget *w); Q_SIGNALS: void insertText(const QString &url); void toolActivated(); private: - void initializeView(KActionCollection *ac); CustomToolsWidgetNgPrivate *const d; }; } #endif // CUSTOMTOOLSWIDGETNG_H diff --git a/src/pimcommon/widgets/tests/customtoolswidgetng_gui.cpp b/src/pimcommon/widgets/tests/customtoolswidgetng_gui.cpp index d1e24ef..13842ec 100644 --- a/src/pimcommon/widgets/tests/customtoolswidgetng_gui.cpp +++ b/src/pimcommon/widgets/tests/customtoolswidgetng_gui.cpp @@ -1,67 +1,68 @@ /* Copyright (c) 2015-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "customtoolswidgetng_gui.h" #include "customtools/customtoolswidgetng.h" #include "customtools/customtoolspluginmanager.h" #include #include #include #include #include #include #include CustomToolWidgetNgTest::CustomToolWidgetNgTest(QWidget *parent) : QWidget(parent) { QVBoxLayout *lay = new QVBoxLayout(this); QToolBar *menu = new QToolBar(this); lay->addWidget(menu); - mCustomTools = new PimCommon::CustomToolsWidgetNg(new KActionCollection(this), this); + mCustomTools = new PimCommon::CustomToolsWidgetNg(this); + mCustomTools->initializeView(new KActionCollection(this), PimCommon::CustomToolsPluginManager::self()->pluginsList()); const QList lst = mCustomTools->actionList(); for (KToggleAction *act : lst) { menu->addAction(act); } lay->addWidget(mCustomTools); } CustomToolWidgetNgTest::~CustomToolWidgetNgTest() { } int main(int argc, char **argv) { QApplication app(argc, argv); QStandardPaths::setTestModeEnabled(true); QCommandLineParser parser; parser.addVersionOption(); parser.addHelpOption(); parser.process(app); CustomToolWidgetNgTest *w = new CustomToolWidgetNgTest(); w->resize(800, 200); w->show(); const int ret = app.exec(); delete w; return ret; }