File indexing completed on 2024-06-23 05:18:28
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Volker Krause <vkrause@kde.org> 0003 * 0004 * Based on kmail/kmcomposewin.cpp 0005 * SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com> 0006 * 0007 * Based on KMail code by: 0008 * SPDX-FileCopyrightText: 1997 Markus Wuebben <markus.wuebben@kde.org> 0009 * 0010 * SPDX-License-Identifier: GPL-2.0-or-later 0011 */ 0012 0013 #pragma once 0014 0015 #include "messagecomposer_export.h" 0016 #include <KIdentityManagementCore/Signature> 0017 #include <QObject> 0018 0019 namespace KIdentityManagementWidgets 0020 { 0021 class IdentityCombo; 0022 } 0023 0024 namespace MessageComposer 0025 { 0026 class RichTextComposerNg; 0027 class SignatureControllerPrivate; 0028 /** 0029 * @brief The SignatureController class 0030 * Controls signature (the footer thing, not the crypto thing) operations 0031 * happening on a KMEditor triggered by identity selection or menu actions. 0032 * @since 4.5 0033 */ 0034 class MESSAGECOMPOSER_EXPORT SignatureController : public QObject 0035 { 0036 Q_OBJECT 0037 public: 0038 explicit SignatureController(QObject *parent = nullptr); 0039 ~SignatureController() override; 0040 0041 void setEditor(MessageComposer::RichTextComposerNg *editor); 0042 void setIdentityCombo(KIdentityManagementWidgets::IdentityCombo *combo); 0043 0044 /** Temporarily disable identity tracking, useful for initial loading for example. */ 0045 void suspend(); 0046 /** Resume identity change tracking after a previous call to suspend(). */ 0047 void resume(); 0048 0049 /** Adds the given signature to the editor, taking user preferences into account. 0050 */ 0051 void applySignature(const KIdentityManagementCore::Signature &signature); 0052 0053 public Q_SLOTS: 0054 /** 0055 * Append signature to the end of the text in the editor. 0056 */ 0057 void appendSignature(); 0058 0059 /** 0060 * Prepend signature at the beginning of the text in the editor. 0061 */ 0062 void prependSignature(); 0063 0064 /** 0065 * Insert signature at the cursor position of the text in the editor. 0066 */ 0067 void insertSignatureAtCursor(); 0068 0069 void cleanSpace(); 0070 0071 Q_SIGNALS: 0072 /** 0073 * A HTML signature is about to be inserted, so enable HTML support in the editor. 0074 */ 0075 void enableHtml(); 0076 void signatureAdded(); 0077 0078 private: 0079 /** 0080 * Helper to insert the signature of the current identity arbitrarily 0081 * in the editor, connecting slot functions to KMeditor::insertSignature(). 0082 * @param placement the position of the signature 0083 */ 0084 MESSAGECOMPOSER_NO_EXPORT void insertSignatureHelper(KIdentityManagementCore::Signature::Placement placement); 0085 0086 private Q_SLOTS: 0087 MESSAGECOMPOSER_NO_EXPORT void identityChanged(uint id); 0088 0089 private: 0090 std::unique_ptr<SignatureControllerPrivate> const d; 0091 }; 0092 }