2022-01-26 16:27:42 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2018 Chinmoy Ranjan Pradhan <chinmoyrp65@gmail.com>
|
2023-05-03 13:41:14 +00:00
|
|
|
SPDX-FileCopyrightText: 2023 g10 Code GmbH
|
|
|
|
SPDX-FileContributor: Sune Stolborg Vuorela <sune@vuorela.dk>
|
2022-01-26 16:27:42 +00:00
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OKULAR_SIGNATUREPARTUTILS_H
|
|
|
|
#define OKULAR_SIGNATUREPARTUTILS_H
|
|
|
|
|
2023-05-03 13:41:14 +00:00
|
|
|
#include <QDialog>
|
|
|
|
#include <QStyledItemDelegate>
|
2022-01-26 16:27:42 +00:00
|
|
|
#include <memory>
|
2023-04-19 12:13:48 +00:00
|
|
|
#include <optional>
|
2022-01-26 16:27:42 +00:00
|
|
|
|
|
|
|
#include "gui/signatureguiutils.h"
|
|
|
|
|
|
|
|
class PageView;
|
2023-04-19 11:36:13 +00:00
|
|
|
class Ui_SelectCertificateDialog;
|
2022-01-26 16:27:42 +00:00
|
|
|
|
|
|
|
namespace SignaturePartUtils
|
|
|
|
{
|
2023-04-19 12:13:48 +00:00
|
|
|
struct SigningInformation {
|
|
|
|
std::unique_ptr<Okular::CertificateInfo> certificate;
|
|
|
|
QString certificatePassword;
|
|
|
|
QString documentPassword;
|
2023-04-20 08:16:04 +00:00
|
|
|
QString reason;
|
|
|
|
QString location;
|
2023-04-20 14:17:41 +00:00
|
|
|
QString backgroundImagePath;
|
2023-04-19 12:13:48 +00:00
|
|
|
};
|
|
|
|
|
2023-04-20 14:17:41 +00:00
|
|
|
enum class SigningInformationOption { None = 0x0, BackgroundImage = 0x1 };
|
|
|
|
Q_DECLARE_FLAGS(SigningInformationOptions, SigningInformationOption);
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(SigningInformationOptions);
|
|
|
|
|
2023-04-19 12:13:48 +00:00
|
|
|
/** Retrieves signing information for this operation
|
|
|
|
\return nullopt on failure, otherwise information
|
|
|
|
*/
|
2023-04-20 14:17:41 +00:00
|
|
|
std::optional<SigningInformation> getCertificateAndPasswordForSigning(PageView *pageView, Okular::Document *doc, SigningInformationOptions opts);
|
2023-04-19 12:13:48 +00:00
|
|
|
|
2022-01-26 16:27:42 +00:00
|
|
|
QString getFileNameForNewSignedFile(PageView *pageView, Okular::Document *doc);
|
|
|
|
void signUnsignedSignature(const Okular::FormFieldSignature *form, PageView *pageView, Okular::Document *doc);
|
|
|
|
|
2023-05-03 13:41:14 +00:00
|
|
|
class KeyDelegate : public QStyledItemDelegate
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
using QStyledItemDelegate::QStyledItemDelegate;
|
|
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const final;
|
|
|
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const final;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SelectCertificateDialog : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2023-04-19 11:36:13 +00:00
|
|
|
std::unique_ptr<Ui_SelectCertificateDialog> ui;
|
|
|
|
~SelectCertificateDialog() override;
|
2023-05-03 13:41:14 +00:00
|
|
|
|
|
|
|
explicit SelectCertificateDialog(QWidget *parent);
|
|
|
|
};
|
2022-01-26 16:27:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|