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 "ui/GpgFrontendUI.h"
35 
36 namespace GpgFrontend {
37 class GpgResultAnalyse;
38 }
39 
40 namespace GpgFrontend::UI {
41 
42 class InfoBoardWidget;
43 class TextEdit;
44 
53 void show_verify_details(QWidget* parent, InfoBoardWidget* info_board,
54  GpgError error, const GpgVerifyResult& verify_result);
55 
63  QWidget* parent, const GpgVerifyResultAnalyse& verify_res);
64 
72 void refresh_info_board(InfoBoardWidget* info_board, int status,
73  const std::string& report_text);
74 
82 void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board,
83  const GpgResultAnalyse& result_analyse);
84 
93 void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board,
94  const GpgResultAnalyse& result_analyse_a,
95  const GpgResultAnalyse& result_analyse_b);
96 
104 void process_operation(
105  QWidget* parent, const std::string& waiting_title,
106  GpgFrontend::Thread::Task::TaskRunnable func,
107  GpgFrontend::Thread::Task::TaskCallback callback = nullptr,
108  Thread::Task::DataObjectPtr data_object = nullptr);
109 
117 void import_key_from_keyserver(QWidget* parent, const std::string& key_id,
118  const std::string& key_server);
119 
124 class CommonUtils : public QWidget {
125  Q_OBJECT
126  public:
131  using ImportCallbackFunctiopn = std::function<void(
132  const std::string&, const std::string&, size_t, size_t)>;
133 
138  CommonUtils();
139 
145  static CommonUtils* GetInstance();
146 
147  signals:
152  void SignalKeyStatusUpdated();
153 
158  void SignalGnupgNotInstall();
159 
165 
170  void SignalNeedUserInputPassphrase();
171 
176  void SignalUserInputPassphraseDone(QString passphrase);
177 
178  public slots:
185  void SlotImportKeys(QWidget* parent, const std::string& in_buffer);
186 
192  void SlotImportKeyFromFile(QWidget* parent);
193 
199  void SlotImportKeyFromKeyServer(QWidget* parent);
200 
206  void SlotImportKeyFromClipboard(QWidget* parent);
207 
215  static void SlotImportKeyFromKeyServer(
216  const GpgFrontend::KeyIdArgsList& key_ids,
217  const GpgFrontend::UI::CommonUtils::ImportCallbackFunctiopn& callback);
218 
226  const QStringList& arguments,
227  const std::function<void(QProcess*)>& interact_func);
228 
235  void SlotExecuteCommand(const std::string& cmd, const QStringList& arguments,
236  const std::function<void(QProcess*)>& interact_func);
237 
238  private slots:
239 
244  void slot_update_key_status();
245 
250  void slot_popup_passphrase_input_dialog();
251 
252  private:
253  static std::unique_ptr<CommonUtils> instance_;
254 };
255 
256 } // namespace GpgFrontend::UI
257 
258 #endif // GPGFRONTEND_USER_INTERFACE_UTILS_H
Definition: UserInterfaceUtils.h:124
void SlotImportKeyFromFile(QWidget *parent)
Definition: UserInterfaceUtils.cpp:194
void SlotImportKeyFromClipboard(QWidget *parent)
Definition: UserInterfaceUtils.cpp:215
void SignalKeyDatabaseRefreshDone()
emit when the key database is refreshed
void SlotImportKeys(QWidget *parent, const std::string &in_buffer)
Definition: UserInterfaceUtils.cpp:186
CommonUtils()
Construct a new Common Utils object.
Definition: UserInterfaceUtils.cpp:150
void SlotExecuteCommand(const std::string &cmd, const QStringList &arguments, const std::function< void(QProcess *)> &interact_func)
Definition: UserInterfaceUtils.cpp:221
void slot_update_key_status()
update the key status when signal is emitted
Definition: UserInterfaceUtils.cpp:398
static CommonUtils * GetInstance()
Get the Instance object.
Definition: UserInterfaceUtils.cpp:143
void SlotImportKeyFromKeyServer(QWidget *parent)
Definition: UserInterfaceUtils.cpp:210
void SlotExecuteGpgCommand(const QStringList &arguments, const std::function< void(QProcess *)> &interact_func)
Definition: UserInterfaceUtils.cpp:253
Definition: FileReadTask.cpp:29
void refresh_info_board(InfoBoardWidget *info_board, int status, const std::string &report_text)
Definition: UserInterfaceUtils.cpp:86
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:116
void show_verify_details(QWidget *parent, InfoBoardWidget *info_board, GpgError error, const GpgVerifyResult &verify_result)
Definition: UserInterfaceUtils.cpp:54
void import_unknown_key_from_keyserver(QWidget *parent, const GpgVerifyResultAnalyse &verify_res)
Definition: UserInterfaceUtils.cpp:63
void import_key_from_keyserver(QWidget *parent, const std::string &key_id, const std::string &key_server)
void process_result_analyse(TextEdit *edit, InfoBoardWidget *info_board, const GpgResultAnalyse &result_analyse)
Definition: UserInterfaceUtils.cpp:98
Definition: CoreCommonUtil.cpp:31