File indexing completed on 2024-04-28 09:45:59

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 
0080     // Signing menu
0081     void slotPreSignFile();
0082     void slotSignFile(const QUrl &url);
0083     void slotSignFileFin(int);
0084     void slotPreVerifyFile();
0085     void slotVerifyFile(const QUrl &url);
0086     void slotCheckMd5();
0087     void importSignatureKey(const QString &id, const QString &fileName);
0088 
0089     // Options menu
0090     void slotOptions();
0091 
0092     void slotUndoAvailable(const bool v);
0093     void slotRedoAvailable(const bool v);
0094     void slotCopyAvailable(const bool v);
0095 
0096     void modified();
0097     void newText();
0098 
0099     void slotLibraryDone();
0100 
0101     void slotDownloadKeysFinished(const QStringList &ids);
0102 
0103 private:
0104     QString m_textencoding;
0105 
0106     KToggleAction *m_encodingaction;
0107     QAction *m_editundo;
0108     QAction *m_editredo;
0109     QAction *m_editcopy;
0110     QAction *m_editcut;
0111     KFind *m_find;
0112     QUrl m_docname;
0113 
0114     bool m_textchanged;     //< text was changed since last save
0115     bool m_emptytext;       //< this was not saved to a file ever
0116 
0117     KGpgItemModel *m_model;
0118     KeysManager *m_parent;
0119 };
0120 
0121 #endif // KGPGEDITOR_H