File indexing completed on 2024-10-27 04:50:59

0001 /*
0002    SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "attachmentmissingwarning.h"
0008 #include <KLocalizedString>
0009 #include <QAction>
0010 #include <QIcon>
0011 
0012 AttachmentMissingWarning::AttachmentMissingWarning(QWidget *parent)
0013     : KMessageWidget(parent)
0014 {
0015     setVisible(false);
0016     setCloseButtonVisible(false);
0017     setMessageType(Information);
0018     setPosition(KMessageWidget::Header);
0019     setText(i18n(
0020         "The message you have composed seems to refer to an attached file but you have not attached anything. Do you want to attach a file to your message?"));
0021     setWordWrap(true);
0022 
0023     auto action = new QAction(QIcon::fromTheme(QStringLiteral("mail-attachment")), i18n("&Attach file"), this);
0024     action->setObjectName(QLatin1StringView("attachfileaction"));
0025     connect(action, &QAction::triggered, this, &AttachmentMissingWarning::slotAttachFile);
0026     addAction(action);
0027 
0028     action = new QAction(QIcon::fromTheme(QStringLiteral("window-close")), i18n("&Remind me later"), this);
0029     action->setObjectName(QLatin1StringView("remindmelater"));
0030     connect(action, &QAction::triggered, this, &AttachmentMissingWarning::explicitlyClosed);
0031     addAction(action);
0032 }
0033 
0034 AttachmentMissingWarning::~AttachmentMissingWarning() = default;
0035 
0036 void AttachmentMissingWarning::slotAttachFile()
0037 {
0038     Q_EMIT attachMissingFile();
0039 }
0040 
0041 void AttachmentMissingWarning::slotFileAttached()
0042 {
0043     animatedHide();
0044     Q_EMIT closeAttachMissingFile();
0045 }
0046 
0047 void AttachmentMissingWarning::explicitlyClosed()
0048 {
0049     animatedHide();
0050     Q_EMIT explicitClosedMissingAttachment();
0051 }
0052 
0053 #include "moc_attachmentmissingwarning.cpp"