diff options
author | Saturneric <[email protected]> | 2021-05-11 22:09:22 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2021-05-11 22:09:22 +0000 |
commit | 8a63cb095c5a6b488e0bbf19269ab7aae492bfcc (patch) | |
tree | 13dd8241e6267b4fae6bb1356d3789e7de40ea37 | |
parent | Qt5 & Cmake Supported. (diff) | |
download | GpgFrontend-8a63cb095c5a6b488e0bbf19269ab7aae492bfcc.tar.gz GpgFrontend-8a63cb095c5a6b488e0bbf19269ab7aae492bfcc.zip |
Change CXX Standard to C++14
Headers Tidy and Reformat
Diffstat (limited to '')
-rw-r--r-- | .idea/vcs.xml | 6 | ||||
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | include/GPG4USB.h | 6 | ||||
-rw-r--r-- | include/aboutdialog.h | 48 | ||||
-rw-r--r-- | include/attachments.h | 30 | ||||
-rw-r--r-- | include/attachmenttablemodel.h | 30 | ||||
-rw-r--r-- | include/editorpage.h | 22 | ||||
-rwxr-xr-x | include/fileencryptiondialog.h | 27 | ||||
-rw-r--r-- | include/findwidget.h | 19 | ||||
-rw-r--r-- | include/gpgconstants.h | 15 | ||||
-rw-r--r-- | include/gpgcontext.h | 222 | ||||
-rw-r--r-- | include/helppage.h | 18 | ||||
-rw-r--r-- | include/keydetailsdialog.h | 17 | ||||
-rw-r--r-- | include/keygendialog.h | 24 | ||||
-rw-r--r-- | include/keygenthread.h | 16 | ||||
-rw-r--r-- | include/keyimportdetaildialog.h | 6 | ||||
-rw-r--r-- | include/keylist.h | 36 | ||||
-rwxr-xr-x | include/keymgmt.h | 35 | ||||
-rw-r--r-- | include/keyserverimportdialog.h | 42 | ||||
-rw-r--r-- | include/mainwindow.h | 46 | ||||
-rw-r--r-- | include/mime.h | 87 | ||||
-rwxr-xr-x | include/quitdialog.h | 23 | ||||
-rwxr-xr-x | include/settingsdialog.h | 262 | ||||
-rw-r--r-- | include/textedit.h | 35 | ||||
-rw-r--r-- | include/verifydetailsdialog.h | 16 | ||||
-rw-r--r-- | include/verifykeydetailbox.h | 17 | ||||
-rw-r--r-- | include/verifynotification.h | 27 | ||||
-rw-r--r-- | include/wizard.h | 92 | ||||
-rw-r--r-- | src/mime.cpp | 2 |
29 files changed, 589 insertions, 639 deletions
diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$" vcs="Git" /> + </component> +</project>
\ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index a9b89d6f..8b00413e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.19) project(gpg4usb VERSION 1.0.0 LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) # set(CMAKE_AUTOMOC ON) diff --git a/include/GPG4USB.h b/include/GPG4USB.h index 6bcd085c..95a6476c 100644 --- a/include/GPG4USB.h +++ b/include/GPG4USB.h @@ -5,11 +5,17 @@ #ifndef GPG4USB_GPG4USB_H #define GPG4USB_GPG4USB_H +#include <iostream> +#include <string> +#include <cmath> +#include <clocale> +#include <cerrno> #include <QtCore> #include <QtWidgets> #include <QtNetwork/QtNetwork> #include <QtPrintSupport/QtPrintSupport> +#include <gpgme.h> #endif //GPG4USB_GPG4USB_H diff --git a/include/aboutdialog.h b/include/aboutdialog.h index 9370508f..4235199e 100644 --- a/include/aboutdialog.h +++ b/include/aboutdialog.h @@ -22,53 +22,41 @@ #ifndef __ABOUTDIALOG_H__ #define __ABOUTDIALOG_H__ -#include <include/GPG4USB.h> - -#include <QWidget> -#include <QtGui> +#include <GPG4USB.h> #include "gpgcontext.h" -QT_BEGIN_NAMESPACE -class QVBoxLayout; -class QLabel; -class QTabWidget; -QT_END_NAMESPACE - /** * @brief Class containing the main tab of about dialog * */ -class InfoTab : public QWidget - { - Q_OBJECT +class InfoTab : public QWidget { +Q_OBJECT - public: - InfoTab(QWidget *parent = 0); - }; +public: + explicit InfoTab(QWidget *parent = nullptr); +}; /** * @brief Class containing the translator tab of about dialog * */ -class TranslatorsTab : public QWidget - { - Q_OBJECT +class TranslatorsTab : public QWidget { +Q_OBJECT - public: - TranslatorsTab(QWidget *parent = 0); - }; +public: + explicit TranslatorsTab(QWidget *parent = nullptr); +}; - /** - * @brief Class for handling the about dialog - * - */ -class AboutDialog : public QDialog -{ - Q_OBJECT +/** + * @brief Class for handling the about dialog + * + */ +class AboutDialog : public QDialog { +Q_OBJECT public: - AboutDialog(QWidget *parent = 0); + explicit AboutDialog(QWidget *parent = nullptr); }; #endif // __ABOUTDIALOG_H__ diff --git a/include/attachments.h b/include/attachments.h index 2ffff3e0..2d614463 100644 --- a/include/attachments.h +++ b/include/attachments.h @@ -23,38 +23,26 @@ #define __ATTACHMENTS_H__ #include "attachmenttablemodel.h" -#include <QtGui> -#include <QWidget> -QT_BEGIN_NAMESPACE -class QTableView; -class QHeaderView; -class QVBoxLayout; -class QMenu; -class QMessageBox; -class QContextMenuEvent; -class QFileDialog; -class QUrl; -class QDesktopServices; -class QSettings; -class QApplication; -QT_END_NAMESPACE - -class Attachments : public QWidget -{ - Q_OBJECT +class Attachments : public QWidget { +Q_OBJECT public slots: + void slotSaveFile(); + void slotOpenFile(); public: - Attachments(QWidget *parent = nullptr); + explicit Attachments(QWidget *parent = nullptr); + void addMimePart(MimePart *mp); private: void createActions(); + void saveByteArrayToFile(QByteArray outBuffer, QString filename); + QAction *saveFileAct; QAction *openFileAct; AttachmentTableModel *table; @@ -62,7 +50,7 @@ private: QSettings settings; protected: - void contextMenuEvent(QContextMenuEvent *event); + void contextMenuEvent(QContextMenuEvent *event) override; }; #endif // __ATTACHMENTS_H__ diff --git a/include/attachmenttablemodel.h b/include/attachmenttablemodel.h index bb019dea..987f75f6 100644 --- a/include/attachmenttablemodel.h +++ b/include/attachmenttablemodel.h @@ -23,29 +23,27 @@ #define __ATTACHMENTTABLEMODEL_H__ #include "mime.h" -#include <QIcon> -#include <QFile> -#include <QAbstractTableModel> -QT_BEGIN_NAMESPACE -class QStandardItem; -QT_END_NAMESPACE - -class AttachmentTableModel : public QAbstractTableModel -{ - Q_OBJECT +class AttachmentTableModel : public QAbstractTableModel { +Q_OBJECT public: - AttachmentTableModel(QObject *parent = 0); - AttachmentTableModel(QList<MimePart> mimeparts, QObject *parent = 0); + explicit AttachmentTableModel(QObject *parent = nullptr); + + explicit AttachmentTableModel(QList<MimePart> mimeparts, QObject *parent = nullptr); + + int rowCount(const QModelIndex &parent) const override; + + int columnCount(const QModelIndex &parent) const override; - int rowCount(const QModelIndex &parent) const; - int columnCount(const QModelIndex &parent) const; - QVariant data(const QModelIndex &index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QVariant data(const QModelIndex &index, int role) const override; + + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; void add(MimePart mp); + MimePart getSelectedMimePart(QModelIndex index); + MimePart getMimePart(int index); //QList<MimePart> getSelectedMimeParts(QModelIndexList indexes); diff --git a/include/editorpage.h b/include/editorpage.h index 5fed07ce..0268c3e2 100644 --- a/include/editorpage.h +++ b/include/editorpage.h @@ -22,25 +22,28 @@ #ifndef __EDITORPAGE_H__ #define __EDITORPAGE_H__ -#include <include/GPG4USB.h> +#include <GPG4USB.h> #include "gpgconstants.h" QT_BEGIN_NAMESPACE class QVBoxLayout; + class QHBoxLayout; + class QString; + class QLabel; + QT_END_NAMESPACE /** * @brief Class for handling a single tab of the tabwidget * */ -class EditorPage : public QWidget -{ - Q_OBJECT +class EditorPage : public QWidget { +Q_OBJECT public: /** @@ -49,12 +52,12 @@ public: * @param filePath Path of the file handled in this tab * @param parent Pointer to the parent widget */ - EditorPage(const QString &filePath = "", QWidget *parent = 0); + explicit EditorPage(const QString &filePath = "", QWidget *parent = nullptr); /** * @details Get the filepath of the currently activated tab. */ - const QString& getFilePath() const; + const QString &getFilePath() const; /** * @details Set filepath of currently activated tab. @@ -86,13 +89,14 @@ public: private: QTextEdit *textPage; /** The textedit of the tab */ QVBoxLayout *mainLayout; /** The layout for the tab */ - QWidget *notificationWidget; /** The notification widget shown at the buttom of the tab */ - QMenu *verifyMenu; /** The menu in the notifiaction widget */ + [[maybe_unused]] QWidget *notificationWidget; /** The notification widget shown at the buttom of the tab */ + [[maybe_unused]] QMenu *verifyMenu; /** The menu in the notifiaction widget */ QString fullFilePath; /** The path to the file handled in the tab */ - QLabel *verifyLabel; /** The label of the verify-notification widget */ + [[maybe_unused]] QLabel *verifyLabel; /** The label of the verify-notification widget */ bool signMarked; /** true, if the signed header is marked, false if not */ private slots: + /** * @details Format the gpg header in another font-style */ diff --git a/include/fileencryptiondialog.h b/include/fileencryptiondialog.h index af6edff5..f929716b 100755 --- a/include/fileencryptiondialog.h +++ b/include/fileencryptiondialog.h @@ -26,27 +26,14 @@ #include "keylist.h" #include "verifydetailsdialog.h" -QT_BEGIN_NAMESPACE -class QDialog; -class QLineEdit; -class QWidget; -class QDialogButtonBox; -class QLabel; -class QPushButton; -class QHBoxLayout; -class QVBoxLayout; -class QDebug; -class QFileDialog; -QT_END_NAMESPACE /** * @brief * * @class FileEncryptionDialog fileencryptiondialog.h "fileencryptiondialog.h" */ -class FileEncryptionDialog : public QDialog -{ - Q_OBJECT +class FileEncryptionDialog : public QDialog { +Q_OBJECT public: @@ -65,38 +52,45 @@ public: * @param keyList * @param parent */ - FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList keyList, DialogAction action, QWidget *parent = 0); + FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList keyList, DialogAction action, QWidget *parent = nullptr); + public slots: + /** * @details * * @fn selectInputFile */ void slotSelectInputFile(); + /** * @brief * * @fn selectOutputFile */ void slotSelectOutputFile(); + /** * @brief * * @fn selectSignFile */ void slotSelectSignFile(); + /** * @brief * * @fn executeAction */ void slotExecuteAction(); + /** * @brief * * @fn hideKeyList */ void slotHideKeyList(); + /** * @brief * @@ -115,4 +109,5 @@ protected: KeyList *mKeyList; /**< TODO */ }; + #endif // __FILEENCRYPTIONDIALOG_H__ diff --git a/include/findwidget.h b/include/findwidget.h index cd8602c7..e135b354 100644 --- a/include/findwidget.h +++ b/include/findwidget.h @@ -2,18 +2,13 @@ #ifndef FINDWIDGET_H #define FINDWIDGET_H -#include <include/GPG4USB.h> - #include "editorpage.h" -#include <QWidget> - /** * @brief Class for handling the find widget shown at buttom of a textedit-page */ -class FindWidget : public QWidget -{ - Q_OBJECT +class FindWidget : public QWidget { +Q_OBJECT public: /** @@ -24,7 +19,8 @@ public: explicit FindWidget(QWidget *parent, QTextEdit *edit); private: - void keyPressEvent( QKeyEvent* e ); + void keyPressEvent(QKeyEvent *e) override; + /** * @details Set background of findEdit to red, if no match is found (Documents textcursor position equals -1), * otherwise set it to white. @@ -33,12 +29,17 @@ private: QTextEdit *mTextpage; /** Textedit associated to the notification */ QLineEdit *findEdit; /** Label holding the text shown in verifyNotification */ - QTextCharFormat cursorFormat; + [[maybe_unused]] QTextCharFormat cursorFormat; private slots: + void slotFindNext(); + void slotFindPrevious(); + void slotFind(); + void slotClose(); }; + #endif // FINDWIDGET_H diff --git a/include/gpgconstants.h b/include/gpgconstants.h index e01083cf..fe690b36 100644 --- a/include/gpgconstants.h +++ b/include/gpgconstants.h @@ -26,15 +26,14 @@ class QString; const int RESTART_CODE = 1000; -class GpgConstants -{ +class GpgConstants { public: - static const char* PGP_CRYPT_BEGIN; - static const char* PGP_CRYPT_END; - static const char* PGP_SIGNED_BEGIN; - static const char* PGP_SIGNED_END; - static const char* PGP_SIGNATURE_BEGIN; - static const char* PGP_SIGNATURE_END; + static const char *PGP_CRYPT_BEGIN; + static const char *PGP_CRYPT_END; + static const char *PGP_SIGNED_BEGIN; + static const char *PGP_SIGNED_END; + static const char *PGP_SIGNATURE_BEGIN; + static const char *PGP_SIGNATURE_END; }; #endif // GPGCONSTANTS_H diff --git a/include/gpgcontext.h b/include/gpgcontext.h index e7b79113..a1680e6b 100644 --- a/include/gpgcontext.h +++ b/include/gpgcontext.h @@ -22,51 +22,37 @@ #ifndef __SGPGMEPP_CONTEXT_H__ #define __SGPGMEPP_CONTEXT_H__ -#include <include/GPG4USB.h> +#include <GPG4USB.h> #include "gpgconstants.h" -#include <locale.h> -#include <errno.h> -#include <gpgme.h> -#include <QLinkedList> -#include <QtGui> - -QT_BEGIN_NAMESPACE -class QMessageBox; -class sstream; -class QApplication; -class QByteArray; -class QString; -QT_END_NAMESPACE - -class GpgKey -{ + + +class GpgKey { public: GpgKey() { privkey = false; } + QString id; QString name; QString email; QString fpr; bool privkey; - bool expired; - bool revoked; + bool expired{}; + bool revoked{}; }; -typedef QLinkedList< GpgKey > GpgKeyList; +typedef QLinkedList<GpgKey> GpgKeyList; -class GpgImportedKey -{ +class GpgImportedKey { public: QString fpr; int importStatus; }; -typedef QLinkedList< GpgImportedKey > GpgImportedKeyList; +typedef QLinkedList<GpgImportedKey> GpgImportedKeyList; -class GpgImportInformation -{ +class GpgImportInformation { public: GpgImportInformation() { considered = 0; @@ -85,14 +71,14 @@ public: } int considered; - int no_user_id; + [[maybe_unused]] int no_user_id; int imported; - int imported_rsa; + [[maybe_unused]] int imported_rsa; int unchanged; - int new_user_ids; - int new_sub_keys; - int new_signatures; - int new_revocations; + [[maybe_unused]] int new_user_ids; + [[maybe_unused]] int new_sub_keys; + [[maybe_unused]] int new_signatures; + [[maybe_unused]] int new_revocations; int secret_read; int secret_imported; int secret_unchanged; @@ -100,86 +86,108 @@ public: GpgImportedKeyList importedKeys; }; -namespace GpgME -{ +namespace GpgME { -class GpgContext : public QObject -{ + class GpgContext : public QObject { Q_OBJECT -public: - GpgContext(); // Constructor - ~GpgContext(); // Destructor - GpgImportInformation importKey(QByteArray inBuffer); - bool exportKeys(QStringList *uidList, QByteArray *outBuffer); - void generateKey(QString *params); - GpgKeyList listKeys(); - void deleteKeys(QStringList *uidList); - bool encrypt(QStringList *uidList, const QByteArray &inBuffer, - QByteArray *outBuffer); - bool decrypt(const QByteArray &inBuffer, QByteArray *outBuffer); - void clearPasswordCache(); - void exportSecretKey(QString uid, QByteArray *outBuffer); - gpgme_key_t getKeyDetails(QString uid); - gpgme_signature_t verify(QByteArray *inBuffer, QByteArray *sigBuffer = NULL); + public: + GpgContext(); // Constructor + ~GpgContext() override; // Destructor + GpgImportInformation importKey(QByteArray inBuffer); + + bool exportKeys(QStringList *uidList, QByteArray *outBuffer); + + void generateKey(QString *params); + + GpgKeyList listKeys(); + + void deleteKeys(QStringList *uidList); + + bool encrypt(QStringList *uidList, const QByteArray &inBuffer, + QByteArray *outBuffer); + + bool decrypt(const QByteArray &inBuffer, QByteArray *outBuffer); + + void clearPasswordCache(); + + void exportSecretKey(QString uid, QByteArray *outBuffer); + + gpgme_key_t getKeyDetails(QString uid); + + gpgme_signature_t verify(QByteArray *inBuffer, QByteArray *sigBuffer = nullptr); + // void decryptVerify(QByteArray in); - bool sign(QStringList *uidList, const QByteArray &inBuffer, QByteArray *outBuffer, bool detached = false); - /** - * @details If text contains PGP-message, put a linebreak before the message, - * so that gpgme can decrypt correctly - * - * @param in Pointer to the QBytearray to check. - */ - void preventNoDataErr(QByteArray *in); - - GpgKey getKeyByFpr(QString fpr); - GpgKey getKeyById(QString id); - - static QString gpgErrString(gpgme_error_t err); - static QString getGpgmeVersion(); - - /** - * @brief - * - * @param text - * @return \li 2, if the text is completly signed, - * \li 1, if the text is partially signed, - * \li 0, if the text is not signed at all. - */ - int textIsSigned(const QByteArray &text); - QString beautifyFingerprint(QString fingerprint); - -signals: - void signalKeyDBChanged(); - -private slots: - void slotRefreshKeyList(); - -private: - gpgme_ctx_t mCtx; - gpgme_data_t in, out; - gpgme_error_t err; - gpgme_error_t readToBuffer(gpgme_data_t in, QByteArray *outBuffer); - QByteArray mPasswordCache; - QSettings settings; - bool debug; - GpgKeyList mKeyList; - int checkErr(gpgme_error_t err) const; - int checkErr(gpgme_error_t err, QString comment) const; - - static gpgme_error_t passphraseCb(void *hook, const char *uid_hint, - const char *passphrase_info, - int last_was_bad, int fd); - gpgme_error_t passphrase(const char *uid_hint, - const char *passphrase_info, - int last_was_bad, int fd); - - void executeGpgCommand(QStringList arguments, - QByteArray *stdOut, - QByteArray *stdErr); - QString gpgBin; - QString gpgKeys; -}; + bool sign(QStringList *uidList, const QByteArray &inBuffer, QByteArray *outBuffer, bool detached = false); + + /** + * @details If text contains PGP-message, put a linebreak before the message, + * so that gpgme can decrypt correctly + * + * @param in Pointer to the QBytearray to check. + */ + void preventNoDataErr(QByteArray *in); + + GpgKey getKeyByFpr(QString fpr); + + GpgKey getKeyById(QString id); + + static QString gpgErrString(gpgme_error_t err); + + static QString getGpgmeVersion(); + + /** + * @brief + * + * @param text + * @return \li 2, if the text is completly signed, + * \li 1, if the text is partially signed, + * \li 0, if the text is not signed at all. + */ + int textIsSigned(const QByteArray &text); + + QString beautifyFingerprint(QString fingerprint); + + signals: + + void signalKeyDBChanged(); + + private slots: + + void slotRefreshKeyList(); + + private: + gpgme_ctx_t mCtx; + gpgme_data_t in; + [[maybe_unused]] gpgme_data_t out; + gpgme_error_t err; + + gpgme_error_t readToBuffer(gpgme_data_t in, QByteArray *outBuffer); + + QByteArray mPasswordCache; + QSettings settings; + [[maybe_unused]] bool debug; + GpgKeyList mKeyList; + + [[nodiscard]] int checkErr(gpgme_error_t err) const; + + [[nodiscard]] int checkErr(gpgme_error_t err, QString comment) const; + + static gpgme_error_t passphraseCb(void *hook, const char *uid_hint, + const char *passphrase_info, + int last_was_bad, int fd); + + gpgme_error_t passphrase(const char *uid_hint, + const char *passphrase_info, + int last_was_bad, int fd); + + void executeGpgCommand(QStringList arguments, + QByteArray *stdOut, + QByteArray *stdErr); + + QString gpgBin; + QString gpgKeys; + }; } // namespace GpgME #endif // __SGPGMEPP_CONTEXT_H__ diff --git a/include/helppage.h b/include/helppage.h index 22aa9b13..d911e391 100644 --- a/include/helppage.h +++ b/include/helppage.h @@ -22,23 +22,19 @@ #ifndef HELPPAGE_H #define HELPPAGE_H -#include <QWidget> -#include <QTextBrowser> -#include <QVBoxLayout> -#include <QSettings> -#include <QFile> -#include <QLocale> - -class HelpPage : public QWidget -{ - Q_OBJECT +#include <GPG4USB.h> + +class HelpPage : public QWidget { +Q_OBJECT public: - explicit HelpPage(const QString path, QWidget *parent = 0); + explicit HelpPage(QString path, QWidget *parent = nullptr); + QTextBrowser *getBrowser(); signals: public slots: + void slotOpenUrl(QUrl url); private: diff --git a/include/keydetailsdialog.h b/include/keydetailsdialog.h index 2774fe23..851f5def 100644 --- a/include/keydetailsdialog.h +++ b/include/keydetailsdialog.h @@ -27,22 +27,30 @@ QT_BEGIN_NAMESPACE class QDateTime; + class QVBoxLayout; + class QHBoxLayout; + class QDialogButtonBox; + class QDialog; + class QGroupBox; + class QLabel; + class QGridLayout; + class QPushButton; + QT_END_NAMESPACE -class KeyDetailsDialog : public QDialog -{ - Q_OBJECT +class KeyDetailsDialog : public QDialog { +Q_OBJECT public: - KeyDetailsDialog(GpgME::GpgContext* ctx, gpgme_key_t key, QWidget *parent = 0); + KeyDetailsDialog(GpgME::GpgContext *ctx, gpgme_key_t key, QWidget *parent = nullptr); /** * @details Return QString with a space inserted at every fourth character @@ -52,6 +60,7 @@ public: static QString beautifyFingerprint(QString fingerprint); private slots: + /** * @details Export the key to a file, which is choosen in a file dialog */ diff --git a/include/keygendialog.h b/include/keygendialog.h index b3f41833..b52a8d86 100644 --- a/include/keygendialog.h +++ b/include/keygendialog.h @@ -24,18 +24,13 @@ #include "keygenthread.h" #include "gpgcontext.h" -#include <QtGui> -QT_BEGIN_NAMESPACE -class QDateTime; -class QDialogButtonBox; -class QDialog; -class QGridLayout; -QT_END_NAMESPACE -class KeyGenDialog : public QDialog -{ - Q_OBJECT +class KeyGenDialog : public QDialog { +Q_OBJECT + + +public: /** * @details Constructor of this class @@ -44,8 +39,7 @@ class KeyGenDialog : public QDialog * @param key The key to show details of * @param parent The parent of this widget */ - public: - KeyGenDialog(GpgME::GpgContext* ctx, QWidget *parent = 0); + explicit KeyGenDialog(GpgME::GpgContext *ctx, QWidget *parent = nullptr); private: void generateKeyDialog(); @@ -58,8 +52,8 @@ private: int checkPassWordStrength(); GpgME::GpgContext *mCtx; /** The current gpg context */ - KeyGenThread *keyGenThread; /** Thread for key generation */ - QStringList errorMessages; /** List of errors occuring when checking entries of lineedits */ + __attribute__((unused)) KeyGenThread *keyGenThread; /** Thread for key generation */ + __attribute__((unused)) QStringList errorMessages; /** List of errors occuring when checking entries of lineedits */ QDialogButtonBox *buttonBox; /** Box for standardbuttons */ QLabel *errorLabel; /** Label containing error message */ QLineEdit *nameEdit; /** Lineedit for the keys name */ @@ -74,6 +68,7 @@ private: QSlider *pwStrengthSlider; /** Slider showing the password strength */ private slots: + /** * @details when expirebox was checked/unchecked, enable/disable the expiration date box */ @@ -90,4 +85,5 @@ private slots: void slotKeyGenAccept(); }; + #endif // __KEYGENDIALOG_H__ diff --git a/include/keygenthread.h b/include/keygenthread.h index 6fc61e96..839111bd 100644 --- a/include/keygenthread.h +++ b/include/keygenthread.h @@ -23,34 +23,32 @@ #define __KEYGENTHREAD_H__ #include "gpgcontext.h" -#include <qthread.h> -#include <iostream> -#include <string> -#include <cmath> -#include <QtGui> + QT_BEGIN_NAMESPACE class QMessageBox; + QT_END_NAMESPACE -class KeyGenThread : public QThread -{ - Q_OBJECT +class KeyGenThread : public QThread { +Q_OBJECT public: KeyGenThread(QString keyGenParams, GpgME::GpgContext *ctx); signals: + void signalKeyGenerated(); private: QString keyGenParams; GpgME::GpgContext *mCtx; - bool abort; + [[maybe_unused]] bool abort; QMutex mutex; protected: void run(); }; + #endif // __KEYGENTHREAD_H__ diff --git a/include/keyimportdetaildialog.h b/include/keyimportdetaildialog.h index dde1f54a..cace45dd 100644 --- a/include/keyimportdetaildialog.h +++ b/include/keyimportdetaildialog.h @@ -23,12 +23,7 @@ #define __KEYIMPORTDETAILSDIALOG_H__ #include "gpgcontext.h" -#include <gpgme.h> -QT_BEGIN_NAMESPACE -class QGridLayout; -class QDialogButtonBox; -QT_END_NAMESPACE class KeyImportDetailDialog : public QDialog { @@ -39,7 +34,6 @@ public: private: void createGeneralInfoBox(); - void createKeyInfoBox(); void createKeysTable(); void createButtonBox(); QString getStatusString(int keyStatus); diff --git a/include/keylist.h b/include/keylist.h index 46663862..428486fb 100644 --- a/include/keylist.h +++ b/include/keylist.h @@ -22,55 +22,59 @@ #ifndef __KEYLIST_H__ #define __KEYLIST_H__ -#include <include/GPG4USB.h> - #include "gpgcontext.h" #include "keyimportdetaildialog.h" -QT_BEGIN_NAMESPACE -class QWidget; -class QVBoxLayout; -class QLabel; -class QTableWidget; -class QMenu; -QT_END_NAMESPACE -class KeyList : public QWidget -{ - Q_OBJECT +class KeyList : public QWidget { +Q_OBJECT public: - KeyList(GpgME::GpgContext *ctx, QWidget *parent = 0); + explicit KeyList(GpgME::GpgContext *ctx, QWidget *parent = nullptr); + void setColumnWidth(int row, int size); + void addMenuAction(QAction *act); QStringList *getChecked(); + QStringList *getPrivateChecked(); + QStringList *getAllPrivateKeys(); void setChecked(QStringList *keyIds); + //QStringList *getPrivateChecked(); QStringList *getSelected(); + void markKeys(QStringList *keyIds); + bool containsPrivateKeys(); public slots: + void slotRefresh(); + void uploadKeyToServer(QByteArray *keys); private: void importKeys(QByteArray inBuffer); + GpgME::GpgContext *mCtx; QTableWidget *mKeyList; QMenu *popupMenu; QNetworkAccessManager *qnam; private slots: + void uploadFinished(); protected: - void contextMenuEvent(QContextMenuEvent *event); - void dragEnterEvent(QDragEnterEvent *event); - void dropEvent(QDropEvent* event);}; + void contextMenuEvent(QContextMenuEvent *event) override; + + void dragEnterEvent(QDragEnterEvent *event) override; + + void dropEvent(QDropEvent *event) override; +}; #endif // __KEYLIST_H__ diff --git a/include/keymgmt.h b/include/keymgmt.h index 22a8b66c..b0b09bd6 100755 --- a/include/keymgmt.h +++ b/include/keymgmt.h @@ -28,46 +28,51 @@ #include "keyimportdetaildialog.h" #include "keyserverimportdialog.h" #include "keygendialog.h" -#include <QtGui> -QT_BEGIN_NAMESPACE -class QMainWindow; -class iostream; -class QFileDialog; -class QIcon; -class QAction; -class QApplication; -QT_END_NAMESPACE -class KeyMgmt : public QMainWindow -{ - Q_OBJECT +class KeyMgmt : public QMainWindow { +Q_OBJECT public: - KeyMgmt(GpgME::GpgContext* ctx, QWidget *parent = 0); + explicit KeyMgmt(GpgME::GpgContext *ctx, QWidget *parent = nullptr); + QAction *importKeyFromClipboardAct; QAction *importKeyFromFileAct; QAction *importKeyFromKeyServerAct; public slots: + void slotImportKeyFromFile(); + void slotImportKeyFromClipboard(); + void slotImportKeyFromKeyServer(); + void slotImportKeys(QByteArray inBuffer); + void slotExportKeyToFile(); + void slotExportKeyToClipboard(); + void slotDeleteSelectedKeys(); + void slotDeleteCheckedKeys(); + void slotGenerateKeyDialog(); + void slotShowKeyDetails(); signals: + void signalStatusBarChanged(QString); private: void createMenus(); + void createActions(); + void createToolBars(); + void deleteKeysWithWarning(QStringList *uidList); KeyList *mKeyList; @@ -82,11 +87,11 @@ private: QAction *generateKeyDialogAct; QAction *closeAct; QAction *showKeyDetailsAct; - QMessageBox msgbox; + [[maybe_unused]] QMessageBox msgbox; KeyServerImportDialog *importDialog; protected: - void closeEvent(QCloseEvent *event); + void closeEvent(QCloseEvent *event) override; }; #endif // __KEYMGMT_H__ diff --git a/include/keyserverimportdialog.h b/include/keyserverimportdialog.h index bd13cd7b..7c79764b 100644 --- a/include/keyserverimportdialog.h +++ b/include/keyserverimportdialog.h @@ -23,53 +23,42 @@ #ifndef __KEYSERVERIMPORTDIALOG_H__ #define __KEYSERVERIMPORTDIALOG_H__ -#include <include/GPG4USB.h> - #include "gpgcontext.h" #include "keyimportdetaildialog.h" #include "keylist.h" -QT_BEGIN_NAMESPACE -class QDialog; -class QDir; -class QUrl; -class QtGui; -class QPixmap; -class QNetworkReply; -class QComboBox; -class QLabel; -class QPushButton; -class QTableWidget; -class QTableWidgetItem; -class QLineEdit; -class QPalette; -class QTreeWidget; -class QTreeWidgetItem; -QT_END_NAMESPACE - -class KeyServerImportDialog : public QDialog -{ - Q_OBJECT + +class KeyServerImportDialog : public QDialog { +Q_OBJECT public: - KeyServerImportDialog(GpgME::GpgContext *ctx, KeyList *keyList, QWidget *parent = 0); + KeyServerImportDialog(GpgME::GpgContext *ctx, KeyList *keyList, QWidget *parent = nullptr); + void slotImport(QStringList keyIds); + void slotImport(QStringList keyIds, QUrl keyserverUrl); private slots: + void slotImport(); + void slotSearchFinished(); + void slotImportFinished(); + void slotSearch(); private: void createKeysTable(); + void setMessage(const QString &text, bool error); - void close(); + void importKeys(QByteArray inBuffer); QPushButton *createButton(const QString &text, const char *member); + QComboBox *createComboBox(); + GpgME::GpgContext *mCtx; KeyList *mKeyList; QLineEdit *searchLineEdit; @@ -82,8 +71,9 @@ private: QPushButton *importButton; QPushButton *searchButton; QTableWidget *keysTable; - QUrl url; + [[maybe_unused]] QUrl url; QNetworkAccessManager *qnam; }; + #endif // __KEYSERVERIMPORTDIALOG_H__ diff --git a/include/mainwindow.h b/include/mainwindow.h index 8f728f25..3969b842 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -22,8 +22,6 @@ #ifndef __GPGWIN_H__ #define __GPGWIN_H__ -#include <include/GPG4USB.h> - #include "gpgconstants.h" #include "attachments.h" #include "keymgmt.h" @@ -35,38 +33,13 @@ #include "findwidget.h" #include "wizard.h" -QT_BEGIN_NAMESPACE -class QMainWindow; -class QTextEdit; -class QWidget; -class QVBoxLayout; -class QGridLayout; -class iostream; -class QtGui; -class QString; -class QFileDialog; -class QStringList; -class QIcon; -class QMessageBox; -class QVBoxLayout; -class QAction; -class QMenu; -class QTextEdit; -class QComboBox; -class QPushButton; -class QRadioButton; -class QButtonGroup; -class QApplication; -class QDockWidget; -QT_END_NAMESPACE /** * @brief * */ -class MainWindow : public QMainWindow -{ - Q_OBJECT +class MainWindow : public QMainWindow { +Q_OBJECT public: /** @@ -74,7 +47,9 @@ public: * */ MainWindow(); + public slots: + void slotSetStatusBarText(QString text); protected: @@ -82,9 +57,10 @@ protected: * @details Close event shows a save dialog, if there are unsaved documents on exit. * @param event */ - void closeEvent(QCloseEvent *event); + void closeEvent(QCloseEvent *event) override; private slots: + /** * @details encrypt the text of currently active textedit-page * with the currently checked keys @@ -117,7 +93,7 @@ private slots: * @details Refresh key information of selected keys from default keyserver */ void refreshKeysFromKeyserver(); - + /** * @details upload the selected key to the keyserver */ @@ -197,7 +173,7 @@ private slots: /** * @details Open integrated help in new tab with the specified page. */ - void slotOpenHelp(const QString page); + void slotOpenHelp(QString page); /** * @details Show a warn message in status bar, if there are files in attachment folder. @@ -311,11 +287,11 @@ private: QToolBar *editToolBar; /** Toolbar holding edit actions */ QToolBar *specialEditToolBar; /** Toolbar holding special edit actions */ QToolBar *keyToolBar; /** Toolbar holding key operations */ - QToolButton* importButton; /** Toolbutton for import dropdown menu in toolbar */ - QToolButton* fileEncButton; /** Toolbutton for file cryption dropdown menu in toolbar */ + QToolButton *importButton; /** Toolbutton for import dropdown menu in toolbar */ + QToolButton *fileEncButton; /** Toolbutton for file cryption dropdown menu in toolbar */ QDockWidget *keylistDock; /** Encrypt Dock*/ QDockWidget *attachmentDock; /** Attachment Dock */ - QDialog *genkeyDialog; /** Dialog for key generation */ + [[maybe_unused]] QDialog *genkeyDialog; /** Dialog for key generation */ QAction *newTabAct; /** Action to create new tab */ QAction *switchTabUpAct; /** Action to switch tab up*/ diff --git a/include/mime.h b/include/mime.h index ed8d1fda..be25b627 100644 --- a/include/mime.h +++ b/include/mime.h @@ -22,19 +22,11 @@ #ifndef __MIME_H__ #define __MIME_H__ -#include <include/GPG4USB.h> +#include <GPG4USB.h> -#include <QHashIterator> -#include <QHash> +#include <utility> -QT_BEGIN_NAMESPACE -class QByteArray; -class QDebug; -class QTextCodec; -QT_END_NAMESPACE - -class HeadElem -{ +class HeadElem { public: QString name; QString value; @@ -47,54 +39,52 @@ public: }; -class Header -{ +class Header { public: QList<HeadElem> headElems; - Header() {} + Header() = default; - Header(QList <HeadElem> heads) { - headElems = heads; + explicit Header(QList<HeadElem> heads) { + headElems = std::move(heads); } - void setHeader(QList <HeadElem> heads) { - headElems = heads; + [[maybe_unused]] void setHeader(QList<HeadElem> heads) { + headElems = std::move(heads); } - QString getValue(QString key) { - foreach(HeadElem tmp, headElems) { - //qDebug() << "gv: " << tmp.name << ":" << tmp.value; - if (tmp.name == key) - return tmp.value; - } + QString getValue(const QString &key) { + foreach(HeadElem tmp, headElems) { + //qDebug() << "gv: " << tmp.name << ":" << tmp.value; + if (tmp.name == key) + return tmp.value; + } return ""; } - QHash<QString, QString> getParams(QString key) { - foreach(HeadElem tmp, headElems) { - //qDebug() << "gv: " << tmp.name << ":" << tmp.value; - if (tmp.name == key) - //return tmp.value; - return tmp.params; - } + [[maybe_unused]] QHash<QString, QString> getParams(const QString &key) { + foreach(HeadElem tmp, headElems) { + //qDebug() << "gv: " << tmp.name << ":" << tmp.value; + if (tmp.name == key) + //return tmp.value; + return tmp.params; + } return *(new QHash<QString, QString>()); } - QString getParam(QString key, QString pKey) { - foreach(HeadElem tmp, headElems) { - //qDebug() << "gv: " << tmp.name << ":" << tmp.value; - if (tmp.name == key) - return tmp.params.value(pKey); - } + QString getParam(const QString &key, const QString &pKey) { + foreach(HeadElem tmp, headElems) { + //qDebug() << "gv: " << tmp.name << ":" << tmp.value; + if (tmp.name == key) + return tmp.params.value(pKey); + } return ""; } }; -class MimePart -{ +class MimePart { public: Header header; QByteArray body; @@ -110,25 +100,30 @@ public: }*/ }; -class Mime -{ +class Mime { public: - Mime(QByteArray *message); // Constructor + explicit Mime(QByteArray *message); // Constructor ~Mime(); // Destructor - static bool isMultipart(QByteArray *message); + [[maybe_unused]] static bool isMultipart(QByteArray *message); + static bool isMime(const QByteArray *message); + QList<MimePart> parts() { return mPartList; } + void splitParts(QByteArray *message); + static Header getHeader(const QByteArray *message); + static Header parseHeader(QByteArray *header); - static void quotedPrintableDecode(const QByteArray& in, QByteArray& out); + + static void quotedPrintableDecode(const QByteArray &in, QByteArray &out); private: - QByteArray *mMessage; - QByteArray *mBoundary; + [[maybe_unused]] QByteArray *mMessage; + [[maybe_unused]] QByteArray *mBoundary; QList<MimePart> mPartList; }; diff --git a/include/quitdialog.h b/include/quitdialog.h index 5fff5527..b0558d27 100755 --- a/include/quitdialog.h +++ b/include/quitdialog.h @@ -22,28 +22,25 @@ #ifndef __QUITDIALOG_H__ #define __QUITDIALOG_H__ -#include <include/GPG4USB.h> -#include <QtGui> +#include <GPG4USB.h> -QT_BEGIN_NAMESPACE -class QTableWidget; -QT_END_NAMESPACE - -class QuitDialog : public QDialog -{ - Q_OBJECT +class QuitDialog : public QDialog { +Q_OBJECT public: - QuitDialog(QWidget *parent,QHash<int, QString> unsavedDocs); + QuitDialog(QWidget *parent, QHash<int, QString> unsavedDocs); + bool isDiscarded(); - QList <int> getTabIdsToSave(); + + QList<int> getTabIdsToSave(); private slots: + void slotMyDiscard(); private: - QAction *closeAct; - QLabel *nameLabel; + [[maybe_unused]] QAction *closeAct; + [[maybe_unused]] QLabel *nameLabel; bool discarded; QTableWidget *mFileList; }; diff --git a/include/settingsdialog.h b/include/settingsdialog.h index 0b5f1642..572a7aad 100755 --- a/include/settingsdialog.h +++ b/include/settingsdialog.h @@ -24,192 +24,190 @@ #include "keylist.h" -#include <QHash> -#include <QWidget> -#include <QtGui> - -QT_BEGIN_NAMESPACE -class QDialog; -class QRadioButton; -class QDialogButtonBox; -class QHBoxLayout; -class QVBoxLayout; -class QComboBox; -class QCheckBox; -class QDebug; -class QSettings; -class QApplication; -class QDir; -class QTranslator; -class QLabel; -class QButtonGroup; -class QGroupBox; -class QFileInfo; -class QTabWidget; -QT_END_NAMESPACE - -class GeneralTab : public QWidget - { - Q_OBJECT - - public: - GeneralTab(GpgME::GpgContext *ctx, QWidget *parent = 0); - void setSettings(); - void applySettings(); - - private: - QCheckBox *rememberPasswordCheckBox; - QCheckBox *importConfirmationcheckBox; - QCheckBox *saveCheckedKeysCheckBox; - QCheckBox *importConfirmationCheckBox; - QComboBox *langSelectBox; - QComboBox *ownKeySelectBox; - QHash<QString, QString> lang; - QHash<QString, QString> keyIds; - QString ownKeyId; - KeyList *mKeyList; - GpgME::GpgContext *mCtx; /** The current gpg context */ +class GeneralTab : public QWidget { +Q_OBJECT + +public: + explicit GeneralTab(GpgME::GpgContext *ctx, QWidget *parent = nullptr); + + void setSettings(); + + void applySettings(); + +private: + QCheckBox *rememberPasswordCheckBox; + [[maybe_unused]] QCheckBox *importConfirmationcheckBox; + QCheckBox *saveCheckedKeysCheckBox; + QCheckBox *importConfirmationCheckBox; + QComboBox *langSelectBox; + QComboBox *ownKeySelectBox; + QHash<QString, QString> lang; + QHash<QString, QString> keyIds; + QString ownKeyId; + KeyList *mKeyList; + GpgME::GpgContext *mCtx; /** The current gpg context */ private slots: + void slotOwnKeyIdChanged(); + void slotLanguageChanged(); signals: + + void signalRestartNeeded(bool needed); + +}; + +class MimeTab : public QWidget { +Q_OBJECT + +public: + explicit MimeTab(QWidget *parent = nullptr); + + void setSettings(); + + void applySettings(); + +private: + QCheckBox *mimeParseCheckBox; + QCheckBox *mimeQPCheckBox; + QCheckBox *mimeOpenAttachmentCheckBox; + +signals: + + void signalRestartNeeded(bool needed); + +}; + +class AppearanceTab : public QWidget { +Q_OBJECT + +public: + //void setSettings(); + explicit AppearanceTab(QWidget *parent = nullptr); + + void setSettings(); + + void applySettings(); + +private: + QButtonGroup *iconStyleGroup; + QRadioButton *iconSizeSmall; + QRadioButton *iconSizeMedium; + QRadioButton *iconSizeLarge; + QButtonGroup *iconSizeGroup; + QRadioButton *iconTextButton; + QRadioButton *iconIconsButton; + QRadioButton *iconAllButton; + QCheckBox *windowSizeCheckBox; + +signals: + void signalRestartNeeded(bool needed); }; - class MimeTab : public QWidget - { - Q_OBJECT - - public: - MimeTab(QWidget *parent = 0); - void setSettings(); - void applySettings(); - - private: - QCheckBox *mimeParseCheckBox; - QCheckBox *mimeQPCheckBox; - QCheckBox *mimeOpenAttachmentCheckBox; - - signals: - void signalRestartNeeded(bool needed); - - }; - - class AppearanceTab : public QWidget - { - Q_OBJECT - - public: - //void setSettings(); - AppearanceTab(QWidget *parent = 0); - void setSettings(); - void applySettings(); - - private: - QButtonGroup *iconStyleGroup; - QRadioButton *iconSizeSmall; - QRadioButton *iconSizeMedium; - QRadioButton *iconSizeLarge; - QButtonGroup *iconSizeGroup; - QRadioButton *iconTextButton; - QRadioButton *iconIconsButton; - QRadioButton *iconAllButton; - QCheckBox *windowSizeCheckBox; - - signals: - void signalRestartNeeded(bool needed); - - }; - - class KeyserverTab : public QWidget - { - Q_OBJECT - - public: - KeyserverTab(QWidget *parent = 0); +class KeyserverTab : public QWidget { +Q_OBJECT + +public: + explicit KeyserverTab(QWidget *parent = nullptr); + void setSettings(); + void applySettings(); - private: +private: QComboBox *comboBox; QLineEdit *newKeyServerEdit; - private slots: +private slots: + void addKeyServer(); - signals: +signals: + void signalRestartNeeded(bool needed); - }; +}; - class AdvancedTab : public QWidget - { - Q_OBJECT +class AdvancedTab : public QWidget { +Q_OBJECT - public: - AdvancedTab(QWidget *parent = 0); - void setSettings(); - void applySettings(); +public: + explicit AdvancedTab(QWidget *parent = nullptr); - private: - QCheckBox *steganoCheckBox; + void setSettings(); - signals: - void signalRestartNeeded(bool needed); + void applySettings(); - }; +private: + QCheckBox *steganoCheckBox; - class GpgPathsTab : public QWidget - { - Q_OBJECT - public: - GpgPathsTab(QWidget *parent = 0); - void applySettings(); +signals: + + void signalRestartNeeded(bool needed); + +}; + +class GpgPathsTab : public QWidget { +Q_OBJECT +public: + explicit GpgPathsTab(QWidget *parent = nullptr); + + void applySettings(); private: - QString getRelativePath(const QString dir1,const QString dir2); + QString getRelativePath(QString dir1, QString dir2); + QString defKeydbPath; /** The default keydb path used by gpg4usb */ QString accKeydbPath; /** The currently used keydb path */ QLabel *keydbLabel; + void setSettings(); - private slots: - QString chooseKeydbDir(); - void setKeydbPathToDefault(); +private slots: + + QString chooseKeydbDir(); + + void setKeydbPathToDefault(); + +}; - }; +class SettingsDialog : public QDialog { +Q_OBJECT - class SettingsDialog : public QDialog -{ - Q_OBJECT +public: + explicit SettingsDialog(GpgME::GpgContext *ctx, QWidget *parent = nullptr); - public: - SettingsDialog(GpgME::GpgContext *ctx, QWidget *parent = 0); GeneralTab *generalTab; MimeTab *mimeTab; AppearanceTab *appearanceTab; KeyserverTab *keyserverTab; AdvancedTab *advancedTab; GpgPathsTab *gpgPathsTab; + static QHash<QString, QString> listLanguages(); - public slots: +public slots: + void slotAccept(); - signals: +signals: + void signalRestartNeeded(bool needed); - private: +private: QTabWidget *tabWidget; QDialogButtonBox *buttonBox; GpgME::GpgContext *mCtx; /** The current gpg context */ bool restartNeeded; + bool getRestartNeeded(); - private slots: +private slots: + void slotSetRestartNeeded(bool needed); }; diff --git a/include/textedit.h b/include/textedit.h index 12e4970e..92a453c3 100644 --- a/include/textedit.h +++ b/include/textedit.h @@ -26,28 +26,12 @@ #include "helppage.h" #include "quitdialog.h" -QT_BEGIN_NAMESPACE -class QDebug; -class QtGui; -class QFileDialog; -class QMessageBox; -class QFileInfo; -class QApplication; -class QFile; -class QTextEdit; -class QFileDialog; -class QMessageBox; -class QWidget; -class QString; -class QTabWidget; -QT_END_NAMESPACE /** * @brief TextEdit class */ -class TextEdit : public QWidget -{ - Q_OBJECT +class TextEdit : public QWidget { +Q_OBJECT public: /** * @brief @@ -73,14 +57,15 @@ public: bool maybeSaveAnyTab(); int tabCount(); + /** * @details textpage of the currently activated tab * @return \li reference to QTextEdit if tab has one * \li 0 otherwise (e.g. if helppage) */ - QTextEdit* curTextPage(); + QTextEdit *curTextPage(); - QTextBrowser* curHelpPage(); + QTextBrowser *curHelpPage(); /** * @details List of currently unsaved tabs. @@ -91,6 +76,7 @@ public: QTabWidget *tabWidget; /** Widget containing the tabs of the editor */ public slots: + /** * @details Return pointer to the currently activated tabpage. * @@ -182,12 +168,6 @@ private: /** * @brief * - */ - bool maybeSaveFile(); - - /** - * @brief - * * @param askToSave */ bool maybeSaveCurrentTab(bool askToSave); @@ -199,6 +179,7 @@ private: int countPage; /* TODO */ private slots: + /** * @details Remove the tab with given index * @@ -240,6 +221,7 @@ private slots: void slotRedo(); void slotZoomIn(); + void slotZoomOut(); /**************************************************************************************** * Name: selectAll @@ -272,4 +254,5 @@ protected: */ bool saveFile(const QString &fileName); }; + #endif // __TEXTEDIT_H__ diff --git a/include/verifydetailsdialog.h b/include/verifydetailsdialog.h index b138f466..439e8596 100644 --- a/include/verifydetailsdialog.h +++ b/include/verifydetailsdialog.h @@ -24,15 +24,15 @@ #include "editorpage.h" #include "verifykeydetailbox.h" -#include <QDialog> -class VerifyDetailsDialog : public QDialog -{ - Q_OBJECT +class VerifyDetailsDialog : public QDialog { +Q_OBJECT public: - explicit VerifyDetailsDialog(QWidget *parent, GpgME::GpgContext* ctx, KeyList* mKeyList, QByteArray* inputData, QByteArray* inputSignature = 0); + explicit VerifyDetailsDialog(QWidget *parent, GpgME::GpgContext *ctx, KeyList *mKeyList, QByteArray *inputData, + QByteArray *inputSignature = nullptr); private slots: + void slotRefresh(); private: @@ -40,9 +40,9 @@ private: KeyList *mKeyList; QHBoxLayout *mainLayout; QWidget *mVbox; - QByteArray* mInputData; /** Data to be verified */ - QByteArray* mInputSignature; /** Data to be verified */ - QDialogButtonBox* buttonBox; + QByteArray *mInputData; /** Data to be verified */ + QByteArray *mInputSignature; /** Data to be verified */ + QDialogButtonBox *buttonBox; }; #endif // __VERIFYDETAILSDIALOG_H__ diff --git a/include/verifykeydetailbox.h b/include/verifykeydetailbox.h index 29d198e3..7563b92c 100644 --- a/include/verifykeydetailbox.h +++ b/include/verifykeydetailbox.h @@ -24,22 +24,23 @@ #include "keylist.h" #include "keyserverimportdialog.h" -#include <QDialog> -#include <QGroupBox> -class VerifyKeyDetailBox: public QGroupBox -{ - Q_OBJECT +class VerifyKeyDetailBox : public QGroupBox { +Q_OBJECT public: - explicit VerifyKeyDetailBox(QWidget *parent, GpgME::GpgContext* ctx, KeyList* mKeyList, gpgme_signature_t signature); + explicit VerifyKeyDetailBox(QWidget *parent, GpgME::GpgContext *ctx, KeyList *mKeyList, + gpgme_signature_t signature); private slots: + void slotImportFormKeyserver(); private: - GpgME::GpgContext* mCtx; - KeyList* mKeyList; + GpgME::GpgContext *mCtx; + KeyList *mKeyList; + QString beautifyFingerprint(QString fingerprint); + QString fpr; }; diff --git a/include/verifynotification.h b/include/verifynotification.h index 60e55f91..dd7f2600 100644 --- a/include/verifynotification.h +++ b/include/verifynotification.h @@ -24,33 +24,33 @@ #include "editorpage.h" #include "verifydetailsdialog.h" -#include <gpgme.h> -#include <QWidget> QT_BEGIN_NAMESPACE class QLabel; + class QHBoxLayout; + class QMenu; + class QPushButton; + QT_END_NAMESPACE /** * @details Enumeration for the status of Verifylabel */ -typedef enum -{ +typedef enum { VERIFY_ERROR_OK = 0, VERIFY_ERROR_WARN = 1, VERIFY_ERROR_CRITICAL = 2, - VERIFY_ERROR_NEUTRAL =3, -} verify_label_status; + VERIFY_ERROR_NEUTRAL [[maybe_unused]] = 3, +} verify_label_status; /** * @brief Class for handling the verifylabel shown at buttom of a textedit-page */ -class VerifyNotification : public QWidget -{ - Q_OBJECT +class VerifyNotification : public QWidget { +Q_OBJECT public: /** * @brief @@ -58,7 +58,8 @@ public: * @param ctx The GPGme-Context * @param parent The parent widget */ - explicit VerifyNotification(QWidget *parent, GpgME::GpgContext *ctx, KeyList *keyList,QTextEdit *edit); + explicit VerifyNotification(QWidget *parent, GpgME::GpgContext *ctx, KeyList *keyList, QTextEdit *edit); + /** * @details Set the text and background-color of verify notification. * @@ -77,6 +78,7 @@ public: public slots: + /** * @details Import the keys contained in keysNotInList from keyserver * @@ -102,8 +104,9 @@ private: GpgME::GpgContext *mCtx; /** GpgME Context */ KeyList *mKeyList; /** Table holding the keys */ QTextEdit *mTextpage; /** Textedit associated to the notification */ - QVector<QString> verifyDetailStringVector; /** Vector containing the text for labels in verifydetaildialog */ - QVector<verify_label_status> verifyDetailStatusVector; /** Vector containing the status for labels in verifydetaildialog */ + [[maybe_unused]] QVector<QString> verifyDetailStringVector; /** Vector containing the text for labels in verifydetaildialog */ + [[maybe_unused]] QVector<verify_label_status> verifyDetailStatusVector; /** Vector containing the status for labels in verifydetaildialog */ }; + #endif // __VERIFYNOTIFICATION_H__ diff --git a/include/wizard.h b/include/wizard.h index 4ed34c19..41736e56 100644 --- a/include/wizard.h +++ b/include/wizard.h @@ -23,84 +23,94 @@ #ifndef WIZARD_H #define WIZARD_H -#include <QWizard> #include "keygendialog.h" #include "keymgmt.h" #include "gpgconstants.h" #include "settingsdialog.h" class QCheckBox; + class QLabel; + class QLineEdit; + class QRadioButton; -class Wizard : public QWizard -{ - Q_OBJECT +class Wizard : public QWizard { +Q_OBJECT Q_ENUMS(WizardPages) public: - enum WizardPages { Page_Intro, Page_Choose, Page_ImportFromGpg4usb, Page_ImportFromGnupg, Page_GenKey, - Page_Conclusion }; + enum WizardPages { + Page_Intro, Page_Choose, Page_ImportFromGpg4usb, Page_ImportFromGnupg, Page_GenKey, + Page_Conclusion + }; - Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = 0); - static bool importPubAndSecKeysFromDir(const QString dir, KeyMgmt *keyMgmt); + Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = nullptr); + + static bool importPubAndSecKeysFromDir(QString dir, KeyMgmt *keyMgmt); private: GpgME::GpgContext *mCtx; KeyMgmt *mKeyMgmt; private slots: + void slotWizardAccepted(); signals: + void signalOpenHelp(QString page); }; -class IntroPage : public QWizardPage -{ - Q_OBJECT +class IntroPage : public QWizardPage { +Q_OBJECT public: - IntroPage(QWidget *parent = 0); - QHash<QString,QString> languages; - int nextId() const; + explicit IntroPage(QWidget *parent = nullptr); + + QHash<QString, QString> languages; + + [[nodiscard]] int nextId() const override; private slots: + void slotLangChange(QString lang); }; -class ChoosePage : public QWizardPage -{ - Q_OBJECT +class ChoosePage : public QWizardPage { +Q_OBJECT public: - ChoosePage(QWidget *parent = 0); + explicit ChoosePage(QWidget *parent = nullptr); private slots: - void slotJumpPage(const QString& page); + + void slotJumpPage(const QString &page); private: - int nextId() const; + [[nodiscard]] int nextId() const override; + int nextPage; }; -class ImportFromGpg4usbPage : public QWizardPage -{ - Q_OBJECT +class ImportFromGpg4usbPage : public QWizardPage { +Q_OBJECT public: - ImportFromGpg4usbPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = 0); + ImportFromGpg4usbPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = nullptr); private slots: + /** * @details Import keys from gnupg-homedir, private or/and public depend on the checked boxes */ void slotImportFromOlderGpg4usb(); + bool slotImportConfFromGpg4usb(QString dir); private: - int nextId() const; + [[nodiscard]] int nextId() const override; KeyMgmt *mKeyMgmt; GpgME::GpgContext *mCtx; @@ -108,14 +118,14 @@ private: QCheckBox *gpg4usbConfigCheckBox; }; -class ImportFromGnupgPage : public QWizardPage -{ - Q_OBJECT +class ImportFromGnupgPage : public QWizardPage { +Q_OBJECT public: - ImportFromGnupgPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = 0); + ImportFromGnupgPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent = nullptr); private slots: + /** * @details Import keys from gnupg-homedir, private or/and public depend on the checked boxes */ @@ -123,7 +133,8 @@ private slots: private: KeyMgmt *mKeyMgmt; - int nextId() const; + + [[nodiscard]] int nextId() const override; /** * @details String containing the gnupg-homedir @@ -136,28 +147,29 @@ private: QPushButton *importFromGnupgButton; }; -class KeyGenPage : public QWizardPage -{ - Q_OBJECT +class KeyGenPage : public QWizardPage { +Q_OBJECT public: - KeyGenPage(GpgME::GpgContext *ctx, QWidget *parent = 0); - int nextId() const; + explicit KeyGenPage(GpgME::GpgContext *ctx, QWidget *parent = nullptr); + + [[nodiscard]] int nextId() const override; private slots: + void slotGenerateKeyDialog(); private: GpgME::GpgContext *mCtx; }; -class ConclusionPage : public QWizardPage -{ - Q_OBJECT +class ConclusionPage : public QWizardPage { +Q_OBJECT public: - ConclusionPage(QWidget *parent = 0); - int nextId() const; + explicit ConclusionPage(QWidget *parent = nullptr); + + [[nodiscard]] int nextId() const override; private: QCheckBox *dontShowWizardCheckBox; diff --git a/src/mime.cpp b/src/mime.cpp index 30f19cf0..51e6a8cb 100644 --- a/src/mime.cpp +++ b/src/mime.cpp @@ -150,7 +150,7 @@ Header Mime::getHeader(const QByteArray *message) { return parseHeader(&header); } -bool Mime::isMultipart(QByteArray *message) +[[maybe_unused]] bool Mime::isMultipart(QByteArray *message) { return message->startsWith("Content-Type: multipart/mixed;"); } |