diff --git a/CMakeLists.txt b/CMakeLists.txt index 77165db65..d1f2c9fce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,163 +1,163 @@ cmake_minimum_required(VERSION 3.5) set(KDEPIM_VERSION_NUMBER "5.11.1") project(kmail VERSION ${KDEPIM_VERSION_NUMBER}) include(CheckIncludeFiles) if (POLICY CMP0063) cmake_policy(SET CMP0063 NEW) endif() set(KF5_MIN_VERSION "5.56.0") find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) 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) # Do NOT add quote set(KDEPIM_DEV_VERSION ) # add an extra space if(DEFINED KDEPIM_DEV_VERSION) set(KDEPIM_DEV_VERSION " ${KDEPIM_DEV_VERSION}") endif() set(KDEPIM_VERSION "${KDEPIM_VERSION_NUMBER}${KDEPIM_DEV_VERSION}") set(AKONADI_MIMELIB_VERSION "5.11.0") set(AKONADI_CONTACT_VERSION "5.11.0") set(KCONTACTS_LIB_VERSION "5.11.0") set(KCALENDARCORE_LIB_VERSION "5.11.0") set(CALENDARUTILS_LIB_VERSION "5.11.0") -set(IDENTITYMANAGEMENT_LIB_VERSION "5.11.0") +set(IDENTITYMANAGEMENT_LIB_VERSION "5.11.1") set(KLDAP_LIB_VERSION "5.11.0") set(KMAILTRANSPORT_LIB_VERSION "5.11.0") set(KONTACTINTERFACE_LIB_VERSION "5.11.0") set(KMIME_LIB_VERSION "5.11.0") set(KPIMTEXTEDIT_LIB_VERSION "5.11.0") set(AKONADI_VERSION "5.11.0") set(KTNEF_LIB_VERSION "5.11.0") set(KDEPIM_LIB_VERSION "${KDEPIM_VERSION_NUMBER}") set(KDEPIM_LIB_SOVERSION "5") set(QT_REQUIRED_VERSION "5.10.0") 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) find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED DBus Network Test Widgets WebEngine WebEngineWidgets) set(LIBGRAVATAR_VERSION_LIB "5.11.0") set(MAILCOMMON_LIB_VERSION_LIB "5.11.0") set(KDEPIM_APPS_LIB_VERSION_LIB "5.11.0") set(MESSAGELIB_LIB_VERSION_LIB "5.11.0") set(LIBKLEO_LIB_VERSION_LIB "5.11.0") set(PIMCOMMON_LIB_VERSION_LIB "5.11.0") set(LIBKDEPIM_LIB_VERSION_LIB "5.11.0") set(LIBKSIEVE_LIB_VERSION_LIB "5.11.0") find_package(KF5WebEngineViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5AkonadiSearch "5.11.0" CONFIG REQUIRED) set_package_properties(KF5AkonadiSearch PROPERTIES DESCRIPTION "The Akonadi Search libraries" URL "https://www.kde.org" TYPE REQUIRED PURPOSE "Provides search capabilities in KMail and Akonadi") set(GPGMEPP_LIB_VERSION "1.8.0") find_package(Gpgmepp ${GPGMEPP_LIB_VERSION} CONFIG REQUIRED) # Find KF5 package find_package(KF5Bookmarks ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Codecs ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Config ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5ConfigWidgets ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Crash ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5DBusAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5DocTools ${KF5_MIN_VERSION} REQUIRED) find_package(KF5GuiAddons ${KF5_MIN_VERSION} REQUIRED) find_package(KF5I18n ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5ItemViews ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5JobWidgets ${KF5_MIN_VERSION} REQUIRED) find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5KCMUtils ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Notifications ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5NotifyConfig ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Parts ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Service ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Sonnet ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5TextWidgets ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5WidgetsAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5WindowSystem ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5XmlGui ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5IconThemes ${KF5_MIN_VERSION} CONFIG REQUIRED) # Find KdepimLibs Package find_package(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiContact ${AKONADI_CONTACT_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiMime ${AKONADI_MIMELIB_VERSION} CONFIG REQUIRED) find_package(KF5Contacts ${KCONTACTS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarCore ${KCALENDARCORE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarUtils ${CALENDARUTILS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5IdentityManagement ${IDENTITYMANAGEMENT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Ldap ${KLDAP_LIB_VERSION} CONFIG REQUIRED) find_package(KF5MailTransportAkonadi ${KMAILTRANSPORT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5PimTextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5KontactInterface ${KONTACTINTERFACE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Mime ${KMIME_LIB_VERSION} CONFIG REQUIRED) find_package(KF5FollowupReminder ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5Gravatar ${LIBGRAVATAR_VERSION_LIB} CONFIG REQUIRED) find_package(KF5KdepimDBusInterfaces ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5LibkdepimAkonadi ${LIBKDEPIM_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5Libkleo ${LIBKLEO_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5LibKSieve ${LIBKSIEVE_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MailCommon ${MAILCOMMON_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageCore ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageComposer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageList ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5PimCommonAkonadi ${PIMCOMMON_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5SendLater ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5TemplateParser ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5Tnef ${KTNEF_LIB_VERSION} CONFIG REQUIRED) find_package(MailTransportDBusService CONFIG REQUIRED) configure_file(config-enterprise.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-enterprise.h ) include_directories(${kmail_SOURCE_DIR} ${kmail_BINARY_DIR}) configure_file(kmail-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kmail-version.h @ONLY) # workaround for https://bugreports.qt.io/browse/QTBUG-74665 (bug in qt5.13 reevaluate it) if (${Qt5Widgets_VERSION} STRGREATER "5.13") MESSAGE(STATUS "Qt version: ${Qt5Widgets_VERSION} DISABLE compile without deprecated methods. bug QTBUG-74665") else() add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000) endif() if (${KF5Config_VERSION} STRGREATER "5.56.0") add_definitions(-DQT_NO_FOREACH) MESSAGE(STATUS "compile without foreach") endif() add_subdirectory(src) add_subdirectory(agents) add_subdirectory(ktnef) install( FILES kmail.renamecategories kmail.categories DESTINATION ${KDE_INSTALL_CONFDIR} ) add_subdirectory(doc) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/identity/identitypage.cpp b/src/identity/identitypage.cpp index a99997ff7..d61feeddf 100644 --- a/src/identity/identitypage.cpp +++ b/src/identity/identitypage.cpp @@ -1,337 +1,338 @@ /* * kmail: KDE mail client * Copyright (C) 2000 Espen Sand, espen@kde.org * Copyright (C) 2001-2003 Marc Mutz, mutz@kde.org * Contains code segments and ideas from earlier kmail dialog code. * Copyright (C) 2010 Volker Krause * * 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 "identitypage.h" #include "identitydialog.h" #include "newidentitydialog.h" #ifndef KCM_KPIMIDENTITIES_STANDALONE #include "kmkernel.h" #include "settings/kmailsettings.h" #endif #include #include #include #include #include #include #include "kmail_debug.h" using namespace KMail; QString IdentityPage::helpAnchor() const { return QStringLiteral("configure-identity"); } IdentityPage::IdentityPage(QWidget *parent) : ConfigModuleTab(parent) { if (!MailCommon::Kernel::self()->kernelIsRegistered()) { return; } mIdentityManager = KernelIf->identityManager(); + connect(mIdentityManager, &KIdentityManagement::IdentityManager::needToReloadIdentitySettings, this, &IdentityPage::load); mIPage.setupUi(this); mIPage.mIdentityList->setIdentityManager(mIdentityManager); connect(mIPage.mIdentityList, &QTreeWidget::itemSelectionChanged, this, &IdentityPage::slotIdentitySelectionChanged); connect(this, QOverload::of(&IdentityPage::changed), this, &IdentityPage::slotIdentitySelectionChanged); connect(mIPage.mIdentityList, QOverload::of(&IdentityListView::rename), this, &IdentityPage::slotRenameIdentityFromItem); connect(mIPage.mIdentityList, &QTreeWidget::itemDoubleClicked, this, &IdentityPage::slotModifyIdentity); connect(mIPage.mIdentityList, &IdentityListView::contextMenu, this, &IdentityPage::slotContextMenu); // ### connect dragged(...), ... connect(mIPage.mButtonAdd, &QPushButton::clicked, this, &IdentityPage::slotNewIdentity); connect(mIPage.mModifyButton, &QPushButton::clicked, this, &IdentityPage::slotModifyIdentity); connect(mIPage.mRenameButton, &QPushButton::clicked, this, &IdentityPage::slotRenameIdentity); connect(mIPage.mRemoveButton, &QPushButton::clicked, this, &IdentityPage::slotRemoveIdentity); connect(mIPage.mSetAsDefaultButton, &QPushButton::clicked, this, &IdentityPage::slotSetAsDefault); load(); } IdentityPage::~IdentityPage() { } void IdentityPage::load() { if (!MailCommon::Kernel::self()->kernelIsRegistered()) { return; } mOldNumberOfIdentities = mIdentityManager->shadowIdentities().count(); // Fill the list: mIPage.mIdentityList->clear(); QTreeWidgetItem *item = nullptr; KIdentityManagement::IdentityManager::Iterator end(mIdentityManager->modifyEnd()); for (KIdentityManagement::IdentityManager::Iterator it = mIdentityManager->modifyBegin(); it != end; ++it) { item = new IdentityListViewItem(mIPage.mIdentityList, item, *it); } if (mIPage.mIdentityList->currentItem()) { mIPage.mIdentityList->currentItem()->setSelected(true); } } void IdentityPage::save() { if (!MailCommon::Kernel::self()->kernelIsRegistered()) { return; } mIdentityManager->sort(); mIdentityManager->commit(); #ifndef KCM_KPIMIDENTITIES_STANDALONE if (mOldNumberOfIdentities < 2 && mIPage.mIdentityList->topLevelItemCount() > 1) { // have more than one identity, so better show the combo in the // composer now: int showHeaders = KMailSettings::self()->headers(); showHeaders |= KMail::Composer::HDR_IDENTITY; KMailSettings::self()->setHeaders(showHeaders); } // and now the reverse if (mOldNumberOfIdentities > 1 && mIPage.mIdentityList->topLevelItemCount() < 2) { // have only one identity, so remove the combo in the composer: int showHeaders = KMailSettings::self()->headers(); showHeaders &= ~KMail::Composer::HDR_IDENTITY; KMailSettings::self()->setHeaders(showHeaders); } #endif } void IdentityPage::slotNewIdentity() { Q_ASSERT(!mIdentityDialog); QScopedPointer dialog(new NewIdentityDialog( mIdentityManager, this)); dialog->setObjectName(QStringLiteral("new")); if (dialog->exec() == QDialog::Accepted && dialog) { QString identityName = dialog->identityName().trimmed(); Q_ASSERT(!identityName.isEmpty()); // // Construct a new Identity: // switch (dialog->duplicateMode()) { case NewIdentityDialog::ExistingEntry: { KIdentityManagement::Identity &dupThis = mIdentityManager->modifyIdentityForName(dialog->duplicateIdentity()); mIdentityManager->newFromExisting(dupThis, identityName); break; } case NewIdentityDialog::ControlCenter: mIdentityManager->newFromControlCenter(identityName); break; case NewIdentityDialog::Empty: mIdentityManager->newFromScratch(identityName); default: ; } // // Insert into listview: // KIdentityManagement::Identity &newIdent = mIdentityManager->modifyIdentityForName(identityName); QTreeWidgetItem *item = nullptr; if (!mIPage.mIdentityList->selectedItems().isEmpty()) { item = mIPage.mIdentityList->selectedItems().at(0); } QTreeWidgetItem *newItem = nullptr; if (item) { newItem = new IdentityListViewItem(mIPage.mIdentityList, mIPage.mIdentityList->itemAbove(item), newIdent); } else { newItem = new IdentityListViewItem(mIPage.mIdentityList, newIdent); } mIPage.mIdentityList->selectionModel()->clearSelection(); if (newItem) { newItem->setSelected(true); } slotModifyIdentity(); updateButtons(); } } void IdentityPage::slotModifyIdentity() { Q_ASSERT(!mIdentityDialog); IdentityListViewItem *item = nullptr; if (!mIPage.mIdentityList->selectedItems().isEmpty()) { item = dynamic_cast(mIPage.mIdentityList->selectedItems().first()); } if (!item) { return; } mIdentityDialog = new IdentityDialog(this); mIdentityDialog->setIdentity(item->identity()); // Hmm, an unmodal dialog would be nicer, but a modal one is easier ;-) if (mIdentityDialog->exec() == QDialog::Accepted) { mIdentityDialog->updateIdentity(item->identity()); item->redisplay(); save(); } delete mIdentityDialog; mIdentityDialog = nullptr; } void IdentityPage::slotRemoveIdentity() { Q_ASSERT(!mIdentityDialog); if (mIdentityManager->shadowIdentities().count() < 2) { qCritical() << "Attempted to remove the last identity!"; } IdentityListViewItem *item = nullptr; if (!mIPage.mIdentityList->selectedItems().isEmpty()) { item = dynamic_cast(mIPage.mIdentityList->selectedItems().at(0)); } if (!item) { return; } const QString msg = i18n("Do you really want to remove the identity named " "%1?", item->identity().identityName()); if (KMessageBox::warningContinueCancel(this, msg, i18n("Remove Identity"), KGuiItem(i18n("&Remove"), QStringLiteral("edit-delete"))) == KMessageBox::Continue) { if (mIdentityManager->removeIdentity(item->identity().identityName())) { delete item; if (mIPage.mIdentityList->currentItem()) { mIPage.mIdentityList->currentItem()->setSelected(true); } refreshList(); updateButtons(); } } } void IdentityPage::slotRenameIdentity() { Q_ASSERT(!mIdentityDialog); QTreeWidgetItem *item = nullptr; if (!mIPage.mIdentityList->selectedItems().isEmpty()) { item = mIPage.mIdentityList->selectedItems().first(); } if (!item) { return; } mIPage.mIdentityList->editItem(item); } void IdentityPage::slotRenameIdentityFromItem(KMail::IdentityListViewItem *item, const QString &text) { if (!item) { return; } const QString newName = text.trimmed(); if (!newName.isEmpty() && !mIdentityManager->shadowIdentities().contains(newName)) { KIdentityManagement::Identity &ident = item->identity(); ident.setIdentityName(newName); save(); } item->redisplay(); } void IdentityPage::slotContextMenu(IdentityListViewItem *item, const QPoint &pos) { QMenu menu(this); menu.addAction(QIcon::fromTheme(QStringLiteral("list-add")), i18n("Add..."), this, &IdentityPage::slotNewIdentity); if (item) { menu.addAction(QIcon::fromTheme(QStringLiteral("document-edit")), i18n("Modify..."), this, &IdentityPage::slotModifyIdentity); menu.addAction(QIcon::fromTheme(QStringLiteral("edit-rename")), i18n("Rename"), this, &IdentityPage::slotRenameIdentity); if (mIPage.mIdentityList->topLevelItemCount() > 1) { menu.addAction(QIcon::fromTheme(QStringLiteral("list-remove")), i18n("Remove"), this, &IdentityPage::slotRemoveIdentity); } if (!item->identity().isDefault()) { menu.addSeparator(); menu.addAction(i18n("Set as Default"), this, &IdentityPage::slotSetAsDefault); } } menu.exec(pos); } void IdentityPage::slotSetAsDefault() { Q_ASSERT(!mIdentityDialog); IdentityListViewItem *item = nullptr; if (!mIPage.mIdentityList->selectedItems().isEmpty()) { item = dynamic_cast(mIPage.mIdentityList->selectedItems().first()); } if (!item) { return; } mIdentityManager->setAsDefault(item->identity().uoid()); refreshList(); mIPage.mSetAsDefaultButton->setEnabled(false); } void IdentityPage::refreshList() { const int numberOfTopLevel(mIPage.mIdentityList->topLevelItemCount()); for (int i = 0; i < numberOfTopLevel; ++i) { IdentityListViewItem *item = dynamic_cast(mIPage.mIdentityList->topLevelItem(i)); if (item) { item->redisplay(); } } save(); } void IdentityPage::slotIdentitySelectionChanged() { updateButtons(); } void IdentityPage::updateButtons() { IdentityListViewItem *item = nullptr; if (!mIPage.mIdentityList->selectedItems().isEmpty()) { item = dynamic_cast(mIPage.mIdentityList->selectedItems().first()); } mIPage.mRemoveButton->setEnabled(item && mIPage.mIdentityList->topLevelItemCount() > 1); mIPage.mModifyButton->setEnabled(item); mIPage.mRenameButton->setEnabled(item); mIPage.mSetAsDefaultButton->setEnabled(item && !item->identity().isDefault()); }