You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.1 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. #include "zqui.hpp"
  2. using namespace std;
  3. #define TAG "ZQUI"
  4. /***********************************************************************************************************************
  5. * PreviewShow *
  6. ***********************************************************************************************************************/
  7. ZQUI *ZQUI::ins() {
  8. static ZQUI instance;
  9. return &instance;
  10. }
  11. void ZQUI::ishow(const char *fmt, ...) {
  12. va_list args;
  13. va_start(args, fmt);
  14. char buf[1024] = {0};
  15. vsnprintf(buf, sizeof(buf), fmt, args);
  16. va_end(args);
  17. QString text(buf);
  18. if (m_ishow) m_ishow(text);
  19. }
  20. void ZQUI::instructionPreviewClear() {
  21. if (m_instructionPreviewClear) m_instructionPreviewClear();
  22. }
  23. void ZQUI::rshow(const char *fmt, ...) {
  24. va_list args;
  25. va_start(args, fmt);
  26. char buf[1024] = {0};
  27. vsnprintf(buf, sizeof(buf), fmt, args);
  28. va_end(args);
  29. QString text(buf);
  30. if (m_reportPreviewShow) m_reportPreviewShow(text);
  31. }
  32. void ZQUI::eshow(const char *fmt, ...) {
  33. va_list args;
  34. va_start(args, fmt);
  35. char buf[1024] = {0};
  36. vsnprintf(buf, sizeof(buf), fmt, args);
  37. va_end(args);
  38. QString text(buf);
  39. if (m_exceptionUploadPreviewShow) m_exceptionUploadPreviewShow(text);
  40. }
  41. void ZQUI::rawDataPreviewShow(const char *fmt, ...) {
  42. va_list args;
  43. va_start(args, fmt);
  44. char buf[1024] = {0};
  45. vsnprintf(buf, sizeof(buf), fmt, args);
  46. va_end(args);
  47. QString text(buf);
  48. if (m_rawDataPreviewShow) m_rawDataPreviewShow(text);
  49. }
  50. void ZQUI::initialize() {
  51. qRegisterMetaType<int32_t>("int32_t");
  52. qRegisterMetaType<uint32_t>("uint32_t");
  53. qRegisterMetaType<float>("float");
  54. qRegisterMetaType<function<void()>>("function<void()>");
  55. qRegisterMetaType<QFunction>("QFunction");
  56. connect(this, SIGNAL(doinui_signal(QFunction)), this, SLOT(doinui_slot(QFunction)));
  57. }
  58. void ZQUI::doinui(function<void()> dowhat) {
  59. emit doinui_signal(QFunction([dowhat]() {
  60. if (dowhat) dowhat();
  61. }));
  62. }
  63. void ZQUI::doinui_slot(QFunction func) {
  64. if (func.get()) func.get()();
  65. }