File indexing completed on 2022-09-27 16:32:20

0001 /*
0002     SPDX-FileCopyrightText: 2002 Jean-Baptiste Mardelle <bj@altern.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef KGPGEDITOR_H
0007 #define KGPGEDITOR_H
0008 
0009 #include <KXmlGuiWindow>
0010 #include <QUrl>
0011 #include <QTextCodec>
0012 
0013 class KToggleAction;
0014 class QAction;
0015 class KFind;
0016 
0017 class KgpgTextEdit;
0018 class KGpgItemModel;
0019 class KeysManager;
0020 class KRecentFilesAction;
0021 
0022 class KgpgEditor : public KXmlGuiWindow
0023 {
0024     Q_OBJECT
0025     friend class KgpgView;
0026 
0027     KgpgEditor() = delete;
0028 public:
0029     KgpgEditor(KeysManager *parent, KGpgItemModel *model, Qt::WindowFlags f);
0030     ~KgpgEditor() override;
0031 
0032     void openEncryptedDocumentFile(const QUrl &url);
0033 
0034     KgpgTextEdit * const m_editor;
0035     KRecentFilesAction *m_recentfiles;
0036 
0037 Q_SIGNALS:
0038     void openChangeFont();
0039     void openConfigDialog();
0040 
0041 public Q_SLOTS:
0042     void openDocumentFile(const QUrl &url, const QString &encoding = QString());
0043     void slotSetFont(QFont myFont);
0044     void closeWindow();
0045 
0046 protected:
0047     void saveOptions();
0048     void initActions();
0049     bool queryClose() override;
0050     bool saveBeforeClear();
0051 
0052 private Q_SLOTS:
0053     // File menu
0054     void slotFileNew();
0055     void slotFileOpen();
0056     bool slotFileSave();
0057     bool slotFileSaveAs();
0058     void slotFilePrint();
0059     void slotFilePreEnc();
0060     void slotFilePreDec();
0061     void slotKeyManager();
0062     void slotFileClose();
0063 
0064     // Edit menu
0065     void slotundo();
0066     void slotredo();
0067     void slotEditCut();
0068     void slotEditCopy();
0069     void slotEditPaste();
0070     void slotSelectAll();
0071     void slotFind();
0072     void slotFindNext();
0073     void slotFindPrev();
0074     void slotFindText();
0075 
0076     // Coding menu
0077     void slotSetCharset();
0078     void slotResetEncoding(bool enc);
0079     bool checkEncoding(QTextCodec *codec);
0080 
0081     // Signing menu
0082     void slotPreSignFile();
0083     void slotSignFile(const QUrl &url);
0084     void slotSignFileFin(int);
0085     void slotPreVerifyFile();
0086     void slotVerifyFile(const QUrl &url);
0087     void slotCheckMd5();
0088     void importSignatureKey(const QString &id, const QString &fileName);
0089 
0090     // Options menu
0091     void slotOptions();
0092 
0093     void slotUndoAvailable(const bool v);
0094     void slotRedoAvailable(const bool v);
0095     void slotCopyAvailable(const bool v);
0096 
0097     void modified();
0098     void newText();
0099 
0100     void slotLibraryDone();
0101 
0102     void slotDownloadKeysFinished(const QStringList &ids);
0103 
0104 private:
0105     QString m_textencoding;
0106 
0107     KToggleAction *m_encodingaction;
0108     QAction *m_editundo;
0109     QAction *m_editredo;
0110     QAction *m_editcopy;
0111     QAction *m_editcut;
0112     KFind *m_find;
0113     QUrl m_docname;
0114 
0115     bool m_textchanged;     //< text was changed since last save
0116     bool m_emptytext;       //< this was not saved to a file ever
0117 
0118     KGpgItemModel *m_model;
0119     KeysManager *m_parent;
0120 };
0121 
0122 #endif // KGPGEDITOR_H