Ask whether to enable Unified Mailboxes when more than 1 account is detected

We ask on start and when a new account is added. We only ever ask once as
not to bother users too much.
wilder
Daniel Vrátil 8 years ago
parent 9c32898d19
commit 116aad1602
  1. 13
      src/kmkernel.cpp
  2. 3
      src/kmkernel.h
  3. 53
      src/kmmainwidget.cpp
  4. 1
      src/kmmainwidget.h
  5. 5
      src/settings/kmail.kcfg.cmake

@ -208,6 +208,8 @@ KMKernel::KMKernel(QObject *parent)
connect(Akonadi::AgentManager::self(), &Akonadi::AgentManager::instanceRemoved, this, &KMKernel::slotInstanceRemoved);
connect(Akonadi::AgentManager::self(), &Akonadi::AgentManager::instanceAdded, this, &KMKernel::slotInstanceAdded);
connect(PimCommon::NetworkManager::self()->networkConfigureManager(), &QNetworkConfigurationManager::onlineStateChanged,
this, &KMKernel::slotSystemNetworkStatusChanged);
@ -1809,6 +1811,17 @@ void KMKernel::slotInstanceRemoved(const Akonadi::AgentInstance &instance)
mResourceCryptoSettingCache.remove(identifier);
}
mFolderArchiveManager->slotInstanceRemoved(instance);
if (MailCommon::Util::isMailAgent(instance)) {
Q_EMIT incomingAccountsChanged();
}
}
void KMKernel::slotInstanceAdded(const Akonadi::AgentInstance &instance)
{
if (MailCommon::Util::isMailAgent(instance)) {
Q_EMIT incomingAccountsChanged();
}
}
void KMKernel::savePaneSelection()

@ -443,7 +443,6 @@ public Q_SLOTS:
void slotRunBackgroundTasks();
void slotConfigChanged();
Q_SIGNALS:
void configChanged();
void onlineStatusChanged(KMailSettings::EnumNetworkState::type);
@ -452,6 +451,7 @@ Q_SIGNALS:
void startCheckMail();
void endCheckMail();
void incomingAccountsChanged();
private Q_SLOTS:
/** Updates identities when a transport has been deleted. */
void transportRemoved(int id, const QString &name);
@ -467,6 +467,7 @@ private Q_SLOTS:
void slotCollectionRemoved(const Akonadi::Collection &col);
void slotDeleteIdentity(uint identity);
void slotInstanceRemoved(const Akonadi::AgentInstance &);
void slotInstanceAdded(const Akonadi::AgentInstance &);
void slotSystemNetworkStatusChanged(bool isOnline);
void slotCollectionChanged(const Akonadi::Collection &, const QSet<QByteArray> &set);

@ -185,6 +185,9 @@
// System includes
#include <AkonadiWidgets/standardactionmanager.h>
#include <QStandardPaths>
#include <QDBusInterface>
#include <QDBusConnection>
#include <QDBusReply>
#include "PimCommonAkonadi/ManageServerSideSubscriptionJob"
#include <job/removeduplicatemailjob.h>
@ -323,6 +326,8 @@ KMMainWidget::KMMainWidget(QWidget *parent, KXMLGUIClient *aGUIClient, KActionCo
mCheckMailTimer.setInterval(3 * 1000);
mCheckMailTimer.setSingleShot(true);
connect(&mCheckMailTimer, &QTimer::timeout, this, &KMMainWidget::slotUpdateActionsAfterMailChecking);
setupUnifiedMailboxChecker();
}
void KMMainWidget::restoreCollectionFolderViewConfig()
@ -4700,3 +4705,51 @@ void KMMainWidget::slotSetFocusToViewer()
messageView()->viewer()->setFocus();
}
}
void KMMainWidget::setupUnifiedMailboxChecker()
{
if (!KMailSettings::self()->askEnableUnifiedMailboxes()) {
return;
}
const auto ask = [this]() {
if (!KMailSettings::self()->askEnableUnifiedMailboxes()) {
return;
}
if (kmkernel->accounts().count() <= 1) {
return;
}
const auto service = Akonadi::ServerManager::self()->agentServiceName(Akonadi::ServerManager::Agent, QStringLiteral("akonadi_unifiedmailbox_agent"));
QDBusInterface iface(service, QStringLiteral("/"), QStringLiteral("org.freedesktop.Akonadi.UnifiedMailboxAgent"),
QDBusConnection::sessionBus(), this);
if (!iface.isValid()) {
return;
}
QDBusReply<bool> reply = iface.call(QStringLiteral("enabledAgent"));
if (!reply.isValid() || bool(reply)) {
return;
}
const auto answer = KMessageBox::questionYesNo(
this, i18n("You have more than one email account set up. Do you want to enable the Unified Mailbox feature to "
"show unified content of your inbox, sent and drafts folders?\n"
"You can configure unified mailboxes, create custom ones or disable the feature completely in KMail's Plugin settings."),
i18n("Enable Unified Mailboxes?"),
KGuiItem(i18n("Enable Unified Mailboxes"), QStringLiteral("dialog-ok")),
KGuiItem(i18n("Cancel"), QStringLiteral("dialog-cancel")));
if (answer == KMessageBox::Yes) {
iface.call(QStringLiteral("setEnableAgent"), true);
}
KMailSettings::self()->setAskEnableUnifiedMailboxes(false);
};
connect(kmkernel, &KMKernel::incomingAccountsChanged, this, ask);
// Wait for a bit before asking so we at least have the window on screen
QTimer::singleShot(500, this, ask);
}

@ -513,6 +513,7 @@ private:
void slotPageIsScrolledToBottom(bool isAtBottom);
void printCurrentMessage(bool preview);
void replyCurrentMessageCommand(MessageComposer::ReplyStrategy strategy);
void setupUnifiedMailboxChecker();
QAction *filterToAction(MailCommon::MailFilter *filter);
Akonadi::Collection::List applyFilterOnCollection(bool recursive);

@ -134,7 +134,10 @@
<label></label>
<whatsthis></whatsthis>
</entry>
<entry key="AskEnableUnifiedMailboxes" type="Bool">
<default>true</default>
<label>Whether to ask if users wants to enable Unified Mailboxes if more than one email accounts are detected. We only ever ask once.</label>
</entry>
</group>
<!-- General -->

Loading…
Cancel
Save