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 
166  public slots:
173  void SlotImportKeys(QWidget* parent, const std::string& in_buffer);
174 
180  void SlotImportKeyFromFile(QWidget* parent);
181 
187  void SlotImportKeyFromKeyServer(QWidget* parent);
188 
194  void SlotImportKeyFromClipboard(QWidget* parent);
195 
203  static void SlotImportKeyFromKeyServer(
204  const GpgFrontend::KeyIdArgsList& key_ids,
205  const GpgFrontend::UI::CommonUtils::ImportCallbackFunctiopn& callback);
206 
214  const QStringList& arguments,
215  const std::function<void(QProcess*)>& interact_func);
216 
223  void SlotExecuteCommand(
224  const std::string& cmd,
225  const QStringList& arguments,
226  const std::function<void(QProcess*)>& interact_func);
227 
228  private slots:
229 
234  void slot_update_key_status();
235 
236  private:
237  static std::unique_ptr<CommonUtils> instance_;
238 };
239 
240 } // namespace GpgFrontend::UI
241 
242 #endif // GPGFRONTEND_USER_INTERFACE_UTILS_H
Definition: UserInterfaceUtils.h:124
void SlotImportKeyFromFile(QWidget *parent)
Definition: UserInterfaceUtils.cpp:189
void SlotImportKeyFromClipboard(QWidget *parent)
Definition: UserInterfaceUtils.cpp:210
void SignalKeyDatabaseRefreshDone()
emit when the key database is refreshed
void SlotImportKeys(QWidget *parent, const std::string &in_buffer)
Definition: UserInterfaceUtils.cpp:181
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:216
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:205
void SlotExecuteGpgCommand(const QStringList &arguments, const std::function< void(QProcess *)> &interact_func)
Definition: UserInterfaceUtils.cpp:251
Definition: FileReadTask.cpp:31
void refresh_info_board(InfoBoardWidget *info_board, int status, const std::string &report_text)
Definition: UserInterfaceUtils.cpp:84
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:52
void import_unknown_key_from_keyserver(QWidget *parent, const GpgVerifyResultAnalyse &verify_res)
Definition: UserInterfaceUtils.cpp:61
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:96
Definition: CoreCommonUtil.cpp:29