Commit c8130bd7 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Allow to reply message

parent 08427db7
......@@ -40,5 +40,8 @@
<entry name="keepPersistentNotification" key="keepPersistentNotification" type="Bool">
<default>false</default>
</entry>
<entry name="replyMail" key="replyMail" type="Bool">
<default>false</default>
</entry>
</group>
</kcfg>
......@@ -17,6 +17,7 @@
#include <QPushButton>
#include <QCheckBox>
#include <QComboBox>
#include <QGroupBox>
#include <QLabel>
#include <QTabWidget>
......@@ -71,13 +72,32 @@ NewMailNotifierSettingsWidget::NewMailNotifierSettingsWidget(const KSharedConfig
mExcludeMySelf->setObjectName(QStringLiteral("mExcludeMySelf"));
vbox->addWidget(mExcludeMySelf);
mKeepPersistentNotification = new QCheckBox(i18n("Keep Persistent Notification"), parent);
mKeepPersistentNotification->setObjectName(QStringLiteral("mKeepPersistentNotification"));
vbox->addWidget(mKeepPersistentNotification);
mAllowToShowMail = new QCheckBox(i18n("Show Action Buttons"), parent);
mAllowToShowMail->setObjectName(QStringLiteral("mAllowToShowMail"));
vbox->addWidget(mAllowToShowMail);
mKeepPersistentNotification = new QCheckBox(i18n("Keep Persistent Notification"), parent);
mKeepPersistentNotification->setObjectName(QStringLiteral("mKeepPersistentNotification"));
vbox->addWidget(mKeepPersistentNotification);
auto hboxLayout = new QHBoxLayout;
hboxLayout->setObjectName(QStringLiteral("hboxLayout"));
vbox->addLayout(hboxLayout);
mReplyMail = new QCheckBox(i18n("Reply Mail"), parent);
mReplyMail->setObjectName(QStringLiteral("mReplyMail"));
hboxLayout->addWidget(mReplyMail);
mReplyMail->setEnabled(false);
mReplyMailTypeComboBox = new QComboBox(parent);
mReplyMailTypeComboBox->setObjectName(QStringLiteral("mReplyMailTypeComboBox"));
mReplyMailTypeComboBox->setEnabled(false);
hboxLayout->addWidget(mReplyMailTypeComboBox);
hboxLayout->addStretch(1);
connect(mAllowToShowMail, &QCheckBox::clicked, this, [this](bool enabled) {
updateReplyMail(enabled);
});
vbox->addStretch();
tab->addTab(settings, i18n("Display"));
......@@ -138,6 +158,12 @@ NewMailNotifierSettingsWidget::~NewMailNotifierSettingsWidget()
delete NewMailNotifierAgentSettings::self();
}
void NewMailNotifierSettingsWidget::updateReplyMail(bool enabled)
{
mReplyMail->setEnabled(enabled);
mReplyMailTypeComboBox->setEnabled(enabled);
}
void NewMailNotifierSettingsWidget::load()
{
Akonadi::AgentConfigurationBase::load();
......@@ -155,6 +181,8 @@ void NewMailNotifierSettingsWidget::load()
mTextToSpeak->setChecked(settings->textToSpeakEnabled());
mTextToSpeakSetting->setEnabled(mTextToSpeak->isChecked());
mTextToSpeakSetting->setText(settings->textToSpeak());
mReplyMail->setChecked(settings->replyMail());
updateReplyMail(mAllowToShowMail->isChecked());
}
bool NewMailNotifierSettingsWidget::save() const
......@@ -170,6 +198,8 @@ bool NewMailNotifierSettingsWidget::save() const
settings->setKeepPersistentNotification(mKeepPersistentNotification->isChecked());
settings->setTextToSpeakEnabled(mTextToSpeak->isChecked());
settings->setTextToSpeak(mTextToSpeakSetting->text());
settings->setReplyMail(mReplyMail->isChecked());
settings->save();
mNotify->save();
......
......@@ -12,6 +12,7 @@
class KNotifyConfigWidget;
class QCheckBox;
class QLineEdit;
class QComboBox;
class NewMailNotifierSelectCollectionWidget;
class NewMailNotifierSettingsWidget : public Akonadi::AgentConfigurationBase
{
......@@ -25,6 +26,7 @@ public:
private:
void slotHelpLinkClicked(const QString &);
void updateReplyMail(bool enabled);
QCheckBox *mShowPhoto = nullptr;
QCheckBox *mShowFrom = nullptr;
QCheckBox *mShowSubject = nullptr;
......@@ -35,6 +37,8 @@ private:
KNotifyConfigWidget *mNotify = nullptr;
QCheckBox *mTextToSpeak = nullptr;
QLineEdit *mTextToSpeakSetting = nullptr;
QCheckBox *mReplyMail = nullptr;
QComboBox *mReplyMailTypeComboBox = nullptr;
NewMailNotifierSelectCollectionWidget *mSelectCollection = nullptr;
};
......
......@@ -148,7 +148,11 @@ void SpecialNotifierJob::emitNotification(const QPixmap &pixmap)
} else {
notification->setPixmap(pixmap);
}
notification->setActions(QStringList() << i18n("Show mail...") << i18n("Mark As Read") << i18n("Delete"));
QStringList lstActions{i18n("Show mail..."), i18n("Mark As Read"), i18n("Delete")};
if (NewMailNotifierAgentSettings::replyMail()) {
lstActions << i18n("Reply mail...");
}
notification->setActions(lstActions);
connect(notification, QOverload<unsigned int>::of(&KNotification::activated), this, &SpecialNotifierJob::slotActivateNotificationAction);
connect(notification, &KNotification::closed, this, &SpecialNotifierJob::deleteLater);
......@@ -173,10 +177,19 @@ void SpecialNotifierJob::slotActivateNotificationAction(unsigned int index)
case 3:
slotDeleteMessage();
return;
case 4:
slotReplyMessage();
return;
}
qCWarning(NEWMAILNOTIFIER_LOG) << " SpecialNotifierJob::slotActivateNotificationAction unknown index " << index;
}
void SpecialNotifierJob::slotReplyMessage()
{
// TODO
deleteLater();
}
void SpecialNotifierJob::slotDeleteMessage()
{
auto job = new Akonadi::ItemDeleteJob(mItem);
......
......@@ -37,6 +37,7 @@ private:
void slotActivateNotificationAction(unsigned int index);
void emitNotification(const QPixmap &pixmap = QPixmap());
void deleteItemDone(KJob *job);
void slotReplyMessage();
const QStringList mListEmails;
QString mDefaultIconName;
QString mSubject;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment