Messagelib

invitationsettings.cpp
1/*
2 SPDX-License-Identifier: BSL-1.0
3*/
4
5#include "invitationsettings.h"
6#include "settings/messageviewersettings.h"
7#include "ui_invitationsettings.h"
8#include <PimCommon/ConfigureImmutableWidgetUtils>
9using namespace PimCommon::ConfigureImmutableWidgetUtils;
10
11#include <KLocalizedString>
12#include <KMessageBox>
13
14using namespace MessageViewer;
15
16class MessageViewer::InvitationSettingsPrivate
17{
18public:
19 InvitationSettingsPrivate()
20 : mInvitationUi(new Ui_InvitationSettings)
21 {
22 }
23
24 ~InvitationSettingsPrivate()
25 {
26 delete mInvitationUi;
27 }
28
29 Ui_InvitationSettings *const mInvitationUi;
30};
31
32InvitationSettings::InvitationSettings(QWidget *parent)
33 : QWidget(parent)
34 , d(new MessageViewer::InvitationSettingsPrivate)
35{
36 d->mInvitationUi->setupUi(this);
37
38 d->mInvitationUi->mDeleteInvitations->setText(
39 i18n(MessageViewer::MessageViewerSettings::self()->deleteInvitationEmailsAfterSendingReplyItem()->label().toUtf8().constData()));
40 d->mInvitationUi->mDeleteInvitations->setWhatsThis(
41 i18n(MessageViewer::MessageViewerSettings::self()->deleteInvitationEmailsAfterSendingReplyItem()->whatsThis().toUtf8().constData()));
42 connect(d->mInvitationUi->mDeleteInvitations, &QCheckBox::toggled, this, &InvitationSettings::changed);
43
44 d->mInvitationUi->mLegacyMangleFromTo->setWhatsThis(
45 i18n(MessageViewer::MessageViewerSettings::self()->legacyMangleFromToHeadersItem()->whatsThis().toUtf8().constData()));
46 connect(d->mInvitationUi->mLegacyMangleFromTo, &QCheckBox::stateChanged, this, &InvitationSettings::changed);
47
48 d->mInvitationUi->mLegacyBodyInvites->setWhatsThis(
49 i18n(MessageViewer::MessageViewerSettings::self()->legacyBodyInvitesItem()->whatsThis().toUtf8().constData()));
50 connect(d->mInvitationUi->mLegacyBodyInvites, &QCheckBox::toggled, this, &InvitationSettings::slotLegacyBodyInvitesToggled);
51 connect(d->mInvitationUi->mLegacyBodyInvites, &QCheckBox::stateChanged, this, &InvitationSettings::changed);
52
53 d->mInvitationUi->mExchangeCompatibleInvitations->setWhatsThis(
54 i18n(MessageViewer::MessageViewerSettings::self()->exchangeCompatibleInvitationsItem()->whatsThis().toUtf8().constData()));
55 connect(d->mInvitationUi->mExchangeCompatibleInvitations, &QCheckBox::stateChanged, this, &InvitationSettings::changed);
56
57 // Laurent BUG:257723: in kmail2 it's not possible to not send automatically.
58 d->mInvitationUi->mAutomaticSending->hide();
59 d->mInvitationUi->mAutomaticSending->setWhatsThis(
60 i18n(MessageViewer::MessageViewerSettings::self()->automaticSendingItem()->whatsThis().toUtf8().constData()));
61 connect(d->mInvitationUi->mAutomaticSending, &QCheckBox::stateChanged, this, &InvitationSettings::changed);
62}
63
64InvitationSettings::~InvitationSettings() = default;
65
66void InvitationSettings::slotLegacyBodyInvitesToggled(bool on)
67{
68 if (on) {
69 const QString txt = i18n(
70 "<qt>Invitations are normally sent as attachments to "
71 "a mail. This switch changes the invitation mails to "
72 "be sent in the text of the mail instead; this is "
73 "necessary to send invitations and replies to "
74 "Microsoft Outlook.<br />But, when you do this, you no "
75 "longer get descriptive text that mail programs "
76 "can read; so, to people who have email programs "
77 "that do not understand the invitations, the "
78 "resulting messages look very odd.<br />People that have email "
79 "programs that do understand invitations will still "
80 "be able to work with this.</qt>");
81 KMessageBox::information(this, txt, QString(), QStringLiteral("LegacyBodyInvitesWarning"));
82 }
83 // Invitations in the body are autosent in any case (no point in editing raw ICAL)
84 // So the autosend option is only available if invitations are sent as attachment.
85 d->mInvitationUi->mAutomaticSending->setEnabled(!d->mInvitationUi->mLegacyBodyInvites->isChecked());
86}
87
88void InvitationSettings::doLoadFromGlobalSettings()
89{
90 loadWidget(d->mInvitationUi->mLegacyMangleFromTo, MessageViewer::MessageViewerSettings::self()->legacyMangleFromToHeadersItem());
91 d->mInvitationUi->mLegacyBodyInvites->blockSignals(true);
92 loadWidget(d->mInvitationUi->mLegacyBodyInvites, MessageViewer::MessageViewerSettings::self()->legacyBodyInvitesItem());
93 d->mInvitationUi->mLegacyBodyInvites->blockSignals(false);
94 loadWidget(d->mInvitationUi->mExchangeCompatibleInvitations, MessageViewer::MessageViewerSettings::self()->exchangeCompatibleInvitationsItem());
95 loadWidget(d->mInvitationUi->mAutomaticSending, MessageViewer::MessageViewerSettings::self()->automaticSendingItem());
96 // TODO verify it
97 d->mInvitationUi->mAutomaticSending->setEnabled(!d->mInvitationUi->mLegacyBodyInvites->isChecked());
98 loadWidget(d->mInvitationUi->mDeleteInvitations, MessageViewer::MessageViewerSettings::self()->deleteInvitationEmailsAfterSendingReplyItem());
99}
100
101void InvitationSettings::save()
102{
103 saveCheckBox(d->mInvitationUi->mLegacyMangleFromTo, MessageViewer::MessageViewerSettings::self()->legacyMangleFromToHeadersItem());
104 saveCheckBox(d->mInvitationUi->mLegacyBodyInvites, MessageViewer::MessageViewerSettings::self()->legacyBodyInvitesItem());
105 saveCheckBox(d->mInvitationUi->mExchangeCompatibleInvitations, MessageViewer::MessageViewerSettings::self()->exchangeCompatibleInvitationsItem());
106 saveCheckBox(d->mInvitationUi->mAutomaticSending, MessageViewer::MessageViewerSettings::self()->automaticSendingItem());
107 saveCheckBox(d->mInvitationUi->mDeleteInvitations, MessageViewer::MessageViewerSettings::self()->deleteInvitationEmailsAfterSendingReplyItem());
108}
109
110QString InvitationSettings::helpAnchor() const
111{
112 return QStringLiteral("configure-misc-invites");
113}
114
115void InvitationSettings::doResetToDefaultsOther()
116{
117 const bool bUseDefaults = MessageViewer::MessageViewerSettings::self()->useDefaults(true);
118 loadWidget(d->mInvitationUi->mLegacyMangleFromTo, MessageViewer::MessageViewerSettings::self()->legacyMangleFromToHeadersItem());
119 d->mInvitationUi->mLegacyBodyInvites->blockSignals(true);
120 loadWidget(d->mInvitationUi->mLegacyBodyInvites, MessageViewer::MessageViewerSettings::self()->legacyBodyInvitesItem());
121 d->mInvitationUi->mLegacyBodyInvites->blockSignals(false);
122 loadWidget(d->mInvitationUi->mExchangeCompatibleInvitations, MessageViewer::MessageViewerSettings::self()->exchangeCompatibleInvitationsItem());
123 loadWidget(d->mInvitationUi->mAutomaticSending, MessageViewer::MessageViewerSettings::self()->automaticSendingItem());
124 // TODO verify it
125 d->mInvitationUi->mAutomaticSending->setEnabled(!d->mInvitationUi->mLegacyBodyInvites->isChecked());
126 loadWidget(d->mInvitationUi->mDeleteInvitations, MessageViewer::MessageViewerSettings::self()->deleteInvitationEmailsAfterSendingReplyItem());
127 MessageViewer::MessageViewerSettings::self()->useDefaults(bUseDefaults);
128}
129
130#include "moc_invitationsettings.cpp"
QString i18n(const char *text, const TYPE &arg...)
void information(QWidget *parent, const QString &text, const QString &title=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
QString label(StandardShortcut id)
QString whatsThis(StandardShortcut id)
void toggled(bool checked)
void stateChanged(int state)
T qobject_cast(QObject *object)
void setupUi(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:37:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.