1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #include "QtMessageSender.h"
- #include "QtBootSender.h"
- #include <thread>
- #include "Widgets/BootWidget.h"
- #include "MessageSender.h"
- #include <QApplication>
- #include "SpBase.h"
- #include "memutil.h"
- int qt_gui_create_format(sp_gui_format_t** p_gui)
- {
- int result = 0;
- sp_gui_format_t* gui = ZALLOC_T(sp_gui_format_t);
- if (gui != nullptr) {
- gui->gui_inst = (void*)(new QtBootSender());
- gui->display = &qt_gui_display;
- gui->hide = &qt_gui_undisplay;
- gui->show_entity_info = &qt_gui_show_entity_info;
- gui->show_running_info = &qt_gui_show_running_info;
- gui->post_message = &qt_gui_post_message;
- *p_gui = gui;
- }
- return result;
- }
- void qt_gui_destroy_format(sp_gui_format_t* p_gui)
- {
- if (p_gui->gui_inst) {
- delete p_gui->gui_inst;
- }
- FREE(p_gui);
- }
- int qt_gui_show_running_info(void* gui, const char* msg, int type)
- {
- QtMessageInfo message{ QString(msg), TextEvent };
- QtBootSender* senderInst = (QtBootSender*)gui;
- emit senderInst->ShowMessage(message);
- return 0;
- }
- int qt_gui_show_entity_info(void* gui, const char* entity, int state)
- {
- return 0;
- }
- int qt_gui_display(void* gui)
- {
- return 0;
- }
- int qt_gui_undisplay(void* gui)
- {
- return 0;
- }
- void qt_gui_post_message(void* gui, unsigned long param1, unsigned long param2)
- {
- }
- QtMessageSender::QtMessageSender():mWinInitialized(false), sender(nullptr) {
- //sender = new QtBootSender();
- kSenderInst = new QtBootSender();
- std::thread uiThread(QtWinThread, this);
- uiThread.detach();
- Sleep(300);
- }
- QtMessageSender::~QtMessageSender()
- {
- if (sender) {
- delete sender;
- sender = nullptr;
- }
- }
- void QtMessageSender::ShowMessage(const SP::UI::MessageInfo& msg)
- {
- QtMessageInfo message{ QString(msg.content.GetData()), msg.type };
- if (kSenderInst) {
- emit kSenderInst->ShowMessage(message);
- }
- }
|