GpgFrontend Project A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.

UserInterfaceUtils.h
1
29 #ifndef GPGFRONTEND_USER_INTERFACE_UTILS_H
30 #define GPGFRONTEND_USER_INTERFACE_UTILS_H
31
32 #include "core/GpgModel.h"
33 #include "core/function/result_analyse/GpgVerifyResultAnalyse.h"
34 #include "core/model/GpgKey.h"
35 #include "ui/GpgFrontendUI.h"
36
37 namespace GpgFrontend {
38 class GpgResultAnalyse;
39 }
40
41 namespace GpgFrontend::UI {
42
43 class InfoBoardWidget;
44 class TextEdit;
45
54 void show_verify_details(QWidget* parent, InfoBoardWidget* info_board,
55 GpgError error, const GpgVerifyResult& verify_result);
56
63 void import_unknown_key_from_keyserver(
64 QWidget* parent, const GpgVerifyResultAnalyse& verify_res);
65
73 void refresh_info_board(InfoBoardWidget* info_board, int status,
74 const std::string& report_text);
75
83 void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board,
84 const GpgResultAnalyse& result_analyse);
85
94 void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board,
95 const GpgResultAnalyse& result_analyse_a,
96 const GpgResultAnalyse& result_analyse_b);
97
105 void process_operation(
106 QWidget* parent, const std::string& waiting_title,
107 GpgFrontend::Thread::Task::TaskRunnable func,
108 GpgFrontend::Thread::Task::TaskCallback callback = nullptr,
109 Thread::Task::DataObjectPtr data_object = nullptr);
110
118 void import_key_from_keyserver(QWidget* parent, const std::string& key_id,
119 const std::string& key_server);
120
125 class CommonUtils : public QWidget {
126 Q_OBJECT
127 public:
132 using ImportCallbackFunctiopn = std::function<void(
133 const std::string&, const std::string&, size_t, size_t)>;
134
139 CommonUtils();
140
146 static CommonUtils* GetInstance();
147
152 bool isApplicationNeedRestart();
153
158 bool KeyExistsinFavouriteList(const GpgKey& key);
159
164 void AddKey2Favourtie(const GpgKey& key);
165
170 void RemoveKeyFromFavourite(const GpgKey& key);
171
172 signals:
177 void SignalKeyStatusUpdated();
178
183 void SignalGnupgNotInstall();
184
189 void SignalKeyDatabaseRefreshDone();
190
195 void SignalNeedUserInputPassphrase();
196
201 void SignalUserInputPassphraseDone(QString passphrase);
202
207 void SignalRestartApplication(int);
208
209 public slots:
216 void SlotImportKeys(QWidget* parent, const std::string& in_buffer);
217
223 void SlotImportKeyFromFile(QWidget* parent);
224
230 void SlotImportKeyFromKeyServer(QWidget* parent);
231
237 void SlotImportKeyFromClipboard(QWidget* parent);
238
246 static void SlotImportKeyFromKeyServer(
247 const GpgFrontend::KeyIdArgsList& key_ids,
248 const GpgFrontend::UI::CommonUtils::ImportCallbackFunctiopn& callback);
249
256 void SlotExecuteGpgCommand(
257 const QStringList& arguments,
258 const std::function<void(QProcess*)>& interact_func);
259
266 void SlotExecuteCommand(const std::string& cmd, const QStringList& arguments,
267 const std::function<void(QProcess*)>& interact_func);
268
273 void SlotRestartApplication(int);
274
275 private slots:
276
281 void slot_update_key_status();
282
287 void slot_popup_passphrase_input_dialog();
288
289 private:
290 static std::unique_ptr<CommonUtils> instance_;
291 bool application_need_to_restart_at_once_ = false;
292 };
293
294 } // namespace GpgFrontend::UI
295
296 #endif // GPGFRONTEND_USER_INTERFACE_UTILS_H
GpgFrontend::GpgKey
Definition: GpgKey.h:43
GpgFrontend::UI::CommonUtils
Definition: UserInterfaceUtils.h:125
GpgFrontend::UI::CommonUtils::SlotImportKeyFromFile
void SlotImportKeyFromFile(QWidget *parent)
Definition: UserInterfaceUtils.cpp:231
GpgFrontend::UI::CommonUtils::SlotImportKeyFromClipboard
void SlotImportKeyFromClipboard(QWidget *parent)
Definition: UserInterfaceUtils.cpp:252
GpgFrontend::UI::CommonUtils::SignalKeyDatabaseRefreshDone
void SignalKeyDatabaseRefreshDone()
emit when the key database is refreshed
GpgFrontend::UI::CommonUtils::SlotImportKeys
void SlotImportKeys(QWidget *parent, const std::string &in_buffer)
Definition: UserInterfaceUtils.cpp:223
GpgFrontend::UI::CommonUtils::CommonUtils
CommonUtils()
Construct a new Common Utils object.
Definition: UserInterfaceUtils.cpp:156
GpgFrontend::UI::CommonUtils::SlotExecuteCommand
void SlotExecuteCommand(const std::string &cmd, const QStringList &arguments, const std::function< void(QProcess *)> &interact_func)
Definition: UserInterfaceUtils.cpp:258
GpgFrontend::UI::CommonUtils::slot_update_key_status
void slot_update_key_status()
update the key status when signal is emitted
Definition: UserInterfaceUtils.cpp:435
GpgFrontend::UI::CommonUtils::GetInstance
static CommonUtils * GetInstance()
Get the Instance object.
Definition: UserInterfaceUtils.cpp:149
GpgFrontend::UI::CommonUtils::SlotImportKeyFromKeyServer
void SlotImportKeyFromKeyServer(QWidget *parent)
Definition: UserInterfaceUtils.cpp:247
GpgFrontend::UI::CommonUtils::SlotExecuteGpgCommand
void SlotExecuteGpgCommand(const QStringList &arguments, const std::function< void(QProcess *)> &interact_func)
Definition: UserInterfaceUtils.cpp:290
GpgFrontend::UI
Definition: FileReadTask.cpp:29
GpgFrontend::UI::refresh_info_board
void refresh_info_board(InfoBoardWidget *info_board, int status, const std::string &report_text)
Definition: UserInterfaceUtils.cpp:89
GpgFrontend::UI::process_operation
void process_operation(QWidget *parent, const std::string &waiting_title, const Thread::Task::TaskRunnable func, const Thread::Task::TaskCallback callback, Thread::Task::DataObjectPtr data_object)
Definition: UserInterfaceUtils.cpp:119
GpgFrontend::UI::show_verify_details
void show_verify_details(QWidget *parent, InfoBoardWidget *info_board, GpgError error, const GpgVerifyResult &verify_result)
Definition: UserInterfaceUtils.cpp:57
GpgFrontend::UI::import_unknown_key_from_keyserver
void import_unknown_key_from_keyserver(QWidget *parent, const GpgVerifyResultAnalyse &verify_res)
Definition: UserInterfaceUtils.cpp:66
GpgFrontend::UI::import_key_from_keyserver
void import_key_from_keyserver(QWidget *parent, const std::string &key_id, const std::string &key_server)
GpgFrontend::UI::process_result_analyse
void process_result_analyse(TextEdit *edit, InfoBoardWidget *info_board, const GpgResultAnalyse &result_analyse)
Definition: UserInterfaceUtils.cpp:101
GpgFrontend
Definition: CoreCommonUtil.cpp:31