7#include "collectiongeneralwidget.h"
8#include "folder/foldersettings.h"
9#include "kernel/mailkernel.h"
10#include "util/mailutil_p.h"
11#include <Akonadi/NewMailNotifierAttribute>
12#include <KIdentityManagementWidgets/IdentityCombo>
13#include <KLocalizedString>
18CollectionGeneralWidget::CollectionGeneralWidget(
QWidget *parent)
23 topLayout->setContentsMargins({});
25 mNotifyOnNewMailCheckBox =
new QCheckBox(
i18nc(
"@option:check",
"Act on new/unread mail in this folder"),
this);
26 mNotifyOnNewMailCheckBox->setWhatsThis(
27 i18n(
"<qt><p>If this option is enabled then you will be notified about "
28 "new/unread mail in this folder. Moreover, going to the "
29 "next/previous folder with unread messages will stop at this "
31 "<p>Uncheck this option if you do not want to be notified about "
32 "new/unread mail in this folder and if you want this folder to "
33 "be skipped when going to the next/previous folder with unread "
34 "messages. This is useful for ignoring any new/unread mail in "
35 "your trash and spam folder.</p></qt>"));
36 topLayout->addRow(
QString(), mNotifyOnNewMailCheckBox);
38 mKeepRepliesInSameFolderCheckBox =
new QCheckBox(
i18nc(
"@option:check",
"Keep replies in this folder"),
this);
39 mKeepRepliesInSameFolderCheckBox->setWhatsThis(
40 i18n(
"Check this option if you want replies you write "
41 "to mails in this folder to be put in this same folder "
42 "after sending, instead of in the configured sent-mail folder."));
43 topLayout->addRow(
QString(), mKeepRepliesInSameFolderCheckBox);
46 mHideInSelectionDialogCheckBox =
new QCheckBox(
i18nc(
"@option:check",
"Hide this folder in the folder selection dialog"),
this);
47 mHideInSelectionDialogCheckBox->setWhatsThis(
xi18nc(
"@info:whatsthis",
48 "Check this option if you do not want this folder "
49 "to be shown in folder selection dialogs, such as the <interface>"
50 "Jump to Folder</interface> dialog."));
51 topLayout->addRow(
QString(), mHideInSelectionDialogCheckBox);
54 mUseDefaultIdentityCheckBox =
new QCheckBox(
i18nc(
"@option:check",
"Use &default identity"),
this);
55 topLayout->addRow(
QString(), mUseDefaultIdentityCheckBox);
56 connect(mUseDefaultIdentityCheckBox, &QCheckBox::checkStateChanged,
this, &CollectionGeneralWidget::slotIdentityCheckboxChanged);
59 mIdentityComboBox->setWhatsThis(
60 i18n(
"Select the sender identity to be used when writing new mail "
61 "or replying to mail in this folder. This means that if you are in "
62 "one of your work folders, you can make KMail use the corresponding "
63 "sender email address, signature and signing or encryption keys "
64 "automatically. Identities can be set up in the main configuration "
65 "dialog. (Settings -> Configure KMail)"));
66 topLayout->addRow(
i18n(
"&Sender identity:"), mIdentityComboBox);
69CollectionGeneralWidget::~CollectionGeneralWidget() =
default;
71void CollectionGeneralWidget::slotIdentityCheckboxChanged()
73 mIdentityComboBox->setEnabled(!mUseDefaultIdentityCheckBox->isChecked());
74 if (!mFolderCollection.isNull() && mUseDefaultIdentityCheckBox->isChecked()) {
75 mIdentityComboBox->setCurrentIdentity(mFolderCollection->fallBackIdentity());
79void CollectionGeneralWidget::save(Akonadi::Collection &collection)
81 if (mFolderCollection.isNull()) {
82 mFolderCollection = FolderSettings::forCollection(collection);
84 if (!mNotifyOnNewMailCheckBox->isChecked()) {
86 newMailNotifierAttr->setIgnoreNewMail(
true);
90 if (!mFolderCollection.isNull()) {
91 mFolderCollection->setIdentity(mIdentityComboBox->currentIdentity());
92 mFolderCollection->setUseDefaultIdentity(mUseDefaultIdentityCheckBox->isChecked());
94 mFolderCollection->setPutRepliesInSameFolder(mKeepRepliesInSameFolderCheckBox->isChecked());
95 mFolderCollection->setHideInSelectionDialog(mHideInSelectionDialogCheckBox->isChecked());
96 mFolderCollection->writeConfig();
98 mFolderCollection.reset();
101void CollectionGeneralWidget::load(
const Akonadi::Collection &col)
103 mFolderCollection = MailCommon::FolderSettings::forCollection(col);
105 mIdentityComboBox->setCurrentIdentity(mFolderCollection->identity());
106 mUseDefaultIdentityCheckBox->setChecked(mFolderCollection->useDefaultIdentity());
109 mNotifyOnNewMailCheckBox->setChecked(!Util::ignoreNewMailInFolder(col));
111 const bool keepInFolder = (mFolderCollection->canCreateMessages() && mFolderCollection->putRepliesInSameFolder());
113 mKeepRepliesInSameFolderCheckBox->setChecked(keepInFolder);
114 mKeepRepliesInSameFolderCheckBox->setEnabled(mFolderCollection->canCreateMessages());
115 mHideInSelectionDialogCheckBox->setChecked(mFolderCollection->hideInSelectionDialog());
118#include "moc_collectiongeneralwidget.cpp"
const T * attribute() const
QString xi18nc(const char *context, const char *text, const TYPE &arg...)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)