File indexing completed on 2025-03-09 04:54:12

0001 /*
0002   SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
0003 
0004   Based on KMail code by various authors (kmmsgpartdlg).
0005 
0006   SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #pragma once
0010 
0011 #include "messagecore_export.h"
0012 
0013 #include "attachmentpart.h"
0014 
0015 #include <QDialog>
0016 
0017 namespace MessageCore
0018 {
0019 /**
0020  * @short A dialog for editing attachment properties.
0021  *
0022  * @author Constantin Berzan <exit3219@gmail.com>
0023  */
0024 class MESSAGECORE_EXPORT AttachmentPropertiesDialog : public QDialog
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     /**
0030      * Creates a new attachment properties dialog.
0031      *
0032      * @param part The attachment part which properties to change.
0033      * @param readOnly Whether the dialog should be in read-only mode.
0034      * @param parent The parent object.
0035      */
0036     explicit AttachmentPropertiesDialog(const AttachmentPart::Ptr &part, bool readOnly = false, QWidget *parent = nullptr);
0037 
0038     /**
0039      * Creates a new attachment properties dialog.
0040      *
0041      * @param content The mime content that represents the attachment which properties to change.
0042      * @param parent The parent object.
0043      *
0044      * @note This converts the KMime::Content to an AttachmentPart internally.
0045      *       Therefore, saving the changes to the KMime::Content is not supported,
0046      *       and the dialog is in readOnly mode.
0047      */
0048     explicit AttachmentPropertiesDialog(const KMime::Content *content, QWidget *parent = nullptr);
0049 
0050     /**
0051      * Destroys the attachment properties dialog.
0052      */
0053     ~AttachmentPropertiesDialog() override;
0054 
0055     /**
0056      * Returns the modified attachment.
0057      */
0058     [[nodiscard]] AttachmentPart::Ptr attachmentPart() const;
0059 
0060     /**
0061      * Sets whether the encryption status of the attachment can be changed.
0062      */
0063     void setEncryptEnabled(bool enabled);
0064 
0065     /**
0066      * Returns whether the encryption status of the attachment can be changed.
0067      */
0068     [[nodiscard]] bool isEncryptEnabled() const;
0069 
0070     /**
0071      * Sets whether the signature status of the attachment can be changed.
0072      */
0073     void setSignEnabled(bool enabled);
0074 
0075     /**
0076      * Returns whether the signature status of the attachment can be changed.
0077      */
0078     [[nodiscard]] bool isSignEnabled() const;
0079 
0080 public Q_SLOTS:
0081     void accept() override;
0082     void slotHelp();
0083 
0084 private:
0085     //@cond PRIVATE
0086     class AttachmentPropertiesDialogPrivate;
0087     std::unique_ptr<AttachmentPropertiesDialogPrivate> const d;
0088     //@endcond
0089 };
0090 }