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 
151  bool isApplicationNeedRestart();
152 
153  signals:
158  void SignalKeyStatusUpdated();
159 
164  void SignalGnupgNotInstall();
165 
171 
176  void SignalNeedUserInputPassphrase();
177 
182  void SignalUserInputPassphraseDone(QString passphrase);
183 
188  void SignalRestartApplication(int);
189 
190  public slots:
197  void SlotImportKeys(QWidget* parent, const std::string& in_buffer);
198 
204  void SlotImportKeyFromFile(QWidget* parent);
205 
211  void SlotImportKeyFromKeyServer(QWidget* parent);
212 
218  void SlotImportKeyFromClipboard(QWidget* parent);
219 
227  static void SlotImportKeyFromKeyServer(
228  const GpgFrontend::KeyIdArgsList& key_ids,
229  const GpgFrontend::UI::CommonUtils::ImportCallbackFunctiopn& callback);
230 
238  const QStringList& arguments,
239  const std::function<void(QProcess*)>& interact_func);
240 
247  void SlotExecuteCommand(const std::string& cmd, const QStringList& arguments,
248  const std::function<void(QProcess*)>& interact_func);
249 
254  void SlotRestartApplication(int);
255 
256  private slots:
257 
262  void slot_update_key_status();
263 
268  void slot_popup_passphrase_input_dialog();
269 
270  private:
271  static std::unique_ptr<CommonUtils> instance_;
272  bool application_need_to_restart_at_once_ = false;
273 };
274 
275 } // namespace GpgFrontend::UI
276 
277 #endif // GPGFRONTEND_USER_INTERFACE_UTILS_H
Definition: UserInterfaceUtils.h:124
void SlotImportKeyFromFile(QWidget *parent)
Definition: UserInterfaceUtils.cpp:230
void SlotImportKeyFromClipboard(QWidget *parent)
Definition: UserInterfaceUtils.cpp:251
void SignalKeyDatabaseRefreshDone()
emit when the key database is refreshed
void SlotImportKeys(QWidget *parent, const std::string &in_buffer)
Definition: UserInterfaceUtils.cpp:222
CommonUtils()
Construct a new Common Utils object.
Definition: UserInterfaceUtils.cpp:155
void SlotExecuteCommand(const std::string &cmd, const QStringList &arguments, const std::function< void(QProcess *)> &interact_func)
Definition: UserInterfaceUtils.cpp:257
void slot_update_key_status()
update the key status when signal is emitted
Definition: UserInterfaceUtils.cpp:434
static CommonUtils * GetInstance()
Get the Instance object.
Definition: UserInterfaceUtils.cpp:148
void SlotImportKeyFromKeyServer(QWidget *parent)
Definition: UserInterfaceUtils.cpp:246
void SlotExecuteGpgCommand(const QStringList &arguments, const std::function< void(QProcess *)> &interact_func)
Definition: UserInterfaceUtils.cpp:289
Definition: FileReadTask.cpp:29
void refresh_info_board(InfoBoardWidget *info_board, int status, const std::string &report_text)
Definition: UserInterfaceUtils.cpp:88
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:118
void show_verify_details(QWidget *parent, InfoBoardWidget *info_board, GpgError error, const GpgVerifyResult &verify_result)
Definition: UserInterfaceUtils.cpp:56
void import_unknown_key_from_keyserver(QWidget *parent, const GpgVerifyResultAnalyse &verify_res)
Definition: UserInterfaceUtils.cpp:65
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:100
Definition: CoreCommonUtil.cpp:31