diff --git a/CMakeLists.txt b/CMakeLists.txt index 023e9049..70703a1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,191 +1,191 @@ cmake_minimum_required(VERSION 3.5) set(PIM_VERSION "5.12.40") project(kdepim-addons VERSION ${PIM_VERSION}) if(POLICY CMP0063) cmake_policy(SET CMP0063 NEW) endif() set(KF5_MIN_VERSION "5.60.0") find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/ ${ECM_MODULE_PATH}) set(CMAKE_AUTORCC TRUE) # Do NOT add quote set(KDEPIM_DEV_VERSION alpha) # add an extra space if(DEFINED KDEPIM_DEV_VERSION) set(KDEPIM_DEV_VERSION " ${KDEPIM_DEV_VERSION}") endif() set(KDEPIMADDONS_VERSION_NUMBER ${PIM_VERSION}) set(KDEPIMADDONS_VERSION "${KDEPIMADDONS_VERSION_NUMBER}${KDEPIM_DEV_VERSION}") set(KDEPIMADDONS_LIB_VERSION "${KDEPIMADDONS_VERSION_NUMBER}") set(KDEPIMADDONS_LIB_SOVERSION "5") set(AKONADINOTES_LIB_VERSION "5.12.40") set(QT_REQUIRED_VERSION "5.11.0") include(ECMInstallIcons) include(ECMSetupVersion) include(ECMAddTests) include(GenerateExportHeader) include(ECMGenerateHeaders) include(FeatureSummary) include(CheckFunctionExists) include(ECMGeneratePriFile) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(ECMAddAppIcon) include(ECMQtDeclareLoggingCategory) option(KDEPIMADDONS_BUILD_EXAMPLES "Build the kdepim-addons example applications." TRUE) option(KDEPIM_ENTERPRISE_BUILD "Enable features specific to the enterprise branch, which are normally disabled. Also, it disables many components not needed for Kontact such as the Kolab client." FALSE) option(KMAIL_EDITORCONVERTERPLUGIN_TEMPLATE_BUILD "Build the kmail editor converter plugin." FALSE) option(KMAIL_DKIM_CONFIGURE_DIALOG_BUILD "Build dkim-verify configure dialog (experimental)." FALSE) find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED WebEngine WebEngineWidgets Widgets Test) find_package(KF5I18n ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Config ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5DBusAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiNotes ${AKONADINOTES_LIB_VERSION} CONFIG REQUIRED) find_package(KF5XmlGui ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Declarative ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5SyntaxHighlighting ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5IconThemes ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Parts ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Prison ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Holidays ${KF5_MIN_VERSION} CONFIG REQUIRED) set(MAILCOMMON_LIB_VERSION "5.12.40") set(GRAVATAR_LIB_VERSION "5.12.40") set(PIMCOMMON_LIB_VERSION "5.12.40") set(GRANTLEETHEME_LIB_VERSION "5.12.40") set(CALENDARSUPPORT_LIB_VERSION "5.12.41") set(EVENTVIEW_LIB_VERSION "5.12.40") set(LIBKDEPIM_LIB_VERSION "5.12.40") set(KDEPIM_APPS_LIB_VERSION "5.12.40") set(LIBKLEO_LIB_VERSION "5.12.40") set(AKONADI_LIB_VERSION "5.12.40") set(INCIDENCEEDITOR_LIB_VERSION "5.12.40") set(KTNEF_LIB_VERSION "5.12.40") set(MESSAGELIB_LIB_VERSION "5.12.42") set(AKONADICALENDAR_LIB_VERSION "5.12.40") set(CALENDAR_UTILS_VERSION "5.12.40") set(KPIMTEXTEDIT_LIB_VERSION "5.12.41") set(KIMAP_LIB_VERSION "5.12.40") set(LIBKSIEVE_LIB_VERSION "5.12.40") set(KMAILTRANSPORT_LIB_VERSION "5.12.40") -set(AKONADICONTACT_LIB_VERSION "5.12.43") +set(AKONADICONTACT_LIB_VERSION "5.12.44") set(KCONTACTS_LIB_VERSION "5.12.40") set(IMPORTWIZARD_LIB_VERSION "5.12.40") set(MAILIMPORTER_LIB_VERSION "5.12.40") set(KPIMPKPASS_LIB_VERSION "5.12.40") set(KPIMITINERARY_LIB_VERSION "5.12.41") set(KCALENDARCORE_LIB_VERSION "5.12.40") set(KONTACTINTERFACE_LIB_VERSION "5.12.40") set(CALENDARSUPPORT_LIB_VERSION_LIB "5.12.40") find_package(KF5CalendarCore ${KCALENDARCORE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarUtils ${CALENDAR_UTILS_VERSION} CONFIG REQUIRED) find_package(KF5WebEngineViewer ${MESSAGELIB_LIB_VERSION} CONFIG REQUIRED) find_package(KF5TemplateParser ${MESSAGELIB_LIB_VERSION} CONFIG REQUIRED) find_package(KF5MailCommon ${MAILCOMMON_LIB_VERSION} CONFIG REQUIRED) find_package(KF5KaddressbookGrantlee ${KDEPIM_APPS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5MessageViewer ${MESSAGELIB_LIB_VERSION} CONFIG REQUIRED) find_package(KF5KaddressbookImportExport ${KDEPIM_APPS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Libkleo ${LIBKLEO_LIB_VERSION} CONFIG REQUIRED) find_package(KF5GrantleeTheme ${GRANTLEETHEME_LIB_VERSION} CONFIG REQUIRED) find_package(KF5PimCommonAkonadi ${PIMCOMMON_LIB_VERSION} CONFIG REQUIRED) find_package(KF5LibkdepimAkonadi ${LIBKDEPIM_LIB_VERSION} CONFIG REQUIRED) find_package(KF5IncidenceEditor ${INCIDENCEEDITOR_LIB_VERSION} CONFIG REQUIRED) find_package(KF5MessageCore ${MESSAGELIB_LIB_VERSION} CONFIG REQUIRED) find_package(KF5MessageComposer ${MESSAGELIB_LIB_VERSION} CONFIG REQUIRED) find_package(KF5MessageList ${MESSAGELIB_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarSupport ${CALENDARSUPPORT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5EventViews ${EVENTVIEW_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Akonadi ${AKONADI_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiCalendar ${AKONADICALENDAR_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Gravatar ${GRAVATAR_LIB_VERSION} CONFIG REQUIRED) find_package(KF5PimTextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5IdentityManagement ${KIDENTITYMANAGEMENT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5IMAP ${KIMAP_LIB_VERSION} CONFIG REQUIRED) find_package(KF5LibKSieve ${LIBKSIEVE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Tnef ${KTNEF_LIB_VERSION} CONFIG REQUIRED) find_package(KF5MailTransportAkonadi ${KMAILTRANSPORT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Contacts ${KCONTACTS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiContact ${AKONADICONTACT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5ContactEditor ${AKONADICONTACT_LIB_VERSION} CONFIG REQUIRED) find_package(KPimImportWizard ${IMPORTWIZARD_LIB_VERSION} CONFIG) find_package(KF5MailImporterAkonadi ${MAILIMPORTER_LIB_VERSION} CONFIG REQUIRED) find_package(KPimPkPass ${KPIMPKPASS_LIB_VERSION} CONFIG REQUIRED) find_package(KPimItinerary ${KPIMITINERARY_LIB_VERSION} CONFIG REQUIRED) find_package(KF5KontactInterface ${KONTACTINTERFACE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarSupport ${CALENDARSUPPORT_LIB_VERSION_LIB} CONFIG REQUIRED) set(CMAKE_CXX_STANDARD 14) if(BUILD_TESTING) add_definitions(-DBUILD_TESTING) endif(BUILD_TESTING) if(KDEPIM_ENTERPRISE_BUILD) set(KDEPIM_ENTERPRISE_BUILD true) else() set(KDEPIM_ENTERPRISE_BUILD false) endif() # Extra package find_package(Gpgmepp 1.11.1 CONFIG) set_package_properties(Gpgmepp PROPERTIES DESCRIPTION "GpgME library" URL "https://www.gnupg.org" TYPE REQUIRED) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000) add_definitions(-DQT_NO_FOREACH) option(KDEPIM_RUN_AKONADI_TEST "Enable autotest based on Akonadi." TRUE) if(KDEPIMADDONS_BUILD_EXAMPLES) add_subdirectory(examples) endif() include_directories(${CMAKE_CURRENT_SOURCE_DIR}) set(QTCREATOR_TEMPLATE_INSTALL_DIR ${KDE_INSTALL_DATADIR}/qtcreator/templates CACHE PATH "Define qtcreator template install path (default is /usr/share/qtcreator/templates)") find_package(Discount "2") set_package_properties("discount" PROPERTIES DESCRIPTION "A library that gives you formatting functions suitable for marking down entire documents or lines of text" URL "https://www.pell.portland.or.us/~orc/Code/discount/" TYPE RECOMMENDED PURPOSE "Generate Markdown file.") if(discount_FOUND) if (${PC_LIBMARKDOWN_VERSION_STRING}) if (${PC_LIBMARKDOWN_VERSION_STRING} VERSION_GREATER "2.2.5") set(DISCOUNT_HAS_HIGHLIGHTING_SUPPORT TRUE) MESSAGE(STATUS "Discount ${PC_LIBMARKDOWN_VERSION_STRING}: has hightlighting support") endif() endif() endif() add_subdirectory(plugins) add_subdirectory(korganizer) add_subdirectory(kmail) add_subdirectory(kaddressbook) add_subdirectory(sieveeditor) add_subdirectory(kmailtransport) if(KPimImportWizard_FOUND) add_subdirectory(akonadi-import-wizard) endif() install(FILES kdepim-addons.categories kdepim-addons.renamecategories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/korganizer/emailaddressselectionldapdialog/emailaddressselectionldapdialog.cpp b/korganizer/emailaddressselectionldapdialog/emailaddressselectionldapdialog.cpp index 32f4bf2c..4978abb2 100644 --- a/korganizer/emailaddressselectionldapdialog/emailaddressselectionldapdialog.cpp +++ b/korganizer/emailaddressselectionldapdialog/emailaddressselectionldapdialog.cpp @@ -1,116 +1,114 @@ /* Copyright (C) 2019 Laurent Montel 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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "emailaddressselectionldapdialog.h" #include #include #include #include #include #include #include #include #include #include #include K_PLUGIN_CLASS_WITH_JSON(EmailAddressSelectionLdapDialog, "emailaddressselectionldapdialog.json") EmailAddressSelectionLdapDialog::EmailAddressSelectionLdapDialog(QWidget *parent, const QList &) : Akonadi::AbstractEmailAddressSelectionDialog(parent) { QVBoxLayout *mainLayout = new QVBoxLayout(this); mView = new Akonadi::RecipientsPickerWidget(true, nullptr, this); mainLayout->addWidget(mView); connect(mView->emailAddressSelectionWidget()->view(), &QTreeView::doubleClicked, this, &QDialog::accept); QPushButton *searchLDAPButton = new QPushButton(i18n("Search &Directory Service"), this); connect(searchLDAPButton, &QPushButton::clicked, this, &EmailAddressSelectionLdapDialog::slotSearchLDAP); mainLayout->addWidget(searchLDAPButton); KConfig config(QStringLiteral("kabldaprc")); KConfigGroup group = config.group("LDAP"); int numHosts = group.readEntry("NumSelectedHosts", 0); if (!numHosts) { searchLDAPButton->setVisible(false); } QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); mainLayout->addWidget(buttonBox); readConfig(); } void EmailAddressSelectionLdapDialog::readConfig() { KConfigGroup group(KSharedConfig::openConfig(), QStringLiteral("EmailAddressSelectionLdapDialog")); const QSize size = group.readEntry("Size", QSize()); if (size.isValid()) { resize(size); } else { resize(sizeHint().width(), sizeHint().height()); } } void EmailAddressSelectionLdapDialog::writeConfig() { KConfigGroup group(KSharedConfig::openConfig(), QStringLiteral("EmailAddressSelectionLdapDialog")); group.writeEntry("Size", size()); } EmailAddressSelectionLdapDialog::~EmailAddressSelectionLdapDialog() { writeConfig(); } Akonadi::EmailAddressSelection::List EmailAddressSelectionLdapDialog::selectedAddresses() const { return mView->emailAddressSelectionWidget()->selectedAddresses(); } Akonadi::EmailAddressSelectionWidget *EmailAddressSelectionLdapDialog::view() const { return mView->emailAddressSelectionWidget(); } void EmailAddressSelectionLdapDialog::slotSearchLDAP() { if (!mLdapSearchDialog) { mLdapSearchDialog = new KLDAP::LdapSearchDialog(this); connect(mLdapSearchDialog, &KLDAP::LdapSearchDialog::contactsAdded, this, &EmailAddressSelectionLdapDialog::ldapSearchResult); } mLdapSearchDialog->setSearchText(mView->emailAddressSelectionWidget()->searchLineEdit()->text()); mLdapSearchDialog->show(); } void EmailAddressSelectionLdapDialog::ldapSearchResult() { const KContacts::Addressee::List contacts = mLdapSearchDialog->selectedContacts(); - for (const KContacts::Addressee &contact : contacts) { - //TODO - } + Q_EMIT insertAddresses(contacts); } #include "emailaddressselectionldapdialog.moc" diff --git a/sieveeditor/emaillineedit/emaillineedit.cpp b/sieveeditor/emaillineedit/emaillineedit.cpp index 9cb0b5d8..fe951d0a 100644 --- a/sieveeditor/emaillineedit/emaillineedit.cpp +++ b/sieveeditor/emaillineedit/emaillineedit.cpp @@ -1,146 +1,161 @@ /* Copyright (C) 2018-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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "emaillineedit.h" #include "sieveeditoremaillineditplugin_debug.h" #include #include #include #include #include #include #include #include #include #include K_PLUGIN_CLASS_WITH_JSON(EmailLineEdit, "emaillineedit.json") EmailLineEdit::EmailLineEdit(QWidget *parent, const QList &) : KSieveUi::AbstractSelectEmailLineEdit(parent) { QHBoxLayout *mainLayout = new QHBoxLayout(this); mainLayout->setObjectName(QStringLiteral("mainlayout")); mainLayout->setContentsMargins(0, 0, 0, 0); mLineEdit = new QLineEdit(this); mLineEdit->setObjectName(QStringLiteral("lineedit")); mLineEdit->setClearButtonEnabled(true); mLineEdit->setPlaceholderText(i18n("Click on button for selecting contacts...")); connect(mLineEdit, &QLineEdit::textChanged, this, &EmailLineEdit::slotTextChanged); mainLayout->addWidget(mLineEdit); mEmailButton = new QToolButton(this); mEmailButton->setText(i18n("...")); mEmailButton->setObjectName(QStringLiteral("emailbutton")); mEmailButton->setToolTip(i18n("Select Emails")); mainLayout->addWidget(mEmailButton); connect(mEmailButton, &QToolButton::clicked, this, &EmailLineEdit::slotSelectEmail); verifyAkonadiStatus(); connect(Akonadi::ServerManager::self(), &Akonadi::ServerManager::stateChanged, this, &EmailLineEdit::akonadiStateChanged); verifyAddress(); } EmailLineEdit::~EmailLineEdit() { } void EmailLineEdit::akonadiStateChanged(Akonadi::ServerManager::State state) { mEmailButton->setVisible(state == Akonadi::ServerManager::Running); } void EmailLineEdit::verifyAkonadiStatus() { Akonadi::ServerManager::State state = Akonadi::ServerManager::self()->state(); mEmailButton->setVisible(state == Akonadi::ServerManager::Running); } +void EmailLineEdit::insertAddresses(const KContacts::Addressee::List &list) +{ + QString currentText = mLineEdit->text(); + bool firstElement = currentText.isEmpty(); + for (const KContacts::Addressee &contact : list) { + if (!firstElement) { + currentText.append(QLatin1Char(';')); + } else { + firstElement = false; + } + currentText.append(contact.preferredEmail()); + } + mLineEdit->setText(currentText); +} + void EmailLineEdit::slotSelectEmail() { std::unique_ptr dlg; KPluginLoader loader(QStringLiteral("akonadi/emailaddressselectionldapdialogplugin")); KPluginFactory *factory = loader.factory(); if (factory) { dlg.reset(factory->create(this)); } else { dlg.reset(new Akonadi::EmailAddressSelectionDialog(this)); } dlg->setWindowTitle(i18n("Select Emails")); dlg->view()->view()->setSelectionMode(multiSelection() ? QAbstractItemView::MultiSelection : QAbstractItemView::SingleSelection); - + connect(dlg.get(), &Akonadi::AbstractEmailAddressSelectionDialog::insertAddresses, this, &EmailLineEdit::insertAddresses); if (dlg->exec()) { QStringList addresses; const Akonadi::EmailAddressSelection::List lstAddress = dlg->selectedAddresses(); if (!lstAddress.isEmpty()) { bool firstElement = true; QString result; for (const Akonadi::EmailAddressSelection &value : lstAddress) { if (!firstElement) { result.append(QLatin1Char(';')); } else { firstElement = false; } result.append(value.email()); } mLineEdit->setText(result); } } } void EmailLineEdit::setText(const QString &str) { mLineEdit->setText(str); } QString EmailLineEdit::text() const { return mLineEdit->text(); } bool EmailLineEdit::isValid() const { return mEmailIsValid; } void EmailLineEdit::slotTextChanged() { verifyAddress(); Q_EMIT valueChanged(); } void EmailLineEdit::verifyAddress() { #ifndef QT_NO_STYLE_STYLESHEET QString styleSheet; const QString lineEditText = text(); mEmailIsValid = lineEditText.contains(QLatin1Char('@')); if (mNegativeBackground.isEmpty()) { KStatefulBrush bgBrush = KStatefulBrush(KColorScheme::View, KColorScheme::NegativeText); mNegativeBackground = QStringLiteral("QLineEdit{ background-color:%1 }").arg(bgBrush.brush(this).color().name()); } if (!mEmailIsValid) { styleSheet = mNegativeBackground; } mLineEdit->setStyleSheet(styleSheet); #endif } #include "emaillineedit.moc" diff --git a/sieveeditor/emaillineedit/emaillineedit.h b/sieveeditor/emaillineedit/emaillineedit.h index 226f9880..fc50ffed 100644 --- a/sieveeditor/emaillineedit/emaillineedit.h +++ b/sieveeditor/emaillineedit/emaillineedit.h @@ -1,51 +1,53 @@ /* Copyright (C) 2018-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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef EMAILLINEEDIT_H #define EMAILLINEEDIT_H #include #include +#include class QLineEdit; class QToolButton; class EmailLineEdit : public KSieveUi::AbstractSelectEmailLineEdit { Q_OBJECT public: explicit EmailLineEdit(QWidget *parent = nullptr, const QList & = { }); ~EmailLineEdit() override; void setText(const QString &str) override; QString text() const override; bool isValid() const override; private: + void insertAddresses(const KContacts::Addressee::List &list); void slotTextChanged(); void verifyAddress(); void slotSelectEmail(); void verifyAkonadiStatus(); void akonadiStateChanged(Akonadi::ServerManager::State state); QString mNegativeBackground; QLineEdit *mLineEdit = nullptr; QToolButton *mEmailButton = nullptr; bool mEmailIsValid = false; }; #endif // EMAILLINEEDIT_H