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

0001 /*
0002   This file is part of KMail, the KDE mail client.
0003   SPDX-FileCopyrightText: 2009 Martin Koller <kollix@aon.at>
0004 
0005   SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #pragma once
0009 
0010 #include <KService>
0011 #include <QObject>
0012 
0013 class QDialog;
0014 class QDialogButtonBox;
0015 namespace MessageViewer
0016 {
0017 /**
0018  * A class which handles the dialog used to present the user a choice what to do
0019  * with an attachment.
0020  */
0021 class AttachmentDialog : public QObject
0022 {
0023     Q_OBJECT
0024 
0025 public:
0026     /// returncodes for exec()
0027     enum {
0028         Save = 2,
0029         Open,
0030         OpenWith,
0031         Cancel,
0032     };
0033 
0034     // if @offer is non-null, the "open with <application>" button will also be shown,
0035     // otherwise only save, open with, cancel
0036     explicit AttachmentDialog(QWidget *parent, const QString &filenameText, const KService::Ptr &offer, const QString &dontAskAgainName);
0037 
0038     // executes the modal dialog
0039     int exec();
0040 
0041 private:
0042     void saveClicked();
0043     void openClicked();
0044     void openWithClicked();
0045     QString text, dontAskName;
0046     QDialog *const dialog;
0047     QDialogButtonBox *mButtonBox = nullptr;
0048 };
0049 }